image.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. (function() {
  6. var r = function(c, j) {
  7. function r() {
  8. var a = arguments,
  9. b = this.getContentElement("advanced", "txtdlgGenStyle");
  10. b && b.commit.apply(b, a);
  11. this.foreach(function(b) { b.commit && "txtdlgGenStyle" != b.id && b.commit.apply(b, a) })
  12. }
  13. function i(a) {
  14. if (!s) {
  15. s = 1;
  16. var b = this.getDialog(),
  17. d = b.imageElement;
  18. if (d) { this.commit(f, d); for (var a = [].concat(a), e = a.length, c, g = 0; g < e; g++)(c = b.getContentElement.apply(b, a[g].split(":"))) && c.setup(f, d) }
  19. s = 0
  20. }
  21. }
  22. var f = 1,
  23. k = /^\s*(\d+)((px)|\%)?\s*$/i,
  24. v = /(^\s*(\d+)((px)|\%)?\s*$)|^$/i,
  25. o = /^\d+px$/,
  26. w = function() {
  27. var a = this.getValue(),
  28. b = this.getDialog(),
  29. d = a.match(k);
  30. d && ("%" == d[2] && l(b, !1), a = d[1]);
  31. b.lockRatio && (d = b.originalElement, "true" == d.getCustomData("isReady") && ("txtHeight" == this.id ? (a && "0" != a && (a = Math.round(d.$.width * (a / d.$.height))), isNaN(a) || b.setValueOf("info", "txtWidth", a)) : (a && "0" != a && (a = Math.round(d.$.height * (a / d.$.width))), isNaN(a) || b.setValueOf("info", "txtHeight", a))));
  32. g(b)
  33. },
  34. g = function(a) {
  35. if (!a.originalElement || !a.preview) return 1;
  36. a.commitContent(4, a.preview);
  37. return 0
  38. },
  39. s, l = function(a,
  40. b) {
  41. if (!a.getContentElement("info", "ratioLock")) return null;
  42. var d = a.originalElement;
  43. if (!d) return null;
  44. if ("check" == b) {
  45. if (!a.userlockRatio && "true" == d.getCustomData("isReady")) {
  46. var e = a.getValueOf("info", "txtWidth"),
  47. c = a.getValueOf("info", "txtHeight"),
  48. d = 1E3 * d.$.width / d.$.height,
  49. f = 1E3 * e / c;
  50. a.lockRatio = !1;
  51. !e && !c ? a.lockRatio = !0 : !isNaN(d) && !isNaN(f) && Math.round(d) == Math.round(f) && (a.lockRatio = !0)
  52. }
  53. } else void 0 !== b ? a.lockRatio = b : (a.userlockRatio = 1, a.lockRatio = !a.lockRatio);
  54. e = CKEDITOR.document.getById(p);
  55. a.lockRatio ?
  56. e.removeClass("cke_btn_unlocked") : e.addClass("cke_btn_unlocked");
  57. e.setAttribute("aria-checked", a.lockRatio);
  58. CKEDITOR.env.hc && e.getChild(0).setHtml(a.lockRatio ? CKEDITOR.env.ie ? "■" : "▣" : CKEDITOR.env.ie ? "□" : "▢");
  59. return a.lockRatio
  60. },
  61. x = function(a) {
  62. var b = a.originalElement;
  63. if ("true" == b.getCustomData("isReady")) {
  64. var d = a.getContentElement("info", "txtWidth"),
  65. e = a.getContentElement("info", "txtHeight");
  66. d && d.setValue(b.$.width);
  67. e && e.setValue(b.$.height)
  68. }
  69. g(a)
  70. },
  71. y = function(a, b) {
  72. function d(a, b) {
  73. var d = a.match(k);
  74. return d ?
  75. ("%" == d[2] && (d[1] += "%", l(e, !1)), d[1]) : b
  76. }
  77. if (a == f) {
  78. var e = this.getDialog(),
  79. c = "",
  80. g = "txtWidth" == this.id ? "width" : "height",
  81. h = b.getAttribute(g);
  82. h && (c = d(h, c));
  83. c = d(b.getStyle(g), c);
  84. this.setValue(c)
  85. }
  86. },
  87. t, q = function() {
  88. var a = this.originalElement,
  89. b = CKEDITOR.document.getById(m);
  90. a.setCustomData("isReady", "true");
  91. a.removeListener("load", q);
  92. a.removeListener("error", h);
  93. a.removeListener("abort", h);
  94. b && b.setStyle("display", "none");
  95. this.dontResetSize || x(this);
  96. this.firstLoad && CKEDITOR.tools.setTimeout(function() { l(this, "check") },
  97. 0, this);
  98. this.dontResetSize = this.firstLoad = !1;
  99. g(this)
  100. },
  101. h = function() {
  102. var a = this.originalElement,
  103. b = CKEDITOR.document.getById(m);
  104. a.removeListener("load", q);
  105. a.removeListener("error", h);
  106. a.removeListener("abort", h);
  107. a = CKEDITOR.getUrl(CKEDITOR.plugins.get("image").path + "images/noimage.png");
  108. this.preview && this.preview.setAttribute("src", a);
  109. b && b.setStyle("display", "none");
  110. l(this, !1)
  111. },
  112. n = function(a) { return CKEDITOR.tools.getNextId() + "_" + a },
  113. p = n("btnLockSizes"),
  114. u = n("btnResetSize"),
  115. m = n("ImagePreviewLoader"),
  116. A = n("previewLink"),
  117. z = n("previewImage");
  118. return {
  119. title: c.lang.image["image" == j ? "title" : "titleButton"],
  120. minWidth: 420,
  121. minHeight: 360,
  122. onShow: function() {
  123. this.linkEditMode = this.imageEditMode = this.linkElement = this.imageElement = !1;
  124. this.lockRatio = !0;
  125. this.userlockRatio = 0;
  126. this.dontResetSize = !1;
  127. this.firstLoad = !0;
  128. this.addLink = !1;
  129. var a = this.getParentEditor(),
  130. b = a.getSelection(),
  131. d = (b = b && b.getSelectedElement()) && a.elementPath(b).contains("a", 1),
  132. c = CKEDITOR.document.getById(m);
  133. c && c.setStyle("display", "none");
  134. t = new CKEDITOR.dom.element("img",
  135. a.document);
  136. this.preview = CKEDITOR.document.getById(z);
  137. this.originalElement = a.document.createElement("img");
  138. this.originalElement.setAttribute("alt", "");
  139. this.originalElement.setCustomData("isReady", "false");
  140. if (d) {
  141. this.linkElement = d;
  142. this.linkEditMode = !0;
  143. c = d.getChildren();
  144. if (1 == c.count()) { var g = c.getItem(0).getName(); if ("img" == g || "input" == g) this.imageElement = c.getItem(0), "img" == this.imageElement.getName() ? this.imageEditMode = "img" : "input" == this.imageElement.getName() && (this.imageEditMode = "input") }
  145. "image" ==
  146. j && this.setupContent(2, d)
  147. }
  148. if (this.customImageElement) this.imageEditMode = "img", this.imageElement = this.customImageElement, delete this.customImageElement;
  149. 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;
  150. this.imageEditMode ? (this.cleanImageElement = this.imageElement, this.imageElement = this.cleanImageElement.clone(!0, !0), this.setupContent(f, this.imageElement)) : this.imageElement = a.document.createElement("img");
  151. l(this, !0);
  152. CKEDITOR.tools.trim(this.getValueOf("info", "txtUrl")) || (this.preview.removeAttribute("src"), this.preview.setStyle("display", "none"))
  153. },
  154. onOk: function() {
  155. if (this.imageEditMode) {
  156. var a = this.imageEditMode;
  157. "image" == j && "input" == a && confirm(c.lang.image.button2Img) ? (this.imageElement = c.document.createElement("img"), this.imageElement.setAttribute("alt", ""), c.insertElement(this.imageElement)) : "image" != j && "img" == a && confirm(c.lang.image.img2Button) ? (this.imageElement = c.document.createElement("input"),
  158. this.imageElement.setAttributes({ type: "image", alt: "" }), c.insertElement(this.imageElement)) : (this.imageElement = this.cleanImageElement, delete this.cleanImageElement)
  159. } else "image" == j ? this.imageElement = c.document.createElement("img") : (this.imageElement = c.document.createElement("input"), this.imageElement.setAttribute("type", "image")), this.imageElement.setAttribute("alt", "");
  160. this.linkEditMode || (this.linkElement = c.document.createElement("a"));
  161. this.commitContent(f, this.imageElement);
  162. this.commitContent(2, this.linkElement);
  163. this.imageElement.getAttribute("style") || this.imageElement.removeAttribute("style");
  164. this.imageEditMode ? !this.linkEditMode && this.addLink ? (c.insertElement(this.linkElement), this.imageElement.appendTo(this.linkElement)) : this.linkEditMode && !this.addLink && (c.getSelection().selectElement(this.linkElement), c.insertElement(this.imageElement)) : this.addLink ? this.linkEditMode ? c.insertElement(this.imageElement) : (c.insertElement(this.linkElement), this.linkElement.append(this.imageElement, !1)) : c.insertElement(this.imageElement)
  165. },
  166. onLoad: function() {
  167. "image" != j && this.hidePage("Link");
  168. var a = this._.element.getDocument();
  169. this.getContentElement("info", "ratioLock") && (this.addFocusable(a.getById(u), 5), this.addFocusable(a.getById(p), 5));
  170. this.commitContent = r
  171. },
  172. onHide: function() {
  173. this.preview && this.commitContent(8, this.preview);
  174. this.originalElement && (this.originalElement.removeListener("load", q), this.originalElement.removeListener("error", h), this.originalElement.removeListener("abort", h), this.originalElement.remove(), this.originalElement = !1);
  175. delete this.imageElement
  176. },
  177. contents: [{
  178. id: "info",
  179. label: c.lang.image.infoTab,
  180. accessKey: "I",
  181. elements: [{
  182. type: "vbox",
  183. padding: 0,
  184. children: [{
  185. type: "hbox",
  186. widths: ["280px", "110px"],
  187. align: "right",
  188. children: [{
  189. id: "txtUrl",
  190. type: "text",
  191. label: c.lang.common.url,
  192. required: !0,
  193. onChange: function() {
  194. var a = this.getDialog(),
  195. b = this.getValue();
  196. if (0 < b.length) {
  197. var a = this.getDialog(),
  198. d = a.originalElement;
  199. a.preview && a.preview.removeStyle("display");
  200. d.setCustomData("isReady", "false");
  201. var c = CKEDITOR.document.getById(m);
  202. c && c.setStyle("display",
  203. "");
  204. d.on("load", q, a);
  205. d.on("error", h, a);
  206. d.on("abort", h, a);
  207. d.setAttribute("src", b);
  208. a.preview && (t.setAttribute("src", b), a.preview.setAttribute("src", t.$.src), g(a))
  209. } else a.preview && (a.preview.removeAttribute("src"), a.preview.setStyle("display", "none"))
  210. },
  211. setup: function(a, b) {
  212. if (a == f) {
  213. var d = b.data("cke-saved-src") || b.getAttribute("src");
  214. this.getDialog().dontResetSize = !0;
  215. this.setValue(d);
  216. this.setInitValue()
  217. }
  218. },
  219. commit: function(a, b) {
  220. a == f && (this.getValue() || this.isChanged()) ? (b.data("cke-saved-src", this.getValue()),
  221. b.setAttribute("src", this.getValue())) : 8 == a && (b.setAttribute("src", ""), b.removeAttribute("src"))
  222. },
  223. validate: CKEDITOR.dialog.validate.notEmpty(c.lang.image.urlMissing)
  224. }, { type: "button", id: "browse", style: "display:inline-block;margin-top:14px;", align: "center", label: c.lang.common.browseServer, hidden: !0, filebrowser: "info:txtUrl" }]
  225. }]
  226. }, {
  227. id: "txtAlt",
  228. type: "text",
  229. label: c.lang.image.alt,
  230. accessKey: "T",
  231. "default": "",
  232. onChange: function() { g(this.getDialog()) },
  233. setup: function(a, b) { a == f && this.setValue(b.getAttribute("alt")) },
  234. commit: function(a, b) { a == f ? (this.getValue() || this.isChanged()) && b.setAttribute("alt", this.getValue()) : 4 == a ? b.setAttribute("alt", this.getValue()) : 8 == a && b.removeAttribute("alt") }
  235. }, {
  236. type: "hbox",
  237. children: [{
  238. id: "basic",
  239. type: "vbox",
  240. children: [{
  241. type: "hbox",
  242. requiredContent: "img{width,height}",
  243. widths: ["50%", "50%"],
  244. children: [{
  245. type: "vbox",
  246. padding: 1,
  247. children: [{
  248. type: "text",
  249. width: "45px",
  250. id: "txtWidth",
  251. label: c.lang.common.width,
  252. onKeyUp: w,
  253. onChange: function() { i.call(this, "advanced:txtdlgGenStyle") },
  254. validate: function() {
  255. var a =
  256. this.getValue().match(v);
  257. (a = !!(a && 0 !== parseInt(a[1], 10))) || alert(c.lang.common.invalidWidth);
  258. return a
  259. },
  260. setup: y,
  261. commit: function(a, b, d) {
  262. var e = this.getValue();
  263. a == f ? (e && c.activeFilter.check("img{width,height}") ? b.setStyle("width", CKEDITOR.tools.cssLength(e)) : b.removeStyle("width"), !d && b.removeAttribute("width")) : 4 == a ? e.match(k) ? b.setStyle("width", CKEDITOR.tools.cssLength(e)) : (a = this.getDialog().originalElement, "true" == a.getCustomData("isReady") && b.setStyle("width", a.$.width + "px")) : 8 == a && (b.removeAttribute("width"),
  264. b.removeStyle("width"))
  265. }
  266. }, {
  267. type: "text",
  268. id: "txtHeight",
  269. width: "45px",
  270. label: c.lang.common.height,
  271. onKeyUp: w,
  272. onChange: function() { i.call(this, "advanced:txtdlgGenStyle") },
  273. validate: function() {
  274. var a = this.getValue().match(v);
  275. (a = !!(a && 0 !== parseInt(a[1], 10))) || alert(c.lang.common.invalidHeight);
  276. return a
  277. },
  278. setup: y,
  279. commit: function(a, b, d) {
  280. var e = this.getValue();
  281. a == f ? (e && c.activeFilter.check("img{width,height}") ? b.setStyle("height", CKEDITOR.tools.cssLength(e)) : b.removeStyle("height"), !d && b.removeAttribute("height")) :
  282. 4 == a ? e.match(k) ? b.setStyle("height", CKEDITOR.tools.cssLength(e)) : (a = this.getDialog().originalElement, "true" == a.getCustomData("isReady") && b.setStyle("height", a.$.height + "px")) : 8 == a && (b.removeAttribute("height"), b.removeStyle("height"))
  283. }
  284. }]
  285. }, {
  286. id: "ratioLock",
  287. type: "html",
  288. style: "margin-top:30px;width:40px;height:40px;",
  289. onLoad: function() {
  290. var a = CKEDITOR.document.getById(u),
  291. b = CKEDITOR.document.getById(p);
  292. a && (a.on("click", function(a) {
  293. x(this);
  294. a.data && a.data.preventDefault()
  295. }, this.getDialog()), a.on("mouseover",
  296. function() { this.addClass("cke_btn_over") }, a), a.on("mouseout", function() { this.removeClass("cke_btn_over") }, a));
  297. b && (b.on("click", function(a) {
  298. l(this);
  299. var b = this.originalElement,
  300. c = this.getValueOf("info", "txtWidth");
  301. if (b.getCustomData("isReady") == "true" && c) {
  302. b = b.$.height / b.$.width * c;
  303. if (!isNaN(b)) {
  304. this.setValueOf("info", "txtHeight", Math.round(b));
  305. g(this)
  306. }
  307. }
  308. a.data && a.data.preventDefault()
  309. }, this.getDialog()), b.on("mouseover", function() { this.addClass("cke_btn_over") }, b), b.on("mouseout", function() { this.removeClass("cke_btn_over") },
  310. b))
  311. },
  312. html: '<div><a href="javascript:void(0)" tabindex="-1" title="' + c.lang.image.lockRatio + '" class="cke_btn_locked" id="' + p + '" role="checkbox"><span class="cke_icon"></span><span class="cke_label">' + c.lang.image.lockRatio + '</span></a><a href="javascript:void(0)" tabindex="-1" title="' + c.lang.image.resetSize + '" class="cke_btn_reset" id="' + u + '" role="button"><span class="cke_label">' + c.lang.image.resetSize + "</span></a></div>"
  313. }]
  314. }, {
  315. type: "vbox",
  316. padding: 1,
  317. children: [{
  318. type: "text",
  319. id: "txtBorder",
  320. requiredContent: "img{border-width}",
  321. width: "60px",
  322. label: c.lang.image.border,
  323. "default": "",
  324. onKeyUp: function() { g(this.getDialog()) },
  325. onChange: function() { i.call(this, "advanced:txtdlgGenStyle") },
  326. validate: CKEDITOR.dialog.validate.integer(c.lang.image.validateBorder),
  327. setup: function(a, b) {
  328. if (a == f) {
  329. var d;
  330. d = (d = (d = b.getStyle("border-width")) && d.match(/^(\d+px)(?: \1 \1 \1)?$/)) && parseInt(d[1], 10);
  331. isNaN(parseInt(d, 10)) && (d = b.getAttribute("border"));
  332. this.setValue(d)
  333. }
  334. },
  335. commit: function(a, b, d) {
  336. var c = parseInt(this.getValue(), 10);
  337. a == f || 4 == a ? (isNaN(c) ? !c &&
  338. this.isChanged() && b.removeStyle("border") : (b.setStyle("border-width", CKEDITOR.tools.cssLength(c)), b.setStyle("border-style", "solid")), !d && a == f && b.removeAttribute("border")) : 8 == a && (b.removeAttribute("border"), b.removeStyle("border-width"), b.removeStyle("border-style"), b.removeStyle("border-color"))
  339. }
  340. }, {
  341. type: "text",
  342. id: "txtHSpace",
  343. requiredContent: "img{margin-left,margin-right}",
  344. width: "60px",
  345. label: c.lang.image.hSpace,
  346. "default": "",
  347. onKeyUp: function() { g(this.getDialog()) },
  348. onChange: function() {
  349. i.call(this,
  350. "advanced:txtdlgGenStyle")
  351. },
  352. validate: CKEDITOR.dialog.validate.integer(c.lang.image.validateHSpace),
  353. setup: function(a, b) {
  354. if (a == f) {
  355. var d, c;
  356. d = b.getStyle("margin-left");
  357. c = b.getStyle("margin-right");
  358. d = d && d.match(o);
  359. c = c && c.match(o);
  360. d = parseInt(d, 10);
  361. c = parseInt(c, 10);
  362. d = d == c && d;
  363. isNaN(parseInt(d, 10)) && (d = b.getAttribute("hspace"));
  364. this.setValue(d)
  365. }
  366. },
  367. commit: function(a, b, d) {
  368. var c = parseInt(this.getValue(), 10);
  369. a == f || 4 == a ? (isNaN(c) ? !c && this.isChanged() && (b.removeStyle("margin-left"), b.removeStyle("margin-right")) :
  370. (b.setStyle("margin-left", CKEDITOR.tools.cssLength(c)), b.setStyle("margin-right", CKEDITOR.tools.cssLength(c))), !d && a == f && b.removeAttribute("hspace")) : 8 == a && (b.removeAttribute("hspace"), b.removeStyle("margin-left"), b.removeStyle("margin-right"))
  371. }
  372. }, {
  373. type: "text",
  374. id: "txtVSpace",
  375. requiredContent: "img{margin-top,margin-bottom}",
  376. width: "60px",
  377. label: c.lang.image.vSpace,
  378. "default": "",
  379. onKeyUp: function() { g(this.getDialog()) },
  380. onChange: function() { i.call(this, "advanced:txtdlgGenStyle") },
  381. validate: CKEDITOR.dialog.validate.integer(c.lang.image.validateVSpace),
  382. setup: function(a, b) {
  383. if (a == f) {
  384. var c, e;
  385. c = b.getStyle("margin-top");
  386. e = b.getStyle("margin-bottom");
  387. c = c && c.match(o);
  388. e = e && e.match(o);
  389. c = parseInt(c, 10);
  390. e = parseInt(e, 10);
  391. c = c == e && c;
  392. isNaN(parseInt(c, 10)) && (c = b.getAttribute("vspace"));
  393. this.setValue(c)
  394. }
  395. },
  396. commit: function(a, b, c) {
  397. var e = parseInt(this.getValue(), 10);
  398. a == f || 4 == a ? (isNaN(e) ? !e && this.isChanged() && (b.removeStyle("margin-top"), b.removeStyle("margin-bottom")) : (b.setStyle("margin-top", CKEDITOR.tools.cssLength(e)), b.setStyle("margin-bottom", CKEDITOR.tools.cssLength(e))), !c && a == f && b.removeAttribute("vspace")) : 8 == a && (b.removeAttribute("vspace"), b.removeStyle("margin-top"), b.removeStyle("margin-bottom"))
  399. }
  400. }, {
  401. id: "cmbAlign",
  402. requiredContent: "img{float}",
  403. type: "select",
  404. widths: ["35%", "65%"],
  405. style: "width:90px",
  406. label: c.lang.common.align,
  407. "default": "",
  408. items: [
  409. [c.lang.common.notSet, ""],
  410. [c.lang.common.alignLeft, "left"],
  411. [c.lang.common.alignRight, "right"]
  412. ],
  413. onChange: function() {
  414. g(this.getDialog());
  415. i.call(this, "advanced:txtdlgGenStyle")
  416. },
  417. setup: function(a, b) {
  418. if (a == f) {
  419. var c = b.getStyle("float");
  420. switch (c) {
  421. case "inherit":
  422. case "none":
  423. c = ""
  424. }!c && (c = (b.getAttribute("align") || "").toLowerCase());
  425. this.setValue(c)
  426. }
  427. },
  428. commit: function(a, b, c) {
  429. var e = this.getValue();
  430. if (a == f || 4 == a) {
  431. if (e ? b.setStyle("float", e) : b.removeStyle("float"), !c && a == f) switch (e = (b.getAttribute("align") || "").toLowerCase(), e) {
  432. case "left":
  433. case "right":
  434. b.removeAttribute("align")
  435. }
  436. } else 8 == a && b.removeStyle("float")
  437. }
  438. }]
  439. }]
  440. }, {
  441. type: "vbox",
  442. height: "250px",
  443. children: [{
  444. type: "html",
  445. id: "htmlPreview",
  446. style: "width:95%;",
  447. html: "<div>" + CKEDITOR.tools.htmlEncode(c.lang.common.preview) +
  448. '<br><div id="' + m + '" class="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div><div class="ImagePreviewBox"><table><tr><td><a href="javascript:void(0)" target="_blank" onclick="return false;" id="' + A + '"><img id="' + z + '" alt="" /></a>' + (c.config.image_previewText || "") +
  449. "</td></tr></table></div></div>"
  450. }]
  451. }]
  452. }]
  453. }, {
  454. id: "Link",
  455. requiredContent: "a[href]",
  456. label: c.lang.image.linkTab,
  457. padding: 0,
  458. elements: [{
  459. id: "txtUrl",
  460. type: "text",
  461. label: c.lang.common.url,
  462. style: "width: 100%",
  463. "default": "",
  464. setup: function(a, b) {
  465. if (2 == a) {
  466. var c = b.data("cke-saved-href");
  467. c || (c = b.getAttribute("href"));
  468. this.setValue(c)
  469. }
  470. },
  471. commit: function(a, b) {
  472. if (2 == a && (this.getValue() || this.isChanged())) {
  473. var d = this.getValue();
  474. b.data("cke-saved-href", d);
  475. b.setAttribute("href", d);
  476. if (this.getValue() || !c.config.image_removeLinkByEmptyURL) this.getDialog().addLink = !0
  477. }
  478. }
  479. }, { type: "button", id: "browse", filebrowser: { action: "Browse", target: "Link:txtUrl", url: c.config.filebrowserImageBrowseLinkUrl }, style: "float:right", hidden: !0, label: c.lang.common.browseServer }, {
  480. id: "cmbTarget",
  481. type: "select",
  482. requiredContent: "a[target]",
  483. label: c.lang.common.target,
  484. "default": "",
  485. items: [
  486. [c.lang.common.notSet, ""],
  487. [c.lang.common.targetNew, "_blank"],
  488. [c.lang.common.targetTop, "_top"],
  489. [c.lang.common.targetSelf, "_self"],
  490. [c.lang.common.targetParent, "_parent"]
  491. ],
  492. setup: function(a, b) {
  493. 2 == a && this.setValue(b.getAttribute("target") ||
  494. "")
  495. },
  496. commit: function(a, b) { 2 == a && (this.getValue() || this.isChanged()) && b.setAttribute("target", this.getValue()) }
  497. }]
  498. }, { id: "Upload", hidden: 0, filebrowser: "uploadButton", label: c.lang.image.upload, elements: [{ type: "file", id: "upload", label: c.lang.image.btnUpload, style: "height:40px", size: 38 }, { type: "fileButton", id: "uploadButton", filebrowser: "info:txtUrl", label: c.lang.image.btnUpload, "for": ["Upload", "upload"] }] }, {
  499. id: "advanced",
  500. label: c.lang.common.advancedTab,
  501. elements: [{
  502. type: "hbox",
  503. widths: ["50%", "25%", "25%"],
  504. children: [{ type: "text", id: "linkId", requiredContent: "img[id]", label: c.lang.common.id, setup: function(a, b) { a == f && this.setValue(b.getAttribute("id")) }, commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("id", this.getValue()) } }, {
  505. id: "cmbLangDir",
  506. type: "select",
  507. requiredContent: "img[dir]",
  508. style: "width : 100px;",
  509. label: c.lang.common.langDir,
  510. "default": "",
  511. items: [
  512. [c.lang.common.notSet, ""],
  513. [c.lang.common.langDirLtr, "ltr"],
  514. [c.lang.common.langDirRtl, "rtl"]
  515. ],
  516. setup: function(a, b) { a == f && this.setValue(b.getAttribute("dir")) },
  517. commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("dir", this.getValue()) }
  518. }, { type: "text", id: "txtLangCode", requiredContent: "img[lang]", label: c.lang.common.langCode, "default": "", setup: function(a, b) { a == f && this.setValue(b.getAttribute("lang")) }, commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("lang", this.getValue()) } }]
  519. }, {
  520. type: "text",
  521. id: "txtGenLongDescr",
  522. requiredContent: "img[longdesc]",
  523. label: c.lang.common.longDescr,
  524. setup: function(a, b) { a == f && this.setValue(b.getAttribute("longDesc")) },
  525. commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("longDesc", this.getValue()) }
  526. }, {
  527. type: "hbox",
  528. widths: ["50%", "50%"],
  529. children: [{ type: "text", id: "txtGenClass", requiredContent: "img(cke-xyz)", label: c.lang.common.cssClass, "default": "", setup: function(a, b) { a == f && this.setValue(b.getAttribute("class")) }, commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("class", this.getValue()) } }, {
  530. type: "text",
  531. id: "txtGenTitle",
  532. requiredContent: "img[title]",
  533. label: c.lang.common.advisoryTitle,
  534. "default": "",
  535. onChange: function() { g(this.getDialog()) },
  536. setup: function(a, b) { a == f && this.setValue(b.getAttribute("title")) },
  537. commit: function(a, b) { a == f ? (this.getValue() || this.isChanged()) && b.setAttribute("title", this.getValue()) : 4 == a ? b.setAttribute("title", this.getValue()) : 8 == a && b.removeAttribute("title") }
  538. }]
  539. }, {
  540. type: "text",
  541. id: "txtdlgGenStyle",
  542. requiredContent: "img{cke-xyz}",
  543. label: c.lang.common.cssStyle,
  544. validate: CKEDITOR.dialog.validate.inlineStyle(c.lang.common.invalidInlineStyle),
  545. "default": "",
  546. setup: function(a,
  547. b) {
  548. if (a == f) {
  549. var c = b.getAttribute("style");
  550. !c && b.$.style.cssText && (c = b.$.style.cssText);
  551. this.setValue(c);
  552. var e = b.$.style.height,
  553. c = b.$.style.width,
  554. e = (e ? e : "").match(k),
  555. c = (c ? c : "").match(k);
  556. this.attributesInStyle = { height: !!e, width: !!c }
  557. }
  558. },
  559. onChange: function() {
  560. i.call(this, "info:cmbFloat info:cmbAlign info:txtVSpace info:txtHSpace info:txtBorder info:txtWidth info:txtHeight".split(" "));
  561. g(this)
  562. },
  563. commit: function(a, b) { a == f && (this.getValue() || this.isChanged()) && b.setAttribute("style", this.getValue()) }
  564. }]
  565. }]
  566. }
  567. };
  568. CKEDITOR.dialog.add("image", function(c) { return r(c, "image") });
  569. CKEDITOR.dialog.add("imagebutton", function(c) { return r(c, "imagebutton") })
  570. })();