Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js |
— | — | @@ -5,7 +5,8 @@ |
6 | 6 | tagName: "div", |
7 | 7 | template: _.template( $( "#listControlNavTemplate" ).html() ), |
8 | 8 | filterMenuVisible: 0, |
9 | | - filterStatus: 'All', |
| 9 | + filterStatus: gM( 'pagetriage-filter-stat-all'), |
| 10 | + newFilterStatus: [], |
10 | 11 | |
11 | 12 | initialize: function( options ) { |
12 | 13 | var _this = this; |
— | — | @@ -43,6 +44,10 @@ |
44 | 45 | |
45 | 46 | render: function() { |
46 | 47 | var _this = this; |
| 48 | + |
| 49 | + if(! this.filterStatus ) { |
| 50 | + this.filterStatus = gM( 'pagetriage-filter-stat-all'); |
| 51 | + } |
47 | 52 | // render and return the template. fill with the current model. |
48 | 53 | $( "#mwe-pt-list-control-nav-content").html( this.template( { filterStatus: this.filterStatus } ) ); |
49 | 54 | |
— | — | @@ -60,24 +65,15 @@ |
61 | 66 | icons: { secondary:'ui-icon-triangle-1-e' } |
62 | 67 | } ); |
63 | 68 | $( ".mwe-pt-filter-set-button" ).click( function( e ) { |
| 69 | + console.log('set button clicked'); |
64 | 70 | _this.filterSync(); |
65 | 71 | _this.toggleFilterMenu(); |
66 | 72 | e.stopPropagation(); |
67 | 73 | } ); |
68 | 74 | |
69 | 75 | // the filter dropdown menu control |
| 76 | + console.log('click event set on body and menu'); |
70 | 77 | $( '#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 | | - |
82 | 78 | _this.toggleFilterMenu(); |
83 | 79 | e.stopPropagation(); |
84 | 80 | } ); |
— | — | @@ -91,15 +87,32 @@ |
92 | 88 | $( '#mwe-pt-list-control-nav' ).css( 'width', $(window).width() - 176 - 16 - 2 + "px" ); |
93 | 89 | }, |
94 | 90 | |
95 | | - toggleFilterMenu: function() { |
96 | | - if( this.filterMenuVisible ) { |
| 91 | + toggleFilterMenu: function( action ) { |
| 92 | + var _this = this; |
| 93 | + if( (action && action == 'close') || this.filterMenuVisible ) { |
97 | 94 | $( '#mwe-pt-dropdown-arrow' ).html( '▸' ); |
98 | 95 | $( '#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' ); |
99 | 98 | this.filterMenuVisible = 0; |
100 | | - } else { |
| 99 | + } else if( (action && action == 'open') || !this.filterMenuVisible ) { |
101 | 100 | this.menuSync(); |
102 | 101 | $( '#mwe-pt-control-dropdown' ).css( 'visibility', 'visible' ); |
103 | 102 | $( '#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 | + |
104 | 117 | this.filterMenuVisible = 1; |
105 | 118 | } |
106 | 119 | }, |
— | — | @@ -170,34 +183,47 @@ |
171 | 184 | |
172 | 185 | // sync the menu with the contents of the filters |
173 | 186 | menuSync: function() { |
174 | | - var newFilterStatus = []; |
| 187 | + this.newFilterStatus = []; |
175 | 188 | |
176 | 189 | $( '#mwe-pt-filter-namespace' ).val( this.model.getParam( 'namespace' ) ); |
177 | 190 | |
178 | 191 | // update the status display |
179 | 192 | 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 ) ); |
181 | 201 | } |
182 | 202 | |
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 | + |
191 | 209 | /* api doesn't support these |
192 | 210 | $( '#mwe-pt-filter-user' ).val( this.model.getParam('') ); |
193 | 211 | $( '#mwe-pt-filter-tag' ).val( this.model.getParam('') ); |
194 | 212 | */ |
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 | + } |
202 | 228 | } |
203 | 229 | |
204 | 230 | } ); |
Index: trunk/extensions/PageTriage/PageTriage.i18n.php |
— | — | @@ -56,7 +56,16 @@ |
57 | 57 | 'pagetriage-filter-ns-article' => 'Article', |
58 | 58 | 'pagetriage-filter-ns-all' => 'All', |
59 | 59 | 'pagetriage-more' => 'More', |
| 60 | + 'pagetriage-filter-stat-all' => 'All', |
60 | 61 | '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 | + |
61 | 70 | ); |
62 | 71 | |
63 | 72 | /** |
— | — | @@ -105,5 +114,16 @@ |
106 | 115 | 'pagetriage-filter-ns-article' => 'The name of the main article namespace, for the namespace filter select list', |
107 | 116 | 'pagetriage-filter-ns-all' => 'For the namespace filter select list, text indicating that all namespaces will be selected', |
108 | 117 | '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 | + |
110 | 130 | ); |
Index: trunk/extensions/PageTriage/PageTriage.php |
— | — | @@ -249,6 +249,14 @@ |
250 | 250 | 'pagetriage-filter-ns-all', |
251 | 251 | 'pagetriage-more', |
252 | 252 | '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', |
253 | 261 | ) |
254 | 262 | ); |
255 | 263 | |