From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- .../mediawiki.action/mediawiki.action.edit.js | 30 ++++++++++++++++++++++ .../mediawiki.action/mediawiki.action.history.js | 7 +++++ .../mediawiki.action.view.rightClickEdit.js | 24 +++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 resources/mediawiki.action/mediawiki.action.edit.js create mode 100644 resources/mediawiki.action/mediawiki.action.history.js create mode 100644 resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js (limited to 'resources/mediawiki.action') diff --git a/resources/mediawiki.action/mediawiki.action.edit.js b/resources/mediawiki.action/mediawiki.action.edit.js new file mode 100644 index 00000000..e5b50958 --- /dev/null +++ b/resources/mediawiki.action/mediawiki.action.edit.js @@ -0,0 +1,30 @@ +/* Note, there is still stuff in skins/common/edit.js that + * has not been jQuery-ized. + */ + +(function( $ ) { + //make sure edit summary does not exceed byte limit + $( '#wpSummary' ).attr( 'maxLength', 250 ).keypress( function( e ) { + // first check to see if this is actually a character key + // being pressed. + // Based on key-event info from http://unixpapa.com/js/key.html + // JQuery should also normalize e.which to be consistent cross-browser, + // however the same check is still needed regardless of jQuery. + + if ( e.which === 0 || e.charCode === 0 || e.ctrlKey || e.altKey || e.metaKey ) { + return true; //a special key (backspace, etc) so don't interfere. + } + + // This basically figures out how many bytes a UTF-16 string (which is what js sees) + // will take in UTF-8 by replacing a 2 byte character with 2 *'s, etc, and counting that. + // Note, surrogate (\uD800-\uDFFF) characters are counted as 2 bytes, since there's two of them + // and the actual character takes 4 bytes in UTF-8 (2*2=4). Might not work perfectly in edge cases + // such as illegal sequences, but that should never happen. + + var len = this.value.replace( /[\u0080-\u07FF\uD800-\uDFFF]/g, '**' ).replace( /[\u0800-\uD7FF\uE000-\uFFFF]/g, '***' ).length; + //247 as this doesn't count character about to be inserted. + if ( len > 247 ) { + e.preventDefault(); + } + }); +})(jQuery); diff --git a/resources/mediawiki.action/mediawiki.action.history.js b/resources/mediawiki.action/mediawiki.action.history.js new file mode 100644 index 00000000..66f90b07 --- /dev/null +++ b/resources/mediawiki.action/mediawiki.action.history.js @@ -0,0 +1,7 @@ +/* + * JavaScript for History action + */ + +// Replaces histrowinit +$( '#pagehistory li input[name=diff], #pagehistory li input[name=oldid]' ).click( diffcheck ); +diffcheck(); \ No newline at end of file diff --git a/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js new file mode 100644 index 00000000..5a7c777f --- /dev/null +++ b/resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js @@ -0,0 +1,24 @@ +/* + * JavaScript to enable right click edit functionality + */ +$( function() { + // Select all h1-h6 elements that contain editsection links + $( 'h1:has(.editsection a), ' + + 'h2:has(.editsection a), ' + + 'h3:has(.editsection a), ' + + 'h4:has(.editsection a), ' + + 'h5:has(.editsection a), ' + + 'h6:has(.editsection a)' + ).live( 'contextmenu', function( e ) { + // Get href of the [edit] link + var href = $(this).find( '.editsection a' ).attr( 'href' ); + // Check if target is the anchor link itself. If so, don't suppress the context menu; this + // way the reader can still do things like copy URL, open in new tab etc. + var $target = $( e.target ); + if ( !$target.is( 'a' ) && !$target.parent().is( '.editsection' ) ){ + window.location = href; + e.preventDefault(); + return false; + } + } ); +} ); -- cgit v1.2.2