/* Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license*/(function(a){if("undefined"==typeofa)throwError("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeofCKEDITOR)throwError("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeofCKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){vara=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";returna},ckeditor:function(g,e){if(!CKEDITOR.env.isCompatible)throwError("The environment is incompatible.");if(!a.isFunction(g)){varm=e;e=g;g=m}vark=[];e=e||{};this.each(function(){varb=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,l=newa.Deferred;k.push(l.promise());if(c&&!f)g&&g.apply(c,[this]),l.resolve();elseif(f)c.once("instanceReady",function(){setTimeout(functiond(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),l.resolve()):setTimeout(d,100)},0)},null,null,9999);else{if(e.autoUpdateElement||"undefined"==typeofe.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)e.autoUpdateElementJquery=!0;e.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,e):CKEDITOR.inline(h,e);b.data("ckeditorInstance",c);c.on("instanceReady",function(e){vard=e.editor;setTimeout(functionn(){if(d.element){e.removeListener();d.on("dataReady",function(){b.trigger("dataReady.ckeditor",[d])});d.on("setData",function(a){b.trigger("setData.ckeditor",[d,a.data])});d.on("getData",function(a){b.trigger("getData.ckeditor",[d,a.data])},999);d.on("destroy",function(){b.trigger("destroy.ckeditor",[d])});d.on("save",function(){a(h.form).submit();return!1},null,null,20);if(d.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){varc=function(){b.ckeditor(function(){d.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",c)})}d.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[d]);g&&g.apply(d,[h]);l.resolve()}elsesetTimeout(n,100)},0)},null,null,9999)}});varf=newa.Deferred;this.promise=f.promise();a.when.apply(this,k).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");returnthis}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){returnfunction(e){if(arguments.length){varm=this,k=[],f=this.each(function(){varb=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){varf=newa.Deferred;c.setData(e,function(){f.resolve()});k.push(f.promise());return!0}returng.call(b,e)});if(k.length){varb=newa.Deferred;a.when.apply(this,k).done(function(){b.resolveWith(m)});returnb.promise()}returnf}varf=a(this).eq(0),c=f.data("ckeditorInstance");returnf.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery);