Index: trunk/phase3/tests/qunit/index.html |
— | — | @@ -62,6 +62,7 @@ |
63 | 63 | <script src="../../resources/jquery/jquery.byteLength.js"></script> |
64 | 64 | <script src="../../resources/jquery/jquery.byteLimit.js"></script> |
65 | 65 | <script src="../../resources/jquery/jquery.colorUtil.js"></script> |
| 66 | + <script src="../../resources/jquery/jquery.delayedBind.js"></script> |
66 | 67 | <script src="../../resources/jquery/jquery.getAttrs.js"></script> |
67 | 68 | <script src="../../resources/jquery/jquery.highlightText.js"></script> |
68 | 69 | <script src="../../resources/jquery/jquery.localize.js"></script> |
— | — | @@ -91,6 +92,7 @@ |
92 | 93 | <script src="suites/resources/jquery/jquery.byteLength.test.js"></script> |
93 | 94 | <script src="suites/resources/jquery/jquery.byteLimit.test.js"></script> |
94 | 95 | <script src="suites/resources/jquery/jquery.colorUtil.test.js"></script> |
| 96 | + <script src="suites/resources/jquery/jquery.delayedBind.test.js"></script> |
95 | 97 | <script src="suites/resources/jquery/jquery.getAttrs.test.js"></script> |
96 | 98 | <script src="suites/resources/jquery/jquery.highlightText.test.js"></script> |
97 | 99 | <script src="suites/resources/jquery/jquery.localize.test.js"></script> |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +test('jquery.delayedBind with data option', function() { |
| 3 | + var $fixture = $('<div>').appendTo('body'), |
| 4 | + data = { magic: "beeswax" }, |
| 5 | + delay = 50; |
| 6 | + |
| 7 | + $fixture.delayedBind(delay, 'testevent', data, function(event) { |
| 8 | + start(); // continue! |
| 9 | + ok(true, 'testevent fired'); |
| 10 | + ok(event.data === data, 'data is passed through delayedBind'); |
| 11 | + }); |
| 12 | + |
| 13 | + expect(2); |
| 14 | + stop(); // async! |
| 15 | + |
| 16 | + // We'll trigger it thrice, but it should only happen once. |
| 17 | + $fixture.trigger('testevent', {}); |
| 18 | + $fixture.trigger('testevent', {}); |
| 19 | + $fixture.trigger('testevent', {}); |
| 20 | + $fixture.trigger('testevent', {}); |
| 21 | +}); |
| 22 | + |
| 23 | +test('jquery.delayedBind without data option', function() { |
| 24 | + var $fixture = $('<div>').appendTo('body'), |
| 25 | + data = { magic: "beeswax" }, |
| 26 | + delay = 50; |
| 27 | + |
| 28 | + $fixture.delayedBind(delay, 'testevent', function(event) { |
| 29 | + start(); // continue! |
| 30 | + ok(true, 'testevent fired'); |
| 31 | + }); |
| 32 | + |
| 33 | + expect(1); |
| 34 | + stop(); // async! |
| 35 | + |
| 36 | + // We'll trigger it thrice, but it should only happen once. |
| 37 | + $fixture.trigger('testevent', {}); |
| 38 | + $fixture.trigger('testevent', {}); |
| 39 | + $fixture.trigger('testevent', {}); |
| 40 | + $fixture.trigger('testevent', {}); |
| 41 | +}); |
| 42 | + |
Property changes on: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.delayedBind.test.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 43 | + native |
Index: trunk/phase3/resources/jquery/jquery.collapsibleTabs.js |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | // if we haven't already bound our resize hanlder, bind it now |
26 | 26 | if( !$.collapsibleTabs.boundEvent ) { |
27 | 27 | $( window ) |
28 | | - .delayedBind( '500', 'resize', null, function( ) { $.collapsibleTabs.handleResize(); } ); |
| 28 | + .delayedBind( '500', 'resize', function( ) { $.collapsibleTabs.handleResize(); } ); |
29 | 29 | } |
30 | 30 | // call our resize handler to setup the page |
31 | 31 | $.collapsibleTabs.handleResize(); |
Index: trunk/phase3/resources/jquery/jquery.delayedBind.js |
— | — | @@ -19,6 +19,11 @@ |
20 | 20 | * @param callback Function to call |
21 | 21 | */ |
22 | 22 | delayedBind: function( timeout, event, data, callback ) { |
| 23 | + if ( arguments.length == 3 ) { |
| 24 | + // Shift optional parameter down |
| 25 | + callback = data; |
| 26 | + data = undefined; |
| 27 | + } |
23 | 28 | var encEvent = encodeEvent( event ); |
24 | 29 | return this.each( function() { |
25 | 30 | var that = this; |