r114723 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114722‎ | r114723 | r114724 >
Date:23:45, 4 April 2012
Author:raindrift
Status:deferred
Tags:
Comment:
made the filter status display work
fixed a bug where the menu wouldn't always put itself away properly
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.i18n.php (modified) (history)
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
@@ -5,7 +5,8 @@
66 tagName: "div",
77 template: _.template( $( "#listControlNavTemplate" ).html() ),
88 filterMenuVisible: 0,
9 - filterStatus: 'All',
 9+ filterStatus: gM( 'pagetriage-filter-stat-all'),
 10+ newFilterStatus: [],
1011
1112 initialize: function( options ) {
1213 var _this = this;
@@ -43,6 +44,10 @@
4445
4546 render: function() {
4647 var _this = this;
 48+
 49+ if(! this.filterStatus ) {
 50+ this.filterStatus = gM( 'pagetriage-filter-stat-all');
 51+ }
4752 // render and return the template. fill with the current model.
4853 $( "#mwe-pt-list-control-nav-content").html( this.template( { filterStatus: this.filterStatus } ) );
4954
@@ -60,24 +65,15 @@
6166 icons: { secondary:'ui-icon-triangle-1-e' }
6267 } );
6368 $( ".mwe-pt-filter-set-button" ).click( function( e ) {
 69+ console.log('set button clicked');
6470 _this.filterSync();
6571 _this.toggleFilterMenu();
6672 e.stopPropagation();
6773 } );
6874
6975 // the filter dropdown menu control
 76+ console.log('click event set on body and menu');
7077 $( '#mwe-pt-filter-dropdown-control' ).click( function( e ) {
71 - // close the meny when the user clicks away
72 - $( 'body' ).one( 'click', function() {
73 - _this.toggleFilterMenu();
74 - } );
75 -
76 - // this event "covers up" the body event, which keeps the menu from closing when
77 - // the user clicks inside.
78 - $( '#mwe-pt-control-dropdown' ).click( function( e ) {
79 - e.stopPropagation();
80 - } );
81 -
8278 _this.toggleFilterMenu();
8379 e.stopPropagation();
8480 } );
@@ -91,15 +87,32 @@
9288 $( '#mwe-pt-list-control-nav' ).css( 'width', $(window).width() - 176 - 16 - 2 + "px" );
9389 },
9490
95 - toggleFilterMenu: function() {
96 - if( this.filterMenuVisible ) {
 91+ toggleFilterMenu: function( action ) {
 92+ var _this = this;
 93+ if( (action && action == 'close') || this.filterMenuVisible ) {
9794 $( '#mwe-pt-dropdown-arrow' ).html( '▸' );
9895 $( '#mwe-pt-control-dropdown' ).css( 'visibility', 'hidden' );
 96+ $( 'body' ).unbind( 'click' ); // remove these events since they're not needed til next time.
 97+ $( '#mwe-pt-control-dropdown' ).unbind( 'click' );
9998 this.filterMenuVisible = 0;
100 - } else {
 99+ } else if( (action && action == 'open') || !this.filterMenuVisible ) {
101100 this.menuSync();
102101 $( '#mwe-pt-control-dropdown' ).css( 'visibility', 'visible' );
103102 $( '#mwe-pt-dropdown-arrow' ).html( '▾' );
 103+
 104+ // close the menu when the user clicks away
 105+ $( 'body' ).click( 'click', function() {
 106+ console.log('body clicked');
 107+ _this.toggleFilterMenu( 'close' );
 108+ } );
 109+
 110+ // this event "covers up" the body event, which keeps the menu from closing when
 111+ // the user clicks inside.
 112+ $( '#mwe-pt-control-dropdown' ).click( function( e ) {
 113+ console.log('menu clicked');
 114+ e.stopPropagation();
 115+ } );
 116+
104117 this.filterMenuVisible = 1;
105118 }
106119 },
@@ -170,34 +183,47 @@
171184
172185 // sync the menu with the contents of the filters
173186 menuSync: function() {
174 - var newFilterStatus = [];
 187+ this.newFilterStatus = [];
175188
176189 $( '#mwe-pt-filter-namespace' ).val( this.model.getParam( 'namespace' ) );
177190
178191 // update the status display
179192 if( this.model.getParam( 'namespace' ) > -1 ) { // still true for ns 0
180 - newFilterStatus.push( gM( 'pagetriage-filter-stat-namespace', this.model.getParam( 'namespace' ) ) );
 193+ var ns = this.model.getParam( 'namespace' );
 194+ var nsText;
 195+ if( ns == 0 ) {
 196+ nsText = gM( 'pagetriage-filter-ns-article' );
 197+ } else {
 198+ nsText = mw.config.get( 'wgFormattedNamespaces' )[ns];
 199+ }
 200+ this.newFilterStatus.push( gM( 'pagetriage-filter-stat-namespace', nsText ) );
181201 }
182202
183 - // TODO: update the status for everything else.
184 -
185 - $( '#mwe-pt-filter-triaged-edits' ).prop( 'checked', this.model.getParam( 'showtriaged' )=="1"?true:false );
186 - // api doesn't support this?
187 - //$( '#mwe-pt-filter-nominated-for-deletion' ).prop( 'checked', this.model.getParam('')=="1"?true:false );
188 - $( '#mwe-pt-filter-bot-edits' ).prop( 'checked', this.model.getParam( 'showbots' )=="1"?true:false );
189 - $( '#mwe-pt-filter-redirects' ).prop( 'checked', this.model.getParam( 'showredirs' )=="1"?true:false );
190 -
 203+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-triaged-edits' ), 'showtriaged', 'pagetriage-filter-stat-triaged');
 204+ // api doesn't suppor this one.
 205+ //this.menuCheckboxUpdate( $( '#mwe-pt-filter-nominated-for-deletion' ' ), '', '');
 206+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-bot-edits' ), 'showbots', 'pagetriage-filter-stat-bots');
 207+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-redirects' ), 'showredirs', 'pagetriage-filter-stat-redirects');
 208+
191209 /* api doesn't support these
192210 $( '#mwe-pt-filter-user' ).val( this.model.getParam('') );
193211 $( '#mwe-pt-filter-tag' ).val( this.model.getParam('') );
194212 */
195 -
196 - $( '#mwe-pt-filter-no-categories' ).prop( 'checked', this.model.getParam( 'no_category' )=="1"?true:false );
197 - $( '#mwe-pt-filter-orphan' ).prop( 'checked', this.model.getParam( 'no_inbound_links' )=="1"?true:false );
198 - $( '#mwe-pt-filter-non-autoconfirmed' ).prop( 'checked', this.model.getParam( 'non_autoconfirmed_users' )=="1"?true:false );
199 - $( '#mwe-pt-filter-blocked' ).prop( 'checked', this.model.getParam( 'blocked_users' )=="1"?true:false );
200 -
201 - this.filterStatus = newFilterStatus.join('.');
 213+
 214+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-no-categories' ), 'no_category', 'pagetriage-filter-stat-no-categories');
 215+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-orphan' ), 'no_inbound_links', 'pagetriage-filter-stat-orphan');
 216+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-non-autoconfirmed' ), 'non_autoconfirmed_users', 'pagetriage-filter-stat-non-autoconfirmed');
 217+ this.menuCheckboxUpdate( $( '#mwe-pt-filter-blocked' ), 'blocked_users', 'pagetriage-filter-stat-blocked');
 218+
 219+ this.filterStatus = this.newFilterStatus.join(' · ');
 220+ },
 221+
 222+ menuCheckboxUpdate: function( $checkbox, param, message ) {
 223+ // update a checkbox in the menu with data from the model.
 224+ $checkbox.prop( 'checked', this.model.getParam( param )=="1"?true:false );
 225+ if( this.model.getParam( param ) ) {
 226+ this.newFilterStatus.push( gM( message ) );
 227+ }
202228 }
203229
204230 } );
Index: trunk/extensions/PageTriage/PageTriage.i18n.php
@@ -56,7 +56,16 @@
5757 'pagetriage-filter-ns-article' => 'Article',
5858 'pagetriage-filter-ns-all' => 'All',
5959 'pagetriage-more' => 'More',
 60+ 'pagetriage-filter-stat-all' => 'All',
