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 @@ |
77 | 77 | ), |
78 | 78 | 'position' => 'bottom', |
79 | 79 | ); |
| 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 @@ |
17 | 17 | * Determines whether or not we should show the MoodBar. |
18 | 18 | */ |
19 | 19 | public static function shouldShowMoodbar( &$output, &$skin ) { |
20 | | - |
21 | 20 | if ( |
22 | 21 | // Front-end appends to header elements, which have different |
23 | 22 | // locations and IDs in every skin. |