r22860 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22859‎ | r22860 | r22861 >
Date:05:53, 9 June 2007
Author:david
Status:old
Tags:
Comment:
JS now makes sure date ranges are sane, CORRECTLY.
Modified paths:
  • /branches/liquidthreads/skins/common/lqt.js (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/common/lqt.js
@@ -11,7 +11,38 @@
1212 }
1313 }
1414
 15+var LqtDateRangeRectifier = function( startsel, endsel ) {
 16+ this.startsel = startsel;
 17+ this.endsel = endsel;
 18+
 19+ this.oldstart = this.startsel.selectedIndex;
 20+ this.oldend = this.endsel.selectedIndex;
1521
 22+ this.handle_start_changed = function(e) {
 23+ newi = this.startsel.selectedIndex;
 24+ oldi = this.oldstart;
 25+ endi = this.endsel.selectedIndex;
 26+ goal = newi - (oldi - endi); // seem backwards? it's because
 27+ this.endsel.selectedIndex = Math.max(goal, 0);
 28+ this.oldend = endi; // later months have smaller
 29+ this.oldstart = newi; // indexes.
 30+ }
 31+
 32+ this.handle_end_changed = function(e){
 33+ this.startsel.selectedIndex = Math.max(this.endsel.selectedIndex,
 34+ this.startsel.selectedIndex)
 35+ this.oldend = this.endsel.selectedIndex;
 36+ this.oldstart = this.startsel.selectedIndex;
 37+ }
 38+
 39+ // In order for this instance to recieve the events, we need to capture the
 40+ // current value of 'this' with a closure, because this = the target object
 41+ // in event handlers.
 42+ me = this;
 43+ lqt_add_event( this.startsel, 'change', function(e) { me.handle_start_changed(e) });
 44+ lqt_add_event( this.endsel, 'change', function(e) { me.handle_end_changed(e) });
 45+}
 46+
1647 function lqt_on_load() {
1748 if(!document.getElementById) return;
1849
@@ -28,9 +59,8 @@
2960
3061 var searchform = document.getElementById("lqt_archive_search_form");
3162 if ( searchform ) {
32 - lqt_add_event( document.getElementById("lqt_archive_start"), 'change', function(e) {
33 - alert(e.target);
34 - } );
 63+ new LqtDateRangeRectifier( document.getElementById("lqt_archive_start"),
 64+ document.getElementById("lqt_archive_end"));
3565 }
3666 }
3767

Status & tagging log