r34535 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34534‎ | r34535 | r34536 >
Date:20:51, 9 May 2008
Author:brion
Status:old
Tags:
Comment:
Split page history radio button tweaks out from wikibits.js to history.js
Only include it when it's needed -- don't force it on every reader!
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/PageHistory.php (modified) (history)
  • /trunk/phase3/skins/common/history.js (added) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -76,88 +76,6 @@
7777 }
7878 }
7979
80 -function historyRadios(parent) {
81 - var inputs = parent.getElementsByTagName('input');
82 - var radios = [];
83 - for (var i = 0; i < inputs.length; i++) {
84 - if (inputs[i].name == "diff" || inputs[i].name == "oldid") {
85 - radios[radios.length] = inputs[i];
86 - }
87 - }
88 - return radios;
89 -}
90 -
91 -// check selection and tweak visibility/class onclick
92 -function diffcheck() {
93 - var dli = false; // the li where the diff radio is checked
94 - var oli = false; // the li where the oldid radio is checked
95 - var hf = document.getElementById('pagehistory');
96 - if (!hf) {
97 - return true;
98 - }
99 - var lis = hf.getElementsByTagName('li');
100 - for (var i=0;i<lis.length;i++) {
101 - var inputs = historyRadios(lis[i]);
102 - if (inputs[1] && inputs[0]) {
103 - if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
104 - if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) {
105 - return false;
106 - }
107 - if (oli) { // it's the second checked radio
108 - if (inputs[1].checked) {
109 - oli.className = "selected";
110 - return false;
111 - }
112 - } else if (inputs[0].checked) {
113 - return false;
114 - }
115 - if (inputs[0].checked) {
116 - dli = lis[i];
117 - }
118 - if (!oli) {
119 - inputs[0].style.visibility = 'hidden';
120 - }
121 - if (dli) {
122 - inputs[1].style.visibility = 'hidden';
123 - }
124 - lis[i].className = "selected";
125 - oli = lis[i];
126 - } else { // no radio is checked in this row
127 - if (!oli) {
128 - inputs[0].style.visibility = 'hidden';
129 - } else {
130 - inputs[0].style.visibility = 'visible';
131 - }
132 - if (dli) {
133 - inputs[1].style.visibility = 'hidden';
134 - } else {
135 - inputs[1].style.visibility = 'visible';
136 - }
137 - lis[i].className = "";
138 - }
139 - }
140 - }
141 - return true;
142 -}
143 -
144 -// page history stuff
145 -// attach event handlers to the input elements on history page
146 -function histrowinit() {
147 - var hf = document.getElementById('pagehistory');
148 - if (!hf) {
149 - return;
150 - }
151 - var lis = hf.getElementsByTagName('li');
152 - for (var i = 0; i < lis.length; i++) {
153 - var inputs = historyRadios(lis[i]);
154 - if (inputs[0] && inputs[1]) {
155 - inputs[0].onclick = diffcheck;
156 - inputs[1].onclick = diffcheck;
157 - }
158 - }
159 - diffcheck();
160 -}
161 -
16280 // generate toc from prefs form, fold sections
16381 // XXX: needs testing on IE/Mac and safari
16482 // more comments to follow
@@ -1209,7 +1127,6 @@
12101128 // might cause the function to terminate prematurely
12111129 doneOnloadHook = true;
12121130
1213 - histrowinit();
12141131 unhidetzbutton();
12151132 tabbedprefs();
12161133 updateTooltipAccessKeys( null );
Index: trunk/phase3/skins/common/history.js
@@ -0,0 +1,83 @@
 2+function historyRadios(parent) {
 3+ var inputs = parent.getElementsByTagName('input');
 4+ var radios = [];
 5+ for (var i = 0; i < inputs.length; i++) {
 6+ if (inputs[i].name == "diff" || inputs[i].name == "oldid") {
 7+ radios[radios.length] = inputs[i];
 8+ }
 9+ }
 10+ return radios;
 11+}
 12+
 13+// check selection and tweak visibility/class onclick
 14+function diffcheck() {
 15+ var dli = false; // the li where the diff radio is checked
 16+ var oli = false; // the li where the oldid radio is checked
 17+ var hf = document.getElementById('pagehistory');
 18+ if (!hf) {
 19+ return true;
 20+ }
 21+ var lis = hf.getElementsByTagName('li');
 22+ for (var i=0;i<lis.length;i++) {
 23+ var inputs = historyRadios(lis[i]);
 24+ if (inputs[1] && inputs[0]) {
 25+ if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
 26+ if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) {
 27+ return false;
 28+ }
 29+ if (oli) { // it's the second checked radio
 30+ if (inputs[1].checked) {
 31+ oli.className = "selected";
 32+ return false;
 33+ }
 34+ } else if (inputs[0].checked) {
 35+ return false;
 36+ }
 37+ if (inputs[0].checked) {
 38+ dli = lis[i];
 39+ }
 40+ if (!oli) {
 41+ inputs[0].style.visibility = 'hidden';
 42+ }
 43+ if (dli) {
 44+ inputs[1].style.visibility = 'hidden';
 45+ }
 46+ lis[i].className = "selected";
 47+ oli = lis[i];
 48+ } else { // no radio is checked in this row
 49+ if (!oli) {
 50+ inputs[0].style.visibility = 'hidden';
 51+ } else {
 52+ inputs[0].style.visibility = 'visible';
 53+ }
 54+ if (dli) {
 55+ inputs[1].style.visibility = 'hidden';
 56+ } else {
 57+ inputs[1].style.visibility = 'visible';
 58+ }
 59+ lis[i].className = "";
 60+ }
 61+ }
 62+ }
 63+ return true;
 64+}
 65+
 66+// page history stuff
 67+// attach event handlers to the input elements on history page
 68+function histrowinit() {
 69+ var hf = document.getElementById('pagehistory');
 70+ if (!hf) {
 71+ return;
 72+ }
 73+ var lis = hf.getElementsByTagName('li');
 74+ for (var i = 0; i < lis.length; i++) {
 75+ var inputs = historyRadios(lis[i]);
 76+ if (inputs[0] && inputs[1]) {
 77+ inputs[0].onclick = diffcheck;
 78+ inputs[1].onclick = diffcheck;
 79+ }
 80+ }
 81+ diffcheck();
 82+}
 83+
 84+hookEvent("load", histrowinit);
Property changes on: trunk/phase3/skins/common/history.js
___________________________________________________________________
Added: svn:eol-style
185 + native
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1347,7 +1347,7 @@
13481348 * to ensure that client-side caches don't keep obsolete copies of global
13491349 * styles.
13501350 */
1351 -$wgStyleVersion = '142';
 1351+$wgStyleVersion = '143';
13521352
13531353
13541354 # Server-side caching:
Index: trunk/phase3/includes/PageHistory.php
@@ -81,6 +81,7 @@
8282 $wgOut->setRobotpolicy( 'noindex,nofollow' );
8383 $wgOut->setSyndicated( true );
8484 $wgOut->setFeedAppendQuery( 'action=history' );
 85+ $wgOut->addScriptFile( 'history.js' );
8586
8687 $logPage = SpecialPage::getTitleFor( 'Log' );
8788 $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() );

Status & tagging log