r72608 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72607‎ | r72608 | r72609 >
Date:20:31, 8 September 2010
Author:adam
Status:ok
Tags:
Comment:
Fixing sql errors, and a class name error. Improving CSS to gain better cross-browser consistency. Implimenting some of Roans comments on the javascript
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/css/ArticleAssessment.css (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.sql
@@ -1,12 +1,12 @@
22 -- Store mapping of i18n key of "rating" to an ID
33 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/article_assessment_ratings (
4 - --Rating Id
 4+ -- Rating Id
55 aar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
6 - --Text (i18n key) for rating description
 6+ -- Text (i18n key) for rating description
77 aar_rating varchar(255) binary NOT NULL
88 ) /*$wgDBTableOptions*/;
99
 10+-- Default article assessment ratings for the pilot
1011 INSERT INTO /*$wgDBprefix*/article_assessment_ratings (aar_rating) VALUES
1112 ('articleassessment-rating-wellsourced'), ('articleassessment-rating-neutrality'),
1213 ('articleassessment-rating-completeness'), ('articleassessment-rating-readability');
Index: trunk/extensions/ArticleAssessmentPilot/css/ArticleAssessment.css
@@ -22,6 +22,7 @@
2323 .article-assessment-wrapper .ui-stars-star a {
2424 width: 21px;
2525 height: 21px;
 26+ line-height: 0;
2627 display: block;
2728 background: url(../images/stars.gif) no-repeat 0 0;
2829 }
@@ -87,6 +88,7 @@
8889 }
8990 .article-assessment-wrapper .rating-field {
9091 float: right;
 92+ width: 125px;
9193 line-height: 24px;
9294 padding-right: 5px;
9395 }
@@ -105,15 +107,14 @@
106108 float: right;
107109 background: url(../images/question.gif) 0 50% no-repeat;
108110 }
109 -.article-assessment-wrapper .article-assessment-submit {
110 - text-align: right;
111 -}
 111+
112112 .article-assessment-wrapper .article-assessment-flash {
113113 float: left;
114114 font-size: 11px;
115115 padding: 1px 5px;
116116 width: 560px;
117117 text-align: left;
 118+ display: block;
118119 }
119120 .article-assessment-wrapper .article-assessment-stale-msg {
120121 background: #d6f3ff;
@@ -162,7 +163,7 @@
163164 float: right;
164165 display: block;
165166 }
166 -.article-assessment-wrapper .article-assessment-wrapper .article-assessment-rating-fields {
 167+.article-assessment-wrapper .article-assessment-rating-fields {
167168 margin: 8px 0;
168169 }
169170 .article-assessment-wrapper .article-assessment-rating-fields .field-wrapper {
@@ -175,6 +176,7 @@
176177 }
177178 .article-assessment-submit input {
178179 margin: 2px 0;
 180+ float: right;
179181 }
180182 .article-assessment-wrapper .article-assessment-ratings-disabled .article-assessment-rating-field-value-wrapper {
181183 background: url( ../images/rating_disabled_bg.gif ) 0 0 no-repeat;
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php
@@ -1,5 +1,5 @@
22 <?php
3 -class ApiListArticleAssessment extends ApiQueryBase {
 3+class ApiQueryArticleAssessment extends ApiQueryBase {
44 public function __construct( $query, $moduleName ) {
55 parent::__construct( $query, $moduleName, 'aa' );
66 }
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js
@@ -17,9 +17,9 @@
1818 ],
1919 'fieldHintSuffix': '-tooltip',
2020 '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"> \
2424 <option value="1">1</option> \
2525 <option value="2">2</option> \
2626 <option value="3">3</option> \
@@ -30,10 +30,10 @@
3131 'structureHTML': '<div class="article-assessment-wrapper"> \
3232 <form action="rate" method="post" id="article-assessment"> \
3333 <fieldset id="article-assessment-rate"> \
34 - <legend>{YOURFEEDBACK}</legend> \
 34+ <legend></legend> \
3535 <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> \
3838 </div> \
3939 <div class="article-assessment-rating-fields"></div> \
4040 <div class="article-assessment-submit"> \
@@ -41,20 +41,20 @@
4242 </div> \
4343 </fieldset> \
4444 <fieldset id="article-assessment-ratings"> \
45 - <legend>{ARTICLERATING}</legend> \
 45+ <legend></legend> \
4646 <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> \
4949 </div> \
5050 </fieldset> \
5151 </form> \
5252 </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> \
5555 <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> \
5757 </span> \
58 - <span class="article-assessment-rating-count">{COUNT}</span> \
 58+ <span class="article-assessment-rating-count"></span> \
5959 </div>',
6060 'staleMSG': '<span class="article-assessment-stale-msg">{MSG}</span>'
6161 },
@@ -84,40 +84,76 @@
8585 config.userID = userToken;
8686 }
8787 // 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 );
111147 }
112148 // 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 } );
114150 // bind the ratings show/hide handlers
115 - $output
 151+ $structure
116152 .find( '.article-assessment-show-ratings a' )
117153 .click( function() {
118154 $( this )
119155 .parent()
120156 .hide();
121 - $output
 157+ $structure
122158 .find( '#article-assessment-ratings' )
123159 .removeClass( 'article-assessment-ratings-disabled' )
124160 .end()
@@ -131,7 +167,7 @@
132168 $( this )
133169 .parent()
134170 .hide();
135 - $output
 171+ $structure
136172 .find( '#article-assessment-ratings' )
137173 .addClass( 'article-assessment-ratings-disabled' )
138174 .end()
@@ -140,7 +176,7 @@
141177 return false;
142178 } )
143179 .click();
144 - $( '#catlinks' ).before( $output );
 180+ $( '#catlinks' ).before( $structure );
145181
146182 // set the height of our smaller fieldset to match the taller
147183 if ( $( '#article-assessment-rate' ).height() > $( '#article-assessment-ratings' ).height() ) {
@@ -271,8 +307,8 @@
272308 } );
273309 var request = $.ajax( {
274310 url: wgScriptPath + '/api.php',
 311+ type: 'POST',
275312 data: {
276 - 'type': 'POST',
277313 'action': 'articleassessment',
278314 'revid': config.revID,
279315 'pageid': config.pageID,

Follow-up revisions

RevisionCommit summaryAuthorDate
r72895Follow up r72608....platonides11:12, 13 September 2010

Status & tagging log