r104176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104175‎ | r104176 | r104177 >
Date:16:07, 24 November 2011
Author:jeroendedauw
Status:reverted (Comments)
Tags:
Comment:
work on reviews control
Modified paths:
  • /trunk/extensions/Reviews/Reviews.i18n.php (modified) (history)
  • /trunk/extensions/Reviews/Reviews.php (modified) (history)
  • /trunk/extensions/Reviews/resources/jquery.reviewControl.css (modified) (history)
  • /trunk/extensions/Reviews/resources/jquery.reviewControl.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/Reviews.i18n.php
@@ -57,6 +57,10 @@
5858 // Review control
5959 'reviews-submission-submit' => 'Submit',
6060 'reviews-submission-saving' => 'Saving',
 61+ 'reviews-submission-title' => 'A title for your review:',
 62+ 'reviews-submission-text' => 'The review text:',
 63+ 'reviews-submission-rating' => 'Overall rating:',
 64+ 'reviews-submission-ratings' => 'Specific ratings:',
6165
6266 // Special:MyReviews
6367 'reviews-myreviews-header' => 'This page lists all reviews you posted.',
Index: trunk/extensions/Reviews/Reviews.php
@@ -130,6 +130,10 @@
131131 'messages' => array(
132132 'reviews-submission-submit',
133133 'reviews-submission-saving',
 134+ 'reviews-submission-title',
 135+ 'reviews-submission-text',
 136+ 'reviews-submission-rating',
 137+ 'reviews-submission-ratings',
134138 ),
135139 'dependencies' => array(
136140 'ext.reviews', 'jquery.ui.button', 'jquery.ui.stars',
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.css
@@ -4,4 +4,26 @@
55 *
66 * @licence GNU GPL v3 or later
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
8 - */
\ No newline at end of file
 8+ */
 9+
 10+.review-control {
 11+ /* border: 1px solid gray; */
 12+}
 13+
 14+.review-textinput {
 15+ width: 80%;
 16+}
 17+
 18+/* .review-ratings-div */
 19+#review-1-ratingdiv > * {
 20+ float: left;
 21+ line-height: 1.4em;
 22+}
 23+
 24+.review-rating-label {
 25+ padding-right: 0.5em;
 26+}
 27+
 28+.review-ratings-table-div {
 29+ clear: both;
 30+}
\ No newline at end of file
Index: trunk/extensions/Reviews/resources/jquery.reviewControl.js
@@ -22,52 +22,94 @@
2323 return 'review-' + ( typeof this.review.fields.id === 'undefined' ? 'new' : this.review.fields.id ) + '-' + name;
2424 };
2525
 26+ this.buildRatingsControl = function() {
 27+ var ratings = this.review.fields.ratings;
 28+ var $tr = $( '<tr />' ).html( '' );
 29+
 30+ for ( rating in ratings ) {
 31+ if ( ratings.hasOwnProperty( rating ) ) {
 32+ $tr.append( $( '<td />' ).append(
 33+ $( '<div class="review-ratings-div" />' )
 34+ .attr( 'id', this.fieldName( 'ratingdiv' + rating ) )
 35+ .attr( 'data-type', rating )
 36+ .html( reviews.htmlSelect(
 37+ { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5 }, // TODO
 38+ ratings[rating],
 39+ {
 40+ 'name': this.fieldName( 'rating' + rating ),
 41+ 'id': this.fieldName( 'rating' + rating ),
 42+ 'class': 'review-specificratinginput'
 43+ }
 44+ ) ).prepend( $( '<label />' ).attr( {
 45+ 'for': this.fieldName( 'ratingdiv' + rating ),
 46+ 'class': 'review-ratings-label'
 47+ } ).text( rating ) )
 48+ )
 49+ );
 50+ }
 51+ }
 52+
 53+ this.ratingsInput = $( '<div />' ).attr( { 'class': 'review-ratings-table-div' } ).html( $( '<table />' ).html( $tr ) );
 54+ };
 55+
