forked from exexzian/photowall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.photoWall.min.js
12 lines (12 loc) · 4.55 KB
/
jquery.photoWall.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*!
* jQuery photoWall.js v0.1.0
* http://jeremyjcpaul.com
* https://github.com/jeremyjcpaul/photowall
*
* Copyright 2013 Jeremy JC Paul
* Released under the MIT license.
* https://github.com/jeremyjcpaul/photowall/blob/master/MIT-LICENSE.txt
*
* Date: 04/06/2013
*/
(function(e){function i(i,s){function a(){y("beforeInit");e(window).load(function(){e(".pw-previewer").remove();e(".pw-slide").attr("class","pw-slide");var t=0;e(".pw-slide").each(function(){e(this).addClass("offset-"+e(this).offset().top);if(t!=0){var n=e(this).offset().top;if(t!=n){e(this).prev().addClass("pw-slide-group-last");e(this).addClass("pw-slide-group-first").before("<div class='pw-previewer pw-preview-"+t+" hide'>HERE</div>");t=n}}else{t=e(this).offset().top}});u.append("<div class='pw-previewer pw-preview-"+t+" hide'>HERE</div>");u.children(".pw-slide:first").addClass("pw-slide-group-first");u.children(".pw-slide:last").addClass("pw-slide-group-last");y("afterInit")});e(".pw-slide").click(function(){n=e(this);e(".pw-previewer").addClass("hide").stop().slideUp(s.speed);$previewer=n.nextAll(".pw-previewer:first");r=$previewer;$previewer.empty();$previewer.append("<span class='pw-previewer-close'>x</span>");e(".pw-previewer-close").click(function(){n=0;r.empty();r=0;e(".pw-previewer").addClass("hide").stop().slideUp(s.speed)});e(this).children("img").clone().appendTo($previewer);e(this).children(".pw-image-desc").contents().clone().appendTo($previewer);$previewer.children("h1, p").wrapAll("<div />");$previewer.slideDown(s.speed,function(){e("html,body").animate({scrollTop:$previewer.children("img").offset().top-100},s.speed)}).removeClass("hide")});e(document).keydown(function(e){switch(e.which){case 27:d();break;case 37:m();break;case 39:v();break;default:return}e.preventDefault()})}function f(e,t){if(t){s[e]=t}else{return s[e]}}function l(t){e(".pw-slide:eq("+t.toString()+")").click()}function c(t){e(".pw-slide#"+t.toString()).click()}function h(){e(".pw-slide:first").click()}function p(){e(".pw-slide:last").click()}function d(){y("beforeClose");n=0;r.empty();r=0;e(".pw-previewer").addClass("hide").stop().slideUp(s.speed);y("afterClose")}function v(){y("beforeNext");y("beforeNextPrev");if(n.next().hasClass("pw-previewer")){if(n.nextAll(".pw-slide:first").length==0)e(".pw-slide:first").click();else n.nextAll(".pw-slide-group-first:first").click()}else{$newContent=n.nextAll(".pw-slide:first");n=$newContent;r.empty();r.append("<span class='pw-previewer-close'>x</span>");e(".pw-previewer-close").click(function(){n=0;r.empty();r=0;e(".pw-previewer").addClass("hide").stop().slideUp(s.speed)});$newContent.children().clone().appendTo(r)}e("html,body").animate({scrollTop:r.children("img").offset().top-100},s.speed);y("afterNext");y("afterNextPrev")}function m(){y("beforePrev");y("beforeNextPrev");if(n.prev().hasClass("pw-previewer")){n.prevAll(".pw-slide-group-last:first").click()}else{if(n.prevAll(".pw-slide:first").length==0){e(".pw-slide:last").click();$newContent=e(".pw-slide:last")}else{$newContent=n.prevAll(".pw-slide:first")}n=$newContent;r.empty();r.append("<span class='pw-previewer-close'>x</span>");e(".pw-previewer-close").click(function(){n=0;r.empty();r=0;e(".pw-previewer").addClass("hide").stop().slideUp(s.speed)});$newContent.children().clone().appendTo(r)}e("html,body").animate({scrollTop:r.children("img").offset().top-100},s.speed);y("afterPrev");y("afterNextPrev")}function g(){u.each(function(){var n=this;var r=e(this);e(".pw-slide").unbind().attr("class","pw-slide");e(".pw-previewer").remove();y("onDestroy");r.removeData("plugin_"+t)})}function y(e){if(s[e]!==undefined){s[e].call(o)}}var o=i;var u=e(i);s=e.extend({},e.fn[t].defaults,s);a();return{option:f,select:l,selectById:c,selectFirst:h,selectLast:p,close:d,next:v,prev:m,destroy:g}}var t="photoWall";var n=0;var r=0;e.fn[t]=function(n){if(typeof arguments[0]==="string"){var r=arguments[0];var s=Array.prototype.slice.call(arguments,1);var o;this.each(function(){if(e.data(this,"plugin_"+t)&&typeof e.data(this,"plugin_"+t)[r]==="function"){o=e.data(this,"plugin_"+t)[r].apply(this,s)}else{throw new Error("Method "+r+" does not exist on jQuery."+t)}});if(o!==undefined){return o}else{return this}}else if(typeof n==="object"||!n){return this.each(function(){if(!e.data(this,"plugin_"+t)){e.data(this,"plugin_"+t,new i(this,n))}})}};e.fn[t].defaults={speed:500,beforeInit:function(){},afterInit:function(){},beforeNextPrev:function(){},afterNextPrev:function(){},beforeNext:function(){},afterNext:function(){},beforePrev:function(){},afterPrev:function(){},beforeClose:function(){},afterClose:function(){},onDestroy:function(){}}})(jQuery)