Changeset 4707
- Timestamp:
- 02/10/08 15:02:03 (1 year ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
plugins/accordion/demo/index.html (modified) (3 diffs)
-
plugins/accordion/jquery.accordion.js (modified) (6 diffs)
-
plugins/accordion/test/test.js (modified) (2 diffs)
-
plugins/accordion/test/testrunner.js (modified) (6 diffs)
-
ui/ui.accordion.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/accordion/demo/index.html
r4655 r4707 39 39 animated: "bounceslide", 40 40 header: "dt" 41 }).bind("change d.ui-accordion", function(event, newHeader, oldHeader, newContent, oldContent) {42 jQuery('<div>' + oldHeader.text() + ' hidden, ' +newHeader.text() + ' shown</div>').appendTo('#log');41 }).bind("change.ui-accordion", function(event, ui) { 42 jQuery('<div>' + ui.oldHeader.text() + ' hidden, ' + ui.newHeader.text() + ' shown</div>').appendTo('#log'); 43 43 }); 44 44 … … 246 246 animated: "bounceslide", 247 247 header: "dt" 248 }).bind("change d.ui-accordion", function(event, newHeader, oldHeader, newContent, oldContent) {249 jQuery(' <div>' + oldHeader.text() + ' hidden, ' + newHeader.text() + ' shown</div>').appendTo('#log');248 }).bind("change.ui-accordion", function(event, ui) { 249 jQuery('<div>' + ui.oldHeader.text() + ' hidden, ' + ui.newHeader.text() + ' shown</div>').appendTo('#log'); 250 250 });</code></pre> 251 251 … … 374 374 </div> 375 375 376 <div id="log"><div><strong>Log of the 2nd accordion</strong></div></div>376 <div id="log"><div><strong>Log</strong></div></div> 377 377 </div> 378 378 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> -
trunk/plugins/accordion/jquery.accordion.js
r4655 r4707 1 1 /* 2 * jQuery UI Accordion 1. 12 * jQuery UI Accordion 1.5 3 3 * 4 4 * Copyright (c) 2007 Jörn Zaefferer … … 108 108 } 109 109 $.removeData(this.element, "ui-accordion"); 110 $(this.element). unbind(".ui-accordion");110 $(this.element).removeClass("ui-accordion").unbind(".ui-accordion"); 111 111 } 112 112 } … … 122 122 if (!$.data(this, "ui-accordion")) 123 123 return; 124 var options = $.data(this, "ui-accordion").options; 124 var instance = $.data(this, "ui-accordion"); 125 var options = instance.options; 125 126 options.running = cancel ? 0 : --options.running; 126 127 if ( options.running ) … … 132 133 }); 133 134 } 134 $(this).trigger ("changed.ui-accordion", options.data);135 $(this).triggerHandler("change.ui-accordion", [options.data], options.change); 135 136 } 136 137 … … 182 183 if ( !event.target && !options.alwaysOpen ) { 183 184 options.active.parent().andSelf().toggleClass(options.selectedClass); 184 var toHide = options.active.next(); 185 var toShow = options.active = $([]); 186 toggle.call(this, toShow, toHide ); 185 var toHide = options.active.next(), 186 data = { 187 instance: this, 188 options: options, 189 newHeader: jQuery([]), 190 oldHeader: options.active, 191 newContent: jQuery([]), 192 oldContent: toHide 193 }, 194 toShow = options.active = $([]); 195 toggle.call(this, toShow, toHide, data ); 187 196 return false; 188 197 } … … 213 222 var toShow = clicked.next(), 214 223 toHide = options.active.next(), 215 data = [clicked, options.active, toShow, toHide], 224 //data = [clicked, options.active, toShow, toHide], 225 data = { 226 instance: this, 227 options: options, 228 newHeader: clicked, 229 oldHeader: options.active, 230 newContent: toShow, 231 oldContent: toHide 232 }, 216 233 down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); 217 234 -
trunk/plugins/accordion/test/test.js
r4523 r4707 13 13 14 14 test("autoheight", function() { 15 $('#navigation'). makeAccordion({ header: '.head', autoheight: false });15 $('#navigation').accordion({ header: '.head', autoheight: false }); 16 16 equals( 90, $('#navigation ul:first').height() ); 17 17 equals( 126, $('#navigation ul:eq(1)').height() ); 18 18 equals( 54, $('#navigation ul:last').height() ); 19 $('#navigation'). removeAccordion().makeAccordion({ header: '.head',autoheight: true });19 $('#navigation').accordion("destroy").accordion({ header: '.head',autoheight: true }); 20 20 equals( 126, $('#navigation ul:first').height() ); 21 21 equals( 126, $('#navigation ul:eq(1)').height() ); … … 24 24 25 25 test("activate, numeric", function() { 26 var ac = $('#list1'). makeAccordion({ active: 1 });26 var ac = $('#list1').accordion({ active: 1 }); 27 27 state(ac, 0, 1, 0); 28 ac.ac tivate(2);28 ac.accordion("activate", 2); 29 29 state(ac, 0, 0, 1); 30 ac.ac tivate(0);30 ac.accordion("activate", 0); 31 31 state(ac, 1, 0, 0); 32 ac.ac tivate(1);32 ac.accordion("activate", 1); 33 33 state(ac, 0, 1, 0); 34 ac.ac tivate(2);34 ac.accordion("activate", 2); 35 35 state(ac, 0, 0, 1); 36 ac.ac tivate(-1);36 ac.accordion("activate", -1); 37 37 state(ac, 0, 0, 1); 38 38 }); 39 39 40 40 test("activate, boolean and numeric, alwaysOpen:false", function() { 41 var ac = $('#list1'). makeAccordion({alwaysOpen: false}).activate(2);41 var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate", 2); 42 42 state(ac, 0, 0, 1); 43 43 ok("x", "----") 44 ac.ac tivate(0);44 ac.accordion("activate", 0); 45 45 state(ac, 1, 0, 0); 46 46 ok("x", "----") 47 ac.ac tivate(-1);47 ac.accordion("activate", -1); 48 48 state(ac, 0, 0, 0); 49 49 }); 50 50 51 51 test("activate, boolean, alwaysOpen:true", function() { 52 var ac = $('#list1'). makeAccordion().activate(2);52 var ac = $('#list1').accordion().accordion("activate", 2); 53 53 state(ac, 0, 0, 1); 54 ac.ac tivate(-1);54 ac.accordion("activate", -1); 55 55 state(ac, 0, 0, 1); 56 56 }); 57 57 58 58 test("activate, string expression", function() { 59 var ac = $('#list1'). makeAccordion({ active: ":last" });59 var ac = $('#list1').accordion({ active: ":last" }); 60 60 state(ac, 0, 0, 1); 61 ac.ac tivate(":first");61 ac.accordion("activate", ":first"); 62 62 state(ac, 1, 0, 0); 63 ac.ac tivate(":eq(1)");63 ac.accordion("activate", ":eq(1)"); 64 64 state(ac, 0, 1, 0); 65 ac.ac tivate(":last");65 ac.accordion("activate", ":last"); 66 66 state(ac, 0, 0, 1); 67 67 }); 68 68 69 69 test("activate, jQuery or DOM element", function() { 70 var ac = $('#list1'). makeAccordion({ active: $("#list1 a:last") });70 var ac = $('#list1').accordion({ active: $("#list1 a:last") }); 71 71 state(ac, 0, 0, 1); 72 ac.ac tivate($("#list1 a:first"));72 ac.accordion("activate", $("#list1 a:first")); 73 73 state(ac, 1, 0, 0); 74 ac.ac tivate($("#list1 a")[1]);74 ac.accordion("activate", $("#list1 a")[1]); 75 75 state(ac, 0, 1, 0); 76 76 }); -
trunk/plugins/accordion/test/testrunner.js
r2587 r4707 14 14 }; 15 15 16 var isLocal = !!(window.location.protocol == 'file:'); 17 16 18 $(function() { 17 19 $('#userAgent').html(navigator.userAgent); … … 40 42 start(); 41 43 }; 42 _config.timeout = setTimeout(handler, _config.asyncTimeout * 1000); 44 // Disabled, caused too many random errors 45 //_config.timeout = setTimeout(handler, _config.asyncTimeout * 1000); 43 46 } 44 47 function start() { 45 if(_config.timeout) 46 clearTimeout(_config.timeout); 47 _config.blocking = false; 48 process(); 48 // A slight delay, to avoid any current callbacks 49 setTimeout(function(){ 50 if(_config.timeout) 51 clearTimeout(_config.timeout); 52 _config.blocking = false; 53 process(); 54 }, 13); 49 55 } 50 56 … … 53 59 var time = new Date(); 54 60 _config.fixture = document.getElementById('main').innerHTML; 55 reset();56 61 synchronize(function() { 57 62 time = new Date() - time; … … 70 75 71 76 var filter = location.search.slice(1); 72 if ( filter && encodeURIComponent(name) != filter)77 if ( filter && encodeURIComponent(name).indexOf(filter) == -1 ) 73 78 return; 74 79 … … 84 89 } 85 90 _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e ] ); 86 throw e;87 91 } 88 92 }); … … 158 162 */ 159 163 function reset() { 160 document.getElementById('main').innerHTML = _config.fixture;164 $("#main").html( _config.fixture ); 161 165 } 162 166 -
trunk/ui/ui.accordion.js
r4654 r4707 1 1 /* 2 * jQuery UI Accordion 1. 12 * jQuery UI Accordion 1.5 3 3 * 4 4 * Copyright (c) 2007 Jörn Zaefferer … … 108 108 } 109 109 $.removeData(this.element, "ui-accordion"); 110 $(this.element). unbind(".ui-accordion");110 $(this.element).removeClass("ui-accordion").unbind(".ui-accordion"); 111 111 } 112 112 } … … 122 122 if (!$.data(this, "ui-accordion")) 123 123 return; 124 var options = $.data(this, "ui-accordion").options; 124 var instance = $.data(this, "ui-accordion"); 125 var options = instance.options; 125 126 options.running = cancel ? 0 : --options.running; 126 127 if ( options.running ) … … 132 133 }); 133 134 } 134 $(this).trigger ("changed.ui-accordion", options.data);135 $(this).triggerHandler("change.ui-accordion", [options.data], options.change); 135 136 } 136 137 … … 182 183 if ( !event.target && !options.alwaysOpen ) { 183 184 options.active.parent().andSelf().toggleClass(options.selectedClass); 184 var toHide = options.active.next(); 185 var toShow = options.active = $([]); 186 toggle.call(this, toShow, toHide ); 185 var toHide = options.active.next(), 186 data = { 187 instance: this, 188 options: options, 189 newHeader: jQuery([]), 190 oldHeader: options.active, 191 newContent: jQuery([]), 192 oldContent: toHide 193 }, 194 toShow = options.active = $([]); 195 toggle.call(this, toShow, toHide, data ); 187 196 return false; 188 197 } … … 213 222 var toShow = clicked.next(), 214 223 toHide = options.active.next(), 215 data = [clicked, options.active, toShow, toHide], 224 //data = [clicked, options.active, toShow, toHide], 225 data = { 226 instance: this, 227 options: options, 228 newHeader: clicked, 229 oldHeader: options.active, 230 newContent: toShow, 231 oldContent: toHide 232 }, 216 233 down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); 217 234
