Index: trunk/phase3/skins/common/ajaxwatch.js |
— | — | @@ -25,27 +25,30 @@ |
26 | 26 | wgAjaxWatch.imgBasePath = ""; // base img path derived from icons on load |
27 | 27 | |
28 | 28 | wgAjaxWatch.setLinkText = function(newText) { |
29 | | - if(wgAjaxWatch.iconMode){ |
30 | | - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { |
| 29 | + if( wgAjaxWatch.iconMode ) { |
| 30 | + for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) { |
31 | 31 | wgAjaxWatch.watchLinks[i].firstChild.alt = newText; |
32 | | - if(newText==wgAjaxWatch.watchingMsg||newText==wgAjaxWatch.unwatchingMsg){ |
33 | | - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/common/images/spinner.gif"; |
34 | | - }else if(newText==wgAjaxWatch.watchMsg){ |
35 | | - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_off.gif"; |
36 | | - }else if(newText==wgAjaxWatch.unwatchMsg){ |
37 | | - wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath+"/skins/vector/images/watch_on.gif"; |
| 32 | + if( newText==wgAjaxWatch.watchingMsg || newText==wgAjaxWatch.unwatchingMsg ) { |
| 33 | + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath |
| 34 | + + "/common/images/spinner.gif"; |
| 35 | + } else if( newText==wgAjaxWatch.watchMsg ) { |
| 36 | + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath |
| 37 | + + "/vector/images/watch_off.gif"; |
| 38 | + } else if( newText==wgAjaxWatch.unwatchMsg ) { |
| 39 | + wgAjaxWatch.watchLinks[i].firstChild.src = wgAjaxWatch.imgBasePath |
| 40 | + + "/vector/images/watch_on.gif"; |
38 | 41 | } |
39 | 42 | } |
40 | | - }else{ |
41 | | - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { |
42 | | - changeText(wgAjaxWatch.watchLinks[i], newText); |
| 43 | + } else{ |
| 44 | + for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) { |
| 45 | + changeText( wgAjaxWatch.watchLinks[i], newText ); |
43 | 46 | } |
44 | 47 | } |
45 | 48 | }; |
46 | 49 | |
47 | 50 | wgAjaxWatch.setLinkID = function(newId) { |
48 | 51 | // We can only set the first one |
49 | | - wgAjaxWatch.watchLinks[0].setAttribute( 'id', newId ); |
| 52 | + wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId ); |
50 | 53 | akeytt(newId); // update tooltips for Monobook |
51 | 54 | }; |
52 | 55 | |
— | — | @@ -130,20 +133,20 @@ |
131 | 134 | |
132 | 135 | var el1 = document.getElementById("ca-unwatch"); |
133 | 136 | var el2 = null; |
134 | | - if (!el1) { |
| 137 | + if ( !el1 ) { |
135 | 138 | el1 = document.getElementById("mw-unwatch-link1"); |
136 | 139 | el2 = document.getElementById("mw-unwatch-link2"); |
137 | 140 | } |
138 | | - if(el1) { |
| 141 | + if( el1 ) { |
139 | 142 | wgAjaxWatch.watching = true; |
140 | 143 | } else { |
141 | 144 | wgAjaxWatch.watching = false; |
142 | 145 | el1 = document.getElementById("ca-watch"); |
143 | | - if (!el1) { |
| 146 | + if ( !el1 ) { |
144 | 147 | el1 = document.getElementById("mw-watch-link1"); |
145 | 148 | el2 = document.getElementById("mw-watch-link2"); |
146 | 149 | } |
147 | | - if(!el1) { |
| 150 | + if( !el1 ) { |
148 | 151 | wgAjaxWatch.supported = false; |
149 | 152 | return; |
150 | 153 | } |
— | — | @@ -151,17 +154,20 @@ |
152 | 155 | |
153 | 156 | // If we're using the icon, add rollover affects |
154 | 157 | try{ |
155 | | - if(el1.firstChild.firstChild.tagName.match(/img/i)){ |
156 | | - wgAjaxWatch.iconMode = true; |
157 | | - wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src.replace(/\/skins\/vector\/images\/watch_(off|on).gif/, ""); |
158 | | - el1.firstChild.onmouseover = function(e){ |
159 | | - this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_on/, "_off") : this.firstChild.src.replace(/_off/, "_on")); |
| 158 | + if( el1.firstChild.firstChild.tagName.match( /img/i ) ) { |
| 159 | + wgAjaxWatch.iconMode = true; |
| 160 | + wgAjaxWatch.imgBasePath = el1.firstChild.firstChild.src |
| 161 | + .replace( /\/vector\/images\/watch_(off|on).gif/, "" ); |
| 162 | + el1.firstChild.onmouseover = function( e ) { |
| 163 | + this.firstChild.src = wgAjaxWatch.imgBasePath |
| 164 | + + "/vector/images/watch_over.gif"; |
160 | 165 | } |
161 | | - el1.firstChild.onmouseout = function(e){ |
162 | | - this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_off/, "_on") : this.firstChild.src.replace(/_on/, "_off")); |
| 166 | + el1.firstChild.onmouseout = function( e ) { |
| 167 | + this.firstChild.src = wgAjaxWatch.imgBasePath |
| 168 | + + "/vector/images/watch_" + ( wgAjaxWatch.watching ? "on.gif" : "off.gif"); |
163 | 169 | } |
164 | 170 | } |
165 | | - }catch(e){ |
| 171 | + } catch( e ) { |
166 | 172 | // not using the icon |
167 | 173 | } |
168 | 174 | |