forked from kdajones/jquery-pageslide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.pageslide.min.js
7 lines (7 loc) · 3.33 KB
/
jquery.pageslide.min.js
1
2
3
4
5
6
7
(function(a){a.fn.pageSlide=function(c){function e(f){if(a("#pageslide-slide-wrap").width()!=0)return!1;d.modal==!0&&a("#pageslide-blanket").toggle().animate({opacity:"0.8"},"fast","linear");d.direction=="right"?(direction={right:"-"+d.width},a("#pageslide-slide-wrap").css({left:0}),a.browser.msie?a("body, html").css({overflowX:"hidden"}):a("body").css({overflowX:"hidden"})):(direction={left:"-"+d.width},a("#pageslide-slide-wrap").css({right:0}));a("#pageslide-slide-wrap").animate({width:d.width},
d.duration);a("#pageslide-body-wrap").animate(direction,d.duration,function(){a.ajax({type:"GET",url:a(f).attr("href"),success:function(b){a("#pageslide-content").css("width",d.width).html(b).queue(function(){a(this).dequeue();a(this).find(".pageslide-close").unbind("click").click(function(b){g(b);a(this).find("pageslide-close").unbind("click")})})}})})}function g(f){a(f)[0].button!=2&&a("#pageslide-slide-wrap").css("width")!="0px"&&a.fn.pageSlideClose(d)}var d=a.extend({width:"300px",duration:"normal",
direction:"left",modal:!1,_identifier:a(this)},c),h={position:"fixed",width:"0",top:"0",height:"100%",zIndex:"999"},i={position:"relative",zIndex:"0"},j={position:"absolute",top:"0px",left:"0px",height:"100%",width:"100%",opacity:"0.0",backgroundColor:"black",zIndex:"1",display:"none"};(function(f){if(a("#pageslide-body-wrap, #pageslide-content, #pageslide-slide-wrap").size()==0){var b=document.createElement("div");a(b).css(i);a(b).attr("id","pageslide-body-wrap").width(a("body").width());a("body").contents().wrapAll(b);
b=document.createElement("div");a(b).attr("id","pageslide-content").width(d.width);var c=document.createElement("div");a(c).css(h);a(c).attr("id","pageslide-slide-wrap").append(b);a("body").append(c)}a("#pageslide-blanket").size()==0&&d.modal==!0&&(b=document.createElement("div"),a(b).css(j),a(b).attr("id","pageslide-blanket"),a("body").append(b),a("#pageslide-blanket").click(function(){return!1}));a(window).resize(function(){a("#pageslide-body-wrap").width(a("body").width())});a(f).attr("rel","pageslide")})(this);
return this.each(function(){a(this).unbind("click").bind("click",function(){function c(a){for(;a!=null;a=a.parentElement)if(a.tagName=="A")return!0;return!1}e(this);a("#pageslide-slide-wrap").unbind("click").click(function(a){if(!c(a.target))return!1});d.modal!=!0&&a(document).unbind("click").click(function(b){if(!c(b.target))return a(document).unbind("click"),g(b),!1});return!1})})}})(jQuery);
(function(a){a.fn.pageSlideClose=function(c){var e=a.extend({width:"300px",duration:"normal",direction:"left",modal:!1,_identifier:a(this)},c);(function(){e.modal==!0&&a("#pageslide-blanket").is(":visible")&&a("#pageslide-blanket").animate({opacity:"0.0"},"fast","linear",function(){a(this).hide()})})();direction=a("#pageslide-slide-wrap").css("left")!="0px"?{left:"0"}:{right:"0"};a("#pageslide-body-wrap").animate(direction,e.duration);a("#pageslide-slide-wrap").animate({width:"0"},e.duration,function(){a("#pageslide-content").css("width",
"0px").empty();a("#pageslide-body-wrap, #pageslide-slide-wrap").css("left","");a("#pageslide-body-wrap, #pageslide-slide-wrap").css("right","");a.browser.msie?a("body, html").css({overflowX:""}):a("body").css({overflowX:""})})}})(jQuery);(function(a){a(document).ready(function(){a(document).keyup(function(c){!a("#pageslide-blanket").is(":visible")&&c.keyCode==27&&a.fn.pageSlideClose()})})})(jQuery);