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=exit", {}, function (result) {
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.pluginList) {
for (var i = 0; i < r.pluginList.lenth; i++) {
addRemoveToken(r.pluginList[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 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