state( ac, 0, 0, 1 );
});
+
+
+
+
+module( "accordion (deprecated) - changestart/change events", accordionSetupTeardown() );
+
+test( "changestart", function() {
+ expect( 20 );
+ var ac = $( "#list1" ).accordion({
+ active: false,
+ collapsible: true
+ });
+ var headers = ac.find( ".ui-accordion-header" );
+ var content = ac.find( ".ui-accordion-content" );
+
+ ac.one( "accordionchangestart", function( event, ui ) {
+ equals( ui.oldHeader.size(), 0 );
+ equals( ui.oldContent.size(), 0 );
+ equals( ui.newHeader.size(), 1 );
+ strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
+ equals( ui.newContent.size(), 1 );
+ strictEqual( ui.newContent[ 0 ], content[ 0 ] );
+ });
+ ac.accordion( "option", "active", 0 );
+
+ ac.one( "accordionchangestart", function( event, ui ) {
+ equals( ui.oldHeader.size(), 1 );
+ strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
+ equals( ui.oldContent.size(), 1 );
+ strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
+ equals( ui.newHeader.size(), 1 );
+ strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
+ equals( ui.newContent.size(), 1 );
+ strictEqual( ui.newContent[ 0 ], content[ 1 ] );
+ });
+ headers.eq( 1 ).click();
+
+ ac.one( "accordionchangestart", function( event, ui ) {
+ equals( ui.oldHeader.size(), 1 );
+ strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
+ equals( ui.oldContent.size(), 1 );
+ strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
+ equals( ui.newHeader.size(), 0 );
+ equals( ui.newContent.size(), 0 );
+ });
+ ac.accordion( "option", "active", false );
+});
+
+test( "change", function() {
+ expect( 20 );
+ var ac = $( "#list1" ).accordion({
+ active: false,
+ collapsible: true
+ });
+ var headers = ac.find( ".ui-accordion-header" );
+ var content = ac.find( ".ui-accordion-content" );
+
+ ac.one( "accordionchange", function( event, ui ) {
+ equals( ui.oldHeader.size(), 0 );
+ equals( ui.oldContent.size(), 0 );
+ equals( ui.newHeader.size(), 1 );
+ strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
+ equals( ui.newContent.size(), 1 );
+ strictEqual( ui.newContent[ 0 ], content[ 0 ] );
+ });
+ ac.accordion( "option", "active", 0 );
+
+ ac.one( "accordionchange", function( event, ui ) {
+ equals( ui.oldHeader.size(), 1 );
+ strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
+ equals( ui.oldContent.size(), 1 );
+ strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
+ equals( ui.newHeader.size(), 1 );
+ strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
+ equals( ui.newContent.size(), 1 );
+ strictEqual( ui.newContent[ 0 ], content[ 1 ] );
+ });
+ headers.eq( 1 ).click();
+
+ ac.one( "accordionchange", function( event, ui ) {
+ equals( ui.oldHeader.size(), 1 );
+ strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
+ equals( ui.oldContent.size(), 1 );
+ strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
+ equals( ui.newHeader.size(), 0 );
+ equals( ui.newContent.size(), 0 );
+ });
+ ac.accordion( "option", "active", false );
+});
+
})(jQuery);
module( "accordion: events", accordionSetupTeardown() );
-test( "changestart", function() {
+test( "beforeActivate", function() {
expect( 20 );
var ac = $( "#list1" ).accordion({
active: false,
var headers = ac.find( ".ui-accordion-header" );
var content = ac.find( ".ui-accordion-content" );
- ac.one( "accordionchangestart", function( event, ui ) {
+ ac.one( "accordionbeforeactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 );
});
ac.accordion( "option", "active", 0 );
- ac.one( "accordionchangestart", function( event, ui ) {
+ ac.one( "accordionbeforeactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equals( ui.oldContent.size(), 1 );
});
headers.eq( 1 ).click();
- ac.one( "accordionchangestart", function( event, ui ) {
+ ac.one( "accordionbeforeactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equals( ui.oldContent.size(), 1 );
ac.accordion( "option", "active", false );
});
-test( "change", function() {
+test( "activate", function() {
expect( 20 );
var ac = $( "#list1" ).accordion({
active: false,
var headers = ac.find( ".ui-accordion-header" );
var content = ac.find( ".ui-accordion-content" );
- ac.one( "accordionchange", function( event, ui ) {
+ ac.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 );
});
ac.accordion( "option", "active", 0 );
- ac.one( "accordionchange", function( event, ui ) {
+ ac.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equals( ui.oldContent.size(), 1 );
});
headers.eq( 1 ).click();
- ac.one( "accordionchange", function( event, ui ) {
+ ac.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equals( ui.oldContent.size(), 1 );
];
function testWidgetOverrides( widget ) {
- test( "$.widget overrides", function() {
- $.each( privateMethods, function( i, method ) {
- strictEqual( $.ui[ widget ].prototype[ method ],
- $.Widget.prototype[ method ], "should not override " + method );
+ if ( $.uiBackCompat === false ) {
+ test( "$.widget overrides", function() {
+ $.each( privateMethods, function( i, method ) {
+ strictEqual( $.ui[ widget ].prototype[ method ],
+ $.Widget.prototype[ method ], "should not override " + method );
+ });
});
- });
+ }
}
function testBasicUsage( widget ) {
return self._completed.apply( self, arguments );
};
- // trigger changestart event
- self._trigger( "changestart", null, self.data );
+ self._trigger( "beforeActivate", null, self.data );
// count elements to animate
self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
this.toHide.parent()[0].className = this.toHide.parent()[0].className;
}
- this._trigger( "change", null, this.data );
+ this._trigger( "activate", null, this.data );
}
});
// resize method
jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
+
+ (function( $, prototype ) {
+ var _trigger = prototype._trigger;
+ prototype._trigger = function( type, event, data ) {
+ var ret = _trigger.apply( this, arguments );
+ if ( !ret ) {
+ return false;
+ }
+
+ if ( type === "beforeActivate" ) {
+ ret = _trigger.call( this, "changestart", event, data );
+ } else if ( type === "activate" ) {
+ ret = _trigger.call( this, "change", event, data );
+ }
+ return ret;
+ }
+ }( jQuery, jQuery.ui.accordion.prototype ) );
}
})( jQuery );