Index: trunk/extensions/ArticleFeedback/sql/article_feedback_properties.sql |
— | — | @@ -1,12 +0,0 @@ |
2 | | -CREATE TABLE /*_*/article_feedback_properties ( |
3 | | - -- Keys to the primary key fields in article_feedback, except aa_rating_id |
4 | | - -- article_feedback doesn't have a nice PK, blegh |
5 | | - afp_revision integer unsigned NOT NULL, |
6 | | - afp_user_text varbinary(255) NOT NULL, |
7 | | - afp_user_anon_token binary(32) DEFAULT '', |
8 | | - |
9 | | - -- Key/value pairs |
10 | | - afp_key varbinary(255) NOT NULL, |
11 | | - afp_value integer signed NOT NULL |
12 | | -) /*$wgDBTableOptions*/; |
13 | | -CREATE UNIQUE INDEX /*i*/afp_rating_key ON /*_*/article_feedback_properties (afp_revision, afp_user_text, afp_user_anon_token, afp_key); |
Index: trunk/extensions/ArticleFeedback/sql/FixAnonTokenSchema.sql |
— | — | @@ -0,0 +1 @@ |
| 2 | +ALTER TABLE /*_*/article_feedback MODIFY aa_user_anon_token varbinary(32) NOT NULL DEFAULT ''; |
Property changes on: trunk/extensions/ArticleFeedback/sql/FixAnonTokenSchema.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 3 | + native |
Index: trunk/extensions/ArticleFeedback/sql/ArticleFeedback.sql |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | -- Username or IP address |
22 | 22 | aa_user_text varbinary(255) NOT NULL, |
23 | 23 | -- Unique token for anonymous users (to facilitate ratings from multiple users on the same IP) |
24 | | - aa_user_anon_token binary(32) DEFAULT '', |
| 24 | + aa_user_anon_token varbinary(32) NOT NULL DEFAULT '', |
25 | 25 | -- Foreign key to revision.rev_id |
26 | 26 | aa_revision integer unsigned NOT NULL, |
27 | 27 | -- MW Timestamp |
Index: trunk/extensions/ArticleFeedback/sql/AddPropertiesTable.sql |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +CREATE TABLE /*_*/article_feedback_properties ( |
| 3 | + -- Keys to the primary key fields in article_feedback, except aa_rating_id |
| 4 | + -- article_feedback doesn't have a nice PK, blegh |
| 5 | + afp_revision integer unsigned NOT NULL, |
| 6 | + afp_user_text varbinary(255) NOT NULL, |
| 7 | + afp_user_anon_token binary(32) DEFAULT '', |
| 8 | + |
| 9 | + -- Key/value pairs |
| 10 | + afp_key varbinary(255) NOT NULL, |
| 11 | + afp_value integer signed NOT NULL |
| 12 | +) /*$wgDBTableOptions*/; |
| 13 | +CREATE UNIQUE INDEX /*i*/afp_rating_key ON /*_*/article_feedback_properties (afp_revision, afp_user_text, afp_user_anon_token, afp_key); |
Property changes on: trunk/extensions/ArticleFeedback/sql/AddPropertiesTable.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 14 | + native |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -31,9 +31,13 @@ |
32 | 32 | 'articlefeedback-pitch-makefirstedit-title', |
33 | 33 | 'articlefeedback-pitch-makefirstedit-message', |
34 | 34 | 'articlefeedback-pitch-makefirstedit-accept', |
| 35 | + 'articlefeedback-survey-title', |
35 | 36 | ), |
36 | 37 | 'dependencies' => array( |
| 38 | + 'jquery.ui.dialog', |
| 39 | + 'jquery.ui.button', |
37 | 40 | 'jquery.articleFeedback', |
| 41 | + 'jquery.cookie', |
38 | 42 | ), |
39 | 43 | ), |
40 | 44 | 'jquery.articleFeedback' => array( |
— | — | @@ -55,6 +59,7 @@ |
56 | 60 | 'jquery.localize', |
57 | 61 | 'jquery.ui.dialog', |
58 | 62 | 'jquery.ui.button', |
| 63 | + 'jquery.cookie', |
59 | 64 | ), |
60 | 65 | ), |
61 | 66 | ); |
— | — | @@ -74,23 +79,45 @@ |
75 | 80 | } else { |
76 | 81 | $dir = dirname( __FILE__ ); |
77 | 82 | $db = $updater->getDB(); |
78 | | - |
79 | 83 | if ( !$db->tableExists( 'article_feedback' ) ) { |
| 84 | + // Rename tables |
80 | 85 | if ( $db->tableExists( 'article_assessment' ) ) { |
81 | | - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback', |
82 | | - $dir . '/sql/RenameTables.sql', true ) ); // Rename tables |
| 86 | + $updater->addExtensionUpdate( array( |
| 87 | + 'addTable', |
| 88 | + 'article_feedback', |
| 89 | + $dir . '/sql/RenameTables.sql', |
| 90 | + true |
| 91 | + ) ); |
83 | 92 | } else { |
84 | | - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback', |
85 | | - $dir . '/sql/ArticleFeedback.sql', true ) ); // Initial install tables |
| 93 | + // Initial install tables |
| 94 | + $updater->addExtensionUpdate( array( |
| 95 | + 'addTable', |
| 96 | + 'article_feedback', |
| 97 | + $dir . '/sql/ArticleFeedback.sql', |
| 98 | + true |
| 99 | + ) ); |
86 | 100 | } |
87 | 101 | } |
88 | | - |
89 | 102 | if ( !$db->fieldExists( 'article_feedback', 'aa_design_bucket', __METHOD__ ) ) { |
90 | | - $updater->addExtensionUpdate( array( 'addField', 'article_feedback', 'aa_design_bucket', |
91 | | - $dir . '/sql/AddRatingBucket.sql', true ) ); |
| 103 | + $updater->addExtensionUpdate( array( |
| 104 | + 'addField', |
| 105 | + 'article_feedback', |
| 106 | + 'aa_design_bucket', |
| 107 | + $dir . '/sql/AddRatingBucket.sql', |
| 108 | + true |
| 109 | + ) ); |
92 | 110 | } |
93 | | - $updater->addExtensionUpdate( array( 'addTable', 'article_feedback_properties', |
94 | | - "$dir/sql/article_feedback_properties.sql", true ) ); |
| 111 | + $updater->addExtensionUpdate( array( |
| 112 | + 'addTable', |
| 113 | + 'article_feedback_properties', |
| 114 | + $dir . 'sql/AddPropertiesTable.sql', |
| 115 | + true |
| 116 | + ) ); |
| 117 | + $updater->addExtensionUpdate( array( |
| 118 | + 'applyPatch', |
| 119 | + $dir . '/sql/FixAnonTokenSchema.sql', |
| 120 | + true |
| 121 | + ) ); |
95 | 122 | } |
96 | 123 | return true; |
97 | 124 | } |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -208,27 +208,31 @@ |
209 | 209 | .each( function() { |
210 | 210 | for ( var key in context.options.pitches ) { |
211 | 211 | $( $.articleFeedback.tpl.pitch ) |
212 | | - .attr( 'rel', key ) |
213 | | - .find( '.articleFeedback-title' ) |
214 | | - .text( mw.msg( context.options.pitches[key].title ) ) |
215 | | - .end() |
216 | | - .find( '.articleFeedback-message' ) |
217 | | - .text( mw.msg( context.options.pitches[key].message ) ) |
218 | | - .end() |
219 | | - .find( '.articleFeedback-accept' ) |
220 | | - .text( mw.msg( context.options.pitches[key].accept ) ) |
221 | | - .click( function() { |
222 | | - context.options.pitches[key].action(); |
223 | | - $(this).closest( '.articleFeedback-pitch' ).fadeOut(); |
224 | | - } ) |
225 | | - .button() |
226 | | - .end() |
227 | | - .find( '.articleFeedback-reject' ) |
228 | | - .text( mw.msg( context.options.pitches[key].reject ) ) |
229 | | - .click( function() { |
230 | | - $(this).closest( '.articleFeedback-pitch' ).fadeOut(); |
231 | | - } ) |
232 | | - .end() |
| 212 | + .attr( 'rel', key ) |
| 213 | + .find( '.articleFeedback-title' ) |
| 214 | + .text( mw.msg( context.options.pitches[key].title ) ) |
| 215 | + .end() |
| 216 | + .find( '.articleFeedback-message' ) |
| 217 | + .text( mw.msg( context.options.pitches[key].message ) ) |
| 218 | + .end() |
| 219 | + .find( '.articleFeedback-accept' ) |
| 220 | + .text( mw.msg( context.options.pitches[key].accept ) ) |
| 221 | + .click( function() { |
| 222 | + var $pitch = $(this).closest( '.articleFeedback-pitch' ); |
| 223 | + var key = $pitch.attr( 'rel' ); |
| 224 | + context.options.pitches[key].action(); |
| 225 | + $pitch.fadeOut(); |
| 226 | + } ) |
| 227 | + .button() |
| 228 | + .end() |
| 229 | + .find( '.articleFeedback-reject' ) |
| 230 | + .text( mw.msg( context.options.pitches[key].reject ) ) |
| 231 | + .click( function() { |
| 232 | + // Remember that the users rejected this, set a cookie to not |
| 233 | + // show this for 3 days |
| 234 | + $(this).closest( '.articleFeedback-pitch' ).fadeOut(); |
| 235 | + } ) |
| 236 | + .end() |
233 | 237 | .appendTo( $(this) ); |
234 | 238 | } |
235 | 239 | } ) |
— | — | @@ -249,6 +253,8 @@ |
250 | 254 | .click( function() { |
251 | 255 | $.articleFeedback.fn.submit.call( context ); |
252 | 256 | for ( var key in context.options.pitches ) { |
| 257 | + // Dont' bother checking the condition if there's a cookie that says |
| 258 | + // the user has rejected this within 3 days of right now |
253 | 259 | if ( context.options.pitches[key].condition() ) { |
254 | 260 | context.$ui |
255 | 261 | .find( '.articleFeedback-pitch[rel="' + key + '"]' ) |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -34,7 +34,35 @@ |
35 | 35 | return true; |
36 | 36 | }, |
37 | 37 | 'action': function() { |
38 | | - // TODO: Do something |
| 38 | + var $dialog = $( '#articleFeedback-dialog' ); |
| 39 | + if ( $dialog.size() == 0 ) { |
| 40 | + $dialog = $( '<div id="articleFeedback-dialog" class="loading" />' ) |
| 41 | + .dialog( { |
| 42 | + 'width': 600, |
| 43 | + 'height': 400, |
| 44 | + 'bgiframe': true, |
| 45 | + 'autoOpen': true, |
| 46 | + 'modal': true, |
| 47 | + 'title': mediaWiki.msg( 'articlefeedback-survey-title' ), |
| 48 | + 'close': function() { |
| 49 | + $( this ) |
| 50 | + .dialog( 'option', 'height', 400 ) |
| 51 | + .find( '.articleFeedback-success-msg, .articleFeedback-error-msg' ) |
| 52 | + .remove() |
| 53 | + .end() |
| 54 | + .find( 'form' ) |
| 55 | + .show(); |
| 56 | + } |
| 57 | + } ); |
| 58 | + $dialog.load( |
| 59 | + wgScript + '?title=Special:SimpleSurvey&survey=articlerating&raw=1', |
| 60 | + function() { |
| 61 | + //$( this ).find( 'form' ).bind( 'submit', $.ArticleAssessment.fn.submitFeedback ); |
| 62 | + $( this ).removeClass( 'loading' ); |
| 63 | + } |
| 64 | + ); |
| 65 | + } |
| 66 | + $dialog.dialog( 'open' ); |
39 | 67 | }, |
40 | 68 | 'title': 'articlefeedback-pitch-takesurvey-title', |
41 | 69 | 'message': 'articlefeedback-pitch-takesurvey-message', |