preview.js
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Create the preview / info box using an ExtJS Dialog window
*/
var showInfo = function(iDocId, sUrl, sDir, loading, mwidth){
// Create the info box container div
createPanel();
showIcon = Ext.get('box_'+iDocId);
dialog = new Ext.Window({
el: 'info-dlg',
closeAction: 'destroy',
layout: 'fit',
shadow: false,
modal: true,
plain: false,
width: mwidth,
height: 360,
minWidth: 300,
minHeight: 250
});
dialog.show(showIcon.dom);
var info = document.getElementById('info-preview');
info.innerHTML = loading;
Ext.Ajax.request({
url: sUrl,
success: function(response) {
info.innerHTML = response.responseText;
},
failure: function(response) {
alert('Error. Couldn\'t create info box.');
},
params: {
fDocumentId: iDocId,
kt_dir: sDir
}
});
}
/*
Create the container div's in which the info box will be created.
Add the div's required by the ExtJS dialog box.
*/
var createPanel = function() {
if(document.getElementById('info-panel')){
destroyPanel();
p = document.getElementById('info-panel');
p.style.display = 'block';
}else{
p = document.getElementById('pageBody').appendChild(document.createElement('div'));
p.id = 'info-panel';
}
b = p.appendChild(document.createElement('div'));
b.id = 'info-dlg';
b.innerHTML = '<div class="x-window-header">Info Panel</div><div class="x-window-body"><div id="info-preview"></div></div>';
}
/*
Set the container div to empty.
The display must be set to none for IE, otherwise the icons under the div aren't clickable.
*/
var destroyPanel = function() {
if(dialog){
dialog.destroy();
}
p = document.getElementById('info-panel');
p.innerHTML = '';
p.style.display = 'none';
}