editorgenerator.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. init();
  2. function init(callback, msg) {
  3. if (msg) {
  4. console.log("INIT:" + msg);
  5. } else
  6. console.log("INIT||||||")
  7. if (document.getElementById("editorgenerator")) {
  8. return
  9. }
  10. /**
  11. *
  12. * @param {String}
  13. * src
  14. * @param {Function}
  15. * callback
  16. */
  17. function loadScript(src, callback) {
  18. if (src) {
  19. var head = document.getElementsByTagName('body')[0];
  20. var script = document.createElement('script');
  21. script.id = src.substring(src.lastIndexOf("/") + 1, src.length).replace("\.", "_");
  22. if (document.getElementById(script.id)) {
  23. callback();
  24. return;
  25. }
  26. script.type = 'text/javascript';
  27. script.src = src;
  28. script.onload = script.onreadystatechange = function () {
  29. if ((!this.readyState || this.readyState === "loaded" || this.readyState === "complete") && callback) {
  30. callback();
  31. script.onload = script.onreadystatechange = null;
  32. }
  33. };
  34. head.appendChild(script);
  35. }
  36. };
  37. if ((typeof $) + "" == "undefined") {
  38. // 加载ueditor专用的jquery
  39. console.log("不存在JQUERY,动态加载");
  40. loadScript("/wd/js/ueditor/jquery.js", function () {
  41. init(callback, "加载完Jquery");
  42. });
  43. return;
  44. }
  45. if ((typeof UE) + "" == "undefined") {
  46. // 检测ueditor,如果没有
  47. console.log("加载UE");
  48. loadScript("/wd/js/ueditor/ueditor.config.js", function () {
  49. loadScript("/wd/js/ueditor/ueditor.parse.js", function () {
  50. loadScript("/wd/js/ueditor/ueditor.all.js", function () {
  51. init(callback, "加载完UE");
  52. })
  53. });
  54. });
  55. return;
  56. }
  57. if ($(window).on)
  58. $(window).on("load", function () {
  59. lload();
  60. });
  61. else if ($(window).bind) {
  62. $(window).bind("load", function () {
  63. lload();
  64. });
  65. } else if ($(window).live) {
  66. $(window).live("load", function () {
  67. lload();
  68. });
  69. } else {
  70. window.onload = lload();
  71. }
  72. function lload() {
  73. if ($(".ueditorItem").length > 0)
  74. $.each($(".ueditorItem"), function () {
  75. if ($(this).attr("loaded") == "true") {
  76. return false;
  77. }
  78. $(this).attr("loaded", "true")
  79. var name = $(this).val();
  80. var options = $(this).attr("options");
  81. initEditor(name, options);
  82. })
  83. }
  84. }
  85. function addEditor(name, options) {
  86. console.log("ADD" + name)
  87. var ueitem = document.createElement("input");
  88. ueitem.type = 'hidden';
  89. ueitem.className = 'ueditorItem';
  90. ueitem.value = name;
  91. if (options)
  92. ueitem.setAttribute("options", JSON.stringify(options));
  93. ueitem.setAttribute("loaded", "false");
  94. document.getElementsByTagName('body')[0].appendChild(ueitem);
  95. }
  96. var styleAttrs = ['width', 'height'];
  97. function initEditor(name, options) {
  98. options = options || {};
  99. if (typeof(options) == "string")
  100. try {
  101. options = JSON.parse(options);
  102. } catch (e) {
  103. console.log(e.message)
  104. options = {
  105. fullable: true
  106. };
  107. }
  108. /* 再去掉,去掉 ?wdApplication= -- 不支持多个应用,ssServ= 里可以写 ss.xxx。Lin
  109. options.wdApp = options.wdApp || getUrlVar("wdApplication");
  110. if (options.wdApp == null) {
  111. alert("没获取到参数wdApp");
  112. return;
  113. }
  114. */
  115. options.forbd != null && alert("“forbd”已摒弃,请使用“mode=change”");
  116. options.forbd != null && delete options["forbd"];
  117. if (options.edittemplate) {
  118. $("body").append("<input type='hidden' id='edittemplate' value='" + options.edittemplate + "'/>");
  119. }
  120. function getUrlVar(name) {
  121. var vars = [],
  122. hash;
  123. var hashes = window.location.href.slice(
  124. window.location.href.indexOf('?') + 1).split('&');
  125. for (var i = 0; i < hashes.length; i++) {
  126. hash = hashes[i].split('=');
  127. vars.push(hash[0]);
  128. vars[hash[0]] = hash[1];
  129. }
  130. return vars[name];
  131. };
  132. /**
  133. * 绑定对象名的模板
  134. * @param {Object} lbm
  135. * @param {Object} dxm
  136. * @param {Object} editorid
  137. */
  138. var txt = $("div#" + name + "Edit");
  139. // txt.css({
  140. // "width": '100%'
  141. // });
  142. $.each(styleAttrs, function () {
  143. var attrV = txt.attr(this);
  144. if (attrV != null) {
  145. txt.css(this, attrV);
  146. }
  147. });
  148. var player = $("#" + name + "Play");
  149. var pathinp = $("input[name='" + name + "wj']").eq(0);
  150. var path = pathinp.val();
  151. /* 再去掉,去掉 ?wdApplication= -- 不支持多个应用,ssServ= 里可以写 ss.xxx。Lin
  152. window.wdApp = "&wdApp=" + options.wdApp;
  153. */
  154. if (options.lbList) {
  155. $.each(options.lbList, function () {
  156. options[this.toString()] = $("select[name='" + this.toString() + "']").val();
  157. });
  158. }
  159. options.othertmpl = $("select[name='othertmpl']").val();
  160. if (options.othertmpl) {
  161. options["t_" + options.othertmpl.toString()] = options.othertmpl.toString();
  162. }
  163. var data = wd.c.getUeditorData(path, options);
  164. var f = $("<div class='UEDITORFIELD' style='background-color:#fff;'></div>");
  165. if (txt.length > 0 && (options.mode == "edit" || options.mode == "change")) {
  166. var textarea = document.createElement("textarea");
  167. textarea.name = txt.attr("id");
  168. textarea.value = txt.html();
  169. $.each(styleAttrs, function () {
  170. var attrV = txt.attr(this);
  171. if (attrV != null) {
  172. txt.css(this, attrV);
  173. }
  174. $(textarea).css(this, txt.css(this));
  175. });
  176. /// 增加,复制 <div id="msEdit" 的 dataset -- 内容 表增加 对象名、对象ID 字段 -- 对象的附件。Lin
  177. // data-ss-nr-obj-name="${ssObjName}" data-ss-nr-obj-id="${ssObjId}"
  178. for (let key in txt[0].dataset) {
  179. if (txt[0].dataset.hasOwnProperty(key)) {
  180. textarea.dataset[key] = txt[0].dataset[key];
  181. }
  182. }
  183. ///
  184. txt.after(textarea);
  185. txt.remove();
  186. txt = $(textarea);
  187. // 编辑器
  188. console.log(options)
  189. console.log("编辑器" + name + "Edit");
  190. txt.attr("id", name + "Edit");
  191. txt.before(f);
  192. f.append(txt);
  193. // txt[0].style.width = window.getComputedStyle(txt[0]).width;
  194. pathinp.val(data.path);
  195. (function (name, opts) {
  196. var editor = UE.getEditor(name + "Edit", opts);
  197. editor.ready(function () {
  198. this.options.imgWidth = data.imgWidth;
  199. this.options.imgHeight = data.imgHeight;
  200. /* 再去掉,去掉 ?wdApplication= -- 不支持多个应用,ssServ= 里可以写 ss.xxx。Lin
  201. editor.options.wdApp = opts.wdApp;
  202. */
  203. editor.addListener("keyup", function (type, event) {
  204. if (event.keyCode === 32) {
  205. var range_ = editor.window.getSelection().getRangeAt(0);
  206. window.top.range_ = range_;
  207. var sofs = range_.startOffset;
  208. range_.setStart(range_.startContainer, sofs - 1);
  209. range_.setEnd(range_.startContainer, sofs);
  210. if (sofs > 0 && range_.toString().charCodeAt() === 32) {
  211. console.log(range_)
  212. range_.startContainer.replaceData(sofs - 1, 1, String.fromCharCode(8194)); //8194是&ensp; 也可能会用160(&nbsp;)
  213. }
  214. range_.setStart(range_.startContainer, sofs);
  215. range_.setEnd(range_.startContainer, sofs);
  216. range_.collapse(true)
  217. // 清除选定对象的所有光标对象
  218. window.getSelection().removeAllRanges()
  219. // 插入新的光标对象
  220. window.getSelection().addRange(range_)
  221. }
  222. });
  223. var callback_;
  224. if (opts.callback && typeof(opts.callback) == "string") {
  225. callback_ = eval(opts.callback);
  226. } else if (opts.callback && typeof(opts.callback) == "function") {
  227. callback_ = opts.callback;
  228. }
  229. if (opts.bindList) {
  230. console.log(opts.bindList)
  231. try {
  232. bindInput(opts.bindList, name + "Edit");
  233. } catch (e) {
  234. console.error(e.message)
  235. }
  236. }
  237. bindSelect(opts.lbList, opts.dxm, name + "Edit", function () {
  238. //切换模板之后的回调
  239. console.log(opts.bindList)
  240. if (opts.bindList) {
  241. for (k in opts.bindList) {
  242. var name = opts.bindList[k];
  243. var $inp = $("input[name='" + name + "']");
  244. if (growHeightList && growHeightList[name]) {
  245. $inp = $(growHeightList[name].getInputElement());
  246. }
  247. $inp.trigger("inputchange");
  248. }
  249. }
  250. });
  251. try {
  252. window[name + "_initWDEditor"] && window[name + "_initWDEditor"](this);
  253. } catch (e) {
  254. console.error("初始化WDEditorUI时发生异常");
  255. }
  256. this.setContent(data.content || txt.val());
  257. window.loadStyles && window.loadStyles(data.styles);
  258. callback_ && callback_.call(this);
  259. for (var i = 0; window.ueCallback != null && window.ueCallback[name] != null && i < window.ueCallback[name].length; i++) {
  260. window.ueCallback[name][i]();
  261. }
  262. // this.execCommand('cleardoc');
  263. // this.focus();
  264. // this.execCommand('inserthtml', data.content);
  265. });
  266. })(name, options)
  267. }
  268. if (player.length > 0 && options.mode == "play" || options.mode == "body") {
  269. console.log("播放器" + name + "Play");
  270. if (player.is("td")) {
  271. var id = player.attr("id");
  272. player.attr("id", "");
  273. player.append("<div id=" + id + "></div>")
  274. player = $("#" + id);
  275. }
  276. player.addClass("player").before(f);
  277. // f.before("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/uePlayer.css'>")
  278. f.append(player);
  279. //全屏、附件按钮
  280. player.css({
  281. overflow: "auto"
  282. });
  283. var t = data.content;
  284. if (options.textonly) {
  285. t = wd.display.removeHTMLTag(t);
  286. }
  287. player.html(t);
  288. if (typeof getGrowHeight != "undefined" && options.mode != "body"&&options["btn_opt_cms"]) { //有growHeight脚本,用growHeight初始化
  289. var cms_jlztm=options["btn_opt_cms"].jlztm?options["btn_opt_cms"].jlztm:options.cms_jlztm;
  290. var gh = wd.display.initGrowHighHtml(player.attr("id"), 300, options["btn_opt_cms"] ? {
  291. fj: {
  292. "key": options["btn_opt_cms"].key,
  293. "value": options["btn_opt_cms"].value,
  294. "name": options["btn_opt_cms"].name,
  295. "jlztm": cms_jlztm
  296. }
  297. }
  298. : {});
  299. if (gh.cmsBtn && options["btn_opt_cms"]) {
  300. console.log(gh.cmsBtn);
  301. bindCMS([gh.cmsBtn], options["btn_opt_cms"].value, cms_jlztm, options.cms_play, options.cms_play_atom);
  302. }
  303. } else { //ueditor原来的脚本
  304. if (options && options.toolbars) {
  305. for (var i = 0; i < options.toolbars[0].length; i++) {
  306. var o = options.toolbars[0][i];
  307. if (typeof(o) == "string" && o == "fullscreen") {
  308. // if(options && (options.fullable != "false" && options.fullable != false) && wd.display.removeHTMLTag(data.content) != '') {
  309. // f.addClass("fullable");
  310. f.prepend("<input type='button' class='list-button fullButton btn' value='全屏' onclick='ueFul(this)' />");
  311. } else if (typeof(o) == "string" && o == "cms") {
  312. var btn = $("<input type='button' class='list-button' style='float:right;margin:5px;' id='" + options["btn_opt_cms"].key + "Play' value='附件' />");
  313. f.prepend(btn);
  314. // f.append("<input type='hidden' name='fjid' value='" + options["btn_opt_cms"].value + "'/>")
  315. var cms_jlztm=options["btn_opt_cms"].jlztm?options["btn_opt_cms"].jlztm:options.cms_jlztm;
  316. bindCMS(btn, options["btn_opt_cms"].value, cms_jlztm, options.cms_play, options.cms_play_atom);
  317. }
  318. }
  319. }
  320. }
  321. // $p=$("input[name='ueditorpath']");
  322. // $("input[name='"+$p.val()+"']").remove();
  323. // $p.remove();
  324. if (!options.callback) {}
  325. else
  326. if (typeof(options.callback) == "string") {
  327. callback_ = eval(options.callback);
  328. callback_.call(this);
  329. } else
  330. if (typeof(options.callback) == 'function') {
  331. options.callback.call(this);
  332. }
  333. };
  334. }
  335. function bindCMS(btn, nrid, jlztm, cms_play, cms_play_atom) {
  336. function fjPlayClick() {
  337. if (nrid == null || nrid.length == 0) {
  338. $.ajax({
  339. type: 'GET',
  340. url: '/service?ssServ=makeAttCms', // =getNewNridAndUpdateNrmc。Lin
  341. data: {
  342. name: 'fj'
  343. },
  344. async: false,
  345. success: function (data) {
  346. nrid = data;
  347. },
  348. });
  349. }
  350. var user = ''
  351. var Nrid = 'T-' + nrid;
  352. var str = '&nrid=';
  353. str += Nrid;
  354. if (jlztm != undefined && jlztm != "") {
  355. if (cms_play.indexOf("&jlztm=") == -1){
  356. str += '&jlztm=' + jlztm;
  357. }else{
  358. var ss =cms_play.split("&jlztm=")
  359. if(ss[1]!=jlztm){
  360. cms_play=cms_play.replace("&jlztm="+ss[1],'&jlztm=' + jlztm);
  361. }
  362. }
  363. }
  364. if (user != undefined && user != "") {
  365. str += '&user=';
  366. str += user;
  367. }
  368. var nrjslbm;
  369. $.ajax({
  370. type: 'POST',
  371. url: '/service?ssServ=wrNrjslbm', // =getNrjslbm,。Lin
  372. data: {
  373. nrid: nrid
  374. },
  375. async: false,
  376. success: function (data) {
  377. nrjslbm = data;
  378. },
  379. });
  380. if (nrjslbm == 150 || nrjslbm == '150') {
  381. wd.display.showComponent({
  382. show: ['wdDialog'],
  383. hide: [],
  384. url: cms_play + str,
  385. dest: 'cmsPlay', // : 'nr_bf',。Lin
  386. title: '播放',
  387. width: 900,
  388. high: 664,
  389. wdDialogId: 44011763,
  390. form: ''
  391. });
  392. } else {
  393. wd.display.showComponent({
  394. show: ['wdDialog'],
  395. hide: [],
  396. url: cms_play_atom + str + '&nrjslbm=' + nrjslbm,
  397. dest: 'ccmsPlay', // : 'yznr_bfq',。Lin
  398. title: '播放',
  399. width: 900,
  400. high: 664,
  401. wdDialogId: 44011763,
  402. form: ''
  403. });
  404. }
  405. }
  406. (function () {
  407. var play = btn[0];
  408. if (play != null) {
  409. if (nrid == null || nrid.length == 0) {
  410. play.className = 'disabled-button';
  411. play.setAttribute('disabled', 'disabled');
  412. play.style.display = "none";
  413. } else {
  414. var flag = null;
  415. var Nrid = 'T-' + nrid;
  416. $.ajax({
  417. type: 'GET',
  418. url: '/service?ssServ=wrHasCcms', // =checkNrHasChildren'。Lin
  419. data: {
  420. 'nrid': Nrid // 'id':。统一为 "nrid" = CmsC.REQ_cmsId。Lin
  421. },
  422. dataType: 'json',
  423. async: false,
  424. success: function (data) {
  425. /// 增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  426. if (data.ssCode != 0) {
  427. alert(data.ssMsg);
  428. return;
  429. }
  430. ///
  431. flag = data.result;
  432. }
  433. });
  434. if (flag) {
  435. play.cms_jlztm = jlztm;
  436. if (play.addEventListener) {
  437. play.addEventListener('click', fjPlayClick, false);
  438. } else if (play.attachEvent) {
  439. play.attachEvent('onclick', fjPlayClick);
  440. } else {
  441. play['onclick'] = fjPlayClick;
  442. }
  443. } else {
  444. console.info(flag);
  445. play.setAttribute('disabled', 'disabled');
  446. play.style.display = "none";
  447. }
  448. }
  449. }
  450. })();
  451. }
  452. function bindSelect(lbList, dxm, editorid, callback) {
  453. if ($("#oldlbl").length < 1) {
  454. $("body").append("<input type='hidden' id='oldlbl'/>")
  455. }
  456. var olb = [];
  457. if (lbList)
  458. $.each(lbList, function () {
  459. var name = this.toString();
  460. olb.push("old" + name);
  461. var $inp = $("[name='" + name + "']");
  462. if ($inp.is("select") || (wd.edit.objectPicker && wd.edit.objectPicker.isObjectPicker($inp[0]))) { //下拉菜单或者objectpicker才能切换模板
  463. $inp.attr("id", name).after("<input type='hidden' id='old" + name + "' value='0'/>");
  464. $inp.bind("change", function () {
  465. var old = $("#old" + this.name),
  466. val = $(this).val(),
  467. content = UE.getEditor(editorid).getContent(),
  468. olblist = eval($("#oldlbl").val());
  469. if (content.trim() == "") {
  470. lbList.push("otherTmpl");
  471. loadUEDTempLate(dxm, lbList, editorid, callback);
  472. old.val(val);
  473. } else {
  474. if ($("#edittemplate").length > 0) {
  475. // console.log("EQUALS+")
  476. lbList.push("otherTmpl");
  477. loadUEDTempLate(dxm, lbList, editorid, callback);
  478. old.val($(this).val());
  479. }
  480. }
  481. });
  482. // $("select[name='" + lbm + "']").attr("id", lbm).after("<input type='hidden' id='old" + lbm + "' value='0'/>");
  483. // $("select[name='" + lbm + "']") /*.unbind("change")*/.bind("change", function () {
  484. // var old = $("#old" + lbm);
  485. // var content = UE.getEditor(editorid).getContentTxt();
  486. // var olblist = eval($("#oldlbl").val());
  487. // if (content.trim() == "") {
  488. // lbList.push("otherTmpl");
  489. // loadUEDTempLate(dxm, lbList, editorid, callback);
  490. // old.val($(this).val());
  491. // } else {
  492. // // var oldtmp = loadUEDTempLate(dxm, olblist).content;
  493. // // console.log("CONTENT:" + content);
  494. // // console.log("TEMPLATE:" + wd.display.removeHTMLTag(oldtmp));
  495. // if ($("#edittemplate").length > 0 || /*wd.display.removeHTMLTag(content) == wd.display.removeHTMLTag(oldtmp) || */(confirm("您切换了类别,是否切换对应的模板\n(切换模板后可以按编辑器上的“撤销”按钮\n或键盘上“Ctrl” + “z”进行撤销)"))) {
  496. // // console.log("EQUALS+")
  497. // lbList.push("otherTmpl");
  498. // loadUEDTempLate(dxm, lbList, editorid, callback);
  499. // old.val($(this).val());
  500. // }
  501. // }
  502. // });
  503. }
  504. });
  505. $("#oldlbl").val(JSON.stringify(olb));
  506. }
  507. function bindInput(inputList, editorid) {
  508. console.log(inputList)
  509. function bindInputChange(inputname, editorid) {
  510. var $inp = $("[name='" + inputname + "']");
  511. if (growHeightList && growHeightList[inputname]) {
  512. $inp = $(growHeightList[inputname].getInputElement());
  513. }
  514. if ($inp.length > 0) {
  515. $inp.bind("keyup keydown mouseup click change input propertychange change", function (event) {
  516. $(this).trigger("inputchange");
  517. });
  518. $inp.bind("inputchange", function (event) {
  519. var $this = $(this),
  520. val = $this.val();
  521. if ($this.is("select")) {
  522. val = $this.find("option:selected").text();
  523. } else if (wd.edit.objectPicker.isObjectPicker($this[0])) {
  524. val = wd.edit.objectPicker.getDisplayValue($this[0])
  525. }
  526. var target = $("#" + editorid).find(".edui-editor-iframeholder ").find("iframe").eq(0).contents().find("." + inputname);
  527. // console.log(a)
  528. if (val != "") {
  529. target.text(val);
  530. var e = UE.getEditor(editorid);
  531. e.setContent('', true);
  532. }
  533. });
  534. if (inputname.length >= 2 && inputname.substr(inputname.length - 2, inputname.length) == "sj") {
  535. //没有值的时候才赋值
  536. if ($inp.val() == '') {
  537. $inp.val(new Date().format("yyyy-MM-dd"));
  538. $inp.trigger("inputchange");
  539. }
  540. }
  541. $inp.trigger("inputchange");
  542. } else {
  543. console.log("没找到input:" + inputname);
  544. }
  545. }
  546. if (inputList)
  547. $.each(inputList, function (key, val) {
  548. console.log(key + ":" + val);
  549. bindInputChange(val, editorid);
  550. })
  551. }
  552. window.top.ueFul = function (obj) {
  553. //允许所有iframe全屏
  554. var arr = parent.document.getElementsByTagName('IFRAME');
  555. for (var i = 0; i < arr.length; i++) {
  556. var iframeObj = arr[i];
  557. iframeObj.setAttribute("allowfullscreen", true);
  558. }
  559. arr = parent.parent.document.getElementsByTagName('IFRAME');
  560. for (var i = 0; i < arr.length; i++) {
  561. var iframeObj = arr[i];
  562. iframeObj.setAttribute("allowfullscreen", true);
  563. }
  564. var element = $(obj).parent()[0];
  565. console.log(element);
  566. var fullscreenchange = function () {
  567. if (document.webkitFullscreenElement != null) {
  568. $(element).addClass("scrollbar");
  569. $(element).css("padding", "30px");
  570. $(element).css("box-sizing", "border-box");
  571. element.style.overflowY = "auto";
  572. element.style.overflowX = "hidden";
  573. element.style.width = "100%";
  574. element.style.height = "100%";
  575. element.style.zoom = 2;
  576. $(obj).hide();
  577. console.log("进入全屏函数");
  578. $('.list-button').css({
  579. 'display': 'none'
  580. });
  581. $('.player').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="button-restore icon-restore" style="position: fixed;right: 10px;top: 10px;height:22px;width:22px;" onclick="exitFullscreen()" ></div></div></div>');
  582. } else {
  583. console.log("退出全屏函数");
  584. $(element).removeClass("scrollbar");
  585. $(element).css("padding", "0px");
  586. $(element).css("box-sizing", "border-box");
  587. element.style.height = 'auto';
  588. element.style.width = 'auto';
  589. element.style.zoom = 1;
  590. $(obj).show();
  591. //添加监听器,监听用户进入全屏和退出全屏操作
  592. element.removeEventListener("webkitfullscreenchange", fullscreenchange);
  593. element.removeEventListener("fullscreenchange", fullscreenchange);
  594. element.removeEventListener("mozfullscreenchange", fullscreenchange);
  595. element.removeEventListener("msfullscreenchange", fullscreenchange);
  596. $('.list-button').css({
  597. 'display': 'block'
  598. });
  599. $('.player #pageClose').remove();
  600. }
  601. }
  602. element.addEventListener("webkitfullscreenchange", fullscreenchange);
  603. element.addEventListener("fullscreenchange", fullscreenchange);
  604. element.addEventListener("mozfullscreenchange", fullscreenchange);
  605. element.addEventListener("msfullscreenchange", fullscreenchange);
  606. if (element.requestFullscreen) {
  607. element.requestFullscreen();
  608. } else if (element.msRequestFullscreen) {
  609. element.msRequestFullscreen();
  610. } else if (element.mozRequestFullScreen) {
  611. element.mozRequestFullScreen();
  612. } else if (element.webkitRequestFullScreen) {
  613. element.webkitRequestFullScreen();
  614. }
  615. }
  616. ueFul = function (obj) {
  617. //允许所有iframe全屏
  618. var arr = parent.document.getElementsByTagName('IFRAME');
  619. for (var i = 0; i < arr.length; i++) {
  620. var iframeObj = arr[i];
  621. iframeObj.setAttribute("allowfullscreen", true);
  622. }
  623. arr = parent.parent.document.getElementsByTagName('IFRAME');
  624. for (var i = 0; i < arr.length; i++) {
  625. var iframeObj = arr[i];
  626. iframeObj.setAttribute("allowfullscreen", true);
  627. }
  628. var element = $(obj).parent()[0];
  629. console.log(element);
  630. var fullscreenchange = function () {
  631. if (document.webkitFullscreenElement != null) {
  632. // $(element).addClass("scrollbar");
  633. $(element).css("padding", "30px");
  634. $(element).css("box-sizing", "border-box");
  635. element.style.overflowY = "auto";
  636. element.style.overflowX = "hidden";
  637. element.style.width = "100%";
  638. element.style.height = "100%";
  639. element.style.zoom = 2;
  640. $(obj).hide();
  641. console.log("进入全屏函数");
  642. $('.list-button').css({
  643. 'display': 'none'
  644. });
  645. $('.player').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="button-restore icon-restore" style="position: fixed;right: 10px;top: 10px;height:22px;width:22px;" onclick="exitFullscreen()" ></div></div></div>');
  646. } else {
  647. console.log("退出全屏函数");
  648. $(element).removeClass("scrollbar");
  649. $(element).css("padding", "0px");
  650. $(element).css("box-sizing", "border-box");
  651. element.style.height = 'auto';
  652. element.style.width = 'auto';
  653. element.style.zoom = 1;
  654. $('#zwPlay').css('height', '88%'); //须知调样式
  655. $(obj).show();
  656. //添加监听器,监听用户进入全屏和退出全屏操作
  657. element.removeEventListener("webkitfullscreenchange", fullscreenchange);
  658. element.removeEventListener("fullscreenchange", fullscreenchange);
  659. element.removeEventListener("mozfullscreenchange", fullscreenchange);
  660. element.removeEventListener("msfullscreenchange", fullscreenchange);
  661. $('.list-button').css({
  662. 'display': 'block'
  663. });
  664. $('.player #pageClose').remove();
  665. }
  666. }
  667. element.addEventListener("webkitfullscreenchange", fullscreenchange);
  668. element.addEventListener("fullscreenchange", fullscreenchange);
  669. element.addEventListener("mozfullscreenchange", fullscreenchange);
  670. element.addEventListener("msfullscreenchange", fullscreenchange);
  671. if (element.requestFullscreen) {
  672. element.requestFullscreen();
  673. } else if (element.msRequestFullscreen) {
  674. element.msRequestFullscreen();
  675. } else if (element.mozRequestFullScreen) {
  676. element.mozRequestFullScreen();
  677. } else if (element.webkitRequestFullScreen) {
  678. element.webkitRequestFullScreen();
  679. }
  680. }
  681. // 退出全屏
  682. function exitFullscreen() {
  683. var elem = document;
  684. if (elem.webkitCancelFullScreen) {
  685. elem.webkitCancelFullScreen();
  686. } else if (elem.mozCancelFullScreen) {
  687. elem.mozCancelFullScreen();
  688. } else if (elem.cancelFullScreen) {
  689. elem.cancelFullScreen();
  690. } else if (elem.exitFullscreen) {
  691. elem.exitFullscreen();
  692. } else {
  693. alert('浏览器不支持全屏API或已被禁用,请按esc键退出');
  694. //浏览器不支持全屏API或已被禁用
  695. }
  696. }
  697. bodyFul = function (obj, hasAbstract) {
  698. //允许所有iframe全屏
  699. var arr = parent.document.getElementsByTagName('IFRAME');
  700. for (var i = 0; i < arr.length; i++) {
  701. var iframeObj = arr[i];
  702. iframeObj.setAttribute("allowfullscreen", true);
  703. }
  704. arr = parent.parent.document.getElementsByTagName('IFRAME');
  705. for (var i = 0; i < arr.length; i++) {
  706. var iframeObj = arr[i];
  707. iframeObj.setAttribute("allowfullscreen", true);
  708. }
  709. var element = $(obj).parent()[0];
  710. console.log(element);
  711. var fullscreenchange = function () {
  712. if (document.webkitFullscreenElement != null) {
  713. $(element).addClass("scrollbar");
  714. $(element).css("padding", "30px");
  715. $(element).css("box-sizing", "border-box");
  716. element.style.overflowY = "auto";
  717. element.style.overflowX = "hidden";
  718. element.style.width = "100%";
  719. element.style.height = "100%";
  720. element.style.zoom = 2;
  721. //$(obj).hide();
  722. if (hasAbstract) {
  723. $(obj).show();
  724. }
  725. console.log("进入全屏函数");
  726. $('.list-button').css({
  727. 'display': 'none'
  728. });
  729. $('.player').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="button-restore icon-restore" style="position: fixed;right: 10px;top: 10px;height:22px;width:22px;" onclick="exitFullscreen()" ></div></div></div>');
  730. } else {
  731. console.log("退出全屏函数");
  732. $(element).removeClass("scrollbar");
  733. $(element).css("padding", "0px");
  734. $(element).css("box-sizing", "border-box");
  735. element.style.height = 'auto';
  736. element.style.width = 'auto';
  737. element.style.zoom = 1;
  738. //$(obj).show();
  739. //添加监听器,监听用户进入全屏和退出全屏操作
  740. element.removeEventListener("webkitfullscreenchange", fullscreenchange);
  741. element.removeEventListener("fullscreenchange", fullscreenchange);
  742. element.removeEventListener("mozfullscreenchange", fullscreenchange);
  743. element.removeEventListener("msfullscreenchange", fullscreenchange);
  744. if (hasAbstract) {
  745. $(obj).hide();
  746. }
  747. $('.list-button').css({
  748. 'display': 'block'
  749. });
  750. $('.player #pageClose').remove();
  751. }
  752. }
  753. element.addEventListener("webkitfullscreenchange", fullscreenchange);
  754. element.addEventListener("fullscreenchange", fullscreenchange);
  755. element.addEventListener("mozfullscreenchange", fullscreenchange);
  756. element.addEventListener("msfullscreenchange", fullscreenchange);
  757. if (element.requestFullscreen) {
  758. element.requestFullscreen();
  759. } else if (element.msRequestFullscreen) {
  760. element.msRequestFullscreen();
  761. } else if (element.mozRequestFullScreen) {
  762. element.mozRequestFullScreen();
  763. } else if (element.webkitRequestFullScreen) {
  764. element.webkitRequestFullScreen();
  765. }
  766. }
  767. function loadUEDTempLate(templateName, lbList, editorid, callback) {
  768. var ueopt = UE.getEditor(editorid, options).options;
  769. var options = {
  770. mode: ueopt.mode,
  771. dxm: ueopt.dxm
  772. };
  773. options.othertmpl = $("[name='othertmpl']").val();
  774. if (options.othertmpl) {
  775. options["t_" + options.othertmpl.toString()] = options.othertmpl.toString();
  776. }
  777. options.edittemplate = $("#edittemplate").length > 0 ? 1 : null;
  778. if (lbList)
  779. $.each(lbList, function () {
  780. options[this.toString()] = $("[name='" + this.toString() + "']").val();
  781. });
  782. options.template = templateName;
  783. /* 再去掉,去掉 ?wdApplication= -- 不支持多个应用,ssServ= 里可以写 ss.xxx。Lin
  784. options.wdApp = UE.getEditor(editorid).options.wdApp;
  785. */
  786. var result = wd.c.getUeditorData(null, options);
  787. if (UE) {
  788. if (editorid) {
  789. var edit = UE.getEditor(editorid, options).ready(function () {
  790. // this.execCommand("cleardoc");
  791. // this.execCommand("inserthtml", result.content);
  792. // this.setContent(result.content, false, true);
  793. this.setContent(result.content);
  794. this.options.imgWidth = result.imgWidth;
  795. this.options.imgHeight = result.imgHeight;
  796. window.loadStyles && window.loadStyles(result.styles);
  797. });
  798. }
  799. if (callback)
  800. callback();
  801. }
  802. if (options.edittemplate && editorid)
  803. $("#" + editorid.replace("Edit", "") + "wj").val(result.path);
  804. return result;
  805. }