1 |
85ad3d82
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
(function($) {
|
14 |
|
|
|
15 |
|
|
var appFields = {}, appWindow = (top.appiFrm||window).opener || parent;
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
imce.hooks.load.push(function(win) {
|
19 |
|
|
var index = location.href.lastIndexOf('app=');
|
20 |
|
|
if (index == -1) return;
|
21 |
|
|
var data = decodeURIComponent(location.href.substr(index + 4)).split('|');
|
22 |
|
|
var arr, prop, str, func, appName = data.shift();
|
23 |
|
|
|
24 |
|
|
for (var i = 0, len = data.length; i < len; i++) {
|
25 |
|
|
str = data[i];
|
26 |
|
|
if (!str.length) continue;
|
27 |
|
|
if (str.indexOf('&') != -1) str = str.split('&')[0];
|
28 |
|
|
arr = str.split('@');
|
29 |
|
|
if (arr.length > 1) {
|
30 |
|
|
prop = arr.shift();
|
31 |
|
|
appFields[prop] = arr.join('@');
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
if (appFields.imceload && (func = isFunc(appFields.imceload))) {
|
36 |
|
|
func(win);
|
37 |
|
|
delete appFields.imceload;
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
var sendtoFunc = appFields.url ? appFinish : false;
|
41 |
|
|
|
42 |
|
|
if (appFields.sendto && (func = isFunc(appFields.sendto))) {
|
43 |
|
|
sendtoFunc = func;
|
44 |
|
|
delete appFields.sendto;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
else if (win.name && (func = isFunc(win.name +'ImceFinish'))) {
|
48 |
|
|
sendtoFunc = func;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
if (appFields.url) {
|
52 |
|
|
|
53 |
|
|
if (appFields.url.indexOf(',') > -1) {
|
54 |
|
|
var arr = appFields.url.split(',');
|
55 |
|
|
for (var i in arr) {
|
56 |
6eb8d15f
|
Assos Assos
|
if ($('#'+ arr[i], appWindow.document).length) {
|
57 |
85ad3d82
|
Assos Assos
|
appFields.url = arr[i];
|
58 |
|
|
break;
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
var filename = $('#'+ appFields.url, appWindow.document).val() || '';
|
63 |
|
|
imce.highlight(filename.substr(filename.lastIndexOf('/')+1));
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
sendtoFunc && imce.setSendTo(Drupal.t('Insert file'), sendtoFunc);
|
67 |
|
|
});
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
var appFinish = function(file, win) {
|
71 |
|
|
var $doc = $(appWindow.document);
|
72 |
|
|
for (var i in appFields) {
|
73 |
|
|
$doc.find('#'+ appFields[i]).val(file[i]);
|
74 |
|
|
}
|
75 |
|
|
if (appFields.url) {
|
76 |
|
|
try{
|
77 |
|
|
$doc.find('#'+ appFields.url).blur().change().focus();
|
78 |
|
|
}catch(e){
|
79 |
|
|
try{
|
80 |
|
|
$doc.find('#'+ appFields.url).trigger('onblur').trigger('onchange').trigger('onfocus');
|
81 |
|
|
}catch(e){}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
appWindow.focus();
|
85 |
|
|
win.close();
|
86 |
|
|
};
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
var isFunc = function(str, scope) {
|
91 |
|
|
var obj = scope || appWindow;
|
92 |
|
|
var parts = str.split('.'), len = parts.length;
|
93 |
|
|
for (var i = 0; i < len && (obj = obj[parts[i]]); i++);
|
94 |
|
|
return obj && i == len && (typeof obj == 'function' || typeof obj != 'string' && !obj.nodeName && obj.constructor != Array && /^[\s[]?function/.test(obj.toString())) ? obj : false;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
})(jQuery); |