PageSourceSearch

http://www.ndhpolo.com/js/float.js

js ndhpolo.com collected 2026-10-02 23:50:27 UTC 4,613 bytes, 122 lines download raw bytes

1jQuery.fn.float = function(settings) {
2    if (typeof settings == "object") {
3        settings = jQuery.extend({
4            delay: 1000,
5            offset: {
6                left: 5,
7                right: 5,
8                top: 0,
9                bottom: 0
10            },
11            style: null,
12            width: 200,
13            height: 200,
14            position: "rm"
15        },
16        settings || {});
17        var winW = $(window).width();
18        var winH = $(window).height();
19        function getPosition($applyTo, position) {
20            var _pos = null;
21            switch (position) {
22            case "rm":
23                $applyTo.data("offset", "right");
24                $applyTo.data("offsetPostion", settings.offset.right);
25                _pos = {
26                    right: settings.offset.right,
27                    top: winH / 2 - $applyTo.innerHeight() / 2
28                };
29                break;
30            case "lm":
31                $applyTo.data("offset", "left");
32                $applyTo.data("offsetPostion", settings.offset.left);
33                _pos = {
34                    left: settings.offset.left,
35                    top: winH / 2 - $applyTo.innerHeight() / 2
36                };
37                break;
38            case "rb":
39                _pos = {
40                    right: settings.offset.right,
41                    top: winH - $applyTo.innerHeight()
42                };
43                break;
44            case "lb":
45                _pos = {
46                    left: settings.offset.left,
47                    top: winH - $applyTo.innerHeight()
48                };
49                break;
50            case "l":
51                _pos = {
52                    left: settings.offset.left,
53                    top: settings.offset.top
54                };
55                break;
56            case "r":
57                _pos = {
58                    right: settings.offset.right,
59                    top: settings.offset.top
60                };
61                break;
62            case "t":
63                $applyTo.data("offset", "top");
64                $applyTo.data("offsetPostion", settings.offset.top);
65                _pos = {
66                    left: settings.offset.left,
67                    top: settings.offset.top
68                };
69                break;
70            case "b":
71                $applyTo.data("offset", "bottom");
72                $applyTo.data("offsetPostion", settings.offset.bottom);
73                _pos = {
74                    left: settings.offset.left,
75                    top: winH - $applyTo.innerHeight()
76                };
77                break
78            }
79            return _pos
80        }
81        function setPosition($applyTo, position, isUseAnimate) {
82            var scrollTop = $(window).scrollTop();
83            var scrollLeft = $(window).scrollLeft();
84            var _pos = getPosition($applyTo, position);
85            _pos.top += scrollTop;
86            isUseAnimate && $applyTo.stop().animate(_pos, settings.delay) || $applyTo.css(_pos)
87        }
88        return this.each(function() {
89            var $this = $(this);
90            $this.css("position", "absolute");
91            settings.style && $this.css(settings.style);
92            setPosition($this, settings.position);
93            $(this).data("isAllowScroll", true);
94            $(window).scroll(function() {
95                $this.data("isAllowScroll") && setPosition($this, settings.position, true)
96            })
97        })
98    } else {
99        var speed = arguments.length > 1 && arguments[1] || "fast";
100        this.each(function() {
101            if (settings == "clearOffset") {
102                var _c = {};
103                if ($(this).data("offset")) {
104                    _c[$(this).data("offset")] = 0;
105                    $(this).data("isAllowScroll", false);
106                    $(this).stop().animate(_c, speed)
107                }
108            } else if (settings == "addOffset") {
109                var _c = {};
110                if ($(this).data("offset") && $(this).data("offsetPostion")) {
111                    _c[$(this).data("offset")] = $(this).data("offsetPostion");
112                    $(this).stop().animate(_c, speed);
113                    $(this).data("isAllowScroll", true)
114                }
115            } else if (settings == "setScrollDisable") {
116                $(this).data("isAllowScroll", false)
117            } else if (settings == "setScrollUsable") {
118                $(this).data("isAllowScroll", true)
119            }
120        })
121    }
122}

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.