r50705 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50704‎ | r50705 | r50706 >
Date:19:04, 17 May 2009
Author:siebrand
Status:ok
Tags:
Comment:
(bug 18342) insertTags works in edit summary box now (patch contributed by Ahmad Sherif)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/skins/common/edit.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/edit.js
@@ -1,3 +1,5 @@
 2+var currentFocused;
 3+
24 // this function generates the actual toolbar buttons with localized text
35 // we use it to avoid creating the toolbar where javascript is not enabled
46 function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
@@ -62,7 +64,7 @@
6365 function insertTags(tagOpen, tagClose, sampleText) {
6466 var txtarea;
6567 if (document.editform) {
66 - txtarea = document.editform.wpTextbox1;
 68+ txtarea = currentFocused;
6769 } else {
6870 // some alternate form? take the first one we can find
6971 var areas = document.getElementsByTagName('textarea');
@@ -77,7 +79,7 @@
7880 var winScroll = document.documentElement.scrollTop
7981 else if (document.body)
8082 var winScroll = document.body.scrollTop;
81 - //get current selection
 83+ //get current selection
8284 txtarea.focus();
8385 var range = document.selection.createRange();
8486 selText = range.text;
@@ -88,10 +90,10 @@
8991 if (isSample && range.moveStart) {
9092 if (window.opera)
9193 tagClose = tagClose.replace(/\n/g,'');
92 - range.moveStart('character', - tagClose.length - selText.length);
93 - range.moveEnd('character', - tagClose.length);
 94+ range.moveStart('character', - tagClose.length - selText.length);
 95+ range.moveEnd('character', - tagClose.length);
9496 }
95 - range.select();
 97+ range.select();
9698 //restore window scroll position
9799 if (document.documentElement && document.documentElement.scrollTop)
98100 document.documentElement.scrollTop = winScroll
@@ -122,7 +124,7 @@
123125 }
124126 //restore textarea scroll position
125127 txtarea.scrollTop = textScroll;
126 - }
 128+ }
127129
128130 function checkSelectedText(){
129131 if (!selText) {
@@ -131,7 +133,7 @@
132134 } else if (selText.charAt(selText.length - 1) == ' ') { //exclude ending space char
133135 selText = selText.substring(0, selText.length - 1);
134136 tagClose += ' '
135 - }
 137+ }
136138 }
137139
138140 }
@@ -148,9 +150,17 @@
149151 if( scrollTop.value )
150152 editBox.scrollTop = scrollTop.value;
151153 addHandler( editForm, 'submit', function() {
152 - document.getElementById( 'wpScrolltop' ).value = document.getElementById( 'wpTextbox1' ).scrollTop;
 154+ document.getElementById( 'wpScrolltop' ).value = document.getElementById( 'wpTextbox1' ).scrollTop;
153155 } );
154156 }
155157 }
156158 hookEvent( 'load', scrollEditBox );
157159 hookEvent( 'load', mwSetupToolbar );
 160+hookEvent( 'load', function() {
 161+ if ( document.editform ) {
 162+ currentFocused = document.editform.wpTextbox1;
 163+ document.editform.wpTextbox1.onfocus = function() { currentFocused = document.editform.wpTextbox1; };
 164+ document.editform.wpSummary.onfocus = function() { currentFocused = document.editform.wpSummary; };
 165+ }
 166+} );
 167+
Index: trunk/phase3/RELEASE-NOTES
@@ -52,6 +52,7 @@
5353 * New hook: MessageNotInMwNs to handle localised messages that aren't in the
5454 Mediawiki Namespace, before checking the message files
5555 * (bug 18466) Add note or warning when overruling a move (semi-)protection
 56+* (bug 18342) insertTags works in edit summary box
5657
5758 === Bug fixes in 1.16 ===
5859

Status & tagging log