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 {Boolean} showDownload (true|false) show download button (default true)
11  * @cfg {Boolean} showTrash (true|false) show trash button (default true)
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          * @event click
30          * Fire after click
31          * @param {Roo.bootstrap.DocumentViewer} this
32          */
33         "click" : true,
34         /**
35          * @event trash
36          * Fire after trash button
37          * @param {Roo.bootstrap.DocumentViewer} this
38          */
39         "trash" : true
40         
41     });
42 };
43
44 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component,  {
45     
46     showDownload : true,
47     
48     showTrash : true,
49     
50     getAutoCreate : function()
51     {
52         var cfg = {
53             tag : 'div',
54             cls : 'roo-document-viewer',
55             cn : [
56                 {
57                     tag : 'div',
58                     cls : 'roo-document-viewer-body',
59                     cn : [
60                         {
61                             tag : 'div',
62                             cls : 'roo-document-viewer-thumb',
63                             cn : [
64                                 {
65                                     tag : 'img',
66                                     cls : 'roo-document-viewer-image'
67                                 }
68                             ]
69                         }
70                     ]
71                 },
72                 {
73                     tag : 'div',
74                     cls : 'roo-document-viewer-footer',
75                     cn : {
76                         tag : 'div',
77                         cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
78                         cn : [
79                             {
80                                 tag : 'div',
81                                 cls : 'btn-group',
82                                 cn : [
83                                     {
84                                         tag : 'button',
85                                         cls : 'btn btn-default roo-document-viewer-trash',
86                                         html : '<i class="fa fa-trash"></i>'
87                                     }
88                                 ]
89                             }
90                         ]
91                     }
92                 }
93             ]
94         };
95         
96         return cfg;
97     },
98     
99     initEvents : function()
100     {
101         
102         this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
103         this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
104         
105         this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
106         this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
107         
108         this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
109         this.imageEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
110         
111         this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
112         this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
113         
114         this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
115         this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
116         
117         this.bodyEl.on('click', this.onClick, this);
118         
119         this.trashBtn.on('click', this.onTrash, this);
120         
121     },
122     
123     initial : function()
124     {
125 //        this.thumbEl.setStyle('line-height', this.thumbEl.getHeight(true) + 'px');
126         
127         
128         this.fireEvent('initial', this);
129         
130     },
131     
132     onClick : function(e)
133     {
134         e.preventDefault();
135         
136         this.fireEvent('click', this);
137     },
138     
139     onTrash : function(e)
140     {
141         e.preventDefault();
142         
143         this.fireEvent('trash', this);
144     }
145     
146 });