diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
commit | 222b01f5169f1c7e69762e0e8904c24f78f71882 (patch) | |
tree | 8e932e12546bb991357ec48eb1638d1770be7a35 /skins/common/ajaxwatch.js | |
parent | 00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff) |
update to MediaWiki 1.16.0
Diffstat (limited to 'skins/common/ajaxwatch.js')
-rw-r--r-- | skins/common/ajaxwatch.js | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/skins/common/ajaxwatch.js b/skins/common/ajaxwatch.js index c8d90b80..7f546014 100644 --- a/skins/common/ajaxwatch.js +++ b/skins/common/ajaxwatch.js @@ -2,7 +2,7 @@ // * ajax.js: /*extern sajax_init_object, sajax_do_call */ // * wikibits.js: - /*extern changeText, akeytt, hookEvent, jsMsg */ + /*extern changeText, hookEvent, jsMsg */ // These should have been initialized in the generated js /*extern wgAjaxWatch, wgPageName */ @@ -12,7 +12,9 @@ if(typeof wgAjaxWatch === "undefined" || !wgAjaxWatch) { watchMsg: "Watch", unwatchMsg: "Unwatch", watchingMsg: "Watching...", - unwatchingMsg: "Unwatching..." + unwatchingMsg: "Unwatching...", + 'tooltip-ca-watchMsg': "Add this page to your watchlist", + 'tooltip-ca-unwatchMsg': "Remove this page from your watchlist" }; } @@ -21,17 +23,36 @@ wgAjaxWatch.watching = false; // currently watching page wgAjaxWatch.inprogress = false; // ajax request in progress wgAjaxWatch.timeoutID = null; // see wgAjaxWatch.ajaxCall wgAjaxWatch.watchLinks = []; // "watch"/"unwatch" links +wgAjaxWatch.iconMode = false; // new icon driven functionality +wgAjaxWatch.imgBasePath = ""; // base img path derived from icons on load -wgAjaxWatch.setLinkText = function(newText) { - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { - changeText(wgAjaxWatch.watchLinks[i], newText); +wgAjaxWatch.setLinkText = function( newText ) { + 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].className += ' loading'; + } else if ( newText == wgAjaxWatch.watchMsg || newText == wgAjaxWatch.unwatchMsg ) { + wgAjaxWatch.watchLinks[i].className = + wgAjaxWatch.watchLinks[i].className.replace( /loading/i, '' ); + // update the title text on the link + var keyCommand = wgAjaxWatch.watchLinks[i].title.match( /\[.*?\]$/ ) ? + wgAjaxWatch.watchLinks[i].title.match( /\[.*?\]$/ )[0] : ""; + wgAjaxWatch.watchLinks[i].title = ( newText == wgAjaxWatch.watchMsg ? + wgAjaxWatch['tooltip-ca-watchMsg'] : wgAjaxWatch['tooltip-ca-unwatchMsg'] ) + + " " + keyCommand; + } + } + } else { + for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) { + changeText( wgAjaxWatch.watchLinks[i], newText ); + } } }; -wgAjaxWatch.setLinkID = function(newId) { +wgAjaxWatch.setLinkID = function( newId ) { // We can only set the first one - wgAjaxWatch.watchLinks[0].setAttribute( 'id', newId ); - akeytt(newId); // update tooltips for Monobook + wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId ); }; wgAjaxWatch.setHref = function( string ) { @@ -112,27 +133,33 @@ wgAjaxWatch.processResult = function(request) { wgAjaxWatch.onLoad = function() { // This document structure hardcoding sucks. We should make a class and // toss all this out the window. + 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; } } - + + // Detect if the watch/unwatch feature is in icon mode + if ( el1.className.match( /icon/i ) ) { + wgAjaxWatch.iconMode = true; + } + // The id can be either for the parent (Monobook-based) or the element // itself (non-Monobook) wgAjaxWatch.watchLinks.push( el1.tagName.toLowerCase() == "a" |