2 Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.md or http://ckeditor.com/license
6 var v = function(d, l) {
9 b = this.getContentElement("advanced", "txtdlgGenStyle");
10 b && b.commit.apply(b, a);
11 this.foreach(function(b) {
12 b.commit && "txtdlgGenStyle" != b.id && b.commit.apply(b, a)
19 var b = this.getDialog(),
24 for (var d = a.length, f, g = 0; g < d; g++)(f = b.getContentElement.apply(b, a[g].split(":"))) && f.setup(1, c)
29 var m = /^\s*(\d+)((px)|\%)?\s*$/i,
30 z = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i,
33 var a = this.getValue(),
36 c && ("%" == c[2] && n(b, !1), a = c[1]);
37 b.lockRatio && (c = b.originalElement, "true" == c.getCustomData("isReady") && ("txtHeight" == this.id ? (a && "0" != a && (a = Math.round(a / c.$.height * c.$.width)), isNaN(a) || b.setValueOf("info", "txtWidth", a)) : (a && "0" != a && (a = Math.round(a / c.$.width * c.$.height)), isNaN(a) || b.setValueOf("info", "txtHeight", a))));
41 if (!a.originalElement || !a.preview) return 1;
42 a.commitContent(4, a.preview);
47 if (!a.getContentElement("info", "ratioLock")) return null;
48 var c = a.originalElement;
51 if (!a.userlockRatio && "true" == c.getCustomData("isReady")) {
52 var d = a.getValueOf("info", "txtWidth"),
53 f = a.getValueOf("info", "txtHeight"),
54 c = 1E3 * c.$.width / c.$.height,
57 d || f ? isNaN(c) || isNaN(g) || Math.round(c) != Math.round(g) || (a.lockRatio = !0) : a.lockRatio = !0
59 } else void 0 !== b ? a.lockRatio = b : (a.userlockRatio = 1, a.lockRatio = !a.lockRatio);
60 d = CKEDITOR.document.getById(t);
62 d.removeClass("cke_btn_unlocked") : d.addClass("cke_btn_unlocked");
63 d.setAttribute("aria-checked", a.lockRatio);
64 CKEDITOR.env.hc && d.getChild(0).setHtml(a.lockRatio ? CKEDITOR.env.ie ? "■" : "▣" : CKEDITOR.env.ie ? "□" : "▢");
68 var c = a.originalElement;
69 if ("true" == c.getCustomData("isReady")) {
70 var d = a.getContentElement("info", "txtWidth"),
71 f = a.getContentElement("info", "txtHeight"),
73 b ? c = g = 0 : (g = c.$.width, c = c.$.height);
83 return c ? ("%" == c[2] && (c[1] += "%", n(d, !1)), c[1]) : b
86 var d = this.getDialog(),
88 g = "txtWidth" == this.id ? "width" : "height",
89 e = b.getAttribute(g);
91 f = c(b.getStyle(g), f);
96 var a = this.originalElement,
97 b = CKEDITOR.document.getById(p);
98 a.setCustomData("isReady", "true");
99 a.removeListener("load", u);
100 a.removeListener("error", h);
101 a.removeListener("abort", h);
102 b && b.setStyle("display", "none");
103 this.dontResetSize || B(this, !1 === d.config.image_prefillDimensions);
105 CKEDITOR.tools.setTimeout(function() {
108 this.dontResetSize = this.firstLoad = !1;
112 var a = this.originalElement,
113 b = CKEDITOR.document.getById(p);
114 a.removeListener("load", u);
115 a.removeListener("error", h);
116 a.removeListener("abort", h);
117 a = CKEDITOR.getUrl(CKEDITOR.plugins.get("image").path + "images/noimage.png");
118 this.preview && this.preview.setAttribute("src", a);
119 b && b.setStyle("display", "none");
123 return CKEDITOR.tools.getNextId() + "_" + a
125 t = q("btnLockSizes"),
126 y = q("btnResetSize"),
127 p = q("ImagePreviewLoader"),
128 E = q("previewLink"),
129 D = q("previewImage");
131 title: d.lang.image["image" == l ? "title" : "titleButton"],
132 minWidth: "moono-lisa" == (CKEDITOR.skinName || d.config.skin) ? 500 : 420,
135 this.linkEditMode = this.imageEditMode = this.linkElement = this.imageElement = !1;
137 this.userlockRatio = 0;
138 this.dontResetSize = !1;
141 var a = this.getParentEditor(),
142 b = a.getSelection(),
143 c = (b = b && b.getSelectedElement()) && a.elementPath(b).contains("a",
145 d = CKEDITOR.document.getById(p);
146 d && d.setStyle("display", "none");
147 x = new CKEDITOR.dom.element("img", a.document);
148 this.preview = CKEDITOR.document.getById(D);
149 this.originalElement = a.document.createElement("img");
150 this.originalElement.setAttribute("alt", "");
151 this.originalElement.setCustomData("isReady", "false");
152 c && (this.linkElement = c, this.addLink = this.linkEditMode = !0, a = c.getChildren(), 1 == a.count() && (d = a.getItem(0), d.type == CKEDITOR.NODE_ELEMENT && (d.is("img") || d.is("input")) && (this.imageElement = a.getItem(0),
153 this.imageElement.is("img") ? this.imageEditMode = "img" : this.imageElement.is("input") && (this.imageEditMode = "input"))), "image" == l && this.setupContent(2, c));
154 if (this.customImageElement) this.imageEditMode = "img", this.imageElement = this.customImageElement, delete this.customImageElement;
155 else if (b && "img" == b.getName() && !b.data("cke-realelement") || b && "input" == b.getName() && "image" == b.getAttribute("type")) this.imageEditMode = b.getName(), this.imageElement = b;
156 this.imageEditMode && (this.cleanImageElement = this.imageElement,
157 this.imageElement = this.cleanImageElement.clone(!0, !0), this.setupContent(1, this.imageElement));
159 CKEDITOR.tools.trim(this.getValueOf("info", "txtUrl")) || (this.preview.removeAttribute("src"), this.preview.setStyle("display", "none"))
162 if (this.imageEditMode) {
163 var a = this.imageEditMode;
164 "image" == l && "input" == a && confirm(d.lang.image.button2Img) ? (this.imageElement = d.document.createElement("img"), this.imageElement.setAttribute("alt", ""), d.insertElement(this.imageElement)) : "image" != l && "img" ==
165 a && confirm(d.lang.image.img2Button) ? (this.imageElement = d.document.createElement("input"), this.imageElement.setAttributes({
168 }), d.insertElement(this.imageElement)) : (this.imageElement = this.cleanImageElement, delete this.cleanImageElement)
169 } else "image" == l ? this.imageElement = d.document.createElement("img") : (this.imageElement = d.document.createElement("input"), this.imageElement.setAttribute("type", "image")), this.imageElement.setAttribute("alt", "");
170 this.linkEditMode || (this.linkElement = d.document.createElement("a"));
171 this.commitContent(1, this.imageElement);
172 this.commitContent(2, this.linkElement);
173 this.imageElement.getAttribute("style") || this.imageElement.removeAttribute("style");
174 this.imageEditMode ? !this.linkEditMode && this.addLink ? (d.insertElement(this.linkElement), this.imageElement.appendTo(this.linkElement)) : this.linkEditMode && !this.addLink && (d.getSelection().selectElement(this.linkElement), d.insertElement(this.imageElement)) : this.addLink ? this.linkEditMode ? this.linkElement.equals(d.getSelection().getSelectedElement()) ?
175 (this.linkElement.setHtml(""), this.linkElement.append(this.imageElement, !1)) : d.insertElement(this.imageElement) : (d.insertElement(this.linkElement), this.linkElement.append(this.imageElement, !1)) : d.insertElement(this.imageElement)
178 "image" != l && this.hidePage("Link");
179 var a = this._.element.getDocument();
180 this.getContentElement("info", "ratioLock") && (this.addFocusable(a.getById(y), 5), this.addFocusable(a.getById(t), 5));
181 this.commitContent = v
184 this.preview && this.commitContent(8,
186 this.originalElement && (this.originalElement.removeListener("load", u), this.originalElement.removeListener("error", h), this.originalElement.removeListener("abort", h), this.originalElement.remove(), this.originalElement = !1);
187 delete this.imageElement
191 label: d.lang.image.infoTab,
198 widths: ["280px", "110px"],
200 className: "cke_dialog_image_url",
204 label: d.lang.common.url,
206 onChange: function() {
207 var a = this.getDialog(),
210 var a = this.getDialog(),
211 c = a.originalElement;
212 a.preview && a.preview.removeStyle("display");
213 c.setCustomData("isReady", "false");
214 var d = CKEDITOR.document.getById(p);
215 d && d.setStyle("display", "");
219 c.setAttribute("src", b);
220 a.preview && (x.setAttribute("src", b), a.preview.setAttribute("src", x.$.src), e(a))
221 } else a.preview && (a.preview.removeAttribute("src"), a.preview.setStyle("display",
224 setup: function(a, b) {
226 var c = b.data("cke-saved-src") || b.getAttribute("src");
227 this.getDialog().dontResetSize = !0;
232 commit: function(a, b) {
233 1 == a && (this.getValue() || this.isChanged()) ? (b.data("cke-saved-src", this.getValue()), b.setAttribute("src", this.getValue())) : 8 == a && (b.setAttribute("src", ""), b.removeAttribute("src"))
235 validate: CKEDITOR.dialog.validate.notEmpty(d.lang.image.urlMissing)
239 style: "display:inline-block;margin-top:14px;",
241 label: d.lang.common.browseServer,
243 filebrowser: "info:txtUrl"
249 label: d.lang.image.alt,
252 onChange: function() {
255 setup: function(a, b) {
256 1 == a && this.setValue(b.getAttribute("alt"))
258 commit: function(a, b) {
259 1 == a ? (this.getValue() || this.isChanged()) && b.setAttribute("alt", this.getValue()) : 4 == a ? b.setAttribute("alt", this.getValue()) : 8 == a && b.removeAttribute("alt")
268 requiredContent: "img{width,height}",
269 widths: ["50%", "50%"],
277 label: d.lang.common.width,
279 onChange: function() {
280 k.call(this, "advanced:txtdlgGenStyle")
282 validate: function() {
283 var a = this.getValue().match(z);
284 (a = !(!a || 0 === parseInt(a[1], 10))) || alert(d.lang.common.invalidWidth);
288 commit: function(a, b) {
289 var c = this.getValue();
290 1 == a ? (c && d.activeFilter.check("img{width,height}") ? b.setStyle("width", CKEDITOR.tools.cssLength(c)) :
291 b.removeStyle("width"), b.removeAttribute("width")) : 4 == a ? c.match(m) ? b.setStyle("width", CKEDITOR.tools.cssLength(c)) : (c = this.getDialog().originalElement, "true" == c.getCustomData("isReady") && b.setStyle("width", c.$.width + "px")) : 8 == a && (b.removeAttribute("width"), b.removeStyle("width"))
297 label: d.lang.common.height,
299 onChange: function() {
300 k.call(this, "advanced:txtdlgGenStyle")
302 validate: function() {
303 var a = this.getValue().match(z);
304 (a = !(!a || 0 === parseInt(a[1], 10))) ||
305 alert(d.lang.common.invalidHeight);
309 commit: function(a, b) {
310 var c = this.getValue();
311 1 == a ? (c && d.activeFilter.check("img{width,height}") ? b.setStyle("height", CKEDITOR.tools.cssLength(c)) : b.removeStyle("height"), b.removeAttribute("height")) : 4 == a ? c.match(m) ? b.setStyle("height", CKEDITOR.tools.cssLength(c)) : (c = this.getDialog().originalElement, "true" == c.getCustomData("isReady") && b.setStyle("height", c.$.height + "px")) : 8 == a && (b.removeAttribute("height"), b.removeStyle("height"))
317 className: "cke_dialog_image_ratiolock",
318 style: "margin-top:30px;width:40px;height:40px;",
320 var a = CKEDITOR.document.getById(y),
321 b = CKEDITOR.document.getById(t);
322 a && (a.on("click", function(a) {
324 a.data && a.data.preventDefault()
325 }, this.getDialog()), a.on("mouseover", function() {
326 this.addClass("cke_btn_over")
327 }, a), a.on("mouseout", function() {
328 this.removeClass("cke_btn_over")
330 b && (b.on("click", function(a) {
332 var b = this.originalElement,
333 d = this.getValueOf("info", "txtWidth");
335 b.getCustomData("isReady") && d && (b = b.$.height / b.$.width * d, isNaN(b) || (this.setValueOf("info", "txtHeight", Math.round(b)), e(this)));
336 a.data && a.data.preventDefault()
337 }, this.getDialog()), b.on("mouseover", function() {
338 this.addClass("cke_btn_over")
339 }, b), b.on("mouseout", function() {
340 this.removeClass("cke_btn_over")
343 html: '\x3cdiv\x3e\x3ca href\x3d"javascript:void(0)" tabindex\x3d"-1" title\x3d"' + d.lang.image.lockRatio + '" class\x3d"cke_btn_locked" id\x3d"' + t + '" role\x3d"checkbox"\x3e\x3cspan class\x3d"cke_icon"\x3e\x3c/span\x3e\x3cspan class\x3d"cke_label"\x3e' +
344 d.lang.image.lockRatio + '\x3c/span\x3e\x3c/a\x3e\x3ca href\x3d"javascript:void(0)" tabindex\x3d"-1" title\x3d"' + d.lang.image.resetSize + '" class\x3d"cke_btn_reset" id\x3d"' + y + '" role\x3d"button"\x3e\x3cspan class\x3d"cke_label"\x3e' + d.lang.image.resetSize + "\x3c/span\x3e\x3c/a\x3e\x3c/div\x3e"
352 requiredContent: "img{border-width}",
354 label: d.lang.image.border,
356 onKeyUp: function() {
359 onChange: function() {
361 "advanced:txtdlgGenStyle")
363 validate: CKEDITOR.dialog.validate.integer(d.lang.image.validateBorder),
364 setup: function(a, b) {
367 c = (c = (c = b.getStyle("border-width")) && c.match(/^(\d+px)(?: \1 \1 \1)?$/)) && parseInt(c[1], 10);
368 isNaN(parseInt(c, 10)) && (c = b.getAttribute("border"));
372 commit: function(a, b) {
373 var c = parseInt(this.getValue(), 10);
374 1 == a || 4 == a ? (isNaN(c) ? !c && this.isChanged() && b.removeStyle("border") : (b.setStyle("border-width", CKEDITOR.tools.cssLength(c)), b.setStyle("border-style",
375 "solid")), 1 == a && b.removeAttribute("border")) : 8 == a && (b.removeAttribute("border"), b.removeStyle("border-width"), b.removeStyle("border-style"), b.removeStyle("border-color"))
380 requiredContent: "img{margin-left,margin-right}",
382 label: d.lang.image.hSpace,
384 onKeyUp: function() {
387 onChange: function() {
388 k.call(this, "advanced:txtdlgGenStyle")
390 validate: CKEDITOR.dialog.validate.integer(d.lang.image.validateHSpace),
391 setup: function(a, b) {
395 c = b.getStyle("margin-left");
396 d = b.getStyle("margin-right");
402 isNaN(parseInt(c, 10)) && (c = b.getAttribute("hspace"));
406 commit: function(a, b) {
407 var c = parseInt(this.getValue(), 10);
408 1 == a || 4 == a ? (isNaN(c) ? !c && this.isChanged() && (b.removeStyle("margin-left"), b.removeStyle("margin-right")) : (b.setStyle("margin-left", CKEDITOR.tools.cssLength(c)), b.setStyle("margin-right", CKEDITOR.tools.cssLength(c))), 1 == a && b.removeAttribute("hspace")) :
409 8 == a && (b.removeAttribute("hspace"), b.removeStyle("margin-left"), b.removeStyle("margin-right"))
414 requiredContent: "img{margin-top,margin-bottom}",
416 label: d.lang.image.vSpace,
418 onKeyUp: function() {
421 onChange: function() {
422 k.call(this, "advanced:txtdlgGenStyle")
424 validate: CKEDITOR.dialog.validate.integer(d.lang.image.validateVSpace),
425 setup: function(a, b) {
428 c = b.getStyle("margin-top");
429 d = b.getStyle("margin-bottom");
435 isNaN(parseInt(c, 10)) && (c = b.getAttribute("vspace"));
439 commit: function(a, b) {
440 var c = parseInt(this.getValue(), 10);
441 1 == a || 4 == a ? (isNaN(c) ? !c && this.isChanged() && (b.removeStyle("margin-top"), b.removeStyle("margin-bottom")) : (b.setStyle("margin-top", CKEDITOR.tools.cssLength(c)), b.setStyle("margin-bottom", CKEDITOR.tools.cssLength(c))), 1 == a && b.removeAttribute("vspace")) : 8 == a && (b.removeAttribute("vspace"), b.removeStyle("margin-top"), b.removeStyle("margin-bottom"))
445 requiredContent: "img{float}",
447 widths: ["35%", "65%"],
449 label: d.lang.common.align,
452 [d.lang.common.notSet, ""],
453 [d.lang.common.alignLeft, "left"],
454 [d.lang.common.alignRight, "right"]
456 onChange: function() {
458 k.call(this, "advanced:txtdlgGenStyle")
460 setup: function(a, b) {
462 var c = b.getStyle("float");
467 }!c && (c = (b.getAttribute("align") || "").toLowerCase());
473 var c = this.getValue();
474 if (1 == a || 4 == a) {
475 if (c ? b.setStyle("float", c) : b.removeStyle("float"), 1 == a) switch (c = (b.getAttribute("align") || "").toLowerCase(), c) {
478 b.removeAttribute("align")
480 } else 8 == a && b.removeStyle("float")
491 html: "\x3cdiv\x3e" + CKEDITOR.tools.htmlEncode(d.lang.common.preview) + '\x3cbr\x3e\x3cdiv id\x3d"' + p + '" class\x3d"ImagePreviewLoader" style\x3d"display:none"\x3e\x3cdiv class\x3d"loading"\x3e\x26nbsp;\x3c/div\x3e\x3c/div\x3e\x3cdiv class\x3d"ImagePreviewBox"\x3e\x3ctable\x3e\x3ctr\x3e\x3ctd\x3e\x3ca href\x3d"javascript:void(0)" target\x3d"_blank" onclick\x3d"return false;" id\x3d"' +
492 E + '"\x3e\x3cimg id\x3d"' + D + '" alt\x3d"" /\x3e\x3c/a\x3e' + (d.config.image_previewText || "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris.") +
493 "\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/div\x3e\x3c/div\x3e"
499 requiredContent: "a[href]",
500 label: d.lang.image.linkTab,
505 label: d.lang.common.url,
506 style: "width: 100%",
508 setup: function(a, b) {
510 var c = b.data("cke-saved-href");
511 c || (c = b.getAttribute("href"));
515 commit: function(a, b) {
516 if (2 == a && (this.getValue() || this.isChanged())) {
517 var c = this.getValue();
518 b.data("cke-saved-href", c);
519 b.setAttribute("href", c);
521 !d.config.image_removeLinkByEmptyURL ? this.getDialog().addLink = !0 : this.getDialog().addLink = !1
527 className: "cke_dialog_image_browse",
530 target: "Link:txtUrl",
531 url: d.config.filebrowserImageBrowseLinkUrl
533 style: "float:right",
535 label: d.lang.common.browseServer
539 requiredContent: "a[target]",
540 label: d.lang.common.target,
543 [d.lang.common.notSet, ""],
544 [d.lang.common.targetNew, "_blank"],
545 [d.lang.common.targetTop,
548 [d.lang.common.targetSelf, "_self"],
549 [d.lang.common.targetParent, "_parent"]
551 setup: function(a, b) {
552 2 == a && this.setValue(b.getAttribute("target") || "")
554 commit: function(a, b) {
555 2 == a && (this.getValue() || this.isChanged()) && b.setAttribute("target", this.getValue())
561 filebrowser: "uploadButton",
562 label: d.lang.image.upload,
566 label: d.lang.image.btnUpload,
567 style: "height:40px",
572 filebrowser: "info:txtUrl",
573 label: d.lang.image.btnUpload,
574 "for": ["Upload", "upload"]
578 label: d.lang.common.advancedTab,
581 widths: ["50%", "25%", "25%"],
585 requiredContent: "img[id]",
586 label: d.lang.common.id,
587 setup: function(a, b) {
588 1 == a && this.setValue(b.getAttribute("id"))
590 commit: function(a, b) {
591 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("id", this.getValue())
596 requiredContent: "img[dir]",
597 style: "width : 100px;",
598 label: d.lang.common.langDir,
601 [d.lang.common.notSet,
604 [d.lang.common.langDirLtr, "ltr"],
605 [d.lang.common.langDirRtl, "rtl"]
607 setup: function(a, b) {
608 1 == a && this.setValue(b.getAttribute("dir"))
610 commit: function(a, b) {
611 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("dir", this.getValue())
616 requiredContent: "img[lang]",
617 label: d.lang.common.langCode,
619 setup: function(a, b) {
620 1 == a && this.setValue(b.getAttribute("lang"))
622 commit: function(a, b) {
623 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("lang", this.getValue())
628 id: "txtGenLongDescr",
629 requiredContent: "img[longdesc]",
630 label: d.lang.common.longDescr,
631 setup: function(a, b) {
632 1 == a && this.setValue(b.getAttribute("longDesc"))
634 commit: function(a, b) {
635 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("longDesc", this.getValue())
639 widths: ["50%", "50%"],
643 requiredContent: "img(cke-xyz)",
644 label: d.lang.common.cssClass,
646 setup: function(a, b) {
647 1 == a && this.setValue(b.getAttribute("class"))
651 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("class", this.getValue())
656 requiredContent: "img[title]",
657 label: d.lang.common.advisoryTitle,
659 onChange: function() {
662 setup: function(a, b) {
663 1 == a && this.setValue(b.getAttribute("title"))
665 commit: function(a, b) {
666 1 == a ? (this.getValue() || this.isChanged()) && b.setAttribute("title", this.getValue()) : 4 == a ? b.setAttribute("title", this.getValue()) : 8 == a && b.removeAttribute("title")
671 id: "txtdlgGenStyle",
672 requiredContent: "img{cke-xyz}",
673 label: d.lang.common.cssStyle,
674 validate: CKEDITOR.dialog.validate.inlineStyle(d.lang.common.invalidInlineStyle),
676 setup: function(a, b) {
678 var c = b.getAttribute("style");
679 !c && b.$.style.cssText && (c = b.$.style.cssText);
681 var d = b.$.style.height,
683 d = (d ? d : "").match(m),
684 c = (c ? c : "").match(m);
685 this.attributesInStyle = {
691 onChange: function() {
692 k.call(this, "info:cmbFloat info:cmbAlign info:txtVSpace info:txtHSpace info:txtBorder info:txtWidth info:txtHeight".split(" "));
695 commit: function(a, b) {
696 1 == a && (this.getValue() || this.isChanged()) && b.setAttribute("style", this.getValue())
702 CKEDITOR.dialog.add("image", function(d) {
705 CKEDITOR.dialog.add("imagebutton", function(d) {
706 return v(d, "imagebutton")