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