Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -121,6 +121,7 @@ |
122 | 122 | 'edittoolbar-tool-replace-nomatch', |
123 | 123 | 'edittoolbar-tool-replace-success', |
124 | 124 | 'edittoolbar-tool-replace-emptysearch', |
| 125 | + 'edittoolbar-tool-replace-invalidregex', |
125 | 126 | /* Special Characters Section */ |
126 | 127 | 'edittoolbar-section-characters', |
127 | 128 | 'edittoolbar-characters-page-latin', |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -985,9 +985,8 @@ |
986 | 986 | var escTarget = escapeExternalTarget( target ); |
987 | 987 | var escText = escapeExternalText( text ); |
988 | 988 | whitespace = $j( '#edittoolbar-link-dialog-tab-ext' ).data( 'whitespace' ); |
989 | | - if ( target == '' || target == 'http://' ) { |
| 989 | + if ( !target.match( /^[a-z]+:\/\/./ ) ) { |
990 | 990 | // Refuse to add links to invalid URLs |
991 | | - // TODO: More elaborate regex here? |
992 | 991 | alert( gM( 'edittoolbar-tool-link-ext-invalid' ) ); |
993 | 992 | return; |
994 | 993 | } |
— | — | @@ -1142,7 +1141,7 @@ |
1143 | 1142 | { |
1144 | 1143 | type: 'replace', |
1145 | 1144 | options: { |
1146 | | - pre: "{|\n", |
| 1145 | + pre: "{| class=\"wikitable\"\n", |
1147 | 1146 | peri: table, |
1148 | 1147 | post: "|}", |
1149 | 1148 | ownline: true |
— | — | @@ -1182,6 +1181,7 @@ |
1183 | 1182 | <div id="edittoolbar-replace-nomatch" rel="edittoolbar-tool-replace-nomatch"></div>\ |
1184 | 1183 | <div id="edittoolbar-replace-success"></div>\ |
1185 | 1184 | <div id="edittoolbar-replace-emptysearch" rel="edittoolbar-tool-replace-emptysearch"></div>\ |
| 1185 | + <div id="edittoolbar-replace-invalidregex"></div>\ |
1186 | 1186 | </div>\ |
1187 | 1187 | <fieldset><table><tr>\ |
1188 | 1188 | <td><label for="edittoolbar-replace-search" rel="edittoolbar-tool-replace-search"></label></td>\ |
— | — | @@ -1203,7 +1203,7 @@ |
1204 | 1204 | |
1205 | 1205 | // TODO: Find a cleaner way to share this function |
1206 | 1206 | $j(this).data( 'replaceCallback', function( mode ) { |
1207 | | - $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch' ).hide(); |
| 1207 | + $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex' ).hide(); |
1208 | 1208 | var searchStr = $j( '#edittoolbar-replace-search' ).val(); |
1209 | 1209 | if ( searchStr == '' ) { |
1210 | 1210 | $j( '#edittoolbar-replace-emptysearch' ).show(); |
— | — | @@ -1222,7 +1222,15 @@ |
1223 | 1223 | if ( !isRegex ) { |
1224 | 1224 | searchStr = RegExp.escape( searchStr ); |
1225 | 1225 | } |
1226 | | - var regex = new RegExp( searchStr, flags ); |
| 1226 | + try { |
| 1227 | + var regex = new RegExp( searchStr, flags ); |
| 1228 | + } catch( e ) { |
| 1229 | + $j( '#edittoolbar-replace-invalidregex' ) |
| 1230 | + .text( gM( 'edittoolbar-tool-replace-invalidregex', |
| 1231 | + e.message ) ) |
| 1232 | + .show(); |
| 1233 | + return; |
| 1234 | + } |
1227 | 1235 | var $textarea = $j(this).data( 'context' ).$textarea; |
1228 | 1236 | var text = $j.wikiEditor.fixOperaBrokenness( $textarea.val() ); |
1229 | 1237 | var matches = false; |
— | — | @@ -1288,16 +1296,12 @@ |
1289 | 1297 | }, |
1290 | 1298 | 'edittoolbar-tool-replace-close': function() { |
1291 | 1299 | $j(this).dialog( 'close' ); |
1292 | | - $j(this).data( 'context' ).$textarea |
1293 | | - .unbind( 'keypress.srdialog' ) |
1294 | | - .focus(); |
1295 | | - $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false ); |
1296 | 1300 | } |
1297 | 1301 | }, |
1298 | 1302 | open: function() { |
1299 | 1303 | $j(this).data( 'offset', 0 ); |
1300 | 1304 | $j( '#edittoolbar-replace-search' ).focus(); |
1301 | | - $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch' ).hide(); |
| 1305 | + $j( '#edittoolbar-replace-nomatch, #edittoolbar-replace-success, #edittoolbar-replace-emptysearch, #edittoolbar-replace-invalidregex' ).hide(); |
1302 | 1306 | if ( !( $j(this).data( 'dialogkeypressset' ) ) ) { |
1303 | 1307 | $j(this).data( 'dialogkeypressset', true ); |
1304 | 1308 | // Execute the action associated with the first button |
— | — | @@ -1318,6 +1322,12 @@ |
1319 | 1323 | e.preventDefault(); |
1320 | 1324 | } |
1321 | 1325 | }); |
| 1326 | + }, |
| 1327 | + close: function() { |
| 1328 | + $j(this).data( 'context' ).$textarea |
| 1329 | + .unbind( 'keypress.srdialog' ) |
| 1330 | + .focus(); |
| 1331 | + $j(this).closest( '.ui-dialog' ).data( 'dialogaction', false ); |
1322 | 1332 | } |
1323 | 1333 | } |
1324 | 1334 | } |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php |
— | — | @@ -115,6 +115,7 @@ |
116 | 116 | 'edittoolbar-tool-replace-nomatch' => 'Your search did not match anything.', |
117 | 117 | 'edittoolbar-tool-replace-success' => '$1 replacement(s) made.', |
118 | 118 | 'edittoolbar-tool-replace-emptysearch' => 'You did not enter anything to search for.', |
| 119 | + 'edittoolbar-tool-replace-invalidregex' => 'The regular expression you entered is invalid: $1', |
119 | 120 | /* Special characters Section */ |
120 | 121 | 'edittoolbar-section-characters' => 'Special characters', |
121 | 122 | 'edittoolbar-characters-page-latin' => 'Latin', |
— | — | @@ -248,6 +249,7 @@ |
249 | 250 | 'edittoolbar-tool-replace-close' => '{{Identical|Cancel}}', |
250 | 251 | 'edittoolbar-tool-replace-success' => '[[file:Bulbgraph.png|left|22px]] |
251 | 252 | This message does not support PLURAL on $1.', |
| 253 | + 'edittoolbar-tool-replace-invalidregex' => '$1 is a browser-supplied error message, probably in English, possibly in the browser language.', |
252 | 254 | 'edittoolbar-characters-page-latin' => 'This is the name of a script, or alphabet, not a language', |
253 | 255 | 'edittoolbar-characters-page-ipa' => 'IPA means a script: "international phonetic alphabet" here, and not "international phonetic association", the organization behind it.', |
254 | 256 | 'edittoolbar-characters-page-greek' => 'This is the name of a script, or alphabet, not a language.', |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 57; |
| 23 | +$wgEditToolbarStyleVersion = 58; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |