From 1d410032383cd93b54b80daf0224201fdc1014d7 Mon Sep 17 00:00:00 2001 From: Terry Zeng Date: Sun, 6 Aug 2017 14:36:16 +0800 Subject: [PATCH] update --- b.dialog.bootstrap3.css | 28 +++++++++++++++++++++++++++- b.dialog.css | 29 ++++++++++++++++++++++++++++- b.dialog.js | 39 ++++++++++++++++++++++++++++++++++++--- b.dialog.min.js | 2 +- 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/b.dialog.bootstrap3.css b/b.dialog.bootstrap3.css index c71f908..550f4c9 100644 --- a/b.dialog.bootstrap3.css +++ b/b.dialog.bootstrap3.css @@ -13,6 +13,25 @@ div.bDialog.in div.modal-dialog { -o-transform: translate(0,0); transform: translate(0,0); } + +/* 窗口最大化功能 */ +div.bDialog.maximize { + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; + padding-right: 0px !important; +} +div.bDialog.maximize div.modal-dialog { + width: 100% !important; + height: 100% !important; +} +div.bDialog.maximize div.modal-content { + height: 100% !important; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} + div.bDialog div.modal-dialog { position: relative; margin: 0px auto; @@ -61,7 +80,14 @@ div.bDialog div.modal-header button.close { div.bDialog div.modal-header button.close:hover { opacity: 1; } - +div.bDialog div.modal-header button.bDialogCloseButton { + font-weight: normal; +} +div.bDialog div.modal-header button.maximize { + margin-right: 5px; + margin-top: 0px; + font-size: 25px !important; +} div.modal-backdrop, div.modal-backdrop.fade.in { opacity: 0.8; background-color: black; diff --git a/b.dialog.css b/b.dialog.css index 5d0d71d..b43e461 100644 --- a/b.dialog.css +++ b/b.dialog.css @@ -23,6 +23,26 @@ div.bDialog.in div.modal-dialog { -o-transform: translate(0,0); transform: translate(0,0); } + +/* 窗口最大化功能 */ +div.bDialog.maximize { + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} +div.bDialog.maximize div.modal-dialog { + width: 100% !important; + height: 100% !important; +} +div.bDialog.maximize div.modal-content { + height: 100% !important; + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} + + + div.bDialog div.modal-dialog { position: relative; margin: 0px auto; @@ -68,7 +88,14 @@ div.bDialog div.modal-header button.close { div.bDialog div.modal-header button.close:hover { opacity: 1; } - +div.bDialog div.modal-header button.bDialogCloseButton { + font-weight: normal; +} +div.bDialog div.modal-header button.maximize { + margin-right: 5px; + margin-top: 1px; + font-size: 25px !important; +} div.modal-backdrop, div.modal-backdrop.fade.in { opacity: 0.8; background-color: black; diff --git a/b.dialog.js b/b.dialog.js index 17d93f1..abd4900 100644 --- a/b.dialog.js +++ b/b.dialog.js @@ -34,6 +34,14 @@ * 修复部分参数丢失的问题 * 2017.07.20 * 修复窗口最小高度限制问题 + * 2017.07.24 + * 修复Bootstrap3下样式应用无效果问题 + * 统一处理Bootstrap2、3的窗口高度计算 + * 修复Bootstrap3下全宽度窗口没有铺满全宽度的问题 + * 2017.08.06 + * 增加窗口最大化功能 + * 增加dialogMaxButton配置项目,设置是否启用最大化窗口按钮,默认:true + * 修正部分样式问题 */ /* ======================================================================== * Bootstrap: modal.js v3.3.7 @@ -52,7 +60,8 @@ '';var _defaults={'backdrop':'static','title':'对话框','width':700,'height':400,'animation':false,'dialogCloseButton':true,'closeButton':false,'scroll':true,'drag':true,'url':false,'fullWidth':false,'customClass':undefined,'show':false,'onShow':$.noop,'onShowed':$.noop,'onHide':$.noop,'onHidden':$.noop,'callback':$.noop};var _bDialog={setParam:function(param){return $.extend({},_defaults,param);},buildDialog:function(p,obj){var template=_template;var dialog=$(template);var topBody=window.top.document.body;dialog.timeout=null;if(p.title)$("h3.bDialogHeaderLabel",$(dialog)).html(p.title);else $('div.bDialogHeader',$(dialog)).hide();if(!p.dialogCloseButton)$('button.bDialogCloseButton',$(dialog)).hide();if(p.animation)$(dialog).addClass('fade');if(p.closeButton){$("div.bDialogFooter",$(dialog)).empty().append('');$("div.bDialogFooter",$(dialog)).show();}var _callback=null;if(p.callback&&$.isFunction(p.callback)){_callback=function(data){if(data){if($.isArray(data)){p.callback({"results":data});return;}else{p.callback({"results":[data]});return;}}else{p.callback({"results":null});return;}};}if(p.callback)dialog.callback=_callback;dialog[0].params=p.params?p.params:{};dialog[0].returnData=null;if(obj){var content=$(obj).clone(true);$("div.bDialogBody",$(dialog)).html($(content).show());if(p.scroll)$("div.bDialogBody",$(dialog)).css('overflow-y','auto');}else if(p.url){var tmp=p.scroll?'yes':'no';var iframe='';$("div.bDialogBody",$(dialog)).html(iframe);}if(p.fullWidth){$("div.bDialogHeader,div.bDialogBody,div.bDialogFooter",$(dialog)).addClass('container');$(dialog).addClass('fullWidth');p.width='100%';}if(p.customClass)$(dialog).addClass(p.customClass);$(topBody).append(dialog);return dialog;},bindEvent:function(dialog,p){var $top=window.top.$;var topBody=window.top.document.body;if(p.onShow&&$.isFunction(p.onShow))$top(dialog).off('show.bs.modal').on('show.bs.modal',function(){p.onShow(this);});if(p.onShowed&&$.isFunction(p.onShowed))$top(dialog).off('shown.bs.modal').on('shown.bs.modal',function(){p.onShowed(this);});if(p.onHide&&$.isFunction(p.onHide))$top(dialog).off('hide.bs.modal').on('hide.bs.modal',function(){p.onHide(this);});$top(dialog).off('hidden.bs.modal').on('hidden.bs.modal',function(e){clearTimeout(dialog.timeout);if(p.onHidden&&$.isFunction(p.onHidden))p.onHidden(this);var data=dialog[0].returnData,callback=dialog.callback;if(callback&&$.isFunction(callback))callback(data);if($('iframe',$(this)).size()>0)$('iframe',$(this)).remove();$(this).remove();if($('[dialog="bDialog"]',$(topBody)).size()>0)$('[dialog="bDialog"]:last',$(topBody)).addClass('dialogInActive');});if(!p.fullWidth){$top('div.bDialog:last',$top(topBody)).off('click.bDialog').on('click.bDialog',function(e){var srcEl=e.target||e.srcElement;if($(srcEl).is('div.bDialog')){var that=$top('div.bDialog:last',$top(topBody));$top(that).removeClass('animated').removeClass('shake');setTimeout(function(){that.addClass('animated').addClass('shake');},0);}});}$top(window.top).bind('resize.bDialog',function(){clearTimeout(dialog.timeout);dialog.timeout=setTimeout(function(){_bDialog.rePosition(dialog);},100);});},openDialog:function(dialog,p){$('div.modal-dialog',$(dialog)).css({'width':p.width,'height':p.height});window.top.$(dialog).modal({backdrop:p.backdrop}).removeClass('hide');},setCssStyle:function(dialog,p,obj){var topBody=window.top.document.body;var setSize=$('div.modal-backdrop',$(topBody)).size();var baseNumber=1000;var stepNumber=(setSize-1)*20;$('div.modal-backdrop:last',$(topBody)).css('z-index',baseNumber+stepNumber+10);$('div.bDialog:last div.modal-content',$(topBody)).css('z-index',baseNumber+stepNumber+20);$('div.bDialog:last',$(topBody)).css('z-index',baseNumber+stepNumber+19);if(setSize>1)$('div.modal-backdrop:last',$(topBody)).css('opacity','0.1');var totalHeight=$('div.modal-dialog',$(dialog)).innerHeight();var head=$("div.bDialogHeader",$(dialog)).outerHeight(true);var footer=p.closeButton?$("div.bDialogFooter",$(dialog)).outerHeight(true):0;var bodyPaddingTop=parseFloat($("div.bDialogBody",$(dialog)).css('padding-top'));var bodyPaddingBottom=parseFloat($("div.bDialogBody",$(dialog)).css('padding-bottom'));var newBodyHeight=totalHeight-head-footer;var minBodyHeight=100-head-footer;if(newBodyHeightdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&e?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!e?this.scrollbarWidth:""})};b.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})};b.prototype.checkScrollbar=function(){var f=window.innerWidth;if(!f){var e=document.documentElement.getBoundingClientRect();f=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth'+'';var _defaults={'backdrop':'static','title':'对话框','width':700,'height':400,'animation':false,'dialogCloseButton':true,'dialogMaxButton':true,'closeButton':false,'scroll':true,'drag':true,'url':false,'fullWidth':false,'customClass':undefined,'show':false,'onShow':$.noop,'onShowed':$.noop,'onHide':$.noop,'onHidden':$.noop,'callback':$.noop};var _bDialog={setParam:function(param){return $.extend({},_defaults,param);},buildDialog:function(p,obj){var template=_template;var dialog=$(template);var topBody=window.top.document.body;dialog.timeout=null;if(p.title)$("h3.bDialogHeaderLabel",$(dialog)).html(p.title);else $('div.bDialogHeader',$(dialog)).hide();if(!p.dialogCloseButton)$('button.bDialogCloseButton',$(dialog)).hide();if(!p.dialogMaxButton)$('button.bDialogMaxButton',$(dialog)).hide();if(p.animation)$(dialog).addClass('fade');if(p.closeButton){$("div.bDialogFooter",$(dialog)).empty().append('');$("div.bDialogFooter",$(dialog)).show();}var _callback=null;if(p.callback&&$.isFunction(p.callback)){_callback=function(data){if(data){if($.isArray(data)){p.callback({"results":data});return;}else{p.callback({"results":[data]});return;}}else{p.callback({"results":null});return;}};}if(p.callback)dialog.callback=_callback;dialog[0].params=p.params?p.params:{};dialog[0].returnData=null;if(obj){var content=$(obj).clone(true);$("div.bDialogBody",$(dialog)).html($(content).show());if(p.scroll)$("div.bDialogBody",$(dialog)).css('overflow-y','auto');}else if(p.url){var tmp=p.scroll?'yes':'no';var iframe='';$("div.bDialogBody",$(dialog)).html(iframe);}if(p.fullWidth){$("div.bDialogHeader,div.bDialogBody,div.bDialogFooter",$(dialog)).addClass('container');$(dialog).addClass('fullWidth');p.width='100%';}if(p.customClass)$(dialog).addClass(p.customClass);$(topBody).append(dialog);return dialog;},bindEvent:function(dialog,p){var $top=window.top.$;var topBody=window.top.document.body;if(p.onShow&&$.isFunction(p.onShow))$top(dialog).off('show.bs.modal').on('show.bs.modal',function(){p.onShow(this);});if(p.onShowed&&$.isFunction(p.onShowed))$top(dialog).off('shown.bs.modal').on('shown.bs.modal',function(){p.onShowed(this);});if(p.onHide&&$.isFunction(p.onHide))$top(dialog).off('hide.bs.modal').on('hide.bs.modal',function(){p.onHide(this);});if(p.dialogMaxButton){$top('button.bDialogMaxButton',dialog).off('click.bDialog').on('click.bDialog',function(e){e.stopPropagation();_bDialog.maxWindow(dialog,p);});}$top(dialog).off('hidden.bs.modal').on('hidden.bs.modal',function(e){clearTimeout(dialog.timeout);if(p.onHidden&&$.isFunction(p.onHidden))p.onHidden(this);var data=dialog[0].returnData,callback=dialog.callback;if(callback&&$.isFunction(callback))callback(data);if($('iframe',$(this)).size()>0)$('iframe',$(this)).remove();$(this).remove();if($('[dialog="bDialog"]',$(topBody)).size()>0)$('[dialog="bDialog"]:last',$(topBody)).addClass('dialogInActive');});if(!p.fullWidth){$top('div.bDialog:last',$top(topBody)).off('click.bDialog').on('click.bDialog',function(e){var srcEl=e.target||e.srcElement;if($(srcEl).is('div.bDialog')){var that=$top('div.bDialog:last',$top(topBody));$top(that).removeClass('animated').removeClass('shake');setTimeout(function(){that.addClass('animated').addClass('shake');},0);}});}$top(window.top).bind('resize.bDialog',function(){clearTimeout(dialog.timeout);dialog.timeout=setTimeout(function(){_bDialog.rePosition(dialog);},100);});},openDialog:function(dialog,p){$('div.modal-dialog',$(dialog)).css({'width':p.width,'height':p.height});window.top.$(dialog).modal({backdrop:p.backdrop}).removeClass('hide');},setCssStyle:function(dialog,p,obj){var topBody=window.top.document.body;var setSize=$('div.modal-backdrop',$(topBody)).size();var baseNumber=1000;var stepNumber=(setSize-1)*20;$('div.modal-backdrop:last',$(topBody)).css('z-index',baseNumber+stepNumber+10);$('div.bDialog:last div.modal-content',$(topBody)).css('z-index',baseNumber+stepNumber+20);$('div.bDialog:last',$(topBody)).css('z-index',baseNumber+stepNumber+19);if(setSize>1)$('div.modal-backdrop:last',$(topBody)).css('opacity','0.1');var totalHeight=$('div.modal-dialog',$(dialog)).innerHeight();var head=$("div.bDialogHeader",$(dialog)).outerHeight(true);var footer=p.closeButton?$("div.bDialogFooter",$(dialog)).outerHeight(true):0;var bodyPaddingTop=parseFloat($("div.bDialogBody",$(dialog)).css('padding-top'));var bodyPaddingBottom=parseFloat($("div.bDialogBody",$(dialog)).css('padding-bottom'));var newBodyHeight=totalHeight-head-footer;var minBodyHeight=100-head-footer;if(newBodyHeight