Index: trunk/extensions/FlaggedRevs/flaggedrevs.css |
— | — | @@ -1,353 +0,0 @@ |
2 | | -/* Every time you change this CSS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
3 | | - |
4 | | -/* Standard User Interface */ |
5 | | -.flaggedrevs_basic, |
6 | | -.flaggedrevs_quality, |
7 | | -.flaggedrevs_pristine, |
8 | | -.flaggedrevs_notice, |
9 | | -.flaggedrevs_editnotice, |
10 | | -.flaggedrevs_diffnotice, |
11 | | -.flaggedrevs_warning, |
12 | | -.flaggedrevs_preview { |
13 | | - border: 1px solid #aaa; |
14 | | - padding: 5px; |
15 | | - font-weight: normal; |
16 | | - line-height: 1.5em; |
17 | | - margin: .5em 1em 0em 0em; |
18 | | - text-align: center; |
19 | | - clear: both; |
20 | | -} |
21 | | - |
22 | | -.flaggedrevs_basic { |
23 | | - background-color: #f0f8ff; |
24 | | -} |
25 | | -.flaggedrevs_quality { |
26 | | - background-color: #f0fff0; |
27 | | -} |
28 | | -.flaggedrevs_pristine { |
29 | | - background-color: #fffff0; |
30 | | -} |
31 | | -.flaggedrevs_notice { |
32 | | - background-color: #f9f9f9; |
33 | | -} |
34 | | -.flaggedrevs_preview { |
35 | | - background-color: #f9f9f9; |
36 | | - color: #8b0000; |
37 | | -} |
38 | | - |
39 | | -.flaggedrevs_warning { |
40 | | - font-size: 85%; |
41 | | - background-color: #fffff0; |
42 | | - margin: 0em 1em 0em 0em; |
43 | | -} |
44 | | -.flaggedrevs_editnotice { |
45 | | - font-size: 85%; |
46 | | - background-color: #f9f9f9; |
47 | | -} |
48 | | -.flaggedrevs_diffnotice { |
49 | | - font-size: 85%; |
50 | | - background-color: #f9f9f9; |
51 | | -} |
52 | | - |
53 | | -.flaggedrevs_notes { |
54 | | - border: 1px solid #aaa; |
55 | | - background-color: #f9f9f9; |
56 | | - padding: 5px; |
57 | | - font-size: 85%; |
58 | | - margin-left: 50px; |
59 | | - margin-right: 50px; |
60 | | - text-align: center; |
61 | | -} |
62 | | - |
63 | | -.fr-text-value { |
64 | | - width: 100px; |
65 | | -} |
66 | | - |
67 | | -.fr-checkbox { |
68 | | - padding: 0px; |
69 | | - width: 16px; |
70 | | - height: 16px; |
71 | | - position: relative; |
72 | | - float: left; |
73 | | - top: 0px; |
74 | | - right: 0px; |
75 | | - background-repeat: no-repeat; |
76 | | - background-position: 0px 0px; |
77 | | - background-image: url(../FlaggedRevs/img/boxC.png); |
78 | | -} |
79 | | - |
80 | | -.fr-marker-20, |
81 | | -.fr-marker-40, |
82 | | -.fr-marker-60, |
83 | | -.fr-marker-80, |
84 | | -.fr-marker-100 { |
85 | | - background-position: bottom left; |
86 | | - background-repeat: no-repeat; |
87 | | - padding-bottom: 3px; |
88 | | -} |
89 | | - |
90 | | -.fr-marker-20 { |
91 | | - background-image: url(../FlaggedRevs/img/bar_20.png); |
92 | | -} |
93 | | -.fr-marker-40 { |
94 | | - background-image: url(../FlaggedRevs/img/bar_40.png); |
95 | | -} |
96 | | -.fr-marker-60 { |
97 | | - background-image: url(../FlaggedRevs/img/bar_60.png); |
98 | | -} |
99 | | -.fr-marker-80 { |
100 | | - background-image: url(../FlaggedRevs/img/bar_80.png); |
101 | | -} |
102 | | -.fr-marker-100 { |
103 | | - background-image: url(../FlaggedRevs/img/bar_100.png); |
104 | | -} |
105 | | - |
106 | | -/* Short User Interface */ |
107 | | -.flaggedrevs_short { |
108 | | - border: 0px; |
109 | | - background-color: #f9f9f9; |
110 | | - padding: 1px; |
111 | | - font-size: 95%; |
112 | | - font-weight: normal; |
113 | | - margin: 0em 0em 0em 1em; |
114 | | - float: right; |
115 | | - text-align: left; |
116 | | - max-width: 450px; |
117 | | - line-height: 16px; |
118 | | -} |
119 | | - |
120 | | -.rtl .flaggedrevs_short { |
121 | | - float: left; |
122 | | - margin: 0 1em 0 0; |
123 | | -} |
124 | | - |
125 | | -.fr-text { |
126 | | - height: 1em; |
127 | | - line-height: 1em; |
128 | | - margin: 0px 7px 0px 0px; |
129 | | - padding: 0px; |
130 | | - font-weight: bold; |
131 | | - width: 80px; |
132 | | -} |
133 | | - |
134 | | -.fr-value20, |
135 | | -.fr-value40, |
136 | | -.fr-value60, |
137 | | -.fr-value80, |
138 | | -.fr-value100 { |
139 | | - height: 1em; |
140 | | - line-height: 1em; |
141 | | - width: 95px; |
142 | | - float: left; |
143 | | - background-repeat: no-repeat; |
144 | | - background-position: 50% 50%; |
145 | | - text-align: center; |
146 | | -} |
147 | | - |
148 | | -.fr-value20 { |
149 | | - background-image: url(../FlaggedRevs/img/fr-marker-20.png); |
150 | | -} |
151 | | -.fr-value40 { |
152 | | - background-image: url(../FlaggedRevs/img/fr-marker-40.png); |
153 | | -} |
154 | | -.fr-value60 { |
155 | | - background-image: url(../FlaggedRevs/img/fr-marker-60.png); |
156 | | -} |
157 | | -.fr-value80 { |
158 | | - background-image: url(../FlaggedRevs/img/fr-marker-80.png); |
159 | | -} |
160 | | -.fr-value100 { |
161 | | - background-image: url(../FlaggedRevs/img/fr-marker-100.png); |
162 | | -} |
163 | | - |
164 | | -.flaggedrevs-box0, |
165 | | -.flaggedrevs-box1, |
166 | | -.flaggedrevs-box2, |
167 | | -.flaggedrevs-box3 { |
168 | | - border: 1px solid #aaa; |
169 | | - text-align: center; |
170 | | - font-size: 85%; |
171 | | - clear: both; |
172 | | -} |
173 | | - |
174 | | -.flaggedrevs-box0 { |
175 | | - background-color: #f9f9f9; |
176 | | -} |
177 | | -.flaggedrevs-box1 { |
178 | | - background-color: #f0f8ff; |
179 | | -} |
180 | | -.flaggedrevs-box2 { |
181 | | - background-color: #f0fff0; |
182 | | -} |
183 | | -.flaggedrevs-box3 { |
184 | | - background-color: #fffff0; |
185 | | -} |
186 | | - |
187 | | -/* Both User Interfaces */ |
188 | | -.flaggedrevs-color-0 { |
189 | | - background-color: #f9f9f9; |
190 | | -} |
191 | | -.flaggedrevs-color-1 { |
192 | | - background-color: #f0f8ff; |
193 | | -} |
194 | | -.flaggedrevs-color-2 { |
195 | | - background-color: #f0fff0; |
196 | | -} |
197 | | -.flaggedrevs-color-3 { |
198 | | - background-color: #fffff0; |
199 | | -} |
200 | | - |
201 | | -.flaggedrevs-unreviewed { |
202 | | - background-color: #fffff0; |
203 | | -} |
204 | | - |
205 | | -.flaggedrevs-unreviewed2 { |
206 | | - background-color: #faebd7; |
207 | | -} |
208 | | - |
209 | | -.flaggedrevs_toggle { |
210 | | - color: blue; |
211 | | - white-space: nowrap; |
212 | | - cursor:pointer; |
213 | | -} |
214 | | - |
215 | | -.fr-icon-current, |
216 | | -.fr-icon-stable, |
217 | | -.fr-icon-quality, |
218 | | -.fr-icon-locked, |
219 | | -.fr-icon-unlocked { |
220 | | - padding: 0px; |
221 | | - margin: 0em .2em 0em 0em; |
222 | | - width: 16px; |
223 | | - height: 16px; |
224 | | - float: left; |
225 | | - background-repeat: no-repeat; |
226 | | - background-position: center center; |
227 | | -} |
228 | | -.fr-icon-current { |
229 | | - background-image: url(../FlaggedRevs/img/1.png); |
230 | | -} |
231 | | -.fr-icon-stable { |
232 | | - background-image: url(../FlaggedRevs/img/2.png); |
233 | | -} |
234 | | -.fr-icon-quality { |
235 | | - background-image: url(../FlaggedRevs/img/3.png); |
236 | | -} |
237 | | -.fr-icon-locked { |
238 | | - background-image: url(../FlaggedRevs/img/lock-closed.png); |
239 | | -} |
240 | | -.fr-icon-unlocked { |
241 | | - width: 23px; |
242 | | - background-image: url(../FlaggedRevs/img/lock-open.png); |
243 | | -} |
244 | | - |
245 | | -.fr-diff-ratings { |
246 | | - font-size: 90%; |
247 | | - line-height: 1em; |
248 | | - width: 100%; |
249 | | -} |
250 | | - |
251 | | -.fr-diff-to-stable { |
252 | | - line-height: 1em; |
253 | | -} |
254 | | - |
255 | | -.fr-hist-stable-user, |
256 | | -.fr-hist-quality-user, |
257 | | -.fr-hist-autoreviewed { |
258 | | - font-weight: bold; |
259 | | -} |
260 | | - |
261 | | -/* Site notices */ |
262 | | -.fr-backlognotice { |
263 | | - padding: 3px; |
264 | | - margin: 5px; |
265 | | - border: 1px solid #990000; |
266 | | - background-color: #f5ecec; |
267 | | -} |
268 | | -.fr-watchlist-old-notice { |
269 | | - padding: 3px; |
270 | | - margin: 5px; |
271 | | - border: 1px solid #990000; |
272 | | - background-color: #FEECD7; |
273 | | -} |
274 | | - |
275 | | -/* Special pages */ |
276 | | -.fr-pending-long { |
277 | | - background-color: #f5ecec; |
278 | | -} |
279 | | -.fr-pending-long2 { |
280 | | - background-color: #f5dddd; |
281 | | -} |
282 | | -.fr-pending-long3 { |
283 | | - background-color: #e2caca; |
284 | | -} |
285 | | - |
286 | | -.fr-unreviewed-unwatched { |
287 | | - background-color: #faebd7; |
288 | | -} |
289 | | - |
290 | | -.fr-under-review { |
291 | | - background-color: yellow; |
292 | | -} |
293 | | - |
294 | | -/* Review form */ |
295 | | -.flaggedrevs_reviewform { |
296 | | - background-color: #f9f9f9; |
297 | | - font-size: 90%; |
298 | | - clear: both; |
299 | | -} |
300 | | - |
301 | | -.fr-rating-controls, |
302 | | -.fr-rating-controls-disabled { |
303 | | - vertical-align: middle; |
304 | | - line-height: 1em; |
305 | | -} |
306 | | - |
307 | | -.fr-rating-controls-disabled { |
308 | | - color: GrayText; |
309 | | -} |
310 | | - |
311 | | -.fr-rating-options { |
312 | | - margin-right: 1.5em; |
313 | | -} |
314 | | - |
315 | | -.fr-rating-option-0 { |
316 | | - background-color: #f5ecec; |
317 | | -} |
318 | | -.fr-rating-option-1 { |
319 | | - background-color: #f0f8ff; |
320 | | -} |
321 | | -.fr-rating-option-2 { |
322 | | - background-color: #f0fff0; |
323 | | -} |
324 | | -.fr-rating-option-3 { |
325 | | - background-color: #fef0db; |
326 | | -} |
327 | | -.fr-rating-option-4 { |
328 | | - background-color: #fffff0; |
329 | | -} |
330 | | - |
331 | | -.fr-diff-patrollink { |
332 | | - text-align: center; |
333 | | -} |
334 | | - |
335 | | -.fr-notes-box { |
336 | | - width: 95%; |
337 | | - margin: 0em 1em 0em .5em; |
338 | | -} |
339 | | - |
340 | | -.fr-comment-box { |
341 | | - margin-top: .25em; |
342 | | -} |
343 | | - |
344 | | -.fr-rating-dave { |
345 | | - background-color: #E0ECF8; |
346 | | -} |
347 | | - |
348 | | -.fr-rating-rave { |
349 | | - background-color: #E0F8EC; |
350 | | -} |
351 | | - |
352 | | -.fr-hiddenform { |
353 | | - display: none; |
354 | | -} |
Index: trunk/extensions/FlaggedRevs/flaggedrevs.js |
— | — | @@ -1,276 +0,0 @@ |
2 | | -/* -- (c) Aaron Schulz, Daniel Arnold 2008 */ |
3 | | - |
4 | | -/* Every time you change this JS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
5 | | - |
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; |
14 | | - ratings.style.display = 'none'; |
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 | | - if( !levels.size ) continue; |
47 | | - var selectedlevel = 0; // default |
48 | | - |
49 | | - if( levels[0].nodeName == 'SELECT' ) { |
50 | | - selectedlevel = levels[0].selectedIndex; |
51 | | - // Update color. Opera does this already, and doing so |
52 | | - // seems to kill custom pretty opera skin form styling. |
53 | | - if( navigator.appName != 'Opera') { |
54 | | - value = levels[0].getElementsByTagName('option')[selectedlevel].value; |
55 | | - levels[0].className = 'fr-rating-option-' + value; |
56 | | - } |
57 | | - } else if( levels[0].type == 'radio' ) { |
58 | | - for( i = 0; i < levels.length; i++ ) { |
59 | | - if( levels[i].checked ) { |
60 | | - selectedlevel = i; |
61 | | - break; |
62 | | - } |
63 | | - } |
64 | | - } else if( levels[0].type == 'checkbox' ) { |
65 | | - selectedlevel = (levels[0].checked) ? 1: 0; |
66 | | - } else { |
67 | | - return; // error: should not happen |
68 | | - } |
69 | | - |
70 | | - // Get quality level for this tag |
71 | | - qualityLevel = wgFlaggedRevsParams.tags[tag]; |
72 | | - |
73 | | - if( selectedlevel < qualityLevel ) { |
74 | | - quality = false; // not a quality review |
75 | | - } |
76 | | - if( selectedlevel > 0 ) { |
77 | | - allzero = false; |
78 | | - } else { |
79 | | - somezero = true; |
80 | | - } |
81 | | - } |
82 | | - // Show note box only for quality revs |
83 | | - var notebox = document.getElementById('mw-notebox'); |
84 | | - if( notebox ) { |
85 | | - notebox.style.display = quality ? 'inline' : 'none'; |
86 | | - } |
87 | | - // If only a few levels are zero, don't show submit link |
88 | | - var submit = document.getElementById('mw-submitreview'); |
89 | | - if( submit ) { |
90 | | - submit.disabled = ( somezero && !allzero ) ? 'disabled' : ''; |
91 | | - } |
92 | | - // Clear note box data if not shown |
93 | | - var notes = document.getElementById('wpNotes'); |
94 | | - if( notes ) { |
95 | | - notes.value = quality ? notes.value : ''; |
96 | | - } |
97 | | - } |
98 | | -}; |
99 | | - |
100 | | -addOnloadHook(FlaggedRevs.enableShowhide); |
101 | | -addOnloadHook(FlaggedRevs.updateRatingForm); |
102 | | - |
103 | | -// dependencies: |
104 | | -// * ajax.js: |
105 | | - /*extern sajax_init_object, sajax_do_call */ |
106 | | -// * wikibits.js: |
107 | | - /*extern hookEvent, jsMsg */ |
108 | | -// These should have been initialized in the generated js |
109 | | -if( typeof wgAjaxReview === "undefined" || !wgAjaxReview ) { |
110 | | - wgAjaxReview = { |
111 | | - sendMsg: "Submit", |
112 | | - sendingMsg: "Submitting...", |
113 | | - flagMsg: "Mark reviewed", |
114 | | - unflagMsg: "Mark unreviewed", |
115 | | - titleFlagMsg: "revreview-tt-review", |
116 | | - titleUnflagMsg: "revreview-tt-unreview", |
117 | | - actioncomplete: "Action complete", |
118 | | - actionfailed: "Action failed" |
119 | | - }; |
120 | | -} |
121 | | - |
122 | | -wgAjaxReview.supported = true; // supported on current page and by browser |
123 | | -wgAjaxReview.inprogress = false; // ajax request in progress |
124 | | -wgAjaxReview.timeoutID = null; // see wgAjaxReview.ajaxCall |
125 | | - |
126 | | -wgAjaxReview.ajaxCall = function() { |
127 | | - if( !wgAjaxReview.supported ) { |
128 | | - return true; |
129 | | - } else if( wgAjaxReview.inprogress ) { |
130 | | - return false; |
131 | | - } |
132 | | - if( !wfSupportsAjax() ) { |
133 | | - // Lazy initialization so we don't toss up |
134 | | - // ActiveX warnings on initial page load |
135 | | - // for IE 6 users with security settings. |
136 | | - wgAjaxReview.supported = false; |
137 | | - return true; |
138 | | - } |
139 | | - var form = document.getElementById("mw-reviewform"); |
140 | | - var notes = document.getElementById("wpNotes"); |
141 | | - var reason = document.getElementById("wpReason"); |
142 | | - if( !form ) { |
143 | | - return false; |
144 | | - } |
145 | | - wgAjaxReview.inprogress = true; |
146 | | - // Build up arguments |
147 | | - var args = []; |
148 | | - var inputs = form.getElementsByTagName("input"); |
149 | | - for( var i=0; i < inputs.length; i++) { |
150 | | - // Different input types may occur depending on tags... |
151 | | - if( inputs[i].name == "title" || inputs[i].name == "action" ) { |
152 | | - // No need to send these... |
153 | | - } else if( inputs[i].type == "submit" ) { |
154 | | - inputs[i].value = wgAjaxReview.sendingMsg; |
155 | | - } else if( inputs[i].type == "checkbox" ) { |
156 | | - args.push( inputs[i].name + "|" + (inputs[i].checked ? inputs[i].value : 0) ); |
157 | | - } else if( inputs[i].type != "radio" || inputs[i].checked ) { |
158 | | - args.push( inputs[i].name + "|" + inputs[i].value ); |
159 | | - } |
160 | | - inputs[i].disabled = "disabled"; |
161 | | - } |
162 | | - if( notes ) { |
163 | | - args.push( notes.name + "|" + notes.value ); |
164 | | - notes.disabled = "disabled"; |
165 | | - } |
166 | | - var selects = form.getElementsByTagName("select"); |
167 | | - for( var i=0; i < selects.length; i++) { |
168 | | - // Get the selected tag level... |
169 | | - if( selects[i].selectedIndex >= 0 ) { |
170 | | - var soption = selects[i].getElementsByTagName("option")[selects[i].selectedIndex]; |
171 | | - args.push( selects[i].name + "|" + soption.value ); |
172 | | - } |
173 | | - selects[i].disabled = "disabled"; |
174 | | - } |
175 | | - // Send! |
176 | | - var old = sajax_request_type; |
177 | | - sajax_request_type = "POST"; |
178 | | - sajax_do_call( "RevisionReview::AjaxReview", args, wgAjaxReview.processResult ); |
179 | | - sajax_request_type = old; |
180 | | - // If the request isn't done in 30 seconds, allow user to try again |
181 | | - wgAjaxReview.timeoutID = window.setTimeout( |
182 | | - function() { wgAjaxReview.inprogress = false; wgAjaxReview.unlockForm(); }, |
183 | | - 30000 |
184 | | - ); |
185 | | - return false; |
186 | | -}; |
187 | | - |
188 | | -wgAjaxReview.unlockForm = function() { |
189 | | - var form = document.getElementById("mw-reviewform"); |
190 | | - var submit = document.getElementById("mw-submitreview"); |
191 | | - var notes = document.getElementById("wpNotes"); |
192 | | - var reason = document.getElementById("wpReason"); |
193 | | - if( !form || !submit ) { |
194 | | - return false; |
195 | | - } |
196 | | - submit.disabled = ""; |
197 | | - var inputs = form.getElementsByTagName("input"); |
198 | | - for( var i=0; i < inputs.length; i++) { |
199 | | - inputs[i].disabled = ""; |
200 | | - } |
201 | | - if( notes ) { |
202 | | - notes.disabled = ""; |
203 | | - } |
204 | | - if( reason ) { |
205 | | - reason.disabled = ""; |
206 | | - } |
207 | | - var selects = form.getElementsByTagName("select"); |
208 | | - for( var i=0; i < selects.length; i++) { |
209 | | - selects[i].disabled = ""; |
210 | | - } |
211 | | - return true; |
212 | | -}; |
213 | | - |
214 | | -wgAjaxReview.processResult = function(request) { |
215 | | - if( !wgAjaxReview.supported ) { |
216 | | - return; |
217 | | - } |
218 | | - var response = request.responseText; |
219 | | - if( (msg = response.substr(6)) ) { |
220 | | - jsMsg( msg, 'review' ); // success notice |
221 | | - window.scroll(0,0); // scroll up to notice |
222 | | - tagBox = document.getElementById('mw-revisiontag'); |
223 | | - if( tagBox ) tagBox.style.display = 'none'; // remove tag from draft |
224 | | - } |
225 | | - wgAjaxReview.inprogress = false; |
226 | | - if( wgAjaxReview.timeoutID ) { |
227 | | - window.clearTimeout(wgAjaxReview.timeoutID); |
228 | | - } |
229 | | - var submit = document.getElementById("mw-submitreview"); |
230 | | - var binaryState = document.getElementById("mw-reviewstate"); |
231 | | - var legend = document.getElementById("mw-reviewformlegend"); |
232 | | - var diffNotice = document.getElementById("mw-difftostable"); |
233 | | - // On success... |
234 | | - if( response.indexOf('<suc#>') == 0 ) { |
235 | | - document.title = wgAjaxReview.actioncomplete; |
236 | | - if( submit ) { |
237 | | - // If flagging is just binary, flip the form |
238 | | - if( binaryState ) { |
239 | | - binaryState.value = (binaryState.value ==1 ) ? 0 : 1; |
240 | | - // Revision was unflagged - switch to flagging form |
241 | | - if( binaryState.value == 1 ) { |
242 | | - legend.innerHTML = '<strong>'+wgAjaxReview.flagLegMsg+'</strong>'; |
243 | | - submit.value = wgAjaxReview.flagMsg; |
244 | | - // Revision was flagged - switch to unflagging form |
245 | | - } else { |
246 | | - legend.innerHTML = '<strong>'+wgAjaxReview.unflagLegMsg+'</strong>'; |
247 | | - submit.value = wgAjaxReview.unflagMsg; |
248 | | - } |
249 | | - } else { |
250 | | - submit.value = wgAjaxReview.sendMsg; // back to normal |
251 | | - } |
252 | | - } |
253 | | - // Hide "review this" box on diffs |
254 | | - if( diffNotice ) diffNotice.style.display = 'none'; |
255 | | - // On failure... |
256 | | - } else { |
257 | | - document.title = wgAjaxReview.actionfailed; |
258 | | - if( submit ) { |
259 | | - if( binaryState ) { |
260 | | - submit.value = binaryState.value ? |
261 | | - wgAjaxReview.flagMsg : wgAjaxReview.unflagMsg; // back to normal |
262 | | - } else { |
263 | | - submit.value = wgAjaxReview.sendMsg; |
264 | | - } |
265 | | - } |
266 | | - } |
267 | | - wgAjaxReview.unlockForm(); |
268 | | -}; |
269 | | - |
270 | | -wgAjaxReview.onLoad = function() { |
271 | | - var submit = document.getElementById("mw-submitreview"); |
272 | | - if( submit ) { |
273 | | - submit.onclick = wgAjaxReview.ajaxCall; |
274 | | - } |
275 | | -}; |
276 | | - |
277 | | -hookEvent("load", wgAjaxReview.onLoad); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | |
159 | 159 | # URL location for flaggedrevs.css and flaggedrevs.js |
160 | 160 | # Use a literal $wgScriptPath as a placeholder for the runtime value of $wgScriptPath |
161 | | -$wgFlaggedRevsStylePath = '$wgScriptPath/extensions/FlaggedRevs'; |
| 161 | +$wgFlaggedRevsStylePath = '$wgScriptPath/extensions/FlaggedRevs/client'; |
162 | 162 | |
163 | 163 | # Define our basic reviewer class |
164 | 164 | $wgGroupPermissions['editor']['review'] = true; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * Add FlaggedRevs css/js. |
7 | 7 | */ |
8 | 8 | public static function injectStyleAndJS() { |
9 | | - global $wgOut; |
| 9 | + global $wgOut, $wgUser; |
10 | 10 | if( $wgOut->hasHeadItem( 'FlaggedRevs' ) ) |
11 | 11 | return true; # Don't double-load |
12 | 12 | if( !$wgOut->isArticleRelated() ) { |
— | — | @@ -23,8 +23,13 @@ |
24 | 24 | $encJsFile = htmlspecialchars( "$stylePath/flaggedrevs.js?$wgFlaggedRevStyleVersion" ); |
25 | 25 | # Add CSS file |
26 | 26 | $wgOut->addExtensionStyle( $encCssFile ); |
27 | | - # Add JS file |
| 27 | + # Add main JS file |
28 | 28 | $head = "<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
| 29 | + # Add review form JS for reviewers |
| 30 | + if( $wgUser->isAllowed('review') ) { |
| 31 | + $encJsFile = htmlspecialchars( "$stylePath/review.js?$wgFlaggedRevStyleVersion" ); |
| 32 | + $head .= "\n<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
| 33 | + } |
29 | 34 | $wgOut->addHeadItem( 'FlaggedRevs', $head ); |
30 | 35 | return true; |
31 | 36 | } |
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.css |
— | — | @@ -0,0 +1,353 @@ |
| 2 | +/* Every time you change this CSS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
| 3 | + |
| 4 | +/* Standard User Interface */ |
| 5 | +.flaggedrevs_basic, |
| 6 | +.flaggedrevs_quality, |
| 7 | +.flaggedrevs_pristine, |
| 8 | +.flaggedrevs_notice, |
| 9 | +.flaggedrevs_editnotice, |
| 10 | +.flaggedrevs_diffnotice, |
| 11 | +.flaggedrevs_warning, |
| 12 | +.flaggedrevs_preview { |
| 13 | + border: 1px solid #aaa; |
| 14 | + padding: 5px; |
| 15 | + font-weight: normal; |
| 16 | + line-height: 1.5em; |
| 17 | + margin: .5em 1em 0em 0em; |
| 18 | + text-align: center; |
| 19 | + clear: both; |
| 20 | +} |
| 21 | + |
| 22 | +.flaggedrevs_basic { |
| 23 | + background-color: #f0f8ff; |
| 24 | +} |
| 25 | +.flaggedrevs_quality { |
| 26 | + background-color: #f0fff0; |
| 27 | +} |
| 28 | +.flaggedrevs_pristine { |
| 29 | + background-color: #fffff0; |
| 30 | +} |
| 31 | +.flaggedrevs_notice { |
| 32 | + background-color: #f9f9f9; |
| 33 | +} |
| 34 | +.flaggedrevs_preview { |
| 35 | + background-color: #f9f9f9; |
| 36 | + color: #8b0000; |
| 37 | +} |
| 38 | + |
| 39 | +.flaggedrevs_warning { |
| 40 | + font-size: 85%; |
| 41 | + background-color: #fffff0; |
| 42 | + margin: 0em 1em 0em 0em; |
| 43 | +} |
| 44 | +.flaggedrevs_editnotice { |
| 45 | + font-size: 85%; |
| 46 | + background-color: #f9f9f9; |
| 47 | +} |
| 48 | +.flaggedrevs_diffnotice { |
| 49 | + font-size: 85%; |
| 50 | + background-color: #f9f9f9; |
| 51 | +} |
| 52 | + |
| 53 | +.flaggedrevs_notes { |
| 54 | + border: 1px solid #aaa; |
| 55 | + background-color: #f9f9f9; |
| 56 | + padding: 5px; |
| 57 | + font-size: 85%; |
| 58 | + margin-left: 50px; |
| 59 | + margin-right: 50px; |
| 60 | + text-align: center; |
| 61 | +} |
| 62 | + |
| 63 | +.fr-text-value { |
| 64 | + width: 100px; |
| 65 | +} |
| 66 | + |
| 67 | +.fr-checkbox { |
| 68 | + padding: 0px; |
| 69 | + width: 16px; |
| 70 | + height: 16px; |
| 71 | + position: relative; |
| 72 | + float: left; |
| 73 | + top: 0px; |
| 74 | + right: 0px; |
| 75 | + background-repeat: no-repeat; |
| 76 | + background-position: 0px 0px; |
| 77 | + background-image: url(../FlaggedRevs/img/boxC.png); |
| 78 | +} |
| 79 | + |
| 80 | +.fr-marker-20, |
| 81 | +.fr-marker-40, |
| 82 | +.fr-marker-60, |
| 83 | +.fr-marker-80, |
| 84 | +.fr-marker-100 { |
| 85 | + background-position: bottom left; |
| 86 | + background-repeat: no-repeat; |
| 87 | + padding-bottom: 3px; |
| 88 | +} |
| 89 | + |
| 90 | +.fr-marker-20 { |
| 91 | + background-image: url(../FlaggedRevs/img/bar_20.png); |
| 92 | +} |
| 93 | +.fr-marker-40 { |
| 94 | + background-image: url(../FlaggedRevs/img/bar_40.png); |
| 95 | +} |
| 96 | +.fr-marker-60 { |
| 97 | + background-image: url(../FlaggedRevs/img/bar_60.png); |
| 98 | +} |
| 99 | +.fr-marker-80 { |
| 100 | + background-image: url(../FlaggedRevs/img/bar_80.png); |
| 101 | +} |
| 102 | +.fr-marker-100 { |
| 103 | + background-image: url(../FlaggedRevs/img/bar_100.png); |
| 104 | +} |
| 105 | + |
| 106 | +/* Short User Interface */ |
| 107 | +.flaggedrevs_short { |
| 108 | + border: 0px; |
| 109 | + background-color: #f9f9f9; |
| 110 | + padding: 1px; |
| 111 | + font-size: 95%; |
| 112 | + font-weight: normal; |
| 113 | + margin: 0em 0em 0em 1em; |
| 114 | + float: right; |
| 115 | + text-align: left; |
| 116 | + max-width: 450px; |
| 117 | + line-height: 16px; |
| 118 | +} |
| 119 | + |
| 120 | +.rtl .flaggedrevs_short { |
| 121 | + float: left; |
| 122 | + margin: 0 1em 0 0; |
| 123 | +} |
| 124 | + |
| 125 | +.fr-text { |
| 126 | + height: 1em; |
| 127 | + line-height: 1em; |
| 128 | + margin: 0px 7px 0px 0px; |
| 129 | + padding: 0px; |
| 130 | + font-weight: bold; |
| 131 | + width: 80px; |
| 132 | +} |
| 133 | + |
| 134 | +.fr-value20, |
| 135 | +.fr-value40, |
| 136 | +.fr-value60, |
| 137 | +.fr-value80, |
| 138 | +.fr-value100 { |
| 139 | + height: 1em; |
| 140 | + line-height: 1em; |
| 141 | + width: 95px; |
| 142 | + float: left; |
| 143 | + background-repeat: no-repeat; |
| 144 | + background-position: 50% 50%; |
| 145 | + text-align: center; |
| 146 | +} |
| 147 | + |
| 148 | +.fr-value20 { |
| 149 | + background-image: url(../FlaggedRevs/img/fr-marker-20.png); |
| 150 | +} |
| 151 | +.fr-value40 { |
| 152 | + background-image: url(../FlaggedRevs/img/fr-marker-40.png); |
| 153 | +} |
| 154 | +.fr-value60 { |
| 155 | + background-image: url(../FlaggedRevs/img/fr-marker-60.png); |
| 156 | +} |
| 157 | +.fr-value80 { |
| 158 | + background-image: url(../FlaggedRevs/img/fr-marker-80.png); |
| 159 | +} |
| 160 | +.fr-value100 { |
| 161 | + background-image: url(../FlaggedRevs/img/fr-marker-100.png); |
| 162 | +} |
| 163 | + |
| 164 | +.flaggedrevs-box0, |
| 165 | +.flaggedrevs-box1, |
| 166 | +.flaggedrevs-box2, |
| 167 | +.flaggedrevs-box3 { |
| 168 | + border: 1px solid #aaa; |
| 169 | + text-align: center; |
| 170 | + font-size: 85%; |
| 171 | + clear: both; |
| 172 | +} |
| 173 | + |
| 174 | +.flaggedrevs-box0 { |
| 175 | + background-color: #f9f9f9; |
| 176 | +} |
| 177 | +.flaggedrevs-box1 { |
| 178 | + background-color: #f0f8ff; |
| 179 | +} |
| 180 | +.flaggedrevs-box2 { |
| 181 | + background-color: #f0fff0; |
| 182 | +} |
| 183 | +.flaggedrevs-box3 { |
| 184 | + background-color: #fffff0; |
| 185 | +} |
| 186 | + |
| 187 | +/* Both User Interfaces */ |
| 188 | +.flaggedrevs-color-0 { |
| 189 | + background-color: #f9f9f9; |
| 190 | +} |
| 191 | +.flaggedrevs-color-1 { |
| 192 | + background-color: #f0f8ff; |
| 193 | +} |
| 194 | +.flaggedrevs-color-2 { |
| 195 | + background-color: #f0fff0; |
| 196 | +} |
| 197 | +.flaggedrevs-color-3 { |
| 198 | + background-color: #fffff0; |
| 199 | +} |
| 200 | + |
| 201 | +.flaggedrevs-unreviewed { |
| 202 | + background-color: #fffff0; |
| 203 | +} |
| 204 | + |
| 205 | +.flaggedrevs-unreviewed2 { |
| 206 | + background-color: #faebd7; |
| 207 | +} |
| 208 | + |
| 209 | +.flaggedrevs_toggle { |
| 210 | + color: blue; |
| 211 | + white-space: nowrap; |
| 212 | + cursor:pointer; |
| 213 | +} |
| 214 | + |
| 215 | +.fr-icon-current, |
| 216 | +.fr-icon-stable, |
| 217 | +.fr-icon-quality, |
| 218 | +.fr-icon-locked, |
| 219 | +.fr-icon-unlocked { |
| 220 | + padding: 0px; |
| 221 | + margin: 0em .2em 0em 0em; |
| 222 | + width: 16px; |
| 223 | + height: 16px; |
| 224 | + float: left; |
| 225 | + background-repeat: no-repeat; |
| 226 | + background-position: center center; |
| 227 | +} |
| 228 | +.fr-icon-current { |
| 229 | + background-image: url(../FlaggedRevs/img/1.png); |
| 230 | +} |
| 231 | +.fr-icon-stable { |
| 232 | + background-image: url(../FlaggedRevs/img/2.png); |
| 233 | +} |
| 234 | +.fr-icon-quality { |
| 235 | + background-image: url(../FlaggedRevs/img/3.png); |
| 236 | +} |
| 237 | +.fr-icon-locked { |
| 238 | + background-image: url(../FlaggedRevs/img/lock-closed.png); |
| 239 | +} |
| 240 | +.fr-icon-unlocked { |
| 241 | + width: 23px; |
| 242 | + background-image: url(../FlaggedRevs/img/lock-open.png); |
| 243 | +} |
| 244 | + |
| 245 | +.fr-diff-ratings { |
| 246 | + font-size: 90%; |
| 247 | + line-height: 1em; |
| 248 | + width: 100%; |
| 249 | +} |
| 250 | + |
| 251 | +.fr-diff-to-stable { |
| 252 | + line-height: 1em; |
| 253 | +} |
| 254 | + |
| 255 | +.fr-hist-stable-user, |
| 256 | +.fr-hist-quality-user, |
| 257 | +.fr-hist-autoreviewed { |
| 258 | + font-weight: bold; |
| 259 | +} |
| 260 | + |
| 261 | +/* Site notices */ |
| 262 | +.fr-backlognotice { |
| 263 | + padding: 3px; |
| 264 | + margin: 5px; |
| 265 | + border: 1px solid #990000; |
| 266 | + background-color: #f5ecec; |
| 267 | +} |
| 268 | +.fr-watchlist-old-notice { |
| 269 | + padding: 3px; |
| 270 | + margin: 5px; |
| 271 | + border: 1px solid #990000; |
| 272 | + background-color: #FEECD7; |
| 273 | +} |
| 274 | + |
| 275 | +/* Special pages */ |
| 276 | +.fr-pending-long { |
| 277 | + background-color: #f5ecec; |
| 278 | +} |
| 279 | +.fr-pending-long2 { |
| 280 | + background-color: #f5dddd; |
| 281 | +} |
| 282 | +.fr-pending-long3 { |
| 283 | + background-color: #e2caca; |
| 284 | +} |
| 285 | + |
| 286 | +.fr-unreviewed-unwatched { |
| 287 | + background-color: #faebd7; |
| 288 | +} |
| 289 | + |
| 290 | +.fr-under-review { |
| 291 | + background-color: yellow; |
| 292 | +} |
| 293 | + |
| 294 | +/* Review form */ |
| 295 | +.flaggedrevs_reviewform { |
| 296 | + background-color: #f9f9f9; |
| 297 | + font-size: 90%; |
| 298 | + clear: both; |
| 299 | +} |
| 300 | + |
| 301 | +.fr-rating-controls, |
| 302 | +.fr-rating-controls-disabled { |
| 303 | + vertical-align: middle; |
| 304 | + line-height: 1em; |
| 305 | +} |
| 306 | + |
| 307 | +.fr-rating-controls-disabled { |
| 308 | + color: GrayText; |
| 309 | +} |
| 310 | + |
| 311 | +.fr-rating-options { |
| 312 | + margin-right: 1.5em; |
| 313 | +} |
| 314 | + |
| 315 | +.fr-rating-option-0 { |
| 316 | + background-color: #f5ecec; |
| 317 | +} |
| 318 | +.fr-rating-option-1 { |
| 319 | + background-color: #f0f8ff; |
| 320 | +} |
| 321 | +.fr-rating-option-2 { |
| 322 | + background-color: #f0fff0; |
| 323 | +} |
| 324 | +.fr-rating-option-3 { |
| 325 | + background-color: #fef0db; |
| 326 | +} |
| 327 | +.fr-rating-option-4 { |
| 328 | + background-color: #fffff0; |
| 329 | +} |
| 330 | + |
| 331 | +.fr-diff-patrollink { |
| 332 | + text-align: center; |
| 333 | +} |
| 334 | + |
| 335 | +.fr-notes-box { |
| 336 | + width: 95%; |
| 337 | + margin: 0em 1em 0em .5em; |
| 338 | +} |
| 339 | + |
| 340 | +.fr-comment-box { |
| 341 | + margin-top: .25em; |
| 342 | +} |
| 343 | + |
| 344 | +.fr-rating-dave { |
| 345 | + background-color: #E0ECF8; |
| 346 | +} |
| 347 | + |
| 348 | +.fr-rating-rave { |
| 349 | + background-color: #E0F8EC; |
| 350 | +} |
| 351 | + |
| 352 | +.fr-hiddenform { |
| 353 | + display: none; |
| 354 | +} |
Property changes on: trunk/extensions/FlaggedRevs/client/flaggedrevs.css |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 355 | + native |
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.js |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +/* -- (c) Aaron Schulz, Daniel Arnold 2008 */ |
| 3 | + |
| 4 | +/* Every time you change this JS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
| 5 | + |
| 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; |
| 14 | + ratings.style.display = 'none'; |
| 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 | +addOnloadHook(FlaggedRevs.enableShowhide); |
Property changes on: trunk/extensions/FlaggedRevs/client/flaggedrevs.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 30 | + native |
Index: trunk/extensions/FlaggedRevs/client/review.js |
— | — | @@ -0,0 +1,243 @@ |
| 2 | +/* -- (c) Aaron Schulz, Daniel Arnold 2008 */ |
| 3 | + |
| 4 | +/* Every time you change this JS please bump $wgFlaggedRevStyleVersion in FlaggedRevs.php */ |
| 5 | + |
| 6 | +/* |
| 7 | +* a) Disable submit in case of invalid input. |
| 8 | +* b) Update colors when select changes (Opera already does this). |
| 9 | +* c) Also remove comment box clutter in case of invalid input. |
| 10 | +*/ |
| 11 | +FlaggedRevs.updateRatingForm = function() { |
| 12 | + var ratingform = document.getElementById('mw-ratingselects'); |
| 13 | + if( !ratingform ) return; |
| 14 | + var disabled = document.getElementById('fr-rating-controls-disabled'); |
| 15 | + if( disabled ) return; |
| 16 | + |
| 17 | + var quality = true; |
| 18 | + var allzero = true; |
| 19 | + var somezero = false; |
| 20 | + |
| 21 | + for( tag in wgFlaggedRevsParams.tags ) { |
| 22 | + var controlName = "wp" + tag; |
| 23 | + var levels = document.getElementsByName(controlName); |
| 24 | + if( !levels.size ) continue; |
| 25 | + var selectedlevel = 0; // default |
| 26 | + |
| 27 | + if( levels[0].nodeName == 'SELECT' ) { |
| 28 | + selectedlevel = levels[0].selectedIndex; |
| 29 | + // Update color. Opera does this already, and doing so |
| 30 | + // seems to kill custom pretty opera skin form styling. |
| 31 | + if( navigator.appName != 'Opera') { |
| 32 | + value = levels[0].getElementsByTagName('option')[selectedlevel].value; |
| 33 | + levels[0].className = 'fr-rating-option-' + value; |
| 34 | + } |
| 35 | + } else if( levels[0].type == 'radio' ) { |
| 36 | + for( i = 0; i < levels.length; i++ ) { |
| 37 | + if( levels[i].checked ) { |
| 38 | + selectedlevel = i; |
| 39 | + break; |
| 40 | + } |
| 41 | + } |
| 42 | + } else if( levels[0].type == 'checkbox' ) { |
| 43 | + selectedlevel = (levels[0].checked) ? 1: 0; |
| 44 | + } else { |
| 45 | + return; // error: should not happen |
| 46 | + } |
| 47 | + |
| 48 | + // Get quality level for this tag |
| 49 | + qualityLevel = wgFlaggedRevsParams.tags[tag]; |
| 50 | + |
| 51 | + if( selectedlevel < qualityLevel ) { |
| 52 | + quality = false; // not a quality review |
| 53 | + } |
| 54 | + if( selectedlevel > 0 ) { |
| 55 | + allzero = false; |
| 56 | + } else { |
| 57 | + somezero = true; |
| 58 | + } |
| 59 | + } |
| 60 | + // Show note box only for quality revs |
| 61 | + var notebox = document.getElementById('mw-notebox'); |
| 62 | + if( notebox ) { |
| 63 | + notebox.style.display = quality ? 'inline' : 'none'; |
| 64 | + } |
| 65 | + // If only a few levels are zero, don't show submit link |
| 66 | + var submit = document.getElementById('mw-submitreview'); |
| 67 | + if( submit ) { |
| 68 | + submit.disabled = ( somezero && !allzero ) ? 'disabled' : ''; |
| 69 | + } |
| 70 | + // Clear note box data if not shown |
| 71 | + var notes = document.getElementById('wpNotes'); |
| 72 | + if( notes ) { |
| 73 | + notes.value = quality ? notes.value : ''; |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +addOnloadHook(FlaggedRevs.updateRatingForm); |
| 78 | + |
| 79 | +// dependencies: |
| 80 | +// * ajax.js: |
| 81 | + /*extern sajax_init_object, sajax_do_call */ |
| 82 | +// * wikibits.js: |
| 83 | + /*extern hookEvent, jsMsg */ |
| 84 | +// These should have been initialized in the generated js |
| 85 | +if( typeof wgAjaxReview === "undefined" || !wgAjaxReview ) { |
| 86 | + wgAjaxReview = {}; |
| 87 | +} |
| 88 | + |
| 89 | +wgAjaxReview.supported = true; // supported on current page and by browser |
| 90 | +wgAjaxReview.inprogress = false; // ajax request in progress |
| 91 | +wgAjaxReview.timeoutID = null; // see wgAjaxReview.ajaxCall |
| 92 | + |
| 93 | +wgAjaxReview.ajaxCall = function() { |
| 94 | + if( !wgAjaxReview.supported ) { |
| 95 | + return true; |
| 96 | + } else if( wgAjaxReview.inprogress ) { |
| 97 | + return false; |
| 98 | + } |
| 99 | + if( !wfSupportsAjax() ) { |
| 100 | + // Lazy initialization so we don't toss up |
| 101 | + // ActiveX warnings on initial page load |
| 102 | + // for IE 6 users with security settings. |
| 103 | + wgAjaxReview.supported = false; |
| 104 | + return true; |
| 105 | + } |
| 106 | + var form = document.getElementById("mw-reviewform"); |
| 107 | + var notes = document.getElementById("wpNotes"); |
| 108 | + var reason = document.getElementById("wpReason"); |
| 109 | + if( !form ) { |
| 110 | + return false; |
| 111 | + } |
| 112 | + wgAjaxReview.inprogress = true; |
| 113 | + // Build up arguments |
| 114 | + var args = []; |
| 115 | + var inputs = form.getElementsByTagName("input"); |
| 116 | + for( var i=0; i < inputs.length; i++) { |
| 117 | + // Different input types may occur depending on tags... |
| 118 | + if( inputs[i].name == "title" || inputs[i].name == "action" ) { |
| 119 | + // No need to send these... |
| 120 | + } else if( inputs[i].type == "submit" ) { |
| 121 | + inputs[i].value = wgAjaxReview.sendingMsg; |
| 122 | + } else if( inputs[i].type == "checkbox" ) { |
| 123 | + args.push( inputs[i].name + "|" + (inputs[i].checked ? inputs[i].value : 0) ); |
| 124 | + } else if( inputs[i].type != "radio" || inputs[i].checked ) { |
| 125 | + args.push( inputs[i].name + "|" + inputs[i].value ); |
| 126 | + } |
| 127 | + inputs[i].disabled = "disabled"; |
| 128 | + } |
| 129 | + if( notes ) { |
| 130 | + args.push( notes.name + "|" + notes.value ); |
| 131 | + notes.disabled = "disabled"; |
| 132 | + } |
| 133 | + var selects = form.getElementsByTagName("select"); |
| 134 | + for( var i=0; i < selects.length; i++) { |
| 135 | + // Get the selected tag level... |
| 136 | + if( selects[i].selectedIndex >= 0 ) { |
| 137 | + var soption = selects[i].getElementsByTagName("option")[selects[i].selectedIndex]; |
| 138 | + args.push( selects[i].name + "|" + soption.value ); |
| 139 | + } |
| 140 | + selects[i].disabled = "disabled"; |
| 141 | + } |
| 142 | + // Send! |
| 143 | + var old = sajax_request_type; |
| 144 | + sajax_request_type = "POST"; |
| 145 | + sajax_do_call( "RevisionReview::AjaxReview", args, wgAjaxReview.processResult ); |
| 146 | + sajax_request_type = old; |
| 147 | + // If the request isn't done in 30 seconds, allow user to try again |
| 148 | + wgAjaxReview.timeoutID = window.setTimeout( |
| 149 | + function() { wgAjaxReview.inprogress = false; wgAjaxReview.unlockForm(); }, |
| 150 | + 30000 |
| 151 | + ); |
| 152 | + return false; |
| 153 | +}; |
| 154 | + |
| 155 | +wgAjaxReview.unlockForm = function() { |
| 156 | + var form = document.getElementById("mw-reviewform"); |
| 157 | + var submit = document.getElementById("mw-submitreview"); |
| 158 | + var notes = document.getElementById("wpNotes"); |
| 159 | + var reason = document.getElementById("wpReason"); |
| 160 | + if( !form || !submit ) { |
| 161 | + return false; |
| 162 | + } |
| 163 | + submit.disabled = ""; |
| 164 | + var inputs = form.getElementsByTagName("input"); |
| 165 | + for( var i=0; i < inputs.length; i++) { |
| 166 | + inputs[i].disabled = ""; |
| 167 | + } |
| 168 | + if( notes ) { |
| 169 | + notes.disabled = ""; |
| 170 | + } |
| 171 | + if( reason ) { |
| 172 | + reason.disabled = ""; |
| 173 | + } |
| 174 | + var selects = form.getElementsByTagName("select"); |
| 175 | + for( var i=0; i < selects.length; i++) { |
| 176 | + selects[i].disabled = ""; |
| 177 | + } |
| 178 | + return true; |
| 179 | +}; |
| 180 | + |
| 181 | +wgAjaxReview.processResult = function(request) { |
| 182 | + if( !wgAjaxReview.supported ) { |
| 183 | + return; |
| 184 | + } |
| 185 | + var response = request.responseText; |
| 186 | + if( (msg = response.substr(6)) ) { |
| 187 | + jsMsg( msg, 'review' ); // success notice |
| 188 | + window.scroll(0,0); // scroll up to notice |
| 189 | + tagBox = document.getElementById('mw-revisiontag'); |
| 190 | + if( tagBox ) tagBox.style.display = 'none'; // remove tag from draft |
| 191 | + } |
| 192 | + wgAjaxReview.inprogress = false; |
| 193 | + if( wgAjaxReview.timeoutID ) { |
| 194 | + window.clearTimeout(wgAjaxReview.timeoutID); |
| 195 | + } |
| 196 | + var submit = document.getElementById("mw-submitreview"); |
| 197 | + var binaryState = document.getElementById("mw-reviewstate"); |
| 198 | + var legend = document.getElementById("mw-reviewformlegend"); |
| 199 | + var diffNotice = document.getElementById("mw-difftostable"); |
| 200 | + // On success... |
| 201 | + if( response.indexOf('<suc#>') == 0 ) { |
| 202 | + document.title = wgAjaxReview.actioncomplete; |
| 203 | + if( submit ) { |
| 204 | + // If flagging is just binary, flip the form |
| 205 | + if( binaryState ) { |
| 206 | + binaryState.value = (binaryState.value ==1 ) ? 0 : 1; |
| 207 | + // Revision was unflagged - switch to flagging form |
| 208 | + if( binaryState.value == 1 ) { |
| 209 | + legend.innerHTML = '<strong>'+wgAjaxReview.flagLegMsg+'</strong>'; |
| 210 | + submit.value = wgAjaxReview.flagMsg; |
| 211 | + // Revision was flagged - switch to unflagging form |
| 212 | + } else { |
| 213 | + legend.innerHTML = '<strong>'+wgAjaxReview.unflagLegMsg+'</strong>'; |
| 214 | + submit.value = wgAjaxReview.unflagMsg; |
| 215 | + } |
| 216 | + } else { |
| 217 | + submit.value = wgAjaxReview.sendMsg; // back to normal |
| 218 | + } |
| 219 | + } |
| 220 | + // Hide "review this" box on diffs |
| 221 | + if( diffNotice ) diffNotice.style.display = 'none'; |
| 222 | + // On failure... |
| 223 | + } else { |
| 224 | + document.title = wgAjaxReview.actionfailed; |
| 225 | + if( submit ) { |
| 226 | + if( binaryState ) { |
| 227 | + submit.value = binaryState.value ? |
| 228 | + wgAjaxReview.flagMsg : wgAjaxReview.unflagMsg; // back to normal |
| 229 | + } else { |
| 230 | + submit.value = wgAjaxReview.sendMsg; |
| 231 | + } |
| 232 | + } |
| 233 | + } |
| 234 | + wgAjaxReview.unlockForm(); |
| 235 | +}; |
| 236 | + |
| 237 | +wgAjaxReview.onLoad = function() { |
| 238 | + var submit = document.getElementById("mw-submitreview"); |
| 239 | + if( submit ) { |
| 240 | + submit.onclick = wgAjaxReview.ajaxCall; |
| 241 | + } |
| 242 | +}; |
| 243 | + |
| 244 | +hookEvent("load", wgAjaxReview.onLoad); |
Property changes on: trunk/extensions/FlaggedRevs/client/review.js |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 245 | + native |