From 13057aa4162869b6b9424243967fa7a3b1fef5ec Mon Sep 17 00:00:00 2001 From: Jon Tascher Date: Tue, 23 Apr 2013 18:45:49 -0400 Subject: [PATCH] fixes library in jquery noConflict mode --- examples/simple-noconflict.html | 99 +++++++++++++++++++++++++++++++++ src/jquery.counter.js | 6 +- 2 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 examples/simple-noconflict.html diff --git a/examples/simple-noconflict.html b/examples/simple-noconflict.html new file mode 100644 index 0000000..aba6901 --- /dev/null +++ b/examples/simple-noconflict.html @@ -0,0 +1,99 @@ + + + + + + sophilabs/jquery-counter + + + + + + + + + +

Examples

+

+ 0:10 +

+
+    <span class="counter counter-analog" data-direction="down">0:10</span>
+    <script>
+    $('.counter').counter({});
+    </script>
+    
+

+ 20.00:00:00 +

+
+    <span class="counter counter-analog" data-direction="down" data-format="20.23:59:59">20.00:00:00</span>
+    <script>
+    $('.counter').counter({});
+    </script>
+    
+

+ 0 +

+
+    <span class="counter counter-analog" data-direction="up" data-interval="1" data-format="9999" data-stop="2012">0</span>
+    <script>
+    $('.counter').counter({});
+    </script>
+    
+

+ 0 +

+
+    <span class="counter counter-analog" data-direction="up" data-format="1 1 1 1 1 1 1 1" data-stop="0 0 1 0 0 0 0 0" data-interval="100">0</span>
+    <script>
+    $('.counter').counter({});
+    </script>
+    
+

Style counter-analog2

+

+ 0:00.0 +

+
+    <span class="counter counter-analog2" data-direction="up" data-format="23:59:59.9" data-stop="00:00:10.0" data-interval="100">0:00.0</span>
+    <script>
+    $('.counter').counter({});
+    </script>
+    
+

Full Javascript Initialization

+

+ +

+        <span id="custom"></span>
+        <script>
+        $('#custom').addClass('counter-analog').counter({
+            initial: '0:00.0',
+            direction: 'up',
+            interval: '1',
+            format: '9999',
+            stop: '2012'
+        });
+        </script>
+        
+

+

Event counterStop

+
+    <script>
+    $('.counter').on('counterStop', function() {
+        //code
+    });
+    </script>
+    
+ + + diff --git a/src/jquery.counter.js b/src/jquery.counter.js index 71a14cf..cb25d6d 100644 --- a/src/jquery.counter.js +++ b/src/jquery.counter.js @@ -5,9 +5,9 @@ * MIT License */ -!(function (context, definition) { +!(function (context, definition, $) { if (typeof define == 'function' && typeof define.amd == 'object') define(['jquery'], definition); - else definition(context['$']); + else definition($); }(this, function ($) { var checkStop = function(data) { @@ -239,4 +239,4 @@ } }; -})); +}, jQuery));