Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -23,11 +23,13 @@ |
24 | 24 | 'articlefeedback-field-wellwritten-tip', |
25 | 25 | 'articlefeedback-pitch-takesurvey-title', |
26 | 26 | 'articlefeedback-pitch-reject', |
| 27 | + 'articlefeedback-pitch-or', |
27 | 28 | 'articlefeedback-pitch-takesurvey-message', |
28 | 29 | 'articlefeedback-pitch-takesurvey-accept', |
29 | 30 | 'articlefeedback-pitch-createaccount-title', |
30 | 31 | 'articlefeedback-pitch-createaccount-message', |
31 | 32 | 'articlefeedback-pitch-createaccount-accept', |
| 33 | + 'articlefeedback-pitch-createaccount-login', |
32 | 34 | 'articlefeedback-pitch-makefirstedit-title', |
33 | 35 | 'articlefeedback-pitch-makefirstedit-message', |
34 | 36 | 'articlefeedback-pitch-makefirstedit-accept', |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -103,6 +103,30 @@ |
104 | 104 | } |
105 | 105 | } ); |
106 | 106 | }, |
| 107 | + 'executePitch': function( action ) { |
| 108 | + $(this) |
| 109 | + .closest( '.articleFeedback-pitch' ) |
| 110 | + .find( '.articleFeedback-accept, .articleFeedback-altAccept' ) |
| 111 | + .button( { 'disabled': true } ) |
| 112 | + .end() |
| 113 | + .find( '.articleFeedback-reject' ) |
| 114 | + .attr( 'disabled', true ); |
| 115 | + var $pitch = $(this).closest( '.articleFeedback-pitch' ); |
| 116 | + var key = $pitch.attr( 'rel' ); |
| 117 | + // If a pitch's action returns true, hide the pitch and |
| 118 | + // re-enable the button |
| 119 | + if ( action.call( $(this) ) ) { |
| 120 | + $pitch.fadeOut(); |
| 121 | + $(this) |
| 122 | + .closest( '.articleFeedback-pitch' ) |
| 123 | + .find( '.articleFeedback-accept, .articleFeedback-altAccept' ) |
| 124 | + .button( { 'disabled': false } ) |
| 125 | + .end() |
| 126 | + .find( '.articleFeedback-reject' ) |
| 127 | + .attr( 'disabled', false ); |
| 128 | + } |
| 129 | + return false; |
| 130 | + }, |
107 | 131 | 'load': function() { |
108 | 132 | var context = this; |
109 | 133 | $.ajax( { |
— | — | @@ -217,23 +241,11 @@ |
218 | 242 | .find( '.articleFeedback-accept' ) |
219 | 243 | .text( mw.msg( context.options.pitches[key].accept ) ) |
220 | 244 | .click( function() { |
221 | | - $(this) |
222 | | - .button( { 'disabled': true } ) |
223 | | - .closest( '.articleFeedback-pitch' ) |
224 | | - .find( '.articleFeedback-reject' ) |
225 | | - .attr( 'disabled', true ); |
226 | 245 | var $pitch = $(this).closest( '.articleFeedback-pitch' ); |
227 | | - var key = $pitch.attr( 'rel' ); |
228 | | - // If a pitch's action returns true, hide the pitch and |
229 | | - // re-enable the button |
230 | | - if ( context.options.pitches[key].action() ) { |
231 | | - $pitch.fadeOut(); |
232 | | - $(this) |
233 | | - .button( { 'disabled': false } ) |
234 | | - .closest( '.articleFeedback-pitch' ) |
235 | | - .find( '.articleFeedback-reject' ) |
236 | | - .attr( 'disabled', false ); |
237 | | - } |
| 246 | + return $.articleFeedback.fn.executePitch.call( |
| 247 | + $(this), |
| 248 | + context.options.pitches[$pitch.attr( 'rel' )].action |
| 249 | + ); |
238 | 250 | } ) |
239 | 251 | .button() |
240 | 252 | .end() |
— | — | @@ -252,6 +264,29 @@ |
253 | 265 | } ) |
254 | 266 | .end() |
255 | 267 | .appendTo( $(this) ); |
| 268 | + if ( |
| 269 | + typeof context.options.pitches[key].altAccept == 'string' |
| 270 | + && typeof context.options.pitches[key].altAction == 'function' |
| 271 | + ) { |
| 272 | + $(this) |
| 273 | + .find( '.articleFeedback-accept' ) |
| 274 | + .after( '<button class="articleFeedback-altAccept"></button>' ) |
| 275 | + .after( |
| 276 | + $( '<span class="articleFeedback-pitch-or"></span>' ) |
| 277 | + .text( mw.msg( 'articlefeedback-pitch-or' ) ) |
| 278 | + ) |
| 279 | + .end() |
| 280 | + .find( '.articleFeedback-altAccept' ) |
| 281 | + .text( mw.msg( context.options.pitches[key].altAccept ) ) |
| 282 | + .click( function() { |
| 283 | + var $pitch = $(this).closest( '.articleFeedback-pitch' ); |
| 284 | + return $.articleFeedback.fn.executePitch.call( |
| 285 | + $(this), |
| 286 | + context.options.pitches[$pitch.attr( 'rel' )].altAction |
| 287 | + ); |
| 288 | + } ) |
| 289 | + .button(); |
| 290 | + } |
256 | 291 | } |
257 | 292 | } ) |
258 | 293 | .localize( { 'prefix': 'articlefeedback-' } ) |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.css |
— | — | @@ -24,7 +24,10 @@ |
25 | 25 | border: 1px solid #cccccc; |
26 | 26 | padding-bottom: 1px; |
27 | 27 | } |
28 | | - |
| 28 | +.articleFeedback-pitch-or { |
| 29 | + margin-left: 0.75em; |
| 30 | + margin-right: 0.25em; |
| 31 | +} |
29 | 32 | .articleFeedback-reject { |
30 | 33 | border: none; |
31 | 34 | background-color: #f9f9f9; |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -195,28 +195,14 @@ |
196 | 196 | } |
197 | 197 | }, |
198 | 198 | 'pitches': { |
199 | | - 'takesurvey': { |
200 | | - 'condition': function() { |
201 | | - // If already taken survey, return false |
202 | | - return isPitchMuted( 'takesurvey' ) ? false : lottery( 0.33 ); |
203 | | - }, |
204 | | - 'action': function() { |
205 | | - survey.load(); |
206 | | - // Hide the pitch immediately |
207 | | - return true; |
208 | | - }, |
209 | | - 'title': 'articlefeedback-pitch-takesurvey-title', |
210 | | - 'message': 'articlefeedback-pitch-takesurvey-message', |
211 | | - 'accept': 'articlefeedback-pitch-takesurvey-accept', |
212 | | - 'reject': 'articlefeedback-pitch-reject' |
213 | | - }, |
214 | 199 | 'createaccount': { |
215 | 200 | 'condition': function() { |
216 | 201 | // If user is logged in, return false |
217 | | - return !isPitchMuted( 'createaccount' ) && mediaWiki.user.anonymous(); |
| 202 | + return ( isPitchMuted( 'createaccount' ) || !mediaWiki.user.anonymous() ) |
| 203 | + ? false : lottery( 0.5 ); |
218 | 204 | }, |
219 | 205 | 'action': function() { |
220 | | - // TODO: Do something |
| 206 | + // Go to account creation page |
221 | 207 | window.location = |
222 | 208 | mediaWiki.config.get( 'wgScript' ) + '?' + $.param( { |
223 | 209 | 'title': 'Special:UserLogin', |
— | — | @@ -230,15 +216,29 @@ |
231 | 217 | 'title': 'articlefeedback-pitch-createaccount-title', |
232 | 218 | 'message': 'articlefeedback-pitch-createaccount-message', |
233 | 219 | 'accept': 'articlefeedback-pitch-createaccount-accept', |
234 | | - 'reject': 'articlefeedback-pitch-reject' |
| 220 | + 'reject': 'articlefeedback-pitch-reject', |
| 221 | + // Special alternative action for going to login page |
| 222 | + 'altAccept': 'articlefeedback-pitch-createaccount-login', |
| 223 | + 'altAction': function() { |
| 224 | + // Go to login page |
| 225 | + window.location = |
| 226 | + mediaWiki.config.get( 'wgScript' ) + '?' + $.param( { |
| 227 | + 'title': 'Special:UserLogin', |
| 228 | + 'returnto': mediaWiki.config.get( 'wgPageName' ) |
| 229 | + } ); |
| 230 | + // Mute for 1 day |
| 231 | + mutePitch( 'createaccount', 1 ); |
| 232 | + return false; |
| 233 | + } |
235 | 234 | }, |
236 | 235 | 'makefirstedit': { |
237 | 236 | 'condition': function() { |
238 | 237 | // If user is not logged in, return false |
239 | | - return !isPitchMuted( 'makefirstedit' ) && !mediaWiki.user.anonymous(); |
| 238 | + return ( isPitchMuted( 'makefirstedit' ) || mediaWiki.user.anonymous() ) |
| 239 | + ? false : lottery( 0.5 ); |
240 | 240 | }, |
241 | 241 | 'action': function() { |
242 | | - // TODO: Do something |
| 242 | + // Go to edit page |
243 | 243 | window.location = |
244 | 244 | mediaWiki.config.get( 'wgScript' ) + '?' + $.param( { |
245 | 245 | 'title': mediaWiki.config.get( 'wgPageName' ), |
— | — | @@ -252,6 +252,21 @@ |
253 | 253 | 'message': 'articlefeedback-pitch-makefirstedit-message', |
254 | 254 | 'accept': 'articlefeedback-pitch-makefirstedit-accept', |
255 | 255 | 'reject': 'articlefeedback-pitch-reject' |
| 256 | + }, |
| 257 | + 'takesurvey': { |
| 258 | + 'condition': function() { |
| 259 | + // If already taken survey, return false |
| 260 | + return !isPitchMuted( 'takesurvey' ); |
| 261 | + }, |
| 262 | + 'action': function() { |
| 263 | + survey.load(); |
| 264 | + // Hide the pitch immediately |
| 265 | + return true; |
| 266 | + }, |
| 267 | + 'title': 'articlefeedback-pitch-takesurvey-title', |
| 268 | + 'message': 'articlefeedback-pitch-takesurvey-message', |
| 269 | + 'accept': 'articlefeedback-pitch-takesurvey-accept', |
| 270 | + 'reject': 'articlefeedback-pitch-reject' |
256 | 271 | } |
257 | 272 | } |
258 | 273 | }; |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php |
— | — | @@ -45,12 +45,14 @@ |
46 | 46 | 'articlefeedback-field-wellwritten-label' => 'Well-written', |
47 | 47 | 'articlefeedback-field-wellwritten-tip' => 'Do you feel that this page is well-organized and well-written?', |
48 | 48 | 'articlefeedback-pitch-reject' => 'Maybe later', |
| 49 | + 'articlefeedback-pitch-or' => 'or', |
49 | 50 | 'articlefeedback-pitch-takesurvey-title' => 'Would you like to take a survey?', |
50 | 51 | 'articlefeedback-pitch-takesurvey-message' => '-- message --', |
51 | 52 | 'articlefeedback-pitch-takesurvey-accept' => 'Start survey', |
52 | 53 | 'articlefeedback-pitch-createaccount-title' => 'Would you like to create an account?', |
53 | 54 | 'articlefeedback-pitch-createaccount-message' => '-- message --', |
54 | 55 | 'articlefeedback-pitch-createaccount-accept' => 'Create account', |
| 56 | + 'articlefeedback-pitch-createaccount-login' => 'Log in', |
55 | 57 | 'articlefeedback-pitch-makefirstedit-title' => 'Would you like to edit this page?', |
56 | 58 | 'articlefeedback-pitch-makefirstedit-message' => '-- message --', |
57 | 59 | 'articlefeedback-pitch-makefirstedit-accept' => 'Start editing', |