Index: branches/RL2/extensions/Gadgets/SpecialGadgetManager.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | // There is atleast one gadget, let's get started. |
61 | | - $this->getOutput()->addWikiMsg( 'gadgetmanager-pagetext' ); |
| 61 | + $this->getOutput()->addWikiMsg( 'gadgetmanager-pagetext', SpecialPage::getTitleFor( 'Recentchanges' )->getFullURL('namespace=' . NS_GADGET_DEFINITION ) ); |
62 | 62 | $html = ''; |
63 | 63 | |
64 | 64 | // Sort categories alphabetically |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Start per-category gadgets table |
84 | | - $html .= '<table class="mw-gadgetmanager-gadgets mw-datatable"><tr>'; |
| 84 | + $html .= '<table class="mw-gadgetmanager-gadgets mw-datatable sortable"><thead><tr>'; |
85 | 85 | $html .= |
86 | 86 | '<th>' . wfMessage( 'gadgetmanager-tablehead-title' )->escaped() |
87 | 87 | . '</th><th>' . wfMessage( 'gadgetmanager-tablehead-default' )->escaped() |
— | — | @@ -89,7 +89,8 @@ |
90 | 90 | if ( $wgGadgetEnableSharing ) { |
91 | 91 | $html .= '<th>' . wfMessage( 'gadgetmanager-tablehead-shared' )->escaped() . '</th>'; |
92 | 92 | } |
93 | | - $html .= '<th>' . wfMessage( 'gadgetmanager-tablehead-lastmod' )->escaped() . '</th></tr>'; |
| 93 | + $html .= '<th>' . wfMessage( 'gadgetmanager-tablehead-lastmod' )->escaped() . '</th>'; |
| 94 | + $html .= '</tr></thead><tbody>'; |
94 | 95 | |
95 | 96 | // Populate table rows for the current category |
96 | 97 | foreach ( $gadgets as $gadgetId => $gadget ) { |
— | — | @@ -151,14 +152,14 @@ |
152 | 153 | ) |
153 | 154 | ); |
154 | 155 | } |
155 | | - $html .= "<td>$lastModText</td>"; |
| 156 | + $html .= "<td class=\"mw-gadgetmanager-gadgets-lastmod\">$lastModText</td>"; |
156 | 157 | } |
157 | 158 | |
158 | 159 | $html .= '</tr>'; |
159 | 160 | } |
160 | 161 | |
161 | 162 | // End of per-category gadgets table |
162 | | - $html .= '</table>'; |
| 163 | + $html .= '</tbody></table>'; |
163 | 164 | } |
164 | 165 | |
165 | 166 | return $html; |
Index: branches/RL2/extensions/Gadgets/Gadgets.i18n.php |
— | — | @@ -27,11 +27,11 @@ |
28 | 28 | Administrators manage to the [[Special:GadgetManager|gadget definitions]] and the [[Special:Gadgets|titles and descriptions]] of available gadgets.', |
29 | 29 | 'gadgets-preference-description' => '$1: $2', |
30 | 30 | |
31 | | - # For Special:Gadgets (overview for users and people with editinterface) |
| 31 | + # For Special:Gadgets (overview for users; titles, messages, description, exporting etc.) |
32 | 32 | 'gadgets' => 'Gadgets', |
33 | 33 | 'gadgets-title' => 'Gadgets', |
34 | | - 'gadgets-pagetext' => "Below is a list of special gadgets users can enable on their [[Special:Preferences#mw-prefsection-gadgets|preferences page]], as defined by the [[MediaWiki:Gadgets-definition|definitions]]. |
35 | | -This overview provides easy access to the system message pages that define each gadget's description and code.", |
| 34 | + 'gadgets-pagetext' => "Below is a list of gadgets available on this wiki. Users can enable or disable these through their [[Special:Preferences#mw-prefsection-gadgets|preferences page]]. |
| 35 | +This overview provides easy access to the system message pages that define each gadget's description and title.", |
36 | 36 | 'gadgets-uses' => 'Uses', |
37 | 37 | 'gadgets-required-rights' => 'Requires the {{PLURAL:$2|$1 right|following rights: $1}}.', |
38 | 38 | 'gadgets-default' => 'Enabled for everyone by default.', |
— | — | @@ -39,15 +39,13 @@ |
40 | 40 | 'gadgets-export-title' => 'Gadget export', |
41 | 41 | 'gadgets-not-found' => 'Gadget "$1" not found.', |
42 | 42 | 'gadgets-export-text' => 'To export the $1 gadget, click on "{{int:gadgets-export-download}}" button, save the downloaded file, |
43 | | -go to Special:Import on destination wiki and upload it. Then add the following to MediaWiki:Gadgets-definition page: |
44 | | -<pre>$2</pre> |
45 | | -You must have appropriate permissions on destination wiki (including the right to edit system messages) and import from file uploads must be enabled.', |
| 43 | +go to Special:Import on destination wiki and upload it. You must have appropriate permissions on the destination wiki (including the right to edit in the {{ns:Gadget}} and {{ns:Gadget definition}} namespaces) and the import from file uploads must be enabled.', |
46 | 44 | 'gadgets-export-download' => 'Download', |
47 | 45 | |
48 | | - # For Special:GadgetManager (for gadget meta-data management) |
| 46 | + # For Special:GadgetManager (for gadget definition management) |
49 | 47 | 'gadgetmanager' => 'Gadget manager', |
50 | | - 'gadgetmanager-title' => 'Gadget manager', |
51 | | - 'gadgetmanager-pagetext' => 'Below is an overview of all gadgets defined on this wiki. Users can opt in or opt out of these through their [[Special:Preferences#mw-prefsection-gadgets|preferences page]].', |
| 48 | + 'gadgetmanager-title' => 'Gadget management', |
| 49 | + 'gadgetmanager-pagetext' => 'Welcome to the gadget management interface. Below is an overview of all gadgets defined on this wiki. Users can opt in or opt out of these through their [[Special:Preferences#mw-prefsection-gadgets|preferences page]]. All modifications to gadget definitions can be followed in the [$1 recent changes].', |
52 | 50 | 'gadgetmanager-nogadgets' => 'This wiki currently has no gadgets defined.', |
53 | 51 | 'gadgetmanager-uncategorized' => 'Uncategorized', |
54 | 52 | 'gadgetmanager-tablehead-title' => 'Gadget title', |
— | — | @@ -74,10 +72,7 @@ |
75 | 73 | 'gadgetmanager-prop-default-yes' => 'This gadget is loaded by default.', |
76 | 74 | 'gadgetmanager-prop-hidden-yes' => 'This is a hidden gadget.', |
77 | 75 | 'gadgetmanager-prop-shared-yes' => 'This gadget is shared.', |
78 | | - 'gadgetmanager-modifylink' => 'modify', |
79 | | - 'gadgetmanager-modifylink-tooltip' => 'Modify this gadget', |
80 | | - 'gadgetmanager-deletelink' => 'delete', |
81 | | - 'gadgetmanager-deletelink-tooltip' => 'Delete ths gadget', |
| 76 | + 'gadgetmanager-comment-modify' => 'Modified definition of gadget [[Special:GadgetManager/$1|$1]]', |
82 | 77 | |
83 | 78 | # Validation error messages |
84 | 79 | 'gadget-validate-invalidjson' => 'The gadget definition page contents are not a valid JSON object.', |
— | — | @@ -108,17 +103,22 @@ |
109 | 104 | * @author Timo Tijhof |
110 | 105 | */ |
111 | 106 | $messages['qqq'] = array( |
| 107 | + # For Special:Version |
| 108 | + 'gadgets' => '{{Identical|Gadgets}}', |
112 | 109 | 'gadgets-desc' => '{{desc}}', |
| 110 | + |
| 111 | + # For Special:Preferences |
113 | 112 | 'prefs-gadgets' => 'In Gadgets extension. The name of a tab in [[Special:Preferences]] where user set their preferences for the extension. |
114 | 113 | |
115 | 114 | {{Identical|Gadgets}}', |
116 | 115 | 'gadgets-prefstext' => 'In Gadgets extension. This is the explanation text displayed under the Gadgets tab in [[Special:Preferences]].', |
117 | 116 | 'gadgets-preference-description' => 'Used for the description HTML of a Gadget in Special:Preferences. $1 is the title of the Gadget, $2 is the description of the Gadget.', |
118 | | - 'gadgets' => '{{Identical|Gadgets}}', |
| 117 | + |
| 118 | + # For Special:Gadgets |
119 | 119 | 'gadgets-title' => '{{Identical|Gadgets}}', |
120 | 120 | 'gadgets-uses' => "This is used as a verb in third-person singular. It appears in front of a script name. Example: \"''Uses: Gadget-UTCLiveClock.js''\" |
121 | 121 | |
122 | | -See [http://meta.wikimedia.org/wiki/Special:Gadgets Gadgets page in meta.wikimedia.org]", |
| 122 | +See [http://mediawiki.org/wiki/Special:Gadgets Gadgets overview on mediawiki.org]", |
123 | 123 | 'gadgets-required-rights' => 'Parameters: |
124 | 124 | * $1 - a list. |
125 | 125 | * $2 - the number of items in list $1 for PLURAL use.', |
— | — | @@ -126,17 +126,29 @@ |
127 | 127 | {{Identical|Export}}', |
128 | 128 | 'gadgets-export-download' => 'Use the verb for this message. Submit button. |
129 | 129 | {{Identical|Download}}', |
130 | | - 'gadgetmanager-tablehead-lastmodified' => '{{Identical|Last modified}}', |
| 130 | + |
| 131 | + # Validation error messages |
| 132 | + 'gadget-validate-notset' => '$1 is the name of the property, e.g. settings.rights .', |
| 133 | + 'gadget-validate-wrongtype' => '* $1 is the name of the property, e.g. settings.rights or module.messages[3]. |
| 134 | +* $2 is the type that this property is expected to have |
| 135 | +* $3 is the type it actually had', |
| 136 | + |
| 137 | + # For Special:GadgetManager |
| 138 | + 'gadgetmanager-tablehead-lastmodified' => '{{Identical|Last modified}} |
| 139 | +{{Output|plain}}', |
131 | 140 | 'gadgetmanager-tablecell-lastmod' => 'This message is used on Special:GadgetManager to indicate the last modified date, time and user for gadget definitions. |
132 | 141 | * $1 is a time and date (duplicated in $3 and $4) |
133 | 142 | * $2 is a link to a user page with a user name as link text, followed by a series of related links |
134 | 143 | * $3 is the date |
135 | 144 | * $4 is the time |
136 | 145 | * $5 is the user name which can be used with GENDER', |
137 | | - 'gadget-validate-notset' => '$1 is the name of the property, e.g. settings.rights .', |
138 | | - 'gadget-validate-wrongtype' => '* $1 is the name of the property, e.g. settings.rights or module.messages[3]. |
139 | | -* $2 is the type that this property is expected to have |
140 | | -* $3 is the type it actually had', |
| 146 | + 'gadgetmanager-comment-modify' => 'Edit summary used when editing definitions from [[Special:GadgetManager]].', |
| 147 | + |
| 148 | + # User rights |
| 149 | + 'right-gadgets-edit' => '{{doc-right}}', |
| 150 | + 'right-gadgets-definition-create' => '{{doc-right}}', |
| 151 | + 'right-gadgets-definition-delete' => '{{doc-right}}', |
| 152 | + 'right-gadgets-definition-edit' => '{{doc-right}}', |
141 | 153 | ); |
142 | 154 | |
143 | 155 | /** Afrikaans (Afrikaans) |
Index: branches/RL2/extensions/Gadgets/Gadgets.php |
— | — | @@ -166,12 +166,15 @@ |
167 | 167 | 'jquery.ui.dialog', |
168 | 168 | 'mediawiki.Title', |
169 | 169 | 'jquery.createPropCloud', |
| 170 | + 'jquery.json', |
170 | 171 | ), |
171 | 172 | 'messages' => array( |
172 | 173 | 'gadgetmanager-editor-title', |
173 | 174 | 'gadgetmanager-editor-removeprop-tooltip', |
174 | 175 | 'gadgetmanager-editor-save', |
175 | 176 | 'gadgetmanager-editor-cancel', |
| 177 | + 'gadgetmanager-propsgroup-settings', |
| 178 | + 'gadgetmanager-propsgroup-module', |
176 | 179 | 'gadgetmanager-prop-scripts', |
177 | 180 | 'gadgetmanager-prop-styles', |
178 | 181 | 'gadgetmanager-prop-dependencies', |
— | — | @@ -181,6 +184,7 @@ |
182 | 185 | 'gadgetmanager-prop-default', |
183 | 186 | 'gadgetmanager-prop-hidden', |
184 | 187 | 'gadgetmanager-prop-shared', |
| 188 | + 'gadgetmanager-comment-modify', |
185 | 189 | ), |
186 | 190 | ), |
187 | 191 | ); |
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.api.js |
— | — | @@ -56,14 +56,15 @@ |
57 | 57 | * Get gadget blob from the API (or from cache if available). |
58 | 58 | * |
59 | 59 | * @param id {String} Gadget id. |
60 | | - * @param callback {Function} To be called with an object as first argument, |
61 | | - * and status as second argument (success or error). |
| 60 | + * @param success {Function} To be called with the gadget object as first argument. |
| 61 | + * @param error {Fucntion} If something went wrong (inexisting gadget, api |
| 62 | + * error, request error), this is called with error code as first argument. |
62 | 63 | * @return {jqXHR|Null}: Null if served from cache, otherwise the jqXHR. |
63 | 64 | */ |
64 | | - getGadgetMetadata: function( id, callback ) { |
| 65 | + getGadgetData: function( id, success, error ) { |
65 | 66 | // Check cache |
66 | 67 | if ( id in gadgetCache && gadgetCache[id] !== null ) { |
67 | | - callback( objClone( gadgetCache[id] ), 'success' ); |
| 68 | + success( objClone( gadgetCache[id] ) ); |
68 | 69 | return null; |
69 | 70 | } |
70 | 71 | // Get from API if not cached |
— | — | @@ -73,7 +74,7 @@ |
74 | 75 | format: 'json', |
75 | 76 | action: 'query', |
76 | 77 | list: 'gadgets', |
77 | | - gaprop: 'id|metadata|desc', |
| 78 | + gaprop: 'id|title|metadata|definitiontimestamp', |
78 | 79 | gaids: id, |
79 | 80 | galanguage: mw.config.get( 'wgUserLanguage' ) |
80 | 81 | }, |
— | — | @@ -81,27 +82,30 @@ |
82 | 83 | dataType: 'json', |
83 | 84 | success: function( data ) { |
84 | 85 | if ( data && data.query && data.query.gadgets && data.query.gadgets[0] ) { |
85 | | - data = data.query.gadgets[0].metadata; |
| 86 | + data = data.query.gadgets[0]; |
86 | 87 | // Update cache |
87 | 88 | gadgetCache[id] = data; |
88 | | - callback( objClone( data ), 'success' ); |
| 89 | + success( objClone( data ) ); |
89 | 90 | } else { |
90 | 91 | // Invalidate cache |
91 | 92 | gadgetCache[id] = null; |
92 | | - callback( {}, 'error' ); |
| 93 | + if ( data && data.error ) { |
| 94 | + error( data.error.code ); |
| 95 | + } else { |
| 96 | + error( 'unknown' ); |
| 97 | + } |
93 | 98 | } |
94 | 99 | }, |
95 | 100 | error: function() { |
96 | 101 | // Invalidate cache |
97 | 102 | gadgetCache[id] = null; |
98 | | - callback( {}, 'error' ); |
| 103 | + error( 'unknown' ); |
99 | 104 | } |
100 | 105 | }); |
101 | 106 | }, |
102 | 107 | |
103 | 108 | /** |
104 | | - * @param callback {Function} To be called with an array as first argument, |
105 | | - * and status as second argument (success or error). |
| 109 | + * @param callback {Function} To be called with an array as first argument. |
106 | 110 | * @return {jqXHR|Null}: Null if served from cache, otherwise the jqXHR. |
107 | 111 | */ |
108 | 112 | getGadgetCategories: function( callback ) { |
— | — | @@ -133,13 +137,13 @@ |
134 | 138 | } else { |
135 | 139 | // Invalidate cache |
136 | 140 | gadgetCategoryCache = null; |
137 | | - callback( [], 'error' ); |
| 141 | + callback( [] ); |
138 | 142 | } |
139 | 143 | }, |
140 | 144 | error: function() { |
141 | 145 | // Invalidate cache |
142 | 146 | gadgetCategoryCache = null; |
143 | | - callback( [], 'error' ); |
| 147 | + callback( [] ); |
144 | 148 | } |
145 | 149 | }); |
146 | 150 | }, |
— | — | @@ -149,22 +153,56 @@ |
150 | 154 | * |
151 | 155 | * @param gadget {Object} |
152 | 156 | * - id {String} Id of the gadget to modify |
153 | | - * - blob {Object} Gadget meta data |
154 | | - * @param callback {Function} Called with two arguments: |
155 | | - * - status ('ok' or 'error') |
156 | | - * - msg (localized, something like "Successful", "Conflict occurred" etc.) |
157 | | - * @return {jqXHR|Null}: Null if served from cache, otherwise the jqXHR. |
| 157 | + * - metadata {Object} Gadget meta data |
| 158 | + * @param o {Object} Additional options: |
| 159 | + * - starttimestamp {String} ISO_8601 timestamp of when user started editing |
| 160 | + * - success {Function} Called with one argument (API response object of the |
| 161 | + * 'edit' action) |
| 162 | + * - error {Function} Called with one argument (status from API if availabe, |
| 163 | + * otherwise, if the request failed, 'unknown' is given) |
| 164 | + * @return {jqXHR} |
158 | 165 | */ |
159 | | - doModifyGadget: function( gadget, callback ) { |
160 | | - mw.log( gadget ); |
161 | | - // @todo |
162 | | - // Get token |
163 | | - // JSON.stringify |
164 | | - // Do with ApiEdit |
165 | | - // Invalidate cache |
166 | | - gadgetCache[gadget.id] = null; |
167 | | - callback( 'error', '@todo: Saving not implemented yet. Check console for object that would be saved.' ); |
168 | | - return null; |
| 166 | + doModifyGadget: function( gadget, o ) { |
| 167 | + var t = new mw.Title( |
| 168 | + gadget.id + '.js', |
| 169 | + mw.config.get( 'wgNamespaceIds' ).gadget_definition |
| 170 | + ); |
| 171 | + return $.ajax({ |
| 172 | + url: mw.util.wikiScript( 'api' ), |
| 173 | + type: 'POST', |
| 174 | + data: { |
| 175 | + format: 'json', |
| 176 | + action: 'edit', |
| 177 | + title: t.getPrefixedDb(), |
| 178 | + text: $.toJSON( gadget.metadata ), |
| 179 | + summary: mw.msg( 'gadgetmanager-comment-modify', gadget.id ), |
| 180 | + token: mw.user.tokens.get( 'editToken' ), |
| 181 | + basetimestamp: gadget.definitiontimestamp, |
| 182 | + starttimestamp: o.starttimestamp |
| 183 | + }, |
| 184 | + dataType: 'json', |
| 185 | + success: function( data ) { |
| 186 | + // Invalidate cache |
| 187 | + gadgetCache[gadget.id] = null; |
| 188 | + |
| 189 | + if ( data && data.edit && data.edit ) { |
| 190 | + if ( data.edit.result === 'Success' ) { |
| 191 | + o.success( data.edit ); |
| 192 | + } else { |
| 193 | + o.error( data.edit.result ); |
| 194 | + } |
| 195 | + } else if ( data && data.error ) { |
| 196 | + o.error( data.error.code ); |
| 197 | + } else { |
| 198 | + o.error( 'unknown' ); |
| 199 | + } |
| 200 | + }, |
| 201 | + error: function(){ |
| 202 | + // Invalidate cache |
| 203 | + gadgetCache[gadget.id] = null; |
| 204 | + o.error( 'unknown' ); |
| 205 | + } |
| 206 | + }); |
169 | 207 | }, |
170 | 208 | |
171 | 209 | /** |
— | — | @@ -172,14 +210,13 @@ |
173 | 211 | * |
174 | 212 | * @param id {String} Id of the gadget to delete. |
175 | 213 | * @param callback {Function} Called with one argument (ok', 'error' or 'conflict'). |
176 | | - * @return {jqXHR|Null}: Null if served from cache, otherwise the jqXHR. |
| 214 | + * @return {jqXHR} |
177 | 215 | */ |
178 | | - doDeleteGadget: function( id, callback ) { |
179 | | - // @todo |
180 | | - // Do with ApiDelete |
| 216 | + doDeleteGadget: function( id, success, error ) { |
| 217 | + // @todo ApiDelete |
181 | 218 | // Invalidate cache |
182 | 219 | gadgetCache[id] = null; |
183 | | - callback( 'error' ); |
| 220 | + error( '@todo' ); |
184 | 221 | return null; |
185 | 222 | } |
186 | 223 | } |
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.ui.js |
— | — | @@ -88,12 +88,35 @@ |
89 | 89 | /** |
90 | 90 | * @var {Number} Maximum number of autocomplete suggestions in the gadget editor input fields. |
91 | 91 | */ |
92 | | - suggestLimit = 7, |
93 | | - /** |
94 | | - * @var {Array} List of category objects with their name, localized title and member count. |
95 | | - */ |
96 | | - gadgetCategoriesCache = []; |
| 92 | + suggestLimit = 7; |
97 | 93 | |
| 94 | + /* Local functions */ |
| 95 | + |
| 96 | + /** |
| 97 | + * Utility function to pad a zero |
| 98 | + * to single digit number. Used by ISODateString(). |
| 99 | + * @param n {Number} |
| 100 | + * @return {String} |
| 101 | + */ |
| 102 | + function pad( n ) { |
| 103 | + return n < 10 ? '0' + n : n; |
| 104 | + } |
| 105 | + /** |
| 106 | + * Format a date in an ISO 8601 format using UTC. |
| 107 | + * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date#Example:_ISO_8601_formatted_dates |
| 108 | + * |
| 109 | + * @param d {Date} |
| 110 | + * @return {String} |
| 111 | + */ |
| 112 | + function ISODateString( d ) { |
| 113 | + return d.getUTCFullYear() + '-' |
| 114 | + + pad( d.getUTCMonth() + 1 ) + '-' |
| 115 | + + pad( d.getUTCDate() ) + 'T' |
| 116 | + + pad( d.getUTCHours() ) + ':' |
| 117 | + + pad( d.getUTCMinutes() ) + ':' |
| 118 | + + pad( d.getUTCSeconds() ) + 'Z'; |
| 119 | + } |
| 120 | + |
98 | 121 | /* Public functions */ |
99 | 122 | |
100 | 123 | gm.ui = { |
— | — | @@ -106,13 +129,7 @@ |
107 | 130 | $( '.mw-gadgetmanager-gadgets .mw-gadgetmanager-gadgets-title a' ) |
108 | 131 | .click( function( e ) { |
109 | 132 | e.preventDefault(); |
110 | | - var $el = $( this ); |
111 | | - var gadget = { |
112 | | - id: $el.data( 'gadget-id' ), |
113 | | - displayTitle: $el.text(), |
114 | | - metadata: null |
115 | | - }; |
116 | | - gm.ui.startGadgetEditor( gadget ); |
| 133 | + gm.ui.startGadgetEditor( $( this ).data( 'gadget-id' ) ); |
117 | 134 | }); |
118 | 135 | }, |
119 | 136 | |
— | — | @@ -120,55 +137,60 @@ |
121 | 138 | * Initialize the gadget editor dialog. |
122 | 139 | * |
123 | 140 | * @asynchronous |
124 | | - * @param id {String} |
125 | | - * @param displayTitle {String} |
| 141 | + * @param gadgetId {String} |
126 | 142 | */ |
127 | | - startGadgetEditor: function( gadget ) { |
128 | | - // We need two things. Gadget meta-data and category information. |
129 | | - var done = 0, ready = 2; |
| 143 | + startGadgetEditor: function( gadgetId ) { |
| 144 | + // Ad hoc multi-loader. We need both requests, which are asynchronous, |
| 145 | + // to be complete. Which ever finishes first will set the local variable |
| 146 | + // to it's return value for the other callback to use. |
| 147 | + // @todo Notification: In case of an 'error'. |
| 148 | + var gadget, cats; |
130 | 149 | |
131 | | - gm.api.getGadgetMetadata( gadget.id, function( metadata, status ) { |
132 | | - // @todo Notification: If status is 'error' |
133 | | - gadget.metadata = metadata; |
134 | | - done++; |
135 | | - if ( done >= ready ) { |
136 | | - gm.ui.showFancyForm( gadget ); |
| 150 | + gm.api.getGadgetCategories( function( ret ) { |
| 151 | + if ( gadget ) { |
| 152 | + // getGadgetData already done |
| 153 | + return gm.ui.showFancyForm( gadget, ret ); |
137 | 154 | } |
| 155 | + // getGadgetData not done yet, leave cats for it's callback to use |
| 156 | + cats = ret; |
138 | 157 | }); |
139 | 158 | |
140 | | - gm.api.getGadgetCategories( function( cats ) { |
141 | | - gadgetCategoriesCache = cats; |
142 | | - done++; |
143 | | - if ( done >= ready ) { |
144 | | - gm.ui.showFancyForm( gadget ); |
| 159 | + gm.api.getGadgetData( gadgetId, function( ret ) { |
| 160 | + if ( cats ) { |
| 161 | + // getGadgetCategories already done |
| 162 | + return gm.ui.showFancyForm( ret, cats ); |
145 | 163 | } |
| 164 | + // getGadgetCategories not done yet, leave gadget for it's callback to use |
| 165 | + gadget = ret; |
146 | 166 | }); |
147 | 167 | }, |
148 | 168 | |
149 | 169 | /** |
150 | 170 | * Generate form, create a dialog and open it into view. |
151 | 171 | * |
152 | | - * @param gadget {Object} |
| 172 | + * @param gadget {Object} Gadget object of the gadget to be modified. |
| 173 | + * @param categories {Array} Gadget categories. |
153 | 174 | * @return {jQuery} The (dialogged) form. |
154 | 175 | */ |
155 | | - showFancyForm: function( gadget ) { |
156 | | - var $form = gm.ui.getFancyForm( gadget.metadata ); |
157 | | - var buttons = {}; |
| 176 | + showFancyForm: function( gadget, categories ) { |
| 177 | + var $form = gm.ui.getFancyForm( gadget.metadata, categories ), |
| 178 | + buttons = {}; |
| 179 | + |
| 180 | + // Form submit |
158 | 181 | buttons[mw.msg( 'gadgetmanager-editor-save' )] = function() { |
159 | | - gm.api.doModifyGadget( gadget, function( status, msg ) { |
160 | | - mw.log( "gm.api.doModifyGadget: status: ", status, "msg: ", + msg ); |
161 | | - /* @todo Notification |
162 | | - addNotification( { |
163 | | - msg: msg, |
164 | | - type: status !== 'error' ? 'success' : status, |
165 | | - timedActionDelay: 5, |
166 | | - timedAction: function(){ |
167 | | - // refresh page |
168 | | - } |
169 | | - }); |
170 | | - */ |
| 182 | + gm.api.doModifyGadget( gadget, { |
| 183 | + starttimestamp: ISODateString( new Date() ), |
| 184 | + success: function( response ) { |
| 185 | + $form.dialog( 'close' ); |
| 186 | + window.location.reload(); |
| 187 | + }, |
| 188 | + error: function( error ) { |
| 189 | + mw.log( 'gm.api.doModifyGadget: error', error ); |
| 190 | + // @todo Notification: $formNotif.add( .. ); |
| 191 | + } |
171 | 192 | }); |
172 | 193 | }; |
| 194 | + |
173 | 195 | return $form |
174 | 196 | .dialog({ |
175 | 197 | autoOpen: true, |
— | — | @@ -176,20 +198,14 @@ |
177 | 199 | modal: true, |
178 | 200 | draggable: false, |
179 | 201 | resizable: false, |
180 | | - title: mw.message( 'gadgetmanager-editor-title', gadget.displayTitle ).escaped(), |
| 202 | + title: mw.message( 'gadgetmanager-editor-title', gadget.title ).escaped(), |
181 | 203 | buttons: buttons, |
182 | 204 | open: function() { |
183 | 205 | // Dialog is ready for action. |
184 | 206 | // Push out any notifications if some were queued up already between |
185 | 207 | // getting the gadget data and the display of the form. |
186 | | - /* @todo Notification |
187 | | - if ( gm.ui.notifications.length ) { |
188 | | - for ( in ) { |
189 | | - slice(i,1)_remove; |
190 | | - gm.ui.addNotification( $form, n[i] ); |
191 | | - } |
192 | | - } |
193 | | - */ |
| 208 | + |
| 209 | + // @todo Notification: $formNotif.add( .. ); |
194 | 210 | } |
195 | 211 | }); |
196 | 212 | }, |
— | — | @@ -200,9 +216,10 @@ |
201 | 217 | * |
202 | 218 | * @param metadata {Object} Object to read and write to, used when saving |
203 | 219 | * the gadget metadata back through the API. |
| 220 | + * @param categories {Array} Gadget categories. |
204 | 221 | * @return {jQuery} The form. |
205 | 222 | */ |
206 | | - getFancyForm: function( metadata ) { |
| 223 | + getFancyForm: function( metadata, categories ) { |
207 | 224 | var nsGadgetId = mw.config.get( 'wgNamespaceIds' ).gadget, |
208 | 225 | $form = $( tpl.fancyForm ).localize(); |
209 | 226 | |
— | — | @@ -337,8 +354,8 @@ |
338 | 355 | opts = '', |
339 | 356 | i = 0, |
340 | 357 | cat; |
341 | | - for ( ; i < gadgetCategoriesCache.length; i++ ) { |
342 | | - cat = gadgetCategoriesCache[i]; |
| 358 | + for ( ; i < categories.length; i++ ) { |
| 359 | + cat = categories[i]; |
343 | 360 | opts += mw.html.element( 'option', { |
344 | 361 | value: cat.name, |
345 | 362 | selected: cat.name === current |
Index: branches/RL2/extensions/Gadgets/modules/ext.gadgets.gadgetmanager.prejs.css |
— | — | @@ -1,4 +1,7 @@ |
2 | | -.mw-gadgetmanager-gadgets.mw-datatable th, |
| 2 | +.mw-gadgetmanager-gadgets.mw-datatable th { |
| 3 | + padding: 2px 21px 2px 5px; |
| 4 | +} |
| 5 | + |
3 | 6 | .mw-gadgetmanager-gadgets.mw-datatable td { |
4 | 7 | padding: 2px 5px; |
5 | 8 | } |
Index: branches/RL2/extensions/Gadgets/modules/jquery.createPropCloud.js |
— | — | @@ -70,15 +70,15 @@ |
71 | 71 | * |
72 | 72 | * @context {jQuery} |
73 | 73 | * @param o {Object} All optional |
74 | | - * - prefix {String} Class name prefix |
75 | | - * - props {Array} Array of properties to start with |
76 | | - * - autocompleteSource {Function|Array} Source of autocomplete suggestions (required) |
77 | | - * See also http://jqueryui.com/demos/autocomplete/#options (source) |
78 | | - * - onAdd {Function} Callback for when an item is added. |
79 | | - * Called with one argument (the value). |
80 | | - * - onRemove {Function} Callback for when an item is removed. |
81 | | - * Called with one argument (the value). |
82 | | - * - removeTooltip {String} Tooltip for the remove-icon |
| 74 | + * - prefix {String} Class name prefix |
| 75 | + * - props {Array} Array of properties to start with |
| 76 | + * - autocompleteSource {Function|Array} Source of autocomplete suggestions (required) |
| 77 | + * See also http://jqueryui.com/demos/autocomplete/#options (source) |
| 78 | + * - onAdd {Function} Callback for when an item is added. |
| 79 | + * Called with one argument (the value). |
| 80 | + * - onRemove {Function} Callback for when an item is removed. |
| 81 | + * Called with one argument (the value). |
| 82 | + * - removeTooltip {String} Tooltip for the remove-icon |
83 | 83 | * |
84 | 84 | * @return {jQuery} prop cloud (input field inside) |
85 | 85 | */ |