Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue #2 -- "Close" button element wasn't being removed when moda…

…l was closed.
  • Loading branch information...
commit 8998d63df63064a90f5f8588c86e302cffd36448 1 parent 3da2f27
@kylefox kylefox authored
Showing with 12 additions and 7 deletions.
  1. +6 −2 jquery.modal.js
  2. +4 −3 jquery.modal.min.js
  3. +2 −2 jquery.modal.pack.js
View
8 jquery.modal.js
@@ -1,6 +1,6 @@
/*
A simple jQuery modal (http://github.com/kylefox/jquery-modal)
- Version 0.2.1
+ Version 0.2.2
*/
(function() {
@@ -42,7 +42,8 @@
function show() {
center_modal(current_modal);
if(options.showClose) {
- current_modal.elm.append('<a href="#close-modal" rel="modal:close" class="close-modal">Close</a>');
+ current_modal.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal">Close</a>');
+ current_modal.elm.append(current_modal.closeButton);
}
$elm.addClass(options.modalClass).addClass('current').show();
$elm.trigger($.fn.modal.OPEN, [current_modal]);
@@ -82,6 +83,9 @@
}
current_modal.elm.trigger($.fn.modal.BEFORE_CLOSE, [current_modal]);
+ if(current_modal.closeButton) {
+ current_modal.closeButton.remove();
+ }
current_modal.blocker.remove();
current_modal.elm.hide();
current_modal.elm.trigger($.fn.modal.CLOSE, [current_modal]);
View
7 jquery.modal.min.js
@@ -1,14 +1,15 @@
/*
A simple jQuery modal (http://github.com/kylefox/jquery-modal)
- Version 0.2.1
+ Version 0.2.2
*/
(function(){var current_modal=null;$.fn.modal=function(options){var $elm=$(this);if($elm.attr('href')){$elm.click(open_modal_from_link);return;}
options=$.extend({},$.fn.modal.defaults,options);function block(){current_modal.blocker=$('<div class="jquery-modal blocker"></div>').css({top:0,right:0,bottom:0,left:0,width:"100%",height:"100%",position:"fixed",zIndex:options.zIndex,background:options.overlay,opacity:options.opacity});if(options.escapeClose){$(document).keydown(function(event){if(event.which==27){$.fn.modal.close();}});}
if(options.clickClose){current_modal.blocker.click($.fn.modal.close);}
$('body').append(current_modal.blocker);$elm.trigger($.fn.modal.BLOCK,[current_modal]);}
-function show(){center_modal(current_modal);if(options.showClose){current_modal.elm.append('<a href="#close-modal" rel="modal:close" class="close-modal">Close</a>');}
+function show(){center_modal(current_modal);if(options.showClose){current_modal.closeButton=$('<a href="#close-modal" rel="modal:close" class="close-modal">Close</a>');current_modal.elm.append(current_modal.closeButton);}
$elm.addClass(options.modalClass).addClass('current').show();$elm.trigger($.fn.modal.OPEN,[current_modal]);}
current_modal={elm:$elm,options:options};$elm.trigger($.fn.modal.BEFORE_BLOCK,[current_modal]);block();$elm.trigger($.fn.modal.BEFORE_OPEN,[current_modal]);show();};$.fn.modal.defaults={overlay:"#000",opacity:0.75,zIndex:1,escapeClose:true,clickClose:true,modalClass:"modal",showClose:true};$.fn.modal.BEFORE_BLOCK='modal:before-block';$.fn.modal.BLOCK='modal:block';$.fn.modal.BEFORE_OPEN='modal:before-open';$.fn.modal.OPEN='modal:open';$.fn.modal.BEFORE_CLOSE='modal:before-close';$.fn.modal.CLOSE='modal:close';$.fn.modal.close=function(event){if(event){event.preventDefault();}
if(!current_modal){return;}
-current_modal.elm.trigger($.fn.modal.BEFORE_CLOSE,[current_modal]);current_modal.blocker.remove();current_modal.elm.hide();current_modal.elm.trigger($.fn.modal.CLOSE,[current_modal]);current_modal=null;};$.fn.modal.resize=function(){center_modal(current_modal);};function open_modal_from_link(event){event.preventDefault();var target=$(this).attr('href');if(target.match(/^#/)){$(target).modal();}else{$.get(target,{},function(html){$(html).appendTo('body').bind('modal:close',function(event,modal){modal.elm.remove();}).modal();});}}
+current_modal.elm.trigger($.fn.modal.BEFORE_CLOSE,[current_modal]);if(current_modal.closeButton){current_modal.closeButton.remove();}
+current_modal.blocker.remove();current_modal.elm.hide();current_modal.elm.trigger($.fn.modal.CLOSE,[current_modal]);current_modal=null;};$.fn.modal.resize=function(){center_modal(current_modal);};function open_modal_from_link(event){event.preventDefault();var target=$(this).attr('href');if(target.match(/^#/)){$(target).modal();}else{$.get(target,{},function(html){$(html).appendTo('body').bind('modal:close',function(event,modal){modal.elm.remove();}).modal();});}}
function center_modal(modal){modal.elm.css({position:'fixed',top:"50%",left:"50%",marginTop:-(modal.elm.height()/2),marginLeft:-(modal.elm.outerWidth()/2),zIndex:modal.options.zIndex+1});};$('a[rel="modal:open"]').live('click',open_modal_from_link);$('a[rel="modal:close"]').live('click',$.fn.modal.close);})();
View
4 jquery.modal.pack.js
@@ -1,5 +1,5 @@
/*
A simple jQuery modal (http://github.com/kylefox/jquery-modal)
- Version 0.2.1
+ Version 0.2.2
*/
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(9(){r 5=L;$.4.3=9(7){r $6=$(X);c($6.W(\'m\')){$6.h(o);t}7=$.17({},$.4.3.E,7);9 g(){5.e=$(\'<D z="16-3 e"></D>\').N({Q:0,18:0,15:0,T:0,1a:"C%",S:"C%",M:"P",f:7.f,1b:7.F,s:7.s});c(7.J){$(14).10(9(b){c(b.11==13){$.4.3.8()}})}c(7.I){5.e.h($.4.3.8)}$(\'U\').B(5.e);$6.d($.4.3.K,[5])}9 q(){j(5);c(7.y){5.6.B(\'<a m="#8-3" p="3:8" z="8-3">12</a>\')}$6.A(7.H).A(\'1c\').q();$6.d($.4.3.u,[5])}5={6:$6,7:7};$6.d($.4.3.G,[5]);g();$6.d($.4.3.x,[5]);q()};$.4.3.E={F:"#1i",s:0.1f,f:1,J:l,I:l,H:"3",y:l};$.4.3.G=\'3:k-g\';$.4.3.K=\'3:g\';$.4.3.x=\'3:k-n\';$.4.3.u=\'3:n\';$.4.3.w=\'3:k-8\';$.4.3.v=\'3:8\';$.4.3.8=9(b){c(b){b.Y()}c(!5){t}5.6.d($.4.3.w,[5]);5.e.O();5.6.1g();5.6.d($.4.3.v,[5]);5=L};$.4.3.1h=9(){j(5)};9 o(b){b.Y();r i=$(X).W(\'m\');c(i.1n(/^#/)){$(i).3()}1e{$.1k(i,{},9(Z){$(Z).1d(\'U\').1j(\'3:8\',9(b,3){3.6.O()}).3()})}}9 j(3){3.6.N({M:\'P\',Q:"V%",T:"V%",1m:-(3.6.S()/2),1l:-(3.6.19()/2),f:3.7.f+1})};$(\'a[p="3:n"]\').R(\'h\',o);$(\'a[p="3:8"]\').R(\'h\',$.4.3.8)})();',62,86,'|||modal|fn|current_modal|elm|options|close|function||event|if|trigger|blocker|zIndex|block|click|target|center_modal|before|true|href|open|open_modal_from_link|rel|show|var|opacity|return|OPEN|CLOSE|BEFORE_CLOSE|BEFORE_OPEN|showClose|class|addClass|append|100|div|defaults|overlay|BEFORE_BLOCK|modalClass|clickClose|escapeClose|BLOCK|null|position|css|remove|fixed|top|live|height|left|body|50|attr|this|preventDefault|html|keydown|which|Close|27|document|bottom|jquery|extend|right|outerWidth|width|background|current|appendTo|else|75|hide|resize|000|bind|get|marginLeft|marginTop|match'.split('|'),0,{}))
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(9(){n 4=x;$.5.3=9(7){n $6=$(A);b($6.W(\'m\')){$6.j(r);B}7=$.15({},$.5.3.P,7);9 g(){4.e=$(\'<Q U="14-3 e"></Q>\').Y({L:0,13:0,16:0,K:0,17:"Z%",I:"Z%",S:"R",f:7.f,1a:7.N,s:7.s});b(7.10){$(19).12(9(c){b(c.18==1b){$.5.3.8()}})}b(7.F){4.e.j($.5.3.8)}$(\'H\').M(4.e);$6.d($.5.3.D,[4])}9 u(){k(4);b(7.v){4.i=$(\'<a m="#8-3" t="3:8" U="8-3">11</a>\');4.6.M(4.i)}$6.V(7.X).V(\'1i\').u();$6.d($.5.3.z,[4])}4={6:$6,7:7};$6.d($.5.3.y,[4]);g();$6.d($.5.3.C,[4]);u()};$.5.3.P={N:"#1k",s:0.1m,f:1,10:q,F:q,X:"3",v:q};$.5.3.y=\'3:o-g\';$.5.3.D=\'3:g\';$.5.3.C=\'3:o-p\';$.5.3.z=\'3:p\';$.5.3.E=\'3:o-8\';$.5.3.G=\'3:8\';$.5.3.8=9(c){b(c){c.w()}b(!4){B}4.6.d($.5.3.E,[4]);b(4.i){4.i.l()}4.e.l();4.6.1o();4.6.d($.5.3.G,[4]);4=x};$.5.3.1c=9(){k(4)};9 r(c){c.w();n h=$(A).W(\'m\');b(h.1n(/^#/)){$(h).3()}1l{$.1j(h,{},9(T){$(T).1e(\'H\').1d(\'3:8\',9(c,3){3.6.l()}).3()})}}9 k(3){3.6.Y({S:\'R\',L:"J%",K:"J%",1f:-(3.6.I()/2),1g:-(3.6.1h()/2),f:3.7.f+1})};$(\'a[t="3:p"]\').O(\'j\',r);$(\'a[t="3:8"]\').O(\'j\',$.5.3.8)})();',62,87,'|||modal|current_modal|fn|elm|options|close|function||if|event|trigger|blocker|zIndex|block|target|closeButton|click|center_modal|remove|href|var|before|open|true|open_modal_from_link|opacity|rel|show|showClose|preventDefault|null|BEFORE_BLOCK|OPEN|this|return|BEFORE_OPEN|BLOCK|BEFORE_CLOSE|clickClose|CLOSE|body|height|50|left|top|append|overlay|live|defaults|div|fixed|position|html|class|addClass|attr|modalClass|css|100|escapeClose|Close|keydown|right|jquery|extend|bottom|width|which|document|background|27|resize|bind|appendTo|marginTop|marginLeft|outerWidth|current|get|000|else|75|match|hide'.split('|'),0,{}))
Please sign in to comment.
Something went wrong with that request. Please try again.