Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | -- Store mapping of i18n key of "rating" to an ID |
3 | 3 | CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment_ratings ( |
4 | | - --Rating Id |
| 4 | + -- Rating Id |
5 | 5 | aar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
6 | | - --Text (i18n key) for rating description |
| 6 | + -- Text (i18n key) for rating description |
7 | 7 | aar_rating varchar(255) binary NOT NULL |
8 | 8 | ) /*$wgDBTableOptions*/; |
9 | 9 | |
| 10 | +-- Default article assessment ratings for the pilot |
10 | 11 | INSERT INTO /*$wgDBprefix*/article_assessment_ratings (aar_rating) VALUES |
11 | 12 | ('articleassessment-rating-wellsourced'), ('articleassessment-rating-neutrality'), |
12 | 13 | ('articleassessment-rating-completeness'), ('articleassessment-rating-readability'); |
Index: trunk/extensions/ArticleAssessmentPilot/css/ArticleAssessment.css |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | .article-assessment-wrapper .ui-stars-star a { |
24 | 24 | width: 21px; |
25 | 25 | height: 21px; |
| 26 | + line-height: 0; |
26 | 27 | display: block; |
27 | 28 | background: url(../images/stars.gif) no-repeat 0 0; |
28 | 29 | } |
— | — | @@ -87,6 +88,7 @@ |
88 | 89 | } |
89 | 90 | .article-assessment-wrapper .rating-field { |
90 | 91 | float: right; |
| 92 | + width: 125px; |
91 | 93 | line-height: 24px; |
92 | 94 | padding-right: 5px; |
93 | 95 | } |
— | — | @@ -105,15 +107,14 @@ |
106 | 108 | float: right; |
107 | 109 | background: url(../images/question.gif) 0 50% no-repeat; |
108 | 110 | } |
109 | | -.article-assessment-wrapper .article-assessment-submit { |
110 | | - text-align: right; |
111 | | -} |
| 111 | + |
112 | 112 | .article-assessment-wrapper .article-assessment-flash { |
113 | 113 | float: left; |
114 | 114 | font-size: 11px; |
115 | 115 | padding: 1px 5px; |
116 | 116 | width: 560px; |
117 | 117 | text-align: left; |
| 118 | + display: block; |
118 | 119 | } |
119 | 120 | .article-assessment-wrapper .article-assessment-stale-msg { |
120 | 121 | background: #d6f3ff; |
— | — | @@ -162,7 +163,7 @@ |
163 | 164 | float: right; |
164 | 165 | display: block; |
165 | 166 | } |
166 | | -.article-assessment-wrapper .article-assessment-wrapper .article-assessment-rating-fields { |
| 167 | +.article-assessment-wrapper .article-assessment-rating-fields { |
167 | 168 | margin: 8px 0; |
168 | 169 | } |
169 | 170 | .article-assessment-wrapper .article-assessment-rating-fields .field-wrapper { |
— | — | @@ -175,6 +176,7 @@ |
176 | 177 | } |
177 | 178 | .article-assessment-submit input { |
178 | 179 | margin: 2px 0; |
| 180 | + float: right; |
179 | 181 | } |
180 | 182 | .article-assessment-wrapper .article-assessment-ratings-disabled .article-assessment-rating-field-value-wrapper { |
181 | 183 | background: url( ../images/rating_disabled_bg.gif ) 0 0 no-repeat; |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -class ApiListArticleAssessment extends ApiQueryBase { |
| 3 | +class ApiQueryArticleAssessment extends ApiQueryBase { |
4 | 4 | public function __construct( $query, $moduleName ) { |
5 | 5 | parent::__construct( $query, $moduleName, 'aa' ); |
6 | 6 | } |
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js |
— | — | @@ -17,9 +17,9 @@ |
18 | 18 | ], |
19 | 19 | 'fieldHintSuffix': '-tooltip', |
20 | 20 | 'fieldPrefix': 'articleassessment-rating-', |
21 | | - 'fieldHTML': '<div class="field-wrapper" id="articleassessment-rate-{FIELD}"> \ |
22 | | - <label for="rating_{FIELD}" original-title="{HINT}" class="rating-field-label">{LABEL}</label> \ |
23 | | - <select id="rating_{FIELD}" name="rating[{FIELD}]" class="rating-field"> \ |
| 21 | + 'fieldHTML': '<div class="field-wrapper"> \ |
| 22 | + <label class="rating-field-label"></label> \ |
| 23 | + <select class="rating-field"> \ |
24 | 24 | <option value="1">1</option> \ |
25 | 25 | <option value="2">2</option> \ |
26 | 26 | <option value="3">3</option> \ |
— | — | @@ -30,10 +30,10 @@ |
31 | 31 | 'structureHTML': '<div class="article-assessment-wrapper"> \ |
32 | 32 | <form action="rate" method="post" id="article-assessment"> \ |
33 | 33 | <fieldset id="article-assessment-rate"> \ |
34 | | - <legend>{YOURFEEDBACK}</legend> \ |
| 34 | + <legend></legend> \ |
35 | 35 | <div class="article-assessment-information"> \ |
36 | | - <span class="article-assessment-rate-instructions">{INSTRUCTIONS}</span> \ |
37 | | - <span class="article-assessment-rate-feedback">{FEEDBACK}</span> \ |
| 36 | + <span class="article-assessment-rate-instructions"></span> \ |
| 37 | + <span class="article-assessment-rate-feedback"></span> \ |
38 | 38 | </div> \ |
39 | 39 | <div class="article-assessment-rating-fields"></div> \ |
40 | 40 | <div class="article-assessment-submit"> \ |
— | — | @@ -41,20 +41,20 @@ |
42 | 42 | </div> \ |
43 | 43 | </fieldset> \ |
44 | 44 | <fieldset id="article-assessment-ratings"> \ |
45 | | - <legend>{ARTICLERATING}</legend> \ |
| 45 | + <legend></legend> \ |
46 | 46 | <div class="article-assessment-information"> \ |
47 | | - <span class="article-assessment-show-ratings">{RESULTSSHOW}</span> \ |
48 | | - <span class="article-assessment-hide-ratings">{RESULTSHIDE}</span> \ |
| 47 | + <span class="article-assessment-show-ratings"></span> \ |
| 48 | + <span class="article-assessment-hide-ratings"></span> \ |
49 | 49 | </div> \ |
50 | 50 | </fieldset> \ |
51 | 51 | </form> \ |
52 | 52 | </div>', |
53 | | - 'ratingHTML': '<div class="article-assessment-rating" id="articleassessment-rating-{FIELD}"> \ |
54 | | - <span class="article-assessment-rating-field-name">{LABEL}</span> \ |
| 53 | + 'ratingHTML': '<div class="article-assessment-rating"> \ |
| 54 | + <span class="article-assessment-rating-field-name"></span> \ |
55 | 55 | <span class="article-assessment-rating-field-value-wrapper"> \ |
56 | | - <span class="article-assessment-rating-field-value">{VALUE}</span> \ |
| 56 | + <span class="article-assessment-rating-field-value">0%</span> \ |
57 | 57 | </span> \ |
58 | | - <span class="article-assessment-rating-count">{COUNT}</span> \ |
| 58 | + <span class="article-assessment-rating-count"></span> \ |
59 | 59 | </div>', |
60 | 60 | 'staleMSG': '<span class="article-assessment-stale-msg">{MSG}</span>' |
61 | 61 | }, |
— | — | @@ -84,40 +84,76 @@ |
85 | 85 | config.userID = userToken; |
86 | 86 | } |
87 | 87 | // setup our markup using the template variables in settings |
88 | | - var $output = $( settings.structureHTML |
89 | | - .replace( /\{INSTRUCTIONS\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-pleaserate' ) ) |
90 | | - .replace( /\{FEEDBACK\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-featurefeedback' ) |
91 | | - .replace( /\[\[([^\|\]]*)\|([^\|\]]*)\]\]/, '<a href="' + wgArticlePath + '">$2</a>' ) ) |
92 | | - .replace( /\{YOURFEEDBACK\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-yourfeedback') ) |
93 | | - .replace( /\{ARTICLERATING\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-articlerating' ) ) |
94 | | - .replace( /\{RESULTSHIDE\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-results-hide' ) |
95 | | - .replace( /\[\[\|([^\]]*)\]\]/, '<a href="#">$1</a>' ) ) |
96 | | - .replace( /\{RESULTSSHOW\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-results-show' ) |
97 | | - .replace( /\[\[\|([^\]]*)\]\]/, '<a href="#">$1</a>' ) ) ); |
98 | | - for ( var field in settings.fieldMessages ) { |
99 | | - $output.find( '.article-assessment-rating-fields' ) |
100 | | - .append( $( settings.fieldHTML |
101 | | - .replace( /\{LABEL\}/g, $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[field] ) ) |
102 | | - .replace( /\{FIELD\}/g, settings.fieldMessages[field] ) |
103 | | - .replace( /\{HINT\}/g, $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[field] + settings.fieldHintSuffix ) ) ) ); |
104 | | - $output.find( '#article-assessment-ratings' ) |
105 | | - .append( $( settings.ratingHTML |
106 | | - .replace( /\{LABEL\}/g, $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[field] ) ) |
107 | | - .replace( /\{FIELD\}/g, settings.fieldMessages[field] ) |
108 | | - .replace( /\{VALUE\}/g, '0%' ) |
109 | | - .replace( /\{COUNT\}/g, $.ArticleAssessment.fn.getMsg( 'articleassessment-noratings', [0, 0] ) ) ) |
110 | | - ); |
| 88 | + var $structure = $( settings.structureHTML ), |
| 89 | + instructions = $.ArticleAssessment.fn.getMsg( 'articleassessment-pleaserate' ), |
| 90 | + feedback = $.ArticleAssessment.fn.getMsg( 'articleassessment-featurefeedback' ), |
| 91 | + yourfeedback = $.ArticleAssessment.fn.getMsg( 'articleassessment-yourfeedback'), |
| 92 | + articlerating = $.ArticleAssessment.fn.getMsg( 'articleassessment-articlerating' ), |
| 93 | + resultshide = $.ArticleAssessment.fn.getMsg( 'articleassessment-results-hide' ), |
| 94 | + resultsshow = $.ArticleAssessment.fn.getMsg( 'articleassessment-results-show' ); |
| 95 | + $structure |
| 96 | + .find( '#article-assessment-rate legend' ) |
| 97 | + .text( yourfeedback ) |
| 98 | + .end() |
| 99 | + .find( '.article-assessment-rate-instructions' ) |
| 100 | + .text( instructions ) |
| 101 | + .end() |
| 102 | + .find( '.article-assessment-rate-feedback' ) |
| 103 | + .html( feedback.replace( /\[\[([^\|\]]*)\|([^\|\]]*)\]\]/, '<a href="' + wgArticlePath + '">$2</a>' ) ) |
| 104 | + .end() |
| 105 | + .find( '#article-assessment-ratings legend' ) |
| 106 | + .text( articlerating ) |
| 107 | + .end() |
| 108 | + .find( '.article-assessment-show-ratings' ) |
| 109 | + .html( resultsshow.replace( /\[\[\|([^\]]*)\]\]/, '<a href="#">$1</a>' ) ) |
| 110 | + .end() |
| 111 | + .find( '.article-assessment-hide-ratings') |
| 112 | + .html( resultshide.replace( /\[\[\|([^\]]*)\]\]/, '<a href="#">$1</a>' ) ) |
| 113 | + .end(); |
| 114 | + for ( var i = 0; i < settings.fieldMessages.length; i++ ) { |
| 115 | + var $field = $( settings.fieldHTML ), |
| 116 | + $rating = $( settings.ratingHTML ), |
| 117 | + label = $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[i] ), |
| 118 | + field = settings.fieldMessages[i], |
| 119 | + hint = $.ArticleAssessment.fn.getMsg( settings.fieldPrefix + settings.fieldMessages[i] + settings.fieldHintSuffix ), |
| 120 | + count = $.ArticleAssessment.fn.getMsg( 'articleassessment-noratings', [0, 0] ); |
| 121 | + // initialize the field html |
| 122 | + $field |
| 123 | + .attr( 'id', 'articleassessment-rate-' + field ) |
| 124 | + .find( 'label' ) |
| 125 | + .attr( 'for', 'rating_' + field ) |
| 126 | + .attr( 'original-title', hint ) |
| 127 | + .text( label ) |
| 128 | + .end() |
| 129 | + .find( 'select' ) |
| 130 | + .attr( 'id', 'rating_' + field ) |
| 131 | + .attr( 'name', 'rating[' + field + ']' ); |
| 132 | + // initialize the rating html |
| 133 | + $rating |
| 134 | + .attr( 'id', 'articleassessment-rating-' + field ) |
| 135 | + .find( '.article-assessment-rating-field-name' ) |
| 136 | + .text( label ) |
| 137 | + .end() |
| 138 | + .find( '.article-assessment-rating-count' ) |
| 139 | + .text( count ); |
| 140 | + // append the field and rating html |
| 141 | + $structure |
| 142 | + .find( '.article-assessment-rating-fields' ) |
| 143 | + .append( $field ) |
| 144 | + .end() |
| 145 | + .find( '#article-assessment-ratings' ) |
| 146 | + .append( $rating ); |
111 | 147 | } |
112 | 148 | // store our settings and configuration for later |
113 | | - $output.find( '#article-assessment' ).data( 'articleAssessment-context', { 'settings': settings, 'config': config } ); |
| 149 | + $structure.find( '#article-assessment' ).data( 'articleAssessment-context', { 'settings': settings, 'config': config } ); |
114 | 150 | // bind the ratings show/hide handlers |
115 | | - $output |
| 151 | + $structure |
116 | 152 | .find( '.article-assessment-show-ratings a' ) |
117 | 153 | .click( function() { |
118 | 154 | $( this ) |
119 | 155 | .parent() |
120 | 156 | .hide(); |
121 | | - $output |
| 157 | + $structure |
122 | 158 | .find( '#article-assessment-ratings' ) |
123 | 159 | .removeClass( 'article-assessment-ratings-disabled' ) |
124 | 160 | .end() |
— | — | @@ -131,7 +167,7 @@ |
132 | 168 | $( this ) |
133 | 169 | .parent() |
134 | 170 | .hide(); |
135 | | - $output |
| 171 | + $structure |
136 | 172 | .find( '#article-assessment-ratings' ) |
137 | 173 | .addClass( 'article-assessment-ratings-disabled' ) |
138 | 174 | .end() |
— | — | @@ -140,7 +176,7 @@ |
141 | 177 | return false; |
142 | 178 | } ) |
143 | 179 | .click(); |
144 | | - $( '#catlinks' ).before( $output ); |
| 180 | + $( '#catlinks' ).before( $structure ); |
145 | 181 | |
146 | 182 | // set the height of our smaller fieldset to match the taller |
147 | 183 | if ( $( '#article-assessment-rate' ).height() > $( '#article-assessment-ratings' ).height() ) { |
— | — | @@ -271,8 +307,8 @@ |
272 | 308 | } ); |
273 | 309 | var request = $.ajax( { |
274 | 310 | url: wgScriptPath + '/api.php', |
| 311 | + type: 'POST', |
275 | 312 | data: { |
276 | | - 'type': 'POST', |
277 | 313 | 'action': 'articleassessment', |
278 | 314 | 'revid': config.revID, |
279 | 315 | 'pageid': config.pageID, |