From: Adam Miller Date: Mon, 28 Sep 2009 02:45:24 +0000 (+0000) Subject: addressing feedback on the watch/unwatch javascript changes introduced in r56924 X-Git-Tag: 1.31.0-rc.0~39497 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=514438093e5006a036b7f152b623c601dfc3cbfd;p=lhc%2Fweb%2Fwiklou.git addressing feedback on the watch/unwatch javascript changes introduced in r56924 --- diff --git a/skins/common/ajaxwatch.js b/skins/common/ajaxwatch.js index 2127cbf8ff..76d3734e2e 100644 --- a/skins/common/ajaxwatch.js +++ b/skins/common/ajaxwatch.js @@ -25,27 +25,30 @@ wgAjaxWatch.iconMode = false; // new icon driven functionality wgAjaxWatch.imgBasePath = ""; // base img path derived from icons on load wgAjaxWatch.setLinkText = function(newText) { - if(wgAjaxWatch.iconMode){ - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { + if( wgAjaxWatch.iconMode ) { + for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) { wgAjaxWatch.watchLinks[i].firstChild.alt = newText; - if(newText==wgAjaxWatch.watchingMsg||newText==wgAjaxWatch.unwatchingMsg){ - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/common/images/spinner.gif"; - }else if(newText==wgAjaxWatch.watchMsg){ - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_off.gif"; - }else if(newText==wgAjaxWatch.unwatchMsg){ - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_on.gif"; + if( newText==wgAjaxWatch.watchingMsg || newText==wgAjaxWatch.unwatchingMsg ) { + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath + + "/common/images/spinner.gif"; + } else if( newText==wgAjaxWatch.watchMsg ) { + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath + + "/vector/images/watch_off.gif"; + } else if( newText==wgAjaxWatch.unwatchMsg ) { + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath + + "/vector/images/watch_on.gif"; } } - }else{ - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { - changeText(wgAjaxWatch.watchLinks[i], newText); + } else{ + for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) { + changeText( wgAjaxWatch.watchLinks[i], newText ); } } }; wgAjaxWatch.setLinkID = function(newId) { // We can only set the first one - wgAjaxWatch.watchLinks[0].setAttribute( 'id', newId ); + wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId ); akeytt(newId); // update tooltips for Monobook }; @@ -130,20 +133,20 @@ wgAjaxWatch.onLoad = function() { var el1 = document.getElementById("ca-unwatch"); var el2 = null; - if (!el1) { + if ( !el1 ) { el1 = document.getElementById("mw-unwatch-link1"); el2 = document.getElementById("mw-unwatch-link2"); } - if(el1) { + if( el1 ) { wgAjaxWatch.watching = true; } else { wgAjaxWatch.watching = false; el1 = document.getElementById("ca-watch"); - if (!el1) { + if ( !el1 ) { el1 = document.getElementById("mw-watch-link1"); el2 = document.getElementById("mw-watch-link2"); } - if(!el1) { + if( !el1 ) { wgAjaxWatch.supported = false; return; } @@ -151,17 +154,20 @@ wgAjaxWatch.onLoad = function() { // If we're using the icon, add rollover affects try{ - if(el1.firstChild.firstChild.tagName.match(/img/i)){ - wgAjaxWatch.iconMode = true; - wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src.replace(/\/skins\/vector\/images\/watch_(off|on).gif/, ""); - el1.firstChild.onmouseover = function(e){ - this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_on/, "_off") : this.firstChild.src.replace(/_off/, "_on")); + if( el1.firstChild.firstChild.tagName.match( /img/i ) ) { + wgAjaxWatch.iconMode = true; + wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src + .replace( /\/vector\/images\/watch_(off|on).gif/, "" ); + el1.firstChild.onmouseover = function( e ) { + this.firstChild.src = wgAjaxWatch.imgBasePath + + "/vector/images/watch_over.gif"; } - el1.firstChild.onmouseout = function(e){ - this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_off/, "_on") : this.firstChild.src.replace(/_on/, "_off")); + el1.firstChild.onmouseout = function( e ) { + this.firstChild.src = wgAjaxWatch.imgBasePath + + "/vector/images/watch_" + ( wgAjaxWatch.watching ? "on.gif" : "off.gif"); } } - }catch(e){ + } catch( e ) { // not using the icon }