[MediaWiki-commits] [Gerrit] jquery.makeCollapsible: Make it possible to clone a collapsible - change (mediawiki/core)

2015-07-20 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: jquery.makeCollapsible: Make it possible to clone a collapsible
..


jquery.makeCollapsible: Make it possible to clone a collapsible

Currently collapsible elements are no longer collapsible after you
cloned them and made them collapsible again, e.g. via

 $clone = $('#bodyContent').clone();
 mw.hook('wikipage.content').fire($clone);
 $('#bodyContent').replaceWith($clone);

This patch fixes this by ignoring the linksPassthru option on links
with href=#.

Bug: T71288
Change-Id: I954483f3e26f46172ec2374a3717f37dd309ca57
---
M resources/src/jquery/jquery.makeCollapsible.js
M tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
2 files changed, 25 insertions(+), 2 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/src/jquery/jquery.makeCollapsible.js 
b/resources/src/jquery/jquery.makeCollapsible.js
index f7c4217..19fdb26 100644
--- a/resources/src/jquery/jquery.makeCollapsible.js
+++ b/resources/src/jquery/jquery.makeCollapsible.js
@@ -159,8 +159,13 @@
}
 
if ( e ) {
-   if ( e.type === 'click'  options.linksPassthru  
$.nodeName( e.target, 'a' ) ) {
-   // Don't fire if a link was clicked, if 
requested  (for premade togglers by default)
+   if (
+   e.type === 'click' 
+   options.linksPassthru 
+   $.nodeName( e.target, 'a' ) 
+   $( e.target ).attr( 'href' ) !== '#'
+   ) {
+   // Don't fire if a link with href !== '#' was 
clicked, if requested  (for premade togglers by default)
return;
} else if ( e.type === 'keypress'  e.which !== 13  
e.which !== 32 ) {
// Only handle keypresses on the Enter or 
Space keys
diff --git a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js 
b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
index 8040581..c51e409 100644
--- a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
@@ -336,4 +336,22 @@
this.clock.tick( 500 );
} );
 
+   QUnit.test( 'cloned collapsibles can be made collapsible again', 2, 
function ( assert ) {
+   var test = this,
+   $collapsible = prepareCollapsible(
+   'div class=mw-collapsible' + loremIpsum + 
'/div'
+   ),
+   $clone = $collapsible.clone() // clone without data and 
events
+   .appendTo( '#qunit-fixture' ).makeCollapsible(),
+   $content = $clone.find( '.mw-collapsible-content' );
+
+   assert.assertTrue( $content.is( ':visible' ), 'content is 
visible' );
+
+   $clone.on( 'afterCollapse.mw-collapsible', function () {
+   assert.assertTrue( $content.is( ':hidden' ), 'after 
collapsing: content is hidden' );
+   } );
+
+   $clone.find( '.mw-collapsible-toggle a' ).trigger( 'click' );
+   test.clock.tick( 500 );
+   } );
 }( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/224758
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I954483f3e26f46172ec2374a3717f37dd309ca57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader gerritpatchuploa...@gmail.com
Gerrit-Reviewer: Bartosz Dziewoński matma@gmail.com
Gerrit-Reviewer: Edokter er...@darcoury.nl
Gerrit-Reviewer: Gerrit Patch Uploader gerritpatchuploa...@gmail.com
Gerrit-Reviewer: Jack Phoenix j...@countervandalism.net
Gerrit-Reviewer: Schnark listenle...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] jquery.makeCollapsible: Make it possible to clone a collapsible - change (mediawiki/core)

2015-07-15 Thread Gerrit Patch Uploader (Code Review)
Gerrit Patch Uploader has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/224758

Change subject: jquery.makeCollapsible: Make it possible to clone a collapsible
..

jquery.makeCollapsible: Make it possible to clone a collapsible

Currently collapsible elements are no longer collapsible after you
cloned them and made them collapsible again, e.g. via

 $clone = $('#bodyContent').clone();
 mw.hook('wikipage.content').fire($clone);
 $('#bodyContent').replaceWith($clone);

This patch fixes this by ignoring the linksPassthru option on links
with href=#.

Bug: T71288
Change-Id: I954483f3e26f46172ec2374a3717f37dd309ca57
---
M resources/src/jquery/jquery.makeCollapsible.js
M tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
2 files changed, 25 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/224758/1

diff --git a/resources/src/jquery/jquery.makeCollapsible.js 
b/resources/src/jquery/jquery.makeCollapsible.js
index f7c4217..19fdb26 100644
--- a/resources/src/jquery/jquery.makeCollapsible.js
+++ b/resources/src/jquery/jquery.makeCollapsible.js
@@ -159,8 +159,13 @@
}
 
if ( e ) {
-   if ( e.type === 'click'  options.linksPassthru  
$.nodeName( e.target, 'a' ) ) {
-   // Don't fire if a link was clicked, if 
requested  (for premade togglers by default)
+   if (
+   e.type === 'click' 
+   options.linksPassthru 
+   $.nodeName( e.target, 'a' ) 
+   $( e.target ).attr( 'href' ) !== '#'
+   ) {
+   // Don't fire if a link with href !== '#' was 
clicked, if requested  (for premade togglers by default)
return;
} else if ( e.type === 'keypress'  e.which !== 13  
e.which !== 32 ) {
// Only handle keypresses on the Enter or 
Space keys
diff --git a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js 
b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
index 8040581..c51e409 100644
--- a/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js
@@ -336,4 +336,22 @@
this.clock.tick( 500 );
} );
 
+   QUnit.test( 'cloned collapsibles can be made collapsible again', 2, 
function ( assert ) {
+   var test = this,
+   $collapsible = prepareCollapsible(
+   'div class=mw-collapsible' + loremIpsum + 
'/div'
+   ),
+   $clone = $collapsible.clone() // clone without data and 
events
+   .appendTo( '#qunit-fixture' ).makeCollapsible(),
+   $content = $clone.find( '.mw-collapsible-content' );
+
+   assert.assertTrue( $content.is( ':visible' ), 'content is 
visible' );
+
+   $clone.on( 'afterCollapse.mw-collapsible', function () {
+   assert.assertTrue( $content.is( ':hidden' ), 'after 
collapsing: content is hidden' );
+   } );
+
+   $clone.find( '.mw-collapsible-toggle a' ).trigger( 'click' );
+   test.clock.tick( 500 );
+   } );
 }( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/224758
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I954483f3e26f46172ec2374a3717f37dd309ca57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader gerritpatchuploa...@gmail.com
Gerrit-Reviewer: Gerrit Patch Uploader gerritpatchuploa...@gmail.com
Gerrit-Reviewer: Schnark listenle...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits