1$.easing.easeOut = function(n,e,t,a,i) { 2 return-a*((e=e/i-1)*e*e*e-1)+t 3}; 4$.widget("ui.mobileSlides", { 5 _create: function() { 6 7 var self = this; 8 9 self.currentIndex = 0; 10 self.slides = this.element.find(".items:first > .mobile-section"); 11 self.indicatorPanel = this.element.find("#page-indicators"); 12 13 self.slides.each(function(index) { 14 var li = $("<span><span></span></span>").appendTo(self.indicatorPanel); 15 if(index == 0) li.addClass("active"); 16 17 li.click(function() { 18 self.goToSlideIndex(index); 19 }); 20 21 var slide = $(this) 22 23 slide.css({ 24 display: 'block', 25 left: index*100+'%' 26 }); 27 28 slide.find(".scroller").scroller({ 29 axis: 'y', 30 autostartTouch: false, 31 mouseDrag: true 32 }); 33 34 }); 35 36 var frameDummy = self.element.find(".frame:first"); 37 var centeredItems = self.element.find(".frame > .centered"); 38 39 $(window).resize(function() { 40 41 centeredItems.each(function() { 42 43 $(this).css({ 44 lineHeight: frameDummy.height()+'px' 45 }); 46 47 }); 48 49 }).resize(); 50 51 // Slide events 52 self.slider = this.element.find(".items:first"); 53 var touchTimer; 54 var speedThreshold = 0.01; 55 var touchStartX = 0, touchStartY = 0, touching = false, lastTouchX = 0, touchOffset = 0, touchVelocity = 0, dragAxis = 0; 56 var currentScroller = null; 57 self.element.bind("touchstart mousedown", function(e) { 58 59 var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e; 60 clearTimeout(touchTimer); 61 e.stopPropagation(); 62 self.slider.stop() 63 dragAxis = 0; 64 touchStartX = data.pageX; 65 touchStartY = data.pageY; 66 touchOffset = 0; 67 touching = true; 68 69 var scroller = self.slides.eq(self.currentIndex).find(".scroller"); 70 if(scroller.size()) { 71 currentScroller = scroller.data("scroller"); 72 } else { 73 currentScroller = null; 74 } 75 76 }).bind("touchend touchcancel touchleave mouseup", function(e) { 77 clearTimeout(touchTimer); 78 self.slider.stop(); 79 touching = false; 80 if(dragAxis == 1) { 81 var wWidth = $(window).width(); 82 if((touchOffset > 0 && touchOffset > wWidth * 0.2) || (touchVelocity/wWidth) < -speedThreshold) { 83 self.goToSlideIndex(self.currentIndex - 1, (touchVelocity/wWidth) * 4); 84 } else if((touchOffset < 0 && touchOffset < -wWidth * 0.2) || (touchVelocity/wWidth) > speedThreshold) { 85 self.goToSlideIndex(self.currentIndex + 1, (touchVelocity/wWidth) * 4); 86 } else { 87 self.goToSlideIndex(self.currentIndex); 88 } 89 } else if(dragAxis == 2) { 90 91 } 92 }).bind("touchmove mousemove", function(e) { 93 if(!touching) return; 94 var data = e.originalEvent.touches ? e.originalEvent.touches[0] : e; 95 if(dragAxis == 0) { 96 var xDist = Math.abs(touchStartX - data.pageX); 97 var yDist = Math.abs(touchStartY - data.pageY); 98 if(xDist > 10) { 99 touchStartX = data.pageX; 100 dragAxis = 1; 101 } else if(yDist > 10) { 102 dragAxis = 2; 103 } 104 if(dragAxis == 2 && currentScroller) { 105 currentScroller.startTouch(e); 106 } else { 107 e.preventDefault(); 108 e.stopPropagation(); 109 } 110 } else if(dragAxis == 1) { 111 self.slider.stop(); 112 touchOffset = data.pageX - touchStartX; 113 touchVelocity = lastTouchX - data.pageX; 114 lastTouchX = data.pageX; 115 self.slider.css('margin-left', touchOffset); 116 clearTimeout(touchTimer); 117 touchTimer = setTimeout(function() { 118 touchVelocity = 0 119 }, 100); 120 e.preventDefault(); 121 e.stopPropagation(); 122 } 123 }); 124 125 self.element.find(".mobile-home .details a").click(function(e) { 126 self.goToSlideIndex(1); 127 }); 128 129 }, 130 goToSlideIndex: function(index, speed) { 131 132 if(speed === undefined) { 133 speed = 0; 134 } 135 136 var self = this; 137 138 if(index < 0) index = 0; 139 if(index > self.slides.length - 1) index = self.slides.length - 1; 140 141 self.currentIndex = index; 142 143 self.indicatorPanel.children("span").removeClass("active").eq(index).addClass("active"); 144 145 self.slider.css({ 146 left: self.slider.position().left + parseInt(self.slider[0].style.marginLeft), 147 marginLeft: 0 148 }).animate({ 149 left: -$(window).width() * index 150 }, { 151 duration: 500 - (speed * 300), 152 easing: 'easeOut', 153 complete: function() { 154 self.slider.css({ 155 left: -index*100+'%' 156 }); 157 } 158 }); 159 160 self.element.css('backgroundColor', self.slides.eq(index).css('backgroundColor')); 161 162 } 163});
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.