if (typeof window.wd == "undefined") { window.wd = {}; } if (!wd.display) { wd.display = {}; } (function () { if (wd.topWindow) return; var currParent = window; var i = 1; while (currParent != top) { try { currParent.parent[new Date().getMilliseconds()] = 1; // 如果这行不报“没权限错误”,才执行下一行。 currParent = currParent.parent; } catch (e) { break; } } /** * 得到同域的顶层窗口,不直接用top,是因为有把WD的页面嵌入到OA的作子页面的情形 如果顶层窗口直接用top,当顶层窗口是另一网站时,就会报错。 */ wd.topWindow = currParent; })(); if (!wd.topWindow.wd) { wd.topWindow.wd = {}; } if (!wd.topWindow.wd.display) { wd.topWindow.wd.display = {}; } /* * Change log: * * --02-14-2014-- function name wd.display.showComponent from title = ''+title+''; to title = ''+title+''; * * */ // 初始化滚动条,by SPACE 2019-01-07 // 关闭鼠标加载动画, by SPACE 2019-04-02 $(document).ready(function () { // waitThenInitNiceScorll(); 不再使用NiceScorll滚动条 Ben(20260106) try { wd.display.closeLoad(); } catch (e) {} }); function waitThenInitNiceScorll() { try { document.onreadystatechange = function () { if (document.readyState == "complete") setTimeout("initNiceScorll()", 200); else setTimeout("waitThenInitNiceScorll()", 10); }; } catch (e) { console.log(e); } } /** * 初始化滚动条 */ var flag = false; var resizeScrollIv; function initNiceScroll() { try { // 流程设计器 if ( $("#draw_demo").html() != undefined || $("#draw_demo").html() != null || $("#workFlowDesigner").html() != null ) { return; } // 网站设计页 if ($("#updateDesignWebpageUrl").val() != null) { return; } // 内容播放器 if ($("#fileProperty").val() != null) { return; } // 大滚动条 var b = $("body"); if ($(b).attr("nicescroll")) { if ($(b).attr("nicescroll") == "true") { loadScorll(b); } } else { loadScorll(b); } loadScorll($("iframe[name='ssTabIframe']")); // [name='wdTabFrame']。Lin loadScorll($(".scrollbar")); loadScorll($(".mainDiv")); loadScorll($(".content-div")); loadScorll(parent.$(".content-div")); loadScorll($(".CodeMirror-vscrollbar")); var iframe = window.parent.getIframeByElement(document.body); var iframeObj = $(iframe); // loadScorll(iframeObj); // 小滚动条 loadSmallScorll($(".smallScrollbar")); // 0.5秒定时监听滚动条变化 clearInterval(resizeScrollIv); resizeScrollIv = setInterval(function () { try { $("body").getNiceScroll().resize(); $("iframe[name='ssTabIframe']").getNiceScroll().resize(); // [name='wdTabFrame']。Lin $(".mainDiv").getNiceScroll().resize(); $(".scrollbar").getNiceScroll().resize(); $(".content-div").getNiceScroll().resize(); $(parent.$(".content-div")).getNiceScroll().resize(); // $(iframeObj).getNiceScroll().resize(); $(".CodeMirror-vscrollbar").getNiceScroll().resize(); $(".smallScrollbar").getNiceScroll().resize(); } catch (e) { console.error(e); } }, 500); } catch (e) { if (!flag) { flag = true; // 解决页面引入多个 Jquery 导致 not function 的问题 /* 改。Lin $("head").append("") */ // $("head").append("") /* 改。Lin $("head").append("") */ // $("head").append("") clearInterval(resizeScrollIv); initNiceScorll(); } } } function getIframeByElement(element) { var iframe; $("iframe").each(function () { if (element.ownerDocument === this.contentWindow.document) { iframe = this; } return !iframe; }); return iframe; } // 大滚动条 function loadScroll(dom) { try { if ($(dom).attr("wdScroll") == "false") return; var hori = $(dom).attr("wdScroll") == "XY"; $(dom).niceScroll({ cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值 cursorwidth: "6px", // 滚动条的宽度,单位:便素 cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框 cursorborderradius: "6px", // 滚动条圆角(像素) mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素) touchbehavior: false, // 激活拖拽滚动 hwacceleration: false, // 激活硬件加速 autohidemode: "true", background: "transparent", // 轨道的背景颜色 iframeautoresize: true, // 在加载事件时自动重置iframe大小 spacebarenabled: true, // 当按下空格时使页面向下滚动 railpadding: { top: 0, right: 4, left: 4, bottom: 0, }, // 设置轨道的内间距 horizrailenabled: hori || false, // nicescroll可以管理水平滚动 railalign: "right", // 对齐垂直轨道 railvalign: "bottom", // 对齐水平轨道 preservenativescrolling: true, enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容 enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件 nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动 }); } catch (e) { throw e; } } //初始化小滚动条 function loadScrollXY(dom) { try { if ($(dom).attr("wdScroll") == "false") return; $(dom).niceScroll({ cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值 cursorwidth: "6px", // 滚动条的宽度,单位:便素 cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框 cursorborderradius: "6px", // 滚动条圆角(像素) mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素) touchbehavior: false, // 激活拖拽滚动 hwacceleration: false, // 激活硬件加速 autohidemode: "true", background: "transparent", // 轨道的背景颜色 iframeautoresize: true, // 在加载事件时自动重置iframe大小 spacebarenabled: true, // 当按下空格时使页面向下滚动 railpadding: { top: 0, right: 4, left: 4, bottom: 0, }, // 设置轨道的内间距 horizrailenabled: true, // nicescroll可以管理水平滚动 railalign: "right", // 对齐垂直轨道 railvalign: "bottom", // 对齐水平轨道 preservenativescrolling: true, enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容 enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件 nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动 }); } catch (e) { throw e; } } // 小滚动条 function loadSmallScroll(dom) { try { $(dom).niceScroll({ cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值 cursorwidth: "1px", // 滚动条的宽度,单位:便素 cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框 cursorborderradius: "1px", // 滚动条圆角(像素) mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素) touchbehavior: false, // 激活拖拽滚动 hwacceleration: false, // 激活硬件加速 background: "transparent", // 轨道的背景颜色 iframeautoresize: true, // 在加载事件时自动重置iframe大小 spacebarenabled: true, // 当按下空格时使页面向下滚动 autohidemode: "true", // leave railpadding: { top: 0, right: 2, left: 2, bottom: 0, }, // 设置轨道的内间距 horizrailenabled: false, // nicescroll可以管理水平滚动 railalign: "right", // 对齐垂直轨道 railvalign: "bottom", // 对齐水平轨道 enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容 nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动 zindex: "999999", }); } catch (e) { console.log(e); } } //原来拼写错误,兼容处理 var initNiceScorll = initNiceScroll; var loadScorll = loadScroll; var loadScorllXY = loadScrollXY; var loadSmallScorll = loadSmallScroll; /* * 设置HTML元素属性 @param object o 要设置属性的HTML元素 @param string a 要设置的属性名 @param string * v 要设置的属性值 */ function setAttribute(o, a, v) { if (typeof o != "object" || typeof a != "string") return; a == "class" ? (o.className = v) : o.setAttribute(a, v); } /* * 获取HTML元素属性值 @param object o 要获取属性的HTML元素 @param string a 要获取的属性名 @return * 返回要获取的属性值 */ function getAttribute(o, a) { if (typeof o != "object" || typeof a != "string") return; return a == "class" ? o.className : o.getAttribute(a); } /* * 移除HTML元素属性 @param object o 要移除属性的HTML元素 @param string a 要移除的属性名 */ function removeAttribute(o, a) { if (typeof o != "object" || typeof a != "string") return; o.removeAttribute(a); if (a == "class") o.removeAttribute("className"); } /** * 去掉所有的html代码 */ wd.display.removeHTMLTag = wd.display.toPlainText = function (str) { str = str.replace(/<\/?[^>]*>/g, ""); // 去除HTML tag str = str.replace(/[ | ]*\n/g, "\n"); // 去除行尾空白 // str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行 str = str.replace(/ /gi, ""); // 去掉  str = str.replace(/\s/g, ""); // 将空格去掉 return str; }; /** * 初始化tr的显示样式 */ wd.display.initTrDisplay = function ( trContainerNameOrId, // tr标签的直接父级标签的name或id oddClassName, // 奇数行的tr应用的class类名 evenClassName, // 偶数行的tr应用的class类名 onMouseOverClassName ) { // 鼠标放在tr上时,tr应用的css样式 var container = wd.c.g(trContainerNameOrId); // container 可能为 undefined if (!container) return; var trs = container.childNodes; if (!trs) return; var trIndex = 0; for (var i = 0; i < trs.length; i++) { var oneTr = trs[i]; if ( !oneTr.tagName || oneTr.tagName != "TR" || oneTr.style.display == "none" ) continue; trIndex++; if (trIndex % 2 == 1) { // 奇数行的tr应用的class类名 oneTr.className += " " + oddClassName; } else { oneTr.className += " " + evenClassName; } oneTr.oriClassName = oneTr.className; var omocn = new RegExp(" " + onMouseOverClassName); // console.log(omocn); oneTr.onmouseover = function () { this.className = this.className.replace(omocn, "") + " " + onMouseOverClassName; }; oneTr.onmouseout = function () { this.className = this.className.replace(omocn, ""); }; } }; wd.display.showDynamicParamDialog = function (url, datas) { eval(wd.display.replaceDynamicParam(url.toString(), datas)); }; wd.display.createMaskDiv = function (containerObj, currWindow, zIndex) { // 创建遮罩层 var ele = currWindow.document.getElementsByTagName("BODY")[0]; var newID = new Date().getTime(); if (!(typeof zIndex != "undefined" && zIndex)) { zIndex = 100001; } var coverDiv = document.createElement("div"); coverDiv.id = newID; // coverDiv.style.cssText = 'display: none;' + 'position: absolute;' + // 'top: 0%;' + 'left: 0%;' + 'width: 100%;' + 'height: 100%;' + // 'background-color: #EEEEEE;' + '-moz-opacity: 0.5;' + // 'opacity: .50;' + 'filter: alpha(opacity=50);'; coverDiv.setAttribute("class", "wdMaskDiv dialog-mask"); coverDiv.style.zIndex = zIndex - 1; ele.appendChild(coverDiv); // coverDiv.style.display = 'block'; var W = currWindow.document.body.scrollLeft + currWindow.document.body.scrollWidth || currWindow.document.documentElement.scrollLeft + currWindow.document.documentElement.scrollWidth; var H = currWindow.document.body.scrollTop + currWindow.document.body.scrollHeight || currWindow.document.documentElement.scrollTop + currWindow.document.documentElement.scrollHeight; coverDiv.style.width = W + "px"; coverDiv.style.height = H + "px"; var maskContainer = containerObj.mask; if (!maskContainer) { containerObj.mask = []; } containerObj.mask.push(newID); }; //按钮 [id,pos,title,label,className] wd.display.wdButtons = [ //功能: 旧UI弹窗右上角按钮图标升级为 icon-base(先改 help/lock/close)by xu 20251223 ["wdHelp", 3, "帮助", "帮助", "dialog-toolbar-icon icon-help"], ["CMS_download", 3, "下载", "下载", "icon-download"], ["wdShare", 3, "收藏", "收藏", "icon-favorite"], ["wdShared", 3, "已收藏", "已收藏", "icon-favoriteOn"], ["editWdHelp", 3, "编辑帮助", "编辑帮助", "icon-setHelp"], ["editWdHelp_save", 3, "编辑帮助保存", "编辑帮助保存", "invertIcon-save"], //功能: icon-base 图标名调整:编辑选项卡 icon-ptab(弹窗顶部用细体)by xu 20251224 ["wdTab", 3, "编辑选项卡", "编辑选项卡", "dialog-toolbar-icon icon-ptab"], //功能: icon-base 图标名调整:保存选项卡使用 icon-save(不再用 invertIcon-save)by xu 20251225 [ "wdTab_save", 3, "保存选项卡", "保存选项卡", "invertIcon-save dialog-toolbar-icon icon-save", ], //功能: icon-base 图标名调整:个人选值 icon-pval(弹窗顶部用细体)by xu 20251224 ["wdRecord", 3, "个人选值", "个人选值", "dialog-toolbar-icon icon-pval"], //功能: icon-base 图标名调整:个人选值保存使用 icon-save(不再用 invertIcon-save)by xu 20251225 [ "wdRecord_save", 3, "个人选值保存", "个人选值保存", "invertIcon-save dialog-toolbar-icon icon-save", ], ["CMS_fullscreen", 3, "全屏", "全屏", "dialog-restoreButton"], ["CMS_nrProperty", 3, "内容属性", "内容属性", "icon-property"], ["change_on", 3, "变动查看-开", "变动查看-开", "dialog-changeOnButton"], ["change_off", 3, "变动查看-关", "变动查看-关", "dialog-changeButton"], ["lockScreen", 3, "锁定", "锁定", "dialog-toolbar-icon icon-lock"], ["wdPrint", 3, "打印", "打印", "icon-print"], ["wdBatchPrint", 3, "批量打印", "批量打印", "icon-print"], ["wdHelpCopyhexcode", 3, "复制帮助代码", "复制帮助代码", "icon-key"], //功能: SsSubTab 菜单模式切换按钮改为按需创建,避免所有弹窗都出现 by xu 20251224 ]; wd.display.initStyleWdButtons = function () { for (var i = 0; i < wd.display.wdButtons.length; i++) { var className = "dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default"; wd.topWindow .$("div.dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default") .addClass(wd.display.wdButtons[i][4]); } // 特殊处理close,因为如果close和dhtmlx的close冲突,会隐藏原生,新增一个按钮 var className = "dhtmlx_button_close_default"; //功能: 弹窗关闭按钮使用 icon-base(避免依赖 svg/png)by xu 20251223 wd.topWindow .$("div.dhtmlx_button_close_default") .removeClass(className) .addClass("dialog-toolbar-close-icon icon-close"); }; /** * 添加隐藏按钮 * @param {Object} w */ wd.display.addWdUserButton = function (w) { var buttonType = wd.display.wdButtons; for (var i = 0; i < buttonType.length; i++) { //添加按钮 w.addUserButton( buttonType[i][0], buttonType[i][1], buttonType[i][2], buttonType[i][3], buttonType[i][4] ); //隐藏按钮 w.button(buttonType[i][0]).hide(); // console.log(buttonType[i][0]+":"+w.button(buttonType[i][0]).isHidden()) } wd.display.initStyleWdButtons(); }; wd.display.showAllWdUserButton = function (w, nolimit) { //解除限制 if (nolimit) { w.unAllowButton = false; } else { w.unAllowButton = true; } var buttonType = wd.display.wdButtons; for (var i = 0; i < buttonType.length; i++) { if (w.button(buttonType[i][0]).isHidden() == false) { w.button(buttonType[i][0]).show(); } } }; wd.display.hideAllWdUserButton = function (w) { w.unAllowButton = true; var buttonType = wd.display.wdButtons; for (var i = 0; i < buttonType.length; i++) { w.button(buttonType[i][0]).style.display = "none"; } }; /** * 添加弹窗事件 * @param {Object} w */ wd.display.addComponentEvent = function (w) { // 按钮:设置wdRecord w.getFrame().addEventListener( "load", function () { var iframeWindow = w.getFrame().contentWindow; if ("0" == iframeWindow.loginStatus) return; //wdShare var wdShare = function () { this.win = null; this.button; this.init = function (w) { this.win = w; // var wdDialogWin = iframeWindow.document.querySelector("wdDialog[collect=true]") // if (!wdDialogWin) // return; this.sendRequest( "query", (function () { return function (data) { if (data == 1) { //已分享 this.addButton("wdShared"); } else if (data == 0) { //未分享 this.addButton("wdShare"); } }; })() ); }; this.addButton = function (buttontype) { var THIS = this; //恢复隐藏按钮 if ( this.win.button(buttontype) && this.win.button(buttontype) != null ) { this.win.button(buttontype).show(); } else { // if (buttontype == "wdShared") { // this.win.addUserButton(buttontype, 3, "已收藏", "已收藏") // } else if (buttontype == "wdShare") { // this.win.addUserButton(buttontype, 3, "未收藏", "未收藏") // } } this.win.button(buttontype).onclick = function () { THIS.wdshareClick(buttontype); }; }; this.wdshareClick = function (buttontype) { var type; //已收藏点击:取消收藏 //未收藏点击: if (buttontype == "wdShared") { type = "delete"; } else if (buttontype == "wdShare") { type = "add"; } this.sendRequest(type, function (data) { if (data == 1) { this.win.button(buttontype).hide(); this.addButton(buttontype == "wdShared" ? "wdShare" : "wdShared"); } else if (data == 0) { console.log(data); } else { console.log(data); } }); }; this.sendRequest = function (type, callback) { var wdsharetype; if (type == "query") { wdsharetype = ""; } else if (type == "add") { wdsharetype = 1; } else if (type == "delete") { wdsharetype = 0; } else { alert("type 值超出范围:" + type); // ("我是不可能出现的!")。Lin } var THIS = this; $.post( "/service?ssServ=wdShare", { wdsharetype: wdsharetype, wdshareurl: iframeWindow.window.location.href, }, function (data) { if (callback) { callback.call(THIS, data); } } ); }; }; new wdShare().init(w); }, false ); }; //功能: SsSubTab 菜单模式切换按钮启用(由页面主动调用)by xu 20251223 wd.display.enableSsSubTabMenuModeButton = function () { try { var wdDialogId = wd.display.getwdDialogId(); if (!wdDialogId) return false; if (!wd.topWindow || !wd.topWindow.dhxWins) return false; var w = wd.topWindow.dhxWins.window(wdDialogId); if (!w) return false; //功能: 打印调试信息(定位点击无反应问题)by xu 20251224 try { console.log("[SsSubTabMenuMode] enable start, wdDialogId=", wdDialogId); } catch (e) {} //功能: 获取当前弹窗的 DOM 容器(用于精准定位按钮,避免多弹窗 querySelector 选错)by xu 20251224 var iframeEl = null; //功能: 优先通过 wdDialogId 精确定位 iframe(避免误拿到 SsSubTab 内部 iframe)by xu 20251224 try { var ifs = wd.topWindow.document.getElementsByTagName("IFRAME"); for (var ii = 0; ii < ifs.length; ii++) { var iframeObj = ifs[ii]; var tempId = iframeObj.getAttribute("wdDialogId"); if (!tempId && iframeObj.dataset) { tempId = iframeObj.dataset["wdDialogId"]; } if (tempId && tempId + "" === wdDialogId + "") { iframeEl = iframeObj; break; } } } catch (e) {} if (!iframeEl) { try { iframeEl = w.getFrame && w.getFrame(); } catch (e) {} } if (!iframeEl) { try { console.log("[SsSubTabMenuMode] fail: no iframeEl"); } catch (e) {} return false; } var winEl = null; try { winEl = iframeEl.closest && iframeEl.closest("div.dhtmlx_window_active,div.dhtmlx_window_inactive"); } catch (e) {} if (!winEl) { try { console.log("[SsSubTabMenuMode] fail: no winEl"); } catch (e) {} return false; } //功能: 精准获取当前弹窗的按钮 DOM(dhtmlx 会切换 _default/_over_default 等)by xu 20251224 var btnEl = null; try { btnEl = winEl.querySelector( "div[class*='dhtmlx_button_ssSubTabMenuMode_']" ); } catch (e) {} if (!btnEl) { //功能: 仅在使用 SsSubTab 的页面按需创建按钮,避免所有弹窗默认带出 by xu 20251224 //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮使用细体 icon-autoTxt / icon-fix by xu 20251224 try { w.addUserButton( "ssSubTabMenuMode", 3, "菜单模式", "菜单模式", "dialog-toolbar-icon icon-autoTxt" ); } catch (e) {} try { wd.display.initStyleWdButtons && wd.display.initStyleWdButtons(); } catch (e) {} try { btnEl = winEl.querySelector( "div[class*='dhtmlx_button_ssSubTabMenuMode_']" ); } catch (e) {} if (!btnEl) { // 页面可能还没创建完成,交给调用方重试 by xu 20251224 try { console.log("[SsSubTabMenuMode] fail: button dom not found"); } catch (e) {} return false; } //功能: 打印调试信息(按钮按需创建成功)by xu 20251224 try { console.log("[SsSubTabMenuMode] button created"); } catch (e) {} } var btn = null; try { btn = w.button && w.button("ssSubTabMenuMode"); } catch (e) {} //功能: 弹窗右上角切换按钮放到最左边(flex 顺序)by xu 20251223 try { var btnContainer = btnEl.parentNode; if ( btnContainer && btnContainer.firstElementChild && btnContainer.firstElementChild !== btnEl ) { btnContainer.insertBefore(btnEl, btnContainer.firstElementChild); } } catch (e) {} //功能: 旧UI弹窗中使用顶部按钮控制 SsSubTab,隐藏组件内置切换按钮 by xu 20251223 try { document.documentElement && document.documentElement.classList && document.documentElement.classList.add("ss-sub-tab-dialog"); } catch (e) {} // 确保组类存在 by xu 20251223 try { btnEl.classList && btnEl.classList.add("dialog-toolbar-icon"); } catch (e) {} //功能: 获取 iframeWindow(用于 click 时动态拿 API,避免 enable 时机问题)by xu 20251224 var iframeWindow = null; try { iframeWindow = iframeEl && iframeEl.contentWindow; } catch (e) {} if (!iframeWindow) { try { console.log("[SsSubTabMenuMode] fail: no iframeWindow"); } catch (e) {} return false; } //功能: 递归在多层 iframe 中查找 SsSubTab API(objPlay -> objInfo -> ss-sub-tab)by xu 20251224 var findSsSubTabCtx = function (win, depth) { //功能 by xu 20251224 if (!win) return null; if (depth > 6) return null; try { var api = (win.SS && win.SS.dom && win.SS.dom.ssSubTabApi) || (win.ss && win.ss.dom && win.ss.dom.ssSubTabApi); var left = win.document && win.document.querySelector && win.document.querySelector(".project-edit-container .left-side"); if (api && api.toggleMenuMode && left) { return { win: win, api: api, leftSide: left }; } } catch (e) {} try { var ifs = win.document && win.document.getElementsByTagName ? win.document.getElementsByTagName("IFRAME") : []; if (!ifs || !ifs.length) return null; // 限制扫描数量,避免极端页面卡顿 by xu 20251224 var maxScan = Math.min(ifs.length, 30); for (var i = 0; i < maxScan; i++) { var cw = null; try { cw = ifs[i].contentWindow; } catch (e) { cw = null; } if (!cw) continue; var r = findSsSubTabCtx(cw, depth + 1); if (r) return r; } } catch (e) {} return null; }; var updateIcon = function () { //功能 by xu 20251224 // dhtmlx hover/active 会切换 class(_default/_over_default 等),这里每次取当前节点 by xu 20251224 var currentBtnEl = null; try { currentBtnEl = winEl.querySelector( "div[class*='dhtmlx_button_ssSubTabMenuMode_']" ); } catch (e) {} if (!currentBtnEl || !currentBtnEl.classList) return; //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo 这种多层iframe拿不到 SS 的问题)by xu 20251224 var ctx = null; try { var apiFromTop = wd.topWindow && wd.topWindow.__ssSubTabApiMap && wd.topWindow.__ssSubTabApiMap[wdDialogId]; if (apiFromTop && apiFromTop.toggleMenuMode) { ctx = { api: apiFromTop, leftSide: null }; } } catch (e) {} if (!ctx) { ctx = findSsSubTabCtx(iframeWindow, 0); } var mode = "collapse"; try { mode = (ctx && ctx.api && ctx.api.getMenuMode && ctx.api.getMenuMode()) || (ctx && ctx.leftSide && ctx.leftSide.getAttribute("data-mode")) || "collapse"; } catch (e) {} currentBtnEl.classList.add("dialog-toolbar-icon"); //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮 icon-autoTxt / icon-fix by xu 20251224 currentBtnEl.classList.remove("icon-autoTxt", "icon-fix"); if (mode === "fixed") { currentBtnEl.classList.add("icon-fix"); currentBtnEl.setAttribute("title", "固定菜单"); } else { currentBtnEl.classList.add("icon-autoTxt"); currentBtnEl.setAttribute("title", "悬浮菜单"); } }; //功能: 用事件委托绑定点击(避免 dhtmlx 切换 class/替换节点导致点击失效)by xu 20251224 try { var btnsEl = winEl.querySelector("div.dhtmlx_wins_btns"); if (btnsEl && btnsEl.getAttribute("data-ss-sub-tab-menu-bound") !== "1") { btnsEl.setAttribute("data-ss-sub-tab-menu-bound", "1"); btnsEl.addEventListener( "click", function (e) { try { var t = e && e.target; var hit = t && t.closest ? t.closest("div[class*='dhtmlx_button_ssSubTabMenuMode_']") : null; if (!hit) return; //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo)by xu 20251224 var ctx = null; var ssSubTabApi = null; try { ssSubTabApi = wd.topWindow && wd.topWindow.__ssSubTabApiMap && wd.topWindow.__ssSubTabApiMap[wdDialogId]; } catch (ee) { ssSubTabApi = null; } if (ssSubTabApi && ssSubTabApi.toggleMenuMode) { ctx = { api: ssSubTabApi }; } else { ctx = findSsSubTabCtx(iframeWindow, 0); ssSubTabApi = ctx && ctx.api; } if (!ssSubTabApi || !ssSubTabApi.toggleMenuMode) { try { console.log( "[SsSubTabMenuMode] click but api not ready", "href=", iframeWindow.location && iframeWindow.location.href, "foundCtx=", !!ctx ); } catch (ee) {} return; } //功能: 打印调试信息(点击事件触发)by xu 20251224 try { console.log( "[SsSubTabMenuMode] click, before=", ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode() ); } catch (ee) {} try { ssSubTabApi.toggleMenuMode(); } catch (ee) { console.log(ee); } try { console.log( "[SsSubTabMenuMode] click, after=", ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode() ); } catch (ee) {} setTimeout(updateIcon, 0); } catch (ee) { console.log(ee); } }, false ); } } catch (e) {} updateIcon(); try { btn && btn.show && btn.show(); } catch (e) {} return true; } catch (e) { console.log(e); return false; } }; /** * 将url中的动态参数替换成指定的值 * 如果param为空,则参数的值在html元素中寻找,如果param的值不为空,则在param中获取 * 对于现在的服务调用,采用匹配进行 * @service{name:"xxx",dest:"xxx",param:{"xxx":"xxx","data":"wdVal{data}"}}@ * 中的"data":"wdVal{data}" * 如果要添加额外变量参数,有两种方法 * 1.在html中 添加 input标签 name对应 data,把需要的值传入value(即是用element获取) * 2.如果是js变量,通过传入json变量覆盖,例: * var json = JSON.parse('{"data":"' + encodeURI(obj) + '"}'); * var url = '@service{name:"cd_ydck",dest:"cd_ydck",show:"wdDialog",param:{"cdydid":"wdVal{data}"}}@'; * url = wd.display.replaceDynamicParam(url, json); * eval(url); */ wd.display.replaceDynamicParam = function (url, param) { /* 再改,规范 wdVal{ 命名。Lin var reg = /wdVal\{\s*[A-Za-z0-9_]*\s*\}/g; */ var reg = /ssVal\{\s*[A-Za-z0-9_]*\s*\}/g; //如果没有匹配的动态参数 if (!reg.test(url)) { return url; } else { var result = url.match(reg); for (var i = 0; i < result.length; i++) { var source = result[i]; //获取动态参数的name var name = source.trim().substring(6, source.trim().length - 1); //增加空字符串的可能性 if (param && param[name] != undefined) { url = url.replace(source, param[name]); } else { var value = document.getElementsByName(name)[0].value; url = url.replace(source, value); } } return url; } }; wd.display.Yi = 49; wd.display.Xi = 23; wd.display.addDialogLine = function (w) { if (!w) { var wdDialogId = wd.display.getwdDialogId(); w = wd.topWindow.dhxWins.window(wdDialogId); } $(w) .find(".dhtmlx_wins_body_inner") .removeClass("dhtmlx_wins_body_inner_noborder") .addClass("dhtmlx_wins_body_inner_border"); }; wd.display.removeDialogLine = function (w) { if (!w) { var wdDialogId = wd.display.getwdDialogId(); w = wd.topWindow.dhxWins.window(wdDialogId); } $(w) .find(".dhtmlx_wins_body_inner") .removeClass("dhtmlx_wins_body_inner_border") .addClass("dhtmlx_wins_body_inner_noborder"); }; /** * 方法中文名:切换DOM元素显示 显示第二个参数数组指定的所有DOM元素,隐藏第三个参数数组指定的所有DOM元素, * 第四个参数为选填,如果填了,则第二个参数中的第一个iframe将加载此参数(url)指定的页面 * * * demo: * wd.display.showComponent({show:[{"name":"wdDialog","size":"450*380"}],hide:[],url:"/service?wdApplication=jw&wdService=ty_gg_ck&wdOutputComponent=44786&wdtest=false&ggid=44000059",dest:"gg.ty_gg_ck",title:"查看",width:450,high:380,wdDialogId:44786,form:""}) * wd.display.showComponent({show:["wdDialog"],hide:[],url:"/service?wdApplication=wd&wdService=grxx_shlist&wdToken=689&wdOutputComponent=44983&wdtest=false&sqid=44438",dest:"shqk",title:"审核情况件",width:500,high:300,wdDialogId:44983,form:""}) * */ wd.display.showComponent = function (params) { if ( typeof beacon != "undefined" && beacon.shouldOpenOtherBrowser && beacon.shouldOpenOtherBrowser() ) { var url = params.url; if (url.startsWith("/")) { url = window.location.origin + url; } beacon.openWindow(params.title, params.width, params.height, url); return; } // 加载鼠标动画 by SPACE 2019-04-02 wd.display.showLoad(); //alert(top.window.document.querySelector('iframe[name="win2"]')); if (window.event) { if (window.event.stopPropagation) { window.event.stopPropagation(); } else { window.event.cancelBubble = true; } } var fullScreenLimitHeight = true; // 全屏时窗口的高度与window.innerHeight一致 var showNameOrId = params.show; // 由需要显示的DOM元素的NAME或ID组成的数组或字符串,注意: // 如果含有值’wdDialog’,则弹出dhtmlxWindows窗口,否则只是切换部件显示 var hideNameOrId = params.hide; // 由需要隐藏的DOM元素的NAME或ID组成的数组或字符串(可选参数,可以不填) if (!params["getSize"]) { params["getSize"] = "1"; params["wdDialogId"] = new Date().getTime(); /* 再改,规范 &token= 命名。Lin * IDEA = Redundant character escape '\=' in RegExp * IDEA = Redundant character escape '\&' in RegExp var exec = /token\=([^\&]*)/.exec(params.url) */ var exec = /ssToken=([^&]*)/.exec(params.url); if (exec) { $.ajax({ url: "/service?ssServ=loadPageParm", data: { tokenstring: exec[1], }, async: true, timeout: 10000, type: "POST", dataType: "json", error: function (data) { console.log(arguments); wd.display.showComponent(params); }, success: function (result) { params = $.extend(params, result, { title: params.title }); wd.display.showComponent(params); }, }); return params["wdDialogId"]; } } var url = wd.display.replaceDynamicParam(params.url); // 参数showElemNameOrIdArr中的第一个iframe将加载此URL的页面(可选参数,可以不填) var width = (parseInt(params.width) || 100) + this.Xi; // 当要弹出窗口宽度,单位为px ///??? 有空再去掉参数 high -- 统一用 height???Lin /// var high = (parseInt(params.high) || parseInt(params.height) || 100) + this.Yi; // 当要弹出窗口宽度,单位为px var showTitle = params.showTitle || false; //弹出窗口自适应高度 if (!!params.minHeight && !!params.maxHeight) { params.minHeight = parseInt(params.minHeight); params.maxHeight = parseInt(params.maxHeight); if (params.minHeight + this.Yi > wd.topWindow.innerHeight) { high = params.minHeight + this.Yi; showNameOrId = "wdFullScreen"; fullScreenLimitHeight = false; } else if (params.maxHeight + this.Yi < wd.topWindow.innerHeight) { high = params.maxHeight + this.Yi; } else { /* 母体里的,showTitle="false" -- if(showTitle) 成立。Lin * PMS 里的 showTitle=false -- if(showTitle) 不成立 * 先改为 high = wd.topWindow.innerHeight; * 先不改 */ if (showTitle) high = wd.topWindow.innerHeight; else showNameOrId = "wdFullScreen"; } } url = wd.base.setRowCountPerPage(url, high - this.Yi, width); var title = params.title || "无题,可能没找到部件"; // 窗口标题,(可选参数,可以不填) var form = params.form; // 需要提交的form名字 // var wdDialogId = params.wdDialogId;//部件ID var wdDialogId = params.wdDialogId || new Date().getTime(); // 部件ID wd.display.winWidth = width; wd.display.winHeight = high; if (form) { wd.topWindow.wd.display.targetForm = window.document.getElementsByName(form)[0]; wd.topWindow.wd.display.targetUrl = url; url = "/wd/js/cloneForm/cloneForm.jsp"; } if (title) { // title = ''+title+''; title = '' + '' + title + "" + '' + ""; } if (showNameOrId) { // 如果需要显示部件 if (typeof showNameOrId != "object") { // 如果传入的不是数组 var arr = []; arr.push(showNameOrId); showNameOrId = arr; // 统一为数组 } var useUrl = true; var hasWdDialog = false; for (var i = 0; i < showNameOrId.length; i++) { var oneNameOrId = showNameOrId[i]; if (oneNameOrId == "wdDialog") { // 这里应该不是 sw - 20) { width = sw - 20; } if (high > sh - 20) high = sh - 20; if (width > sw || high > sh) cenFlag = true; // / if (!wd.topWindow.dhxWins) wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows(); var w = wd.topWindow.dhxWins.createWindow(windowId, 0, 0, width, high); w.keepInViewport(true); // 保持在窗口内 if (!cenFlag) w.center(); // 居中 w.setText(title); // 设置窗口标题 //2021-09-06 新增,当url超长时候,改成form提交 var hasInvalidUrlChar = false; var invalidUrlChar = ["{", "}", "[", "]", "|"]; for (var _ici = 0; _ici < invalidUrlChar.length; _ici++) { if (url.indexOf(invalidUrlChar[_ici]) > -1) { hasInvalidUrlChar = true; break; } } if (hasInvalidUrlChar || (url && url.length > 1000)) { hasInvalidUrlChar && console.log("url中有非法字符"); console.log("触发了form提交表单~,url长度:" + url.length); w.attachEvent("onContentLoaded", function () { try { if (this.getFrame().getAttribute("formload")) { return; } var myDoc = this.getFrame().contentDocument; var index = url.indexOf("?"); index = index < 0 ? url.length - 1 : index; var base = url.substring(0, index); var params = url.substring(index + 1); var paramarr = params.split("&"); var myform = myDoc.createElement("form"); myform.setAttribute("action", base); myform.setAttribute("method", "post"); myDoc.body.appendChild(myform); for (var pi = 0; pi < paramarr.length; pi++) { var pstr = paramarr[pi]; var pei = pstr.indexOf("="); pei = pei < 0 ? pstr.length : pei; var k = pstr.substring(0, pei); var v = pstr.substring(pei + 1); var myInput = myDoc.createElement("input"); myInput.setAttribute("type", "hidden"); myInput.setAttribute("name", k); myInput.value = decodeURIComponent(v); //可能会有url编码了的情况 myform.appendChild(myInput); } myform.submit(); this.getFrame().setAttribute("formload", "true"); } catch (e) { console.error(e); } }); w.attachURL("javascript:false;"); } else { w.attachURL(url); // 跳到此URL } useUrl = false; w.setModal(true); // 设置模式窗口 w.bringToTop(); // 置顶 wd.display.addWdUserButton(w); wd.display.addComponentEvent(w); wd.display.addDialogLine(w); // 改变按钮的类样式名 // var buttonType = wd.display.wdButtons; // for (var i = 0; i < buttonType.length; i++) { // w.button(buttonType[i][0]).className = "dhtmlx_wins_btns_button " + buttonType[i][4]; // } // 隐藏不需要的按钮 w.clearIcon(); if (w.button("help")) w.button("help").hide(); if (w.button("stick")) w.button("stick").hide(); if (w.button("sticked")) w.button("sticked").hide(); if (w.button("park")) w.button("park").hide(); if (w.button("minmax1")) // 隐藏最大化按钮 w.button("minmax1").hide(); w.denyResize(); // 不允许改变大小 // if(w.button('close')) // w.button('close').hide(); // w.btns.help.title = "帮助"; w.button("close").setAttribute("title", "关闭"); // 修改关闭按钮提示 var containerObj = wd.topWindow.wd.display; var currentDialogZIndex = w.zi; // 弹出窗口的z-index wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex); w.attachEvent("onClose", function (win) { wd.display.dxwindowsCloseMaskDiv(); /* * var parentDialog = * wd.topWindow.dhxWins.window(parentWdDialogId); if(typeof * parentDialog != 'undefined' && parentDialog ){ * //parentDialog.button('close').enable(); } */ // var iframeObj = $(win).find('iframe')[0]; function findIframe(dom) { for (var i = 0; i < dom.childNodes.length; i++) { var c = dom.childNodes[i]; if (c.tagName == "IFRAME") { return c; } var temp = findIframe(c); if (temp) return temp; } } try { var iframeObj = findIframe(win); var popWindow = iframeObj.contentWindow; // 调用关闭窗口时调用的回调方法 if ( typeof popWindow != "undefined" && popWindow.wd.display.closeDialogCallbackFun ) { popWindow.wd.display.closeDialogCallbackFun(); } wd.display.onCloseDialog(win, popWindow); } catch (e) { console.log(e); } return true; }); } else if (oneNameOrId == "wdFullScreen") { // 如果只是显示功能部件 if (!wd.topWindow.dhxWins) wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows(); if (!wd.topWindow.wd.display.wdDialogOpeners) wd.topWindow.wd.display.wdDialogOpeners = {}; wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window; var w = wd.topWindow.dhxWins.createWindow( wdDialogId, 0, 0, width, high ); w.keepInViewport(true); // 保持在窗口内 w.attachURL(url); // 跳到此URL w.setModal(true); // 设置模式窗口 w.bringToTop(); // 置顶 w.setText(title); w.clearIcon(); w.hideMenu(); w.hideToolbar(); w.center(); //窗口居中 wd.display.addWdUserButton(w); wd.display.addComponentEvent(w); wd.display.hideAllWdUserButton(w); wd.display.addDialogLine(w); var winbody; var Pbtn = w.button("close").parentNode; //关闭按钮的父节点 var titleline = w.childNodes[0].childNodes[2]; //获取到标题元素 var btns = w.childNodes[0].childNodes[3]; var odiv = document.createElement("div"); //创建一个新的元素div,用于存放btn div以及标题的div w.childNodes[0].appendChild(odiv); odiv.style.height = 43 + "px"; //给新元素进行设置样式 odiv.style.position = "absolute"; // odiv.style.display = 'none'; odiv.id = "odiv"; odiv.style.top = 0; odiv.style.width = "100%"; odiv.style.backgroundColor = "#ffffff"; odiv.style.zIndex = -1; odiv.setAttribute("class", "hLine"); w.fullScreen = function () { //初始化页面的函数 var dhwin = wd.topWindow.dhxWins; if (fullScreenLimitHeight) wd.topWindow.document.body.style.overflow = "hidden"; dhwin._engineGetWindowLabel(this).style.display = "none"; // alert(dhwin._engineFixWindowPosInViewport(this)); var vpw = _isIE ? document.body.offsetWidth : window.innerWidth; var vph = _isIE ? document.body.offsetHeight : window.innerHeight; // this.h = document.body.clientHeight; if (fullScreenLimitHeight) this.h = wd.topWindow.document.body.offsetHeight; this.y = wd.topWindow.document.body.scrollTop; // dhwin._engineFixWindowPosInViewport(this); dhwin._engineRedrawWindowSize(this); dhwin._engineRedrawWindowPos(this); winbody = this.vs[this.av].dhxcont; winbody.style.top = 0; winbody.style.marginTop = 0; winbody.style.height = this.h + "px"; winbody.childNodes[0].style.height = this.h + "px"; Pbtn.style.zIndex = 100; }; w.fullScreen(); Pbtn.onmouseover = function () { // console.log(w); wd.display.showAllWdUserButton(w, true); titleline.style.display = "block"; //把标题的display属性改成block,在初始化的时候全部设置成了none odiv.style.zIndex = 99; //通过调整div的层数来对原有的信息进行覆盖 odiv.style.display = "block"; titleline.style.zIndex = 100; }; odiv.onmouseover = function () { this.style.display = "block"; this.style.zIndex = 99; titleline.style.zIndex = 100; }; titleline.onmouseover = function () { odiv.style.zIndex = 99; odiv.style.display = "block"; this.style.zIndex = 100; }; Pbtn.onmouseout = function (e) { if (!e) e = window.event; var reltg = e.relatedTarget ? e.relatedTarget : e.toElement; if (reltg.id != "odiv") { odiv.style.zIndex = -1; odiv.style.display = "none"; w.childNodes[0].childNodes[2].style.display = "none"; //鼠标离开时进行还原 wd.display.hideAllWdUserButton(w); } else { titleline.style.display = "block"; } }; odiv.onmouseout = function (e) { if (!e) e = window.event; var reltg = e.relatedTarget ? e.relatedTarget : e.toElement; // if (reltg.className == "dhtmlx_wins_btns_button dhtmlx_button_wdTab_default") { //判定离开新元素是否到了按钮 // titleline.style.display = "block" // } else if (reltg.className == "dhtmlx_wins_title") { //判定离开了新元素是否到了title元素 titleline.style.display = "block"; } else { odiv.style.zIndex = -1; odiv.style.display = "none"; w.childNodes[0].childNodes[2].style.display = "none"; wd.display.hideAllWdUserButton(w); } }; titleline.onmouseout = function (e) { if (!e) e = window.event; var reltg = e.relatedTarget ? e.relatedTarget : e.toElement; if (reltg.id == "odiv") { titleline.style.display = "block"; } else { odiv.style.zIndex = -1; odiv.style.display = "none"; w.childNodes[0].childNodes[2].style.display = "none"; //鼠标离开时进行还原 wd.display.hideAllWdUserButton(w); } }; wd.display.hideAllWdUserButton(w); w.button("close").setAttribute("title", "关闭"); //以上是对鼠标的走向进行判定 w.attachEvent("onClose", function (win) { wd.topWindow.document.body.style.overflow = "auto"; wd.display.dxwindowsCloseMaskDiv(); function findIframe(dom) { for (var i = 0; i < dom.childNodes.length; i++) { var c = dom.childNodes[i]; if (c.tagName == "IFRAME") { return c; } var temp = findIframe(c); if (temp) return temp; } } try { var iframeObj = findIframe(win); var popWindow = iframeObj.contentWindow; // 调用关闭窗口时调用的回调方法 if ( typeof popWindow != "undefined" && popWindow.wd.display.closeDialogCallbackFun ) { popWindow.wd.display.closeDialogCallbackFun(); } wd.display.onCloseDialog(win, popWindow); } catch (e) { console.log(e); } return true; }); var currentDialogZIndex = w.zi; wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex); } else if (showNameOrId == "wdhelpdialog") { console.log("wdhelpdialog"); if (!wd.topWindow.dhxWins) wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows(); if (!wd.topWindow.wd.display.wdDialogOpeners) wd.topWindow.wd.display.wdDialogOpeners = {}; wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window; var w; //判断窗口是否已关闭 if (wd.topWindow.wdhelpdialog && wd.topWindow.wdhelpdialog.id) { w = wd.topWindow.wdhelpdialog; } else { // x,y控制弹窗口位置 w = wd.topWindow.dhxWins.createWindow( wdDialogId, params.x, params.y, width, high ); wd.topWindow.wdhelpdialog = w; } if (params.center) { w.center(); //窗口居中 } w.attachHTMLString(url); // 跳到此URL w.keepInViewport(true); // 保持在窗口内 // w.setModal(true); // 设置模式窗口 w.bringToTop(); // 置顶 w.setText(title); w.clearIcon(); // w.denyResize() // w.hideMenu(); // w.hideToolbar(); wd.display.addWdUserButton(w); // w.addUserButton("wdHelp_copyhashcode", 3, "复制代码", "复制代码") w.button("wdHelp_copyhashcode").onclick = function () { var isRTL = document.documentElement.getAttribute("dir") == "rtl"; var fakeElem = document.createElement("textarea"); // Prevent zooming on iOS fakeElem.style.fontSize = "12pt"; // Reset box model fakeElem.style.border = "0"; fakeElem.style.padding = "0"; fakeElem.style.margin = "0"; // Move element out of screen horizontally fakeElem.style.position = "absolute"; fakeElem.style[isRTL ? "right" : "left"] = "-9999px"; // Move element to the same position vertically fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + "px"; fakeElem.setAttribute("readonly", ""); fakeElem.value = params.helpHaShCode; document.body.appendChild(fakeElem); fakeElem.select(); var succeeded; try { succeeded = document.execCommand("copy"); alert("复制成功"); } catch (err) { succeeded = false; alert("复制失败"); } removeFake(fakeElem); return succeeded; }; if (params.pin) { //已锁定 w.denyMove(); w.button("wdHelp_pin").hide(); w.button("close").show(); } else { //未锁定 w.button("wdHelp_unpin").show(); w.button("close").hide(); w.allowMove(); wd.topWindow.setTimeout(function () { if (w.isMovable()) { w.close(); } }, 3000); } w.button("wdHelp_unpin").onclick = function () { w.button("close").show(); w.denyMove(); this.hide(); w.button("wdHelp_pin").hide(); }; w.button("wdHelp_pin").onclick = function () { w.button("close").hide(); w.allowMove(); this.hide(); w.button("wdHelp_unpin").hide(); setTimeout(function () { if (w.isMovable()) { w.close(); } }, 5000); }; return w.getId(); } } } // end if if (hideNameOrId) { // 如果有需要隐藏的DOM元素 // 显示所有DOM元素 for (var i = 0; i < hideNameOrId.length; i++) { var elem = wd.c.g(hideElemNameOrIdArr[i], windowObj); elem.style.display = "none"; var p = elem.parentNode; if (p && p.tagName == "DIV") { p.style.display = "none"; } } } //允许所有iframe全屏 var arr = wd.topWindow.document.getElementsByTagName("IFRAME"); for (var i = 0; i < arr.length; i++) { var iframeObj = arr[i]; iframeObj.setAttribute("allowfullscreen", true); } // w.button("wdHelp").show() // w.button("wdShare").show() // w.button("wdRecord").show() return wdDialogId; }; /** * * 设置当前iframe部件的长宽 */ wd.display.changeDxwindowDimension = function (width, height) { //wd.topWindow.dhxWins. //刷新弹出本窗口的窗口 if (null != wd.display.getwdDialogOpener) wd.display.refreshOpener(); //获得弹出部件window对象,通过创建时的部件id var wdDialogId = wd.display.getwdDialogId(); var win = wd.topWindow.dhxWins.window(wdDialogId); //myWins.window(id).setDimension(int width, int height); win.setDimension(width, height); win.keepInViewport(true); // 保持在窗口内 win.center(); // 居中 }; /** * * @param {} * currentDialogZIndex:当前弹出窗口的zIndex */ wd.display.dxwindowsCreateMaskDiv = function (currentDialogZIndex) { var containerObj = wd.topWindow.wd.display; var topWindow = wd.topWindow; wd.display.createMaskDiv(containerObj, topWindow, currentDialogZIndex); }; // 关闭wddialog时,移除遮罩层 wd.display.dxwindowsCloseMaskDiv = function () { var containerObj = wd.topWindow.wd.display.mask; var currentMaskEleID = containerObj.pop(); var currMaskEle = wd.topWindow.document.getElementById(currentMaskEleID); if (typeof currMaskEle != "undefined" && currMaskEle) { if (typeof currMaskEle.remove != "undefined") { currMaskEle.remove(); } else { currMaskEle.parentNode.removeChild(currMaskEle); } } }; //获取当前窗口对应的dhxWin对象 wd.display.getwdDialogWindows = function (dialogid) { /** * 根据是否找到wdDialogId判断当前页面在弹窗中或应用页面 * */ var wdDialogId = wd.display.getwdDialogId(); if (dialogid) wdDialogId = dialogid; var win = wd.topWindow.dhxWins.window(wdDialogId); return win; }; // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回包含本窗口的iframe wd.display.getwdDialogId = function (winUnderIframe) { if (!winUnderIframe) { winUnderIframe = window; } var arr = wd.topWindow.document.getElementsByTagName("IFRAME"); var wdDialogId = null; for (var i = 0; i < arr.length; i++) { var iframeObj = arr[i]; var cw = iframeObj.contentWindow; var tempId = iframeObj.getAttribute("wdDialogId"); if (cw == winUnderIframe) { if (tempId != null) { // 如果找到包含本窗口的iframe,ie走这里 wdDialogId = tempId; break; } else if (iframeObj.dataset) { // chrome走这里 if (iframeObj.dataset["wdDialogId"]) { wdDialogId = iframeObj.dataset["wdDialogId"]; break; } } } } if (!wdDialogId) { //最顶层页面跳出循环 if (winUnderIframe == wd.topWindow) return null; wdDialogId = wd.display.getwdDialogId(winUnderIframe.parent); } return wdDialogId; }; // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回弹出本窗口的原窗口window对象 wd.display.getwdDialogOpener = function () { var wdDialogId = wd.display.getwdDialogId(); return wd.topWindow.wd.display.wdDialogOpeners[wdDialogId]; }; // 刷新弹出本窗口的窗口 wd.display.refreshOpener = function () { // //全屏模式下,按确定按钮关闭全屏模式 // var fullFiv = wd.topWindow.document.querySelector("#wdfullscreen"); // if (fullFiv) { // fullFiv.parentNode.removeChild(fullFiv); // } try { // 刷新原窗口页面 var wdDialogOpener = wd.display.getwdDialogOpener(); // 获得原窗口window对象 if (wd.topWindow == wdDialogOpener) { return; } //执行自定义刷新方法(需要打开窗口定义wdRefresh) if (wdDialogOpener.wdRefresh) { wdDialogOpener.wdRefresh(); return; } //执行默认刷新方法 var forms = wdDialogOpener.document.getElementsByTagName("FORM"); //提交表单 if (forms && forms.length > 0 && forms[0].action) { if (forms.length == 1) { var f = forms[0]; f.submit(); } //刷新个人首页部件 } else { if ( typeof wdDialogOpener.SYBJCTRL != "undefined" && wdDialogOpener.SYBJCTRL ) { // 个人首页分支 by Rd 2016-01-13 // 通过刷新调用窗口的部件来替代刷新整个调用窗口 wdDialogOpener.SYBJCTRL.EventCtrl.FlushBj(); } else { wdDialogOpener.location.reload(); } } } catch (e) { console.log(e); } }; // 关闭弹出窗口 wd.display.closeDialog = function () { try { if (typeof beacon != "undefined") beacon.beaconCloseWindow(); } catch (e) { console.error(e); } var wdDialogId = wd.display.getwdDialogId(); // console.log(wdDialogId); // console.log(wd.topWindow.dhxWins.window(wdDialogId)); // 关闭鼠标加载动画 by SPACE 2019-04-02 wd.display.closeLoad(); // 关闭本弹出窗口 wd.topWindow.dhxWins.window(wdDialogId).close(); }; /** * 改变对象的样式 * event:监听事件的参数--{eventIds:['1','2'],styleName:{onclick:'样式名1',onmouseover:'样式名2',onmouseout:'样式名3'}} * eventIds: 监听事件的id数组 * styleName:样式名(className),[0]是获得点击后样式名,[1]是鼠标移过时的样式名,[2]是对象默认的样式 */ wd.display.changeTabStyle = function (param) { /** * 绑定监听事件 eventIds:绑定事件的id数组, eventType:绑定的事件--onclick,onmouseout等, * styleName:样式的类名 */ var objClick = new Object(); objClick.clickId = null; objClick.mouseoverId = null; function onEvent(tabIds, eventType, styleNames) { // try{ if (eventType == "onclick") { for (var key in tabIds) { var tagId = document.getElementById(tabIds[key]); (function (key) { wd.c.addEventListener(tagId, eventType, function () { setTabCssToNormal(); var objById = this; var objFocus = document.activeElement; objById.className = styleNames.onclick; objClick.clickId = tabIds[key]; }); })(key); } } else if (eventType == "onmouseover") { for (var key in tabIds) { var tagId = document.getElementById(tabIds[key]); (function (key) { wd.c.addEventListener(tagId, eventType, function () { var objById = document.getElementById(tabIds[key]); if (tabIds[key] == objClick.clickId) { return; } objById.className = styleNames.onmouseover; objClick.mouseoverId = tabIds[key]; }); })(key); } } else if (eventType == "onmouseout") { for (var key in tabIds) { var tagId = document.getElementById(tabIds[key]); (function (key) { wd.c.addEventListener(tagId, eventType, function () { var objById = document.getElementById(tabIds[key]); if (tabIds[key] == objClick.clickId) { return; } objById.className = styleNames.normal; }); })(key); } } /** * }catch(e){ alert("创建监听事件错误:"+e.message+" Type:"+e.name); } */ } // ----------------------- var tabIds = param.tabIds; var styleNames = param.styleNames; onEvent(tabIds, "onclick", styleNames); onEvent(tabIds, "onmouseover", styleNames); onEvent(tabIds, "onmouseout", styleNames); function setTabCssToNormal() { for (var i = 0; i < tabIds.length; i++) { var tabId = tabIds[i]; document.getElementById(tabId).className = styleNames.normal; } } // 设置默认对象 function setTabCssToNormalDefault() { for (var i = 0; i < tabIds.length; i++) { var tabId = tabIds[i]; if (i == 0) { document.getElementById(tabId).className = styleNames.onclick; objClick.clickId = tabId; // objClick.clickId = tabId; } else { document.getElementById(tabId).className = styleNames.normal; } } } setTabCssToNormalDefault(); }; // 把当前窗口的window对象,保存到指定的窗口中,以便关闭窗口时使用 wd.display.windowToObj = function (Ele) { if (!Ele.dom.wdDialogOpeners) Ele.dom.wdDialogOpeners = {}; Ele.dom.wdDialogOpeners[Ele.wdDialogId] = window; }; // 为dhtmlXWindows设置参数,创建窗口 wd.display.setDhtmlXWinParam = function (winParam) { var windowId = winParam.wdDialogId; // /当前可视区域 var sw = winParam.dom.document.body.offsetWidth; var sh = winParam.dom.document.body.offsetHeight; var positionParam = winParam.positionParam; var btnParam = winParam.btnParam; var sizeParam = winParam.sizeParam; var winWid; var winHeg; // 根据可是区域调整窗口 var cenFlag = false; // 超过时不居中 // 处理x,y if (positionParam) { var win_X = positionParam.split(",")[0]; var win_Y = positionParam.split(",")[1]; } else { cenFlag = true; // 居中 } // 处理size属性 if (!sizeParam) { // 用户不填写size属性 winWid = wd.display.getDialogWidAndHei(wd.display.winWidth); winHeg = wd.display.getDialogWidAndHei(wd.display.winHeight); } else if ("max" == sizeParam) { // 这里设置的win // size是还原状态下的窗口大小,后面会直接调用控件的最大化方法 if (wd.topWindow == winParam.dom) { winWidth = wd.topWindow.document.body.offsetWidth; winHeight = wd.topWindow.document.body.offsetHeight; } else { winWidth = document.body.offsetWidth; winHeight = document.body.offsetHeight; } winWid = wd.display.getDialogWidAndHei(winWidth); winHeg = wd.display.getDialogWidAndHei(winHeight); } else { winWid = wd.display.getDialogWidAndHei( sizeParam.split("*")[0], document.body.offsetWidth ); winHeg = wd.display.getDialogWidAndHei( sizeParam.split("*")[1], document.body.offsetHeight ); } // if(winParam.dom.width < winWid || winParam.dom.heigh < winHeg) // cenFlag=true; if (positionParam) { var w = winParam.dom.dhxWins.createWindow( windowId, parseInt(win_X), parseInt(win_Y), winWid, winHeg ); } else { var w = winParam.dom.dhxWins.createWindow(windowId, 0, 0, winWid, winHeg); } w.keepInViewport(true); // 保持在窗口内 if (cenFlag) w.center(); // 居中 if (winParam.title) w.setText(winParam.title); // 设置窗口标题 w.attachURL(winParam.url); // 跳到此URL useUrl = false; w.setModal(true); // 设置模式窗口 w.bringToTop(); // 置顶 // 隐藏不需要的按钮 wd.display.showDialogBtn(w, btnParam); if ("max" == sizeParam) { w.maximize(); } // if(w.button('help')) // w.button('help').hide(); // if(w.button('stick')) // w.button('stick').hide(); // if(w.button('sticked')) // w.button('sticked').hide(); // if(w.button('park')) // w.button('park').hide(); }; // 处理弹出窗口的大小 // 分为3中情况:数字*数字;max*数字;max wd.display.getDialogWidAndHei = function (p, wp) { if (p == "max") { p = wp; } return parseInt(p); }; // 处理弹出窗口的按钮 wd.display.showDialogBtn = function (w, btnParam) { if (w.button("help")) w.button("help").hide(); if (w.button("stick")) w.button("stick").hide(); if (w.button("sticked")) w.button("sticked").hide(); if (w.button("park")) w.button("park").hide(); if (w.button("minmax1")) w.button("minmax1").hide(); w.button("minmax2").hide(); if (w.button("close")) w.button("close").hide(); if (btnParam) { if (btnParam.indexOf("min") >= 0) { w.button("park").show(); } if (btnParam.indexOf("max") >= 0) { if (w.isMaximized()) w.button("minmax2").show(); else w.button("minmax1").show(); } if (btnParam.indexOf("close") >= 0) { w.button("close").show(); } } else { // 用户没填写的话,默认值为“max,close” if (w.isMaximized()) w.button("minmax2").show(); else w.button("minmax1").show(); w.button("close").show(); } }; /** * 把名为frameName的frame的src属性置为url */ wd.display.changeFrameSrc = function (frameName, url) { document.getElementsByName(frameName)[0].src = url; }; wd.display.wdTabNo = wd.display.defaultTabNo = 1; //默认的tab索引值 // 初始化tab的总方法 wd.display.initTab = function () { (function () { var tab = function () { this.dom = null; this.wdTabFrame = null; this.wdTabList = []; this.wdSecondaryTab = []; this.styles = { wdNormalClass: null, wdSelectedClass: null, wdNormalMoreClass: null, wdSelectedMoreClass: null, }; this.selectTab = null; this.mouseoutid = null; var li = function () { this.topSide = null; this.dom = null; this.type = null; //1:普通,2,显示隐藏开关,3,二级选项 this.parent = null; this.ul = null; this.url; //点击刷新iframe的地址 this.secondaryTabList = []; //独立 this.init = function (ele, type, topside, styles) { //二级的顶层 this.dom = ele; this.url = this.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin this.setTopSide(topside); this.type = type; this.setStyle(styles); // this.dom.setAttribute("class", this.wdNormalClass) this.initEvent(); return this; }; //初始化样式属性 this.setStyle = function (styles) { this.styles = styles; if (this.type == 1) { } else if (this.type == 2) { //初始二级的选项 this.initSecondaryTap(); $(this.dom).children("ul").addClass("popup-div").css({ position: "absolute", }); } else if (this.type == 3) { this.dom.style.list_style_type = "none"; $(this.dom).attr("class", ""); $(this.dom).addClass(styles.wdNormalMoreClass); } $(this.dom) .removeClass(styles.wdSelectedClass) .addClass(styles.wdNormalClass); return this; }; //绑定事件初始化 this.initEvent = function () { this.dom.addEventListener("click", this.mouseClickEvent(), false); this.dom.addEventListener("mouseover", this.mouseOverEvent(), false); this.dom.addEventListener("mouseout", this.mouseOutEvent(), false); }; this.initSecondaryTap = function () { var newStyles = $.extend({}, this.styles); newStyles.wdNormalClass = this.styles.wdNormalMoreClass; newStyles.wdSelectedClass = this.styles.wdSelectedMoreClass; var result = []; //显示隐藏的位置 var ul = this.dom.getElementsByTagName("ul")[0]; if (ul == null) return; this.ul = ul; ul.style.display = "none"; var childNodes = ul.childNodes; for (var i = 0; i < childNodes.length; i++) { var nod = childNodes[i]; if (nod.nodeType == 1) { if (nod.hasAttribute("ssTabClick")) { // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin var liobj = new li(); liobj.init(nod, 3, this.topSide, newStyles); result.push(nod); } } } this.secondaryTabList = result; }; //设置根 this.setTopSide = function (obj) { this.topSide = obj; }; this.mouseClickEvent = function () { var THIS = this; return function () { //编辑选项卡状态 if ("1" == THIS.topSide.dom.getAttribute("editing")) { return true; } //清除上次点击 if (THIS.type != 2 && THIS.topSide.selectTab) { $(THIS.topSide.selectTab.dom) .removeClass(THIS.topSide.selectTab.styles.wdSelectedClass) .addClass(THIS.topSide.selectTab.styles.wdNormalClass); // THIS.topSide.selectTab.dom.setAttribute("class", THIS.topSide.selectTab.wdNormalClass) THIS.topSide.selectTab = null; } THIS.topSide.selectTab = THIS; THIS.url = THIS.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin if (THIS.type == 1 || THIS.type == 3) { // THIS.topSide.wdTabFrame.src = THIS.url; THIS.topSide.wdTabFrame.src = wd.base.setRowCountPerPage( THIS.url, THIS.topSide.wdTabFrame.offsetHeight ); $(THIS.dom) .removeClass(THIS.styles.wdNormalClass) .addClass(THIS.styles.wdSelectedClass); // THIS.dom.setAttribute("class", THIS.wdSelectedClass); } else if (THIS.type == 2) { if (THIS.ul) { if (THIS.ul.style.display == "none") { THIS.ul.style.display = ""; } else { THIS.ul.style.display = "none"; } } } /** * 找不到原来说的点击tab之后更多变成tab对应的名字 */ var secondarytab = document.querySelector( '[wdsecondarytab="true"]' ); if (secondarytab) { var type = THIS.type; if (type != 2) { $(secondarytab).children(":not(ul)").remove(); $(secondarytab) .contents() .filter(function () { if (this.nodeType == 3) return true; }) .remove(); } var firstNode = secondarytab.firstChild; switch (type) { case 1: var moreNode = document.createTextNode("更多"); if (firstNode.nodeType == 3) { secondarytab.replaceChild(moreNode, firstNode); } else { secondarytab.insertBefore(moreNode, firstNode); } secondarytab.currentSelectedItem = null; //删除小黄点 $(secondarytab).children(".statePoint").remove(); break; case 2: //“更多”被点击 if (secondarytab.currentSelectedItem) { secondarytab.currentSelectedItem.dom.click(); } break; case 3: //复制小黄点 if ($(THIS.dom).find(".statePoint").length > 0) { $(secondarytab).prepend( $(THIS.dom).find(".statePoint").clone() ); } $(secondarytab).prepend( document.createTextNode( $(THIS.dom).contents().text() + "..." ) ); secondarytab.currentSelectedItem = THIS; break; } } }; }; this.mouseOverEvent = function () { var THIS = this; return function () { if ("1" == THIS.topSide.dom.getAttribute("editing")) { return true; } if (THIS.type == 2) { if (THIS.ul) THIS.ul.style.display = "block"; //THIS.dom.getElementsByTagName("ul")[0] if (THIS.topSide.mouseoutid) clearTimeout(THIS.topSide.mouseoutid); THIS.topSide.mouseoutid = null; } }; }; this.mouseOutEvent = function () { var THIS = this; return function () { if ("1" == THIS.topSide.dom.getAttribute("editing")) { return true; } if (THIS.topSide.selectTab != THIS) { $(THIS.dom) .removeClass(THIS.styles.wdSelectedClass) .addClass(THIS.styles.wdNormalClass); } // if (THIS.type == 2 && THIS.ul && THIS.ul.style.display == "") { // THIS.ul.style.display = "none" // } if (THIS.type == 2) { var pos = THIS.dom.compareDocumentPosition( window.event.relatedTarget ); if (pos == 10 || pos == 4) { if ("true" == THIS.dom.getAttribute("wdSecondaryTab")) { if (THIS.topSide.mouseoutid) clearTimeout(THIS.topSide.mouseoutid); THIS.topSide.mouseoutid = null; THIS.topSide.mouseoutid = setTimeout(function () { THIS.ul.style.display = "none"; }, 800); } } } }; }; }; this.init = function (dom) { this.dom = dom; //原为 this.wdTabFrame = document.getElementsByTagName("iframe")[0] this.wdTabFrame = document.querySelector('iframe[name="ssTabIframe"]') || // [name="wdTabFrame"]。Lin document.getElementsByTagName("iframe")[0]; this.wdTabFrame.tabObj = this; //为了获取当前选中的tab来刷新当前的iframe /* 改,规范命名。Lin * wdNormalClass > ssNormClazz * 去掉 wdNomalClass * wdSelectedClass > ssSelClazz this.styles.wdNormalClass = this.dom.getAttribute("wdNormalClass") || this.dom.getAttribute("wdNomalClass"); this.styles.wdSelectedClass = this.dom.getAttribute("wdSelectedClass"); */ this.styles.wdNormalClass = this.dom.getAttribute("ssNormClazz"); this.styles.wdSelectedClass = this.dom.getAttribute("ssSelClazz"); var parentiframe = window.parent.document.querySelector("iframe"); if (parentiframe.tabObj) { //双层选项卡 if (this.styles.wdSelectedClass != "lightTab-selected") this.styles.wdSelectedClass += " lightTab-selected"; if (this.styles.wdNormalClass != "lightTab") this.styles.wdNormalClass += " lightTab"; this.dom.style = "height:33px;padding-left: 14px;box-sizing:border-box"; } else { if (this.styles.wdSelectedClass != "tab-selected") this.styles.wdSelectedClass += " tab-selected"; if (this.styles.wdNormalClass != "tab") this.styles.wdNormalClass += " tab"; } this.styles.wdNormalMoreClass = "popupList"; this.styles.wdSelectedMoreClass = "popupList"; //初始化 var child = this.findChildLi(); var secondLi; for (var i = 0; i < child.length; i++) { var type = 1; if (child[i].hasAttribute("wdSecondaryTab")) { type = 2; } var liobj = new li(); liobj.init(child[i], type, this, this.styles); if (type == 2) { secondLi = liobj; } this.wdTabList.push(liobj); } //超出显示范围,就显示出更多选项卡 start var wholewidth = 0; var domwidth = $(dom).width(); for (var i = 0; i < this.wdTabList.length; i++) { var w = this.wdTabList[i].dom.offsetWidth; wholewidth += w; } if (wholewidth > domwidth) { secondLi.dom.style.display = ""; domwidth -= secondLi.dom.offsetWidth * 2; var fistgroup = []; var secondgroup = []; var thirdgroup = []; wholewidth = 0; for (var i = 0; i < this.wdTabList.length; i++) { wholewidth += this.wdTabList[i].dom.offsetWidth; var t = this.wdTabList[i].type; if (t == 2) { secondgroup.push(this.wdTabList[i]); continue; } if (wholewidth > domwidth) { thirdgroup.push(this.wdTabList[i]); this.wdTabList[i].type = 3; var oo = $.extend({}, this.wdTabList[i].styles, { wdNormalClass: this.wdTabList[i].styles.wdNormalMoreClass, wdSelectedClass: this.wdTabList[i].styles.wdNormalMoreClass, }); this.wdTabList[i].setStyle(oo); $(this.wdTabList[i].dom).prependTo(secondLi.ul); } else { fistgroup.push(this.wdTabList[i]); } } this.wdTabList = fistgroup.concat(secondgroup); secondLi.secondaryTabList = thirdgroup.concat( secondLi.secondaryTabList ); } //超出显示范围,就显示出更多选项卡 end this.selectClick(wd.display.wdTabNo); return this; }; this.findChildLi = function () { var result = []; var childNodes = this.dom.childNodes; for (var i = 0; i < childNodes.length; i++) { var nod = childNodes[i]; if (nod.nodeType == 1) { /* 再改,规范
  • childLength ? wd.display.defaultTabNo : num; if (childLength == 0) { var cc = $(child[0]) .find("li") .filter(function () { return this.style != "none"; }) .first(); if (cc.length == 1) cc[0].click(); //隐藏更多 $(child[0]).find("#tabOption").hide(); } else if (num > childLength) { child[0].click(); } else { child[num - 1].click(); } }; }; //从wdTabClick的元素顶层初始化 var initList = document.querySelectorAll("[ssTabClick]"); // ("[wdTabClick]")。Lin var tabobj; if (initList.length > 0) { if ("tabOption" == initList[0].parentNode.getAttribute("id")) { tabobj = new tab().init(initList[0].parentNode.parentNode.parentNode); } else { tabobj = new tab().init(initList[0].parentNode); } } window.tabobj = tabobj; })(); }; wd.display.getTabInstance = function () { return window.tabobj; }; /** * 打印指定div等内容,可多个selector */ wd.display.printArea = function (selector, noscroll, options) { var jqsrc = "/wd/js/jquery/jquery.js"; var printsrc = "/wd/js/print/jquery.PrintArea.js"; if (typeof $ + "" == "undefined") { loadScript(jqsrc, "jquery", function () { loadAndPrint(); }); } else { loadAndPrint(); } function loadAndPrint() { if (typeof $.PrintArea + "" == "undefined") { loadScript(printsrc, "print", function () { options = options || { mode: "iframe", popClose: false, extraCss: "", retainAttr: ["class", "id", "style", "on"], extraHead: ',', }; if (noscroll) $(selector).css("overflow", ""); $(selector).append($("link").clone()); $(selector).append($("style").clone()); try { $(selector).printArea(options); } catch (e) { alert("打印出错,检查打印窗是否被拦截"); console.error(e); } }); } else { if (noscroll) $(selector).css("overflow", ""); $(selector).append($("link").clone()); $(selector).append($("style").clone()); try { $(selector).printArea(options); } catch (e) { alert("打印出错,检查打印窗是否被拦截"); console.error(e); } } } }; /** * * @param {Object} * output * @param {Object} * wdurl */ wd.display.qrcode = function (output, wdurl, width, height, render) { // console.log($().qrcode); // if (typeof $ + "" == "undefined") { // loadScript("/wd/js/jquery/jquery.js", "jquery~", function() { // wd.display.qrcode(output, wdurl, width, height, render); // }); // } else { // if (!$().qrcode) // loadScript("/wd/js/qrcode/jquery.qrcode.js", "qrcode1", function() { // loadScript("/wd/js/qrcode/qrcode.js", "qrcode2", function() { // wd.display.qrcode(output, wdurl, width, height, render); // }); // }); // else { var option = { render: render || "table", text: wdurl.toString(), width: width || "200", height: height || "200", }; $(output).find(".qrcode").remove(); $(output).append("
    "); $(output).find(".qrcode").qrcode(option); // } // } }; /** * 改变dom元素的背景图片 * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg) * * @param domId * 需要改变背景图片的dom元素id */ wd.display.changeBackgroundImage = function (domId) { var domElement = document.getElementById(domId); var cssStr = getClass(domElement, "backgroundImage"); cssStr = cssStr.substring(4, cssStr.length - 1); cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, ""); var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?")); if (cssStr.lastIndexOf("?") != -1) { imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置 var changeImgStartIndex = cssStr.lastIndexOf("=") + 1; var changeImg = cssStr.substring( parseInt(changeImgStartIndex), parseInt(cssStr.length) ); var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?")); var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1); changeImg = imgPath + changeImg; changeImg = changeImg.replace(/\"/g, ""); var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL domElement.style.backgroundImage = imgUrl; } function getClass(obj, attr) { if (obj.currentStyle) { if (attr == "backgroundPosition") { return ( obj.currentStyle.backgroundPositionX + " " + obj.currentStyle.backgroundPositionY ); } else { return obj.currentStyle[attr]; } } else { return document.defaultView.getComputedStyle(obj, null)[attr]; } } }; /** * 改变dom元素的背景图片 * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg) * * @param domId * 需要改变背景图片的dom元素id */ wd.display.changeBackgroundImage = function (domId) { var domElement = document.getElementById(domId); var cssStr = getClass(domElement, "backgroundImage"); cssStr = cssStr.substring(4, cssStr.length - 1); cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, ""); var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?")); if (cssStr.lastIndexOf("?") != -1) { imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置 var changeImgStartIndex = cssStr.lastIndexOf("=") + 1; var changeImg = cssStr.substring( parseInt(changeImgStartIndex), parseInt(cssStr.length) ); var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?")); var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1); changeImg = imgPath + changeImg; changeImg = changeImg.replace(/\"/g, ""); var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL domElement.style.backgroundImage = imgUrl; } function getClass(obj, attr) { if (obj.currentStyle) { if (attr == "backgroundPosition") { return ( obj.currentStyle.backgroundPositionX + " " + obj.currentStyle.backgroundPositionY ); } else { return obj.currentStyle[attr]; } } else { return document.defaultView.getComputedStyle(obj, null)[attr]; } } }; // table列表自适应宽度 // ;(function($){ //但是每个部件都要加载一次 if (typeof $ + "" == "undefined") { loadScript("/wd/js/jquery.js", "Jquery", function () { setTimeout(tabFoo, 200); }); } // 这个延迟执行在于加载时比dom元素先加载 而且该js文件在页面被加载多次消耗性能望后来者去解决这些问题 function tabFoo() { var oTh = $("table.list th"), oTr = $("table.list tr"), arr_oth = Array.prototype.slice.apply(oTh), font_size = parseInt($(arr_oth[0]).css("fontSize")), style_h = $("style"), str_sheet = " white-space: nowrap;overflow: hidden;text-overflow: ellipsis;padding-left:10px;"; if (oTh.length <= 5) { if (style_h.length) { var first_style = style_h[0], sheet = first_style.sheet ? first_style.sheet : first_style.styleSheet; if (sheet.insertRule) { sheet.insertRule("table.list td,table.list th{" + str_sheet + "}", 1); } else { sheet.addRule("table.list td,table.list th", str_sheet, 0); } } else { $("head").append( '" ); } for (var i = 0; i < arr_oth.length - 1; i++) { // console.log($(arr_oth[i]).text().length, '222'); var thW = $(arr_oth[i]).text().length; thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符 if (i == 0) { $(arr_oth[i]).css({ "min-width": (thW + 10) * font_size + "px", // max-width and // min-width // 根据th字符数上下浮动一个 "max-width": (thW + 12) * font_size + "px", }); // console.log($('table.list tr td:nth-child(' + (i + 1) + ')')) $("table.list tr td:nth-child(" + (i + 1) + ")").css({ "min-width": (thW + 10) * font_size + "px", "max-width": (thW + 12) * font_size + "px", }); } else { $(arr_oth[i]).css({ "min-width": (thW + 6) * font_size + "px", // max-width and // min-width // 根据th字符数上下浮动一个 "max-width": (thW + 8) * font_size + "px", }); // console.log($('table.list tr td:nth-child(' + (i + 1) + ')')) $("table.list tr td:nth-child(" + (i + 1) + ")").css({ "min-width": (thW + 6) * font_size + "px", "max-width": (thW + 8) * font_size + "px", }); } } $("table.list tr td:nth-child(" + arr_oth.length + ")").css({ "white-space": "inherit", overflow: "inherit", "text-overflow": "inherit", }); $(".img1").parents("td").css("cssText", "width:90px !important"); return; } if (style_h.length) { var first_style = style_h[0], sheet = first_style.sheet ? first_style.sheet : first_style.styleSheet; if (sheet.insertRule) { sheet.insertRule("table.list td,table.list th{" + str_sheet + "}", 1); } else { sheet.addRule("table.list td,table.list th", str_sheet, 0); } } else { $("head").append( '" ); } // console.log(arr_oth.length) for (var i = 0; i < arr_oth.length - 1; i++) { var thW = $(arr_oth[i]).text().length; thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符 $(arr_oth[i]).css({ "min-width": (thW - 1) * font_size + "px", // max-width and // min-width // 根据th字符数上下浮动一个 "max-width": (thW + 1) * font_size + "px", }); // console.log($('table.list tr td:nth-child(' + (i + 1) + ')')) $("table.list tr td:nth-child(" + (i + 1) + ")").css({ "min-width": (thW - 1) * font_size + "px", "max-width": (thW + 1) * font_size + "px", }); } $("table.list tr td:nth-child(1)").css({ "min-width": (thW + 1) * font_size + "px", "max-width": (thW + 3) * font_size + "px", }); $("table.list tr td:nth-child(" + arr_oth.length + ")").css({ "white-space": "inherit", overflow: "inherit", "text-overflow": "inherit", }); $(".img1").parents("td").css("cssText", "width:90px !important"); // console.log($('.img1').parents('td').css('width')); } function loadScript(src, id, callback) { if (!document.getElementById(id)) { var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.id = id; script.type = "text/javascript"; script.onreadystatechange = function () { if (this.readyState == "complete") { callback(); } }; script.onload = function () { callback(); }; script.src = src; head.appendChild(script); } else { callback(); } } // })($); //下拉改变irame wd.display.initWdSelectFrame = function () { (function () { // 查找所有的option var optionAll = document.querySelectorAll("option[wdSelectClick]"); // 遍历option for (var i = 0; i < optionAll.length; i++) { var options = optionAll[i]; // 找出匹配的option if (typeof options.getAttribute("wdSelectClick") != "undefined") { // 为其父元素绑定一个id options.parentNode.setAttribute("id", "wdSelect"); // 为其父元素绑定一个事件 options.parentNode.onchange = function () { iframeSrc(); }; } } // 下拉默认值 function iframeSrc() { var mySelect = document.getElementById("wdSelect"); var myOption = mySelect.options[mySelect.selectedIndex].getAttribute("wdSelectClick"); document.getElementById("wdIframe").setAttribute("src", myOption); } if (optionAll.length > 0) iframeSrc(); })(); }; wd.display.home = function () { //显示个人首页 // if (document.getElementById("mbwzbj")) { // document.getElementById("mbwzbj").innerHTML = "个人首页"; // } else { // var div = top.window.document.querySelector("div[name='mbwz']"); // if (!div) try { // wd.topWindow.window.document.querySelector("span[id='mbwzbj']").innerHTML = "个人首页"; wd.display.setHomeIconName("个人首页"); } catch (e) { console.log(e); } // } var iframe = wd.topWindow.window.document.querySelector("iframe[oriSrc]"); // console.log(iframe); iframe.src = iframe.getAttribute("oriSrc"); //处理菜单项 /* var menu = new dhtmlXMenuObject("menuObj440141088","dhx_black"); var casState = new Object({ ctrl: false, alt: false, shift: false }); menu._clearAndHide(); if(document.getElementById("mbwzbj")!=null){ //该文字部件可能不存在 menu.dqlm=menu.itemPull[menu.idPrefix + id]["title"]; //改变当前栏目 //document.getElementById("mbwzbj").innerHTML=this.itemPull[this.idPrefix + id]["title"]; //系统菜单下项目 } if (menu._isContextMenuVisible() && menu.contextAutoHide) menu._hideContextMenu(); menu.callEvent("onClick", ["shortcutMenu", false, casState]); */ // // var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy'); // if (bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'none')) // bjsy.style.display = 'inline'; // // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb'); // if (bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'none')) // bjsymb.style.display = 'inline'; if (wd.topWindow.userEditButton_official) { wd.topWindow.userEditButton_official.style.display = "inline"; } if (wd.topWindow.userEditButton_personal) { wd.topWindow.userEditButton_personal.style.display = "inline"; } //自动调整win2的iframe大小 if (wd.topWindow.wd.base.refreshApplyIframeHeight) { wd.topWindow.wd.base.refreshApplyIframeHeight(); } if (wd.topWindow.wdHelpIcon) wd.topWindow.wdHelpIcon.style.display = "none"; }; /** 异步提交,试用 06-06 by david config: { param: {}, async: boolean, contentType: string, 默认为application/x-www-form-urlencoded dataType: string 默认为json } callback: success回调 error: error回调 **/ wd.display.ajaxSubmit = function (url, config, callback, error) { var xhr = getXmlHttpRequest(); var callback = undefined == callback ? function () {} : callback; var error = undefined == error ? function (err) { console.log(err); } : error; var async; var method; var contentType; var dataType; //xmlhttprequest设置datatype if (undefined == config.async || config.async == true) async = true; else if (config.async == "false") async = false; method = config.method; if (method.toLocaleLowerCase() == "get") { url += "&"; //一般都带token参数 url += params(config.param); } if (undefined == config.contentType) contentType = "application/x-www-form-urlencoded"; else contentType = config.contentType; if (undefined == config.dataType) dataType = "json"; else dataType = config.dataType; xhr.responseType = dataType; xhr.open(method, url, async); xhr.setRequestHeader("Content-Type", contentType); xhr.onreadystatechange = function () { switch (xhr.readyState) { case 1: break; case 2: break; case 3: break; case 4: if (xhr.status == 200) { /* var result = xhr.response; if(window.JSON){ result = JSON.parse(result); }else{ result = eval("(" + result + ")"); } callback(result); */ callback(xhr.response); } else { error(xhr.response); } break; } }; if (method.toLocaleLowerCase() == "get") xhr.send(); else xhr.send(params(config.param)); function params(data) { var arr = []; for (var i in data) { arr.push(encodeURIComponent(i) + "=" + encodeURIComponent(data[i])); } return arr.join("&"); } function getXmlHttpRequest() { var xmlHttpRequest = null; if (typeof XMLHttpRequest != "undefined") { xmlHttpRequest = new XMLHttpRequest(); } else { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHttp"); } return xmlHttpRequest; } }; //表格批示使用,url带有单元格序号‘bgbj_xh’>0时全屏 wd.display.JumpTest = function (params) { function FindParam(url, name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = url.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } /** function openScreenLayer(src) { var topbody = $("body", wd.topWindow.document); var wdfs = topbody.find("#wdfullscreen"); //弹层的div if(wdfs.length < 1) { topbody.append(""); wdfs = topbody.find("#wdfullscreen"); } wdfs.html(""); wdfs.append("").show() wdfs.append('
    '); wdfs.find(".fullscreen").html(''); wdfs.find(".fulscrbtn").click(function(e) { wdfs.remove(); }); } **/ /****/ function openScreenLayer(src) { var topbody = $("body", wd.topWindow.document); var wdfs = topbody.find("#wdfullscreen"); //弹层的div if (wdfs.length < 1) { topbody.append( "" ); wdfs = topbody.find("#wdfullscreen"); } wdfs.html(""); wdfs .append( "" ) .show(); wdfs.append( '
    ' ); wdfs .find(".fullscreen") .html( '' ); wdfs.find(".fulscrbtn").click(function (e) { wdfs.remove(); }); } var a = parseInt(FindParam(params.url, "bgbj_xh")); if (a && a > 0) { // openScreenLayer(params.url); params.show = "wdFullScreen"; params.width = wd.topWindow.document.body.offsetWidth; wd.display.showComponent(params); } else { wd.display.showComponent(params); } }; //使参数指定的滚动图片全屏 wd.display.fullgdtpScreen = function (element, bjid) { // console.log(element); // wd.display.CmsZNRFull(element); $("#ydfull" + bjid).css("display", "-webkit-flex"); var index_img = 0; var lastindex_img = 0; var full_src; full_src = $(element).children("img")[0].src; // console.log(full_src); $("#imgfull" + bjid).attr("src", full_src); var items = $("#list" + bjid).find(".ydimg_item"); if (items != undefined && items.length != 0) { lastindex_img = items.length - 1; for (var ii = 0; ii < items.length; ii++) { if ($(element).children("img")[0] == $(items[ii]).children("img")[0]) { index_img = ii; } } } var marioVideo = $("#ydfull" + bjid)[0]; // wd.display.CmsZNRFull(element); var fullscreenchange = function () { if (document.webkitFullscreenElement != null) { // element.style.width = "100%"; // element.style.height = "100%"; // element.style.overflowY = 'hidden'; //console.log("进入全屏函数"); // $('#mainDiv').append('
    '); } else { //console.log("退出全屏函数"); $("#ydfull" + bjid).hide(); //添加监听器,监听用户进入全屏和退出全屏操作 marioVideo.removeEventListener( "webkitfullscreenchange", fullscreenchange ); marioVideo.removeEventListener("fullscreenchange", fullscreenchange); marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange); marioVideo.removeEventListener("msfullscreenchange", fullscreenchange); } }; // 判断各种浏览器,找到正确的方法 var elem = marioVideo; elem.onmousemove = function (e) { // console.log(e.offsetY); e = e || window.event; var newY = e.screenY; //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2)) if (newY < window.screen.height / 3 && index_img != 0) { elem.style.cursor = 'url("./wd/image/top.cur"),default'; //上1/3区域 } else if ( newY > (window.screen.height / 3) * 2 && index_img != lastindex_img ) { elem.style.cursor = 'url("./wd/image/bottom.cur"),default'; //下1/3区域 } else { elem.style.cursor = "default"; //中1/3区域 } }; elem.onclick = function (e) { e = e || window.event; var newY = e.screenY; //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2)) if (newY < window.screen.height / 3 && index_img != 0) { //上一张 index_img = index_img - 1; if (items != undefined && items.length != 0) { for (var ii = 0; ii < items.length; ii++) { $(items[ii]).removeClass("selected"); } full_src = $(items[index_img]).children("img")[0].src; $("#imgfull" + bjid).attr("src", full_src); $(items[index_img]).addClass("selected"); $("#img" + bjid).attr("src", full_src); $("#bt" + bjid).html( $(items[index_img]).children("img").eq(0).attr("alt") ); } } else if ( newY > (window.screen.height / 3) * 2 && index_img != lastindex_img ) { //下一张 index_img = index_img + 1; if (items != undefined && items.length != 0) { for (var ii = 0; ii < items.length; ii++) { $(items[ii]).removeClass("selected"); } full_src = $(items[index_img]).children("img")[0].src; $("#imgfull" + bjid).attr("src", full_src); $(items[index_img]).addClass("selected"); $("#img" + bjid).attr("src", full_src); $("#bt" + bjid).html( $(items[index_img]).children("img").eq(0).attr("alt") ); } } else { //关闭 wd.display.exitFullScreen(); } }; marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange); marioVideo.addEventListener("fullscreenchange", fullscreenchange); marioVideo.addEventListener("mozfullscreenchange", fullscreenchange); marioVideo.addEventListener("msfullscreenchange", fullscreenchange); if (marioVideo.requestFullscreen) { marioVideo.requestFullscreen(elem); } else if (marioVideo.msRequestFullscreen) { marioVideo.msRequestFullscreen(elem); } else if (marioVideo.mozRequestFullScreen) { marioVideo.mozRequestFullScreen(elem); } else if (marioVideo.webkitRequestFullScreen) { marioVideo.webkitRequestFullScreen(elem); } }; wd.display.fullsltScreen = function (bjid) { $("#sltfull" + bjid).css("display", "-webkit-flex"); var index_img = 0; var lastindex_img = 0; var full_src; var items_selected = $("#list" + bjid).find(".slximg_box.selected"); if (items_selected != undefined && items_selected.length != 0) { for (var ii = 0; ii < items_selected.length; ii++) { full_src = $(items_selected[ii]).find("img")[0].src; // console.log(full_src); $("#imgfull" + bjid).attr("src", full_src); } } var items = $("#list" + bjid).find(".slximg_item"); if (items != undefined && items.length != 0) { lastindex_img = items.length - 1; for (var ii = 0; ii < items.length; ii++) { if ($(items_selected[0]).find("img")[0] == $(items[ii]).find("img")[0]) { index_img = ii; } } } var marioVideo = $("#sltfull" + bjid)[0]; // wd.display.CmsZNRFull(element); var fullscreenchange = function () { if (document.webkitFullscreenElement != null) { // element.style.width = "100%"; // element.style.height = "100%"; // element.style.overflowY = 'hidden'; //console.log("进入全屏函数"); // $('#mainDiv').append('
    '); } else { //console.log("退出全屏函数"); $("#sltfull" + bjid).hide(); //添加监听器,监听用户进入全屏和退出全屏操作 marioVideo.removeEventListener( "webkitfullscreenchange", fullscreenchange ); marioVideo.removeEventListener("fullscreenchange", fullscreenchange); marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange); marioVideo.removeEventListener("msfullscreenchange", fullscreenchange); } }; // 判断各种浏览器,找到正确的方法 var elem = marioVideo; elem.onmousemove = function (e) { // console.log(e.offsetY); e = e || window.event; var newY = e.screenY; //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2)) if (newY < window.screen.height / 3 && index_img != 0) { elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/top.cur") + "),default"; //上1/3区域 } else if ( newY > (window.screen.height / 3) * 2 && index_img != lastindex_img ) { elem.style.cursor = "url(" + wd.common.loadFile("theme/meow/image/bottom.cur") + "),default"; //下1/3区域 } else { elem.style.cursor = "default"; //中1/3区域 } }; elem.onclick = function (e) { e = e || window.event; var newY = e.screenY; //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2)) if (newY < window.screen.height / 3 && index_img != 0) { //上一张 index_img = index_img - 1; if (items != undefined && items.length != 0) { for (var ii = 0; ii < items.length; ii++) { $(items[ii]).removeClass("selected"); } full_src = $(items[index_img]).find("img")[0].src; $("#imgfull" + bjid).attr("src", full_src); $(items[index_img]).addClass("selected"); $("#img" + bjid).attr("src", full_src); $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt")); } } else if ( newY > (window.screen.height / 3) * 2 && index_img != lastindex_img ) { //下一张 index_img = index_img + 1; if (items != undefined && items.length != 0) { for (var ii = 0; ii < items.length; ii++) { $(items[ii]).removeClass("selected"); } full_src = $(items[index_img]).find("img")[0].src; $("#imgfull" + bjid).attr("src", full_src); $(items[index_img]).addClass("selected"); $("#img" + bjid).attr("src", full_src); $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt")); } } else { //关闭 wd.display.exitFullScreen(); } }; marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange); marioVideo.addEventListener("fullscreenchange", fullscreenchange); marioVideo.addEventListener("mozfullscreenchange", fullscreenchange); marioVideo.addEventListener("msfullscreenchange", fullscreenchange); if (marioVideo.requestFullscreen) { marioVideo.requestFullscreen(elem); } else if (marioVideo.msRequestFullscreen) { marioVideo.msRequestFullscreen(elem); } else if (marioVideo.mozRequestFullScreen) { marioVideo.mozRequestFullScreen(elem); } else if (marioVideo.webkitRequestFullScreen) { marioVideo.webkitRequestFullScreen(elem); } }; //使参数指定的DOM元素全屏,如果不传参数则默认带个页面全屏 wd.display.fullScreen = function (element) { element.sdasdasds = playlist; // 判断各种浏览器,找到正确的方法 var requestMethod = element.requestFullScreen || //W3C element.webkitRequestFullScreen || //Chrome等 element.mozRequestFullScreen || //FireFox element.msRequestFullScreen; //IE11 if (requestMethod) { requestMethod.call(element); } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { alert("f11"); wscript.SendKeys("{F11}"); } } }; //从全屏状态切换为普通状态 wd.display.exitFullScreen = function () { // 判断各种浏览器,找到正确的方法 var exitMethod = document.exitFullscreen || //W3C document.mozCancelFullScreen || //Chrome等 document.webkitExitFullscreen || //FireFox document.webkitExitFullscreen; //IE11 if (exitMethod) { exitMethod.call(document); } else if (typeof window.ActiveXObject !== "undefined") { //for Internet Explorer var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { wscript.SendKeys("{F11}"); } } }; wd.display.CmsZNRFull = function (element) { //目前对图片,视频,pdf,word,flash,全屏下特殊处理 var IMG_TYPE = "IMG"; var VIDEO_TYPE = "VIDEO"; var PDF_TYPE = "PDF"; var WORD_TYPE = "WORD"; var FLASH_TYPE = "FLASH"; var XLS_TYPE = "XLS"; var PPT_TYPE = "PPT"; function nrjsblmType(nrjslbm) { var group = { 300: IMG_TYPE, 310: IMG_TYPE, 320: IMG_TYPE, 330: IMG_TYPE, 340: IMG_TYPE, 500: VIDEO_TYPE, 510: VIDEO_TYPE, 520: VIDEO_TYPE, 1010: PDF_TYPE, 810: PPT_TYPE, 910: WORD_TYPE, 1110: XLS_TYPE, 710: FLASH_TYPE, }; return group[nrjslbm]; } var width; //定义宽度与高度 var height; var dataList = []; //查找出当前所有的所有播放器 var playlist = element.querySelectorAll("[data-init]"); console.log("555:" + playlist.length); // var nrid = null; for (var i = 0; i < playlist.length; i++) { var playDiv = playlist[i]; var nrJson = JSON.parse(playDiv.getAttribute("data-init")); // console.log(nrJson); // nrid = nrJson.resDesign.ID; var nrjslbm = nrJson.resDesign.nrjslbm; var TYPE = nrjsblmType(nrjslbm); if (!TYPE) continue; // console.log("666:" + TYPE); var exitFunction = null; //退出全屏回调方法 var data = { type: TYPE, nrjslbm: nrjslbm, }; // console.log(TYPE); if (TYPE == IMG_TYPE) { var handle = playDiv.querySelector(".img"); width = handle.naturalWidth; height = handle.naturalHeight; //退出全屏用到的数据缓存 data.handle = handle; data.width = handle.style.width; data.height = handle.style.height; data.exitFunction = function (data) { // console.log(data) data.handle.style.width = data.width; data.handle.style.height = data.height; }; var zzz = wd.display.CmscalZoomSize(width, height); handle.style.width = zzz.width + "px"; handle.style.height = zzz.height + "px"; // console.log(handle.style.width) // console.log(handle.style.height) } else if (TYPE == VIDEO_TYPE) { var handle = playDiv.querySelector(".video"); var handleparent = playDiv.querySelector(".videoparent"); width = handle.videoWidth; height = handle.videoHeight; //退出全屏还原 data.handleparent = handleparent; data.width = handleparent.style.width; data.height = handleparent.style.height; data.exitFunction = function (data) { // console.log(data) data.handleparent.style.width = data.width; data.handleparent.style.height = data.height; }; var zzz = wd.display.CmscalZoomSize(width, height); handleparent.style.width = zzz.width + "px"; handleparent.style.height = zzz.height + "px"; } else if (TYPE == PDF_TYPE || TYPE == WORD_TYPE || TYPE == XLS_TYPE) { var handle = playDiv.querySelector(".show"); var son1 = handle.querySelector("#pf1"); if (son1 == null) return; width = son1.clientWidth; height = son1.clientHeight; var zzz = wd.display.CmscalZoomSize(width, height); data.handle = handle; data.overflow = handle.style.overflow; data.zoom = handle.style.zoom; //特殊处理excel背景颜色变黑色 if (TYPE == XLS_TYPE) { playDiv.style.background = "white"; } data.exitFunction = function (data) { if (zzz.zoom != null) { element.scrollTop = element.scrollTop / zzz.zoom; } // console.log(data) data.handle.style.zoom = data.zoom; data.handle.style.overflow = data.overflow; if (data.type == XLS_TYPE) { data.handle.style.background = ""; } }; handle.style.zoom = zzz.zoom; element.scrollTop = element.scrollTop * zzz.zoom; } else if (TYPE == FLASH_TYPE) { var handle = playDiv.querySelector("#embed"); //退出全屏方法 data.handle = handle; data.width = handle.style.width; data.height = handle.style.height; data.exitFunction = function (data) { // console.log(data) data.handle.style.width = $("#mainDiv").innerWidth(); data.handle.style.height = $("#mainDiv").innerHeight(); }; var zzz = wd.display.CmscalZoomSize(); handle.style.width = zzz.maxWidth + "px"; handle.style.height = zzz.maxHeight + "px"; } dataList.push(data); playlist[i].dataList = dataList; } }; /** * * 计算放大后width,height,zoom * @param {Object} w * @param {Object} h */ wd.display.CmscalZoomSize = function (w, h) { var maxWidth = screen.availWidth - 1; var maxHeight = screen.availHeight - 1; //获取页面的高度与宽度 var xswidth = w; var xsheight = h; if (w && h) { //显示的高度与宽度 var ratio1 = w / maxWidth; var ratio2 = h / maxHeight; //根据长度与宽度获取缩放比例 if (ratio1 > 1 || ratio2 > 1) { if (ratio1 > ratio2) { //选取较大的缩放比例 xswidth = w / ratio1; xsheight = h / ratio1; } else { xswidth = w / ratio2; xsheight = h / ratio2; } } } if (w) { var zoom = maxWidth / w; if (zoom >= 2) { //确定zoom 用于word与pdf放缩 zoom = 2; } } return { width: xswidth, height: xsheight, zoom: zoom, maxWidth: maxWidth, maxHeight: maxHeight, }; }; wd.display.CmsFullDiv = function ( element, onFullscreen, onExitfullscreen, win ) { win = win || element.ownerDocument.defaultView; // var video,photo,pdf,word,flash; // console.log(element); var marioVideo = element; var fullscreenchange = function () { if (win.document.webkitFullscreenElement != null) { //$(element).addClass("scrollbar"); // $(element).css("padding","25px"); // $(element).css("box-sizing","border-box"); // element.style.overflowY = "auto"; // element.style.overflowX = "hidden"; // element.style.width = "100%"; // element.style.height = "100%"; // console.log("进入全屏函数"); // element.setAttribute("isCmsFullScreen", 'true'); win .$(element) .append( '
    ' ); onFullscreen && onFullscreen(); } else { // console.log("退出全屏函数"); win.$(element).find("#pageClose").remove(); //$(element).removeClass("scrollbar"); // $(element).css("padding","0px"); // $(element).css("box-sizing","border-box"); // element.style.height = 'auto'; // element.style.width = 'auto'; // element.setAttribute("isCmsFullScreen", 'false'); // element.style.overflowY = 'auto'; // element.style.height = '100%'; // element.style.width = '750px'; //添加监听器,监听用户进入全屏和退出全屏操作 marioVideo.removeEventListener( "webkitfullscreenchange", fullscreenchange ); marioVideo.removeEventListener("fullscreenchange", fullscreenchange); marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange); marioVideo.removeEventListener("msfullscreenchange", fullscreenchange); onExitfullscreen && onExitfullscreen(); } }; var elem = marioVideo; marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange); marioVideo.addEventListener("fullscreenchange", fullscreenchange); marioVideo.addEventListener("mozfullscreenchange", fullscreenchange); marioVideo.addEventListener("msfullscreenchange", fullscreenchange); if (marioVideo.requestFullscreen) { marioVideo.requestFullscreen(elem); } else if (marioVideo.msRequestFullscreen) { marioVideo.msRequestFullscreen(elem); } else if (marioVideo.mozRequestFullScreen) { marioVideo.mozRequestFullScreen(elem); } else if (marioVideo.webkitRequestFullScreen) { marioVideo.webkitRequestFullScreen(elem); } }; wd.display.CmsFullScreen = function ( element, onFullscreen, onExitfullscreen, win ) { win = win || element.ownerDocument.defaultView; // var video,photo,pdf,word,flash; // console.log(element); var marioVideo = element; try { win.wd.display.CmsZNRFull(element); } catch (e) {} var fullscreenchange = function () { if (win.document.webkitFullscreenElement != null) { //$(element).addClass("scrollbar"); // $(element).css("padding","25px"); // $(element).css("box-sizing","border-box"); element.style.overflowY = "auto"; element.style.overflowX = "hidden"; element.style.width = "100%"; element.style.height = "100%"; // console.log("进入全屏函数"); element.setAttribute("isCmsFullScreen", "true"); win .$(element) .append( '
    ' ); onFullscreen && onFullscreen(); } else { // console.log("退出全屏函数"); win.$(element).find("#pageClose").remove(); //$(element).removeClass("scrollbar"); // $(element).css("padding","0px"); // $(element).css("box-sizing","border-box"); // element.style.height = 'auto'; // element.style.width = 'auto'; element.setAttribute("isCmsFullScreen", "false"); // element.style.overflowY = 'auto'; element.style.height = "100%"; element.style.width = "750px"; //回调退出全屏方法 var playlist = element.querySelectorAll("[data-init]"); for (var i = 0; i < playlist.length; i++) { dataList = playlist[i].dataList; for (var j = 0; dataList != null && j < dataList.length; j++) { var data = dataList[j]; if (data.exitFunction) { data.exitFunction.call(this, data); } } delete playlist[i].dataList; } //添加监听器,监听用户进入全屏和退出全屏操作 marioVideo.removeEventListener( "webkitfullscreenchange", fullscreenchange ); marioVideo.removeEventListener("fullscreenchange", fullscreenchange); marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange); marioVideo.removeEventListener("msfullscreenchange", fullscreenchange); onExitfullscreen && onExitfullscreen(); } }; var elem = marioVideo; marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange); marioVideo.addEventListener("fullscreenchange", fullscreenchange); marioVideo.addEventListener("mozfullscreenchange", fullscreenchange); marioVideo.addEventListener("msfullscreenchange", fullscreenchange); if (marioVideo.requestFullscreen) { marioVideo.requestFullscreen(elem); } else if (marioVideo.msRequestFullscreen) { marioVideo.msRequestFullscreen(elem); } else if (marioVideo.mozRequestFullScreen) { marioVideo.mozRequestFullScreen(elem); } else if (marioVideo.webkitRequestFullScreen) { marioVideo.webkitRequestFullScreen(elem); } }; //附件滑动和上下项 wd.display.CmsNrscroll = function (element, currSubNrid) { var ismousedown = false; var oldY, scollY; var nrid = currSubNrid; element.onmousedown = function (e) { oldscrollTop = element.scrollTop; oldY = e.screenY; scollY = element.scrollTop; ismousedown = true; }; element.onmouseup = function (e) { ismousedown = false; }; element.onmousemove = function (e) { // console.log(e.offsetY); e = e || window.event; var newY = e.screenY; //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2)) if (ismousedown) { //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight) if ( oldY - newY >= 150 && element.scrollTop + element.clientHeight + 1 >= element.scrollHeight && oldscrollTop + element.clientHeight + 1 >= element.scrollHeight ) { ismousedown = false; // console.log("鼠标向上移动"); nrid = nextitem(nrid); // console.log(element.getAttribute("isCmsFullScreen")); } else if ( newY - oldY >= 150 && element.scrollTop <= 0 && oldscrollTop == 0 ) { ismousedown = false; // console.log("鼠标向下移动"); nrid = lastitem(nrid); // console.log(element.getAttribute("isCmsFullScreen")); } else { element.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度 } } }; function nextitem(nrid) { var items = $(".dragList").find(".item"); var i = 0; var result = nrid; items.each(function () { if (nrid == $(items[i]).find(".nrid").text()) { if (i < items.length - 1) { // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929 // $(items[i + 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929 selectItem($(items[i + 1])[0]); loadPlayer( $(items[i + 1]) .find(".nrid") .text(), $(items[i + 1]) .find(".nrjslbm") .text() ); result = $(items[i + 1]) .find(".nrid") .text(); } return false; //跳出循环 } else { i++; } }); return result; } function lastitem(nrid) { var items = $(".dragList").find(".item"); var i = 0; var result = nrid; items.each(function () { if (nrid == $(items[i]).find(".nrid").text()) { if (i > 0) { // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929 // $(items[i - 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929 selectItem($(items[i - 1])[0]); loadPlayer( $(items[i - 1]) .find(".nrid") .text(), $(items[i - 1]) .find(".nrjslbm") .text() ); //$(items[i - 1])[0].scrollTop( $(items[i - 1])[0].scrollHeight ); result = $(items[i - 1]) .find(".nrid") .text(); } return false; //跳出循环 } else { i++; } }); return result; } }; /** * 退出登录 */ wd.display.exit = function (param) { // console.log("exit") wd.display.showLoad(); var beaconLogin = wd.display.beaconLogin("loginOut") || wd.display.getBeaconWhetherToOpen(); param = param || {}; var homepage = 1 == param.homepage ? "&homepage=" + param.homepage : ""; var urlparam = "" + homepage; /* 改。Lin $.post("/service?wdApplication=wd&wdService=ss.exitByA&wdtest=false", {}, function (result) { */ /* 再改,规范命名。Lin * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx * &wdService= 改为 ssServ $.post("/service?wdApplication=wd&wdService=exit", {}, function (result) { */ $.post( "/service?ssServ=ssExit", {}, function (result) { // =exit"。Lin var newurl = result.path + (result.path.indexOf("?") == -1 ? "?" : "") + urlparam; if (beaconLogin) { setTimeout(function () { wd.topWindow.location.href = newurl; }, 1000); } else { wd.topWindow.location.href = newurl; } }, "json" ); }; /** * 执行当前弹窗的wdfitheight调整事件 */ wd.display.initWdFitHeight = function (windowobj) { var dialogid = wd.display.getwdDialogId(); if (!dialogid) return; //弹窗对象 var win = wd.topWindow.dhxWins.window(dialogid); if (!win) return; var nextiframe = win.getFrame(); var count = 0; while (nextiframe != null) { if (count > 10) break; // 最多查找10层iframe,防止死循环 count++; //执行页面所在的初始化iframe事件 if (nextiframe.contentWindow.window.initWdFitHeightFunction) { if (nextiframe.contentWindow.window != windowobj) { nextiframe.contentWindow.window.initWdFitHeightFunction(); } } // console.log(nextiframe) nextiframe = nextiframe.contentWindow.document.querySelector("iframe[src]"); } }; /** * */ wd.display.submitToTopTab = function (submitBtn) { if (!submitBtn) console.error("请指定submit按钮"); var myform = submitBtn.form.cloneNode(true); myform.style.display = "none"; submitBtn.form.parentNode.innerHTML = ""; var win = window, topFrame = wd.display.getFrameOfWindow(win); while (topFrame.tabObj) { //找到不是tab为止 win = win.parent; topFrame = wd.display.getFrameOfWindow(win); } topFrame.contentWindow.document.body.appendChild(myform); myform.submit(); // submitBtn.click(); }; /** * 获取window所在的iframe * */ wd.display.getFrameOfWindow = function (win) { win = win || window; if ( win != win.top && win.parent && win.parent.document.querySelectorAll("iframe").length > 0 ) { var pfs = win.parent.document.querySelectorAll("iframe"); for (var i = 0; i < pfs.length; i++) { if (pfs[i].contentWindow == win) { return pfs[i]; } } console.error("没找到上级window所对应当前window的iframe"); } else { console.warn("当前页面不存在任何iframe底下"); return null; } }; /** * 刷新当前的tabframe */ wd.display.refreshTabFrame = function (wdTabNo) { var frame = wd.display.getFrameOfWindow(); if (frame) { if (frame.tabObj) { if (wdTabNo && /[0-9]*/.test(wdTabNo)) { // frame.contentWindow.wd.display.wdTabNo=wdTabNo; var num = parseInt(wdTabNo); frame.tabObj.selectClick(num); } else { frame.tabObj.selectTab.dom.click(); } } else { console.error("当前iframe不是tabFrame"); } } }; wd.display.changeFormAction = function ( url, element, width, height, minHeight, maxHeight ) { var a = $(element).parents("form:first").attr("action", url); if (a.length != 1) { alert("找不到form元素"); return false; } if (a[0].checkOnly) { if (!a[0].checkOnly(true)) { return; } } if (width && height && minHeight && maxHeight) { wd.display.resizeComponent(width, height, minHeight, maxHeight); } return true; }; wd.display.MsgManager = function (timeout, minHeight, minWidth) { if (wd.topWindow.popupPanel == null) { // 动画小圈圈 //flashMessageDocument--fmd $("body", wd.topWindow.document).append( '' ); this.element = wd.topWindow.popupPanel = $( '' ); $("body", wd.topWindow.document).append(wd.topWindow.popupPanel); timeout = timeout || 1300; // minHeight = minHeight || "10px"; // minWidth = minWidth || "70px"; // this.element[0].className = "flashMsg-div"; // this.element[0].id = "flashmsgtipsId"; // $(".flashMsg-div").append("
    "); // this.element.css({ // display: "none", // position: "fixed", // // minHeight: minHeight, // // minWidth: minWidth, // "z-index": "999" // }); this.messages = []; var this_ = this; setInterval(function () { // if (this_.messages.length > 1) { // this_.removeMsg(this_.messages.shift()); // } else if (this_.messages.length == 1) { // setTimeout(function () { // this_.removeMsg(this_.messages.shift()); // }, 1700); // } if (this_.messages.length > 0) { var span = this_.messages.shift(); setTimeout(function () { this_.removeMsg(span); }, span.data("timeout")); } }, timeout); } this.removeMsg = function (span) { var $span = $(span); $span.slideUp("normal", function () { $span.trigger("onHide"); $span.remove(); }); this.messages.length == 0 && this.element.fadeOut("fast"); }; this.pushMsg = function (msg, options) { if (msg == "" || msg == null) return; var $span = $("

    "); $span.text(msg); $span.data("timeout", Math.max(300 * (msg.length / 3), 1700)); $span.bind("onShow", function () { options && options.onShow && options.onShow.call(this); }); $span.bind("onHide", function () { options && options.onHide && options.onHide.call(this); }); this.messages.push($span); this.element.prepend($span).show(); $span.fadeIn("normal", function () { $span.trigger("onShow"); }); }; }; //开启加载动画 wd.display.showLoad = function () { wd.topWindow.$("#fMD").show(); }; //关闭加载动画 wd.display.closeLoad = function () { wd.topWindow.$("#fMD").hide(); }; if (!window.flashmsgmousemove) { window.flashmsgmousemove = 1; document.addEventListener("mousemove", function () { if (wd.topWindow.$("#flashmsgtipsId").is(":visible")) { return; } if (wd.display.isFixation) { return; } // 有弹出窗口且大于 1 时,MSG固定右下角 if (wd.topWindow.$(".wdMaskDiv").size() > 1) { setFixation(); } // 无弹出窗口或弹出窗口等于 1 时,MSG跟随鼠标 else { var xy, x, y; try { xy = recursionIframe(); x = window.event.pageX += xy.left; y = window.event.pageY += xy.top; } catch (e) { //console.log("xy err " + e) x = window.event.pageX; y = window.event.pageY; } if (wd.topWindow.$("#flashmsgtipsId").find("p").size() < 1) { // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips").removeClass("flashmsgtips-submit"); wd.topWindow.$("#flashmsgtipsId").css({ top: y - 53 + "px", left: x - 7 + "px", bottom: "", right: "", }); } wd.topWindow.$("#fMD").css("left", x - 10); wd.topWindow.$("#fMD").css("top", y - 4); } }); } wd.display.showMsgPopup = function (msg, options) { if (window.location.href.indexOf("view.jsp") > 0) return; var msgs = (wd.topWindow.wd.display.popupMsgMagager = wd.topWindow.window.wd.display.popupMsgMagager || new wd.topWindow.window.wd.display.MsgManager()); msgs.pushMsg(msg, options); if (wd.display.isFixation) { setFixation(); } }; var setFixation = function () { // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips-submit").removeClass('flashmsgtips'); wd.topWindow.$("#flashmsgtipsId").css({ bottom: "50px", right: "10px", top: "", left: "", }); }; var recursionIframe = function (win) { try { win = win || window; function getTop(e) { var offset = e.offsetTop; if (e.offsetParent != null) offset += getTop(e.offsetParent); return offset; } function getLeft(e) { var offset = e.offsetLeft; if (e.offsetParent != null) offset += getLeft(e.offsetParent); return offset; } if ((win.parent == top && win.parent == win) || win.document == undefined) { return { left: 0, top: 0, }; } var winPar = win.parent; var iframeArr = winPar.document.getElementsByTagName("IFRAME"); var targetIframe; var iframeArr1 = win.document.getElementsByTagName("IFRAME"); for (var i = 0; i < iframeArr1.length; i++) { var iframeElem = iframeArr1[i]; if (iframeElem.contentWindow == win) { targetIframe = iframeElem; break; } } for (var i = 0; i < iframeArr.length; i++) { var iframeElem = iframeArr[i]; if (iframeElem.contentWindow == win) { targetIframe = iframeElem; break; } } var xy = { left: getLeft(targetIframe), top: getTop(targetIframe), }; if (winPar.parent != winPar) { var xy2 = recursionIframe(winPar); xy.left += xy2.left; xy.top += xy2.top; } return xy; } catch (e) { console.log("Point err " + e); } }; wd.display.resizeComponent = function (width, height, minHeight, maxHeight) { if (parseInt(width) == "NaN" || parseInt(height) == "NaN") return; var dialog = wd.display.getwdDialogWindows(); if (!dialog) return; var changesize = true; if (minHeight && !isNaN(minHeight) && maxHeight && !isNaN(maxHeight)) { minHeight = parseInt(minHeight); maxHeight = parseInt(maxHeight); if (minHeight + this.Yi > wd.topWindow.innerHeight) { height = minHeight + this.Yi; // showNameOrId = 'wdFullScreen'; // fullScreenLimitHeight = false; } else if (maxHeight + this.Yi < wd.topWindow.innerHeight) { height = maxHeight + this.Yi; } else { height = wd.topWindow.innerHeight; changesize = true; // changesize = false; // showNameOrId = 'wdFullScreen'; } } wd.display.addDialogLine(); if (changesize) { dialog.setDimension(width, height); dialog.keepInViewport(false); dialog.center(); } }; wd.display.reset = function ( type, submitBtn, url, width, height, minHeight, maxHeight ) { var canSubmit = false; if (submitBtn.iscommit) { canSubmit = true; } else if (!submitBtn.form) { console.warn("没找到元素所在form"); } else { if (!submitBtn.form.checkOnly) { //没有校验器 canSubmit = true; } else if (submitBtn.form.checkOnly(true)) { //验证通过 canSubmit = true; } else { //表单验证不通过 canSubmit = false; } } if (canSubmit) { wd.display.changeFormAction(url, submitBtn); if (type == "dialog") { wd.display.resizeComponent(width, height, minHeight, maxHeight); wd.display.submitToTopTab(submitBtn); return false; } // submitBtn.iscommit = true; // submitBtn.click(); } return canSubmit; }; /** * commwrite oneLine=true 限制宽度,结尾添加'...' * @param {Object} ele */ wd.display.initOneLine = function (ele) { try { var parent = ele.parentNode; parent.removeChild(ele); parent.setAttribute("title", parent.innerHTML); parent.style.overflow = "hidden"; parent.style.textOverflow = "ellipsis"; parent.style.whiteSpace = "nowrap"; // 如果无效 table加样式 table-layout: fixed; // var poffsetW = parent.offsetWidth; // var pscrollW = parent.scrollWidth; // console.log(poffsetW+" "+pscrollW) // parent.setAttribute("aaa",poffsetW+"/"+pscrollW) // if(poffsetW") // bottom_div.append("") // bottom_div.append("") bottom_div.html( '' + '' + '' + bottom_div.html() ); bottom_div.on("click", ".authorize", function () { wd.display.getwdDialogWindows().getFrame().contentWindow.authorize(); }); bottom_div.on("click", ".submitButton", function () { wd.display.getwdDialogWindows().getFrame().contentWindow.agree(); }); } } var tokenList = []; var tokenData = {}; var $elements = $("[onclick^='wd.display.showComponent']:not(:hidden)").each( function (num, ele) { var showComponentFunStr = this.getAttribute("onClick"); //获取token查询 var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin var patt = reg.exec(showComponentFunStr); if (patt == null) return true; var token = patt[0].split("=")[1]; tokenList.push(token); tokenData[token] = { type: "childObject", ele: this, }; } ); // console.log(tokenData) if (iframe != null && iframe.contentWindow == window) { var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin var patt = reg.exec(window.location.href); var token = ""; if (patt == null) { // return true token = window.location.href; } else { token = patt[0].split("=")[1]; } tokenList.push(token); tokenData[token] = { type: "primaryObject", }; } if (tokenList.length == 0) return; // console.log(tokenList) /* 再改,规范命名。Lin * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx * &wdService= 改为 ssServ $.post("/service?wdApplication=wd&wdService=objectDataQueryByToken", { */ $.post( "/service?ssServ=objectDataQueryByToken", { tokenList: JSON.stringify(tokenList), }, function (data) { data = eval(data); var mark = wd.topWindow.mark[wdDialogId]; // console.log(tokenData) for (var i = 0; i < data.length; i++) { var temp = data[i]; var ele = tokenData[temp.token].ele; var type = tokenData[temp.token].type; var keyid = temp.object + temp.id; var checked = temp.checked == "true" || temp.checked == true ? true : false; if (!mark[keyid]) { mark[keyid] = { id: temp.id, type: type, object: temp.object, checkStatue: checked, checked: checked, }; } // console.log(mark[keyid]); // console.log(mark[keyid]) if (type != "childObject") continue; var topDoc = window.document; var chartDiv = topDoc.createElement("div"); chartDiv.setAttribute("id", keyid); topDoc.body.appendChild(chartDiv); // chartDiv.innerHTML = ""; if (mark[keyid].checked) { chartDiv.setAttribute("class", "smallButton-checked checked"); } else { chartDiv.setAttribute("class", "smallButton-unchecked"); } var bounding = ele.getBoundingClientRect(); $(chartDiv).css({ left: bounding.left - chartDiv.offsetWidth * 0.5, top: bounding.top + ele.offsetHeight * 0.5 - chartDiv.offsetHeight, // width: "auto", // height: ele.offsetHeight, zIndex: 65535, position: "absolute", // background: (mark[keyid].checkStatue != mark[keyid].checked ? 'red' : 'cyan'), // display: 'block' }); $(chartDiv).on("click", function () { var id = this.getAttribute("id"); var checked = $(this).hasClass("smallButton-unchecked"); var mark = wd.topWindow.mark[wdDialogId]; mark[id]["checked"] = checked; // console.log(checked) if (checked) { this.setAttribute("class", "smallButton-checked"); } else { this.setAttribute("class", "smallButton-unchecked"); } // // // $(this).css({ // background: (mark[id]["checkStatue"] != mark[id]["checked"] ? 'red' : 'cyan'), // }) // console.log(wd.topWindow.mark[wdDialogId]) }); } } ); }; //临时js $(function () { //首页模板添加样式 if (wd.topWindow && wd.topWindow.MenuSetting) { var topiframe = wd.topWindow.document.querySelector( "iframe[name=" + wd.topWindow.MenuSetting.target + "]" ); if (topiframe && topiframe.contentWindow) { if (topiframe.contentWindow == window) { $(window.document.body).addClass("home-div"); $(wd.topWindow.document.body).addClass("home-div"); $(".gridster,#pg_cj").addClass("home-div"); } } } //动态添加单记录授权按钮 var wdDialogId = wd.display.getwdDialogId(); // return; if (!wdDialogId) return; if (!wd.topWindow.mark) wd.topWindow.mark = {}; //打标记 if (document.querySelector("meow")) { if (!wd.topWindow.mark[wdDialogId]) wd.topWindow.mark[wdDialogId] = {}; } if (wd.topWindow.mark[wdDialogId]) { wd.display.shareTable(wdDialogId); } var win = wd.topWindow.dhxWins.window(wdDialogId); if (wd.topWindow.lockScreen) { win.button("lockScreen").onclick = function () { wd.display.beaconLogin("loginOut"); wd.topWindow.lockScreen(); }; win.button("lockScreen").show(); } }); //查询获取object的function服务 //结果用来调用弹窗方法 wd.display.showComponent.call(window,r); wd.display.createObjectService = function (objName, functionName) { var p = { objName: objName, funcName: functionName, }; var r = null; $.ajax({ type: "post", /* 再改,规范命名。Lin * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx * &wdService= 改为 ssServ url: "/service?wdApplication=wd&wdService=createObjectService&wdtest=false", */ url: "/service?ssServ=makeFuncParm", data: p, async: false, dataType: "json", success: function (result) { r = result; // console.log(r); addRemoveToken(r.token); r.show = "wdDialog"; // wd.display.showComponent.call(window,r); if (r.pageList) { for (var i = 0; i < r.pageList.lenth; i++) { addRemoveToken(r.pageList[i].token); } } }, error: function (error) { // alert("查询失败") console.log(error); }, }); return r; }; wd.display.showTextTile = function (id, msg) { var iii = document.getElementById(id); iii.parentNode.setAttribute("title", msg); iii.parentNode.removeChild(iii); }; var styleAttrs = { width: "width", height: "minHeight", }; var isdebug = false; wd.display.initGrowHighHtml = function (areaId, maxHeight, buttons) { return wd.display.initGrowHigh(areaId, maxHeight, buttons, true); }; wd.display.initGrowHigh = function (areaId, maxHeight, buttons, multimedia) { // if (typeof GrowHeight == "undefined") // $.getScript("/wd/js/growHeight.js", function () { // getGrowHeight(areaId, maxHeight, buttons); // }); // else return getGrowHeight(areaId, maxHeight, buttons, multimedia ? 2 : 3); }; /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin if (!window.wdFitHeightbqgd) { window.wdFitHeightbqgd = 0; } */ if (!window.ssLblHeightByFith) window.ssLblHeightByFith = 0; /** * wdfitheight传入减去高度 */ wd.display.fitHeightbqgd = function (n) { /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin window.wdFitHeightbqgd += n; */ window.ssLblHeightByFith += n; }; wd.display.initGrowHighByIds = function (ids, maxHeight) { for (var i = 0; i < ids.length; i++) { if (typeof ids[i] != "string") { console.error("这不是一个ID"); continue; } wd.display.initGrowHigh(ids[i], maxHeight, {}); } }; wd.display.ellipsisContent = function (dom, height) { function setText(text) { var nn = this.nodeName; if (nn == "TEXTAREA" || nn == "INPUT") { this.value = text; } else { this.innerText = text; } } function getText() { var nn = this.nodeName; if (nn == "TEXTAREA" || nn == "INPUT") { return this.value; } else { return this.innerText; } } function haveScroll(dom) { return dom.scrollHeight > dom.clientHeight; } function getCnHeight() { var otxt = getText.call(this); setText.call(this, "中"); var cnHeight = Math.max(this.scrollHeight, this.clientHeight); setText.call(this, otxt); return cnHeight; } var css = dom.style.cssText, $dom = $(dom), srcText = getText.call(dom); dom.srcText = srcText; var _style = window.getComputedStyle(dom); var fontSize = _style.fontSize; fontSize = parseInt(fontSize) || $("body").css("font-size"); var domWidth = $dom.width(); var cnHeight = getCnHeight.call(dom); height = height || parseFloat(_style.height) || parseFloat($dom.css("min-height")); height = Math.max(cnHeight, height); dom.style.setProperty("height", height + "px", "important"); setText.call(dom, dom.srcText); if (srcText.length == 0 || height == 0) { dom.style.cssText = css; return srcText; } // console.log(dom, cnHeight, height, fontSize, haveScroll(dom)); // var noBlankText = srcText.replace(/\s/g, ""); var endOffset = parseInt(domWidth / fontSize); //大概一行的字数 var viewText = srcText.substring(0, endOffset); setText.call(dom, viewText); var dot = false; while (endOffset < srcText.length && !haveScroll(dom)) { //还有字但是没有滚动条,加 endOffset++; viewText = srcText.substring(0, endOffset); setText.call(dom, viewText); if (haveScroll(dom)) { // dot = true; } } while (endOffset > 0 && haveScroll(dom)) { //出了滚动条,减 endOffset--; viewText = viewText.substring(0, endOffset) + "..."; (function (vt) { setText.call(dom, vt); })(viewText); } setText.call(dom, viewText); dom.style.cssText = css; return viewText; }; //显示tag圆点 wd.display.showTagState = function (url) { // console.log(url) $(function () { var tokenList = []; var lis = document.querySelectorAll("[ssTabClick]"); // ("[wdtabclick]")。先改,是 wdtabclick,不是 wdTabClick。Lin for (var i = 0; i < lis.length; i++) { var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin var patt = reg.exec(lis[i].getAttribute("ssTabClick")); // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin if (patt == null) { tokenList.push(null); } else { var token = patt[0].split("=")[1]; tokenList.push(token); } } // console.log(7777777777) // console.log(tokenList) // $.post( url, { tokenList: JSON.stringify(tokenList), }, function (result) { result = eval("(" + result + ")"); // console.log(result); for (var i = 0; i < lis.length; i++) { if (!result[i]) continue; if (true == result[i].cgxList) { // ("true" ==。字符串改为布尔型。Lin lis[i].innerHTML = lis[i].innerHTML + ''; } else if (true == result[i].objectList) { // ("true" ==。字符串改为布尔型。Lin lis[i].innerHTML = lis[i].innerHTML + ''; } else { } } } ); }); }; //级联查看 growheight前文本处理 wd.display.combineDiv = function (id) { // console.log($("#" + id).children().find("[id$=combine]")) // if ( $("#" + id) .children() .find("[id$=combine]").length > 0 ) return; var content = ""; var isCascading = $("#" + id).find(".content-offButton,.content-onButton").length == 0; if (isCascading) { $("#" + id) .children(":visible") .each(function () { content += this.innerHTML + " "; }); } else { $("#" + id) .find(":visible") .each(function () { if ($(this).is("[type=button]")) { // var name = this.getAttribute("name"); // if ("1" == $("[type=hidden][name=" + name + "]").val()) { // content += ($("[type=button][name=" + name + "][wdValue=1]").val() + " "); // } if ($(this).hasClass("content-onButton")) { content += $(this).val() + " "; } } }); } if (/\ \;$/.test(content)) content = content.substring(0, content.length - " ".length); $("#" + id) .empty() .html(content); }; wd.display.initSelectOption = function (id) { wd.topWindow.$("#" + id).remove(); var ele = $( '

    " )[0]; wd.topWindow.document.body.appendChild(ele); return ele; }; wd.display.buildSelectOption = function ( dom, datalist, valueKey, nameKey, selectValue, hasNullOption ) { var ul = dom.childNodes[0]; if (datalist && datalist.length > 0) { var listr = hasNullOption ? '
       
    ' : ""; for (var i = 0; i < datalist.length; i++) { var name = datalist[i][nameKey]; var value = datalist[i][valueKey]; listr += '
    ' + name + "
    "; } ul.innerHTML = listr; } else { ul.innerHTML = hasNullOption ? '
    找不到相关项
    ' : ""; } }; wd.display.queryNrSubNr = function (nrid, jlztm, datas) { var result = []; $.ajax({ type: "post", url: "/service", dataType: "json", data: { ssServ: "wrCmsList", // wdService: "nrxtsy",。Lin nrid: "T-" + nrid, sfbf: 1, jlztm: jlztm, }, async: false, success: function (jsonData) { for (var i = 0; i < jsonData.length; i++) { result.push({ name: jsonData[i].mc, value: jsonData[i].mswj, nrjslbm: jsonData[i].nrjslbm, }); } }, }); return result; }; wd.display.initCmsbtn = function (btn, fjid) { if (fjid != null && fjid != "") { $.ajax({ type: "post", url: "/service?ssServ=wrCcmsList", // =getSubNrCount",。Lin data: { nrid: "T-" + fjid, jlztm: 51, }, dataType: "json", // 增加,统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin success: function (data) { /* 改,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin * 去掉 JSON.parse(,改为用 Map 传输 var names = JSON.parse(data); */ if (data.ssCode != 0) { alert(data.ssMsg); return; } var names = data.ssData; var count = names.length; //if (count > 0) { var num = btn[0].querySelector(".attachment_count"); if (!num) { num = document.createElement("span"); num.className = "attachment_count"; btn[0].appendChild(num); } num.innerText = count; if (count == 0) { $(num).hide(); } else { $(num).show(); } var datas = []; for (var iii = 0; iii < names.length; iii++) { datas.push({ name: iii, value: names[iii], }); } btn.off("mouseenter").on("mouseenter", function () { var menuelement = wd.display.initCmsMenu(fjid + "", 51); if (menuelement) { menuelement.showAt(btn[0]); btn.off("mouseleave").on("mouseleave", function () { menuelement.hide(); }); } }); }, error: function (data) { console.log(data); }, }); } }; wd.display.initCmsMenu = function (id) { wd.topWindow.$("#CMSMENU").remove(); var nrid = (id = id.replace(/\D*/, "")); //注册内容 $.ajax({ url: "/service", data: { nrid: "T-" + nrid, ssServ: "regCms", // wdService: "register"。Lin }, async: false, dataType: "json", success: function (data) { console.log(data); }, }); var data = wd.display.queryNrSubNr(nrid); if (data.length == 0) { return; } var mainElement = wd.display.initSelectOption("CMSMENU"); function loadPlayer(contentDiv) { var win = contentDiv.ownerDocument.defaultView; var se = contentDiv.srcElement, $se = $(se), subnrid = $se.attr("value"), nrjslbm = $se.attr("nrjslbm"); win.$.ajax({ type: "GET", url: "/service", data: { ssServ: "wrCmsPlay", // : wdService: "loadNrDesignAndPlayerData",。Lin nrid: subnrid, nrjslbm: nrjslbm, }, async: false, dataType: "json", success: function (data) { /// 增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin if (data.ssCode != 0) { alert(data.ssMsg); return; } /// var div = document.createElement("div"); var obj = {}; obj.design = data.design; obj.resDesign = data.resDesign; div.setAttribute("data-init", JSON.stringify(obj)); var tempData = data.data.replace( new RegExp("@dataFolder@", "gm"), data.dataFolderPath ); var $ma = win.$(contentDiv); var hasClose = $ma.find("#pageClose").length > 0; div.innerHTML = tempData; var $div = $(div); // $div.hide(); $ma.html($div); $ma.append( '
    ' ); // var $content = $(contentDiv); // loadScorll($content); // $content.getNiceScroll().resize(); div.addEventListener("DOMSubtreeModified", function () { try { win.wd.display.CmsZNRFull(contentDiv); } catch (e) {} // var $content = $(contentDiv); // loadScorll($content); // $content.getNiceScroll().resize(); // $content.css("height", $content.height()); // $content.css("height", "100%"); }); }, }); var $pe = $se.prev(".popupList"), prev = $pe.attr("value"), $ne = $se.next(".popupList"), next = $ne.attr("value"); var ismousedown = false; var oldY, scollY; contentDiv.onmousedown = function (e) { oldscrollTop = contentDiv.scrollTop; oldY = e.screenY; scollY = contentDiv.scrollTop; ismousedown = true; }; contentDiv.onmouseup = function (e) { ismousedown = false; }; contentDiv.onmousemove = function (e) { e = e || window.event; var newY = e.screenY; if (ismousedown) { //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight) if ( oldY - newY >= 150 && contentDiv.scrollTop + contentDiv.clientHeight + 1 >= contentDiv.scrollHeight && oldscrollTop + contentDiv.clientHeight + 1 >= contentDiv.scrollHeight ) { ismousedown = false; // console.log("鼠标向上移动"); if ($ne.length > 0) { contentDiv.srcElement = $ne[0]; loadPlayer(contentDiv); } // console.log(contentDiv.getAttribute("isCmsFullScreen")); } else if ( newY - oldY >= 150 && contentDiv.scrollTop <= 0 && oldscrollTop == 0 ) { ismousedown = false; // console.log("鼠标向下移动"); if ($pe.length > 0) { contentDiv.srcElement = $pe[0]; loadPlayer(contentDiv); } // console.log(contentDiv.getAttribute("isCmsFullScreen")); } else { contentDiv.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度 } } }; // console.log("加载播放器完毕") } mainElement.style.minWidth = "180px"; wd.display.buildSelectOption(mainElement, data, "value", "name", "null"); var $mainElement = wd.topWindow.$(mainElement); $.each(data, function () { $mainElement .find("[value='" + this.value + "']") .attr("nrjslbm", this.nrjslbm); }); $mainElement.find(".popupList").click(function () { //绑定全屏 var doc = mainElement.ownerDocument; var maindiv = doc.querySelector("#CMSPLAY" + id); if (maindiv == null) { //创建打的包装div maindiv = doc.createElement("div"); maindiv.id = "CMSPLAY" + id; maindiv.style.textAlign = "center"; maindiv.onselectstart = function () { return false; }; doc.body.appendChild(maindiv); $(maindiv).append(''); $(maindiv).append(''); $(maindiv).append( '' ); $(maindiv).append( '' ); var contentDiv = (maindiv.contentDiv = doc.createElement("div")); contentDiv.className = "mainDiv"; contentDiv.style.width = "100%"; contentDiv.style.height = "100%"; contentDiv.style.display = "flex"; contentDiv.style.justifyContent = "center"; contentDiv.style.background = "white"; contentDiv.style.alignItems = "center"; maindiv.appendChild(contentDiv); } maindiv.contentDiv.srcElement = this; // setTimeout(function () { // console.log("开始全屏") doc.defaultView.wd.display.CmsFullScreen( maindiv.getElementsByTagName("DIV")[0], function () { loadPlayer(maindiv.contentDiv); $(maindiv).children("#pageClose").remove(); }, function () { maindiv.parentNode.removeChild(maindiv); doc.defaultView.clearInterval(maindiv.contentDiv.intervalID); } ); // }, 500); }); $mainElement.mouseenter(function () { if (this.removeTimerId != null) { this.ownerDocument.defaultView.clearTimeout(this.removeTimerId); this.removeTimerId = null; } }); mainElement.hide = function () { mainElement.removeTimerId = mainElement.ownerDocument.defaultView.setTimeout(function () { $mainElement.remove(); }, 300); }; $mainElement.mouseleave(function () { this.hide(); }); mainElement.showAt = function (element) { $mainElement.show(); var bounding = element.getBoundingClientRect(), mb = mainElement.getBoundingClientRect(), xy = recursionIframe(window); var left = bounding.right + xy.left - mb.width; var top_ = bounding.top + xy.top - 10 - mb.height; $mainElement.css({ left: left, top: top_, }); }; $mainElement.click(function (e) { e.stopPropagation(); }); $("body").click(function () { mainElement.hide(); }); $("body", wd.topWindow.document).click(function () { mainElement.hide(); }); $mainElement.hide(); return mainElement; }; //获取表单元素 //growHeight //objectpicker //onoffbutton //ueditor //input select datepicker //编辑帮助,个人选值 wd.display.getInputsGroups = function () { var arr = $("form,input,select,:radio,:checkbox").serializeArray(); var ret = {}; for (var i = 0; i < arr.length; i++) { var name = arr[i].name; if (!name) continue; if (/objectPicker.*/.test(name)) continue; var cc = wd.display.getInputBox(name); if (!cc) continue; ret[name] = cc; } return ret; }; /** * * @param {Object} name * @param {Object} any true:不过滤隐藏元素 */ wd.display.getInputBox = function (name, any) { if (wd.display.filterInputBoxNames[name]) { // console.log("filterInputBoxNames:"+name); return null; } var result = { name: name, container: null, //定位元素 setChange: null, focus: null, //光标 onKeyDown: null, //enter key event onKeyDownContainer: null, modify: null, modifyContainer: null, }; result.getValue = function () { return $(this.container).val(); }; result.setValue = function (v) { $(this.container).val(v); }; result.setChange = function (changefunc) { $(this.container).on("change", changefunc); }; result.focus = function () { $(this.container).focus(); }; result.modify = function (canmodify) { if (canmodify) { $(this.modifyContainer || this.container).removeAttr("readonly"); } else { $(this.modifyContainer || this.container).attr("readonly", "readonly"); } }; //键盘录入监听,keycode 9:tab 13:enter result.onKeyDown = function (keycode, func) { var code = []; code = keycode; $(this.onKeyDownContainer || this.container).on("keydown", function () { if (code.indexOf(window.event.keyCode) != -1) { return func(); } }); }; try { if (window.growHeightList && window.growHeightList[name]) { result.type = "growHeight"; result.instance = growHeightList[name]; result.container = growHeightList[name].container.parentNode; result.getValue = function () { return this.instance.val(); }; result.setValue = function (v) { this.instance.val(v); }; result.focus = function () { this.instance.onFocus(); }; result.onKeyDownContainer = $( growHeightList[name].getInputElement().parentNode ).find("textarea"); result.modifyContainer = growHeightList[name].getInputElement(); } else if ( wd && wd.edit && wd.edit.objectPicker && wd.edit.objectPicker.getInstance(name) ) { result.type = "objectPicker"; result.instance = wd.edit.objectPicker.getInstance(name); result.container = result.instance.getDisplayElement(); result.getValue = function () { return this.instance.getValue(); }; result.setValue = function (v) { this.instance.initValue(v); }; result.setChange = function (func) { this.instance.onchange = func; }; result.modify = function (canmodify) { this.instance.modify(canmodify); }; } else if ( window.EditorManager && EditorManager.instances && EditorManager.instances[name] ) { result.type = "ueditor"; result.container = EditorManager.instances[name].getUeditor().container; result.instance = EditorManager.instances[name].getUeditor(); result.getValue = function () { var c = this.instance.getContent(); return c ? wd.display.toPlainText() : c; }; result.setValue = function (v) { return this.instance.setContent(v); }; } else if ($("#" + name + "_onoffbutton_list").length == 1) { result.type = "onoffbutton"; result.container = $("[name=" + name + "][type=button]").last()[0]; result.getValue = function () { return $("[name='" + name + "'][type=hidden]").val(); }; result.setValue = function (v) { /* 改,是小写的 wdvalue=,也改先 -- 规范命名。Lin $("[name='"+name+"'][type=button][wdvalue="+v+"]").click(); */ $("[name='" + name + "'][type=button][ssVal=" + v + "]").click(); }; } else if (window.enrolDateList && window.enrolDateList[name]) { result.type = "enrolDate"; result.instance = window.enrolDateList[name]; result.container = window.enrolDateList[name].container; result.getValue = function () { return this.instance.getValue(); }; result.setValue = function (v) { this.instance.setValue(v); }; result.setChange = function (func) { this.instance.onchange = func; }; } else if (window.editPhotoList && window.editPhotoList[name]) { result.type = "editPhoto"; result.instance = window.editPhotoList[name]; result.container = window.editPhotoList[name].container; result.getValue = function () { return this.instance.getValue(); }; result.setValue = function (v) { this.instance.setValue(v); }; result.modify = function (canmodify) { this.instance.modify(canmodify); }; } else if (document.querySelector("[name='" + name + "']")) { result.type = "input"; result.container = document.querySelector("[name='" + name + "']"); } else { return null; } if (any) { } else { if ($(result.container).width() == 0) return null; } } catch (e) { console.log(e); } return result; }; if (!wd.display.filterInputBoxNames) { wd.display.filterInputBoxNames = {}; } /** * 过滤inputbox */ wd.display.filterInputBox = function (name) { for (var i = 0; i < arguments.length; i++) { var m = arguments[i]; wd.display.filterInputBoxNames[m] = "1"; } // console.log(wd.display.filterInputBoxNames); }; wd.display.changeFirstTitle = function (t) { var displgid = wd.display.getwdDialogId(); if (!displgid) return; wd.topWindow.dhxWins .window(displgid) .querySelector(".dialog-title").innerHTML = t; }; wd.display.changeSecondTitle = function (t) { var displgid = wd.display.getwdDialogId(); if (!displgid) return; wd.topWindow.dhxWins .window(displgid) .querySelector(".secondTitle").innerHTML = t; }; /** * 判断当前url是否个人首页 * @param {Object} win */ wd.display.isPersonalHomePageUrl = function (url) { if (!url) return false; return url.indexOf("initDesktop") == -1 ? false : true; }; /** * 生成更多按钮 * @param {Object} buttonId * @param {Object} childrenClass * selectedDiv 选中菜单,显示按钮名称 * recordvalue 启用个人选值 */ wd.display.attachButton = function ( buttonId, childrenClass, selectedDiv, buttonNotClickAschild, recordvalue ) { var $button = $("#" + buttonId); var vanishId; //获取二级数据 function findDatalist() { var datalist = []; var d = document.querySelectorAll("." + childrenClass); //adminNo for (var i = 0; i < d.length; i++) { datalist.push({ name: d[i].getAttribute("value"), value: d[i].getAttribute("value"), ele: d[i], }); } return datalist; } function showChild(v, isinit) { var datalist = findDatalist(); var thisdata; for (var i = 0; i < datalist.length; i++) { if (datalist[i].value == v) { thisdata = datalist[i]; } } //记忆,点击按钮触发上一个点击过的选项 $button.off("click"); if (true === buttonNotClickAschild) { $button.on("click", function () { vanishId = setTimeout(function () { $("#" + buttonId + "_buttons").hide(); }, 500); }); } else { $("#" + buttonId + "_buttons").hide(); var html = thisdata ? thisdata.name : ""; if (true === isinit) { html = $button.val() + html; } if (selectedDiv) { $button.find(selectedDiv).html(html); } else if ($button.is("input")) { $button.val(html); } $button.on("click", function () { $(thisdata.ele).trigger("click"); }); } return thisdata; } $button .on("mouseenter click", function () { //获取下拉数据 var datalist = findDatalist(); //create div $("#" + buttonId + "_buttons").remove(); var dom = wd.display.initSelectOption(buttonId + "_buttons"); if (datalist.length > 0) { /* 再改,不知为何要反转 细分部件(原 plugin) 顺序???Lin wd.display.buildSelectOption(dom, datalist.reverse(), "value", "name", null, false); */ wd.display.buildSelectOption(dom, datalist, "value", "name", null, false); $("body").append(dom); } //position var dombounding = dom.getBoundingClientRect(); var bounding = ( this.querySelector("img") || this ).getBoundingClientRect(); //console.log(bounding); var left = bounding.left; //防止超出屏幕出现滚动条 if (left + dombounding.width > window.innerWidth) { left = window.innerWidth - dombounding.width; } dom.style.left = Math.max(left, 0) + "px"; if ( bounding.top + bounding.height + dombounding.height > window.innerHeight ) { dom.style.top = bounding.top - dombounding.height + "px"; //console.log("up side") } else { //console.log("down side") dom.style.top = bounding.top + bounding.height + "px"; } //bind event $(dom) .on("click", ".popupList", function () { if (window.event) { if (window.event.stopPropagation) { window.event.stopPropagation(); } else { window.event.cancelBubble = true; } } var v = this.getAttribute("value"); var thisdata = showChild(v); $(thisdata.ele).trigger("click"); // console.log(thisdata); if (recordvalue) { var recordzhi = {}; recordzhi[buttonId] = { value: v, default: true, }; wd.edit.insertRecord(recordzhi); } }) .on("mouseleave", function () { $(this).hide(); }) .on("mouseenter", function () { if (vanishId) clearTimeout(vanishId); }); }) .on("mouseleave", function () { if ($(window.event.relatedTarget).is($(this).parents())) { vanishId = setTimeout(function () { $("#" + buttonId + "_buttons").hide(); }, 500); } }); if (recordvalue) { $(function () { var record = wd.edit.getRecord(); // console.log(record); if (record && record[buttonId]) { var v = record[buttonId].value; showChild(v, true); } }); } }; wd.display.inputCaptcha = function (name, captchalength) { try { var inputbox = wd.display.getInputBox(name); if (!inputbox) return; var inputClass = name + "_inputCaptcha"; var va = $( '
    ' + '
    ' + '' + '' + // +"" "
    " + "
    " ); // va.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",background:"azure",zIndex:1}) $(inputbox.container).before(va); va.on("click", "img", function () { this.setAttribute( "src", "/wd/verificationCode.do?" + new Date().getTime() ); }).on("blur", "." + inputClass, function () { /* 再改,规范命名。Lin * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx * &wdService= 改为 ssServ $.post("/service?wdApplication=wd&wdService=checkCaptcha_ajax&wdtest=false", { */ $.post( "/service?ssServ=checkCaptcha_ajax", { yzm: this.value, }, function (result) { if ("1" == result.result) { va.hide(); $(inputbox.container).show(); if (typeof window.inputCaptchaCallback == "function") window.inputCaptchaCallback(); } else { wd.display.alert("验证码错误!"); } }, "json" ); }); $(inputbox.container).hide(); } catch (e) { console.log(e); } }; wd.display.previewPicture = function (url, errorPhoto) { if ($(window.event.srcElement).is("input,button")) return; $(".previewPicture").remove(); // var onerror = errorPhoto ? ('this.src=\'' + errorPhoto + '\'') : ""; var onerror = ""; // if(true)return; // $("
    " // + "" // +"X" // +"download" // + "
    ") // .appendTo("body") // .on('click',".close", function () { // $('.previewPicture').remove(); // }); var startLeft, startTop, startX, startY; $( "
    " + '
    ' + '
    ' + '
    ' + "
    " + "' + "
    " ) .appendTo("body") .on("click", ".close", function () { $(".previewPicture").remove(); }) .on("click", ".download", function () { wd.display.downloadFile(url + "&download=1"); // $('.previewPicture').remove(); }); // on("mousedown",function(){ // startLeft=parseInt( $(this).css("marginLeft")); // startTop=parseInt( $(this).css("marginTop")); // startX=window.event.clientX; // startY=window.event.clientY; // this.setAttribute("move","1"); // }).on("mouseup mouseout",function(){ // this.setAttribute("move","0"); // }).on("mousemove",function(){ // if("1"!=this.getAttribute("move"))return; // $(this).css({ // marginLeft:startLeft+window.event.clientX-startX, // marginTop:startTop+window.event.clientY-startY // }) // }) }; wd.display.beaconLogin = function (type) { type = type || "login"; try { if (typeof beacon == "undefined") return false; if (type == "login") { beacon.login(wd.topWindow.beaconLoginTicket); } else { beacon.loginOut(); } return true; } catch (error) { console.log("------------------------------------"); console.log(error); console.log("------------------------------------"); } return false; }; wd.display.getBeaconWhetherToOpen = function () { try { if (typeof beacon == "undefined") return false; if (beacon.getBeaconWhetherToOpen() == "True") { alert("“待办列表”已在烽火台打开"); beacon.close2(); } return true; } catch (error) { console.error(error); } return false; }; wd.display.refreshToDoList = function () { wd.display.refreshHomeplugin("6011"); }; wd.display.refreshHomeplugin = function (type) { if (!wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL) return "0"; return wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL.refreshHomeplugin( type ); }; wd.display.setCloseWindowParam = function (p) { if (!p) return; var wdDialogId = wd.display.getwdDialogId(); if (!wdDialogId) return; var win = wd.topWindow.dhxWins.window(wdDialogId); win.closeWindowParam = p; return win; }; wd.display.onCloseDialog = function (win, popWindow) { try { // console.log("wd.display.onCloseDialog"); // console.log(win.closeWindowParam); if (!win.closeWindowParam) return; var openerWindow = popWindow.wd.display.getwdDialogOpener(); var name = openerWindow.wd.edit.objectPicker.addButtonClickName; if (!name) return; var objectpickerobj = openerWindow.wd.edit.objectPicker.getInstance(name); if (!objectpickerobj) return; // var data={option:[{name:"abc",id:"999"}]}; var data = eval("(" + win.closeWindowParam + ")"); objectpickerobj.setwdCloseWindowParamData(data); // console.log(objectpickerobj); } catch (err) { console.error(err); } }; /** * 调用关闭窗口时调用的回调方法 */ wd.display.closeDialogCallbackFun = null; /** * 给一个按钮绑定事件 * @param {Object} buttonname * @param {Object} bindevent * @param {Object} bindfunction */ wd.display.bindWdButton = function (buttonname, bindevent, bindfunction) { var wdDialogId = wd.display.getwdDialogId(); if (!wdDialogId) return; var win = wd.topWindow.dhxWins.window(wdDialogId); var b = win.button(buttonname); $(b).on(bindevent, bindfunction); }; /** * px 2 rem */ wd.display.px2Rem = function (px) { var unit = parseFloat($("html").css("font-size")); return px / unit; }; /** * * rem 2 px */ wd.display.rem2Px = function (rem) { var unit = parseFloat($("html").css("font-size")); return rem * unit; }; /* * 调用示例 1: wd.flashMsg.show({ el: $("#domDiv"), // 吸附的元素 msg: "hi,hello", // 内容 time: 200000, // 显示的时间,默认 3000,单位毫秒, offset: 'd', // 气泡方向,[u]: 上, [d]: 下,当所定的方向无法完全显示内容时,将自动进行调整方向 arrowsOffset: 'r', // 箭头方位,[l]:左边,[c]:居中,[r]:右,默认为[c]居中 zindex: 100, // 层级,默认 1996, animate: true, // 为真则开启动画,默认开启 end: function() { console.log("销毁后的回调"); } }); 2: wd.flashMsg.show("内容"); */ wd.flashMsg = { vars: { ARROWS_UP_CLASS_NAME: "flashMsg-up", ARROWS_DOWN_CLASS_NAME: "flashMsg-down", }, timeout: undefined, flashDivTemplate: ``, show: function (param) { var setting; if (typeof param == "object") { setting = param; } else { setting = { el: window.event.srcElement, msg: param, }; } if (!this.validation(setting)) { return; } // 获取吸附元素的坐标和宽高 // var positionObj = this.getAbsolute(document, $(setting.el)[0]); var positionObj = $(setting.el).position(); var offsetObj = $(setting.el).offset(); var elTop = offsetObj.top; var elLeft = offsetObj.left; var elWidth = $(setting.el).innerWidth(); var elHeight = $(setting.el).innerHeight(); setting.time = isNaN(setting.time) ? 3000 : setting.time; // 显示时间,默认3秒 setting.animate = setting.animate == undefined ? true : setting.animate; // 动画,默认为真 setting.zindex = this.isNull(setting.zindex) ? 1996 : setting.zindex; // 气泡的层级样式,默认层级 999 setting.offset = this.isNull(setting.offset) ? "d" : setting.offset; // 气泡的定位样式,默认在下面 setting.arrowsOffset = this.isNull(setting.arrowsOffset) ? "l" : setting.arrowsOffset; // 箭头的定位样式,默认左边 var arrorwsStyle = ""; // 箭头样式 var flashMsgClassName = setting.animate ? "wd-anim wd-anim-upbit" : ""; // 动画 var arrorwsClassName = undefined; // 箭头的类名 // 气泡在上 if (setting.offset && setting.offset == "u") { arrorwsStyle += "bottom: -10px;left: 7px"; arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME; } // 气泡在下 else if (setting.offset && setting.offset == "d") { arrorwsStyle += "bottom: -10px;left: 7px"; arrorwsClassName = this.vars.ARROWS_UP_CLASS_NAME; } // 默认气泡在上 else { arrorwsStyle += "bottom: -10px;left: 7px"; arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME; } this.clearFlashMsg(); $("body").append( this.getFlashDivTemplate( setting, elTop, elLeft, arrorwsClassName, arrorwsStyle, flashMsgClassName ) ); ////////////////////////////// 计算最终的坐标 ////////////////////////////// var lastTop = -1; var flashDom = $("#flashmsgtipsId"); var flashDomWidth = $(flashDom).innerWidth(); var flashDomHeight = $(flashDom).innerHeight(); // 是箭头的高度 $(flashDom).css({ top: elTop + "px", left: elLeft + "px", }); // 气泡在上 if (arrorwsClassName == this.vars.ARROWS_DOWN_CLASS_NAME) { var lastDomTop = elTop - flashDomHeight - 16; lastTop = elTop - flashDomHeight - 16; // flashMsg 元素超出了窗口顶部范围 if (lastDomTop < 0) { // 未尝试过向上的方向 if (!setting.upFlag) { setting.offset = "d"; setting.downFlag = true; this.show(setting); return; } lastTop = flashDomHeight + 6; } } // 气泡在下 else if (arrorwsClassName == this.vars.ARROWS_UP_CLASS_NAME) { lastTop = elTop + elHeight + 20; var lastDomTop = elTop + elHeight + flashDomHeight + 20; // flashMsg 元素超出了窗口底部范围 if (lastDomTop > window.innerHeight) { // 未尝试过向下的方向 if (!setting.downFlag) { setting.offset = "u"; setting.upFlag = true; this.show(setting); return; } lastTop = window.innerHeight - flashDomHeight - 12; } } else { console.error("arrorwsClassName [" + arrorwsClassName + "] error!"); return; } this.settingFlashMsgArrorwsLeft( setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth ); $(flashDom).css("top", lastTop + "px"); $(flashDom).show(); if (setting.time != 0) { this.timeout = setTimeout(function () { wd.flashMsg.clearFlashMsg(setting); }, setting.time); } }, /** * 清除气泡 */ clear: function () { this.clearFlashMsg(); }, settingFlashMsgArrorwsLeft: function ( setting, arrorwsClassName, elWidth, elLeft, flashDom, flashDomWidth ) { var arrorwsDom = $(flashDom).find("div." + arrorwsClassName); // 箭头往左 if (setting.arrowsOffset == "l") { var arrowLeft = 7; $(arrorwsDom).css("left", arrowLeft + "px"); return; } // 箭头往右 else if (setting.arrowsOffset == "r") { var arrowLeft = flashDomWidth - 20; // 箭头的位置超出了元素的宽度 var elEndLeft = elLeft + elWidth; if (arrowLeft > elEndLeft) { // 元素的一半宽度大于12像素的时候,看着就不会太别扭,放心置 left 为 6px if (elWidth / 2 >= 12) { arrowLeft = elEndLeft - 6 - 7; } // 取半 else { arrowLeft = elLeft + elWidth / 2; } } $(arrorwsDom).css("left", arrowLeft + "px"); } // 箭头居中 else { /////////////////////// 重新定位气泡 /////////////////////// var flashMsgDomLeft = this.settingFlashMsgLeft( flashDom, flashDomWidth, elWidth, elLeft ); var arrowLeft = elLeft - flashMsgDomLeft + elWidth / 2; $(arrorwsDom).css("left", arrowLeft + "px"); } }, settingFlashMsgLeft: function (flashDom, flashDomWidth, elWidth, elLeft) { var flashMsgDomLeft = elLeft - (flashDomWidth - elWidth) / 2; // 超出了屏幕左边,向右移动 if (flashMsgDomLeft < 0) { flashMsgDomLeft = 6; } // 超出屏幕右边,向左移动 else if (flashMsgDomLeft + flashDomWidth > window.innerWidth) { flashMsgDomLeft -= flashMsgDomLeft + flashDomWidth - window.innerWidth; } $(flashDom).css("left", flashMsgDomLeft); return flashMsgDomLeft; }, clearFlashMsg: function (setting) { window.clearTimeout(wd.flashMsg.timeout); wd.flashMsg.timeout = undefined; $("#flashmsgtipsId").remove(); // 移除掉之前的 if (setting && setting.end) { setting.end(); } }, getFlashDivTemplate: function ( setting, elTop, elLeft, arrorwsClassName, arrowsStyle, flashMsgClassName ) { var html = this.flashDivTemplate.replace( "{position}", "zindex:" + setting.zindex + ";" ); html = html.replace("{arrorwsClassName}", arrorwsClassName); html = html.replace("{arrorwsStyle}", arrowsStyle); html = html.replace("{msg}", setting.msg); html = html.replace("{flashMsgClassName}", flashMsgClassName); return html; }, isNull: function (obj) { switch (typeof obj) { case "undefined": return true; case "string": if (obj.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, "").length == 0) return true; break; case "boolean": if (!obj) return true; break; case "number": if (0 === obj || isNaN(obj)) return true; break; case "object": if (null === obj || obj.length === 0) return true; for (var i in obj) { return false; } return true; } return false; }, notNull: function (obj) { return !this.isNull(obj); }, validation: function (setting) { if (this.isNull(setting)) { console.error("flashMsg 未获取到 setting!"); return false; } if (this.isNull(setting.el)) { console.error("flashMsg Setting [el] 属性不能为空 "); return false; } if (this.isNull(setting.msg)) { console.error("flashMsg Setting [msg] 属性不能为空 "); return false; } return true; }, getAbsolute: function (reference, target) { var result = { left: -target.clientLeft, top: -target.clientTop, }; var node = target; while (node != reference && node != document) { result.left = result.left + node.offsetLeft + node.clientLeft; result.top = result.top + node.offsetTop + node.clientTop; node = node.parentNode; } if (isNaN(reference.scrollLeft)) { result.right = document.documentElement.scrollWidth - result.left; result.bottom = document.documentElement.scrollHeight - result.top; } else { result.right = reference.scrollWidth - result.left; result.bottom = reference.scrollHeight - result.top; } return result; }, }; //隐藏的元素 wd.display._lockScreenElement = null; //有值表示正在执行lockScreen,unlockScreen wd.display._lockScreenWaitting = null; /** * 锁屏 */ wd.display.lockScreen = function () { "use strict"; if (wd.display._lockScreenWaitting) return; wd.display._lockScreenWaitting = 0; $.post( "/service?ssServ=lockScreen", {}, function (result) { if (wd.display._lockScreenElement) return; wd.display._lockScreenElement = $("body > * :visible"); wd.display._lockScreenElement.hide(); $("body").append( '
    ' ); }, "json" ); wd.display._lockScreenWaitting = null; }; /** * 解锁屏 */ wd.display.unlockScreen = function () { "use strict"; if (wd.display._lockScreenWaitting) return; wd.display._lockScreenWaitting = 1; $.post( "/service?ssServ=unlockScreen", {}, function (result) { if (!wd.display._lockScreenElement) return; wd.display._lockScreenElement.show(); wd.display._lockScreenElement = null; $(".lockscreenMask").remove(); }, "json" ); wd.display._lockScreenWaitting = null; }; window.enrolDateList = window.enrolDateList || {}; wd.display.initEnrolDate = function (nameee, mode) { var hiddenEle = document.querySelector("[name=" + nameee + "][type=hidden]"); if ("play" == mode) { if (!hiddenEle.value) return; var year = parseInt(hiddenEle.value.split("-")[0]); var month = parseInt(hiddenEle.value.split("-")[1]); $(hiddenEle).before( "" + year + "年(" + (month <= 6 ? "春季" : "秋季") + ")" ); return; } function editEnrolDate(name) { var THIS = this; this.onchange = null; this.getValue = null; this.setValue = null; this.container = null; var hiddenEle = document.querySelector("[name=" + name + "][type=hidden]"); this.element = hiddenEle; var yyy = document.querySelector("[name=" + name + "_year]"); var mmm = document.querySelector("[name=" + name + "_month]"); wd.display.filterInputBox(name + "_year", name + "_month"); var placeholder = hiddenEle.getAttribute("placeholder"); if (placeholder) { yyy.setAttribute("placeholder", placeholder); } else { //样式特殊处理 yyy.style.width = "30px"; } this.container = yyy.parentNode; this.container.style.display = "inline"; var width = hiddenEle.getAttribute("width"); if (width) yyy.style.width = width; this._initYear = function (y) { yyy.value = y; }; this._initMonth = function (m) { /* 改,规范 wdValue= 命名。Lin $("[name="+name+"_month][type=button][wdValue="+(m<=6?3:9)+"]").trigger("click"); */ $( "[name=" + name + "_month][type=button][ssVal=" + (m <= 6 ? 3 : 9) + "]" ).trigger("click"); }; var year, month; //默认值为当前时间 if ("0" == hiddenEle.value) { year = new Date().getUTCFullYear(); month = new Date().getMonth() + 1; } else if (hiddenEle.value && hiddenEle.value.split("-").length > 0) { year = parseInt(hiddenEle.value.split("-")[0]); month = parseInt(hiddenEle.value.split("-")[1]); } else { //默认秋季 month = 9; } if (year) { this._initYear(year); } if (month) { this._initMonth(month); } function RebuildingValue() { var yy = document.querySelector("[name=" + name + "_year]").value; var mm = document.querySelector( "[name=" + name + "_month][type=hidden]" ).value; var hiddenvalue = ""; if (yy && mm) { hiddenvalue = yy + "-0" + mm + "-01"; } console.log(hiddenvalue); document.querySelector("[name=" + name + "][type=hidden]").value = hiddenvalue; if (THIS.onchange) THIS.onchange(); } RebuildingValue(); $("[name=" + name + "_month][type=button]").on("click", RebuildingValue); $("[name=" + name + "_year][type=text]").on("click", function () { wd.edit.datePicker({ dateFmt: "yyyy", onpicked: RebuildingValue, oncleared: RebuildingValue, el: this, }); }); this.setValue = function (v) { var v_year = v.split("-")[0]; var v_month = v.split("-")[1]; THIS._initYear(v_year); THIS._initMonth(v_month); }; this.getValue = function () { return THIS.element.value; }; } if (window.enrolDateList[nameee]) return; window.enrolDateList[nameee] = new editEnrolDate(nameee); }; window.defaultValueList = window.defaultValueList || {}; wd.display.inputDefaultValue = function (name, param) { //xq[rxnd]; param = param.replace(/]$/, ""); var pp = param.split(/\[/); var dictName = pp[0]; var dictParam = pp[1]; if (window.defaultValueList[name]) return; window.defaultValueList[name] = new (function (name, n, p) { var THIS = this; this.name = name; this.dict = n; this.dictParam = p; this.dictItem = wd.display.getInputBox(p); this._change = function () { console.log(THIS); var v = THIS.dictItem.getValue(); $.ajax({ url: "/service?ssServ=defaultValueTranslate", data: { dict: THIS.dict, param: "{" + THIS.dictParam + ":" + v + "}", }, async: true, dataType: "json", success: function (data) { wd.display.getInputBox(THIS.name).setValue(data.result); }, }); }; this.dictItem.setChange(this._change); if (!wd.display.getInputBox(name).getValue()) { this._change(); } })(name, dictName, dictParam); }; //下载文件 wd.display.downloadFile = function (path, downloadName) { var download = downloadName ? 'download="' + downloadName + '"' : ""; $("') .find("span") .trigger("click"); //关闭圈圈 wd.display.closeLoad(); //ScreenOver层移除 $("#ScreenOver").remove(); }; //首页图标 wd.display.setHomeIconName = function (name) { var ele = wd.topWindow.document.getElementById("mbwzbj"); if (ele != null && name) { ele.innerHTML = name; } }; /** * * 弹出右键菜单 * * param { * leftClick:true//左击弹菜单 * } * * wd.display.showContextMenu("body",[{text:"图片",func:function(element){}}]); */ wd.display.showContextMenu = function (selecter, datas, param) { var options = $.extend({}, { leftClick: false }, param); for (var i = 0; i < datas.length; i++) { datas[i].value = i; } var id = "what_menu" + new Date().getTime(); var dom = wd.display.initSelectOption(id); wd.display.buildSelectOption(dom, datas, "value", "text", null, false); $("body").append(dom); var $dom = $(dom).css({ position: "absolute" }).hide(); var triggerElement; $dom.on("click", ".popupList", function () { var v = $(this).attr("value"); datas[v].func.call(triggerElement, triggerElement); $dom.hide(); return false; }); var eventName = options.leftClick ? "contextmenu click" : "contextmenu"; $(document).on(eventName, selecter, function () { var offset = $(this).offset(); dom.style.left = offset.left + window.event.offsetX + "px"; dom.style.top = offset.top + window.event.offsetY + "px"; $(dom).show(); triggerElement = this; return false; }); $(document).on("click", function () { $dom.hide(); }); $(".content-div,.list-div").scroll(function () { $dom.hide(); }); };