Index: trunk/phase3/skins/common/edit.js |
— | — | @@ -229,41 +229,3 @@ |
230 | 230 | editForm |
231 | 231 | } ); |
232 | 232 | |
233 | | -//make sure edit summary does not exceed byte limit |
234 | | -addOnloadHook(function () { |
235 | | - var summary = document.getElementById( 'wpSummary' ); |
236 | | - if ( !summary ) { |
237 | | - return; |
238 | | - } |
239 | | - summary.maxLength = 250; //L must be capitalized in length. |
240 | | - |
241 | | - checkSummary = function (e) { |
242 | | - if (!e) e = window.event; //IE |
243 | | - |
244 | | - //first check to see if this is actually a character key |
245 | | - // being pressed. |
246 | | - //Based on key-event info from http://unixpapa.com/js/key.html |
247 | | - //note === sign, if undefined, still could be a real key |
248 | | - |
249 | | - if (e.which === 0 || e.charCode === 0 || e.ctrlKey || e.altKey || e.metaKey) { |
250 | | - return true; //a special key (backspace, etc) so don't interefere. |
251 | | - } |
252 | | - |
253 | | - //This basically figures out how many bytes a utf-16 string (which is what js sees) will take in utf-8 |
254 | | - //by replacing a 2 byte character with 2 *'s, etc, and counting that. |
255 | | - //Note, surogate (\uD800-\uDFFF) characters are counted as 2 bytes, since theres two of them |
256 | | - //and the actual character takes 4 bytes in utf-8 (2*2=4). might not work perfectly in edge cases such as |
257 | | - //such as illegal sequences, but that should never happen. |
258 | | - |
259 | | - len = summary.value.replace(/[\u0080-\u07FF\uD800-\uDFFF]/g, '**').replace(/[\u0800-\uD7FF\uE000-\uFFFF]/g, '***').length; |
260 | | - //247 as this doesn't count character about to be inserted. |
261 | | - if (len > 247) { |
262 | | - if (e.preventDefault) e.preventDefault(); |
263 | | - e.returnValue = false; //IE |
264 | | - return false; |
265 | | - } |
266 | | - }; |
267 | | - |
268 | | - addHandler(summary, 'keypress', checkSummary); |
269 | | -}); |
270 | | - |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | $this->preview = true; |
337 | 337 | } |
338 | 338 | |
339 | | - $wgOut->addModules( 'mediawiki.legacy.edit' ); |
| 339 | + $wgOut->addModules( array( 'mediawiki.legacy.edit', 'mediawiki.action.edit' ) ); |
340 | 340 | |
341 | 341 | if ( $wgUser->getOption( 'uselivepreview', false ) ) { |
342 | 342 | $wgOut->addModules( 'mediawiki.legacy.preview' ); |
Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js |
— | — | @@ -0,0 +1,30 @@ |
| 2 | +/* Note, there is still stuff in skins/common/edit.js that |
| 3 | + * has not been jQuery-ized. |
| 4 | + */ |
| 5 | + |
| 6 | +//make sure edit summary does not exceed byte limit |
| 7 | +$( '#wpSummary' ).attr( 'maxLength', 250 ).keypress( function (e) { |
| 8 | + |
| 9 | + // first check to see if this is actually a character key |
| 10 | + // being pressed. |
| 11 | + // Based on key-event info from http://unixpapa.com/js/key.html |
| 12 | + // JQuery should also normalize e.which to be consistent cross-browser, |
| 13 | + // however the same check is still needed regardless of jQuery. |
| 14 | + |
| 15 | + if (e.which === 0 || e.charCode === 0 || e.ctrlKey || e.altKey || e.metaKey) { |
| 16 | + return true; //a special key (backspace, etc) so don't interfere. |
| 17 | + } |
| 18 | + |
| 19 | + // This basically figures out how many bytes a UTF-16 string (which is what js sees) |
| 20 | + // will take in UTF-8 by replacing a 2 byte character with 2 *'s, etc, and counting that. |
| 21 | + // Note, surrogate (\uD800-\uDFFF) characters are counted as 2 bytes, since there's two of them |
| 22 | + // and the actual character takes 4 bytes in UTF-8 (2*2=4). Might not work perfectly in edge cases |
| 23 | + // such as illegal sequences, but that should never happen. |
| 24 | + |
| 25 | + len = this.value.replace(/[\u0080-\u07FF\uD800-\uDFFF]/g, '**').replace(/[\u0800-\uD7FF\uE000-\uFFFF]/g, '***').length; |
| 26 | + //247 as this doesn't count character about to be inserted. |
| 27 | + if (len > 247) { |
| 28 | + e.preventDefault(); |
| 29 | + } |
| 30 | +}); |
| 31 | + |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -353,6 +353,9 @@ |
354 | 354 | 'scripts' => 'resources/mediawiki.action/mediawiki.action.history.js', |
355 | 355 | 'dependencies' => 'mediawiki.legacy.history', |
356 | 356 | ), |
| 357 | + 'mediawiki.action.edit' => array( |
| 358 | + 'scripts' => 'resources/mediawiki.action/mediawiki.action.edit.js', |
| 359 | + ), |
357 | 360 | 'mediawiki.action.view.rightClickEdit' => array( |
358 | 361 | 'scripts' => 'resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js', |
359 | 362 | ), |