diff --git a/js/dwz.ui.js b/js/dwz.ui.js index 131b3967862783a218b238095e301acfafe65c1a..ecffd39fe3b74e4296f0e88e8ba59b2db2c7f813 100644 --- a/js/dwz.ui.js +++ b/js/dwz.ui.js @@ -229,7 +229,6 @@ function initUI($p){ options.minable = eval($this.attr("minable") || "true"); options.fresh = eval($this.attr("fresh") || "true"); options.resizable = eval($this.attr("resizable") || "true"); - options.resizable = eval($this.attr("resizable") || "true"); options.drawable = eval($this.attr("drawable") || "true"); options.close = eval($this.attr("close") || ""); options.param = $this.attr("param") || ""; @@ -269,6 +268,185 @@ function initUI($p){ }); }); + //selectOneNewTab + $("a[target=selectOneNewTab]", $p).each(function(){ + + $(this).click(function(event){ + var $this = $(this); + var title = $this.attr("title") || $this.text(); + var rel = $this.attr("sname") || "ids"; + + var targetType = $this.attr("targetType"); + var ids = ""; + var $box = targetType == "dialog" ? $.pdialog.getCurrent() : navTab.getCurrentPanel(); + $box.find("input:checked").filter("[name='"+rel+"']").each(function(i){ + var val = $(this).val(); + ids += i==0 ? val : ","+val; + }); + if (!ids) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + if (ids.indexOf(',')!=-1) { + alertMsg.error($this.attr("warn")||"只能选择一条信息"); + return false; + } + var check = $(this).attr("check"); + if(check){ + check = check.substring(0,check.indexOf("(")); + if (typeof window[check]==='function'){ + if(!(window[check]())){ + return false; + } + } + } + var tabid = $this.attr("rel") || "_blank"; + var fresh = eval($this.attr("fresh") || "true"); + var external = eval($this.attr("external") || "false"); + var url = ($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first")); + url = url +ids; + DWZ.debug(url); + if (!url.isFinishedTm()) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + navTab.openTab(tabid, url,{title:title, fresh:fresh, external:external}); + + event.preventDefault(); + + }); + }) + + //selectOneDialog + $("a[target=selectOneDialog]", $p).each(function(){ + + $(this).click(function(event){ + var $this = $(this); + var title = $this.attr("title") || $this.text(); + var rel = $this.attr("sname") || "ids"; + + var targetType = $this.attr("targetType"); + var ids = ""; + var $box = targetType == "dialog" ? $.pdialog.getCurrent() : navTab.getCurrentPanel(); + $box.find("input:checked").filter("[name='"+rel+"']").each(function(i){ + var val = $(this).val(); + ids += i==0 ? val : ","+val; + }); + if (!ids) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + if (ids.indexOf(',')!=-1) { + alertMsg.error($this.attr("warn")||"只能选择一条信息"); + return false; + } + var check = $(this).attr("check"); + if(check){ + check = check.substring(0,check.indexOf("(")); + if (typeof window[check]==='function'){ + if(!(window[check]())){ + return false; + } + } + } + var options = {}; + var w = $this.attr("width"); + var h = $this.attr("height"); + if(w&&/.*%$/.test(w)){ + var sw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; + w = Number(w.substring(0,w.length-1))*sw/100; + } + if(h&&/.*%$/.test(h)){ + var sh = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + h = Number(h.substring(0,h.length-1))*sh/100; + } + if (w) options.width = w; + if (h) options.height = h; + options.max = eval($this.attr("max") || "false"); + options.mask = eval($this.attr("mask") || "false"); + options.maxable = eval($this.attr("maxable") || "true"); + options.minable = eval($this.attr("minable") || "true"); + options.fresh = eval($this.attr("fresh") || "true"); + options.resizable = eval($this.attr("resizable") || "true"); + options.drawable = eval($this.attr("drawable") || "true"); + options.close = eval($this.attr("close") || ""); + options.param = $this.attr("param") || ""; + var url = ($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first")); + url = url +ids; + DWZ.debug(url); + if (!url.isFinishedTm()) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + $.pdialog.open(url, rel, title, options); + + return false; + }); + }) + + //selectMultipleDialog + $("a[target=selectMultipleDialog]", $p).each(function(){ + + $(this).click(function(event){ + var $this = $(this); + var title = $this.attr("title") || $this.text(); + var rel = $this.attr("sname") || "ids"; + + var targetType = $this.attr("targetType"); + var ids = ""; + var $box = targetType == "dialog" ? $.pdialog.getCurrent() : navTab.getCurrentPanel(); + $box.find("input:checked").filter("[name='"+rel+"']").each(function(i){ + var val = $(this).val(); + ids += i==0 ? val : ","+val; + }); + if (!ids) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + var check = $(this).attr("check"); + if(check){ + check = check.substring(0,check.indexOf("(")); + if (typeof window[check]==='function'){ + if(!(window[check]())){ + return false; + } + } + } + var options = {}; + var w = $this.attr("width"); + var h = $this.attr("height"); + if(w&&/.*%$/.test(w)){ + var sw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; + w = Number(w.substring(0,w.length-1))*sw/100; + } + if(h&&/.*%$/.test(h)){ + var sh = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + h = Number(h.substring(0,h.length-1))*sh/100; + } + if (w) options.width = w; + if (h) options.height = h; + options.max = eval($this.attr("max") || "false"); + options.mask = eval($this.attr("mask") || "false"); + options.maxable = eval($this.attr("maxable") || "true"); + options.minable = eval($this.attr("minable") || "true"); + options.fresh = eval($this.attr("fresh") || "true"); + options.resizable = eval($this.attr("resizable") || "true"); + options.drawable = eval($this.attr("drawable") || "true"); + options.close = eval($this.attr("close") || ""); + options.param = $this.attr("param") || ""; + var url = ($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first")); + url = url +ids; + DWZ.debug(url); + if (!url.isFinishedTm()) { + alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg")); + return false; + } + $.pdialog.open(url, rel, title, options); + + return false; + }); + }) + $("div.pagination", $p).each(function(){ var $this = $(this); $this.pagination({