Changeset 5527
- Timestamp:
- 05/09/08 03:15:18 (3 days ago)
- Location:
- trunk/plugins/batch
- Files:
-
- 2 modified
-
jquery.batch.js (modified) (3 diffs)
-
test/unit/batch.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/batch/jquery.batch.js
r4158 r5527 1 /* Copyright (c) 2007 Brandon Aaron (http://brandonaaron.net)1 /*! Copyright (c) 2007 Brandon Aaron (http://brandonaaron.net) 2 2 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 3 3 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. … … 6 6 * $Rev$ 7 7 * 8 * Version: @VERSION8 * Version: 1.0 9 9 */ 10 10 (function($){ … … 18 18 }; 19 19 20 $.each( "attr css offset width height html text val".split(" "), function(index, method) { 21 $.fn[method+"s"] = function() { 22 return this.batch.apply( this, [method].concat( $.makeArray(arguments) ) ); 23 }; 24 }); 20 $.batch = { 21 version: "1.0", 22 registerPlugin: function() { 23 $.each( arguments, function( index, plugin ) { 24 var method = plugin.constructor == Array && plugin[0] || plugin, 25 newMethod = plugin.constructor == Array && plugin[1] || plugin+"s"; 26 if ( $.fn[ method ] && !$.fn[ newMethod ] ) 27 $.fn[ newMethod ] = function() { 28 return this.batch.apply( this, [ method ].concat( $.makeArray(arguments) ) ); 29 }; 30 }); 31 } 32 }; 33 34 $.batch.registerPlugin( 'attr', ['css','styles'], 'offset', 'width', 'height', 'html', 'text', 'val' ); 25 35 26 36 })(jQuery); -
trunk/plugins/batch/test/unit/batch.js
r4158 r5527 2 2 3 3 test("batch", function() { 4 $.each( ['attr', 'styles', 'offset', 'width', 'height', 'html', 'text', 'val'], function(index, name) { 5 ok( $.fn[name], "Make sure " + name + " exists" ); 6 }); 7 }); 8 test("attrs", function() { 4 9 isSet( $('input[value=Test]').attrs('value'), ["Test", "Test"], "$('input[value=Test]').attrs('value')" ); 5 10 isSet( $('input[value=Test]').attrs('value', function(){ return 'Updated'; }).attrs('value'), ["Updated", "Updated"], "$('input[value=Test]').attrs('value', function(){ return 'Updated'; })" );