(function(b){CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;"undefined"!=typeof b&&(b.extend(b.fn,{ckeditorGet:function(){var c=this.eq(0).data("ckeditorInstance");if(!c){throw"CKEditor is not initialized yet, use ckeditor() with a callback.";}return c;},ckeditor:function(e,j){if(!CKEDITOR.env.isCompatible){throw Error("The environment is incompatible.");}if(!b.isFunction(e)){var a=j,j=e,e=a;}var c=[],j=j||{};this.each(function(){var d=b(this),l=d.data("ckeditorInstance"),k=d.data("_ckeditorInstanceLock"),i=this,g=new b.Deferred;c.push(g.promise());if(l&&!k){e&&e.apply(l,[this]),g.resolve();}else{if(k){l.once("instanceReady",function(){setTimeout(function(){l.element?(l.element.$==i&&e&&e.apply(l,[i]),g.resolve()):setTimeout(arguments.callee,100);},0);},null,null,9999);}else{if(j.autoUpdateElement||"undefined"==typeof j.autoUpdateElement&&CKEDITOR.config.autoUpdateElement){j.autoUpdateElementJquery=!0;}j.autoUpdateElement=!1;d.data("_ckeditorInstanceLock",!0);l=b(this).is("textarea")?CKEDITOR.replace(i,j):CKEDITOR.inline(i,j);d.data("ckeditorInstance",l);l.on("instanceReady",function(m){var f=m.editor;setTimeout(function(){if(f.element){m.removeListener();f.on("dataReady",function(){d.trigger("dataReady.ckeditor",[f]);});f.on("setData",function(o){d.trigger("setData.ckeditor",[f,o.data]);});f.on("getData",function(o){d.trigger("getData.ckeditor",[f,o.data]);},999);f.on("destroy",function(){d.trigger("destroy.ckeditor",[f]);});f.on("save",function(){b(i.form).submit();return !1;},null,null,20);if(f.config.autoUpdateElementJquery&&d.is("textarea")&&b(i.form).length){var n=function(){d.ckeditor(function(){f.updateElement();});};b(i.form).submit(n);b(i.form).bind("form-pre-serialize",n);d.bind("destroy.ckeditor",function(){b(i.form).unbind("submit",n);b(i.form).unbind("form-pre-serialize",n);});}f.on("destroy",function(){d.removeData("ckeditorInstance");});d.removeData("_ckeditorInstanceLock");d.trigger("instanceReady.ckeditor",[f]);e&&e.apply(f,[i]);g.resolve();}else{setTimeout(arguments.callee,100);}},0);},null,null,9999);}}});var h=new b.Deferred;this.promise=h.promise();b.when.apply(this,c).then(function(){h.resolve();});this.editor=this.eq(0).data("ckeditorInstance");return this;}}),CKEDITOR.config.jqueryOverrideVal&&(b.fn.val=CKEDITOR.tools.override(b.fn.val,function(a){return function(l){if(arguments.length){var g=this,h=[],j=this.each(function(){var d=b(this),k=d.data("ckeditorInstance");if(d.is("textarea")&&k){var i=new b.Deferred;k.setData(l,function(){i.resolve();});h.push(i.promise());return !0;}return a.call(d,l);});if(h.length){var e=new b.Deferred;b.when.apply(this,h).done(function(){e.resolveWith(g);});return e.promise();}return j;}var j=b(this).eq(0),m=j.data("ckeditorInstance");return j.is("textarea")&&m?m.getData():a.call(j);};})));})(window.jQuery);