1$(document).ready(function(){ 2 3 //var win_iwidth = $('main').innerWidth(); 4 //var win_iwidth = document.body.clientWidth+16; 5 //if (win_iwidth > 1600) win_iwidth = 1600; 6 var win_iwidth = ($('body.home #slides').width()); 7 8 var timerOuter; 9 function autoSlide() { 10 timerOuter = setInterval(startSlide,10000); 11 } 12 function startSlide() { 13 clickRight(which); 14 } 15 16 if ($('#slides .scroller').length>0 && win_iwidth > 400) { 17 var which = 'container'; 18 var slide = []; 19 var slides = []; 20 var dir = []; 21 autoSlide(which); 22 slide['container'] = 1; 23 slides['container'] = $('div#slides .scroller item').length; 24 $('div#slides .scroller item:last-child').clone().prependTo($('div#slides .scroller')); 25 $('div#slides .scroller item:nth-child(2)').clone().appendTo($('div#slides .scroller')); 26 $('div#slides .scroller').css({'margin-left':-win_iwidth}); 27 slide['container'] = 2; 28 //$('#slides').prepend('<arrow_left></arrow_left>'); 29 //$('#slides').append('<arrow_right></arrow_right>'); 30 31 //$('div#slides .scroller item').append('<a href="javascript://" class="info" title="Details">i</a>'); 32 33 function clickLeft(which) { 34 if (slide[which]>=2) { 35 if (dir[which]=='up') slide[which]-=2; 36 else slide[which]-=1; 37 $('#slides .scroller').stop().animate({'margin-left':-slide[which]*win_iwidth}); 38 } 39 else if (slide[which]==1) { 40 $('#slides .scroller').stop().animate({'margin-left':0+'%'},function(){ 41 $('#slides .scroller').css({'margin-left':-slides[which]*win_iwidth}); 42 slide[which] = slides[which]; 43 }); 44 } 45 dir[which] = 'down'; 46 47 $('#slides .scroller item pic img').each(function(){ 48 $(this).attr('src',$(this).parent().attr('data-src')); 49 }); 50 51 //console.log(slide[which]); 52 53 if (slide[which]==0) { 54 slide[which] = 1; 55 $('#slides .scroller').stop().animate({'margin-left':'0%'}); 56 } 57 58 } 59 function clickRight(which) { 60 if (slide[which]>slides[which]) { 61 $('#slides .scroller').stop().css({'margin-left':'0'}); 62 slide[which] = 2; 63 } 64 if (slide[which]>=1) { 65 if (dir[which]=='down') slide[which]+=1; 66 $('#slides .scroller').stop().animate({'margin-left':-slide[which]*win_iwidth},function(){ 67 if (slide[which]==slides[which]+1) { 68 $('#slides .scroller').css({'margin-left':'0%'}); 69 slide[which] = 1; 70 } 71 }); 72 slide[which]++; 73 } 74 dir[which] = 'up'; 75 76 $('#slides .scroller item pic img').each(function(){ 77 $(this).attr('src',$(this).parent().attr('data-src')); 78 }); 79 80 console.log(slide[which]); 81 82 if (slide[which]==0) { 83 slide[which] = 1; 84 $('#slides .scroller').stop().animate({'margin-left':'0%'}); 85 } 86 } 87 88 if ($('div#slides').length>0) { 89 $("#slides .scroller").swipe({ 90 PreventDefault: true, 91 EnableMouse: true, 92 Distance: 100, 93 OnSwipe: function (detail) { 94 if (detail.direction == 'l') $('arrow_right').click(); 95 else if (detail.direction == 'r') $('arrow_left').click(); 96 97 //console.log("Swipe Details : { direction :" + detail.direction + ", distance : " + detail.distance + ", speed : " + detail.speed + ", time: " + detail.time + "}"); 98 }, 99 //OnEnd: function () { $('footer').hide(); } 100 }); 101 } 102 103 $('div#slides arrow_left').on('click',function(){ 104 clearTimeout(timerOuter); 105 clickLeft(which); 106 }); 107 $('div#slides arrow_right').on('click',function(){ 108 clearTimeout(timerOuter); 109 clickRight(which); 110 }); 111 } 112 113 $('div#slides item pic').each(function(){ 114 $(this).attr('data-src',$(this).find('img').attr('src')); 115 $(this).find('img').attr('data-width',$(this).width()); 116 $(this).find('img').attr('data-height',$(this).height()); 117 }); 118 119 $(document).on( "keydown", function(e) { 120 if (e.which=='37') { 121 $('#slides arrow_left').click(); 122 } 123 if (e.which=='39') { 124 $('#slides arrow_right').click(); 125 } 126 }); 127 128 $.fn.isOnScreen = function(){ 129 var element = this.get(0); 130 var bounds = element.getBoundingClientRect(); 131 return bounds.top < window.innerHeight && bounds.bottom > 0; 132 } 133}); 134 135(function ($) { 136 $.fn.swipe = function (options) { 137 var defaultVal = { 138 PreventDefault: true, 139 EnableMouse: true, 140 TrackMouse: 'click', 141 Distance: 100, 142 OnTouch: function (detail) { }, 143 OnMove: function (detail) { }, 144 OnSwipe: function (detail) { }, 145 OnEnd: function () { } 146 }; 147 148 var obj = $.extend(defaultVal, options); 149 var startTime; 150 var endTime; 151 152 153 return this.each(function () { 154 var selobj = $(this); 155 var curX, curY; 156 var startX, startY; 157 var mdown = false;
158 159 var touchStart = function (event) { 160 if (event.targetTouches.length > 1) { return; } 161 162 startX = event.targetTouches[0].pageX; 163 startY = event.targetTouches[0].pageY; 164 curX = event.targetTouches[0].pageX; 165 curY = event.targetTouches[0].pageY 166 startTime = new Date(); 167 168 obj.OnTouch({ client: { x: event.targetTouches[0].clientX, y: event.targetTouches[0].clientY }, 169 page: { x: event.targetTouches[0].pageX, y: event.targetTouches[0].pageY }, 170 screen: { x: event.targetTouches[0].screenX, y: event.targetTouches[0].screenY } 171 }); 172 }; 173 174 var mouseDown = function (e) { 175 176 mdown = true; 177 startX = e.pageX; 178 startY = e.pageY; 179 curX = e.pageX; 180 curY = e.pageY; 181 startTime = new Date(); 182 obj.OnTouch({ client: { x: e.clientX, y: e.clientY }, 183 page: { x: e.pageX, y: e.pageY }, 184 screen: { x: e.screenX, y: e.screenY } 185 }); 186 187 if (obj.PreventDefault) { 188 e.preventDefault(); 189 } 190 }; 191 192 var mouseMove = function (e) { 193 194 if (mdown) { 195 det = { 196 diffx: e.pageX - curX, 197 diffy: e.pageY - curY, 198 client: { x: e.clientX, y: e.clientY }, 199 page: { x: e.pageX, y: e.pageY }, 200 screen: { x: e.screenX, y: e.screenY } 201 }; 202 obj.OnMove(det); 203 204 curX = e.pageX; 205 curY = e.pageY; 206 } 207 if (obj.PreventDefault) { 208 e.preventDefault(); 209 } 210 }; 211 212 var moveEnd = function (e) { 213 if (mdown) { 214 var x = curX - startX; 215 var y = curY - startY; 216 endTime = Math.abs(new Date() - startTime) / 1000; 217 mdown = false; 218 if (Math.abs(x) >= Math.abs(y)) { 219 if (Math.abs(x) >= obj.Distance) { 220 if (x >= 0) { 221 det = { direction: 'r', distance: Math.abs(x), speed: (Math.abs(x) / endTime), time: endTime }; 222 obj.OnSwipe(det); 223 } 224 else { 225 det = { direction: 'l', distance: Math.abs(x), speed: (Math.abs(x) / endTime), time: endTime }; 226 obj.OnSwipe(det); 227 } 228 } 229 } 230 else { 231 if (Math.abs(y) >= obj.Distance) { 232 if (y >= 0) { 233 det = { direction: 'd', distance: Math.abs(y), speed: (Math.abs(y) / endTime), time: endTime }; 234 obj.OnSwipe(det); 235 } 236 else { 237 det = { direction: 'u', distance: Math.abs(y), speed: (Math.abs(y) / endTime), time: endTime }; 238 obj.OnSwipe(det); 239 } 240 } 241 } 242 } 243 if (obj.PreventDefault) { 244 e.preventDefault(); 245 } 246 obj.OnEnd(); 247 }; 248 249 var touchMove = function (event) { 250 251 if (event.targetTouches.length > 1) { return; } 252 det = { diffx: event.targetTouches[0].pageX - curX, diffy: event.targetTouches[0].pageY - curY, 253 client: { x: event.targetTouches[0].clientX, y: event.targetTouches[0].clientY }, 254 page: { x: event.targetTouches[0].pageX, y: event.targetTouches[0].pageY }, 255 screen: { x: event.targetTouches[0].screenX, y: event.targetTouches[0].screenY }, 256 evt : event 257 }; 258 obj.OnMove(det); 259 260 curX = event.targetTouches[0].pageX; 261 curY = event.targetTouches[0].pageY; 262 263 if (obj.PreventDefault) { 264 event.preventDefault(); 265 } 266 }; 267 268 var touchEnd = function (event) { 269 var x = curX - startX; 270 var y = curY - startY; 271 endTime = Math.abs(new Date() - startTime) / 1000; 272 mdown = false;
273 if (Math.abs(x) >= Math.abs(y)) { 274 if (Math.abs(x) >= obj.Distance) { 275 if (x >= 0) { 276 det = { direction: 'r', distance: Math.abs(x), speed: (Math.abs(x) / endTime), time: endTime }; 277 obj.OnSwipe(det); 278 } 279 else { 280 det = { direction: 'l', distance: Math.abs(x), speed: (Math.abs(x) / endTime), time: endTime }; 281 obj.OnSwipe(det); 282 } 283 } 284 } 285 else { 286 if (Math.abs(y) >= obj.Distance) { 287 if (y >= 0) { 288 det = { direction: 'd', distance: Math.abs(y), speed: (Math.abs(y) / endTime), time: endTime }; 289 obj.OnSwipe(det); 290 } 291 else { 292 det = { direction: 'u', distance: Math.abs(y), speed: (Math.abs(y) / endTime), time: endTime }; 293 obj.OnSwipe(det); 294 } 295 } 296 } 297 obj.OnEnd(); 298 }; 299 var touchCancel = function (event) { }; 300 if (obj.EnableMouse) { 301 if (obj.TrackMouse == 'click') { 302 selobj.mousedown(function (e) { 303 if (!e) { e = window.event; } 304 var kc = (e.keyCode || e.which); 305 if (kc == 1) { 306 mouseDown(e); 307 } 308 }); 309 selobj.mouseup(moveEnd); 310 $("body").mouseup(moveEnd); 311 } else if (obj.TrackMouse == 'hover') { 312 selobj.mouseover(mouseDown); 313 selobj.mouseout(moveEnd); 314 } 315 selobj.mousemove(mouseMove); 316 } 317 318 this.addEventListener("touchstart", touchStart, false); 319 this.addEventListener("touchmove", touchMove, false); 320 this.addEventListener("touchend", touchEnd, false); 321 this.addEventListener("touchcancel", touchCancel, false); 322 }); 323 }; 324})(jQuery);
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.