mediawiki.util: Add JS-handler usage example for addPortletLink()
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 22 Jan 2016 21:15:38 +0000 (21:15 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 22 Jan 2016 21:34:36 +0000 (21:34 +0000)
Makes it clear that the method returns the Element node which
can then be used to attach event handlers.

Change-Id: Id33d3dc24a439cc6fe86f2de5baafa0aa779b2c0

resources/src/mediawiki/mediawiki.util.js

index f9810f9..cc983e4 100644 (file)
                 * (e.g. `'#foobar'`) for that item.
                 *
                 *     mw.util.addPortletLink(
-                *         'p-tb', 'http://mediawiki.org/',
-                *         'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', '#t-print'
+                *         'p-tb', 'https://www.mediawiki.org/',
+                *         'mediawiki.org', 't-mworg', 'Go to mediawiki.org', 'm', '#t-print'
                 *     );
                 *
+                *     var node = mw.util.addPortletLink(
+                *         'p-tb',
+                *         new mw.Title( 'Special:Example' ).getUrl(),
+                *         'Example'
+                *     );
+                *     $( node ).on( 'click', function ( e ) {
+                *         console.log( 'Example' );
+                *         e.preventDefault();
+                *     } );
+                *
                 * @param {string} portlet ID of the target portlet ( 'p-cactions' or 'p-personal' etc.)
                 * @param {string} href Link URL
                 * @param {string} text Link text