1 2(function($) { 3 4 $(function() { 5 $.yuga.scroll(); 6 }); 7 8 //--------------------------------------------------------------------- 9 10 $.yuga = { 11 // URIãè§£æãããªãã¸ã§ã¯ããè¿ãfunction 12 Uri: function(path){ 13 var self = this; 14 this.originalPath = path; 15 //絶対ãã¹ãåå¾ 16 this.absolutePath = (function(){ 17 var e = document.createElement('span'); 18 e.innerHTML = '<a href="' + path + '" />'; 19 return e.firstChild.href; 20 })(); 21 //絶対ãã¹ãåè§£ 22 var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11}; 23 var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath); 24 for (var field in fields) { 25 this[field] = r[fields[field]]; 26 } 27 this.querys = {}; 28 if(this.query){ 29 $.each(self.query.split('&'), function(){ 30 var a = this.split('='); 31 if (a.length == 2) self.querys[a[0]] = a[1]; 32 }); 33 } 34 }, 35 36 //ãã¼ã¸å ãªã³ã¯ã¯ããããã¹ã¯ãã¼ã« 37 scroll: function(options) { 38 //ããã¥ã¡ã³ãã®ã¹ã¯ãã¼ã«ãå¶å¾¡ãããªãã¸ã§ã¯ã 39 var scroller = (function() { 40 var c = $.extend({ 41 easing:100, 42 step:60, 43 fps:60, 44 fragment:'' 45 }, options); 46 c.ms = Math.floor(1000/c.fps); 47 var timerId; 48 var param = { 49 stepCount:0, 50 startY:0, 51 endY:0, 52 lastY:0 53 }; 54 //ã¹ã¯ãã¼ã«ä¸ã«å®è¡ãããfunction 55 function move() { 56 if (param.stepCount == c.step) { 57 //ã¹ã¯ãã¼ã«çµäºæ 58 setFragment(param.hrefdata.absolutePath); 59 window.scrollTo(getCurrentX(), param.endY); 60 } else if (param.lastY == getCurrentY()) { 61 //é常ã¹ã¯ãã¼ã«æ 62 param.stepCount++; 63 window.scrollTo(getCurrentX(), getEasingY()); 64 param.lastY = getEasingY(); 65 timerId = setTimeout(move, c.ms); 66 } else { 67 //ãã£ã³ã»ã«çºç 68 if (getCurrentY()+getViewportHeight() == getDocumentHeight()) { 69 //ç»é¢ä¸ã®ããã¹ã¯ãã¼ã«çµäº 70 setFragment(param.hrefdata.absolutePath); 71 } 72 } 73 } 74 function setFragment(path){ 75 location.href = path 76 } 77 function getCurrentY() { 78 return document.body.scrollTop || document.documentElement.scrollTop; 79 } 80 function getCurrentX() { 81 return document.body.scrollLeft || document.documentElement.scrollLeft; 82 } 83 function getDocumentHeight(){ 84 return document.documentElement.scrollHeight || document.body.scrollHeight; 85 } 86 function getViewportHeight(){ 87 return (!$.browser.safari && !$.browser.opera) ? document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight : window.innerHeight; 88 } 89 function getEasingY() { 90 return Math.floor(getEasing(param.startY, param.endY, param.stepCount, c.step, c.easing)); 91 } 92 function getEasing(start, end, stepCount, step, easing) { 93 var s = stepCount / step; 94 return (end - start) * (s + easing / (100 * Math.PI) * Math.sin(Math.PI * s)) + start; 95 } 96 return { 97 set: function(options) { 98 this.stop(); 99 if (options.startY == undefined) options.startY = getCurrentY(); 100 param = $.extend(param, options); 101 param.lastY = param.startY; 102 timerId = setTimeout(move, c.ms); 103 }, 104 stop: function(){ 105 clearTimeout(timerId); 106 param.stepCount = 0; 107 } 108 }; 109 })(); 110 $('a[href^="#"], area[href^="#"]').not('a[href="#"], area[href="#"]').each(function(){ 111 this.hrefdata = new $.yuga.Uri(this.getAttribute('href')); 112 }).click(function(){ 113 var target = $('#'+this.hrefdata.fragment); 114 if (target.length == 0) target = $('a[name='+this.hrefdata.fragment+']'); 115 if (target.length) { 116 scroller.set({ 117 endY: target.offset().top, 118 hrefdata: this.hrefdata 119 }); 120 return false; 121 } 122 }); 123 }, 124 125 126 }; 127})(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.