Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | $wgAvailableRights[] = 'stablesettings'; |
293 | 293 | |
294 | 294 | # Bump this number every time you change flaggedrevs.css/flaggedrevs.js |
295 | | -$wgFlaggedRevStyleVersion = 61; |
| 295 | +$wgFlaggedRevStyleVersion = 62; |
296 | 296 | |
297 | 297 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
298 | 298 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevsXML.php |
— | — | @@ -240,7 +240,8 @@ |
241 | 241 | |
242 | 242 | public static function ratingToggle() { |
243 | 243 | return "<a id='mw-revisiontoggle' class='flaggedrevs_toggle' style='display:none;'" . |
244 | | - " onclick='toggleRevRatings()' title='" . wfMsgHtml('revreview-toggle-title') . "' >" . |
| 244 | + " onclick='FlaggedRevs.toggleRevRatings()' title='" . |
| 245 | + wfMsgHtml('revreview-toggle-title') . "' >" . |
245 | 246 | wfMsg( 'revreview-toggle' ) . "</a>"; |
246 | 247 | } |
247 | 248 | |
— | — | @@ -286,7 +287,7 @@ |
287 | 288 | # 6 is an arbitrary value choosen according to screen space and usability |
288 | 289 | if( $size > 6 ) { |
289 | 290 | $attribs = array( 'name' => "wp$quality", 'id' => "wp$quality", |
290 | | - 'onchange' => "updateRatingForm()" ) + $toggle; |
| 291 | + 'onchange' => "FlaggedRevs.updateRatingForm()" ) + $toggle; |
291 | 292 | $form .= Xml::openElement( 'select', $attribs ); |
292 | 293 | foreach( $label as $i => $name ) { |
293 | 294 | $optionClass = array( 'class' => "fr-rating-option-$i" ); |
— | — | @@ -298,7 +299,7 @@ |
299 | 300 | } elseif( $numLevels > 2 ) { |
300 | 301 | foreach( $label as $i => $name ) { |
301 | 302 | $attribs = array( 'class' => "fr-rating-option-$i", |
302 | | - 'onchange' => "updateRatingForm()" ); |
| 303 | + 'onchange' => "FlaggedRevs.updateRatingForm()" ); |
303 | 304 | $form .= Xml::radioLabel( FlaggedRevs::getTagMsg($name), "wp$quality", $i, |
304 | 305 | "wp$quality".$i, ($i == $selected), $attribs ) . "\n"; |
305 | 306 | } |
— | — | @@ -307,7 +308,7 @@ |
308 | 309 | # If disable, use the current flags; if none, then use the min flag. |
309 | 310 | $i = $disabled ? $selected : $minLevel; |
310 | 311 | $attribs = array( 'class' => "fr-rating-option-$i", |
311 | | - 'onchange' => "updateRatingForm()" ); |
| 312 | + 'onchange' => "FlaggedRevs.updateRatingForm()" ); |
312 | 313 | $attribs = $attribs + $toggle + array('value' => $minLevel); |
313 | 314 | $form .= Xml::checkLabel( wfMsg( "revreview-{$label[$i]}" ), "wp$quality", |
314 | 315 | "wp$quality", ($selected == $i), $attribs ) . "\n"; |
Index: trunk/extensions/FlaggedRevs/flaggedrevs.js |
— | — | @@ -2,97 +2,99 @@ |
3 | 3 | |
4 | 4 | /* Every time you change this JS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
5 | 5 | |
6 | | -/* Hide rating clutter */ |
7 | | -function enable_showhide() { |
8 | | - var toggle = document.getElementById('mw-revisiontoggle'); |
9 | | - if( !toggle ) return; |
10 | | - toggle.style.display = 'inline'; |
11 | | - var ratings = document.getElementById('mw-revisionratings'); |
12 | | - if( !ratings ) return; |
13 | | - ratings.style.display = 'none'; |
14 | | -} |
15 | | - |
16 | | -/* Toggles ratings */ |
17 | | -function toggleRevRatings() { |
18 | | - var ratings = document.getElementById('mw-revisionratings'); |
19 | | - if( !ratings ) return; |
20 | | - if( ratings.style.display == 'none' ) { |
21 | | - ratings.style.display = 'inline'; |
22 | | - } else { |
| 6 | +var FlaggedRevs = { |
| 7 | + /* Hide rating clutter */ |
| 8 | + 'enableShowhide': function() { |
| 9 | + var toggle = document.getElementById('mw-revisiontoggle'); |
| 10 | + if( !toggle ) return; |
| 11 | + toggle.style.display = 'inline'; |
| 12 | + var ratings = document.getElementById('mw-revisionratings'); |
| 13 | + if( !ratings ) return; |
23 | 14 | ratings.style.display = 'none'; |
24 | | - } |
25 | | -} |
26 | | - |
27 | | -/* |
28 | | -* a) Disable submit in case of invalid input. |
29 | | -* b) Update colors when select changes (Opera already does this). |
30 | | -* c) Also remove comment box clutter in case of invalid input. |
31 | | -*/ |
32 | | -function updateRatingForm() { |
33 | | - var ratingform = document.getElementById('mw-ratingselects'); |
34 | | - if( !ratingform ) return; |
35 | | - var disabled = document.getElementById('fr-rating-controls-disabled'); |
36 | | - if( disabled ) return; |
37 | | - |
38 | | - var quality = true; |
39 | | - var allzero = true; |
40 | | - var somezero = false; |
41 | | - |
42 | | - for( tag in wgFlaggedRevsParams.tags ) { |
43 | | - var controlName = "wp" + tag; |
44 | | - var levels = document.getElementsByName(controlName); |
45 | | - var selectedlevel = 0; // default |
46 | | - |
47 | | - if( levels[0].nodeName == 'SELECT' ) { |
48 | | - selectedlevel = levels[0].selectedIndex; |
49 | | - // Update color. Opera does this already, and doing so |
50 | | - // seems to kill custom pretty opera skin form styling. |
51 | | - if( navigator.appName != 'Opera') { |
52 | | - value = levels[0].getElementsByTagName('option')[selectedlevel].value; |
53 | | - levels[0].className = 'fr-rating-option-' + value; |
54 | | - } |
55 | | - } else if( levels[0].type == 'radio' ) { |
56 | | - for( i = 0; i < levels.length; i++ ) { |
57 | | - if( levels[i].checked ) { |
58 | | - selectedlevel = i; |
59 | | - break; |
| 15 | + }, |
| 16 | + |
| 17 | + /* Toggles ratings */ |
| 18 | + 'toggleRevRatings': function() { |
| 19 | + var ratings = document.getElementById('mw-revisionratings'); |
| 20 | + if( !ratings ) return; |
| 21 | + if( ratings.style.display == 'none' ) { |
| 22 | + ratings.style.display = 'inline'; |
| 23 | + } else { |
| 24 | + ratings.style.display = 'none'; |
| 25 | + } |
| 26 | + }, |
| 27 | + |
| 28 | + /* |
| 29 | + * a) Disable submit in case of invalid input. |
| 30 | + * b) Update colors when select changes (Opera already does this). |
| 31 | + * c) Also remove comment box clutter in case of invalid input. |
| 32 | + */ |
| 33 | + 'updateRatingForm': function() { |
| 34 | + var ratingform = document.getElementById('mw-ratingselects'); |
| 35 | + if( !ratingform ) return; |
| 36 | + var disabled = document.getElementById('fr-rating-controls-disabled'); |
| 37 | + if( disabled ) return; |
| 38 | + |
| 39 | + var quality = true; |
| 40 | + var allzero = true; |
| 41 | + var somezero = false; |
| 42 | + |
| 43 | + for( tag in wgFlaggedRevsParams.tags ) { |
| 44 | + var controlName = "wp" + tag; |
| 45 | + var levels = document.getElementsByName(controlName); |
| 46 | + var selectedlevel = 0; // default |
| 47 | + |
| 48 | + if( levels[0].nodeName == 'SELECT' ) { |
| 49 | + selectedlevel = levels[0].selectedIndex; |
| 50 | + // Update color. Opera does this already, and doing so |
| 51 | + // seems to kill custom pretty opera skin form styling. |
| 52 | + if( navigator.appName != 'Opera') { |
| 53 | + value = levels[0].getElementsByTagName('option')[selectedlevel].value; |
| 54 | + levels[0].className = 'fr-rating-option-' + value; |
60 | 55 | } |
| 56 | + } else if( levels[0].type == 'radio' ) { |
| 57 | + for( i = 0; i < levels.length; i++ ) { |
| 58 | + if( levels[i].checked ) { |
| 59 | + selectedlevel = i; |
| 60 | + break; |
| 61 | + } |
| 62 | + } |
| 63 | + } else if( levels[0].type == 'checkbox' ) { |
| 64 | + selectedlevel = (levels[0].checked) ? 1: 0; |
| 65 | + } else { |
| 66 | + return; // error: should not happen |
61 | 67 | } |
62 | | - } else if( levels[0].type == 'checkbox' ) { |
63 | | - selectedlevel = (levels[0].checked) ? 1: 0; |
64 | | - } else { |
65 | | - return; // error: should not happen |
| 68 | + |
| 69 | + // Get quality level for this tag |
| 70 | + qualityLevel = wgFlaggedRevsParams.tags[tag]; |
| 71 | + |
| 72 | + if( selectedlevel < qualityLevel ) { |
| 73 | + quality = false; // not a quality review |
| 74 | + } |
| 75 | + if( selectedlevel > 0 ) { |
| 76 | + allzero = false; |
| 77 | + } else { |
| 78 | + somezero = true; |
| 79 | + } |
66 | 80 | } |
67 | | - |
68 | | - // Get quality level for this tag |
69 | | - qualityLevel = wgFlaggedRevsParams.tags[tag]; |
70 | | - |
71 | | - if( selectedlevel < qualityLevel ) { |
72 | | - quality = false; // not a quality review |
| 81 | + // Show note box only for quality revs |
| 82 | + var notebox = document.getElementById('mw-notebox'); |
| 83 | + if( notebox ) { |
| 84 | + notebox.style.display = quality ? 'inline' : 'none'; |
73 | 85 | } |
74 | | - if( selectedlevel > 0 ) { |
75 | | - allzero = false; |
76 | | - } else { |
77 | | - somezero = true; |
| 86 | + // If only a few levels are zero, don't show submit link |
| 87 | + var submit = document.getElementById('submitreview'); |
| 88 | + submit.disabled = ( somezero && !allzero ) ? 'disabled' : ''; |
| 89 | + // Clear note box data if not shown |
| 90 | + var notes = document.getElementById('wpNotes'); |
| 91 | + if( notes ) { |
| 92 | + notes.value = quality ? notes.value : ''; |
78 | 93 | } |
79 | 94 | } |
80 | | - // Show note box only for quality revs |
81 | | - var notebox = document.getElementById('mw-notebox'); |
82 | | - if( notebox ) { |
83 | | - notebox.style.display = quality ? 'inline' : 'none'; |
84 | | - } |
85 | | - // If only a few levels are zero, don't show submit link |
86 | | - var submit = document.getElementById('submitreview'); |
87 | | - submit.disabled = ( somezero && !allzero ) ? 'disabled' : ''; |
88 | | - // Clear note box data if not shown |
89 | | - var notes = document.getElementById('wpNotes'); |
90 | | - if( notes ) { |
91 | | - notes.value = quality ? notes.value : ''; |
92 | | - } |
93 | | -} |
| 95 | +}; |
94 | 96 | |
95 | | -addOnloadHook(enable_showhide); |
96 | | -addOnloadHook(updateRatingForm); |
| 97 | +addOnloadHook(FlaggedRevs.enableShowhide); |
| 98 | +addOnloadHook(FlaggedRevs.updateRatingForm); |
97 | 99 | |
98 | 100 | // dependencies: |
99 | 101 | // * ajax.js: |
— | — | @@ -199,6 +201,7 @@ |
200 | 202 | for( var i=0; i < selects.length; i++) { |
201 | 203 | selects[i].disabled = ""; |
202 | 204 | } |
| 205 | + return true; |
203 | 206 | }; |
204 | 207 | |
205 | 208 | wgAjaxReview.processResult = function(request) { |
— | — | @@ -206,7 +209,7 @@ |
207 | 210 | return; |
208 | 211 | } |
209 | 212 | var response = request.responseText; |
210 | | - if( msg = response.substr(6) ) { |
| 213 | + if( (msg = response.substr(6)) ) { |
211 | 214 | jsMsg( msg, 'review' ); // success notice |
212 | 215 | window.scroll(0,0); // scroll up to notice |
213 | 216 | tagBox = document.getElementById('mw-revisiontag'); |