Revision: 50705 Author: siebrand Date: 2009-05-17 19:04:05 +0000 (Sun, 17 May 2009)
Log Message: ----------- (bug 18342) insertTags works in edit summary box now (patch contributed by Ahmad Sherif) Modified Paths: -------------- trunk/phase3/RELEASE-NOTES trunk/phase3/skins/common/edit.js Modified: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES 2009-05-17 18:42:22 UTC (rev 50704) +++ trunk/phase3/RELEASE-NOTES 2009-05-17 19:04:05 UTC (rev 50705) @@ -52,6 +52,7 @@ * New hook: MessageNotInMwNs to handle localised messages that aren't in the Mediawiki Namespace, before checking the message files * (bug 18466) Add note or warning when overruling a move (semi-)protection +* (bug 18342) insertTags works in edit summary box === Bug fixes in 1.16 === Modified: trunk/phase3/skins/common/edit.js =================================================================== --- trunk/phase3/skins/common/edit.js 2009-05-17 18:42:22 UTC (rev 50704) +++ trunk/phase3/skins/common/edit.js 2009-05-17 19:04:05 UTC (rev 50705) @@ -1,3 +1,5 @@ +var currentFocused; + // this function generates the actual toolbar buttons with localized text // we use it to avoid creating the toolbar where javascript is not enabled function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) { @@ -62,7 +64,7 @@ function insertTags(tagOpen, tagClose, sampleText) { var txtarea; if (document.editform) { - txtarea = document.editform.wpTextbox1; + txtarea = currentFocused; } else { // some alternate form? take the first one we can find var areas = document.getElementsByTagName('textarea'); @@ -77,7 +79,7 @@ var winScroll = document.documentElement.scrollTop else if (document.body) var winScroll = document.body.scrollTop; - //get current selection + //get current selection txtarea.focus(); var range = document.selection.createRange(); selText = range.text; @@ -88,10 +90,10 @@ if (isSample && range.moveStart) { if (window.opera) tagClose = tagClose.replace(/\n/g,''); - range.moveStart('character', - tagClose.length - selText.length); - range.moveEnd('character', - tagClose.length); + range.moveStart('character', - tagClose.length - selText.length); + range.moveEnd('character', - tagClose.length); } - range.select(); + range.select(); //restore window scroll position if (document.documentElement && document.documentElement.scrollTop) document.documentElement.scrollTop = winScroll @@ -122,7 +124,7 @@ } //restore textarea scroll position txtarea.scrollTop = textScroll; - } + } function checkSelectedText(){ if (!selText) { @@ -131,7 +133,7 @@ } else if (selText.charAt(selText.length - 1) == ' ') { //exclude ending space char selText = selText.substring(0, selText.length - 1); tagClose += ' ' - } + } } } @@ -148,9 +150,17 @@ if( scrollTop.value ) editBox.scrollTop = scrollTop.value; addHandler( editForm, 'submit', function() { - document.getElementById( 'wpScrolltop' ).value = document.getElementById( 'wpTextbox1' ).scrollTop; + document.getElementById( 'wpScrolltop' ).value = document.getElementById( 'wpTextbox1' ).scrollTop; } ); } } hookEvent( 'load', scrollEditBox ); hookEvent( 'load', mwSetupToolbar ); +hookEvent( 'load', function() { + if ( document.editform ) { + currentFocused = document.editform.wpTextbox1; + document.editform.wpTextbox1.onfocus = function() { currentFocused = document.editform.wpTextbox1; }; + document.editform.wpSummary.onfocus = function() { currentFocused = document.editform.wpSummary; }; + } +} ); + _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs