Merge "Allow custom event handlers for the click event of toolbar buttons"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 26 Aug 2014 15:31:45 +0000 (15:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 26 Aug 2014 15:31:45 +0000 (15:31 +0000)
resources/src/mediawiki.action/mediawiki.action.edit.js

index 0481b6a..0ebcd3c 100644 (file)
                        title: b.speedTip,
                        id: b.imageId || undefined,
                        'class': 'mw-toolbar-editbutton'
-               } ).click( function () {
-                       toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText );
+               } ).click( function ( e ) {
+                       if ( $.isFunction( b.onClick ) ) {
+                               b.onClick( e );
+                       } else {
+                               toolbar.insertTags( b.tagOpen, b.tagClose, b.sampleText );
+                       }
                        return false;
                } );
 
@@ -72,6 +76,7 @@
                 * @param {string} button.tagClose
                 * @param {string} button.sampleText
                 * @param {string} [button.imageId]
+                * @param {Function} [button.onClick]
                 */
                addButton: function () {
                        if ( isReady ) {