2656 this.buildInterface = function() {
2757 this.titleInput = $( '<input />' ).attr( {
2858 'type': 'text',
2959 'size': 45,
30 - 'name': this.fieldName( 'title' )
 60+ 'name': this.fieldName( 'title' ),
 61+ 'class': 'review-titleinput'
3162 } ).val( this.review.fields.title );
3263
3364 this.textInput = $( '<textarea />' ).attr( {
34 - 'name': this.fieldName( 'text' )
 65+ 'name': this.fieldName( 'text' ),
 66+ 'class': 'review-textinput'
3567 } ).text( this.review.fields.text );
3668
3769 this.ratingInput = reviews.htmlSelect(
3870 { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5 }, // TODO
3971 this.review.fields.rating,
40 - { 'name': this.fieldName( 'rating' ), 'id': this.fieldName( 'rating' ) }
 72+ {
 73+ 'name': this.fieldName( 'rating' ),
 74+ 'id': this.fieldName( 'rating' ),
 75+ 'class': 'review-ratinginput'
 76+ }
4177 );
4278
43 - this.ratingInput = $( '<div />' ).attr( 'id', this.fieldName( 'ratingdiv' ) ).html( this.ratingInput );
44 -
45 - this.ratingsInput = $( '<div />' ).html( '' );
 79+ this.ratingInput = $( '<div />' ).attr( {
 80+ 'id': this.fieldName( 'ratingdiv' ),
 81+ 'class': 'review-ratingdiv'
 82+ } ).html( this.ratingInput );
4683
47 - var ratings = this.review.fields.ratings;
48 - for ( rating in ratings ) {
49 - if ( ratings.hasOwnProperty( rating ) ) {
50 - this.ratingsInput.append(
51 - $( '<div class="review-ratings-div" />' )
52 - .attr( 'id', this.fieldName( 'ratingdiv' + rating ) )
53 - .attr( 'data-type', rating )
54 - .html( reviews.htmlSelect(
55 - { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5 }, // TODO
56 - ratings[rating],
57 - { 'name': this.fieldName( 'rating' + rating ), 'id': this.fieldName( 'rating' + rating ) }
58 - ) )
59 - );
60 - }
61 - }
 84+ this.buildRatingsControl();
6285
63 - this.button = $( '<button />' )
 86+ this.button = $( '<button class="review-save" />' )
6487 .button( { 'label': mw.msg( 'reviews-submission-submit' ) } )
6588 .click( function() {
6689 _this.save();
6790 } );
6891
6992 $this.html( '' );
70 - $this.append( this.titleInput, this.textInput, this.ratingInput, this.ratingsInput, this.button );
7193
 94+ $this.append(
 95+ $( '<label />' ).attr( { 'for': this.fieldName( 'title' ) } ).text( mw.msg( 'reviews-submission-title' ) + ' ' ),
 96+ this.titleInput
 97+ ).append( '<br />' );
 98+
 99+ $this.append(
 100+ $( '<label />' ).attr( { 'for': this.fieldName( 'text' ) } ).text( mw.msg( 'reviews-submission-text' ) ).append( '<br />' ),
 101+ this.textInput
 102+ ).append( '<br />' );
 103+
 104+ $this.append(
 105+ this.ratingInput.prepend( $( '<label />' ).attr( {
 106+ 'for': this.fieldName( 'rating' ),
 107+ 'class': 'review-rating-label'
 108+ } ).text( mw.msg( 'reviews-submission-rating' ) ) )
 109+ );
 110+
 111+ $this.append( this.ratingsInput );
 112+ $this.append( this.button );
 113+
72114 this.ratingInput.stars( {
73115 inputType: 'select',
74116 cancelShow: false,

Follow-up revisions

RevisionCommit summaryAuthorDate
r104187Follow up to r104176;jeroendedauw18:43, 24 November 2011
r104199qqq docs, follow up to r104189 r104188 r104176jeroendedauw21:56, 24 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   17:50, 24 November 2011

If I have understood this correctly things like $( '<div class="foo" />' ) will not work in IE. For elements there is shorter way to write them: $( '<div>' );

See User:Krinkle/Extension_review/WebFonts#HTML_fragments

#Comment by Jeroen De Dauw (talk | contribs)   18:43, 24 November 2011

Cool, fixed in follow up :)

#Comment by Siebrand (talk | contribs)   20:21, 24 November 2011

Please add message documentation for the newly added messages. Thanks.

Status & tagging log