r92515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92514‎ | r92515 | r92516 >
Date:00:54, 19 July 2011
Author:werdna
Status:deferred
Tags:
Comment:
MoodBar: Add a simple jQuery module that simplifies submitting MoodBar feedback
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/jquery.moodBar (added) (history)
  • /trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js (added) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js
@@ -0,0 +1,48 @@
 2+/**
 3+ * jquery.moodbar.js
 4+ * JavaScript interface for the MoodBar backend.
 5+ *
 6+ * @author Andrew Garrett
 7+ */
 8+( function( $ ) {
 9+ $.moodBar = {
 10+ /**
 11+ * Submit a MoodBar feedback item.
 12+ * @param params Object: Named parameters:
 13+ * comment: The comments submitted
 14+ * bucket: A bucket, for A/B testing.
 15+ * anonymize: Boolean, whether or not to mark as anonymous
 16+ * callback: A function, accepts a single 'data' parameter, to call when the
 17+ * request completes.
 18+ * @return null
 19+ */
 20+ 'submit' : function( params ) {
 21+ var useragent = navigator.userAgent;
 22+ var clientData = $.client.profile();
 23+
 24+ var apiRequest =
 25+ {
 26+ 'action' : 'moodbar',
 27+ 'page' : mw.config.get('wgPageName'),
 28+ 'comment' : params.comment,
 29+ 'anonymize' : params.anonymize,
 30+ 'editmode' : (wgAction == 'edit') ? 1 : 0,
 31+ 'useragent' : clientData.name + '/' + clientData.versionBase,
 32+ 'system' : clientData.platform,
 33+ 'bucket' : params.bucket,
 34+ 'type' : params.type,
 35+ 'token' : mw.user.tokens.get('editToken'),
 36+ 'format' : 'json'
 37+ };
 38+
 39+ var path = wgScriptPath+'/api'+wgScriptExtension;
 40+
 41+ $j.post( path, apiRequest,
 42+ function(data) {
 43+ if (params.callback) {
 44+ params.callback(data);
 45+ }
 46+ }, 'json' );
 47+ }
 48+ };
 49+} ) ( jQuery );
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -76,3 +76,12 @@
7777 ),
7878 'position' => 'bottom',
7979 );
 80+
 81+
 82+$wgResourceModules['jquery.moodBar'] = $mbResourceTemplate + array(
 83+ 'scripts' => 'jquery.moodBar/jquery.moodBar.js',
 84+ 'dependencies' => array(
 85+ 'mediawiki.util',
 86+ 'jquery.client',
 87+ ),
 88+);
Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -16,7 +16,6 @@
1717 * Determines whether or not we should show the MoodBar.
1818 */
1919 public static function shouldShowMoodbar( &$output, &$skin ) {
20 -
2120 if (
2221 // Front-end appends to header elements, which have different
2322 // locations and IDs in every skin.

Status & tagging log