r106003 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106002‎ | r106003 | r106004 >
Date:10:26, 13 December 2011
Author:neilk
Status:ok (Comments)
Tags:
Comment:
change args for feedback and api -- all optional, in array.
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.api.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.feedback.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.api.js
@@ -12,15 +12,21 @@
1313 * can override the parameter defaults and ajax default options.
1414 * XXX document!
1515 *
 16+ * TODO share api objects with exact same config.
 17+ *
1618 * ajax options can also be overriden on every get() or post()
1719 *
1820 * @param options {Mixed} can take many options, but must include at minimum the API url.
1921 */
2022 mw.Api = function( options ) {
2123
 24+ if ( options === undefined ) {
 25+ options = {};
 26+ }
 27+
2228 // make sure we at least have a URL endpoint for the API
2329 if ( options.url === undefined ) {
24 - throw new Error( 'Configuration error - needs url property' );
 30+ options.url = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' );
2531 }
2632
2733 this.url = options.url;
Index: trunk/phase3/resources/mediawiki/mediawiki.feedback.js
@@ -31,18 +31,32 @@
3232
3333 /**
3434 * Thingy for collecting user feedback on a wiki page
35 - * @param {mw.api} api properly configured to talk to this wiki
36 - * @param {mw.Title} the title of the page where you collect feedback
37 - * @param {String} optional - message key for the title of the dialog box
 35+ * @param {Array} options -- optional, all properties optional.
 36+ * api: {mw.Api} if omitted, will just create a standard API
 37+ * title: {mw.Title} the title of the page where you collect feedback. Defaults to "Feedback".
 38+ * dialogTitleMessageKey: {String} message key for the title of the dialog box
3839 */
39 - mw.Feedback = function( api, feedbackTitle, dialogTitleMessageKey ) {
40 - var _this = this;
41 - this.api = api;
42 - this.feedbackTitle = feedbackTitle;
43 - this.dialogTitleMessageKey = dialogTitleMessageKey;
44 - if ( this.dialogTitleMessageKey === undefined ) {
45 - this.dialogTitleMessageKey = 'feedback-submit';
 40+ mw.Feedback = function( options ) {
 41+
 42+ if ( options === undefined ) {
 43+ options = {};
4644 }
 45+
 46+ if ( options.api === undefined ) {
 47+ options.api = new mw.Api();
 48+ }
 49+
 50+ if ( options.title === undefined ) {
 51+ options.title = new mw.Title( 'Feedback' );
 52+ }
 53+
 54+ if ( options.dialogTitleMessageKey === undefined ) {
 55+ options.dialogTitleMessageKey = 'feedback-submit';
 56+ }
 57+
 58+ this.api = options.api;
 59+ this.feedbackTitle = options.title;
 60+ this.dialogTitleMessageKey = options.dialogTitleMessageKey;
4761 this.setup();
4862 };
4963

Follow-up revisions

RevisionCommit summaryAuthorDate
r106062merging extensions/VisualEditor....neilk18:47, 13 December 2011
r107011[mediawiki.api] clean up...krinkle23:52, 21 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r105972add feedback link to visual editorneilk02:46, 13 December 2011

Comments

#Comment by Catrope (talk | contribs)   18:02, 13 December 2011
+			options.url = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' );

Why not use mw.util.wikiScript( 'api' ) ?

#Comment by Krinkle (talk | contribs)   23:57, 21 December 2011

Done in r107011.

Status & tagging log