Edit File by line
/home/barbar84/www/wp-conte.../plugins/file-man.../applicat.../library/js/commands
File: quicklook.plugins.js
elFinder.prototype.commands.quicklook.plugins = [
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Images preview plugin
[3] Fix | Delete
*
[4] Fix | Delete
* @param elFinder.commands.quicklook
[5] Fix | Delete
**/
[6] Fix | Delete
function(ql) {
[7] Fix | Delete
"use strict";
[8] Fix | Delete
var mimes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/x-ms-bmp'],
[9] Fix | Delete
getDimSize = ql.fm.returnBytes((ql.options.getDimThreshold || 0)),
[10] Fix | Delete
preview = ql.preview,
[11] Fix | Delete
WebP, flipMime;
[12] Fix | Delete
[13] Fix | Delete
// webp support
[14] Fix | Delete
WebP = new Image();
[15] Fix | Delete
WebP.onload = WebP.onerror = function() {
[16] Fix | Delete
if (WebP.height == 2) {
[17] Fix | Delete
mimes.push('image/webp');
[18] Fix | Delete
}
[19] Fix | Delete
};
[20] Fix | Delete
WebP.src='data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
[21] Fix | Delete
[22] Fix | Delete
// what kind of images we can display
[23] Fix | Delete
$.each(navigator.mimeTypes, function(i, o) {
[24] Fix | Delete
var mime = o.type;
[25] Fix | Delete
[26] Fix | Delete
if (mime.indexOf('image/') === 0 && $.inArray(mime, mimes)) {
[27] Fix | Delete
mimes.push(mime);
[28] Fix | Delete
}
[29] Fix | Delete
});
[30] Fix | Delete
[31] Fix | Delete
preview.on(ql.evUpdate, function(e) {
[32] Fix | Delete
var fm = ql.fm,
[33] Fix | Delete
file = e.file,
[34] Fix | Delete
showed = false,
[35] Fix | Delete
dimreq = null,
[36] Fix | Delete
setdim = function(dim) {
[37] Fix | Delete
var rfile = fm.file(file.hash);
[38] Fix | Delete
rfile.width = dim[0];
[39] Fix | Delete
rfile.height = dim[1];
[40] Fix | Delete
},
[41] Fix | Delete
show = function() {
[42] Fix | Delete
var elm, varelm, memSize, width, height, prop;
[43] Fix | Delete
[44] Fix | Delete
dimreq && dimreq.state && dimreq.state() === 'pending' && dimreq.reject();
[45] Fix | Delete
if (showed) {
[46] Fix | Delete
return;
[47] Fix | Delete
}
[48] Fix | Delete
showed = true;
[49] Fix | Delete
[50] Fix | Delete
elm = img.get(0);
[51] Fix | Delete
memSize = file.width && file.height? {w: file.width, h: file.height} : (elm.naturalWidth? null : {w: img.width(), h: img.height()});
[52] Fix | Delete
[53] Fix | Delete
memSize && img.removeAttr('width').removeAttr('height');
[54] Fix | Delete
[55] Fix | Delete
width = file.width || elm.naturalWidth || elm.width || img.width();
[56] Fix | Delete
height = file.height || elm.naturalHeight || elm.height || img.height();
[57] Fix | Delete
if (!file.width || !file.height) {
[58] Fix | Delete
setdim([width, height]);
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
memSize && img.width(memSize.w).height(memSize.h);
[62] Fix | Delete
[63] Fix | Delete
prop = (width/height).toFixed(2);
[64] Fix | Delete
preview.on('changesize', function() {
[65] Fix | Delete
var pw = parseInt(preview.width()),
[66] Fix | Delete
ph = parseInt(preview.height()),
[67] Fix | Delete
w, h;
[68] Fix | Delete
[69] Fix | Delete
if (prop < (pw/ph).toFixed(2)) {
[70] Fix | Delete
h = ph;
[71] Fix | Delete
w = Math.floor(h * prop);
[72] Fix | Delete
} else {
[73] Fix | Delete
w = pw;
[74] Fix | Delete
h = Math.floor(w/prop);
[75] Fix | Delete
}
[76] Fix | Delete
img.width(w).height(h).css('margin-top', h < ph ? Math.floor((ph - h)/2) : 0);
[77] Fix | Delete
[78] Fix | Delete
})
[79] Fix | Delete
.trigger('changesize');
[80] Fix | Delete
[81] Fix | Delete
//show image
[82] Fix | Delete
img.fadeIn(100);
[83] Fix | Delete
},
[84] Fix | Delete
hideInfo = function() {
[85] Fix | Delete
loading.remove();
[86] Fix | Delete
// hide info/icon
[87] Fix | Delete
ql.hideinfo();
[88] Fix | Delete
},
[89] Fix | Delete
url, img, loading, prog, m, opDfd;
[90] Fix | Delete
[91] Fix | Delete
if (!flipMime) {
[92] Fix | Delete
flipMime = fm.arrayFlip(mimes);
[93] Fix | Delete
}
[94] Fix | Delete
if (flipMime[file.mime] && ql.dispInlineRegex.test(file.mime)) {
[95] Fix | Delete
// this is our file - stop event propagation
[96] Fix | Delete
e.stopImmediatePropagation();
[97] Fix | Delete
[98] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[99] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[100] Fix | Delete
[101] Fix | Delete
img = $('<img/>')
[102] Fix | Delete
.hide()
[103] Fix | Delete
.appendTo(preview)
[104] Fix | Delete
.on('load', function() {
[105] Fix | Delete
hideInfo();
[106] Fix | Delete
show();
[107] Fix | Delete
})
[108] Fix | Delete
.on('error', function() {
[109] Fix | Delete
loading.remove();
[110] Fix | Delete
});
[111] Fix | Delete
opDfd = fm.openUrl(file.hash, false, function(url) {
[112] Fix | Delete
img.attr('src', url);
[113] Fix | Delete
}, { progressBar: prog });
[114] Fix | Delete
// stop loading on change file if not loaded yet
[115] Fix | Delete
preview.one('change', function() {
[116] Fix | Delete
opDfd && opDfd.state && opDfd.state() === 'pending' && opDfd.reject();
[117] Fix | Delete
});
[118] Fix | Delete
[119] Fix | Delete
if (file.width && file.height) {
[120] Fix | Delete
show();
[121] Fix | Delete
} else if (file.size > getDimSize) {
[122] Fix | Delete
dimreq = fm.request({
[123] Fix | Delete
data : {cmd : 'dim', target : file.hash},
[124] Fix | Delete
preventDefault : true
[125] Fix | Delete
})
[126] Fix | Delete
.done(function(data) {
[127] Fix | Delete
if (data.dim) {
[128] Fix | Delete
var dim = data.dim.split('x');
[129] Fix | Delete
file.width = dim[0];
[130] Fix | Delete
file.height = dim[1];
[131] Fix | Delete
setdim(dim);
[132] Fix | Delete
show();
[133] Fix | Delete
}
[134] Fix | Delete
});
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
});
[139] Fix | Delete
},
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* TIFF image preview
[143] Fix | Delete
*
[144] Fix | Delete
* @param object ql elFinder.commands.quicklook
[145] Fix | Delete
*/
[146] Fix | Delete
function(ql) {
[147] Fix | Delete
"use strict";
[148] Fix | Delete
var fm = ql.fm,
[149] Fix | Delete
mime = 'image/tiff',
[150] Fix | Delete
preview = ql.preview;
[151] Fix | Delete
if (window.Worker && window.Uint8Array) {
[152] Fix | Delete
preview.on(ql.evUpdate, function(e) {
[153] Fix | Delete
var file = e.file,
[154] Fix | Delete
err = function(e) {
[155] Fix | Delete
wk && wk.terminate();
[156] Fix | Delete
loading.remove();
[157] Fix | Delete
fm.debug('error', e);
[158] Fix | Delete
},
[159] Fix | Delete
setdim = function(dim) {
[160] Fix | Delete
var rfile = fm.file(file.hash);
[161] Fix | Delete
rfile.width = dim[0];
[162] Fix | Delete
rfile.height = dim[1];
[163] Fix | Delete
},
[164] Fix | Delete
loading, prog, url, base, wk, opDfd;
[165] Fix | Delete
if (file.mime === mime) {
[166] Fix | Delete
e.stopImmediatePropagation();
[167] Fix | Delete
[168] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[169] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[170] Fix | Delete
// stop loading on change file if not loaded yet
[171] Fix | Delete
preview.one('change', function() {
[172] Fix | Delete
wk && wk.terminate();
[173] Fix | Delete
loading.remove();
[174] Fix | Delete
});
[175] Fix | Delete
[176] Fix | Delete
opDfd = fm.getContents(file.hash, 'arraybuffer', { progressBar: prog }).done(function(data) {
[177] Fix | Delete
if (data) {
[178] Fix | Delete
base = $('<div></div>').css({width:'100%',height:'100%'}).hide().appendTo(preview);
[179] Fix | Delete
try {
[180] Fix | Delete
wk = fm.getWorker();
[181] Fix | Delete
wk.onmessage = function(res) {
[182] Fix | Delete
var data = res.data,
[183] Fix | Delete
cv, co, id, prop;
[184] Fix | Delete
wk && wk.terminate();
[185] Fix | Delete
cv = document.createElement('canvas');
[186] Fix | Delete
co = cv.getContext('2d');
[187] Fix | Delete
cv.width = data.width;
[188] Fix | Delete
cv.height = data.height;
[189] Fix | Delete
id = co.createImageData(data.width, data.height);
[190] Fix | Delete
(id).data.set(new Uint8Array(data.image));
[191] Fix | Delete
co.putImageData(id, 0, 0);
[192] Fix | Delete
base.append(cv).show();
[193] Fix | Delete
loading.remove();
[194] Fix | Delete
prop = (data.width/data.height).toFixed(2);
[195] Fix | Delete
preview.on('changesize', function() {
[196] Fix | Delete
var pw = parseInt(preview.width()),
[197] Fix | Delete
ph = parseInt(preview.height()),
[198] Fix | Delete
w, h;
[199] Fix | Delete
if (prop < (pw/ph).toFixed(2)) {
[200] Fix | Delete
h = ph;
[201] Fix | Delete
w = Math.floor(h * prop);
[202] Fix | Delete
} else {
[203] Fix | Delete
w = pw;
[204] Fix | Delete
h = Math.floor(w/prop);
[205] Fix | Delete
}
[206] Fix | Delete
$(cv).width(w).height(h).css('margin-top', h < ph ? Math.floor((ph - h)/2) : 0);
[207] Fix | Delete
}).trigger('changesize');
[208] Fix | Delete
if (!file.width || !file.height) {
[209] Fix | Delete
setdim([data.width, data.height]);
[210] Fix | Delete
}
[211] Fix | Delete
ql.hideinfo();
[212] Fix | Delete
};
[213] Fix | Delete
wk.onerror = err;
[214] Fix | Delete
wk.postMessage({
[215] Fix | Delete
scripts: [fm.options.cdns.tiff, fm.getWorkerUrl('quicklook.tiff.js')],
[216] Fix | Delete
data: { data: data }
[217] Fix | Delete
});
[218] Fix | Delete
} catch(e) {
[219] Fix | Delete
err(e);
[220] Fix | Delete
}
[221] Fix | Delete
} else {
[222] Fix | Delete
err();
[223] Fix | Delete
}
[224] Fix | Delete
});
[225] Fix | Delete
// stop loading on change file if not loaded yet
[226] Fix | Delete
preview.one('change', function() {
[227] Fix | Delete
opDfd && opDfd.state && opDfd.state() === 'pending' && opDfd.reject();
[228] Fix | Delete
});
[229] Fix | Delete
}
[230] Fix | Delete
});
[231] Fix | Delete
}
[232] Fix | Delete
},
[233] Fix | Delete
[234] Fix | Delete
/**
[235] Fix | Delete
* PSD(Adobe Photoshop data) preview plugin
[236] Fix | Delete
*
[237] Fix | Delete
* @param elFinder.commands.quicklook
[238] Fix | Delete
**/
[239] Fix | Delete
function(ql) {
[240] Fix | Delete
"use strict";
[241] Fix | Delete
var fm = ql.fm,
[242] Fix | Delete
mimes = fm.arrayFlip(['image/vnd.adobe.photoshop', 'image/x-photoshop']),
[243] Fix | Delete
preview = ql.preview,
[244] Fix | Delete
load = function(url, img, loading) {
[245] Fix | Delete
try {
[246] Fix | Delete
fm.replaceXhrSend();
[247] Fix | Delete
PSD.fromURL(url).then(function(psd) {
[248] Fix | Delete
var prop;
[249] Fix | Delete
img.attr('src', psd.image.toBase64());
[250] Fix | Delete
requestAnimationFrame(function() {
[251] Fix | Delete
prop = (img.width()/img.height()).toFixed(2);
[252] Fix | Delete
preview.on('changesize', function() {
[253] Fix | Delete
var pw = parseInt(preview.width()),
[254] Fix | Delete
ph = parseInt(preview.height()),
[255] Fix | Delete
w, h;
[256] Fix | Delete
[257] Fix | Delete
if (prop < (pw/ph).toFixed(2)) {
[258] Fix | Delete
h = ph;
[259] Fix | Delete
w = Math.floor(h * prop);
[260] Fix | Delete
} else {
[261] Fix | Delete
w = pw;
[262] Fix | Delete
h = Math.floor(w/prop);
[263] Fix | Delete
}
[264] Fix | Delete
img.width(w).height(h).css('margin-top', h < ph ? Math.floor((ph - h)/2) : 0);
[265] Fix | Delete
}).trigger('changesize');
[266] Fix | Delete
[267] Fix | Delete
loading.remove();
[268] Fix | Delete
// hide info/icon
[269] Fix | Delete
ql.hideinfo();
[270] Fix | Delete
//show image
[271] Fix | Delete
img.fadeIn(100);
[272] Fix | Delete
});
[273] Fix | Delete
}, function() {
[274] Fix | Delete
loading.remove();
[275] Fix | Delete
img.remove();
[276] Fix | Delete
});
[277] Fix | Delete
fm.restoreXhrSend();
[278] Fix | Delete
} catch(e) {
[279] Fix | Delete
fm.restoreXhrSend();
[280] Fix | Delete
loading.remove();
[281] Fix | Delete
img.remove();
[282] Fix | Delete
}
[283] Fix | Delete
},
[284] Fix | Delete
PSD;
[285] Fix | Delete
[286] Fix | Delete
preview.on(ql.evUpdate, function(e) {
[287] Fix | Delete
var file = e.file,
[288] Fix | Delete
url, img, loading, prog, m,
[289] Fix | Delete
_define, _require, opDfd;
[290] Fix | Delete
[291] Fix | Delete
if (mimes[file.mime] && fm.options.cdns.psd && ! fm.UA.ltIE10 && ql.dispInlineRegex.test(file.mime)) {
[292] Fix | Delete
// this is our file - stop event propagation
[293] Fix | Delete
e.stopImmediatePropagation();
[294] Fix | Delete
[295] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[296] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[297] Fix | Delete
opDfd = fm.openUrl(file.hash, 'sameorigin', function(url) {
[298] Fix | Delete
if (url) {
[299] Fix | Delete
img = $('<img/>').hide().appendTo(preview);
[300] Fix | Delete
if (PSD) {
[301] Fix | Delete
load(url, img, loading);
[302] Fix | Delete
} else {
[303] Fix | Delete
_define = window.define;
[304] Fix | Delete
_require = window.require;
[305] Fix | Delete
window.require = null;
[306] Fix | Delete
window.define = null;
[307] Fix | Delete
fm.loadScript(
[308] Fix | Delete
[ fm.options.cdns.psd ],
[309] Fix | Delete
function() {
[310] Fix | Delete
PSD = require('psd');
[311] Fix | Delete
_define? (window.define = _define) : (delete window.define);
[312] Fix | Delete
_require? (window.require = _require) : (delete window.require);
[313] Fix | Delete
load(url, img, loading);
[314] Fix | Delete
}
[315] Fix | Delete
);
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
}, { progressBar: prog });
[319] Fix | Delete
// stop loading on change file if not loaded yet
[320] Fix | Delete
preview.one('change', function() {
[321] Fix | Delete
opDfd && opDfd.state && opDfd.state() === 'pending' && opDfd.reject();
[322] Fix | Delete
});
[323] Fix | Delete
}
[324] Fix | Delete
});
[325] Fix | Delete
},
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* HTML preview plugin
[329] Fix | Delete
*
[330] Fix | Delete
* @param elFinder.commands.quicklook
[331] Fix | Delete
**/
[332] Fix | Delete
function(ql) {
[333] Fix | Delete
"use strict";
[334] Fix | Delete
var fm = ql.fm,
[335] Fix | Delete
mimes = fm.arrayFlip(['text/html', 'application/xhtml+xml']),
[336] Fix | Delete
preview = ql.preview;
[337] Fix | Delete
[338] Fix | Delete
preview.on(ql.evUpdate, function(e) {
[339] Fix | Delete
var file = e.file, jqxhr, loading, prog;
[340] Fix | Delete
[341] Fix | Delete
if (mimes[file.mime] && ql.dispInlineRegex.test(file.mime) && (!ql.options.getSizeMax || file.size <= ql.options.getSizeMax)) {
[342] Fix | Delete
e.stopImmediatePropagation();
[343] Fix | Delete
[344] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[345] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[346] Fix | Delete
[347] Fix | Delete
// stop loading on change file if not loaded yet
[348] Fix | Delete
preview.one('change', function() {
[349] Fix | Delete
jqxhr.state() == 'pending' && jqxhr.reject();
[350] Fix | Delete
}).addClass('elfinder-overflow-auto');
[351] Fix | Delete
[352] Fix | Delete
jqxhr = fm.request({
[353] Fix | Delete
data : {cmd : 'get', target : file.hash, conv : 1, _t : file.ts},
[354] Fix | Delete
options : {type: 'get', cache : true},
[355] Fix | Delete
preventDefault : true,
[356] Fix | Delete
progressBar : prog
[357] Fix | Delete
})
[358] Fix | Delete
.done(function(data) {
[359] Fix | Delete
ql.hideinfo();
[360] Fix | Delete
var doc = $('<iframe class="elfinder-quicklook-preview-html"></iframe>').appendTo(preview)[0].contentWindow.document;
[361] Fix | Delete
doc.open();
[362] Fix | Delete
doc.write(data.content);
[363] Fix | Delete
doc.close();
[364] Fix | Delete
})
[365] Fix | Delete
.always(function() {
[366] Fix | Delete
loading.remove();
[367] Fix | Delete
});
[368] Fix | Delete
}
[369] Fix | Delete
});
[370] Fix | Delete
},
[371] Fix | Delete
[372] Fix | Delete
/**
[373] Fix | Delete
* MarkDown preview plugin
[374] Fix | Delete
*
[375] Fix | Delete
* @param elFinder.commands.quicklook
[376] Fix | Delete
**/
[377] Fix | Delete
function(ql) {
[378] Fix | Delete
"use strict";
[379] Fix | Delete
var fm = ql.fm,
[380] Fix | Delete
mimes = fm.arrayFlip(['text/x-markdown']),
[381] Fix | Delete
preview = ql.preview,
[382] Fix | Delete
marked = null,
[383] Fix | Delete
show = function(data, loading) {
[384] Fix | Delete
ql.hideinfo();
[385] Fix | Delete
var doc = $('<iframe class="elfinder-quicklook-preview-html"></iframe>').appendTo(preview)[0].contentWindow.document;
[386] Fix | Delete
doc.open();
[387] Fix | Delete
doc.write((marked.parse || marked)(data.content));
[388] Fix | Delete
doc.close();
[389] Fix | Delete
loading.remove();
[390] Fix | Delete
},
[391] Fix | Delete
error = function(loading) {
[392] Fix | Delete
marked = false;
[393] Fix | Delete
loading.remove();
[394] Fix | Delete
};
[395] Fix | Delete
[396] Fix | Delete
preview.on(ql.evUpdate, function(e) {
[397] Fix | Delete
var file = e.file, jqxhr, loading, prog;
[398] Fix | Delete
[399] Fix | Delete
if (mimes[file.mime] && fm.options.cdns.marked && marked !== false && ql.dispInlineRegex.test(file.mime) && (!ql.options.getSizeMax || file.size <= ql.options.getSizeMax)) {
[400] Fix | Delete
e.stopImmediatePropagation();
[401] Fix | Delete
[402] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[403] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[404] Fix | Delete
[405] Fix | Delete
// stop loading on change file if not loaded yet
[406] Fix | Delete
preview.one('change', function() {
[407] Fix | Delete
jqxhr.state() == 'pending' && jqxhr.reject();
[408] Fix | Delete
}).addClass('elfinder-overflow-auto');
[409] Fix | Delete
[410] Fix | Delete
jqxhr = fm.request({
[411] Fix | Delete
data : {cmd : 'get', target : file.hash, conv : 1, _t : file.ts},
[412] Fix | Delete
options : {type: 'get', cache : true},
[413] Fix | Delete
preventDefault : true,
[414] Fix | Delete
progressBar : prog
[415] Fix | Delete
})
[416] Fix | Delete
.done(function(data) {
[417] Fix | Delete
if (marked || window.marked) {
[418] Fix | Delete
if (!marked) {
[419] Fix | Delete
marked = window.marked;
[420] Fix | Delete
}
[421] Fix | Delete
show(data, loading);
[422] Fix | Delete
} else {
[423] Fix | Delete
fm.loadScript([fm.options.cdns.marked],
[424] Fix | Delete
function(res) {
[425] Fix | Delete
marked = res || window.marked || false;
[426] Fix | Delete
delete window.marked;
[427] Fix | Delete
if (marked) {
[428] Fix | Delete
show(data, loading);
[429] Fix | Delete
} else {
[430] Fix | Delete
error(loading);
[431] Fix | Delete
}
[432] Fix | Delete
},
[433] Fix | Delete
{
[434] Fix | Delete
tryRequire: true,
[435] Fix | Delete
error: function() {
[436] Fix | Delete
error(loading);
[437] Fix | Delete
}
[438] Fix | Delete
}
[439] Fix | Delete
);
[440] Fix | Delete
}
[441] Fix | Delete
})
[442] Fix | Delete
.fail(function() {
[443] Fix | Delete
error(loading);
[444] Fix | Delete
});
[445] Fix | Delete
}
[446] Fix | Delete
});
[447] Fix | Delete
},
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* PDF/ODT/ODS/ODP preview with ViewerJS
[451] Fix | Delete
*
[452] Fix | Delete
* @param elFinder.commands.quicklook
[453] Fix | Delete
*/
[454] Fix | Delete
function(ql) {
[455] Fix | Delete
if (ql.options.viewerjs) {
[456] Fix | Delete
var fm = ql.fm,
[457] Fix | Delete
preview = ql.preview,
[458] Fix | Delete
opts = ql.options.viewerjs,
[459] Fix | Delete
mimes = opts.url? fm.arrayFlip(opts.mimes || []) : [],
[460] Fix | Delete
win = ql.window,
[461] Fix | Delete
navi = ql.navbar,
[462] Fix | Delete
setNavi = function() {
[463] Fix | Delete
navi.css('bottom', win.hasClass('elfinder-quicklook-fullscreen')? '30px' : '');
[464] Fix | Delete
};
[465] Fix | Delete
[466] Fix | Delete
if (opts.url) {
[467] Fix | Delete
preview.on('update', function(e) {
[468] Fix | Delete
var file = e.file, node, loading, prog, opDfd;
[469] Fix | Delete
[470] Fix | Delete
if (mimes[file.mime] && (file.mime !== 'application/pdf' || !opts.pdfNative || !ql.flags.pdfNative)) {
[471] Fix | Delete
e.stopImmediatePropagation();
[472] Fix | Delete
loading = $('<div class="elfinder-quicklook-info-data"><span class="elfinder-spinner-text">'+fm.i18n('nowLoading')+'</span><span class="elfinder-spinner"></span></div>').appendTo(ql.info.find('.elfinder-quicklook-info'));
[473] Fix | Delete
prog = $('<div class="elfinder-quicklook-info-progress"></div>').appendTo(loading);
[474] Fix | Delete
opDfd = fm.openUrl(file.hash, 'sameorigin', function(url) {
[475] Fix | Delete
if (url) {
[476] Fix | Delete
node = $('<iframe class="elfinder-quicklook-preview-iframe"></iframe>')
[477] Fix | Delete
.css('background-color', 'transparent')
[478] Fix | Delete
.on('load', function() {
[479] Fix | Delete
ql.hideinfo();
[480] Fix | Delete
loading.remove();
[481] Fix | Delete
node.css('background-color', '#fff');
[482] Fix | Delete
})
[483] Fix | Delete
.on('error', function() {
[484] Fix | Delete
loading.remove();
[485] Fix | Delete
node.remove();
[486] Fix | Delete
})
[487] Fix | Delete
.appendTo(preview)
[488] Fix | Delete
.attr('src', opts.url + '#' + url);
[489] Fix | Delete
[490] Fix | Delete
win.on('viewchange.viewerjs', setNavi);
[491] Fix | Delete
setNavi();
[492] Fix | Delete
[493] Fix | Delete
preview.one('change', function() {
[494] Fix | Delete
win.off('viewchange.viewerjs');
[495] Fix | Delete
loading.remove();
[496] Fix | Delete
node.off('load').remove();
[497] Fix | Delete
});
[498] Fix | Delete
}
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function