Roo/bootstrap/DocumentViewer.js
[roojs1] / Roo / bootstrap / DocumentViewer.js
1
2 /*
3 * Licence: LGPL
4 */
5
6 /**
7  * @class Roo.bootstrap.DocumentViewer
8  * @extends Roo.bootstrap.Component
9  * Bootstrap DocumentViewer class
10  * @cfg {Number} thumbWidth default 300
11  * @cfg {Number} thumbHeight default 300
12  * 
13  * @constructor
14  * Create a new DocumentViewer
15  * @param {Object} config The config object
16  */
17
18 Roo.bootstrap.DocumentViewer = function(config){
19     Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
20     
21     this.addEvents({
22         /**
23          * @event initial
24          * Fire after initEvent
25          * @param {Roo.bootstrap.DocumentViewer} this
26          */
27         "initial" : true
28         
29     });
30 };
31
32 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component,  {
33     
34     thumbWidth : 300,
35     thumbHeight : 300,
36     
37     getAutoCreate : function()
38     {
39         var cfg = {
40             tag : 'div',
41             cls : 'roo-document-viewer',
42             cn : [
43                 {
44                     tag : 'div',
45                     cls : 'roo-document-viewer-body',
46                     cn : [
47                         {
48                             tag : 'div',
49                             cls : 'roo-document-viewer-thumb',
50                             style : 'width: ' + this.thumbWidth + 'px; height: ' + this.thumbHeight + 'px;'
51                         }
52                     ]
53                 },
54                 {
55                     tag : 'div',
56                     cls : 'roo-document-viewer-footer',
57                     cn : {
58                         tag : 'div',
59                         cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
60                         cn : [
61                             {
62                                 tag : 'div',
63                                 cls : 'btn-group',
64                                 cn : [
65                                     {
66                                         tag : 'button',
67                                         cls : 'btn btn-default roo-document-viewer-trash',
68                                         html : '<i class="fa fa-trash"></i>'
69                                     }
70                                 ]
71                             }
72                         ]
73                     }
74                 }
75             ]
76         };
77         
78         return cfg;
79     },
80     
81     initEvents : function()
82     {
83         
84         this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
85         this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
86         
87         this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
88         this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
89         
90         this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
91         this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
92         
93         this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
94         this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
95         
96         var _this = this;
97         
98 //        window.addEventListener("resize", function() { _this.resize(); } );
99         
100         this.bodyEl.on('click', this.onClick, this);
101         
102         this.trashBtn.on('click', this.onTrash, this);
103         
104         this.fireEvent('initial', this);
105         
106         
107     },
108     
109     resize : function()
110     {
111         this.setThumbBoxPosition();
112     },
113     
114     setThumbBoxPosition : function()
115     {
116         var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
117         var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
118         
119         this.thumbEl.setLeft(x);
120         this.thumbEl.setTop(y);
121         
122     },
123     
124     onClick : function()
125     {
126         
127     },
128     
129     onTrash : function()
130     {
131         
132     }
133     
134 });