jenkins-bot has submitted this change and it was merged. Change subject: Allow multiple button types. Fix getButton tests. ......................................................................
Allow multiple button types. Fix getButton tests. When defining a button, you can now pass multiple types as a button. eg: quiet progressive Correct issue with getButtons tests. Added quiet progressive button test. Change-Id: If142be0de35e171a61e9c731788cddee9a190ae2 --- M modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js M tests/ext.guidedTour.lib.tests.js 2 files changed, 30 insertions(+), 18 deletions(-) Approvals: Phuedx: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js b/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js index 48daa9b..5636f41 100644 --- a/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js +++ b/modules/ext.guidedTour.lib/ext.guidedTour.lib.Step.js @@ -242,22 +242,28 @@ */ function getButtonTypeClass( button ) { var buttonTypes = { - progressive: 'mw-ui-progressive', - constructive: 'mw-ui-constructive', - destructive: 'mw-ui-destructive' - }; - // Button have a flagged type? - // TODO: rmoen 7/7/14 in the future it might be nice to have - // type optionally an array so we can add additional classes here. - // example: mw-ui-quiet + progressive: 'mw-ui-progressive', + constructive: 'mw-ui-constructive', + destructive: 'mw-ui-destructive', + quiet: 'mw-ui-quiet' + }, + classString = ''; + + // Build button class string if ( button.type ) { + if ( $.isArray( button.type ) ) { + $.each( button.type, function( i , key ) { + classString += buttonTypes[key] + ' '; + } ); + return classString; + } return buttonTypes[button.type] || ''; } else if ( button.action === 'back' || button.action === 'wikiLink' || button.action === 'externalLink' ) { // No additional classes for the above buttons - return ''; + return classString; } // Otherwise, make the button progressive return buttonTypes.progressive; diff --git a/tests/ext.guidedTour.lib.tests.js b/tests/ext.guidedTour.lib.tests.js index 419b364..84ab1fc 100644 --- a/tests/ext.guidedTour.lib.tests.js +++ b/tests/ext.guidedTour.lib.tests.js @@ -1080,9 +1080,10 @@ ); } ); - QUnit.test( 'Step.getButtons', 6, function ( assert ) { + QUnit.test( 'Step.getButtons', 7, function ( assert ) { var buttons = [ { type: 'destructive' }, + { type: ['progressive', 'quiet'] }, { action: 'wikiLink', type: 'constructive' }, { action: 'externalLink' }, { action: 'back' }, @@ -1097,30 +1098,35 @@ tourBuilder.tour.showStep( firstStep ); returnedButtons = spy.lastCall.args[0].buttons; - assert.ok( - returnedButtons[0].html['class'].indexOf( 'mw-ui-destructive' ) && + returnedButtons[0].html['class'].indexOf( 'mw-ui-destructive' ) !== -1 && returnedButtons[0].html['class'].indexOf( 'mw-ui-button' ) !== -1, - 'Destructive Custom button' + 'Destructive custom button' ); assert.ok( - returnedButtons[1].html['class'].indexOf( 'mw-ui-constructive' ) !== -1, + returnedButtons[1].html['class'].indexOf( 'mw-ui-button' ) !== -1 && + returnedButtons[1].html['class'].indexOf( 'mw-ui-progressive' ) !== -1 && + returnedButtons[1].html['class'].indexOf( 'mw-ui-quiet' ) !== -1, + 'A quietly progressive custom button' + ); + assert.ok( + returnedButtons[2].html['class'].indexOf( 'mw-ui-constructive' ) !== -1, 'Constructive internal link' ); assert.ok( - returnedButtons[2].html['class'].indexOf( 'mw-ui-progressive' ) === -1, + returnedButtons[3].html['class'].indexOf( 'mw-ui-progressive' ) === -1, 'External link button is not progressive by default' ); assert.ok( - returnedButtons[3].html['class'].indexOf( 'mw-ui-progressive' ) === -1, + returnedButtons[4].html['class'].indexOf( 'mw-ui-progressive' ) === -1, 'Back button is not progressive by default' ); assert.ok( - returnedButtons[4].html['class'].indexOf( 'mw-ui-progressive' ) !== -1, + returnedButtons[5].html['class'].indexOf( 'mw-ui-progressive' ) !== -1, 'Okay button is progressive by default' ); assert.ok( - returnedButtons[5].html['class'].indexOf( 'mw-ui-progressive' ) !== -1, + returnedButtons[6].html['class'].indexOf( 'mw-ui-progressive' ) !== -1, 'Next button is progressive by default' ); } ); -- To view, visit https://gerrit.wikimedia.org/r/145991 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If142be0de35e171a61e9c731788cddee9a190ae2 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/GuidedTour Gerrit-Branch: master Gerrit-Owner: Robmoen <rm...@wikimedia.org> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Phuedx <g...@samsmith.io> Gerrit-Reviewer: Swalling <swall...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits