/* * jqmodal - minimalist modaling with jquery * * copyright (c) 2007 brice burgess , http://www.iceburg.net * licensed under the mit license: * http://www.opensource.org/licenses/mit-license.php * * $version: 2007.08.17 +r11 * */ (function($) { $.fn.jqm=function(o){ var _o = { zindex: 3000, overlay: 75, overlayclass: 'jqmoverlay', closeclass: 'jqmclose', trigger: '.jqmodal', ajax: false, target: false, modal: false, totop: false, onshow: false, onhide: false, onload: false }; return this.each(function(){ if(this._jqm)return; s++; this._jqm=s; h[s]={c:$.extend(_o, o),a:false,w:$(this).addclass('jqmid'+s),s:s}; if(_o.trigger)$(this).jqmaddtrigger(_o.trigger); });}; $.fn.jqmaddclose=function(e){hs(this,e,'jqmhide'); return this;}; $.fn.jqmaddtrigger=function(e){hs(this,e,'jqmshow'); return this;}; $.fn.jqmshow=function(t){return this.each(function(){if(!h[this._jqm].a)$.jqm.open(this._jqm,t)});}; $.fn.jqmhide=function(t){return this.each(function(){if(h[this._jqm].a)$.jqm.close(this._jqm,t)});}; $.jqm = { hash:{}, open:function(s,t){var h=h[s],c=h.c,cc='.'+c.closeclass,z=(/^\d+$/.test(h.w.css('z-index')))?h.w.css('z-index'):c.zindex,o=$('
').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1}).opacity(c.overlay);h.t=t;h.a=true;h.w.css('z-index',z); if(c.modal) {if(!a[0])f('bind');a.push(s);o.css('cursor','default');} else if(c.overlay > 0)h.w.jqmaddclose(o); else o=false; h.o=(o)?o.addclass(c.overlayclass).prependto('body'):false; if($.browser.msie){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {top:1,left:1})o.style.setexpression(y.tolowercase(),"(_=(document.documentelement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}} if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u; r.load(u,function(){if(c.onload)c.onload.call(this,h);if(cc)h.w.jqmaddclose($(cc,h.w));e(h);});} else if(cc)h.w.jqmaddclose($(cc,h.w)); if(c.totop&&h.o)h.w.before('').insertafter(h.o); (c.onshow)?c.onshow(h):h.w.show();e(h);return false; }, close:function(s){var h=h[s];h.a=false; if(a[0]){a.pop();if(!a[0])f('unbind');} if(h.c.totop&&h.o)$('#jqmp'+h.w[0]._jqm).after(h.w).remove(); if(h.c.onhide)h.c.onhide(h);else{h.w.hide();if(h.o)h.o.remove();} return false; }}; var s=0,h=$.jqm.hash,a=[],ie6=$.browser.msie&&($.browser.version == "6.0"), i=$('').css({opacity:0}), e=function(h){if(ie6)if(h.o)h.o.html('

').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);}, f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(e){}}, f=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);}, m=function(e){var h=h[a[a.length-1]],r=(!$(e.target).parents('.jqmid'+h.s)[0]);if(r)f(h);return !r;}, hs=function(w,e,y){var s=[];w.each(function(){s.push(this._jqm)}); $(e).each(function(){if(this[y])$.extend(this[y],s);else{this[y]=s;$(this).click(function(){for(var i in {jqmshow:1,jqmhide:1})for(var s in this[i])if(h[this[i][s]])h[this[i][s]].w[i](this);return false;});}});}; })(jquery);