Merge changes Icdd8f392,Ied13e5ab

* changes:
  jquery.makeCollapsible: basic test suite
  jquery.makeCollapsible: use 'mw-collapsible' event namespace
This commit is contained in:
jenkins-bot 2013-04-03 22:08:07 +00:00 committed by Gerrit Code Review
commit ef730cbed1
4 changed files with 60 additions and 5 deletions

View file

@ -27,6 +27,8 @@ changes to languages because of Bugzilla reports.
* redirect.php was removed. It was unused.
* BREAKING CHANGE: Legacy skins Simple, MySkin and Standard were all removed.
Nostalgia was moved to an extension.
* Event namespace used by jquery.makeCollapsible has been changed from
'mw-collapse' to 'mw-collapsible' for consistency with the module name.
== Compatibility ==

View file

@ -274,7 +274,7 @@
.parent()
.prepend( ' [' )
.append( '] ' )
.on( 'click.mw-collapse', function ( e, opts ) {
.on( 'click.mw-collapsible', function ( e, opts ) {
opts = $.extend( { toggleText: { collapseText: collapsetext, expandText: expandtext } }, options, opts );
toggleLinkDefault( $(this), e, opts );
} );
@ -298,7 +298,7 @@
// Bind the custom togglers
if ( $customTogglers && $customTogglers.length ) {
$customTogglers.on( 'click.mw-collapse', function ( e, opts ) {
$customTogglers.on( 'click.mw-collapsible', function ( e, opts ) {
opts = $.extend( {}, options, opts );
toggleLinkCustom( $(this), e, opts, $collapsible );
} );
@ -324,7 +324,7 @@
if ( !$toggle.length ) {
$firstItem.eq(-1).prepend( $toggleLink );
} else {
$toggleLink = $toggle.off( 'click.mw-collapse' ).on( 'click.mw-collapse', function ( e, opts ) {
$toggleLink = $toggle.off( 'click.mw-collapsible' ).on( 'click.mw-collapsible', function ( e, opts ) {
opts = $.extend( {}, options, opts );
toggleLinkPremade( $toggle, e, opts );
} );
@ -346,7 +346,7 @@
}
$collapsible.prepend( $toggleLink.wrap( '<li class="mw-collapsible-toggle-li"></li>' ).parent() );
} else {
$toggleLink = $toggle.off( 'click.mw-collapse' ).on( 'click.mw-collapse', function ( e, opts ) {
$toggleLink = $toggle.off( 'click.mw-collapsible' ).on( 'click.mw-collapsible', function ( e, opts ) {
opts = $.extend( {}, options, opts );
toggleLinkPremade( $toggle, e, opts );
} );
@ -366,7 +366,7 @@
if ( !$toggle.length ) {
$collapsible.prepend( $toggleLink );
} else {
$toggleLink = $toggle.off( 'click.mw-collapse' ).on( 'click.mw-collapse', function ( e, opts ) {
$toggleLink = $toggle.off( 'click.mw-collapsible' ).on( 'click.mw-collapsible', function ( e, opts ) {
opts = $.extend( {}, options, opts );
toggleLinkPremade( $toggle, e, opts );
} );

View file

@ -16,6 +16,7 @@ return array(
'tests/qunit/suites/resources/jquery/jquery.hidpi.test.js',
'tests/qunit/suites/resources/jquery/jquery.highlightText.test.js',
'tests/qunit/suites/resources/jquery/jquery.localize.test.js',
'tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js',
'tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js',
'tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js',
'tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js',
@ -45,6 +46,7 @@ return array(
'jquery.hidpi',
'jquery.highlightText',
'jquery.localize',
'jquery.makeCollapsible',
'jquery.mwExtension',
'jquery.tabIndex',
'jquery.tablesorter',

View file

@ -0,0 +1,51 @@
( function ( mw, $ ) {
var loremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.';
QUnit.module( 'jquery.makeCollapsible', QUnit.newMwEnvironment() );
function prepareCollapsible( html, options ) {
return $( $.parseHTML( html ) )
.appendTo( '#qunit-fixture' )
// options might be undefined here - this is okay
.makeCollapsible( options );
}
QUnit.test( 'basic operation with instantHide (synchronous test)', 2, function ( assert ) {
var $collapsible, $content;
$collapsible = prepareCollapsible(
'<div class="mw-collapsible">' + loremIpsum + '</div>',
{ instantHide: true }
);
$content = $collapsible.find( '.mw-collapsible-content' );
assert.assertTrue( $content.is( ':visible' ), 'content is visible' );
$collapsible.find( '.mw-collapsible-toggle' ).trigger( 'click' );
assert.assertTrue( $content.is( ':hidden' ), 'after collapsing: content is hidden' );
} );
QUnit.test( 'initially collapsed - mw-collapsed class', 1, function ( assert ) {
var $collapsible, $content;
$collapsible = prepareCollapsible(
'<div class="mw-collapsible mw-collapsed">' + loremIpsum + '</div>'
);
$content = $collapsible.find( '.mw-collapsible-content' );
// Synchronous - mw-collapsed should cause instantHide: true to be used on initial collapsing
assert.assertTrue( $content.is( ':hidden' ), 'content is hidden' );
} );
QUnit.test( 'initially collapsed - options', 1, function ( assert ) {
var $collapsible, $content;
$collapsible = prepareCollapsible(
'<div class="mw-collapsible">' + loremIpsum + '</div>',
{ collapsed: true }
);
$content = $collapsible.find( '.mw-collapsible-content' );
// Synchronous - collapsed: true should cause instantHide: true to be used on initial collapsing
assert.assertTrue( $content.is( ':hidden' ), 'content is hidden' );
} );
}( mediaWiki, jQuery ) );