From 58054fea47f68b73291d147c26767e45a7bbe9e6 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 25 Sep 2009 18:04:11 +0000 Subject: [PATCH] Moving watch/unwatch action out of the drop down --- skins/Vector.php | 14 +++++---- skins/common/ajaxwatch.js | 39 +++++++++++++++++++++-- skins/vector/images/watch_off.gif | Bin 0 -> 550 bytes skins/vector/images/watch_on.gif | Bin 0 -> 543 bytes skins/vector/main-ltr.css | 50 ++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 skins/vector/images/watch_off.gif create mode 100644 skins/vector/images/watch_on.gif diff --git a/skins/Vector.php b/skins/Vector.php index f65d29ad3f..bd863f84ca 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -59,7 +59,7 @@ class SkinVector extends SkinTemplate { * @private */ function buildNavigationUrls() { - global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle; + global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle, $wgStylePath; global $wgDisableLangConversion; wfProfileIn( __METHOD__ ); @@ -285,21 +285,23 @@ class SkinVector extends SkinTemplate { if( $this->loggedin ) { // Checks if the user is watching this page if( !$this->mTitle->userIsWatching() ) { - // Adds watch action link - $links['actions']['watch'] = array( + // Adds watch view link + $links['views']['watch'] = array( 'class' => ( $action == 'watch' or $action == 'unwatch' ) ? 'selected' : false, 'text' => wfMsg( 'watch' ), + 'img' => "{$wgStylePath}/vector/images/watch_off.gif", 'href' => $this->mTitle->getLocalUrl( 'action=watch' ) ); } else { - // Adds unwatch action link - $links['actions']['unwatch'] = array( + // Adds unwatch view link + $links['views']['unwatch'] = array( 'class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false, 'text' => wfMsg( 'unwatch' ), + 'img' => "{$wgStylePath}/vector/images/watch_on.gif", 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' ) ); } @@ -722,7 +724,7 @@ class VectorTemplate extends QuickTemplate {
msg('views') ?>
diff --git a/skins/common/ajaxwatch.js b/skins/common/ajaxwatch.js index c8d90b8090..2127cbf8ff 100644 --- a/skins/common/ajaxwatch.js +++ b/skins/common/ajaxwatch.js @@ -21,11 +21,26 @@ 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); - } + 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"; + } + } + }else{ + for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) { + changeText(wgAjaxWatch.watchLinks[i], newText); + } + } }; wgAjaxWatch.setLinkID = function(newId) { @@ -112,6 +127,7 @@ 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) { @@ -132,6 +148,23 @@ wgAjaxWatch.onLoad = function() { return; } } + + // 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")); + } + el1.firstChild.onmouseout = function(e){ + this.firstChild.src = (wgAjaxWatch.watching ? this.firstChild.src.replace(/_off/, "_on") : this.firstChild.src.replace(/_on/, "_off")); + } + } + }catch(e){ + // not using the icon + } + // The id can be either for the parent (Monobook-based) or the element // itself (non-Monobook) diff --git a/skins/vector/images/watch_off.gif b/skins/vector/images/watch_off.gif new file mode 100644 index 0000000000000000000000000000000000000000..a17f62629fe39e9e64db79ddfce759e97890c972 GIT binary patch literal 550 zcmZ?wbhEHbU4xj~%jsyBBYNc;d>N{bye( zgzQlb-}mOjcLwXtiLK|=Blms%_VdWa*UNW3VzuA$?&J51x8JinZ2kQ8hkWp!=Wo6~ zeEx;mcFT*m-*jRRB)4BUeeG@C?CaZ(Js0-eQ8x7|hvU{84?dPpyK0tl=>4Z3)7Rbe zEIKh^M)$?F2cG8kU)pu@ z#mCP-j$L|Vn|UO(=Jcw)PhEFgvp3#`)t%%VQ>J&pDbX9=zvI2oG`FAHv}~`xyxBJcXX(T zn{#${u*f*rd-c1@avHM-iSg-pYBs3{FgkH_H7UC3vKv||J97C8cJQic@mbk2%J&CJ zn=$YPDX@8WvPd%61O)~PtBRgG$Kj!WIgo>q>4r74)D2T@CRQE|X9**v8w@-GY^?ku XcFYDhTuglQ&iVRr3!P(PWUvMR@8H6W literal 0 HcmV?d00001 diff --git a/skins/vector/images/watch_on.gif b/skins/vector/images/watch_on.gif new file mode 100644 index 0000000000000000000000000000000000000000..6c1c587cc60987a57c054ed19ca55d7e81ca6908 GIT binary patch literal 543 zcmZ?wbhEHbJBQ;|o!A3MF1}7_KY#4fo5a@hA3y&Ht~$+Xzh&|EhtFPrnYQlU&!4}f19q2B zyZY?)*Eb)&zj*siCSbRG@Sd|b-flenl*?(`gq3$rUwdnoa){e`+w$FywjF!U?yz<3 zfv4(``#ygDp4@(6!M2B?HK+CC4>HJ2fVJ^(>gC$rXPO)=?9O?HfGx`RWq*r`t|Gg@89bW zK4lohK=CIF*mXJ}5)>y4>@^KuO-;6Z_RSp~=2}MVogFgn-UcrHl5*@KOy1s{DyFVY z(uR!ctaIk@xG_0so5-)&xPsG6kWp{b97j6_Sua&)=S}(w48mTXo))|so0N4=o)lxW u-pImbdC^nA#+!{pO^L-x^A-b#4l|pOC^whHEe|PU@so;Hto$b%8LR