|
4 | 4 | * Copyright (c) 2012 Sophilabs <contact@sophilabs.com>
|
5 | 5 | * MIT License
|
6 | 6 | */
|
| 7 | + |
| 8 | +!(function (context, definition) { |
| 9 | + if (typeof define == 'function' && typeof define.amd == 'object') define(['jquery'], definition); |
| 10 | + else definition(context['$']); |
| 11 | +}(this, function ($) { |
7 | 12 |
|
8 |
| -(function($){ |
9 | 13 | $.fn.counter = function(options) {
|
10 | 14 |
|
11 | 15 | options = options || {};
|
|
29 | 33 | part.value += data.down ? -1 : 1;
|
30 | 34 | if (data.down && part.value < 0) {
|
31 | 35 | part.value = part.limit;
|
32 |
| - } else if (!data.down && part.value > part.limit) { |
33 |
| - part.value = 0; |
| 36 | + } else if (!data.down && part.value > part.limit) { |
| 37 | + part.value = 0; |
34 | 38 | } else {
|
35 | 39 | break;
|
36 | 40 | }
|
|
53 | 57 | digits = '0' + digits;
|
54 | 58 | }
|
55 | 59 | $.each(digits.split(''), function(j, digit) {
|
56 |
| - animate(e, i, j, digit) |
| 60 | + animate(e, i, j, digit); |
57 | 61 | });
|
58 | 62 | i--;
|
59 | 63 | }
|
60 | 64 | };
|
61 | 65 |
|
62 | 66 | var animate = function(e, ipart, idigit, digit) {
|
63 |
| - var edigit = $($(e.children().get(ipart)).find('span.digit').get(idigit)); |
| 67 | + var edigit = $($(e.children('span.part').get(ipart)).find('span.digit').get(idigit)); |
64 | 68 | edigit.attr('class', 'digit digit' + digit + ' digit' + edigit.text() + digit).text(digit);
|
65 | 69 | };
|
66 | 70 |
|
|
72 | 76 | data.parts = [];
|
73 | 77 | var initial = (options.initial || e.text()).split(/([^0-9]+)/);
|
74 | 78 | //WARN: Use attr() no data()
|
75 |
| - var format = (options.format || e.attr('data-format') ||"23:59:59").split(/([^0-9]+)/); |
| 79 | + var format = (options.format || e.attr('data-format') || "23:59:59").split(/([^0-9]+)/); |
76 | 80 | var stop = options.stop || e.attr('data-stop');
|
77 | 81 | if (stop) {
|
78 | 82 | stop = stop.split(/([^0-9]+)/);
|
|
112 | 116 | return this;
|
113 | 117 | });
|
114 | 118 | };
|
115 |
| -})(jQuery); |
| 119 | +})); |
0 commit comments