r57130 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57129‎ | r57130 | r57131 >
Date:18:46, 30 September 2009
Author:catrope
Status:ok
Tags:
Comment:
Put the watch icon part of the changes reverted in r57125 back in.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)
  • /trunk/phase3/skins/common/ajaxwatch.js (modified) (history)
  • /trunk/phase3/skins/vector/images/watch-icon-loading.gif (added) (history)
  • /trunk/phase3/skins/vector/images/watch-icons.png (added) (history)
  • /trunk/phase3/skins/vector/main-ltr.css (modified) (history)
  • /trunk/phase3/skins/vector/main-rtl.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/ajaxwatch.js
@@ -21,16 +21,29 @@
2222 wgAjaxWatch.inprogress = false; // ajax request in progress
2323 wgAjaxWatch.timeoutID = null; // see wgAjaxWatch.ajaxCall
2424 wgAjaxWatch.watchLinks = []; // "watch"/"unwatch" links
 25+wgAjaxWatch.iconMode = false; // new icon driven functionality
 26+wgAjaxWatch.imgBasePath = ""; // base img path derived from icons on load
2527
26 -wgAjaxWatch.setLinkText = function(newText) {
27 - for (i = 0; i < wgAjaxWatch.watchLinks.length; i++) {
28 - changeText(wgAjaxWatch.watchLinks[i], newText);
 28+wgAjaxWatch.setLinkText = function( newText ) {
 29+ if( wgAjaxWatch.iconMode ) {
 30+ for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) {
 31+ wgAjaxWatch.watchLinks[i].firstChild.alt = newText;
 32+ if ( newText == wgAjaxWatch.watchingMsg || newText == wgAjaxWatch.unwatchingMsg ) {
 33+ wgAjaxWatch.watchLinks[i].className += ' loading';
 34+ } else if ( newText == wgAjaxWatch.watchMsg || newText == wgAjaxWatch.unwatchMsg ) {
 35+ wgAjaxWatch.watchLinks[i].className = wgAjaxWatch.watchLinks[i].className.replace( /loading/i, '' );
 36+ }
 37+ }
 38+ } else {
 39+ for ( i = 0; i < wgAjaxWatch.watchLinks.length; i++ ) {
 40+ changeText( wgAjaxWatch.watchLinks[i], newText );
 41+ }
2942 }
3043 };
3144
32 -wgAjaxWatch.setLinkID = function(newId) {
 45+wgAjaxWatch.setLinkID = function( newId ) {
3346 // We can only set the first one
34 - wgAjaxWatch.watchLinks[0].setAttribute( 'id', newId );
 47+ wgAjaxWatch.watchLinks[0].parentNode.setAttribute( 'id', newId );
3548 akeytt(newId); // update tooltips for Monobook
3649 };
3750
@@ -112,27 +125,33 @@
113126 wgAjaxWatch.onLoad = function() {
114127 // This document structure hardcoding sucks. We should make a class and
115128 // toss all this out the window.
 129+
116130 var el1 = document.getElementById("ca-unwatch");
117131 var el2 = null;
118 - if (!el1) {
 132+ if ( !el1 ) {
119133 el1 = document.getElementById("mw-unwatch-link1");
120134 el2 = document.getElementById("mw-unwatch-link2");
121135 }
122 - if(el1) {
 136+ if( el1 ) {
123137 wgAjaxWatch.watching = true;
124138 } else {
125139 wgAjaxWatch.watching = false;
126140 el1 = document.getElementById("ca-watch");
127 - if (!el1) {
 141+ if ( !el1 ) {
128142 el1 = document.getElementById("mw-watch-link1");
129143 el2 = document.getElementById("mw-watch-link2");
130144 }
131 - if(!el1) {
 145+ if( !el1 ) {
132146 wgAjaxWatch.supported = false;
133147 return;
134148 }
135149 }
136 -
 150+
 151+ // Detect if the watch/unwatch feature is in icon mode
 152+ if ( el1.className.match( /icon/i ) ) {
 153+ wgAjaxWatch.iconMode = true;
 154+ }
 155+
137156 // The id can be either for the parent (Monobook-based) or the element
138157 // itself (non-Monobook)
139158 wgAjaxWatch.watchLinks.push( el1.tagName.toLowerCase() == "a"
Index: trunk/phase3/skins/Vector.php
@@ -59,8 +59,8 @@
6060 * @private
6161 */
6262 function buildNavigationUrls() {
63 - global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle;
64 - global $wgDisableLangConversion;
 63+ global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle, $wgStylePath;
 64+ global $wgDisableLangConversion, $wgVectorUseIconWatch;
6565
6666 wfProfileIn( __METHOD__ );
6767
@@ -271,7 +271,6 @@
272272 }
273273 }
274274 wfProfileOut( __METHOD__ . '-live' );
275 -
276275 /**
277276 * The following actions use messages which, if made particular to
278277 * the Vector skin, would break the Ajax code which makes this
@@ -282,29 +281,21 @@
283282 * the global versions.
284283 */
285284 // Checks if the user is logged in
286 - if( $this->loggedin ) {
287 - // Checks if the user is watching this page
288 - if( !$this->mTitle->userIsWatching() ) {
289 - // Adds watch action link
290 - $links['actions']['watch'] = array(
291 - 'class' =>
292 - ( $action == 'watch' or $action == 'unwatch' ) ?
293 - 'selected' : false,
294 - 'text' => wfMsg( 'watch' ),
295 - 'href' => $this->mTitle->getLocalUrl( 'action=watch' )
296 - );
 285+ if ( $this->loggedin ) {
 286+ if ( $wgVectorUseIconWatch ) {
 287+ $class = 'icon ';
 288+ $place = 'views';
297289 } else {
298 - // Adds unwatch action link
299 - $links['actions']['unwatch'] = array(
300 - 'class' =>
301 - ($action == 'unwatch' or $action == 'watch') ?
302 - 'selected' : false,
303 - 'text' => wfMsg( 'unwatch' ),
304 - 'href' => $this->mTitle->getLocalUrl( 'action=unwatch' )
305 - );
 290+ $class = '';
 291+ $place = 'actions';
306292 }
 293+ $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
 294+ $links[$place][$mode] = array(
 295+ 'class' => $class . ( ( $action == 'watch' || $action == 'unwatch' ) ? ' selected' : false ),
 296+ 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
 297+ 'href' => $this->mTitle->getLocalUrl( 'action=' . $mode )
 298+ );
307299 }
308 -
309300 // This is instead of SkinTemplateTabs - which uses a flat array
310301 wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) );
311302
@@ -722,7 +713,7 @@
723714 <h5><?php $this->msg('views') ?></h5>
724715 <ul <?php $this->html('userlangattributes') ?>>
725716 <?php foreach ($this->data['view_urls'] as $key => $link ): ?>
726 - <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>
 717+ <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>
727718 <?php endforeach; ?>
728719 </ul>
729720 </div>
Index: trunk/phase3/skins/vector/images/watch-icons.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/phase3/skins/vector/images/watch-icons.png
___________________________________________________________________
Name: svn:mime-type
730721 + application/octet-stream
Index: trunk/phase3/skins/vector/images/watch-icon-loading.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/phase3/skins/vector/images/watch-icon-loading.gif
___________________________________________________________________
Name: svn:mime-type
731722 + application/octet-stream
Index: trunk/phase3/skins/vector/main-ltr.css
@@ -1049,3 +1049,41 @@
10501050 line-height: 1.5em;
10511051 }
10521052
 1053+/* Watch/Unwatch Icon Styling */
 1054+#ca-unwatch.icon,
 1055+#ca-watch.icon {
 1056+}
 1057+#ca-unwatch.icon a,
 1058+#ca-watch.icon a {
 1059+ margin: 0;
 1060+ padding: 0;
 1061+ outline: none;
 1062+ display: block;
 1063+ width: 26px;
 1064+ height: 2.5em;
 1065+}
 1066+#ca-unwatch.icon a {
 1067+ background-image: url(images/watch-icons.png);
 1068+ background-position: -43px 60%;
 1069+}
 1070+#ca-watch.icon a {
 1071+ background-image: url(images/watch-icons.png);
 1072+ background-position: 5px 60%;
 1073+}
 1074+#ca-unwatch.icon a:hover {
 1075+ background-image: url(images/watch-icons.png);
 1076+ background-position: -67px 60%;
 1077+}
 1078+#ca-watch.icon a:hover {
 1079+ background-image: url(images/watch-icons.png);
 1080+ background-position: -19px 60%;
 1081+}
 1082+#ca-unwatch.icon a.loading,
 1083+#ca-watch.icon a.loading {
 1084+ background-image: url(images/watch-icon-loading.gif);
 1085+ background-position: center 60%;
 1086+}
 1087+#ca-unwatch.icon a span,
 1088+#ca-watch.icon a span {
 1089+ display: none;
 1090+}
