Put the watch icon part of the changes reverted in r57125 back in.
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 30 Sep 2009 18:46:23 +0000 (18:46 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 30 Sep 2009 18:46:23 +0000 (18:46 +0000)
includes/DefaultSettings.php
skins/Vector.php
skins/common/ajaxwatch.js
skins/vector/images/watch-icon-loading.gif [new file with mode: 0644]
skins/vector/images/watch-icons.png [new file with mode: 0644]
skins/vector/main-ltr.css
skins/vector/main-rtl.css

index d86f1cb..466855e 100644 (file)
@@ -1606,7 +1606,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches do not keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '241';
+$wgStyleVersion = '243';
 
 
 # Server-side caching:
@@ -4096,12 +4096,19 @@ $wgEnforceHtmlIds = true;
 $wgUseTwoButtonsSearchForm = true;
 
 /**
- *  Search form behavior for Vector skin only
+ * Search form behavior for Vector skin only
  * true = use an icon search button
  * false = use Go & Search buttons
  */
 $wgVectorUseSimpleSearch = false;
 
+/**
+ * Watch and unwatch as an icon rather than a link for Vector skin only
+ * true = use an icon watch/unwatch button
+ * false = use watch/unwatch text link
+ */
+$wgVectorUseIconWatch = false;
+
 /**
  * Preprocessor caching threshold
  */
index f65d29a..e18230e 100644 (file)
@@ -59,8 +59,8 @@ class SkinVector extends SkinTemplate {
         * @private
         */
        function buildNavigationUrls() {
-               global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle;
-               global $wgDisableLangConversion;
+               global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle, $wgStylePath;
+               global $wgDisableLangConversion, $wgVectorUseIconWatch;
 
                wfProfileIn( __METHOD__ );
 
@@ -271,7 +271,6 @@ class SkinVector extends SkinTemplate {
                                }
                        }
                        wfProfileOut( __METHOD__ . '-live' );
-
                        /**
                         * The following actions use messages which, if made particular to
                         * the Vector skin, would break the Ajax code which makes this
@@ -282,29 +281,21 @@ class SkinVector extends SkinTemplate {
                         * the global versions.
                         */
                        // Checks if the user is logged in
-                       if( $this->loggedin ) {
-                               // Checks if the user is watching this page
-                               if( !$this->mTitle->userIsWatching() ) {
-                                       // Adds watch action link
-                                       $links['actions']['watch'] = array(
-                                               'class' =>
-                                                       ( $action == 'watch' or $action == 'unwatch' ) ?
-                                                               'selected' : false,
-                                               'text' => wfMsg( 'watch' ),
-                                               'href' => $this->mTitle->getLocalUrl( 'action=watch' )
-                                       );
+                       if ( $this->loggedin ) {
+                               if ( $wgVectorUseIconWatch ) {
+                                       $class = 'icon ';
+                                       $place = 'views';
                                } else {
-                                       // Adds unwatch action link
-                                       $links['actions']['unwatch'] = array(
-                                               'class' =>
-                                                       ($action == 'unwatch' or $action == 'watch') ?
-                                                               'selected' : false,
-                                               'text' => wfMsg( 'unwatch' ),
-                                               'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
-                                       );
+                                       $class = '';
+                                       $place = 'actions';
                                }
+                               $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
+                               $links[$place][$mode] = array(
+                                       'class' => $class . ( ( $action == 'watch' || $action == 'unwatch' ) ? ' selected' : false ),
+                                       'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
+                                       'href' => $this->mTitle->getLocalUrl( 'action=' . $mode )
+                               );
                        }
-
                        // This is instead of SkinTemplateTabs - which uses a flat array
                        wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) );
 
@@ -722,7 +713,7 @@ class VectorTemplate extends QuickTemplate {
        <h5><?php $this->msg('views') ?></h5>
        <ul <?php $this->html('userlangattributes') ?>>
                <?php foreach ($this->data['view_urls'] as $key => $link ): ?>
-                       <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><span><?php echo htmlspecialchars( $link['text'] ) ?></span></a></li>
+                       <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo (array_key_exists('img',$link) ?  '<img src="'.$link['img'].'" alt="'.$link['text'].'" />' : '<span>'.htmlspecialchars( $link['text'] ).'</span>') ?></a></li>
                <?php endforeach; ?>
        </ul>
 </div>
index c8d90b8..f3211ed 100644 (file)
@@ -21,16 +21,29 @@ 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, '' );
+                       }
+               }
+       } 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 );
+       wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId );
        akeytt(newId); // update tooltips for Monobook
 };
 
@@ -112,27 +125,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"
diff --git a/skins/vector/images/watch-icon-loading.gif b/skins/vector/images/watch-icon-loading.gif
new file mode 100644 (file)
index 0000000..618c308
Binary files /dev/null and b/skins/vector/images/watch-icon-loading.gif differ
diff --git a/skins/vector/images/watch-icons.png b/skins/vector/images/watch-icons.png
new file mode 100644 (file)
index 0000000..54b2c79
Binary files /dev/null and b/skins/vector/images/watch-icons.png differ
index 411ff76..b9cc55f 100644 (file)
@@ -1049,3 +1049,41 @@ div#bodyContent {
        line-height: 1.5em;
 }
 
+/* Watch/Unwatch Icon Styling */
+#ca-unwatch.icon,
+#ca-watch.icon {
+}
+#ca-unwatch.icon a,
+#ca-watch.icon a {
+       margin: 0;
+       padding: 0;
+       outline: none;
+       display: block;
+       width: 26px;
+       height: 2.5em;
+}
+#ca-unwatch.icon a {
+       background-image: url(images/watch-icons.png);
+       background-position: -43px 60%;
+}
+#ca-watch.icon a {
+       background-image: url(images/watch-icons.png);
+       background-position: 5px 60%;
+}
+#ca-unwatch.icon a:hover {
+       background-image: url(images/watch-icons.png);
+       background-position: -67px 60%;
+}
+#ca-watch.icon a:hover {
+       background-image: url(images/watch-icons.png);
+       background-position: -19px 60%;
+}
+#ca-unwatch.icon a.loading,
+#ca-watch.icon a.loading {
+       background-image: url(images/watch-icon-loading.gif);
+       background-position: center 60%;
+}
+#ca-unwatch.icon a span,
+#ca-watch.icon a span {
+       display: none;
+}
index 69b3de2..cf5d9a2 100644 (file)
@@ -1049,4 +1049,41 @@ div#bodyContent {
        line-height: 1.5em;
 }
 
-       
\ No newline at end of file
+/* Watch/Unwatch Icon Styling */
+#ca-unwatch.icon,
+#ca-watch.icon {
+}
+#ca-unwatch.icon a,
+#ca-watch.icon a {
+       margin: 0;
+       padding: 0;
+       outline: none;
+       display: block;
+       width: 26px;
+       height: 2.5em;
+}
+#ca-unwatch.icon a {
+       background-image: url(images/watch-icons.png);
+       background-position: -43px 60%;
+}
+#ca-watch.icon a {
+       background-image: url(images/watch-icons.png);
+       background-position: 5px 60%;
+}
+#ca-unwatch.icon a:hover {
+       background-image: url(images/watch-icons.png);
+       background-position: -67px 60%;
+}
+#ca-watch.icon a:hover {
+       background-image: url(images/watch-icons.png);
+       background-position: -19px 60%;
+}
+#ca-unwatch.icon a.loading,
+#ca-watch.icon a.loading {
+       background-image: url(images/watch-icon-loading.gif);
+       background-position: center 60%;
+}
+#ca-unwatch.icon a span,
+#ca-watch.icon a span {
+       display: none;
+}