jenkins-bot has submitted this change and it was merged.

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(-)

Approvals:
  Spage: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ext.guidedTour.lib.js b/modules/ext.guidedTour.lib.js
index 4b9a373..eefb902 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':
@@ -1043,7 +1046,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
@@ -1053,6 +1065,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
@@ -1181,7 +1195,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: merged
Gerrit-Change-Id: I1003825a40498c1f71c7ece6bf656c6bf8f60728
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to