summaryrefslogtreecommitdiffstats
path: root/skins/common/history.js
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-10-24 18:01:35 +0000
committerNicolas Vigier <boklm@mageia.org>2011-10-24 18:01:35 +0000
commit246b38834224f9575f7b22cf84428ff615cb5acd (patch)
tree9e856efbb5a8f14faedf83432687b2a4bef5c493 /skins/common/history.js
downloadmediawiki-246b38834224f9575f7b22cf84428ff615cb5acd.tar
mediawiki-246b38834224f9575f7b22cf84428ff615cb5acd.tar.gz
mediawiki-246b38834224f9575f7b22cf84428ff615cb5acd.tar.bz2
mediawiki-246b38834224f9575f7b22cf84428ff615cb5acd.tar.xz
mediawiki-246b38834224f9575f7b22cf84428ff615cb5acd.zip
add mediawiki themes
Diffstat (limited to 'skins/common/history.js')
-rw-r--r--skins/common/history.js94
1 files changed, 94 insertions, 0 deletions
diff --git a/skins/common/history.js b/skins/common/history.js
new file mode 100644
index 0000000..0265122
--- /dev/null
+++ b/skins/common/history.js
@@ -0,0 +1,94 @@
+function historyRadios(parent) {
+ var inputs = parent.getElementsByTagName('input');
+ var radios = [];
+ for (var i = 0; i < inputs.length; i++) {
+ if (inputs[i].name == "diff" || inputs[i].name == "oldid") {
+ radios[radios.length] = inputs[i];
+ }
+ }
+ return radios;
+}
+
+// check selection and tweak visibility/class onclick
+function diffcheck() {
+ var dli = false; // the li where the diff radio is checked
+ var oli = false; // the li where the oldid radio is checked
+ var hf = document.getElementById('pagehistory');
+ if (!hf) {
+ return true;
+ }
+ var lis = hf.getElementsByTagName('li');
+ for (var i=0;i<lis.length;i++) {
+ var inputs = historyRadios(lis[i]);
+ if (inputs[1] && inputs[0]) {
+ if (inputs[1].checked || inputs[0].checked) { // this row has a checked radio button
+ if (inputs[1].checked && inputs[0].checked && inputs[0].value == inputs[1].value) {
+ return false;
+ }
+ if (oli) { // it's the second checked radio
+ if (inputs[1].checked) {
+ if ( (typeof oli.className) != 'undefined') {
+ oli.classNameOriginal = oli.className.replace( 'selected', '' );
+ } else {
+ oli.classNameOriginal = '';
+ }
+
+ oli.className = "selected "+oli.classNameOriginal;
+ return false;
+ }
+ } else if (inputs[0].checked) {
+ return false;
+ }
+ if (inputs[0].checked) {
+ dli = lis[i];
+ }
+ if (!oli) {
+ inputs[0].style.visibility = 'hidden';
+ }
+ if (dli) {
+ inputs[1].style.visibility = 'hidden';
+ }
+ if ( (typeof lis[i].className) != 'undefined') {
+ lis[i].classNameOriginal = lis[i].className.replace( 'selected', '' );
+ } else {
+ lis[i].classNameOriginal = '';
+ }
+
+ lis[i].className = "selected "+lis[i].classNameOriginal;
+ oli = lis[i];
+ } else { // no radio is checked in this row
+ if (!oli) {
+ inputs[0].style.visibility = 'hidden';
+ } else {
+ inputs[0].style.visibility = 'visible';
+ }
+ if (dli) {
+ inputs[1].style.visibility = 'hidden';
+ } else {
+ inputs[1].style.visibility = 'visible';
+ }
+ if ( typeof lis[i].classNameOriginal != 'undefined' ) {
+ lis[i].className = lis[i].classNameOriginal;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+// Attach event handlers to the input elements on history page
+function histrowinit() {
+ var hf = document.getElementById('pagehistory');
+ if (!hf) return;
+ var lis = hf.getElementsByTagName('li');
+ for (var i = 0; i < lis.length; i++) {
+ var inputs = historyRadios(lis[i]);
+ if (inputs[0] && inputs[1]) {
+ inputs[0].onclick = diffcheck;
+ inputs[1].onclick = diffcheck;
+ }
+ }
+ diffcheck();
+}
+
+hookEvent("load", histrowinit);