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