remove debugging code
[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 download
36          * Fire after download button
37          * @param {Roo.bootstrap.DocumentViewer} this
38          */
39         "download" : true,
40         /**
41          * @event trash
42          * Fire after trash button
43          * @param {Roo.bootstrap.DocumentViewer} this
44          */
45         "trash" : true
46         
47     });
48 };
49
50 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component,  {
51     
52     showDownload : true,
53     
54     showTrash : true,
55     
56     getAutoCreate : function()
57     {
58         var cfg = {
59             tag : 'div',
60             cls : 'roo-document-viewer',
61             cn : [
62                 {
63                     tag : 'div',
64                     cls : 'roo-document-viewer-body',
65                     cn : [
66                         {
67                             tag : 'div',
68                             cls : 'roo-document-viewer-thumb',
69                             cn : [
70                                 {
71                                     tag : 'img',
72                                     cls : 'roo-document-viewer-image'
73                                 }
74                             ]
75                         }
76                     ]
77                 },
78                 {
79                     tag : 'div',
80                     cls : 'roo-document-viewer-footer',
81                     cn : {
82                         tag : 'div',
83                         cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
84                         cn : [
85                             {
86                                 tag : 'div',
87                                 cls : 'btn-group roo-document-viewer-download',
88                                 cn : [
89                                     {
90                                         tag : 'button',
91                                         cls : 'btn btn-default',
92                                         html : '<i class="fa fa-download"></i>'
93                                     }
94                                 ]
95                             },
96                             {
97                                 tag : 'div',
98                                 cls : 'btn-group roo-document-viewer-trash',
99                                 cn : [
100                                     {
101                                         tag : 'button',
102                                         cls : 'btn btn-default',
103                                         html : '<i class="fa fa-trash"></i>'
104                                     }
105                                 ]
106                             }
107                         ]
108                     }
109                 }
110             ]
111         };
112         
113         return cfg;
114     },
115     
116     initEvents : function()
117     {
118         this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
119         this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
120         
121         this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
122         this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
123         
124         this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
125         this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
126         
127         this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
128         this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
129         
130         this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
131         this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
132         
133         this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
134         this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
135         
136         this.bodyEl.on('click', this.onClick, this);
137         this.downloadBtn.on('click', this.onDownload, this);
138         this.trashBtn.on('click', this.onTrash, this);
139         
140         this.downloadBtn.hide();
141         this.trashBtn.hide();
142         
143         if(this.showDownload){
144             this.downloadBtn.show();
145         }
146         
147         if(this.showTrash){
148             this.trashBtn.show();
149         }
150         
151         if(!this.showDownload && !this.showTrash) {
152             this.footerEl.hide();
153         }
154         
155     },
156     
157     initial : function()
158     {
159         this.fireEvent('initial', this);
160         
161     },
162     
163     onClick : function(e)
164     {
165         e.preventDefault();
166         
167         this.fireEvent('click', this);
168     },
169     
170     onDownload : function(e)
171     {
172         e.preventDefault();
173         
174         this.fireEvent('download', this);
175     },
176     
177     onTrash : function(e)
178     {
179         e.preventDefault();
180         
181         this.fireEvent('trash', this);
182     }
183     
184 });