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-preview'
50                         },
51                         {
52                             tag : 'div',
53                             cls : 'roo-document-viewer-thumb',
54                             style : 'width: ' + this.thumbWidth + 'px; height: ' + this.thumbHeight + 'px;'
55                         }
56                     ]
57                 },
58                 {
59                     tag : 'div',
60                     cls : 'roo-document-viewer-footer',
61                     cn : {
62                         tag : 'div',
63                         cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
64                         cn : [
65                             {
66                                 tag : 'div',
67                                 cls : 'btn-group',
68                                 cn : [
69                                     {
70                                         tag : 'button',
71                                         cls : 'btn btn-default roo-document-viewer-trash',
72                                         html : '<i class="fa fa-trash"></i>'
73                                     }
74                                 ]
75                             }
76                         ]
77                     }
78                 }
79             ]
80         };
81         
82         return cfg;
83     },
84     
85     initEvents : function()
86     {
87         
88         this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
89         this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
90         
91         this.previewEl = this.el.select('.roo-document-viewer-preview', true).first();
92         this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
93         
94         this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
95         this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
96         
97         this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
98         this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
99         
100         this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
101         this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
102         
103         var _this = this;
104         
105         window.addEventListener("resize", function() { _this.resize(); } );
106         
107         
108         this.bodyEl.on('click', this.onClick, this);
109         
110         this.trashBtn.on('click', this.onTrash, this);
111         
112         this.fireEvent('initial', this);
113     },
114     
115     resize : function()
116     {
117         this.setThumbBoxPosition();
118     },
119     
120     onClick : function()
121     {
122         
123     },
124     
125     onTrash : function()
126     {
127         
128     }
129     
130 });