r64273 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64272‎ | r64273 | r64274 >
Date:21:01, 27 March 2010
Author:catrope
Status:ok
Tags:
Comment:
ProofreadPage: Fix incompatibility with UsabilityInitiative
* Wrap the <textarea> with DOM methods instead of reconstructing it
* Account for the fact that the <textarea> may not be a direct child of the <form>
* Use += , that's what it's for
Modified paths:
  • /trunk/extensions/ProofreadPage/proofread_index.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/proofread_index.js
@@ -26,21 +26,25 @@
2727 if(!m) return;
2828 params = m[1]+'\n\|END=';
2929 }
30 -
31 - var f = text.parentNode;
32 - var new_text = f.removeChild(text);
33 -
 30+
 31+ // Certain extensions, like UsabilityInitiative, wrap the textarea
 32+ var textWrapper = text;
 33+ while(textWrapper.parentNode.nodeName != 'FORM') textWrapper = textWrapper.parentNode;
 34+ var f = textWrapper.parentNode;
3435 var container = document.createElement("div");
 36+ var wrapper = document.createElement("div");
 37+ wrapper.style.display = 'none';
 38+ container.appendChild(wrapper);
 39+ wrapper.appendChild(textWrapper);
3540
3641 var index_attributes = self.prp_index_attributes.split('\n');
37 - var str = '<div style="display:none;"><textarea id="wpTextbox1" name="wpTextbox1">'+new_text.value+'</textarea></div>';
38 - str = str + '<table>';
 42+ var str = '<table>';
3943 for(i=0;i<index_attributes.length;i++){
4044 m = index_attributes[i].split('|');
4145 param_name = m[0];
4246
4347 if(m[1]) param_label=m[1]; else param_label=param_name;
44 - str = str + '<tr><td>'+param_label+': </td>';
 48+ str += '<tr><td>'+param_label+': </td>';
4549
4650 value = findparam(params,param_name);
4751 value = value.replace(/\{\{!\}\}/g,'|');
@@ -50,14 +54,14 @@
5155
5256 if(m[2]) size=m[2]; else size="1";
5357 if(size=="1") {
54 - str = str + '<td><input name="'+param_name+'" size=60 value="'+value+'"/></td></tr>';
 58+ str += '<td><input name="'+param_name+'" size=60 value="'+value+'"/></td></tr>';
5559 }
5660 else{
57 - str = str +'<td><textarea name="'+param_name+'" cols=60 rows='+size+'>'+value+'</textarea></td></tr>';
 61+ str += '<td><textarea name="'+param_name+'" cols=60 rows='+size+'>'+value+'</textarea></td></tr>';
5862 }
5963 }
60 - str = str +'</table>';
61 - container.innerHTML = str;
 64+ str += '</table>';
 65+ container.innerHTML += str;
6266
6367 var saveButton = document.getElementById("wpSave");
6468 var previewButton = document.getElementById("wpPreview");

Follow-up revisions

RevisionCommit summaryAuthorDate
r658571.16wmf4: MFT r64273 (ProofreadPage incompat with UsabilityInitiative)catrope15:09, 3 May 2010

Status & tagging log