PageSourceSearch

https://www.aec-inc.jp/js/jquery.page-scroller.js

js aec-inc.jp collected 2026-10-08 01:15:52 UTC 8,419 bytes, 178 lines download raw bytes

1/*  ================================================================================
2 *
3 *  jQuery Page Scroller -version 3.0.9
4 *  http://coliss.com/articles/build-websites/operation/javascript/296.html
5 *  (c)2011 coliss.com
6 *
7 *  この作品は、クリエイティブ・コモンズの表示 2.1 日本ライセンスの下で
8 *  ライセンスされています。
9 *  この使用許諾条件を見るには、http://creativecommons.org/licenses/by-sa/2.1/jp/を
10 *  チェックするか、クリエイティブ・コモンズに郵便にてお問い合わせください。
11 *  住所は:559 Nathan Abbott Way, Stanford, California 94305, USA です。
12 *
13================================================================================  */
14
15
16/*  ================================================================================
17TOC
18============================================================
19Ooption
20Page Scroller
21============================================================
22this script requires jQuery 1.3-1.4.4(http://jquery.com/)
23================================================================================  */
24
25
26/*  ================================================================================
27Ooption
28================================================================================  */
29var virtualTopId = "top",
30    virtualTop,
31    adjTraverser,
32    adjPosition,
33    callExternal = "pSc",
34    delayExternal= 200,
35    adjSpeed = 1;
36
37/* option example
38======================================================================  */
39//  virtualTop = 0;    // virtual top's left position = 0
40//  virtualTop = 1;    // virtual top's left position = vertical movement
41//  adjTraverser = 0;  // left position = 0
42//  adjTraverser = 1;  // horizontal movement.
43//  adjPosition = -26;
44
45/*  ================================================================================
46Page Scroller
47================================================================================  */
48var $ = jQuery.noConflict();
49(function($) {
50    var height = $.fn.height,
51        width = $.fn.width,
52        left = $.fn.left,
53        top = $.fn.top;
54    $.fn.extend({
55        width: function() {
56            if (!this[0]) error();
57            if (this[0] == window) return self.innerWidth || $.boxModel && document.documentElement.clientWidth || document.body.clientWidth;
58            if (this[0] == document) return ((document.documentElement && document.compatMode == "CSS1Compat") ? document.documentElement.scrollWidth : document.body.scrollWidth);
59            return width.apply(this, arguments)
60        },
61        height: function() {
62            //if (!this[0]) error();
63            if (this[0] == window) return self.innerHeight || $.boxModel && document.documentElement.clientHeight || document.body.clientHeight;
64            if (this[0] == document) return ((document.documentElement && document.compatMode == "CSS1Compat") ? document.documentElement.scrollHeight : document.body.scrollHeight);
65            return height.apply(this, arguments)
66        },
67        left: function() {
68            if (!this[0]) return true;
69            var obj = document.getElementById ? document.getElementById(this[0].id) : document.all(this[0].id);
70            var tagCoords = new Object();
71            tagCoords.x = obj.offsetLeft;
72            while ((obj = obj.offsetParent) != null) {
73                tagCoords.x += obj.offsetLeft
74            }
75            if ((tagCoords.x * 0) == 0) return (tagCoords.x);
76            else return (this[0].id)
77        },
78        top: function() {
79            if (!this[0]) return true;
80            var obj = document.getElementById ? document.getElementById(this[0].id) : document.all(this[0].id);
81            var tagCoords = new Object();
82            tagCoords.y = obj.offsetTop;
83            while ((obj = obj.offsetParent) != null) {
84                tagCoords.y += obj.offsetTop
85            }
86            if ((tagCoords.y * 0) == 0) return (tagCoords.y);
87            else return (this[0].id)
88        }
89    })
90})(jQuery);
91$(function() {
92    $('a[href^="#"], area[href^="#"]').not('.nopscr a[href^="#"], a[href^="#"].nopscr').click(function() {
93        var usrUrl = location.hostname + location.pathname;
94        var anchorPath = ((this.href).substring(0, (((this.href).length) - ((this.hash).length)))).slice((this.href).indexOf("//") + 2);
95        if (usrUrl.lastIndexOf("?") != -1) usrUrlOmitQ = usrUrl.slice(0, (usrUrl.lastIndexOf("?")));
96        else usrUrlOmitQ = usrUrl; if (anchorPath.lastIndexOf("?") != -1) anchorPathOmitQ = anchorPath.slice(0, (anchorPath.lastIndexOf("?")));
97        else anchorPathOmitQ = anchorPath; if (anchorPathOmitQ == usrUrlOmitQ) {
98            coliss.toAnchor((this.hash).substr(1));
99            return false
100        }
101    });
102    $("body").click(function() {
103        coliss.stopScroll()
104    })
105});
106this.pageScrollTimer = null;
107var coliss = {
108    getScrollRange: function(type) {
109        if (type == "x") return (($(document).width()) - ($(window).width()));
110        else if (type == "y") return (($(document).height()) - ($(window).height()))
111    },
112    getWindowOffset: function(type) {
113        if (type == "x") return (window.pageXOffset || document.body.scrollLeft || document.body.parentNode.scrollLeft);
114        else if (type == "y") return (window.pageYOffset || document.body.scrollTop || document.body.parentNode.scrollTop)
115    },
116    pageScroll: function(toX, toY, frms, frX, frY) {
117        var pageScrollTimer;
118        if (pageScrollTimer) clearTimeout(pageScrollTimer);
119        var spd = 16 * adjSpeed;
120        var actX = coliss.getWindowOffset('x');
121        var actY = coliss.getWindowOffset('y');
122        if (!toX || toX < 0) toX = 0;
123        if (!toY || toY < 0) toY = 0;
124        if (!frms) frms = $.browser.mozilla ? 10 : $.browser.opera ? 8 : 9;
125        if (!frX) frX = 0 + actX;
126        if (!frY) frY = 0 + actY;
127        frX += (toX - actX) / frms;
128        if (frX < 0) frX = 0;
129        frY += (toY - actY) / frms;
130        if (frY < 0) frY = 0;
131        var posX = Math.ceil(frX);
132        var posY = Math.ceil(frY);
133        window.scrollTo(posX, posY);
134        if ((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY - toY)) < 1)) {
135            clearTimeout(this.pageScrollTimer);
136            window.scroll(toX, toY)
137        } else if ((posX != toX) || (posY != toY)) this.pageScrollTimer = setTimeout("coliss.pageScroll(" + toX + "," + toY + "," + frms + "," + frX + "," + frY + ")", spd);
138        else clearTimeout(this.pageScrollTimer)
139    },
140    stopScroll: function() {
141        clearTimeout(this.pageScrollTimer)
142    },
143    cancelScroll: function(e) {
144        coliss.stopScroll()
145    },
146    toAnchor: function(idName) {
147        coliss.stopScroll();
148        var anchorX, anchorY;
149        if (!!idName) {
150            if (idName == virtualTopId) {
151                anchorX = (virtualTop == 0) ? 0 : (virtualTop == 1) ? window.pageXOffset || document.body.scrollLeft || document.body.parentNode.scrollLeft : $('#' + idName).left();
152                anchorY = ((virtualTop == 0) || (virtualTop == 1)) ? 0 : $('#' + idName).top()
153            } else {
154                anchorX = (adjTraverser == 0) ? 0 : (adjTraverser == 1) ? ($('#' + idName).left()) : window.pageXOffset || document.body.scrollLeft || document.body.parentNode.scrollLeft;
155                anchorY = adjPosition ? ($('#' + idName).top()) + adjPosition : ($('#' + idName).top())
156            }
157            var dMaxX = coliss.getScrollRange('x');
158            var dMaxY = coliss.getScrollRange('y');
159            if (((anchorX * 0) == 0) || ((anchorY * 0) == 0)) {
160                var setX = (anchorX < 1) ? 0 : (anchorX > dMaxX) ? dMaxX : anchorX;
161                var setY = (anchorY < 1) ? 0 : (anchorY > dMaxY) ? dMaxY : anchorY;
162                coliss.pageScroll(setX, setY)
163            } else location.hash = idName
164        } else coliss.pageScroll(0, 0)
165    },
166    initPageScroller: function() {
167        var usrUrl = location.href;
168        var checkAnchor = usrUrl.indexOf("#", 0);
169        var checkPageScroller = usrUrl.match(callExternal);
170        if (!!checkPageScroller) {
171            anchorId = usrUrl.slice(usrUrl.lastIndexOf("?" + callExternal) + 4, usrUrl.length);
172            timerID = setTimeout("coliss.toAnchor(anchorId)", delayExternal)
173        }
174        if (!checkAnchor) window.scroll(0, 0);
175        else return true
176    }
177};
178$(coliss.initPageScroller);

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.