From e15c263c2d0731255ef949247efd518b504c6037 Mon Sep 17 00:00:00 2001 From: lijiangt Date: Sun, 9 Dec 2018 17:56:43 +0800 Subject: [PATCH] =?UTF-8?q?dialog=E6=94=AF=E6=8C=81=E4=BB=A5=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E7=AA=97=E5=8F=A3=E7=99=BE=E5=88=86=E6=AF=94?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=E8=AE=BE=E7=BD=AE=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E5=92=8C=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/dwz.dialog.js | 10 +++++++++- js/dwz.ui.js | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/dwz.dialog.js b/js/dwz.dialog.js index a59b971..80fc15d 100644 --- a/js/dwz.dialog.js +++ b/js/dwz.dialog.js @@ -180,6 +180,14 @@ }, _init:function(dialog, options) { var op = $.extend({}, this._op, options); + if(op.width&&/.*%$/.test(op.width)){ + var sw = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; + op.width = Number(op.width.substring(0,op.width.length-1))*sw/100; + } + if(op.height&&/.*%$/.test(op.height)){ + var sh = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + op.height = Number(op.height.substring(0,op.height.length-1))*sh/100; + } var height = op.height>op.minH?op.height:op.minH; var width = op.width>op.minW?op.width:op.minW; if(isNaN(dialog.height()) || dialog.height() < height){ @@ -364,4 +372,4 @@ $(window).trigger(DWZ.eventType.resizeGrid); } }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/js/dwz.ui.js b/js/dwz.ui.js index 131b396..448039e 100644 --- a/js/dwz.ui.js +++ b/js/dwz.ui.js @@ -221,6 +221,14 @@ function initUI($p){ 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"); -- Gitee