r105075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105074‎ | r105075 | r105076 >
Date:19:10, 3 December 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
fix jQuery usage fail
Modified paths:
  • /trunk/extensions/Reviews/resources/jquery.reviewRating.js (modified) (history)
  • /trunk/extensions/Reviews/resources/jquery.reviewState.js (modified) (history)
  • /trunk/extensions/Reviews/resources/reviews.pager.js (modified) (history)
  • /trunk/extensions/Reviews/resources/reviews.special.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/resources/jquery.reviewRating.js
@@ -10,7 +10,7 @@
1111
1212 var settings = $.extend( {
1313
14 - } );
 14+ }, options );
1515
1616 return this.each( function() {
1717
Index: trunk/extensions/Reviews/resources/jquery.reviewState.js
@@ -6,89 +6,95 @@
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -(function( $, mw ) { $.fn.reviewState = function() {
 10+(function( $, mw ) { $.fn.reviewState = function( options ) {
1111
12 - var _this = this;
13 - var $this = $( _this );
 12+ var settings = $.extend( {
 13+
 14+ }, options );
1415
15 - this.linksForState = null;
 16+ return this.each( function() {
1617
17 - this.updateStateLinks = function( id, state ) {
18 - $this.text( '' );
 18+ var _this = this;
 19+ var $this = $( _this );
1920
20 - $this.attr( {
21 - 'data-review-state': state
22 - } );
 21+ this.linksForState = null;
2322
24 - for ( i in this.linksForState[state] ) {
25 - if ( this.linksForState[state].hasOwnProperty( i ) ) {
26 - var targetState = this.linksForState[state][i];
27 - var isFirst = $this.text() === '';
28 -
29 - if ( isFirst ) {
30 - $this.append( mw.msg( 'reviews-state-' + state ), ' (' );
31 - }
32 - else {
33 - $this.append( ' | ' );
34 - }
35 -
36 - $this.append( $( '<a>' ).attr( {
37 - 'class': 'review-flag-link',
38 - 'data-target': targetState
39 - } ).text( mw.msg( 'reviews-pager-change-' + targetState ) ).click( this.onLinkClick ) );
40 - }
41 - }
42 -
43 - if ( this.linksForState[state].length > 0 ) {
44 - $this.append( ')' );
45 - }
46 - };
47 -
48 - this.onLinkClick = function() {
49 - var state = $this.attr( 'data-review-state' );
50 - var id = $this.attr( 'data-review-id' );
51 - var targetState = $( this ).attr( 'data-target' );
52 -
53 - if ( confirm( mw.msg( 'reviews-pager-confirm-' + targetState ) ) ) {
54 - var requestArgs = {
55 - 'action': 'flagreviews',
56 - 'format': 'json',
57 - 'token': mw.user.tokens.get( 'editToken' ),
58 - 'state': targetState,
59 - 'ids': id
60 - };
 23+ this.updateStateLinks = function( id, state ) {
 24+ $this.text( '' );
6125
62 - $this.text( mw.msg( 'reviews-pager-updating' ) );
 26+ $this.attr( {
 27+ 'data-review-state': state
 28+ } );
6329
64 - $.post(
65 - wgScriptPath + '/api.php',
66 - requestArgs,
67 - function( data ) {
68 - if ( data.hasOwnProperty( 'success' ) && data.success ) {
69 - _this.updateStateLinks( id, targetState );
 30+ for ( i in this.linksForState[state] ) {
 31+ if ( this.linksForState[state].hasOwnProperty( i ) ) {
 32+ var targetState = this.linksForState[state][i];
 33+ var isFirst = $this.text() === '';
 34+
 35+ if ( isFirst ) {
 36+ $this.append( mw.msg( 'reviews-state-' + state ), ' (' );
7037 }
7138 else {
72 - // TODO
73 - alert( 'Could not change the state of the review' );
74 -
75 - _this.updateStateLinks( id, state );
 39+ $this.append( ' | ' );
7640 }
 41+
 42+ $this.append( $( '<a>' ).attr( {
 43+ 'class': 'review-flag-link',
 44+ 'data-target': targetState
 45+ } ).text( mw.msg( 'reviews-pager-change-' + targetState ) ).click( this.onLinkClick ) );
7746 }
 47+ }
 48+
 49+ if ( this.linksForState[state].length > 0 ) {
 50+ $this.append( ')' );
 51+ }
 52+ };
 53+
 54+ this.onLinkClick = function() {
 55+ var state = $this.attr( 'data-review-state' );
 56+ var id = $this.attr( 'data-review-id' );
 57+ var targetState = $( this ).attr( 'data-target' );
 58+
 59+ if ( confirm( mw.msg( 'reviews-pager-confirm-' + targetState ) ) ) {
 60+ var requestArgs = {
 61+ 'action': 'flagreviews',
 62+ 'format': 'json',
 63+ 'token': mw.user.tokens.get( 'editToken' ),
 64+ 'state': targetState,
 65+ 'ids': id
 66+ };
 67+
 68+ $this.text( mw.msg( 'reviews-pager-updating' ) );
 69+
 70+ $.post(
 71+ wgScriptPath + '/api.php',
 72+ requestArgs,
 73+ function( data ) {
 74+ if ( data.hasOwnProperty( 'success' ) && data.success ) {
 75+ _this.updateStateLinks( id, targetState );
 76+ }
 77+ else {
 78+ // TODO
 79+ alert( 'Could not change the state of the review' );
 80+
 81+ _this.updateStateLinks( id, state );
 82+ }
 83+ }
 84+ );
 85+ }
 86+ };
 87+
 88+ this.setup = function() {
 89+ this.linksForState = $.parseJSON( $this.attr( 'data-review-states' ) );
 90+
 91+ this.updateStateLinks(
 92+ $this.attr( 'data-review-id' ),
 93+ $this.attr( 'data-review-state' )
7894 );
79 - }
80 - };
81 -
82 - this.setup = function() {
83 - this.linksForState = $.parseJSON( $this.attr( 'data-review-states' ) );
 95+ };
8496
85 - this.updateStateLinks(
86 - $this.attr( 'data-review-id' ),
87 - $this.attr( 'data-review-state' )
88 - );
89 - };
90 -
91 - this.setup();
 97+ this.setup();
9298
93 - return this;
 99+ });
94100
95101 }; })( window.jQuery, window.mediaWiki );
Index: trunk/extensions/Reviews/resources/reviews.pager.js
@@ -10,10 +10,7 @@
1111
1212 $( document ).ready( function() {
1313
14 - $.each( $( '.reviews-state-controls' ), function( i, e ) {
15 - $( e ).reviewState();
16 - } );
17 -
 14+ $( '.reviews-state-controls' ).reviewState();
1815 $( '.review-rating-display' ).reviewRating();
1916
2017 } );
Index: trunk/extensions/Reviews/resources/reviews.special.js
@@ -10,9 +10,7 @@
1111
1212 $( document ).ready( function() {
1313
14 - $.each( $( '.reviews-state-controls' ), function( i, e ) {
15 - $( e ).reviewState();
16 - } );
 14+ $( '.reviews-state-controls' ).reviewState();
1715
1816 $( '.reviews-delete-button' ).button().click( function() {
1917 if ( confirm( mw.msg( 'reviews-reviews-delete-confirm' ) ) ) {

Status & tagging log