r52870 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52869‎ | r52870 | r52871 >
Date:23:00, 7 July 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditWarning: Trigger warning on actual changes only using text comparison
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditWarning/EditWarning.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditWarning/EditWarning.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditWarning/EditWarning.php
@@ -18,7 +18,7 @@
1919 /* Configuration */
2020
2121 // Bump the version number every time you change any of the .css/.js files
22 -$wgEditWarningStyleVersion = 2;
 22+$wgEditWarningStyleVersion = 3;
2323
2424 /* Setup */
2525
Index: trunk/extensions/UsabilityInitiative/EditWarning/EditWarning.js
@@ -1,18 +1,16 @@
22 /* JavaScript for EditWarning extension */
33
44 $( document ).ready( function() {
5 - $( 'textarea#wpTextbox1, input#wpSummary' )
6 - .bind(
7 - 'change paste cut keydown',
8 - function () {
9 - if ( !( 'onbeforeunload' in window ) ) {
10 - window.onbeforeunload = function() {
11 - return gM('editwarning-warning' );
12 - }
13 - }
14 - }
15 - );
 5+ $( '#wpTextbox1, #wpSummary' ).each( function() {
 6+ $(this).data( 'origtext', $(this).val() );
 7+ });
 8+ if( !( 'onbeforeunload' in window ) )
 9+ window.onbeforeunload = function() {
 10+ if( $( '#wpTextbox1' ).data( 'origtext' ) != $( '#wpTextbox1' ).val() ||
 11+ $( '#wpSummary' ).data( 'origtext' ) != $( '#wpSummary' ).val() )
 12+ return gM( 'editwarning-warning' );
 13+ };
1614 $( 'form' ).submit( function() {
17 - window.onbeforeunload = function () {};
 15+ window.onbeforeunload = function() {};
1816 });
19 -});
\ No newline at end of file
 17+});

Status & tagging log