PageSourceSearch

https://sh-dalian.com/theme/dalianshiyou/style/js/cont.js

js sh-dalian.com collected 2026-10-06 13:16:41 UTC 6,275 bytes, 429 lines download raw bytes

1/*
2
3 * jQuery.appear
4
5 * https://github.com/bas2k/jquery.appear/
6
7 * http://code.google.com/p/jquery-appear/
8
9 *
10
11 * Copyright (c) 2009 Michael Hixson
12
13 * Copyright (c) 2012 Alexander Brovikov
14
15 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
16
17 */
18
19(function($) {
20
21    $.fn.appear = function(fn, options) {
22
23
24
25        var settings = $.extend({
26
27
28
29            //arbitrary data to pass to fn
30
31            data: undefined,
32
33
34
35            //call fn only on the first appear?
36
37            one: true,
38
39
40
41            // X & Y accuracy
42
43            accX: 0,
44
45            accY: 0
46
47
48
49        }, options);
50
51
52
53        return this.each(function() {
54
55
56
57            var t = $(this);
58
59
60
61            //whether the element is currently visible
62
63            t.appeared = false;
64
65
66
67            if (!fn) {
68
69
70
71                //trigger the custom event
72
73                t.trigger('appear', settings.data);
74
75                return;
76
77            }
78
79
80
81            var w = $(window);
82
83
84
85            //fires the appear event when appropriate
86
87            var check = function() {
88
89
90
91                //is the element hidden?
92
93                if (!t.is(':visible')) {
94
95
96
97                    //it became hidden
98
99                    t.appeared = false;
100
101                    return;
102
103                }
104
105
106
107                //is the element inside the visible window?
108
109                var a = w.scrollLeft();
110
111                var b = w.scrollTop();
112
113                var o = t.offset();
114
115                var x = o.left;
116
117                var y = o.top;
118
119
120
121                var ax = settings.accX;
122
123                var ay = settings.accY;
124
125                var th = t.height();
126
127                var wh = w.height();
128
129                var tw = t.width();
130
131                var ww = w.width();
132
133
134
135                if (y + th + ay >= b &&
136
137                    y <= b + wh + ay &&
138
139                    x + tw + ax >= a &&
140
141                    x <= a + ww + ax) {
142
143
144
145                    //trigger the custom event
146
147                    if (!t.appeared) t.trigger('appear', settings.data);
148
149
150
151                } else {
152
153
154
155                    //it scrolled out of view
156
157                    t.appeared = false;
158
159                }
160
161            };
162
163
164
165            //create a modified fn with some additional logic
166
167            var modifiedFn = function() {
168
169
170
171                //mark the element as visible
172
173                t.appeared = true;
174
175
176
177                //is this supposed to happen only once?
178
179                if (settings.one) {
180
181
182
183                    //remove the check
184
185                    w.unbind('scroll', check);
186
187                    var i = $.inArray(check, $.fn.appear.checks);
188
189                    if (i >= 0) $.fn.appear.checks.splice(i, 1);
190
191                }
192
193
194
195                //trigger the original fn
196
197                fn.apply(this, arguments);
198
199            };
200
201
202
203            //bind the modified fn to the element
204
205            if (settings.one) t.one('appear', settings.data, modifiedFn);
206
207            else t.bind('appear', settings.data, modifiedFn);
208
209
210
211            //check whenever the window scrolls
212
213            w.scroll(check);
214
215
216
217            //check whenever the dom changes
218
219            $.fn.appear.checks.push(check);
220
221
222
223            //check now
224
225            (check)();
226
227        });
228
229    };
230
231
232
233    //keep a queue of appearance checks
234
235    $.extend($.fn.appear, {
236
237
238
239        checks: [],
240
241        timeout: null,
242
243
244
245        //process the queue
246
247        checkAll: function() {
248
249            var length = $.fn.appear.checks.length;
250
251            if (length > 0) while (length--) ($.fn.appear.checks[length])();
252
253        },
254
255
256
257        //check the queue asynchronously
258
259        run: function() {
260
261            if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout);
262
263            $.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20);
264
265        }
266
267    });
268
269
270
271    //run checks when these methods are called
272
273    $.each(['append', 'prepend', 'after', 'before', 'attr',
274
275        'removeAttr', 'addClass', 'removeClass', 'toggleClass',
276
277        'remove', 'css', 'show', 'hide'], function(i, n) {
278
279        var old = $.fn[n];
280
281        if (old) {
282
283            $.fn[n] = function() {
284
285                var r = old.apply(this, arguments);
286
287                $.fn.appear.run();
288
289                return r;
290
291            }
292
293        }
294
295    });
296
297
298
299})(jQuery);
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339(function($) {
340
341    $.fn.countTo = function(options) {
342
343        // merge the default plugin settings with the custom options
344
345        options = $.extend({}, $.fn.countTo.defaults, options || {});
346
347
348
349        // how many times to update the value, and how much to increment the value on each update
350
351        var loops = Math.ceil(options.speed / options.refreshInterval),
352
353            increment = (options.to - options.from) / loops;
354
355
356
357        return $(this).each(function() {
358
359            var _this = this,
360
361                loopCount = 0,
362
363                value = options.from,
364
365                interval = setInterval(updateTimer, options.refreshInterval);
366
367
368
369            function updateTimer() {
370
371                value += increment;
372
373                loopCount++;
374
375                $(_this).html(value.toFixed(options.decimals));
376
377
378
379                if (typeof(options.onUpdate) == 'function') {
380
381                    options.onUpdate.call(_this, value);
382
383                }
384
385
386
387                if (loopCount >= loops) {
388
389                    clearInterval(interval);
390
391                    value = options.to;
392
393
394
395                    if (typeof(options.onComplete) == 'function') {
396
397                        options.onComplete.call(_this, value);
398
399                    }
400
401                }
402
403            }
404
405        });
406
407    };
408
409
410
411    $.fn.countTo.defaults = {
412
413        from: 0,  // the number the element should start at
414
415        to: 100,  // the number the element should end at
416
417        speed: 1000,  // how long it should take to count between the target numbers
418
419        refreshInterval: 100,  // how often the element should be updated
420
421        decimals: 0,  // the number of decimal places to show
422
423        onUpdate: null,  // callback method for every time the element is updated,
424
425        onComplete: null,  // callback method for when the element finishes updating
426
427    };
428
429})(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.