aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/accordion/accordion_deprecated.js90
-rw-r--r--tests/unit/accordion/accordion_events.js16
-rw-r--r--tests/unit/testsuite.js12
-rw-r--r--ui/jquery.ui.accordion.js22
4 files changed, 124 insertions, 16 deletions
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index a0ca3f634..6f1c30562 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -221,4 +221,94 @@ test( "{ navigation: true, navigationFilter: content }", function() {
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);
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index 463a277d8..fd7391387 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -2,7 +2,7 @@
module( "accordion: events", accordionSetupTeardown() );
-test( "changestart", function() {
+test( "beforeActivate", function() {
expect( 20 );
var ac = $( "#list1" ).accordion({
active: false,
@@ -11,7 +11,7 @@ test( "changestart", function() {
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 );
@@ -21,7 +21,7 @@ test( "changestart", function() {
});
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 );
@@ -33,7 +33,7 @@ test( "changestart", function() {
});
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 );
@@ -44,7 +44,7 @@ test( "changestart", function() {
ac.accordion( "option", "active", false );
});
-test( "change", function() {
+test( "activate", function() {
expect( 20 );
var ac = $( "#list1" ).accordion({
active: false,
@@ -53,7 +53,7 @@ test( "change", function() {
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 );
@@ -63,7 +63,7 @@ test( "change", function() {
});
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 );
@@ -75,7 +75,7 @@ test( "change", function() {
});
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 );
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 0033182dc..9724a946f 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -34,12 +34,14 @@ var privateMethods = [
];
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 ) {
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index d855da5f3..cd6a2ce93 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -381,8 +381,7 @@ $.widget( "ui.accordion", {
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();
@@ -487,7 +486,7 @@ $.widget( "ui.accordion", {
this.toHide.parent()[0].className = this.toHide.parent()[0].className;
}
- this._trigger( "change", null, this.data );
+ this._trigger( "activate", null, this.data );
}
});
@@ -711,6 +710,23 @@ if ( $.uiBackCompat !== false ) {
// 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 );