/*! * froala_editor v2.9.4 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms/ * Copyright 2014-2019 Froala Labs */ !function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof module&&module.exports?module.exports=function(e,t){return t===undefined&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),i(t)}:i(window.jQuery)}(function(T){T.extend(T.FE.POPUP_TEMPLATES,{"file.insert":"[_BUTTONS_][_UPLOAD_LAYER_][_PROGRESS_BAR_]"}),T.extend(T.FE.DEFAULTS,{fileUpload:!0,fileUploadURL:null,fileUploadParam:"file",fileUploadParams:{},fileUploadToS3:!1,fileUploadMethod:"POST",fileMaxSize:10485760,fileAllowedTypes:["*"],fileInsertButtons:["fileBack","|"],fileUseSelectedText:!1}),T.FE.PLUGINS.file=function(f){var r,p="https://i.froala.com/upload",l=2,d=3,u=4,c=5,v=6,i={};function g(){var e=f.popups.get("file.insert");e||(e=S()),e.find(".fr-layer.fr-active").removeClass("fr-active").addClass("fr-pactive"),e.find(".fr-file-progress-bar-layer").addClass("fr-active"),e.find(".fr-buttons").hide(),n(f.language.translate("Uploading"),0)}function o(e){var t=f.popups.get("file.insert");t&&(t.find(".fr-layer.fr-pactive").addClass("fr-active").removeClass("fr-pactive"),t.find(".fr-file-progress-bar-layer").removeClass("fr-active"),t.find(".fr-buttons").show(),e&&(f.events.focus(),f.popups.hide("file.insert")))}function n(e,t){var i=f.popups.get("file.insert");if(i){var r=i.find(".fr-file-progress-bar-layer");r.find("h3").text(e+(t?" "+t+"%":"")),r.removeClass("fr-error"),t?(r.find("div").removeClass("fr-indeterminate"),r.find("div > span").css("width",t+"%")):r.find("div").addClass("fr-indeterminate")}}function h(e,t,i){f.edit.on(),f.events.focus(!0),f.selection.restore(),f.opts.fileUseSelectedText&&f.selection.text().length&&(t=f.selection.text()),f.html.insert(''+t+"");var r=f.$el.find("#fr-inserted-file");r.removeAttr("id"),f.popups.hide("file.insert"),f.undo.saveStep(),C(),f.events.trigger("file.inserted",[r,i])}function m(e){var t=this.status,i=this.response,r=this.responseXML,o=this.responseText;try{if(f.opts.fileUploadToS3)if(201==t){var n=function(e){try{var t=T(e).find("Location").text(),i=T(e).find("Key").text();return!1===f.events.trigger("file.uploadedToS3",[t,i,e],!0)?(f.edit.on(),!1):t}catch(r){return U(u,e),!1}}(r);n&&h(n,e,i||r)}else U(u,i||r);else if(200<=t&&t<300){var a=function(e){try{if(!1===f.events.trigger("file.uploaded",[e],!0))return f.edit.on(),!1;var t=JSON.parse(e);return t.link?t:(U(l,e),!1)}catch(i){return U(u,e),!1}}(o);a&&h(a.link,e,i||o)}else U(d,i||o)}catch(s){U(u,i||o)}}function b(){U(u,this.response||this.responseText||this.responseXML)}function y(e){if(e.lengthComputable){var t=e.loaded/e.total*100|0;n(f.language.translate("Uploading"),t)}}function U(e,t){f.edit.on(),function(e){g();var t=f.popups.get("file.insert").find(".fr-file-progress-bar-layer");t.addClass("fr-error");var i=t.find("h3");i.text(e),f.events.disableBlur(),i.focus()}(f.language.translate("Something went wrong. Please try again.")),f.events.trigger("file.error",[{code:e,message:i[e]},t])}function w(){f.edit.on(),o(!0)}function a(e){if(void 0!==e&&0f.opts.fileMaxSize)return U(c),!1;if(f.opts.fileAllowedTypes.indexOf("*")<0&&f.opts.fileAllowedTypes.indexOf(i.type.replace(/file\//g,""))<0)return U(v),!1;if(f.drag_support.formdata&&(t=f.drag_support.formdata?new FormData:null),t){var r;if(!1!==f.opts.fileUploadToS3)for(r in t.append("key",f.opts.fileUploadToS3.keyStart+(new Date).getTime()+"-"+(i.name||"untitled")),t.append("success_action_status","201"),t.append("X-Requested-With","xhr"),t.append("Content-Type",i.type),f.opts.fileUploadToS3.params)f.opts.fileUploadToS3.params.hasOwnProperty(r)&&t.append(r,f.opts.fileUploadToS3.params[r]);for(r in f.opts.fileUploadParams)f.opts.fileUploadParams.hasOwnProperty(r)&&t.append(r,f.opts.fileUploadParams[r]);t.append(f.opts.fileUploadParam,i);var o=f.opts.fileUploadURL;f.opts.fileUploadToS3&&(o=f.opts.fileUploadToS3.uploadURL?f.opts.fileUploadToS3.uploadURL:"https://"+f.opts.fileUploadToS3.region+".amazonaws.com/"+f.opts.fileUploadToS3.bucket);var n=f.core.getXHR(o,f.opts.fileUploadMethod);n.onload=function(){m.call(n,i.name)},n.onerror=b,n.upload.onprogress=y,n.onabort=w,g();var a=f.popups.get("file.insert");a&&a.off("abortUpload").on("abortUpload",function(){4!=n.readyState&&n.abort()}),n.send(t)}}var s,l}function s(){o()}function S(e){if(e)return f.popups.onHide("file.insert",s),!0;var t;f.opts.fileUpload||f.opts.fileInsertButtons.splice(f.opts.fileInsertButtons.indexOf("fileUpload"),1),t='
'+f.button.buildList(f.opts.fileInsertButtons)+"
";var i="";f.opts.fileUpload&&(i='
'+f.language.translate("Drop file")+"
("+f.language.translate("or click")+')
');var r,o={buttons:t,upload_layer:i,progress_bar:'

Uploading

'},n=f.popups.create("file.insert",o);return r=n,f.events.$on(r,"dragover dragenter",".fr-file-upload-layer",function(){return T(this).addClass("fr-drop"),!1},!0),f.events.$on(r,"dragleave dragend",".fr-file-upload-layer",function(){return T(this).removeClass("fr-drop"),!1},!0),f.events.$on(r,"drop",".fr-file-upload-layer",function(e){e.preventDefault(),e.stopPropagation(),T(this).removeClass("fr-drop");var t=e.originalEvent.dataTransfer;t&&t.files&&(r.data("instance")||f).file.upload(t.files)},!0),f.helpers.isIOS()&&f.events.$on(r,"touchstart",'.fr-file-upload-layer input[type="file"]',function(){T(this).trigger("click")}),f.events.$on(r,"change",'.fr-file-upload-layer input[type="file"]',function(){if(this.files){var e=r.data("instance")||f;e.events.disableBlur(),r.find("input:focus").blur(),e.events.enableBlur(),e.file.upload(this.files)}T(this).val("")},!0),n}function e(e){f.node.hasClass(e,"fr-file")}function t(e){var t=e.originalEvent.dataTransfer;if(t&&t.files&&t.files.length){var i=t.files[0];if(i&&"undefined"!=typeof i.type){if(i.type.indexOf("image")<0){if(!f.opts.fileUpload)return e.preventDefault(),e.stopPropagation(),!1;f.markers.remove(),f.markers.insertAtPoint(e.originalEvent),f.$el.find(".fr-marker").replaceWith(T.FE.MARKERS),f.popups.hideAll();var r=f.popups.get("file.insert");return r||(r=S()),f.popups.setContainer("file.insert",f.$sc),f.popups.show("file.insert",e.originalEvent.pageX,e.originalEvent.pageY),g(),a(t.files),e.preventDefault(),e.stopPropagation(),!1}}else i.type.indexOf("image")<0&&(e.preventDefault(),e.stopPropagation())}}function C(){var e,t=Array.prototype.slice.call(f.el.querySelectorAll("a.fr-file")),i=[];for(e=0;e