diff --git a/b.dialog.bootstrap3.css b/b.dialog.bootstrap3.css index 4de9b8d..c71f908 100644 --- a/b.dialog.bootstrap3.css +++ b/b.dialog.bootstrap3.css @@ -75,6 +75,7 @@ div.bDialog.fullWidth { -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; + padding-right: 0px; } div.bDialog.fullWidth div.modal-header { -webkit-border-radius: 0px; diff --git a/b.dialog.js b/b.dialog.js index b154165..17d93f1 100644 --- a/b.dialog.js +++ b/b.dialog.js @@ -197,16 +197,18 @@ $(this).remove(); if($('[dialog="bDialog"]',$(topBody)).size() > 0) $('[dialog="bDialog"]:last',$(topBody)).addClass('dialogInActive'); }); - $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); - } - }); + 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() { // clear a previously set timeout @@ -293,6 +295,8 @@ var bodyFrameCss = {'height':frameHeight,'max-height':frameHeight}; $("iframe.bDialogBodyFrame",$(dialog)).css(bodyFrameCss); } + if(p.fullWidth) $(dialog).css('padding-right','0px'); + //清除所有已弹出窗口的当前激活样式 $('[dialog="bDialog"]',$(topBody)).removeClass('dialogInActive'); $(dialog).addClass('dialogInActive'); diff --git a/b.dialog.min.js b/b.dialog.min.js index 98cd494..a9d5b9e 100644 --- a/b.dialog.min.js +++ b/b.dialog.min.js @@ -1,3 +1,3 @@ -+function(d){var b=function(f,e){this.options=e;this.$body=d(document.body);this.$element=d(f);this.$dialog=this.$element.find(".modal-dialog");this.$backdrop=null;this.isShown=null;this.originalBodyPad=null;this.scrollbarWidth=0;this.ignoreBackdropClick=false;if(this.options.remote){this.$element.find(".modal-content").load(this.options.remote,d.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))}};b.VERSION="3.3.7";b.TRANSITION_DURATION=300;b.BACKDROP_TRANSITION_DURATION=150;b.DEFAULTS={backdrop:true,keyboard:true,show:true};b.prototype.toggle=function(e){return this.isShown?this.hide():this.show(e)};b.prototype.show=function(h){var f=this;var g=d.Event("show.bs.modal",{relatedTarget:h});this.$element.trigger(g);if(this.isShown||g.isDefaultPrevented()){return}this.isShown=true;this.checkScrollbar();this.setScrollbar();this.$body.addClass("modal-open");this.escape();this.resize();this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',d.proxy(this.hide,this));this.$dialog.on("mousedown.dismiss.bs.modal",function(){f.$element.one("mouseup.dismiss.bs.modal",function(i){if(d(i.target).is(f.$element)){f.ignoreBackdropClick=true}})});this.backdrop(function(){var j=d.support.transition&&f.$element.hasClass("fade");if(!f.$element.parent().length){f.$element.appendTo(f.$body)}f.$element.show().scrollTop(0);f.adjustDialog();if(j){f.$element[0].offsetWidth}f.$element.addClass("in");f.enforceFocus();var i=d.Event("shown.bs.modal",{relatedTarget:h});j?f.$dialog.one("bsTransitionEnd",function(){f.$element.trigger("focus").trigger(i)}).emulateTransitionEnd(b.TRANSITION_DURATION):f.$element.trigger("focus").trigger(i)})};b.prototype.hide=function(f){if(f){f.preventDefault()}f=d.Event("hide.bs.modal");this.$element.trigger(f);if(!this.isShown||f.isDefaultPrevented()){return}this.isShown=false;this.escape();this.resize();d(document).off("focusin.bs.modal");this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal");this.$dialog.off("mousedown.dismiss.bs.modal");d.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",d.proxy(this.hideModal,this)).emulateTransitionEnd(b.TRANSITION_DURATION):this.hideModal()};b.prototype.enforceFocus=function(){d(document).off("focusin.bs.modal").on("focusin.bs.modal",d.proxy(function(f){if(document!==f.target&&this.$element[0]!==f.target&&!this.$element.has(f.target).length){this.$element.trigger("focus")}},this))};b.prototype.escape=function(){if(this.isShown&&this.options.keyboard){this.$element.on("keydown.dismiss.bs.modal",d.proxy(function(f){f.which==27&&this.hide()},this))}else{if(!this.isShown){this.$element.off("keydown.dismiss.bs.modal")}}};b.prototype.resize=function(){if(this.isShown){d(window).on("resize.bs.modal",d.proxy(this.handleUpdate,this))}else{d(window).off("resize.bs.modal")}};b.prototype.hideModal=function(){var e=this;this.$element.hide();this.backdrop(function(){e.$body.removeClass("modal-open");e.resetAdjustments();e.resetScrollbar();e.$element.trigger("hidden.bs.modal")})};b.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove();this.$backdrop=null};b.prototype.backdrop=function(i){var h=this;var f=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=d.support.transition&&f;this.$backdrop=d(document.createElement("div")).addClass("modal-backdrop "+f).appendTo(this.$body);this.$element.on("click.dismiss.bs.modal",d.proxy(function(j){if(this.ignoreBackdropClick){this.ignoreBackdropClick=false;return}if(j.target!==j.currentTarget){return}this.options.backdrop=="static"?this.$element[0].focus():this.hide()},this));if(e){this.$backdrop[0].offsetWidth}this.$backdrop.addClass("in");if(!i){return}e?this.$backdrop.one("bsTransitionEnd",i).emulateTransitionEnd(b.BACKDROP_TRANSITION_DURATION):i()}else{if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var g=function(){h.removeBackdrop();i&&i()};d.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",g).emulateTransitionEnd(b.BACKDROP_TRANSITION_DURATION):g()}else{if(i){i()}}}};b.prototype.handleUpdate=function(){this.adjustDialog()};b.prototype.adjustDialog=function(){var e=this.$element[0].scrollHeight>document.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,'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');});$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,'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(newBodyHeight