diff --git a/js/dwz.dialog.js b/js/dwz.dialog.js index a59b971996ee7deeb96748aa3f5a0455c19d9e40..80fc15d77c13d7d1f658a2d15dc152387a06ed94 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 131b3967862783a218b238095e301acfafe65c1a..448039e1c25af0a5389dc32e9ed114d35630f44f 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");