1// wppa-touch.js 2// 3// Contains swipe modules 4// Dependancies: wppa.js and default wp jQuery library 5// 6var wppaJsTouchVersion = '8.5.01.008'; 7 8function wppaStartTime() { 9 var d = new Date(); 10 var t = d.getTime(); 11 wppaMobileTimeStart = t; 12 return true; 13} 14 15function wppaInTime() { 16 var d = new Date(); 17 var t = d.getTime(); 18 // Return true if no later than 500 msec after wppaStartTime(); 19 return ( t - wppaMobileTimeStart ) < 250; 20} 21 22function wppaTapLink( id, url ) { 23 if ( wppaInTime() ) { 24 _bumpClickCount( id ); 25 document.location.href = url; 26 } 27} 28 29function wppaTouchStart( event, id, mocc ) { 30 31 wppaSwipeMocc = mocc; 32 33 if ( mocc == -1 ) { 34 wppaSwipeOnLightbox = true; 35 event.preventDefault(); 36 } 37 38 wppaFingerCount = event.touches.length; 39 40 if ( wppaFingerCount == 1 ) { 41 wppaStartX = event.touches[0].pageX; 42 wppaStartY = event.touches[0].pageY; 43 wppaTriggerElementID = id; 44 } else { 45 wppaTouchCancel(); 46 } 47} 48 49function wppaTouchMove( event ) { 50 51 if ( wppaSwipeOnLightbox ) { 52 event.preventDefault(); 53 } 54 55 if ( event.touches.length == 1 ) { 56 wppaCurX = event.touches[0].pageX; 57 wppaCurY = event.touches[0].pageY; 58 } else { 59 wppaTouchCancel(); 60 } 61} 62 63function wppaTouchEnd( event ) { 64 65 if ( wppaSwipeOnLightbox ) { 66 event.preventDefault(); 67 } 68 69 if ( wppaFingerCount == 1 && wppaCurX != 0 ) { 70 wppaSwipeLength = Math.round( Math.sqrt( Math.pow( wppaCurX - wppaStartX,2 ) + Math.pow( wppaCurY - wppaStartY,2 ) ) ); 71 if ( wppaSwipeLength >= wppaMinLength ) { 72 wppaCalculateAngle(); 73 wppaDetermineSwipeDirection(); 74 wppaProcessingRoutine(); 75 } 76 } 77 wppaTouchCancel(); 78} 79 80function wppaTouchCancel() { 81 wppaFingerCount = 0; 82 wppaStartX = 0; 83 wppaStartY = 0; 84 wppaCurX = 0; 85 wppaCurY = 0; 86 wppaDeltaX = 0; 87 wppaDeltaY = 0; 88 wppaHorzDiff = 0; 89 wppaVertDiff = 0; 90 wppaSwipeLength = 0; 91 wppaSwipeAngle = null; 92 wppaSwipeDirection = null; 93 wppaTriggerElementID = null; 94 wppaSwipeOnLightbox = false; 95 wppaSwipeMocc = 0; 96} 97 98function wppaCalculateAngle() { 99 100 var X = wppaStartX-wppaCurX; 101 var Y = wppaCurY-wppaStartY; 102 var Z = Math.round( Math.sqrt( Math.pow( X,2 )+Math.pow( Y,2 ) ) ); //the distance - rounded - in pixels 103 var r = Math.atan2( Y,X ); //angle in radians ( Cartesian system ) 104 105 wppaSwipeAngle = Math.round( r*180/Math.PI ); //angle in degrees 106 107 if ( wppaSwipeAngle < 0 ) { 108 wppaSwipeAngle = 360 - Math.abs( wppaSwipeAngle ); 109 } 110} 111 112function wppaDetermineSwipeDirection() { 113 114 if ( ( wppaSwipeAngle <= 45 ) && ( wppaSwipeAngle >= 0 ) ) { 115 wppaSwipeDirection = 'left'; 116 } 117 else if ( ( wppaSwipeAngle <= 360 ) && ( wppaSwipeAngle >= 315 ) ) { 118 wppaSwipeDirection = 'left'; 119 } 120 else if ( ( wppaSwipeAngle >= 135 ) && ( wppaSwipeAngle <= 225 ) ) { 121 wppaSwipeDirection = 'right'; 122 } 123 else if ( ( wppaSwipeAngle > 45 ) && ( wppaSwipeAngle < 135 ) ) { 124 wppaSwipeDirection = 'down'; 125 } 126 else { 127 wppaSwipeDirection = 'up'; 128 } 129} 130 131function wppaProcessingRoutine() { 132 133 var swipedElement = document.getElementById( wppaTriggerElementID ); 134 135 // swipe on ligtbox image 136 if ( wppaSwipeOnLightbox ) { 137 if ( wppaSwipeDirection == 'left' ) { 138 wppaOvlShowNext(); 139 } 140 else if ( wppaSwipeDirection == 'right' ) { 141 wppaOvlShowPrev(); 142 } 143 } 144 145 // swipe on slideshow 146 else { 147 if ( wppaSwipeDirection == 'right' ) { 148 idx = _wppaCurIdx[wppaSwipeMocc] - 1; 149 if ( idx < 0 ) { 150 if ( ! wppaSlideWrap ) { 151 return; 152 } 153 idx = _wppaSlides[wppaSwipeMocc].length - 1; 154 } 155 wppaGotoKeepState( wppaSwipeMocc , idx ); 156 } 157 if ( wppaSwipeDirection == 'left' ) { 158 idx = _wppaCurIdx[wppaSwipeMocc] + 1; 159 if ( idx == _wppaSlides[wppaSwipeMocc].length ) { 160 if ( ! wppaSlideWrap ) { 161 return; 162 } 163 idx = 0; 164 } 165 wppaGotoKeepState( wppaSwipeMocc , idx ); 166 } 167 else if ( wppaSwipeDirection == 'up' ) { 168 } 169 else if ( wppaSwipeDirection == 'down' ) { 170 } 171 } 172 173 wppaTouchCancel(); // Reset 174}
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.