6061 'pagetriage-filter-stat-namespace' => 'Namespace: $1',
 62+ 'pagetriage-filter-stat-triaged' => 'Triaged',
 63+ 'pagetriage-filter-stat-bots' => 'Bots',
 64+ 'pagetriage-filter-stat-redirects' => 'Redirects',
 65+ 'pagetriage-filter-stat-no-categories' => 'No categories',
 66+ 'pagetriage-filter-stat-orphan' => 'Orphans',
 67+ 'pagetriage-filter-stat-non-autoconfirmed' => 'New editors',
 68+ 'pagetriage-filter-stat-blocked' => 'Blocked users',
 69+
6170 );
6271
6372 /**
@@ -105,5 +114,16 @@
106115 'pagetriage-filter-ns-article' => 'The name of the main article namespace, for the namespace filter select list',
107116 'pagetriage-filter-ns-all' => 'For the namespace filter select list, text indicating that all namespaces will be selected',
108117 'pagetriage-more' => 'Text for a link that loads more articles into list',
109 - 'pagetriage-filter-stat-namespace' => 'Status display for the namespace filter. $1 is the name of the namespace.',
 118+ 'pagetriage-filter-stat-all' => 'Status display component for all pages (no filter)',
 119+ 'pagetriage-filter-stat-namespace' => 'Status display component for the namespace filter. $1 is the name of the namespace.',
 120+ 'pagetriage-filter-stat-triaged' => 'Status display component for triaged pages',
 121+ 'pagetriage-filter-stat-bots' => 'Status display component for bot-created pages',
 122+ 'pagetriage-filter-stat-redirects' => 'Status display component for redirects',
 123+ 'pagetriage-filter-stat-no-categories' => 'Status display component for articles with no categories',
 124+ 'pagetriage-filter-stat-orphan' => 'Status display component for orphan articles',
 125+ 'pagetriage-filter-stat-non-autoconfirmed' => 'Status display component for articles by non-autoconfirmed editors',
 126+ 'pagetriage-filter-stat-blocked' => 'Status display component for articles by blocked users',
 127+
 128+
 129+
110130 );
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -249,6 +249,14 @@
250250 'pagetriage-filter-ns-all',
251251 'pagetriage-more',
252252 'pagetriage-filter-stat-namespace',
 253+ 'pagetriage-filter-stat-triaged',
 254+ 'pagetriage-filter-stat-bots',
 255+ 'pagetriage-filter-stat-redirects',
 256+ 'pagetriage-filter-stat-all',
 257+ 'pagetriage-filter-stat-no-categories',
 258+ 'pagetriage-filter-stat-orphan',
 259+ 'pagetriage-filter-stat-non-autoconfirmed',
 260+ 'pagetriage-filter-stat-blocked',
253261 )
254262 );
255263

Status & tagging log