r98837 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98836‎ | r98837 | r98838 >
Date:00:00, 4 October 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
[RL2] Implement "create" mode
* New option 'extraquery' in doModifyGadget so that this function can be re-used for gadget creation by only adding two query values.
* Moving some query parameters out of the default data object in doModifyGadget, and making them optional instead (when creating a new gadget, the gadget object will not have a definitiontimestamp)
* New mw.gadgets.api.doCreateGadget method
* Commenting out function body of .mw-gadgets-delete click callback. That way it will not be prevented following by nothing and instead the NS_GADGET_DEFINITION fallback will actually be fallen back to (until the AJAX doDeleteGadget is implemented)
* Add clearGadgetCache and clearCategoryCache to mw.gadgets.api, this is needed to make sure mw.gadgets.api.getGadgetData will return a fresh list of gadgets when doing the availability check in the front-end.
* i18n messages update
Modified paths:
  • /branches/RL2/extensions/Gadgets/Gadgets.i18n.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/Gadgets.php (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.api.js (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.css (modified) (history)
  • /branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.js (modified) (history)

Diff [purge]

Index: branches/RL2/extensions/Gadgets/Gadgets.i18n.php
@@ -73,10 +73,15 @@
7474 # For the ext.gadgets.gadgetmanager module
7575 'gadgets-gadget-create' => 'Create',
7676 'gadgets-gadget-create-tooltip' => 'Create new gadget',
77 - 'gadgetmanager-editor-title' => 'Editing $1:',
 77+ 'gadgetmanager-editor-title-editing' => 'Editing $1:',
 78+ 'gadgetmanager-editor-title-creating' => 'Creating a new gadget',
7879 'gadgetmanager-editor-removeprop-tooltip' => 'Remove this item',
7980 'gadgetmanager-editor-save' => 'Save gadget',
8081 'gadgetmanager-editor-cancel' => 'Cancel',
 82+ 'gadgetmanager-prop-id' => 'Gadget id',
 83+ 'gadgetmanager-prop-id-error-blank' => 'Id cannot be empty.',
 84+ 'gadgetmanager-prop-id-error-illegal' => 'Illegal characters detected.',
 85+ 'gadgetmanager-prop-id-error-taken' => 'A gadget by this id already exists.',
8186 'gadgetmanager-propsgroup-settings' => 'Gadget settings',
8287 'gadgetmanager-propsgroup-module' => 'Module properties',
8388 'gadgetmanager-prop-scripts' => 'Scripts',
@@ -89,6 +94,7 @@
9095 'gadgetmanager-prop-hidden' => 'Hide gadget',
9196 'gadgetmanager-prop-shared' => 'Share gadget',
9297 'gadgetmanager-comment-modify' => 'Modified definition of gadget [[Special:Gadgets/$1|$1]]',
 98+ 'gadgetmanager-comment-create' => 'Created definition of Gadget [[Special:Gadgets/$1|$1]]',
9399
94100 # Validation error messages
95101 'gadget-validate-invalidjson' => 'The gadget definition page contents are not a valid JSON object.',
@@ -163,7 +169,8 @@
164170 * {{mw-msg|create}}',
165171
166172 # For the ext.gadgets.gadgetmanager module
167 - 'gadgetmanager-comment-modify' => 'Edit summary used when editing definitions from [[Special:Gadgets]].',
 173+ 'gadgetmanager-comment-modify' => 'Edit summary used when modifying gadget definition pages through AJAX on [[Special:Gadgets]].',
 174+ 'gadgetmanager-comment-create' => 'Edit summary used when creating gadget definition pages through AJAX on [[Special:Gadgets]].',
168175
169176 # Validation error messages
170177 'gadget-validate-notset' => '$1 is the name of the property, e.g. settings.rights .',
Index: branches/RL2/extensions/Gadgets/Gadgets.php
@@ -171,15 +171,22 @@
172172 'mediawiki.Title',
173173 'jquery.createPropCloud',
174174 'jquery.json',
 175+ 'jquery.spinner',
175176 ),
176177 'messages' => array(
177178 'gadgets-gadget-create',
178179 'gadgets-gadget-create-tooltip',
179 - 'gadgetmanager-editor-title',
 180+ 'gadgetmanager-editor-title-editing',
 181+ 'gadgetmanager-editor-title-creating',
180182 'gadgetmanager-editor-prop-remove',
181183 'gadgetmanager-editor-removeprop-tooltip',
182184 'gadgetmanager-editor-save',
183185 'gadgetmanager-editor-cancel',
 186+ 'gadgetmanager-prop-id',
 187+ 'gadgetmanager-prop-id-error-blank',
 188+ 'gadgetmanager-prop-id-error-illegal',
 189+ 'gadgetmanager-prop-id-error-taken',
 190+ 'colon-separator',
184191 'gadgetmanager-propsgroup-settings',
185192 'gadgetmanager-propsgroup-module',
186193 'gadgetmanager-prop-scripts',
@@ -192,6 +199,7 @@
193200 'gadgetmanager-prop-hidden',
194201 'gadgetmanager-prop-shared',
195202 'gadgetmanager-comment-modify',
 203+ 'gadgetmanager-comment-create',
196204 ),
197205 ),
198206 'ext.gadgets.preferences' => $gadResourceTemplate + array(
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.api.js
@@ -273,7 +273,7 @@
274274 },
275275
276276 /**
277 - * Creates or edits an existing gadget definition.
 277+ * Edits an existing gadget definition.
278278 *
279279 * @param gadget {Object}
280280 * - id {String} Id of the gadget to modify
@@ -284,26 +284,37 @@
285285 * 'edit' action)
286286 * - error {Function} Called with one argument (status from API if availabe,
287287 * otherwise, if the request failed, 'unknown' is given)
 288+ * - extraquery {Object} Query parameters to add or overwrite the default.
288289 * @return {jqXHR}
289290 */
290291 doModifyGadget: function( gadget, o ) {
291292 var t = new mw.Title(
292 - gadget.id + '.js',
293 - mw.config.get( 'wgNamespaceIds' ).gadget_definition
294 - );
295 - return $.ajax({
296 - url: mw.util.wikiScript( 'api' ),
297 - type: 'POST',
298 - data: {
 293+ gadget.id + '.js',
 294+ mw.config.get( 'wgNamespaceIds' ).gadget_definition
 295+ ),
 296+ query = {
299297 format: 'json',
300298 action: 'edit',
301299 title: t.getPrefixedDb(),
302300 text: $.toJSON( gadget.metadata ),
303301 summary: mw.msg( 'gadgetmanager-comment-modify', gadget.id ),
304 - token: mw.user.tokens.get( 'editToken' ),
305 - basetimestamp: gadget.definitiontimestamp,
306 - starttimestamp: o.starttimestamp
307 - },
 302+ token: mw.user.tokens.get( 'editToken' )
 303+ };
 304+ // Optional, only include if passed
 305+ if ( gadget.definitiontimestamp ) {
 306+ query.basetimestamp = gadget.definitiontimestamp;
 307+ }
 308+ if ( o.starttimestamp ) {
 309+ query.starttimestamp = o.starttimestamp;
 310+ }
 311+ // Allow more customization for mw.gadgets.api.doCreateGadget
 312+ if ( o.extraquery ) {
 313+ $.extend( query, o.extraquery );
 314+ }
 315+ return $.ajax({
 316+ url: mw.util.wikiScript( 'api' ),
 317+ type: 'POST',
 318+ data: query,
308319 dataType: 'json',
309320 success: function( data ) {
310321 // Invalidate cache
@@ -329,6 +340,26 @@
330341 },
331342
332343 /**
 344+ * Create a gadget by creating a gadget definition page.
 345+ * Like mw.gadgets.api.doModifyGadget(), but to create a new gadget.
 346+ * Will fail if gadget exists already.
 347+ *
 348+ * @param gadget {Object}
 349+ * - id {String}
 350+ * - metadata {Object}
 351+ * @param o {Object} Additional options
 352+ * @return {jqXHR}
 353+ */
 354+ doCreateGadget: function( gadget, o ) {
 355+ return mw.gadgets.api.doModifyGadget( gadget, $.extend( o, {
 356+ extraquery: {
 357+ createonly: 1,
 358+ summary: mw.msg( 'gadgetmanager-comment-create', gadget.id )
 359+ }
 360+ } ) );
 361+ },
 362+
 363+ /**
333364 * Deletes a gadget definition.
334365 *
335366 * @param id {String} Id of the gadget to delete.
@@ -341,6 +372,19 @@
342373 cacheGadgetData( 'local', id, null );
343374 error( '@todo' );
344375 return null;
 376+ },
 377+
 378+ /**
 379+ * Cache clearing
 380+ * @return {Boolean}
 381+ */
 382+ clearGadgetCache: function() {
 383+ gadgetCache = {};
 384+ return true;
 385+ },
 386+ clearCatgoryCache: function() {
 387+ gadgetCategoryCache = {};
 388+ return true;
345389 }
346390 }
347391 };
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.css
@@ -11,6 +11,8 @@
1212
1313 .mw-gadgetmanager-form table {
1414 width: 100%;
 15+ border-spacing: 0;
 16+ border-collapse: collapse;
1517 }
1618
1719 .mw-gadgetmanager-label {
@@ -20,8 +22,59 @@
2123 .mw-gadgetmanager-form td,
2224 .mw-gadgetmanager-form th {
2325 vertical-align: top;
 26+ padding: 2px;
2427 }
2528
 29+.mw-gadgetmanager-id-wrapper {
 30+ width: 100%;
 31+ margin-bottom: 12px;
 32+}
 33+
 34+.mw-gadgetmanager-id-wrapper label {
 35+ margin-left: 20%;
 36+ display: inline-block;
 37+}
 38+
 39+.mw-gadgetmanager-id {
 40+ margin: 0 5px 0 0;
 41+ padding: 3px;
 42+ border: 1px solid grey;
 43+ background-color: white;
 44+}
 45+
 46+.mw-gadgetmanager-id-available {
 47+ background-color: #E5F6E5;
 48+}
 49+
 50+.mw-gadgetmanager-id-invalid {
 51+ background-color: #F6E5E5;
 52+}
 53+
 54+.mw-gadgetmanager-id-taken {
 55+ background-color: #E5EFF6;
 56+}
 57+
 58+.mw-gadgetmanager-id.disabled {
 59+ background-color: #F6F6F6;
 60+ border-color: lightgrey;
 61+}
 62+
 63+.mw-gadgetmanager-id input {
 64+ margin: 0;
 65+ padding: 0;
 66+ display: inline-block;
 67+ width: 30%;
 68+ border: 0;
 69+ outline: 0;
 70+ background: transparent;
 71+}
 72+
 73+.mw-gadgetmanager-id-error {
 74+ display: none;
 75+ color: #FF4040;
 76+ font-style: italic;
 77+}
 78+
2679 /**
2780 * Gadget list
2881 */
@@ -33,9 +86,10 @@
3487 * The PropCloud
3588 */
3689 .mw-gadgetmanager-propcloud {
 90+ overflow: hidden;
 91+ padding: 3px;
 92+ border: 1px solid grey;
3793 background: white;
38 - border: 1px solid grey;
39 - overflow: hidden;
4094 }
4195
4296 .mw-gadgetmanager-prop {
@@ -68,6 +122,8 @@
69123
70124 .mw-gadgetmanager-propinput,
71125 .mw-gadgetmanager-propinput:focus {
 126+ margin: 0;
 127+ padding: 0;
72128 border: 0;
73129 outline: 0;
74130 background: transparent;
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.js
@@ -18,6 +18,11 @@
1919 tpl = {
2020 fancyForm: '<form class="mw-gadgetmanager-form">\
2121 <fieldset>\
 22+ <div class="mw-gadgetmanager-id-wrapper">\
 23+ <label for="mw-gadgetmanager-input-id"><html:msg key="gadgetmanager-prop-id" /><html:msg key="colon-separator" /></label>\
 24+ <span class="mw-gadgetmanager-id"><input type="text" id="mw-gadgetmanager-input-id" /></span>\
 25+ <span class="mw-gadgetmanager-id-error"></span>\
 26+ </div>\
2227 <legend><html:msg key="gadgetmanager-propsgroup-module" /></legend>\
2328 <table>\
2429 <tr>\
@@ -116,6 +121,24 @@
117122 + pad( d.getUTCMinutes() ) + ':'
118123 + pad( d.getUTCSeconds() ) + 'Z';
119124 }
 125+ /**
 126+ * Validate a gadget id, which must be a valid
 127+ * title, as well as a valid module name.
 128+ * @param id {String}
 129+ * @return {Boolean}
 130+ */
 131+ function validateGadgetId( id ) {
 132+ return id.length
 133+ && new mw.Title( id, mw.config.get( 'wgNamespaceIds' ).gadget_definition ).getMainText() === id;
 134+ }
 135+ /**
 136+ * Toggle the state of the UI buttons in a dialog.
 137+ * @param $dialog {jQuery.ui.widget from jquery.ui.dialog}
 138+ * @param state {String} 'enable' or 'disable' (defaults to disable)
 139+ */
 140+ function toggleDialogButtons( $form, state ) {
 141+ $form.dialog( 'widget' ).find( 'button' ).button( state );
 142+ }
120143
121144 /* Public functions */
122145
@@ -131,12 +154,14 @@
132155 if ( ga.conf.userIsAllowed['gadgets-definition-edit'] ) {
133156 $el.find( '.mw-gadgets-modify' ).click( function( e ) {
134157 e.preventDefault();
135 - ga.ui.startGadgetEditor( $el.data( 'gadget-id' ) );
 158+ e.stopPropagation(); // To stop bubbling up to .mw-gadgets-gadget
 159+ ga.ui.startGadgetManager( 'modify', $el.data( 'gadget-id' ) );
136160 });
137161 }
138162 if ( ga.conf.userIsAllowed['gadgets-definition-delete'] ) {
139 - $el.find( '.mw-gadgets-modify' ).click( function( e ) {
140 - e.preventDefault();
 163+ $el.find( '.mw-gadgets-delete' ).click( function( e ) {
 164+ //e.preventDefault();
 165+ //e.stopPropagation();
141166 // @todo: Show delete action form
142167 });
143168 }
@@ -145,11 +170,12 @@
146171 // Entire gadget list item is clickable
147172 $( '.mw-gadgets-gadget' ).click( function( e ) {
148173 e.preventDefault();
 174+ e.stopPropagation();
149175 var t,
150176 id = $( this ).data( 'gadget-id' );
151177
152178 if ( ga.conf.userIsAllowed['gadgets-definition-edit'] ) {
153 - ga.ui.startGadgetEditor( id );
 179+ ga.ui.startGadgetManager( id );
154180 return;
155181 }
156182 // Use localized page name if possible to avoid redirect
@@ -159,7 +185,6 @@
160186 t = new mw.Title( 'Gadgets/' + id, -1 );
161187 }
162188 window.location.href = t.getUrl();
163 - return false;
164189 } );
165190
166191 if ( ga.conf.userIsAllowed['gadgets-definition-create'] ) {
@@ -175,42 +200,69 @@
176201 );
177202 $( createTab ).click( function( e ) {
178203 e.preventDefault();
179 - // @todo: Trigger edit form with editable field for gadget id.
 204+ ga.ui.startGadgetManager( 'create' );
180205 } );
181206 }
182207
183208 },
184209
185210 /**
186 - * Initialize the gadget editor dialog.
 211+ * Initialize the gadget manager dialog.
187212 *
188213 * @asynchronous
 214+ * @param mode {String} (See mw.gadgets.ui.getFancyForm)
189215 * @param gadgetId {String}
190216 */
191 - startGadgetEditor: function( gadgetId ) {
 217+ startGadgetManager: function( mode, gadgetId ) {
 218+
192219 // Ad hoc multi-loader. We need both requests, which are asynchronous,
193220 // to be complete. Which ever finishes first will set the local variable
194221 // to it's return value for the other callback to use.
195222 // @todo Notification: In case of an 'error'.
196223 var gadget, cats;
197224
 225+
 226+ if ( mode === 'create' ) {
 227+ // New gadget, no need to query the api
 228+ gadget = {
 229+ id: undefined,
 230+ metadata: {
 231+ settings: {
 232+ rights: [],
 233+ 'default': false,
 234+ hidden: false,
 235+ shared: false,
 236+ category: ''
 237+ },
 238+ module: {
 239+ scripts: [],
 240+ styles: [],
 241+ dependencies: [],
 242+ messages: []
 243+ }
 244+ },
 245+ definitiontimestamp: undefined,
 246+ title: undefined
 247+ };
 248+ } else {
 249+ ga.api.getGadgetData( gadgetId, function( ret ) {
 250+ if ( cats ) {
 251+ // getGadgetCategories already done
 252+ return ga.ui.showFancyForm( ret, cats, mode );
 253+ }
 254+ // getGadgetCategories not done yet, leave gadget for it's callback to use
 255+ gadget = ret;
 256+ });
 257+ }
 258+
198259 ga.api.getGadgetCategories( function( ret ) {
199260 if ( gadget ) {
200261 // getGadgetData already done
201 - return ga.ui.showFancyForm( gadget, ret );
 262+ return ga.ui.showFancyForm( gadget, ret, mode );
202263 }
203264 // getGadgetData not done yet, leave cats for it's callback to use
204265 cats = ret;
205266 });
206 -
207 - ga.api.getGadgetData( gadgetId, function( ret ) {
208 - if ( cats ) {
209 - // getGadgetCategories already done
210 - return ga.ui.showFancyForm( ret, cats );
211 - }
212 - // getGadgetCategories not done yet, leave gadget for it's callback to use
213 - gadget = ret;
214 - });
215267 },
216268
217269 /**
@@ -218,25 +270,41 @@
219271 *
220272 * @param gadget {Object} Gadget object of the gadget to be modified.
221273 * @param categories {Array} Gadget categories.
 274+ * @param mode {String} (See mw.gadgets.ui.getFancyForm)
222275 * @return {jQuery} The (dialogged) form.
223276 */
224 - showFancyForm: function( gadget, categories ) {
225 - var $form = ga.ui.getFancyForm( gadget.metadata, categories ),
 277+ showFancyForm: function( gadget, categories, mode ) {
 278+ var $form = ga.ui.getFancyForm( gadget, categories, mode ),
226279 buttons = {};
227280
228281 // Form submit
229282 buttons[mw.msg( 'gadgetmanager-editor-save' )] = function() {
230 - ga.api.doModifyGadget( gadget, {
231 - starttimestamp: ISODateString( new Date() ),
232 - success: function( response ) {
233 - $form.dialog( 'close' );
234 - window.location.reload();
235 - },
236 - error: function( error ) {
237 - mw.log( 'mw.gadgets.api.doModifyGadget: error', error );
238 - // @todo Notification: $formNotif.add( .. );
239 - }
240 - });
 283+ if ( mode === 'create' ) {
 284+ ga.api.doCreateGadget( gadget, {
 285+ success: function( response ) {
 286+ mw.log( 'mw.gadgets.api.doModifyGadget: success', arguments );
 287+ $form.dialog( 'close' );
 288+ window.location.reload();
 289+ },
 290+ error: function( error ) {
 291+ mw.log( 'mw.gadgets.api.doModifyGadget: error', arguments );
 292+ // @todo Notification: $formNotif.add( .. );
 293+ }
 294+ });
 295+ } else {
 296+ ga.api.doModifyGadget( gadget, {
 297+ starttimestamp: ISODateString( new Date() ),
 298+ success: function( response ) {
 299+ mw.log( 'mw.gadgets.api.doModifyGadget: success', arguments );
 300+ $form.dialog( 'close' );
 301+ window.location.reload();
 302+ },
 303+ error: function( error ) {
 304+ mw.log( 'mw.gadgets.api.doModifyGadget: error', arguments );
 305+ // @todo Notification: $formNotif.add( .. );
 306+ }
 307+ });
 308+ }
241309 };
242310
243311 return $form
@@ -246,7 +314,9 @@
247315 modal: true,
248316 draggable: false,
249317 resizable: false,
250 - title: mw.message( 'gadgetmanager-editor-title', gadget.title ).escaped(),
 318+ title: mode === 'create'
 319+ ? mw.message( 'gadgetmanager-editor-title-creating' ).escaped()
 320+ : mw.message( 'gadgetmanager-editor-title-editing', gadget.title ).escaped(),
251321 buttons: buttons,
252322 open: function() {
253323 // Dialog is ready for action.
@@ -262,15 +332,92 @@
263333 * Generate a <form> for the given module.
264334 * Also binds events for submission and autocompletion.
265335 *
266 - * @param metadata {Object} Object to read and write to, used when saving
267 - * the gadget metadata back through the API.
 336+ * @param gadget {Object} Gadget object to read from and write to, used when saving
 337+ * the gadget metadata to the API.
268338 * @param categories {Array} Gadget categories.
 339+ * @param mode {String} (optional) 'create' or 'modify' (defaults to 'modify')
269340 * @return {jQuery} The form.
270341 */
271 - getFancyForm: function( metadata, categories ) {
 342+ getFancyForm: function( gadget, categories, mode ) {
272343 var nsGadgetId = mw.config.get( 'wgNamespaceIds' ).gadget,
273 - $form = $( tpl.fancyForm ).localize();
 344+ metadata = gadget.metadata,
 345+ $form = $( tpl.fancyForm ).localize(),
 346+ $idSpan = $form.find( '.mw-gadgetmanager-id' ),
 347+ $idErrMsg = $form.find( '.mw-gadgetmanager-id-error' );
274348
 349+ if ( mode === 'create' ) {
 350+
 351+ // Validate
 352+ $form.find( '#mw-gadgetmanager-input-id' ).bind( 'keyup keypress keydown', function( e ) {
 353+ var val = $(this).val();
 354+
 355+ // Reset
 356+ toggleDialogButtons( $form, 'enable' );
 357+ $idSpan.removeClass( 'mw-gadgetmanager-id-invalid mw-gadgetmanager-id-available mw-gadgetmanager-id-taken' );
 358+
 359+ // Abort if empty, don't warn when user is still typing,
 360+ // The onblur event handler takes care of that
 361+ if ( !val.length ) {
 362+ $idErrMsg.hide(); // Just in case
 363+ return;
 364+ }
 365+
 366+ // Auto-correct trim if needed (leading/tailing spaces are invalid)
 367+ // No need to raise errors just for that.
 368+ if ( $.trim( val ) !== val ) {
 369+ val = $.trim( val );
 370+ $el.val( val );
 371+ }
 372+
 373+ if ( validateGadgetId( val ) ) {
 374+ gadget.id = val;
 375+ $idErrMsg.hide();
 376+ } else {
 377+ toggleDialogButtons( $form, 'disable' );
 378+ $idSpan.addClass( 'mw-gadgetmanager-id-invalid' );
 379+ $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-illegal' ) ).show();
 380+ }
 381+
 382+ // Availability and non-empty check
 383+ }).blur( function( e ) {
 384+ var val = $(this).val();
 385+
 386+ // Reset
 387+ $idSpan.removeClass( 'mw-gadgetmanager-id-invalid mw-gadgetmanager-id-available mw-gadgetmanager-id-taken' );
 388+ toggleDialogButtons( $form, 'enable' );
 389+
 390+ if ( !val.length ) {
 391+ toggleDialogButtons( $form, 'disable' );
 392+ $idSpan.addClass( 'mw-gadgetmanager-id-invalid' );
 393+ $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-blank' ) ).show();
 394+ return;
 395+ }
 396+
 397+ ga.api.clearGadgetCache();
 398+
 399+ // asynchronous from here, show loading
 400+ $idSpan.addClass( 'ui-autocomplete-loading' );
 401+
 402+ ga.api.getGadgetData( null, function( data ) {
 403+ $idSpan.removeClass( 'ui-autocomplete-loading' );
 404+ if ( val in data ) {
 405+ toggleDialogButtons( $form, 'disable' );
 406+ $idSpan.addClass( 'mw-gadgetmanager-id-taken' );
 407+ $idErrMsg.text( mw.msg( 'gadgetmanager-prop-id-error-taken' ) ).show();
 408+ } else {
 409+ $idSpan.addClass( 'mw-gadgetmanager-id-available' );
 410+ $idErrMsg.hide();
 411+ }
 412+ });
 413+ });
 414+
 415+
 416+ } else {
 417+ $form.find( '.mw-gadgetmanager-id input' ).val( gadget.id ).prop( 'disabled', true );
 418+ $idSpan.addClass( 'disabled' );
 419+ }
 420+
 421+
275422 // Module properties: scripts
276423 $form.find( '#mw-gadgetmanager-input-scripts' ).createPropCloud({
277424 props: metadata.module.scripts,

Follow-up revisions

RevisionCommit summaryAuthorDate
r98858RL2: Fix typo in r98837catrope14:35, 4 October 2011

Comments

#Comment by Catrope (talk | contribs)   11:03, 4 October 2011
+						success: function( response ) {
+							mw.log( 'mw.gadgets.api.doModifyGadget: success', arguments );
+							$form.dialog( 'close' );
+							window.location.reload();
+						},
+						error: function( error ) {
+							mw.log( 'mw.gadgets.api.doModifyGadget: error', arguments );
+							// @todo Notification: $formNotif.add( .. );
+						}

You shouldn't duplicate the success and error callbacks here. Store them in a local variable or something.

OK otherwise, marking as such.

Status & tagging log