r77646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77645‎ | r77646 | r77647 >
Date:13:20, 3 December 2010
Author:catrope
Status:ok
Tags:
Comment:
Remove ArticleFeedback alpha CSS and JS files. This is the first step towards cleaning up the mess that r76961 and r77026 left behind by renaming these files twice without preserving history. PLEASE use svn rename next time!
Modified paths:
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback-alpha/ext.articleFeedback-alpha.css (deleted) (history)
  • /trunk/extensions/ArticleFeedback/modules/ext.articleFeedback-alpha/ext.articleFeedback-alpha.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback-alpha/ext.articleFeedback-alpha.css
@@ -1,186 +0,0 @@
2 -/*
3 - * Styles for Article Feedback (alpha)
4 - */
5 -
6 -.articleFeedback-wrapper #articleFeedback-rate,
7 -.articleFeedback-wrapper #articleFeedback-ratings {
8 - background: #f7f7f7;
9 - float: left;
10 -}
11 -
12 -.articleFeedback-wrapper #articleFeedback-rate {
13 - width: 650px;
14 - margin-right: 10px;
15 -}
16 -.articleFeedback-wrapper legend {
17 - font-weight: bold;
18 -}
19 -.articleFeedback-wrapper .field-wrapper {
20 - float: left;
21 - width: 270px;
22 - padding-right: 28px;
23 -}
24 -.articleFeedback-wrapper .rating-field {
25 - float: right;
26 - width: 125px;
27 - line-height: 24px;
28 - padding-right: 5px;
29 -}
30 -.articleFeedback-wrapper .rating-field-label{
31 - float: left;
32 - font-weight: bold;
33 - line-height: 24px;
34 -}
35 -.articleFeedback-wrapper .rating-field-label {
36 - margin-right: 10px;
37 -}
38 -.articleFeedback-wrapper .rating-field-hint {
39 - width: 11px;
40 - height: 24px;
41 - display: block;
42 - float: right;
43 - background: url(images/question.png) 0 50% no-repeat;
44 -}
45 -.articleFeedback-wrapper .rating-field-hint:hover {
46 - background: url(images/question-hover.png) 0 50% no-repeat;
47 -}
48 -
49 -.articleFeedback-wrapper .articleFeedback-flash {
50 - float: left;
51 - font-size: 11px;
52 - padding: 1px 5px;
53 - width: 560px;
54 - text-align: left;
55 - display: block;
56 -}
57 -.articleFeedback-wrapper .articleFeedback-stale-msg {
58 - background: #d6f3ff;
59 - border: 2px solid #5dc9f4;
60 -}
61 -.articleFeedback-wrapper .articleFeedback-success-msg {
62 - background: #e8e8e8;
63 - border: 2px solid #006505;
64 -}
65 -.articleFeedback-wrapper .articleFeedback-error-msg {
66 - background: #e8e8e8;
67 - border: 2px solid #a91100;
68 -}
69 -.articleFeedback-wrapper .articleFeedback-rating-field-name {
70 - float: left;
71 - width: 110px;
72 - font-weight: bold;
73 - font-size: 11px;
74 -}
75 -.articleFeedback-wrapper .articleFeedback-rating-field-value-wrapper {
76 - background: url(images/rating-base.png) 0 0 no-repeat;
77 - width: 120px;
78 - height: 13px;
79 - display: block;
80 - float: left;
81 - padding: 2px;
82 - text-indent: -9999px;
83 - margin-top: 4px;
84 -}
85 -.articleFeedback-wrapper .articleFeedback-rate-instructions,
86 -.articleFeedback-wrapper .articleFeedback-rate-feedback,
87 -.articleFeedback-wrapper .articleFeedback-show-ratings,
88 -.articleFeedback-wrapper .articleFeedback-hide-ratings {
89 - font-size: 11px;
90 - font-style: italic;
91 -}
92 -.articleFeedback-wrapper .articleFeedback-rate-instructions {
93 - float: left;
94 -}
95 -.articleFeedback-wrapper .articleFeedback-rate-feedback {
96 - float: right;
97 -}
98 -.articleFeedback-wrapper .articleFeedback-rating-field-value-wrapper .articleFeedback-rating-field-value {
99 - background: url(images/rating-bar.png) 0 0 no-repeat;
100 - height: 9px;
101 - float: right;
102 - display: block;
103 -}
104 -.articleFeedback-wrapper .articleFeedback-rating-fields {
105 - margin: 8px 0;
106 -}
107 -.articleFeedback-wrapper .articleFeedback-rating-fields .field-wrapper {
108 - margin-bottom: 5px;
109 -}
110 -.articleFeedback-rating-count {
111 - font-size: 11px;
112 - margin-left: 5px;
113 - float: left;
114 -}
115 -.articleFeedback-submit input {
116 - margin: 2px 0;
117 - float: right;
118 -}
119 -.articleFeedback-wrapper .articleFeedback-ratings-disabled .articleFeedback-rating-field-value-wrapper {
120 - background: urlimages/rating-base-disabled.png) 0 0 no-repeat;
121 -}
122 -.articleFeedback-wrapper .articleFeedback-ratings-disabled .articleFeedback-rating-field-value {
123 - display: none;
124 -}
125 -.articleFeedback-wrapper .articleFeedback-ratings-disabled .articleFeedback-rating-count {
126 - visibility: hidden;
127 -
128 -}
129 -.articleFeedback-wrapper .articleFeedback-ratings-disabled .articleFeedback-rating-field-name {
130 - color: #9f9f9f;
131 -}
132 -
133 -/* Simple Survey Dialog Styling */
134 -#articleFeedback-dialog.loading {
135 - display: block;
136 - height: 24px;
137 - width: 24px;
138 - background: url(images/loading.gif) center no-repeat;
139 - text-indent: -9999px;
140 - margin: 0 auto;
141 -}
142 -#articleFeedback-dialog textarea {
143 - margin-left: -2em;
144 - padding-right: 2em;
145 -}
146 -.articleFeedback-error-msg {
147 - padding: 20px 0;
148 -}
149 -
150 -
151 -/* Self Clearing Floats */
152 -.articleFeedback-wrapper .articleFeedback-information:after,
153 -.articleFeedback-wrapper .field-wrapper:after,
154 -.articleFeedback-wrapper .articleFeedback-rating-fields:after,
155 -.articleFeedback-rating:after,
156 -.articleFeedback-wrapper .articleFeedback-submit:after,
157 -.articleFeedback-wrapper .rating-fields:after {
158 - content: ".";
159 - display: block;
160 - height: 0;
161 - clear: both;
162 - visibility: hidden;
163 -}
164 -.articleFeedback-wrapper .field-wrapper,
165 -.articleFeedback-wrapper .articleFeedback-information,
166 -.articleFeedback-wrapper .articleFeedback-rating-fields,
167 -.articleFeedback-rating,
168 -.articleFeedback-wrapper .articleFeedback-submit,
169 -.articleFeedback-wrapper .rating-fields {
170 - display: inline-block;
171 -}
172 -* html .articleFeedback-wrapper .field-wrapper,
173 -* html .articleFeedback-wrapper .articleFeedback-information,
174 -* html .articleFeedback-wrapper .articleFeedback-rating-fields,
175 -* html .articleFeedback-rating,
176 -* html .articleFeedback-wrapper .articleFeedback-submit,
177 -* html .articleFeedback-wrapper .rating-fields {
178 - height: 1%;
179 -}
180 -.articleFeedback-wrapper .field-wrapper,
181 -.articleFeedback-wrapper .articleFeedback-information,
182 -.articleFeedback-wrapper .articleFeedback-rating-fields,
183 -.articleFeedback-rating,
184 -.articleFeedback-wrapper .articleFeedback-submit,
185 -.articleFeedback-wrapper .rating-fields {
186 - display: block;
187 -}
\ No newline at end of file
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback-alpha/ext.articleFeedback-alpha.js
@@ -1,520 +0,0 @@
2 -/*
3 - * Script for Article Feedback (alpha)
4 - */
5 -
6 -( function( $ ) {
7 - $.ArticleFeedback = {
8 - 'config': {
9 - 'authtoken': '',
10 - 'userID': '',
11 - 'pageID': wgArticleId,
12 - 'revID': wgCurRevisionId
13 - },
14 - 'messages': {},
15 - 'settings': {
16 - 'endpoint': wgScriptPath + '/api.php?',
17 - 'fieldMessages' : [
18 - 'wellsourced',
19 - 'neutrality',
20 - 'completeness',
21 - 'readability'
22 - ],
23 - 'fieldHintSuffix': '-tooltip',
24 - 'fieldPrefix': 'articlefeedback-alpha-rating-',
25 - 'fieldHTML': '<div class="field-wrapper"> \
26 - <label class="rating-field-label"></label> \
27 - <select class="rating-field"> \
28 - <option value="1">1</option> \
29 - <option value="2">2</option> \
30 - <option value="3">3</option> \
31 - <option value="4">4</option> \
32 - <option value="5">5</option> \
33 - </select> \
34 - </div>',
35 - 'structureHTML': '<div class="articleFeedback-wrapper nonopopups"> \
36 - <form action="rate" method="post" id="articleFeedback"> \
37 - <fieldset id="articleFeedback-rate"> \
38 - <legend></legend> \
39 - <div class="articleFeedback-information"> \
40 - <span class="articleFeedback-rate-instructions"></span> \
41 - <span class="articleFeedback-rate-feedback"></span> \
42 - </div> \
43 - <div class="articleFeedback-rating-fields"></div> \
44 - <div class="articleFeedback-submit"> \
45 - <input type="submit" value="Submit" /> \
46 - </div> \
47 - </fieldset> \
48 - <fieldset id="articleFeedback-ratings"> \
49 - <legend></legend> \
50 - <div class="articleFeedback-information"> \
51 - <span class="articleFeedback-show-ratings"></span> \
52 - <span class="articleFeedback-hide-ratings"></span> \
53 - </div> \
54 - </fieldset> \
55 - </form> \
56 - </div>',
57 - 'ratingHTML': '<div class="articleFeedback-rating"> \
58 - <span class="articleFeedback-rating-field-name"></span> \
59 - <span class="articleFeedback-rating-field-value-wrapper"> \
60 - <span class="articleFeedback-rating-field-value">0%</span> \
61 - </span> \
62 - <span class="articleFeedback-rating-count"></span> \
63 - </div>'
64 - },
65 -
66 - 'fn' : {
67 - 'init': function( $$options ) {
68 - // merge options with the config
69 - var settings = $.extend( {}, $.ArticleFeedback.settings, $$options );
70 - var config = $.ArticleFeedback.config;
71 - // if this is an anon user, get a unique identifier for them
72 - // load up the stored ratings and update the markup if the cookie exists
73 - var userToken = $.cookie( 'mwArticleFeedbackUserToken' );
74 - if ( typeof userToken == 'undefined' || userToken == null ) {
75 - function randomString( string_length ) {
76 - var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
77 - var randomstring = '';
78 - for ( var i = 0; i < string_length; i++ ) {
79 - var rnum = Math.floor( Math.random() * chars.length );
80 - randomstring += chars.substring( rnum, rnum + 1 );
81 - }
82 - return randomstring;
83 - }
84 - userToken = randomString( 32 );
85 - $.cookie(
86 - 'mwArticleFeedbackUserToken',
87 - userToken,
88 - { 'expires': 30, 'path': '/' }
89 - );
90 - }
91 - if ( !wgUserName ) {
92 - config.userID = userToken;
93 - }
94 - // setup our markup using the template variables in settings
95 - var $structure = $( settings.structureHTML ),
96 - instructions = mediaWiki.msg( 'articlefeedback-alpha-pleaserate' ),
97 - feedback = mediaWiki.msg( 'articlefeedback-alpha-featurefeedback' ),
98 - yourfeedback = mediaWiki.msg( 'articlefeedback-alpha-yourfeedback'),
99 - articlerating = mediaWiki.msg( 'articlefeedback-alpha-articlerating' ),
100 - resultshide = mediaWiki.msg( 'articlefeedback-alpha-results-hide' ),
101 - resultsshow = mediaWiki.msg( 'articlefeedback-alpha-results-show' );
102 - submitbutton = mediaWiki.msg( 'articlefeedback-alpha-submit' );
103 - $structure
104 - .find( '#articleFeedback-rate legend' )
105 - .html( yourfeedback )
106 - .end()
107 - .find( '.articleFeedback-rate-instructions' )
108 - .html( instructions )
109 - .end()
110 - .find( '.articleFeedback-rate-feedback' )
111 - .html( feedback )
112 - .find( '.feedbacklink' )
113 - .wrap( '<a href="#"></a>' )
114 - .parent()
115 - .click( $.ArticleFeedback.fn.showFeedback )
116 - .end()
117 - .end()
118 - .end()
119 - .find( '#articleFeedback-ratings legend' )
120 - .html( articlerating )
121 - .end()
122 - .find( '.articleFeedback-show-ratings' )
123 - .html( resultsshow )
124 - .find( '.showlink' )
125 - .wrap( '<a href="#"></a>' )
126 - .parent()
127 - .click( $.ArticleFeedback.fn.showRatings )
128 - .end()
129 - .end()
130 - .end()
131 - .find( '.articleFeedback-hide-ratings' )
132 - .html( resultshide )
133 - .find ( '.hidelink' )
134 - .wrap( '<a href="#"></a>' )
135 - .parent()
136 - .click( $.ArticleFeedback.fn.hideRatings )
137 - .end()
138 - .end()
139 - .end()
140 - .find( '.articleFeedback-submit input' )
141 - .val( submitbutton )
142 - .end();
143 - // hide the feedback link if we need to
144 - if( $.cookie( 'mwArticleFeedbackHideFeedbackLink' ) ) {
145 - $structure
146 - .find( '.articleFeedback-rate-feedback' )
147 - .hide();
148 - }
149 - for ( var i = 0; i < settings.fieldMessages.length; i++ ) {
150 - var $field = $( settings.fieldHTML ),
151 - $rating = $( settings.ratingHTML ),
152 - label = mediaWiki.msg( settings.fieldPrefix + settings.fieldMessages[i] ),
153 - field = settings.fieldMessages[i],
154 - hint = mediaWiki.msg(
155 - settings.fieldPrefix + settings.fieldMessages[i] +
156 - settings.fieldHintSuffix
157 - ),
158 - count = mediaWiki.msg( 'articlefeedback-alpha-noratings', 0, 0 );
159 - // initialize the field html
160 - $field
161 - .attr( 'id', 'articlefeedback-alpha-rate-' + field )
162 - .find( 'label' )
163 - .attr( 'for', 'rating_' + field )
164 - .attr( 'original-title', hint )
165 - .html( label )
166 - .end()
167 - .find( 'select' )
168 - .attr( 'id', 'rating_' + field )
169 - .attr( 'name', 'rating[' + field + ']' );
170 - // initialize the rating html
171 - $rating
172 - .attr( 'id', 'articlefeedback-alpha-rating-' + field )
173 - .find( '.articleFeedback-rating-field-name' )
174 - .html( label )
175 - .end()
176 - .find( '.articleFeedback-rating-count' )
177 - .html( count );
178 - // append the field and rating html
179 - $structure
180 - .find( '.articleFeedback-rating-fields' )
181 - .append( $field )
182 - .end()
183 - .find( '#articleFeedback-ratings' )
184 - .append( $rating );
185 - }
186 - // store our settings and configuration for later
187 - $structure.find( '#articleFeedback' )
188 - .data(
189 - 'articleFeedback-context',
190 - { 'settings': settings, 'config': config }
191 - );
192 - $( '#catlinks' ).before( $structure );
193 - // Hide the ratings initially
194 - $.ArticleFeedback.fn.hideRatings();
195 -
196 -
197 - // set the height of our smaller fieldset to match the taller
198 - if (
199 - $( '#articleFeedback-rate' ).height() >
200 - $( '#articleFeedback-ratings' ).height() ) {
201 - $( '#articleFeedback-ratings' )
202 - .css( 'minHeight', $( '#articleFeedback-rate' ).height() );
203 - } else {
204 - $( '#articleFeedback-rate' )
205 - .css( 'minHeight', $( '#articleFeedback-ratings' ).height() );
206 - }
207 - // attempt to fetch the ratings
208 - $.ArticleFeedback.fn.getRatingData();
209 -
210 - // initialize the star plugin
211 - $( '.rating-field' ).each( function() {
212 - $(this)
213 - .wrapAll( '<div class="rating-field"></div>' )
214 - .parent()
215 - .stars( {
216 - inputType: 'select',
217 - callback: function( value, link ) {
218 - // remove any stale or rated classes
219 - value.$stars.each( function() {
220 - $(this)
221 - .removeClass( 'ui-stars-star-stale' )
222 - .removeClass( 'ui-stars-star-rated' );
223 - // enable our submit button if it's still disabled
224 - $( '#articleFeedback input:disabled' )
225 - .removeAttr( 'disabled' );
226 - } );
227 - }
228 - } );
229 - } );
230 - // intialize the tooltips
231 - $( '.field-wrapper label[original-title]' ).each( function() {
232 - $(this)
233 - .after( $( '<span class="rating-field-hint" />' )
234 - .attr( 'original-title', $(this).attr( 'original-title' ) )
235 - .tipsy( { gravity : 'se', opacity: '0.9' } ) );
236 - } );
237 - // bind submit event to the form
238 - $( '#articleFeedback' )
239 - .submit( function() { $.ArticleFeedback.fn.submitRating(); return false; } );
240 - // prevent the submit button for being active until all ratings are filled out
241 - $( '#articleFeedback input[type=submit]' )
242 - .attr( 'disabled', 'disabled' );
243 - },
244 - 'showRatings': function() {
245 - $( '#articleFeedback-ratings' )
246 - .removeClass( 'articleFeedback-ratings-disabled' )
247 - .find( '.articleFeedback-show-ratings' )
248 - .hide()
249 - .end()
250 - .find( '.articleFeedback-hide-ratings' )
251 - .show();
252 - return false;
253 - },
254 - 'hideRatings': function() {
255 - $( '#articleFeedback-ratings' )
256 - .addClass( 'articleFeedback-ratings-disabled' )
257 - .find( '.articleFeedback-hide-ratings' )
258 - .hide()
259 - .end()
260 - .find( '.articleFeedback-show-ratings' )
261 - .show();
262 - return false;
263 -
264 - },
265 -
266 - // Request the ratings data for the current article
267 - 'getRatingData': function() {
268 - var config = $( '#articleFeedback' ).data( 'articleFeedback-context' ).config;
269 - var requestData = {
270 - 'action': 'query',
271 - 'list': 'articlefeedback',
272 - 'aapageid': config.pageID,
273 - 'aauserrating': 1,
274 - 'format': 'json'
275 - }
276 - if ( config.userID.length == 32 ) {
277 - requestData.aaanontoken = config.userID;
278 - }
279 -
280 - var request = $.ajax( {
281 - url: wgScriptPath + '/api.php',
282 - data: requestData,
283 - dataType: 'json',
284 - success: $.ArticleFeedback.fn.afterGetRatingData,
285 - error: function( XMLHttpRequest, textStatus, errorThrown ) {
286 - $.ArticleFeedback.fn.flashNotice( mediaWiki.msg( 'articlefeedback-alpha-error' ),
287 - { 'class': 'articleFeedback-error-msg' } );
288 - }
289 - } );
290 - },
291 - 'afterGetRatingData' : function( data ) {
292 - var settings = $( '#articleFeedback' ).data( 'articleFeedback-context' ).settings,
293 - userHasRated = false;
294 - // add the correct data to the markup
295 - if ( typeof data.query != 'undefined' && typeof data.query.articlefeedback != 'undefined' &&
296 - typeof data.query.articlefeedback[0] != 'undefined' ) {
297 - for ( var r in data.query.articlefeedback[0].ratings ) {
298 - var rating = data.query.articlefeedback[0].ratings[r],
299 - $rating = $( '#' + rating.ratingdesc ),
300 - count = rating.count,
301 - total = ( rating.total / count ).toFixed( 1 ),
302 - label = mediaWiki.msg( 'articlefeedback-alpha-noratings', total, count );
303 - $rating
304 - .find( '.articleFeedback-rating-field-value' )
305 - .text( total )
306 - .end()
307 - .find( '.articleFeedback-rating-count' )
308 - .html( label );
309 - if( rating.userrating ) {
310 - userHasRated = true;
311 - // this user rated. Word. Show them their ratings
312 - var $rateControl = $( '#' + rating.ratingdesc.replace( 'rating', 'rate' ) + ' .rating-field' );
313 - $rateControl.stars( 'select', rating.userrating );
314 - }
315 - }
316 - // show the ratings if the user has rated
317 - if( userHasRated ) {
318 - $.ArticleFeedback.fn.showRatings();
319 - }
320 - // if the rating is more than 5 revisions old, mark it as stale
321 - if ( typeof data.query.articlefeedback[0].stale != 'undefined' ) {
322 - // add the stale star class to each on star
323 - $( '.ui-stars-star-on' )
324 - .addClass( 'ui-stars-star-stale' );
325 - // add the stale message
326 - var msg = mediaWiki.msg( 'articlefeedback-alpha-stalemessage-norevisioncount' );
327 - $.ArticleFeedback.fn.flashNotice( msg, { 'class': 'articleFeedback-stale-msg' } );
328 - } else {
329 - // if it's not a stale rating, we want to make the stars blue
330 - $( '.ui-stars-star-on' ).addClass( 'ui-stars-star-rated' );
331 - }
332 - }
333 - // initialize the ratings
334 - $( '.articleFeedback-rating-field-value' ).each( function() {
335 - $(this)
336 - .css( {
337 - 'width': 120 - ( 120 * ( parseFloat( $(this).text() ) / 5 ) ) + 'px'
338 - } )
339 - } );
340 - },
341 - 'submitRating': function() {
342 - var config = $( '#articleFeedback' ).data( 'articleFeedback-context' ).config;
343 - // clear out the stale message
344 - $.ArticleFeedback.fn.flashNotice( );
345 -
346 - // lock the star inputs & submit
347 - $( '.rating-field' ).stars( 'disable' );
348 - $( '#articleFeedback input' ).attr( 'disabled', 'disabled' );
349 - // get our results for submitting
350 - var results = {};
351 - $( '.rating-field input' ).each( function() {
352 - // expects the hidden inputs to have names like 'rating[field-name]' which we use to
353 - // be transparent about what values we're sending to the server
354 - var fieldName = $(this).attr( 'name' ).match( /\[([a-zA-Z0-9\-]*)\]/ )[1];
355 - results[ fieldName ] = $(this).val();
356 - } );
357 - var request = $.ajax( {
358 - url: wgScriptPath + '/api.php',
359 - type: 'POST',
360 - data: {
361 - 'action': 'articlefeedback',
362 - 'revid': config.revID,
363 - 'pageid': config.pageID,
364 - 'r1' : results['wellsourced'],
365 - 'r2' : results['neutrality'],
366 - 'r3' : results['completeness'],
367 - 'r4' : results['readability'],
368 - 'anontoken': config.userID,
369 - 'format': 'json'
370 - },
371 - dataType: 'json',
372 - success: $.ArticleFeedback.fn.afterSubmitRating,
373 - error: function( XMLHttpRequest, textStatus, errorThrown ) {
374 - $.ArticleFeedback.fn.flashNotice( mediaWiki.msg( 'articlefeedback-alpha-error' ),
375 - { 'class': 'articleFeedback-error-msg' } );
376 - }
377 - } );
378 - },
379 - 'afterSubmitRating': function ( data ) {
380 - // update the ratings
381 - $.ArticleFeedback.fn.getRatingData();
382 - // set the stars to rated status
383 - $( '.ui-stars-star-on' ).addClass( 'ui-stars-star-rated' );
384 - // unlock the stars & submit
385 - $( '.rating-field' ).stars( 'enable' );
386 - $( '#articleFeedback input:disabled' ).removeAttr( 'disabled' );
387 - // update the results
388 -
389 - // show the results
390 - $.ArticleFeedback.fn.showRatings();
391 - // say thank you
392 - $.ArticleFeedback.fn.flashNotice( mediaWiki.msg( 'articlefeedback-alpha-thanks' ),
393 - { 'class': 'articleFeedback-success-msg' } );
394 - },
395 - // places a message on the interface
396 - 'flashNotice': function( text, options ) {
397 - if ( arguments.length == 0 ) {
398 - // clear existing messages, but don't add a new one
399 - $( '#articleFeedback .articleFeedback-flash' ).remove();
400 - } else {
401 - // clear and add a new message
402 - $( '#articleFeedback .articleFeedback-flash' ).remove();
403 - var className = options['class'];
404 - // create our new message
405 - $msg = $( '<div />' )
406 - .addClass( 'articleFeedback-flash' )
407 - .html( text );
408 - // if the class option was passed, add it
409 - if( options['class'] ) {
410 - $msg.addClass( options['class'] );
411 - }
412 - // place our new message on the page
413 - $( '#articleFeedback .articleFeedback-submit' )
414 - .append( $msg );
415 - }
416 - },
417 - 'showFeedback': function() {
418 - var $dialogDiv = $( '#articleFeedback-dialog' );
419 - if ( $dialogDiv.size() == 0 ) {
420 - $dialogDiv = $( '<div id="articleFeedback-dialog" class="loading" />' )
421 - .dialog( {
422 - width: 600,
423 - height: 400,
424 - bgiframe: true,
425 - autoOpen: true,
426 - modal: true,
427 - title: mediaWiki.msg( 'articlefeedback-alpha-survey-title' ),
428 - close: function() {
429 - $(this)
430 - .dialog( 'option', 'height', 400 )
431 - .find( '.articleFeedback-success-msg, .articleFeedback-error-msg' )
432 - .remove()
433 - .end()
434 - .find( 'form' )
435 - .show();
436 - }
437 - } );
438 - $dialogDiv.load(
439 - wgScript + '?title=Special:SimpleSurvey&survey=articlerating&raw=1',
440 - function() {
441 - $(this).find( 'form' ).bind( 'submit', $.ArticleFeedback.fn.submitFeedback );
442 - $(this).removeClass( 'loading' );
443 - }
444 - );
445 - }
446 - $dialogDiv.dialog( 'open' );
447 - return false;
448 - },
449 - 'submitFeedback': function() {
450 - var $dialogDiv = $( '#articleFeedback-dialog' );
451 - $dialogDiv
452 - .find( 'form' )
453 - .hide()
454 - .end()
455 - .addClass( 'loading' );
456 - // Submit straight to the special page. Yes, this is a dirty dirty hack
457 - // Build request from form data
458 - var formData = {};
459 - $dialogDiv.find( 'input[type=text], input[type=radio]:checked, input[type=checkbox]:checked, ' +
460 - 'input[type=hidden], textarea' ).each( function() {
461 - var name = $(this).attr( 'name' );
462 - if ( name !== '' ) {
463 - if ( name.substr( -2 ) == '[]' ) {
464 - var trimmedName = name.substr( 0, name.length - 2 );
465 - if ( typeof formData[trimmedName] == 'undefined' ) {
466 - formData[trimmedName] = [];
467 - }
468 - formData[trimmedName].push( $(this).val() );
469 - } else {
470 - formData[name] = $(this).val();
471 - }
472 - }
473 - } );
474 - formData.title = 'Special:SimpleSurvey';
475 -
476 - $.ajax( {
477 - url: wgScript,
478 - type: 'POST',
479 - data: formData,
480 - dataType: 'html',
481 - success: function( data ) {
482 - // This is an evil screenscraping method to determine whether
483 - // the submission was successful
484 - var success = $( data ).find( '.simplesurvey-success' ).size() > 0;
485 - // TODO: Style success-msg, error-msg
486 - var $msgDiv = $( '<div />' )
487 - .addClass( success ? 'articleFeedback-success-msg' : 'articleFeedback-error-msg' )
488 - .html( mediaWiki.msg( success? 'articlefeedback-alpha-survey-thanks' : 'articlefeedback-alpha-error' ) )
489 - .appendTo( $dialogDiv );
490 - $dialogDiv.removeClass( 'loading' );
491 -
492 - // This is absurdly unnecessary from the looks of it, but it seems this is somehow
493 - // needed in certain cases.
494 - $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 );
495 -
496 - if ( success ) {
497 - // Hide the dialog link
498 - $( '#articleFeedback .articleFeedback-rate-feedback' ).hide();
499 - // set a cookie to keep the dialog link hidden
500 - $.cookie( 'mwArticleFeedbackHideFeedbackLink', true, { 'expires': 30, 'path': '/' } );
501 -
502 - }
503 - },
504 - error: function( XMLHttpRequest, textStatus, errorThrown ) {
505 - // TODO: Duplicates code, factor out, maybe
506 - var $msgDiv = $( '<div />' )
507 - .addClass( 'articleFeedback-error-msg' )
508 - .html( mediaWiki.msg( 'articlefeedback-alpha-error' ) )
509 - .appendTo( $dialogDiv );
510 - $dialogDiv.removeClass( 'loading' );
511 - $dialogDiv.dialog( 'option', 'height', $msgDiv.height() + 100 );
512 - }
513 - } );
514 - return false;
515 - }
516 - }
517 - };
518 - $( document ).ready( function () {
519 - $.ArticleFeedback.fn.init( );
520 - } ); //document ready
521 -} )( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r77647Part 2 of r77646: copy articleFeedback CSS and JS from old ArticleAssessmentP...catrope13:26, 3 December 2010
r77648Part 3 of r77646: reapply r76964, r76965, r76966catrope13:33, 3 December 2010
r77649Final part of r77646: reapply r77027catrope13:36, 3 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76961Part 1 of 2 - Renaming ArticleAssessmentPilot to ArticleFeedback - this commi...tparscal21:15, 18 November 2010
r77026Moved initial implementation into the alpha moduletparscal19:53, 19 November 2010

Status & tagging log