2 Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.md or http://ckeditor.com/license
6 if ("undefined" == typeof a) throw Error("jQuery should be loaded before CKEditor jQuery adapter.");
7 if ("undefined" == typeof CKEDITOR) throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");
8 CKEDITOR.config.jqueryOverrideVal = "undefined" == typeof CKEDITOR.config.jqueryOverrideVal ? !0 : CKEDITOR.config.jqueryOverrideVal;
10 ckeditorGet: function() {
11 var a = this.eq(0).data("ckeditorInstance");
12 if (!a) throw "CKEditor is not initialized yet, use ckeditor() with a callback.";
15 ckeditor: function(g, d) {
16 if (!CKEDITOR.env.isCompatible) throw Error("The environment is incompatible.");
17 if (!a.isFunction(g)) {
24 this.each(function() {
26 c = b.data("ckeditorInstance"),
27 f = b.data("_ckeditorInstanceLock"),
31 if (c && !f) g && g.apply(c, [this]), l.resolve();
32 else if (f) c.once("instanceReady", function() {
33 setTimeout(function() {
34 c.element ? (c.element.$ == h && g && g.apply(c, [h]), l.resolve()) : setTimeout(arguments.callee, 100)
39 if (d.autoUpdateElement || "undefined" == typeof d.autoUpdateElement && CKEDITOR.config.autoUpdateElement) d.autoUpdateElementJquery = !0;
40 d.autoUpdateElement = !1;
41 b.data("_ckeditorInstanceLock", !0);
42 c = a(this).is("textarea") ? CKEDITOR.replace(h, d) : CKEDITOR.inline(h, d);
43 b.data("ckeditorInstance", c);
44 c.on("instanceReady", function(d) {
46 setTimeout(function() {
49 e.on("dataReady", function() {
50 b.trigger("dataReady.ckeditor", [e])
52 e.on("setData", function(a) {
53 b.trigger("setData.ckeditor", [e, a.data])
55 e.on("getData", function(a) {
56 b.trigger("getData.ckeditor", [e, a.data])
58 e.on("destroy", function() {
59 b.trigger("destroy.ckeditor", [e])
61 e.on("save", function() {
65 if (e.config.autoUpdateElementJquery && b.is("textarea") && a(h.form).length) {
67 b.ckeditor(function() {
72 a(h.form).bind("form-pre-serialize", c);
73 b.bind("destroy.ckeditor", function() {
74 a(h.form).unbind("submit", c);
75 a(h.form).unbind("form-pre-serialize",
79 e.on("destroy", function() {
80 b.removeData("ckeditorInstance")
82 b.removeData("_ckeditorInstanceLock");
83 b.trigger("instanceReady.ckeditor", [e]);
86 } else setTimeout(arguments.callee, 100)
91 var f = new a.Deferred;
92 this.promise = f.promise();
93 a.when.apply(this, k).then(function() {
96 this.editor = this.eq(0).data("ckeditorInstance");
100 CKEDITOR.config.jqueryOverrideVal && (a.fn.val = CKEDITOR.tools.override(a.fn.val, function(g) {
102 if (arguments.length) {
106 f = this.each(function() {
108 c = b.data("ckeditorInstance");
109 if (b.is("textarea") && c) {
110 var f = new a.Deferred;
111 c.setData(d, function() {
120 var b = new a.Deferred;
121 a.when.apply(this, k).done(function() {
128 var f = a(this).eq(0),
129 c = f.data("ckeditorInstance");
130 return f.is("textarea") && c ? c.getData() : g.call(f)