flash.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. (function() {
  6. function b(a, b, c) {
  7. var h = n[this.id];
  8. if (h)
  9. for (
  10. var f = this instanceof CKEDITOR.ui.dialog.checkbox, e = 0;
  11. e < h.length;
  12. e++
  13. ) {
  14. var d = h[e];
  15. switch (d.type) {
  16. case 1:
  17. if (!a) continue;
  18. if (null !== a.getAttribute(d.name)) {
  19. a = a.getAttribute(d.name);
  20. f ? this.setValue("true" == a.toLowerCase()) : this.setValue(a);
  21. return;
  22. }
  23. f && this.setValue(!!d["default"]);
  24. break;
  25. case 2:
  26. if (!a) continue;
  27. if (d.name in c) {
  28. a = c[d.name];
  29. f ? this.setValue("true" == a.toLowerCase()) : this.setValue(a);
  30. return;
  31. }
  32. f && this.setValue(!!d["default"]);
  33. break;
  34. case 4:
  35. if (!b) continue;
  36. if (b.getAttribute(d.name)) {
  37. a = b.getAttribute(d.name);
  38. f ? this.setValue("true" == a.toLowerCase()) : this.setValue(a);
  39. return;
  40. }
  41. f && this.setValue(!!d["default"]);
  42. }
  43. }
  44. }
  45. function c(a, b, c) {
  46. var h = n[this.id];
  47. if (h)
  48. for (
  49. var f = "" === this.getValue(),
  50. e = this instanceof CKEDITOR.ui.dialog.checkbox,
  51. d = 0;
  52. d < h.length;
  53. d++
  54. ) {
  55. var g = h[d];
  56. switch (g.type) {
  57. case 1:
  58. if (!a || ("data" == g.name && b && !a.hasAttribute("data")))
  59. continue;
  60. var m = this.getValue();
  61. f || (e && m === g["default"])
  62. ? a.removeAttribute(g.name)
  63. : a.setAttribute(g.name, m);
  64. break;
  65. case 2:
  66. if (!a) continue;
  67. m = this.getValue();
  68. if (f || (e && m === g["default"]))
  69. g.name in c && c[g.name].remove();
  70. else if (g.name in c) c[g.name].setAttribute("value", m);
  71. else {
  72. var p = CKEDITOR.dom.element.createFromHtml(
  73. "\x3ccke:param\x3e\x3c/cke:param\x3e",
  74. a.getDocument()
  75. );
  76. p.setAttributes({ name: g.name, value: m });
  77. 1 > a.getChildCount()
  78. ? p.appendTo(a)
  79. : p.insertBefore(a.getFirst());
  80. }
  81. break;
  82. case 4:
  83. if (!b) continue;
  84. m = this.getValue();
  85. f || (e && m === g["default"])
  86. ? b.removeAttribute(g.name)
  87. : b.setAttribute(g.name, m);
  88. }
  89. }
  90. }
  91. for (
  92. var n = {
  93. id: [{ type: 1, name: "id" }],
  94. classid: [{ type: 1, name: "classid" }],
  95. codebase: [{ type: 1, name: "codebase" }],
  96. pluginspage: [{ type: 4, name: "pluginspage" }],
  97. src: [
  98. { type: 2, name: "movie" },
  99. { type: 4, name: "src" },
  100. { type: 1, name: "data" }
  101. ],
  102. name: [{ type: 4, name: "name" }],
  103. align: [{ type: 1, name: "align" }],
  104. class: [{ type: 1, name: "class" }, { type: 4, name: "class" }],
  105. width: [{ type: 1, name: "width" }, { type: 4, name: "width" }],
  106. height: [{ type: 1, name: "height" }, { type: 4, name: "height" }],
  107. hSpace: [{ type: 1, name: "hSpace" }, { type: 4, name: "hSpace" }],
  108. vSpace: [{ type: 1, name: "vSpace" }, { type: 4, name: "vSpace" }],
  109. style: [{ type: 1, name: "style" }, { type: 4, name: "style" }],
  110. type: [{ type: 4, name: "type" }]
  111. },
  112. k = "play loop menu quality scale salign wmode bgcolor base flashvars allowScriptAccess allowFullScreen".split(
  113. " "
  114. ),
  115. l = 0;
  116. l < k.length;
  117. l++
  118. )
  119. n[k[l]] = [{ type: 4, name: k[l] }, { type: 2, name: k[l] }];
  120. k = ["play", "loop", "menu"];
  121. for (l = 0; l < k.length; l++)
  122. n[k[l]][0]["default"] = n[k[l]][1]["default"] = !0;
  123. CKEDITOR.dialog.add("flash", function(a) {
  124. var l = !a.config.flashEmbedTagOnly,
  125. k = a.config.flashAddEmbedTag || a.config.flashEmbedTagOnly,
  126. h,
  127. f =
  128. "\x3cdiv\x3e" +
  129. CKEDITOR.tools.htmlEncode(a.lang.common.preview) +
  130. '\x3cbr\x3e\x3cdiv id\x3d"cke_FlashPreviewLoader' +
  131. CKEDITOR.tools.getNextNumber() +
  132. '" style\x3d"display:none"\x3e\x3cdiv class\x3d"loading"\x3e\x26nbsp;\x3c/div\x3e\x3c/div\x3e\x3cdiv id\x3d"cke_FlashPreviewBox' +
  133. CKEDITOR.tools.getNextNumber() +
  134. '" class\x3d"FlashPreviewBox"\x3e\x3c/div\x3e\x3c/div\x3e';
  135. return {
  136. title: a.lang.flash.title,
  137. minWidth: 420,
  138. minHeight: 310,
  139. onShow: function() {
  140. this.fakeImage = this.objectNode = this.embedNode = null;
  141. h = new CKEDITOR.dom.element("embed", a.document);
  142. var e = this.getSelectedElement();
  143. if (
  144. e &&
  145. e.data("cke-real-element-type") &&
  146. "flash" == e.data("cke-real-element-type")
  147. ) {
  148. this.fakeImage = e;
  149. var d = a.restoreRealElement(e),
  150. g = null,
  151. b = null,
  152. c = {};
  153. if ("cke:object" == d.getName()) {
  154. g = d;
  155. d = g.getElementsByTag("embed", "cke");
  156. 0 < d.count() && (b = d.getItem(0));
  157. for (
  158. var d = g.getElementsByTag("param", "cke"), f = 0, l = d.count();
  159. f < l;
  160. f++
  161. ) {
  162. var k = d.getItem(f),
  163. n = k.getAttribute("name"),
  164. k = k.getAttribute("value");
  165. c[n] = k;
  166. }
  167. } else "cke:embed" == d.getName() && (b = d);
  168. this.objectNode = g;
  169. this.embedNode = b;
  170. this.setupContent(g, b, c, e);
  171. }
  172. },
  173. onOk: function() {
  174. var e = null,
  175. d = null,
  176. b = null;
  177. this.fakeImage
  178. ? ((e = this.objectNode), (d = this.embedNode))
  179. : (l &&
  180. ((e = CKEDITOR.dom.element.createFromHtml(
  181. "\x3ccke:object\x3e\x3c/cke:object\x3e",
  182. a.document
  183. )),
  184. e.setAttributes({
  185. classid: "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
  186. codebase:
  187. "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version\x3d6,0,40,0"
  188. })),
  189. k &&
  190. ((d = CKEDITOR.dom.element.createFromHtml(
  191. "\x3ccke:embed\x3e\x3c/cke:embed\x3e",
  192. a.document
  193. )),
  194. d.setAttributes({
  195. type: "application/x-shockwave-flash",
  196. pluginspage: "http://www.macromedia.com/go/getflashplayer"
  197. }),
  198. e && d.appendTo(e)));
  199. if (e)
  200. for (
  201. var b = {},
  202. c = e.getElementsByTag("param", "cke"),
  203. f = 0,
  204. h = c.count();
  205. f < h;
  206. f++
  207. )
  208. b[c.getItem(f).getAttribute("name")] = c.getItem(f);
  209. c = {};
  210. f = {};
  211. this.commitContent(e, d, b, c, f);
  212. e = a.createFakeElement(e || d, "cke_flash", "flash", !0);
  213. e.setAttributes(f);
  214. e.setStyles(c);
  215. this.fakeImage
  216. ? (e.replace(this.fakeImage), a.getSelection().selectElement(e))
  217. : a.insertElement(e);
  218. },
  219. onHide: function() {
  220. this.preview && this.preview.setHtml("");
  221. },
  222. contents: [
  223. {
  224. id: "info",
  225. label: a.lang.common.generalTab,
  226. accessKey: "I",
  227. elements: [
  228. {
  229. type: "vbox",
  230. padding: 0,
  231. children: [
  232. {
  233. type: "hbox",
  234. widths: ["280px", "110px"],
  235. align: "right",
  236. className: "cke_dialog_flash_url",
  237. children: [
  238. {
  239. id: "src",
  240. type: "text",
  241. label: a.lang.common.url,
  242. required: !0,
  243. validate: CKEDITOR.dialog.validate.notEmpty(
  244. a.lang.flash.validateSrc
  245. ),
  246. setup: b,
  247. commit: c,
  248. onLoad: function() {
  249. var a = this.getDialog(),
  250. b = function(b) {
  251. h.setAttribute("src", b);
  252. a.preview.setHtml(
  253. '\x3cembed height\x3d"100%" width\x3d"100%" src\x3d"' +
  254. CKEDITOR.tools.htmlEncode(
  255. h.getAttribute("src")
  256. ) +
  257. '" type\x3d"application/x-shockwave-flash"\x3e\x3c/embed\x3e'
  258. );
  259. };
  260. a.preview = a
  261. .getContentElement("info", "preview")
  262. .getElement()
  263. .getChild(3);
  264. this.on("change", function(a) {
  265. a.data && a.data.value && b(a.data.value);
  266. });
  267. this.getInputElement().on(
  268. "change",
  269. function() {
  270. b(this.getValue());
  271. },
  272. this
  273. );
  274. }
  275. },
  276. {
  277. type: "button",
  278. id: "browse",
  279. filebrowser: "info:src",
  280. hidden: !0,
  281. style: "display:inline-block;margin-top:14px;",
  282. label: a.lang.common.browseServer
  283. }
  284. ]
  285. }
  286. ]
  287. },
  288. {
  289. type: "hbox",
  290. widths: ["25%", "25%", "25%", "25%", "25%"],
  291. children: [
  292. {
  293. type: "text",
  294. id: "width",
  295. requiredContent: "embed[width]",
  296. style: "width:95px",
  297. label: a.lang.common.width,
  298. validate: CKEDITOR.dialog.validate.htmlLength(
  299. a.lang.common.invalidHtmlLength.replace(
  300. "%1",
  301. a.lang.common.width
  302. )
  303. ),
  304. setup: b,
  305. commit: c
  306. },
  307. {
  308. type: "text",
  309. id: "height",
  310. requiredContent: "embed[height]",
  311. style: "width:95px",
  312. label: a.lang.common.height,
  313. validate: CKEDITOR.dialog.validate.htmlLength(
  314. a.lang.common.invalidHtmlLength.replace(
  315. "%1",
  316. a.lang.common.height
  317. )
  318. ),
  319. setup: b,
  320. commit: c
  321. },
  322. {
  323. type: "text",
  324. id: "hSpace",
  325. requiredContent: "embed[hspace]",
  326. style: "width:95px",
  327. label: a.lang.flash.hSpace,
  328. validate: CKEDITOR.dialog.validate.integer(
  329. a.lang.flash.validateHSpace
  330. ),
  331. setup: b,
  332. commit: c
  333. },
  334. {
  335. type: "text",
  336. id: "vSpace",
  337. requiredContent: "embed[vspace]",
  338. style: "width:95px",
  339. label: a.lang.flash.vSpace,
  340. validate: CKEDITOR.dialog.validate.integer(
  341. a.lang.flash.validateVSpace
  342. ),
  343. setup: b,
  344. commit: c
  345. }
  346. ]
  347. },
  348. {
  349. type: "vbox",
  350. children: [
  351. { type: "html", id: "preview", style: "width:95%;", html: f }
  352. ]
  353. }
  354. ]
  355. },
  356. {
  357. id: "Upload",
  358. hidden: !0,
  359. filebrowser: "uploadButton",
  360. label: a.lang.common.upload,
  361. elements: [
  362. {
  363. type: "file",
  364. id: "upload",
  365. label: a.lang.common.upload,
  366. size: 38
  367. },
  368. {
  369. type: "fileButton",
  370. id: "uploadButton",
  371. label: a.lang.common.uploadSubmit,
  372. filebrowser: "info:src",
  373. for: ["Upload", "upload"]
  374. }
  375. ]
  376. },
  377. {
  378. id: "properties",
  379. label: a.lang.flash.propertiesTab,
  380. elements: [
  381. {
  382. type: "hbox",
  383. widths: ["50%", "50%"],
  384. children: [
  385. {
  386. id: "scale",
  387. type: "select",
  388. requiredContent: "embed[scale]",
  389. label: a.lang.flash.scale,
  390. default: "",
  391. style: "width : 100%;",
  392. items: [
  393. [a.lang.common.notSet, ""],
  394. [a.lang.flash.scaleAll, "showall"],
  395. [a.lang.flash.scaleNoBorder, "noborder"],
  396. [a.lang.flash.scaleFit, "exactfit"]
  397. ],
  398. setup: b,
  399. commit: c
  400. },
  401. {
  402. id: "allowScriptAccess",
  403. type: "select",
  404. requiredContent: "embed[allowscriptaccess]",
  405. label: a.lang.flash.access,
  406. default: "",
  407. style: "width : 100%;",
  408. items: [
  409. [a.lang.common.notSet, ""],
  410. [a.lang.flash.accessAlways, "always"],
  411. [a.lang.flash.accessSameDomain, "samedomain"],
  412. [a.lang.flash.accessNever, "never"]
  413. ],
  414. setup: b,
  415. commit: c
  416. }
  417. ]
  418. },
  419. {
  420. type: "hbox",
  421. widths: ["50%", "50%"],
  422. children: [
  423. {
  424. id: "wmode",
  425. type: "select",
  426. requiredContent: "embed[wmode]",
  427. label: a.lang.flash.windowMode,
  428. default: "",
  429. style: "width : 100%;",
  430. items: [
  431. [a.lang.common.notSet, ""],
  432. [a.lang.flash.windowModeWindow, "window"],
  433. [a.lang.flash.windowModeOpaque, "opaque"],
  434. [a.lang.flash.windowModeTransparent, "transparent"]
  435. ],
  436. setup: b,
  437. commit: c
  438. },
  439. {
  440. id: "quality",
  441. type: "select",
  442. requiredContent: "embed[quality]",
  443. label: a.lang.flash.quality,
  444. default: "high",
  445. style: "width : 100%;",
  446. items: [
  447. [a.lang.common.notSet, ""],
  448. [a.lang.flash.qualityBest, "best"],
  449. [a.lang.flash.qualityHigh, "high"],
  450. [a.lang.flash.qualityAutoHigh, "autohigh"],
  451. [a.lang.flash.qualityMedium, "medium"],
  452. [a.lang.flash.qualityAutoLow, "autolow"],
  453. [a.lang.flash.qualityLow, "low"]
  454. ],
  455. setup: b,
  456. commit: c
  457. }
  458. ]
  459. },
  460. {
  461. type: "hbox",
  462. widths: ["50%", "50%"],
  463. children: [
  464. {
  465. id: "align",
  466. type: "select",
  467. requiredContent: "object[align]",
  468. label: a.lang.common.align,
  469. default: "",
  470. style: "width : 100%;",
  471. items: [
  472. [a.lang.common.notSet, ""],
  473. [a.lang.common.left, "left"],
  474. [a.lang.flash.alignAbsBottom, "absBottom"],
  475. [a.lang.flash.alignAbsMiddle, "absMiddle"],
  476. [a.lang.flash.alignBaseline, "baseline"],
  477. [a.lang.common.alignBottom, "bottom"],
  478. [a.lang.common.alignMiddle, "middle"],
  479. [a.lang.common.right, "right"],
  480. [a.lang.flash.alignTextTop, "textTop"],
  481. [a.lang.common.alignTop, "top"]
  482. ],
  483. setup: b,
  484. commit: function(a, b, f, k, l) {
  485. var h = this.getValue();
  486. c.apply(this, arguments);
  487. h && (l.align = h);
  488. }
  489. },
  490. { type: "html", html: "\x3cdiv\x3e\x3c/div\x3e" }
  491. ]
  492. },
  493. {
  494. type: "fieldset",
  495. label: CKEDITOR.tools.htmlEncode(a.lang.flash.flashvars),
  496. children: [
  497. {
  498. type: "vbox",
  499. padding: 0,
  500. children: [
  501. {
  502. type: "checkbox",
  503. id: "menu",
  504. label: a.lang.flash.chkMenu,
  505. default: !0,
  506. setup: b,
  507. commit: c
  508. },
  509. {
  510. type: "checkbox",
  511. id: "play",
  512. label: a.lang.flash.chkPlay,
  513. default: !0,
  514. setup: b,
  515. commit: c
  516. },
  517. {
  518. type: "checkbox",
  519. id: "loop",
  520. label: a.lang.flash.chkLoop,
  521. default: !0,
  522. setup: b,
  523. commit: c
  524. },
  525. {
  526. type: "checkbox",
  527. id: "allowFullScreen",
  528. label: a.lang.flash.chkFull,
  529. default: !0,
  530. setup: b,
  531. commit: c
  532. }
  533. ]
  534. }
  535. ]
  536. }
  537. ]
  538. },
  539. {
  540. id: "advanced",
  541. label: a.lang.common.advancedTab,
  542. elements: [
  543. {
  544. type: "hbox",
  545. children: [
  546. {
  547. type: "text",
  548. id: "id",
  549. requiredContent: "object[id]",
  550. label: a.lang.common.id,
  551. setup: b,
  552. commit: c
  553. }
  554. ]
  555. },
  556. {
  557. type: "hbox",
  558. widths: ["45%", "55%"],
  559. children: [
  560. {
  561. type: "text",
  562. id: "bgcolor",
  563. requiredContent: "embed[bgcolor]",
  564. label: a.lang.flash.bgcolor,
  565. setup: b,
  566. commit: c
  567. },
  568. {
  569. type: "text",
  570. id: "class",
  571. requiredContent: "embed(cke-xyz)",
  572. label: a.lang.common.cssClass,
  573. setup: b,
  574. commit: c
  575. }
  576. ]
  577. },
  578. {
  579. type: "text",
  580. id: "style",
  581. requiredContent: "embed{cke-xyz}",
  582. validate: CKEDITOR.dialog.validate.inlineStyle(
  583. a.lang.common.invalidInlineStyle
  584. ),
  585. label: a.lang.common.cssStyle,
  586. setup: b,
  587. commit: c
  588. }
  589. ]
  590. }
  591. ]
  592. };
  593. });
  594. })();