2019-09-11 10:57:42 +00:00
|
|
|
!function(e,t){if("function"==typeof define&&define.amd)define(["elfinder"],e);else if(t){var i=t.prototype._options.commandsOptions.edit.editors;t.prototype._options.commandsOptions.edit.editors=i.concat(e(t))}}(function(e){"use strict";var t,i=window.location.search.match(/getfile=([a-z]+)/),n=e.prototype.hasRequire,o=function(){var e;try{e=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){e=!!("undefined"==typeof window.orientation||navigator&&navigator.mimeTypes["application/x-shockwave-flash"])}return e}(),a={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"},r=function(e,i){t||(t=i.arrayFlip(a));var n=t[e]||i.mimeTypes[e];return"jpeg"===n&&(n="jpg"),n},s=function(e,t){var i=$.Deferred();try{var n=document.createElement("canvas"),o=n.getContext("2d"),a=new Image,r=function(){var e,o,a=n.toDataURL(t);e=(o=a.match(/^data:([a-z0-9]+\/[a-z0-9.+-]+)/i))?o[1]:"",e.toLowerCase()===t.toLowerCase()?i.resolve(n.toDataURL(t),n):i.reject()};return a.src=e,$(a).on("load",function(){try{n.width=a.width,n.height=a.height,o.drawImage(a,0,0),r()}catch(e){i.reject()}}).on("error",function(){i.reject()}),i}catch(s){return i.reject()}},c=function(e,t,i,n){var o,a=$(this).children("img:first").data("ext",r(t.mime,n)),s=$('<div class="elfinder-edit-spinner elfinder-edit-image"/>').html('<span class="elfinder-spinner-text">'+n.i18n("ntfloadimg")+'</span><span class="elfinder-spinner"/>').hide().appendTo(this);i.match(/^data:/)||(o=n.openUrl(t.hash),a.attr("_src",i)),a.attr("id",e+"-img").attr("src",o||i).css({height:"","max-width":"100%","max-height":"100%",cursor:"pointer"}).data("loading",function(e){var t=a.closest(".elfinder-dialog").find("button,.elfinder-titlebar-button");return t.prop("disabled",!e)[e?"removeClass":"addClass"]("ui-state-disabled"),a.css("opacity",e?"":"0.3"),s[e?"hide":"show"](),a})},d=function(e,t){var i,n,o,a=e.attr("style");try{e.attr("style",""),i=e.get(0),n=document.createElement("canvas"),n.width=i.width,n.height=i.height,e.attr("style",a),n.getContext("2d").drawImage(i,0,0),o=n.toDataURL(t)}catch(r){o=e.attr("src")}return o},l=function(){if(o&&window.parent!==window){var e,t,i,n,r,s=window.location.search.match(/[?&]pixlr=([^&]+)/),c=window.location.search.match(/[?&]image=([^&]+)/);s&&(e=window.parent,t=e.$("#"+s[1]+"iframe").hide(),n=e.$("#"+s[1]).data("resizeoff")(),"http"===c[1].substr(0,4)?(i=c[1],r=i.replace(/.+\.([^.]+)$/,"$1"),n.data("ext")!==r&&n.closest(".ui-dialog").trigger("changeType",{extention:r,mime:a[r]}),"https:"===window.location.protocol&&(i=i.replace(/^http:/,"https:")),n.on("load error",function(){n.data("loading")(!0)}).attr("src",i).data("loading")()):n.data("loading")(!0),t.trigger("destroy").remove())}},p=function(e,t){o&&!t.UA.ltIE8||(this.disabled=!0)},m=function(e,t){var i,n=this,o=this.fm,a=o.res("class","preventback"),r=$(t).children("img:first").data("loading")().data("resizeoff",function(){return $(window).off("resize."+r.attr("id")),s.addClass(a),r}).on("click",function(){u()}),s=$(t).closest(".ui-dialog"),c=o.getUI(),d=o.getUI("toast"),l=$('<iframe class="ui-front" allowtransparency="true">'),p=this.file,m=15,f=function(e){e?(l.trigger("destroy").remove(),r.data("loading")(!0),o.error(e)):(d.appendTo(s.closest(".ui-dialog")),o.toast({mode:"info",msg:"Can not launch Pixlr yet. Waiting "+m+" seconds.",button:{text:"Abort",click:function(){l.trigger("destroy").remove(),r.data("loading")(!0)}},onHidden:function(){1===d.children().length&&d.appendTo(o.getUI())}}),i=setTimeout(e,1e3*m))},u=function(){var d="https://pixlr.com/"+e+"/?s=c",u=window.location.href.toString().replace(/#.*$/,""),g={};i=setTimeout(f,1e3*m),u+=(u.indexOf("?")===-1?"?":"&")+"pixlr="+r.attr("id"),d+="&referrer=elFinder&locktitle=true",d+="&exit="+encodeURIComponent(u+"&image=0"),d+="&target="+encodeURIComponent(u),d+="&title
|
|
|
|
namespace:"ckfinder"})}t.execute("imageInsert",{source:e})},s.execute=function(){var e=d.closest(".elfinder-dialog"),o=n.getCommand("getfile"),a=function(){p.hasVar&&(e.off("resize close",a),o.callback=p.callback,o.options.folders=p.folders,o.options.multiple=p.multi,n.commandMap.open=p.open,p.hasVar=!1)};e.trigger("togleminimize").one("resize close",a),p.callback=o.callback,p.folders=o.options.folders,p.multi=o.options.multiple,p.open=n.commandMap.open,p.hasVar=!0,o.callback=function(o){var a=[];return 1===o.length&&"directory"===o[0].mime?void n.one("open",function(){n.commandMap.open="getfile"}).getCommand("open").exec(o[0].hash):(n.getUI("cwd").trigger("unselectall"),$.each(o,function(e,o){i(o)?a.push(n.convAbsUrl(o.url)):t.execute("link",n.convAbsUrl(o.url))}),a.length&&r(a),void e.trigger("togleminimize"))},o.options.folders=!0,o.options.multiple=!0,n.commandMap.open="getfile",n.toast({mode:"info",msg:n.i18n("dblclickToSelect")})}),l.createUploadAdapter=function(e){return new c(e)},t.setData($(e).data("data").body),n.getUI().append($("body > div.ck-body")),$("div.ck-balloon-panel").css({"z-index":n.getMaximizeCss().zIndex+1}),o.resolve(t)})["catch"](function(e){n.error(e)})},c=function(e){var t=function(t,i,o){n.exec("upload",{files:[t]},void 0,n.cwd().hash).done(function(e){e.added&&e.added.length?n.url(e.added[0].hash,{async:!0}).done(function(e){i({"default":n.convAbsUrl(e)})}).fail(function(){o("errFileNotFound")}):o(n.i18n(e.error?e.error:"errUpload"))}).fail(function(e){var t=n.parseError(e);o(n.i18n(t?"userabort"===t?"errAbort":t:"errUploadNoFiles"))}).progress(function(t){e.uploadTotal=t.total,e.uploaded=t.progress})};this.upload=function(){return new Promise(function(i,n){e.file instanceof Promise||e.file&&"function"==typeof e.file.then?e.file.then(function(e){t(e,i,n)}):t(e.file,i,n)})},this.abort=function(){n.getUI().trigger("uploadabort")}};return i.confObj.editor?s(i.confObj.editor):(t=$.Deferred(),i.fm.loadScript([n.options.cdns.ckeditor5+"/"+a+"/ckeditor.js"],function(e){e||(e=window.BalloonEditor||window.InlineEditor||window.ClassicEditor||window.DecoupledEditor),"en"!==n.lang?i.fm.loadScript([n.options.cdns.ckeditor5+"/"+a+"/translations/"+r+".js"],function(i){t.resolve(e)},{tryRequire:!0,loadType:"tag",error:function(i){r="en",t.resolve(e)}}):t.resolve(e)},{tryRequire:!0,loadType:"tag"}),t.done(function(e){i.confObj.editor=e,s(e)})),o},getContent:function(){var e=$(this).data("data");return e.header+e.body+e.footer},close:function(e,t){t&&t.destroy()},save:function(e,t){var i=$(e),n=i.data("data");t&&(n.body=t.getData(),i.data("data",n))},focus:function(e,t){$(e).trigger("focus")}},{info:{id:"tinymce",name:"TinyMCE",iconImg:"img/editor-icons.png 0 -64"},exts:["htm","html","xhtml"],setup:function(e,t){var i=this;t.options.cdns.tinymce?(i.mceOpts={},e.extraOptions?(i.uploadOpts=Object.assign({},e.extraOptions.uploadOpts||{}),i.mceOpts=Object.assign({},e.extraOptions.tinymce||{})):i.uploadOpts={}):i.disabled=!0},load:function(e){var t=this,i=this.fm,n=$.Deferred(),o=function(){var o,a,r,s=$(e).show().parent(),c=s.closest(".elfinder-dialog"),d=s.height(),l=s.outerHeight(!0)-d,p=function(){var e;tinymce.activeEditor.windowManager.windows?(e=tinymce.activeEditor.windowManager.windows[0],a=$(e?e.getEl():void 0).hide(),r=$("#mce-modal-block").hide()):a=$(".tox-dialog-wrap").hide()},m=function(){r&&r.show(),a&&a.show()},f=tinymce.majorVersion;s.height(d),e._setHeight=function(e){if(f<5){var t,i=$(this).parent(),n=e||i.innerHeight(),o=0;i.find(".mce-container-body:first").children(".mce-top-part,.mce-statusbar").each(function(){o+=$(this).outerHeight(!0)}),t=n-o-l,i.find(".mce-edit-area iframe:first").height(t)}},o={selector:"#"+e.id,resize:!1,plugins:"print preview fullpage searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern help",toolbar:"formatselect | bold italic strikethrough forecolor backcolor | link image media | alignleft alignce
|