/*! * froala_editor v2.0.4 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms * Copyright 2014-2015 Froala Labs */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){"use strict";if(a.extend(a.FroalaEditor.DEFAULTS,{imageManagerLoadURL:"http://i.froala.com/load-files",imageManagerLoadMethod:"get",imageManagerLoadParams:{},imageManagerPreloader:"",imageManagerDeleteURL:"",imageManagerDeleteMethod:"post",imageManagerDeleteParams:{},imageManagerPageSize:12,imageManagerScrollOffset:20,imageManagerToggleTags:!0}),a.FroalaEditor.PLUGINS.imageManager=function(b){function c(){z.show(),F.show(),U=b.image.get(),A||x(),i(),b.$document.find("body").addClass("prevent-scroll"),b.helpers.isMobile()&&b.$document.find("body").addClass("fr-mobile")}function d(){b.events.enableBlur(),z.hide(),F.hide(),b.$document.find("body").removeClass("prevent-scroll fr-mobile")}function e(){var b=a(window).outerWidth();return 768>b?2:1200>b?3:4}function f(){B.empty();for(var a=0;K>a;a++)B.append('
')}function g(){var c="";b.opts.theme&&(c=" "+b.opts.theme+"-theme");var d='
';return d+='

'+b.language.translate("Manage Images")+'

',d+='
',d+="
",d+='',d+='
',d+="
",a(d)}function h(){z=g(),b.helpers.isMobile()||z.addClass("fr-desktop"),z.appendTo("body"),F=a('
').appendTo("body"),b.opts.theme&&F.addClass(b.opts.theme+"-theme"),d(),b.events.on("destroy",function(){z.removeData().remove(),F.removeData().remove()},!0)}function i(){A.show(),B.find(".fr-list-column").empty(),b.opts.imageManagerLoadURL?a.ajax({url:b.opts.imageManagerLoadURL,method:b.opts.imageManagerLoadMethod,data:b.opts.imageManagerLoadParams,dataType:"json"}).done(function(a,c,d){b.events.trigger("imageManager.imagesLoaded",[a]),j(a,d.response),A.hide()}).fail(function(){var a=this.xhr();s(M,a.response||a.responseText)}):s(N)}function j(a,b){try{B.find(".fr-list-column").empty(),H=0,I=0,J=0,G=a,k()}catch(c){s(O,b)}}function k(){if(IB.outerHeight()-C.outerHeight())){H++;for(var a=b.opts.imageManagerPageSize*(H-1);a');p(!1),d.onload=function(){e.height(Math.floor(e.width()/d.width*d.height));var f=a("");if(c.thumb)f.attr("src",c.thumb);else{if(s(P,c),!c.url)return s(Q,c),!1;f.attr("src",c.url)}if(c.url&&f.attr("data-url",c.url),c.tag)if(E.find(".fr-modal-more.fr-not-available").removeClass("fr-not-available"),E.find(".fr-modal-tags").show(),c.tag.indexOf(",")>=0){for(var g=c.tag.split(","),h=0;h'+g[h]+"");f.attr("data-tag",g.join())}else 0===D.find('a[title="'+c.tag.trim()+'"]').length&&D.append(''+c.tag.trim()+""),f.attr("data-tag",c.tag.trim());for(var i in c)"thumb"!=i&&"url"!=i&&"tag"!=i&&f.attr("data-"+i,c[i]);e.append(f).append('').append(''),D.find(".fr-selected-tag").each(function(a,b){w(f,b.text)||e.hide()}),f.on("load",function(){e.removeClass("fr-empty"),e.height("auto"),I++;var a=n(parseInt(f.parent().attr("class").match(/fr-image-(\d+)/)[1],10)+1);o(a),p(!1),I%b.opts.imageManagerPageSize===0&&k()}),b.events.trigger("imageManager.imageLoaded",[f])},d.onerror=function(){I++,e.remove();var a=n(parseInt(e.attr("class").match(/fr-image-(\d+)/)[1],10)+1);o(a),s(L,c),I%b.opts.imageManagerPageSize===0&&k()},d.src=c.url,m().append(e)}function m(){var b,c;return B.find(".fr-list-column").each(function(d,e){var f=a(e);0===d?(c=f.outerHeight(),b=f):f.outerHeight()=b;d--){var e=B.find(".fr-image-"+d);e.length&&(c.push(e),a('
').append(e),B.find(".fr-image-"+d).remove())}return c}function o(a){for(var b=a.length-1;b>=0;b--)m().append(a[b])}function p(a){if(void 0===a&&(a=!0),!z.is(":visible"))return!0;var c=e();if(c!=K){K=c;var d=n();f(),o(d)}var g=b.$window.height(),h=z.find(".fr-modal-wrapper"),i=parseFloat(h.css("margin-top"))+parseFloat(h.css("margin-bottom")),j=parseFloat(h.css("padding-top"))+parseFloat(h.css("padding-bottom")),l=parseFloat(h.css("border-top-width")),m=h.find("h4").outerHeight();C.height(Math.min(B.outerHeight(),g-i-j-m-l)),a&&k()}function q(c){var e=a(c.currentTarget).siblings("img");if(d(),b.image.showProgressBar(),U)U.trigger("click");else{b.events.focus(!0),b.selection.restore();var f=b.position.getBoundingRect(),g=f.left+f.width/2,h=f.top+f.height;b.popups.setContainer("image.insert",b.$box||a("body")),b.popups.show("image.insert",g,h)}var i={},j=e.data();for(var k in j)"url"!=k&&"tag"!=k&&(i[k]=j[k]);b.image.insert(e.data("url"),!1,i,U)}function r(c){var d=a(c.currentTarget).siblings("img"),e=b.language.translate("Are you sure? Image will be deleted.");confirm(e)&&(b.opts.imageManagerDeleteURL?b.events.trigger("imageManager.beforeDeleteImage",[d])!==!1&&(d.parent().addClass("fr-image-deleting"),a.ajax({method:b.opts.imageManagerDeleteMethod,url:b.opts.imageManagerDeleteURL,data:a.extend({src:d.attr("src")},b.opts.imageManagerDeleteParams)}).done(function(a){b.events.trigger("imageManager.imageDeleted",[a]);var c=n(parseInt(d.parent().attr("class").match(/fr-image-(\d+)/)[1],10)+1);d.parent().remove(),o(c),p(!0)}).fail(function(){var a=this.xhr();s(R,a.response||a.responseText)})):s(S))}function s(c,d){c>=10&&20>c?A.hide():c>=20&&30>c&&a(".fr-image-deleting").removeClass("fr-image-deleting"),b.events.trigger("imageManager.error",[{code:c,message:T[c]},d])}function t(){var a=E.find(".fr-modal-title-line").outerHeight(),b=D.outerHeight();E.toggleClass(".fr-show-tags"),E.hasClass(".fr-show-tags")?(E.css("height",a+b),D.find("a").css("opacity",1)):(E.css("height",a),D.find("a").css("opacity",0))}function u(){var b=D.find(".fr-selected-tag");b.length>0?(B.find("img").parent().show(),b.each(function(b,c){B.find("img").each(function(b,d){var e=a(d);w(e,c.text)||e.parent().hide()})})):B.find("img").parent().show();var c=n();o(c),k()}function v(c){c.preventDefault();var d=a(c.currentTarget);d.toggleClass("fr-selected-tag"),b.opts.imageManagerToggleTags&&d.siblings("a").removeClass("fr-selected-tag"),u()}function w(a,b){for(var c=a.attr("data-tag").split(","),d=0;d