1var PageFlipper = { 2 wrapper: null, 3 contentWrapper: null, 4 imageWrapper: null, 5 6 nextButton: null, 7 prevButton: null, 8 9 storyCount: null, 10 currentStory: 0, 11 12 animating: false, 13 animationTotalTime: 500, 14 15 init: function(){ 16 this.wrapper = $('.success-stories2'); 17 this.contentWrapper = this.wrapper.find(".story-content"); 18 this.imageWrapper = this.wrapper.find(".story-image"); 19 20 this.nextButton = this.wrapper.find(".story-next"); 21 this.prevButton = this.wrapper.find(".story-prev"); 22 23 this.storyCount = this.imageWrapper.children().length; 24 25 this.setWrapperHeight(); 26 27 this.prevButton.on("click", function(e){ 28 e.preventDefault(); 29 if( !this.animating ){ 30 PageFlipper.prevPage(); 31 } 32 }); 33 34 this.nextButton.on("click", function(e){ 35 e.preventDefault(); 36 if( !this.animating ){ 37 PageFlipper.nextPage(); 38 } 39 }); 40 }, 41 42 nextPage: function(){ 43 var that = this; 44 this.animating = true; 45 46 var nextImage = this.imageWrapper.children().eq(this.currentStory+1); 47 var curContent = this.contentWrapper.children().eq(this.currentStory); 48 49 curContent.removeClass("active"); 50 51 setTimeout(function(){ 52 nextImage.addClass("active"); 53 54 that.animating = false; 55 }, this.animationTotalTime/2); 56 57 if( that.currentStory < that.storyCount ){ 58 that.currentStory++; 59 } 60 61 if( that.currentStory == that.storyCount - 1 ){ 62 that.nextButton.removeClass("active"); 63 } 64 65 if( that.currentStory === 1 ){ 66 that.prevButton.addClass("active"); 67 } 68 69 }, 70 71 prevPage: function(){ 72 var that = this; 73 this.animating = true; 74 75 var curImage = this.imageWrapper.children().eq(this.currentStory); 76 var nextContent = this.contentWrapper.children().eq(this.currentStory-1); 77 78 curImage.removeClass('active'); 79 80 setTimeout(function(){ 81 nextContent.addClass("active"); 82 83 that.animating = false; 84 }, this.animationTotalTime/2); 85 86 if( that.currentStory > 0 ){ 87 that.currentStory--; 88 } 89 90 if( that.currentStory === that.storyCount - 2 ){ 91 that.nextButton.addClass("active"); 92 } 93 94 if( that.currentStory === 0 ){ 95 that.prevButton.removeClass("active"); 96 } 97 }, 98 99 setWrapperHeight: function(){ 100 if( this.storyCount ){ 101 var that = this; 102 this.contentWrapper.css("height", "auto"); 103 var children = this.contentWrapper.children(); 104 children.addClass("height-test"); 105 var count = children.length; 106 var maxHeight = 0; 107 108 children.each(function(){ 109 var h = Math.floor($(this).outerHeight()); 110 if( h > maxHeight ){ 111 maxHeight = h; 112 } 113 114 if(!--count){ 115 children.removeClass("height-test"); 116 that.contentWrapper.css("height", maxHeight + "px"); 117 } 118 }) 119 } 120 } 121} 122 123 124$(document).ready(function(){ 125 if( $(".success-stories2").length > 0 ){ 126 PageFlipper.init(); 127 } 128}); 129
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.