Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/63255
Change subject: Add check for missing onclick function, document, fix exception ...................................................................... Add check for missing onclick function, document, fix exception * Throws an exception if you use action: okay without an onclick * Document some action-related things more clearly * Have exception class work around https://code.google.com/p/chromium/issues/detail?id=228909 Change-Id: I1003825a40498c1f71c7ece6bf656c6bf8f60728 --- M modules/ext.guidedTour.lib.js 1 file changed, 18 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GuidedTour refs/changes/55/63255/1 diff --git a/modules/ext.guidedTour.lib.js b/modules/ext.guidedTour.lib.js index 2e10257..8f17cc0 100644 --- a/modules/ext.guidedTour.lib.js +++ b/modules/ext.guidedTour.lib.js @@ -336,6 +336,9 @@ nextButton = getMessageButton( 'next', next ); break; case 'okay': + if ( currentButton.onclick === undefined ) { + throw new gt.TourDefinitionError( 'You must pass an \'onclick\' function if you use an \'okay\' action.' ); + } okayButton = getMessageButton( 'okay', currentButton.onclick ); break; case 'end': @@ -1044,7 +1047,16 @@ * actions currently supported are: * * - next - Goes to the next step. - * - okay - Arbitrary function (passed as onclick) used for okay button + * - okay - An arbitrary function is used for okay button. This must have + * an accompanying 'onclick': + * + * { + * action: 'okay', + * onclick: function () { + * // Do something... + * } + * } + * * - end - Ends the tour. * - wikiLink - links to a page on the same wiki * - externalLink - links to an external page @@ -1054,6 +1066,8 @@ * { * action: 'next' * } + * + * Multiple action fields for a single button are not possible. * * @param {string} tourSpec.steps.buttons.page Page to link to, only for * the wikiLink action @@ -1183,7 +1197,9 @@ } }; - gt.TourDefinitionError.prototype = new Error(); + gt.TourDefinitionError.prototype.toString = function () { + return 'TourDefinitionError: ' + this.message; + }; gt.TourDefinitionError.prototype.constructor = gt.TourDefinitionError; initialize(); -- To view, visit https://gerrit.wikimedia.org/r/63255 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1003825a40498c1f71c7ece6bf656c6bf8f60728 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GuidedTour Gerrit-Branch: master Gerrit-Owner: Mattflaschen <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
