// if we haven't already bound our resize hanlder, bind it now
if( !$.collapsibleTabs.boundEvent ) {
$( window )
- .delayedBind( '500', 'resize', null, function( ) { $.collapsibleTabs.handleResize(); } );
+ .delayedBind( '500', 'resize', function( ) { $.collapsibleTabs.handleResize(); } );
}
// call our resize handler to setup the page
$.collapsibleTabs.handleResize();
* @param callback Function to call
*/
delayedBind: function( timeout, event, data, callback ) {
+ if ( arguments.length == 3 ) {
+ // Shift optional parameter down
+ callback = data;
+ data = undefined;
+ }
var encEvent = encodeEvent( event );
return this.each( function() {
var that = this;
<script src="../../resources/jquery/jquery.byteLength.js"></script>
<script src="../../resources/jquery/jquery.byteLimit.js"></script>
<script src="../../resources/jquery/jquery.colorUtil.js"></script>
+ <script src="../../resources/jquery/jquery.delayedBind.js"></script>
<script src="../../resources/jquery/jquery.getAttrs.js"></script>
<script src="../../resources/jquery/jquery.highlightText.js"></script>
<script src="../../resources/jquery/jquery.localize.js"></script>
<script src="suites/resources/jquery/jquery.byteLength.test.js"></script>
<script src="suites/resources/jquery/jquery.byteLimit.test.js"></script>
<script src="suites/resources/jquery/jquery.colorUtil.test.js"></script>
+ <script src="suites/resources/jquery/jquery.delayedBind.test.js"></script>
<script src="suites/resources/jquery/jquery.getAttrs.test.js"></script>
<script src="suites/resources/jquery/jquery.highlightText.test.js"></script>
<script src="suites/resources/jquery/jquery.localize.test.js"></script>
--- /dev/null
+test('jquery.delayedBind with data option', function() {
+ var $fixture = $('<div>').appendTo('body'),
+ data = { magic: "beeswax" },
+ delay = 50;
+
+ $fixture.delayedBind(delay, 'testevent', data, function(event) {
+ start(); // continue!
+ ok(true, 'testevent fired');
+ ok(event.data === data, 'data is passed through delayedBind');
+ });
+
+ expect(2);
+ stop(); // async!
+
+ // We'll trigger it thrice, but it should only happen once.
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+});
+
+test('jquery.delayedBind without data option', function() {
+ var $fixture = $('<div>').appendTo('body'),
+ data = { magic: "beeswax" },
+ delay = 50;
+
+ $fixture.delayedBind(delay, 'testevent', function(event) {
+ start(); // continue!
+ ok(true, 'testevent fired');
+ });
+
+ expect(1);
+ stop(); // async!
+
+ // We'll trigger it thrice, but it should only happen once.
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+ $fixture.trigger('testevent', {});
+});
+