(function(editors, elFinder) { if (typeof define === 'function' && define.amd) { define(['elfinder'], editors); } else if (elFinder) { var optEditors = elFinder.prototype._options.commandsOptions.edit.editors; elFinder.prototype._options.commandsOptions.edit.editors = optEditors.concat(editors(elFinder)); } }(function(elFinder) { "use strict"; var apps = {}, // get query of getfile getfile = window.location.search.match(/getfile=([a-z]+)/), useRequire = elFinder.prototype.hasRequire, hasFlash = (function() { var hasFlash; try { hasFlash = !!(new ActiveXObject('ShockwaveFlash.ShockwaveFlash')); } catch (e) { hasFlash = !!(typeof window.orientation === 'undefined' || (navigator && navigator.mimeTypes["application/x-shockwave-flash"])); } return hasFlash; })(), ext2mime = { bmp: 'image/x-ms-bmp', dng: 'image/x-adobe-dng', gif: 'image/gif', jpeg: 'image/jpeg', jpg: 'image/jpeg', pdf: 'application/pdf', png: 'image/png', ppm: 'image/x-portable-pixmap', psd: 'image/vnd.adobe.photoshop', pxd: 'image/x-pixlr-data', svg: 'image/svg+xml', tiff: 'image/tiff', webp: 'image/webp', xcf: 'image/x-xcf', sketch: 'application/x-sketch' }, mime2ext, getExtention = function(mime, fm) { if (!mime2ext) { mime2ext = fm.arrayFlip(ext2mime); } var ext = mime2ext[mime] || fm.mimeTypes[mime]; if (ext === 'jpeg') { ext = 'jpg'; } return ext; }, initImgTag = function(id, file, content, fm) { var node = $(this).children('img:first').data('ext', getExtention(file.mime, fm)), spnr = $('
') .css({ position: 'absolute', top: '50%', textAlign: 'center', width: '100%', fontSize: '16pt' }) .html(fm.i18n('ntfloadimg')) .hide() .appendTo(this); node.attr('id', id+'-img') .attr('src', content) .css({'height':'', 'max-width':'100%', 'max-height':'100%', 'cursor':'pointer'}) .data('loading', function(done) { var btns = node.closest('.elfinder-dialog').find('button,.elfinder-titlebar-button'); btns.prop('disabled', !done)[done? 'removeClass' : 'addClass']('ui-state-disabled'); node.css('opacity', done? '' : '0.3'); spnr[done? 'hide' : 'show'](); return node; }); }, imgBase64 = function(node, mime) { var style = node.attr('style'), img, canvas, ctx, data; try { // reset css for getting image size node.attr('style', ''); // img node img = node.get(0); // New Canvas canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; // restore css node.attr('style', style); // Draw Image canvas.getContext('2d').drawImage(img, 0, 0); // To Base64 data = canvas.toDataURL(mime); } catch(e) { data = node.attr('src'); } return data; }, pixlrCallBack = function() { if (!hasFlash || window.parent === window) { return; } var pixlr = window.location.search.match(/[?&]pixlr=([^&]+)/), image = window.location.search.match(/[?&]image=([^&]+)/), p, ifm, url, node, ext; if (pixlr) { // case of redirected from pixlr.com p = window.parent; ifm = p.$('#'+pixlr[1]+'iframe').hide(); node = p.$('#'+pixlr[1]).data('resizeoff')(); if (image[1].substr(0, 4) === 'http') { url = image[1]; ext = url.replace(/.+\.([^.]+)$/, '$1'); if (node.data('ext') !== ext) { node.closest('.ui-dialog').trigger('changeType', { extention: ext, mime : ext2mime[ext] }); } if (window.location.protocol === 'https:') { url = url.replace(/^http:/, 'https:'); } node.on('load error', function() { node.data('loading')(true); }) .attr('src', url) .data('loading')(); } else { node.data('loading')(true); } ifm.trigger('destroy').remove(); } }, pixlrSetup = function(opts, fm) { if (!hasFlash || fm.UA.ltIE8) { this.disabled = true; } }, pixlrLoad = function(mode, base) { var self = this, fm = this.fm, clPreventBack = fm.res('class', 'preventback'), node = $(base).children('img:first') .data('loading')() .data('resizeoff', function() { $(window).off('resize.'+node.attr('id')); dialog.addClass(clPreventBack); return node; }) .on('click', function() { launch(); }), dialog = $(base).closest('.ui-dialog'), elfNode = fm.getUI(), uiToast = fm.getUI('toast'), container = $('