Index: trunk/phase3/skins/vector/main-rtl.css
@@ -1049,4 +1049,41 @@
10501050 line-height: 1.5em;
10511051 }
10521052
1053 -
\ No newline at end of file
 1053+/* Watch/Unwatch Icon Styling */
 1054+#ca-unwatch.icon,
 1055+#ca-watch.icon {
 1056+}
 1057+#ca-unwatch.icon a,
 1058+#ca-watch.icon a {
 1059+ margin: 0;
 1060+ padding: 0;
 1061+ outline: none;
 1062+ display: block;
 1063+ width: 26px;
 1064+ height: 2.5em;
 1065+}
 1066+#ca-unwatch.icon a {
 1067+ background-image: url(images/watch-icons.png);
 1068+ background-position: -43px 60%;
 1069+}
 1070+#ca-watch.icon a {
 1071+ background-image: url(images/watch-icons.png);
 1072+ background-position: 5px 60%;
 1073+}
 1074+#ca-unwatch.icon a:hover {
 1075+ background-image: url(images/watch-icons.png);
 1076+ background-position: -67px 60%;
 1077+}
 1078+#ca-watch.icon a:hover {
 1079+ background-image: url(images/watch-icons.png);
 1080+ background-position: -19px 60%;
 1081+}
 1082+#ca-unwatch.icon a.loading,
 1083+#ca-watch.icon a.loading {
 1084+ background-image: url(images/watch-icon-loading.gif);
 1085+ background-position: center 60%;
 1086+}
 1087+#ca-unwatch.icon a span,
 1088+#ca-watch.icon a span {
 1089+ display: none;
 1090+}
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1606,7 +1606,7 @@
16071607 * to ensure that client-side caches do not keep obsolete copies of global
16081608 * styles.
16091609 */
1610 -$wgStyleVersion = '241';
 1610+$wgStyleVersion = '243';
16111611
16121612
16131613 # Server-side caching:
@@ -4096,13 +4096,20 @@
40974097 $wgUseTwoButtonsSearchForm = true;
40984098
40994099 /**
4100 - * Search form behavior for Vector skin only
 4100+ * Search form behavior for Vector skin only
41014101 * true = use an icon search button
41024102 * false = use Go & Search buttons
41034103 */
41044104 $wgVectorUseSimpleSearch = false;
41054105
41064106 /**
 4107+ * Watch and unwatch as an icon rather than a link for Vector skin only
 4108+ * true = use an icon watch/unwatch button
 4109+ * false = use watch/unwatch text link
 4110+ */
 4111+$wgVectorUseIconWatch = false;
 4112+
 4113+/**
41074114 * Preprocessor caching threshold
41084115 */
41094116 $wgPreprocessorCacheThreshold = 1000;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r57125Revert r56924 (new watch icon and color changes for Vector) and followups r57...catrope17:58, 30 September 2009

Status & tagging log