r98082 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98081‎ | r98082 | r98083 >
Date:20:28, 25 September 2011
Author:aaron
Status:ok
Tags:
Comment:
* Removed references to FlaggedRevs JS object in PHP. Set event handlers all in JS.
* Removed some logToggle JS duplication.
Modified paths:
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsXML.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.js (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsXML.php
@@ -290,7 +290,6 @@
291291 $encPath = htmlspecialchars( FlaggedRevs::styleUrlPath() . '/img' );
292292 $img = '<img id="mw-fr-revisiontoggle" class="fr-toggle-arrow"';
293293 $img .= " src=\"{$encPath}/arrow-down.png\" style=\"display:none;\"";
294 - $img .= ' onmouseover="FlaggedRevs.onBoxMouseOver()"';
295294 $img .= ' alt="' . wfMsgHtml( 'revreview-toggle-title' ) . '" />';
296295 return $img;
297296 }
@@ -301,8 +300,7 @@
302301 */
303302 public static function ratingToggle() {
304303 return '<a id="mw-fr-revisiontoggle" class="fr-toggle-symbol"' .
305 - ' style="display:none;" onclick="FlaggedRevs.toggleBoxDetails()" title="' .
306 - wfMsgHtml( 'revreview-toggle-title' ) . '" >' .
 304+ ' style="display:none;" title="' . wfMsgHtml( 'revreview-toggle-title' ) . '" >' .
307305 wfMsgHtml( 'revreview-toggle-show' ) . '</a>';
308306 }
309307
@@ -311,8 +309,7 @@
312310 * @return string
313311 */
314312 public static function diffToggle() {
315 - $toggle = '<a class="fr-toggle-text" ' .
316 - ' onclick="FlaggedRevs.toggleDiff()" title="' .
 313+ $toggle = '<a class="fr-toggle-text" title="' .
317314 wfMsgHtml( 'revreview-diff-toggle-title' ) . '" >' .
318315 wfMsgHtml( 'revreview-diff-toggle-show' ) . '</a>';
319316 return '<span id="mw-fr-difftoggle" style="display:none;">' .
@@ -324,11 +321,10 @@
325322 * @return string
326323 */
327324 public static function logToggle() {
328 - $toggle = '<a class="fr-toggle-text" ' .
329 - ' onclick="FlaggedRevs.toggleLog()" title="' .
 325+ $toggle = '<a class="fr-toggle-text" title="' .
330326 wfMsgHtml( 'revreview-log-toggle-title' ) . '" >' .
331327 wfMsgHtml( 'revreview-log-toggle-show' ) . '</a>';
332 - return '<span id="mw-fr-logtoggle" style="display:none;">' .
 328+ return '<span id="mw-fr-logtoggle" class="fr-logtoggle-excerpt" style="display:none;">' .
333329 wfMsgHtml( 'parentheses', $toggle ) . '</span>';
334330 }
335331
@@ -337,11 +333,10 @@
338334 * @return string
339335 */
340336 public static function logDetailsToggle() {
341 - $toggle = '<a class="fr-toggle-text" ' .
342 - ' onclick="FlaggedRevs.toggleLogDetails()" title="' .
 337+ $toggle = '<a class="fr-toggle-text" title="' .
343338 wfMsgHtml( 'revreview-log-details-title' ) . '" >' .
344339 wfMsgHtml( 'revreview-log-details-show' ) . '</a>';
345 - return '<span id="mw-fr-logtoggle" style="display:none;">' .
 340+ return '<span id="mw-fr-logtoggle" class="fr-logtoggle-details" style="display:none;">' .
346341 wfMsgHtml( 'parentheses', $toggle ) . '</span>';
347342 }
348343
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -364,12 +364,9 @@
365365 } else {
366366 $this->showDraftVersion( $srev, $tag, $prot );
367367 }
368 - $encJS = ''; // JS events to use
369368 # Some checks for which tag CSS to use
370369 if ( $this->useSimpleUI() ) {
371370 $tagClass = 'flaggedrevs_short';
372 - # Collapse the box details on mouseOut
373 - $encJS .= ' onmouseout="FlaggedRevs.onBoxMouseOut(event)"';
374371 } elseif ( $pristine ) {
375372 $tagClass = 'flaggedrevs_pristine';
376373 } elseif ( $quality ) {
@@ -380,7 +377,7 @@
381378 # Wrap tag contents in a div
382379 if ( $tag != '' ) {
383380 $css = "{$tagClass} plainlinks noprint";
384 - $notice = "<div id=\"mw-fr-revisiontag\" class=\"{$css}\"{$encJS}>{$tag}</div>\n";
 381+ $notice = "<div id=\"mw-fr-revisiontag\" class=\"{$css}\">{$tag}</div>\n";
385382 $this->reviewNotice .= $notice;
386383 }
387384 return true;
Index: trunk/extensions/FlaggedRevs/presentation/modules/flaggedrevs.js
@@ -14,21 +14,31 @@
1515 var toggle = $('#mw-fr-revisiontoggle');
1616 if ( toggle.length ) {
1717 toggle.css('display','inline'); /* show toggle control */
18 - this.hideBoxDetails(); /* hide the initially displayed ratings */
 18+ FlaggedRevs.hideBoxDetails(); /* hide the initially displayed ratings */
1919 }
20 - // Enables diff detail box
 20+ // Bar UI: Toggle the box when the toggle is clicked
 21+ $('.fr-toggle-symbol#mw-fr-revisiontoggle').click( FlaggedRevs.toggleBoxDetails );
 22+ // Simple UI: Show the box on mouseOver
 23+ $('.fr-toggle-arrow#mw-fr-revisiontoggle').mouseover( FlaggedRevs.onBoxMouseOver );
 24+ $('.flaggedrevs_short#mw-fr-revisiontag').mouseout( FlaggedRevs.onBoxMouseOut );
 25+
 26+ // Enables diff detail box and toggle
2127 toggle = $('#mw-fr-difftoggle');
2228 if ( toggle.length ) {
2329 toggle.css('display','inline'); /* show toggle control */
2430 $('#mw-fr-stablediff').hide();
2531 }
26 - // Enables log detail box
 32+ toggle.children('a').click( FlaggedRevs.toggleDiff );
 33+
 34+ // Enables log detail box and toggle
2735 toggle = $('#mw-fr-logtoggle');
2836 if ( toggle.length ) {
2937 toggle.css('display','inline'); /* show toggle control */
3038 $('#mw-fr-logexcerpt').hide();
3139 }
32 - // Enables changing of save button when "review this" checkbox changes */
 40+ toggle.children('a').click( FlaggedRevs.toggleLog );
 41+
 42+ // Enables changing of save button when "review this" checkbox changes
3343 $('#wpReviewEdit').click( FlaggedRevs.updateSaveButton );
3444 },
3545
@@ -49,11 +59,11 @@
5060 if ( toggle.length && ratings.length ) {
5161 // Collapsed -> expand
5262 if ( ratings.css('display') == 'none' ) {
53 - this.showBoxDetails();
 63+ FlaggedRevs.showBoxDetails();
5464 toggle.text( mw.msg('revreview-toggle-hide') );
5565 // Expanded -> collapse
5666 } else {
57 - this.hideBoxDetails();
 67+ FlaggedRevs.hideBoxDetails();
5868 toggle.text( mw.msg('revreview-toggle-show') );
5969 }
6070 }
@@ -61,15 +71,15 @@
6272
6373 /* Expands flag info box details on mouseOver */
6474 'onBoxMouseOver': function( event ) {
65 - window.clearTimeout( this.boxCollapseTimer );
66 - this.boxCollapseTimer = null;
67 - this.showBoxDetails();
 75+ window.clearTimeout( FlaggedRevs.boxCollapseTimer );
 76+ FlaggedRevs.boxCollapseTimer = null;
 77+ FlaggedRevs.showBoxDetails();
6878 },
6979
7080 /* Hides flag info box details on mouseOut *except* for event bubbling */
7181 'onBoxMouseOut': function( event ) {
72 - if ( !this.isMouseOutBubble( event, 'mw-fr-revisiontag' ) ) {
73 - this.boxCollapseTimer = window.setTimeout( this.hideBoxDetails, 150 );
 82+ if ( !FlaggedRevs.isMouseOutBubble( event, 'mw-fr-revisiontag' ) ) {
 83+ FlaggedRevs.boxCollapseTimer = window.setTimeout( FlaggedRevs.hideBoxDetails, 150 );
7484 }
7585 },
7686
@@ -113,27 +123,20 @@
114124 var log = $('#mw-fr-logexcerpt');
115125 var toggle = $('#mw-fr-logtoggle');
116126 if ( log.length && toggle.length ) {
117 - if ( log.css('display') == 'none' ) {
118 - log.show();
119 - toggle.children('a').text( mw.msg('revreview-log-toggle-hide') );
 127+ // Two different message sets used here...
 128+ if ( toggle.hasClass('fr-logtoggle-details') ) {
 129+ var hideMsg = mw.msg('revreview-log-details-hide');
 130+ var showMsg = mw.msg('revreview-log-details-show');
120131 } else {
121 - log.hide();
122 - toggle.children('a').text( mw.msg('revreview-log-toggle-show') );
 132+ var hideMsg = mw.msg('revreview-log-toggle-hide');
 133+ var showMsg = mw.msg('revreview-log-toggle-show');
123134 }
124 - }
125 - },
126 -
127 - /* Toggles log excerpts */
128 - 'toggleLogDetails': function() {
129 - var log = $('#mw-fr-logexcerpt');
130 - var toggle = $('#mw-fr-logtoggle');
131 - if ( log.length && toggle.length ) {
132135 if ( log.css('display') == 'none' ) {
133136 log.show();
134 - toggle.children('a').text( mw.msg('revreview-log-details-hide') );
 137+ toggle.children('a').text( hideMsg );
135138 } else {
136139 log.hide();
137 - toggle.children('a').text( mw.msg('revreview-log-details-show') );
 140+ toggle.children('a').text( showMsg );
138141 }
139142 }
140143 },

Follow-up revisions

RevisionCommit summaryAuthorDate
r98096[flaggedrevs.js]: Code cleanup...krinkle23:16, 25 September 2011

Status & tagging log