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     file : false,
37     
38     getAutoCreate : function()
39     {
40         var cfg = {
41             tag : 'div',
42             cls : 'roo-document-viewer',
43             cn : [
44                 {
45                     tag : 'div',
46                     cls : 'roo-document-viewer-body',
47                     cn : [
48                         {
49                             tag : 'div',
50                             cls : 'roo-document-viewer-thumb',
51                             style : 'width: ' + this.thumbWidth + 'px; height: ' + this.thumbHeight + 'px;',
52                         }
53                     ]
54                 },
55                 {
56                     tag : 'div',
57                     cls : 'roo-document-viewer-footer',
58                     cn : {
59                         tag : 'div',
60                         cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
61                         cn : [
62                             {
63                                 tag : 'div',
64                                 cls : 'btn-group',
65                                 cn : [
66                                     {
67                                         tag : 'button',
68                                         cls : 'btn btn-default roo-document-viewer-trash',
69                                         html : '<i class="fa fa-trash"></i>'
70                                     }
71                                 ]
72                             }
73                         ]
74                     }
75                 }
76             ]
77         };
78         
79         return cfg;
80     },
81     
82     initEvents : function()
83     {
84         
85         this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
86         this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
87         
88         this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
89         this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
90         
91         this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
92         this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
93         
94         this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
95         this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
96         
97         this.bodyEl.on('click', this.onClick, this);
98         
99         this.trashBtn.on('click', this.onTrash, this);
100         
101         this.fireEvent('initial', this);
102     },
103     
104     set : function(file)
105     {
106         this.file = file;
107         
108         this.thumbEl.setStyle('background-image', 'url("' + baseURL +'/Images/Thumb/' + this.thumbWidth + '/' + file.id + '/' + file.filename + '")');
109         
110     },
111     
112     onClick : function()
113     {
114         
115     },
116     
117     onTrash : function()
118     {
119         
120     }
121     
122 });