1 //<script type="text/javascript">
5 * singleton preview frame / object..
9 * frame = handles doc's that can appear in frames
10 * pdf = is for firefox - displaying PDF's and others????
19 active: false, // frame of pdf
23 if (this.frame) { // already exists.
28 //var frm = this.layout.getEl().createChild({
30 // src: 'about:blank'});
32 this.pdf = Ext.DomHelper.append(
37 type : 'application/pdf',
41 style : 'position:absolute;top:-1000;left:-1000; z-index:-100',
54 this.imgDiv = Ext.DomHelper.append(
58 style : 'position:absolute;top:-1000;left:-1000; z-index:-100;' +
59 'overflow-x:hidden;overflow-y:scroll;width:200px; height: 200px;'
63 this.frame = Ext.DomHelper.append(
68 style : 'position:absolute;top:-1000;left:-1000; z-index:-100;' +
69 'width:1px; height: 1px;'
80 this.active.style.zIndex = this.activeCfg ? this.activeCfg.zIndex : -100;
83 //var pz = this.config.previewRegion.panelSize;
87 //if (pz.width < 10) {
90 if (!this.config.previewRegion) {
96 var pos = this.config.previewRegion.el.getBox();
102 //var top = pos.y + (pos.height - pz.height);
107 this.active.setAttribute( 'width',pos.width);
108 this.active.setAttribute( 'height',pos.height);
110 this.active.style.width = pos.width + 'px';
111 this.active.style.height = pos.height + 'px';
114 this.active.style.top = pos.y + 'px';
115 this.active.style.left = pos.x + 'px';
118 this.active.setAttribute( 'width',pz.width);
119 this.active.setAttribute( 'height',pz.height);
121 this.active.style.width = pz.width + 'px';
122 this.active.style.height = pz.height + 'px';
125 this.active.style.top = top + 'px';
126 this.active.style.left = pos.x + 'px';
134 // remove the listeners on that object...
138 if (this.config.dialog ) {
139 this.config.dialog.un('hide', this.onHide, this);
141 if (this.config.tab) {
142 this.config.tab.un('deactivate', this.onHide, this);
144 this.config.previewRegion.un('resized', this.onResize, this);
145 // this.config.previewRegion.getSplitBar().un('beforeresize', this.disable, this);
149 link: function(config)
151 // add the listener to the ownerDiv..
157 this.config = config;
158 if (this.config.dialog) {
159 this.config.dialog.on('hide', this.onHide, this);
161 if (this.config.tab) {
162 this.config.tab.on('deactivate', this.onHide, this);
165 this.config.previewRegion.on('resized', this.onResize, this);
166 //this.config.previewRegion.getSplitBar().on('beforeresize', this.disable, this);
170 removeActive: function()
175 this.active.style.left='-1000px';
176 this.active.style.top='-1000px';
177 this.active.style.width='200px';
178 this.active.style.top='200px';
179 this.active.style.zIndex= -100;
183 onHide: function () {
194 this.activeCfg.url = this.activeCfg.pdfurl;
195 this.activeCfg.mimetype = 'application/pdf';
196 this.load(this.activeCfg);
203 * mimetype : load mimetype (needs more explaination)
205 * width : (for image)
206 * height: (for image)
212 this.activeCfg = false;
213 if (typeof(cfg) != 'object') {
214 alert('Preview Load only accepts object with url/mimetype/zIndex as loader');
217 this.activeCfg = Roo.apply({},cfg);
218 var url = this.activeCfg.url;
219 var mimetype = this.activeCfg.mimetype;
226 case 'image/jpeg': // preview!!!!
227 // we need to show this in a floating div...
228 //var ps = 100; //this.config.previewRegion.panelSize;
229 var ps = this.config.previewRegion.el.getBox();
231 this.imgDiv.innerHTML = '<img src="' + url +'"' +
232 ' width="'+ (ps.width-15) + '"' +
233 ' qtip="'+ "Click to view PDF" + '"' +
235 ' onclick="Pman.Preview.showPdf();"/>';
236 this.active = this.imgDiv;
237 this.enable(this.activeCfg.zIndex);
242 case 'application/pdf':
243 case 'application/msword':
244 case 'application/vnd.oasis.opendocument.text':
246 case 'application/vnd.ms-excel':
247 case 'application/vnd.oasis.opendocument.spreadsheet':
248 case 'application/vnd.dwg':
249 case 'application/acad':
250 case 'application/x-acad':
251 case 'application/autocad_dwg':
253 case 'application/dwg':
254 case 'application/x-dwg':
255 case 'application/x-autocad':
256 case 'image/vnd.dwg':
259 if (!url.match(/\.pdf$/)) {
265 this.frame.src = url;
266 this.active = this.frame;
267 this.enable(this.activeCfg.zIndex);
270 this.pdf.setAttribute( 'data', url);
271 // this.pdf.childNodes[0].setAttribute( 'src', url);
272 this.active = this.pdf;
273 this.enable(this.activeCfg.zIndex);
277 this.frame.src = url; ///'about:blank';
278 this.active = this.frame;
279 this.enable(this.activeCfg.zIndex);
293 this.disabled = true;
294 this.active.style.zIndex = -100;
296 this.frame.src= 'about:blank';
299 enable: function(zIndex)
304 this.disabled = false;
306 this.active.style.zIndex = zIndex ? zIndex : 10000;
307 if (!Roo.isGecko && this.activeCfg) {
308 this.frame.src= this.activeCfg.url;
314 tmpDisable : function()
317 this.tmpStatus = false;
320 this.tmpStatus = true;
323 tmpEnable: function()
325 if (!this.tmpStatus) {
328 this.tmpStatus = false;