(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) { var // get query of getfile getfile = window.location.search.match(/getfile=([a-z]+)/), // cdns location cdns = { ace : '//cdnjs.cloudflare.com/ajax/libs/ace/1.2.6', codemirror : '//cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0', ckeditor : '//cdnjs.cloudflare.com/ajax/libs/ckeditor/4.7.0', tinymce : '//cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.3', simplemde : '//cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2' }, useRequire = (typeof define === 'function' && define.amd), hasFlash = (function() { var hasFlash; try { hasFlash = !!(new ActiveXObject('ShockwaveFlash.ShockwaveFlash')); } catch (e) { hasFlash = !!(navigator && navigator.mimeTypes["application/x-shockwave-flash"]); } return hasFlash; })(), initImgTag = function(id, file, content, fm) { var node = $(this).children('img:first'), 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; 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]; 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.remove(); } }; pixlrSetup = function(opts, fm) { if (!hasFlash) { this.disabled = true; } }, pixlrLoad = function(mode, base) { var fm = this.fm, node = $(base).children('img:first') .data('loading')() .data('resizeoff', function() { $(window).off('resize.'+node.attr('id')); return node; }) .on('click', function() { launch(); }), elfNode = fm.getUI(), container = $('