Changeset 2618
- Timestamp:
- 02/25/2016 09:17:16 PM (9 years ago)
- Location:
- sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/js/rosetta-roles.js
r2548 r2618 22 22 23 23 initialize: function() { 24 _.bindAll( this, 'uncheck' ); 25 24 26 // Store the original sub-projects data, it's used to reset the collection on searches. 25 27 this._subProjects = this.get( 'sub_projects' ); … … 29 31 project: this, 30 32 } ) ); 31 this.set( 'checked', _.contains( projects.settings.accessList, parseInt( this.get( 'id' ), 10 ) ) ); 33 34 var isChecked = projects.selection.get( this.get( 'id' ) ); 35 if ( isChecked ) { 36 this.set( 'checked', true ); 37 } 32 38 33 39 this.listenTo( this.get( 'subProjects' ), 'change:checked', this.updateChecked ); 34 40 41 $window.on( 'uncheck-other-projects.rosetta', this.uncheck ); 42 43 this.on( 'change:checked', this.updateSelection ); 44 35 45 this.checkForCheckedSubProjects(); 46 }, 47 48 uncheck: function() { 49 this.set( 'checked', false ); 36 50 }, 37 51 … … 42 56 43 57 this.checkForCheckedSubProjects(); 58 }, 59 60 updateSelection: function( model, checked ) { 61 if ( checked ) { 62 projects.selection.add( { id: this.get( 'id' ) } ); 63 $window.trigger( 'uncheck-all-projects.rosetta' ); 64 } else { 65 projects.selection.remove( { id: this.get( 'id' ) } ); 66 } 44 67 }, 45 68 … … 59 82 initialize: function() { 60 83 _.bindAll( this, 'disableActiveStates' ); 84 61 85 this.on( 'change:isActive', this.toggleActiveStates ); 62 $window.on( 'deactivate-all-projects.rosetta', this.disableActiveStates ); 86 87 $window.on( 'deactivate-other-projects.rosetta', this.disableActiveStates ); 63 88 }, 64 89 … … 67 92 return; 68 93 } 94 69 95 this.each( function( project ) { 70 96 if ( project.get( 'id' ) != model.get( 'id' ) ) { … … 73 99 }); 74 100 75 $window.trigger( 'deactivate- other-projects.rosetta' );101 $window.trigger( 'deactivate-all-projects.rosetta' ); 76 102 }, 77 103 … … 92 118 93 119 initialize: function() { 94 this.set( 'checked', _.contains( projects.settings.accessList, this.get( 'id' ) ) ); 120 _.bindAll( this, 'uncheck' ); 121 122 var isChecked = projects.selection.get( this.get( 'id' ) ); 123 if ( isChecked ) { 124 this.set( 'checked', true ); 125 } 126 127 $window.on( 'uncheck-other-projects.rosetta', this.uncheck ); 128 129 this.on( 'change:checked', this.updateSelection ); 130 }, 131 132 uncheck: function() { 133 this.set( 'checked', false ); 134 }, 135 136 updateSelection: function( model, checked ) { 137 if ( checked ) { 138 projects.selection.add( { id: this.get( 'id' ) } ); 139 $window.trigger( 'uncheck-all-projects.rosetta' ); 140 } else { 141 projects.selection.remove( { id: this.get( 'id' ) } ); 142 } 95 143 } 96 144 }); … … 174 222 }); 175 223 224 projects.model.Selection = Backbone.Collection.extend({ 225 226 initialize: function() { 227 this.$field = $( '#project-access-list' ); 228 this.on( 'add remove reset', this.updateInputField ); 229 }, 230 231 updateInputField: function() { 232 this.$field.val( _.pluck( this.toJSON(), 'id' ).join() ); 233 } 234 }); 235 176 236 /** 177 237 * VIEWS … … 215 275 216 276 prepare: function() { 217 return _.pick( this.model.toJSON(), ' id', 'name', 'slug', 'checked', 'checkedSubProjects' );277 return _.pick( this.model.toJSON(), 'name', 'slug', 'checked', 'checkedSubProjects' ); 218 278 }, 219 279 … … 426 486 }; 427 487 488 projects.selection = new projects.model.Selection(); 489 428 490 projects.init = function() { 491 _.each( projects.settings.accessList, function( projectID ) { 492 projects.selection.add( { id: projectID } ); 493 }); 494 429 495 var data = null; 430 496 … … 448 514 $( projects.init ); 449 515 450 $( '#project-all' ).on( 'click', function() { 516 var $projectAll = $( '#project-all' ), $projectAllCheckbox = $projectAll.find( 'input' ); 517 518 $projectAll.on( 'click', function() { 451 519 var $el = $( this ); 452 520 … … 456 524 457 525 $el.addClass( 'active' ); 458 $window.trigger( 'deactivate-all-projects.rosetta' ); 459 }); 460 461 $window.on( 'deactivate-other-projects.rosetta', function() { 462 $( '#project-all' ).removeClass( 'active' ); 526 $window.trigger( 'deactivate-other-projects.rosetta' ); 527 }); 528 529 $projectAll.find( 'input' ).on( 'change', function() { 530 var checked = $( this ).prop( 'checked' ); 531 532 if ( checked ) { 533 projects.selection.add( { id: 'all' } ); 534 $window.trigger( 'uncheck-other-projects.rosetta' ); 535 } else { 536 projects.selection.remove( { id: 'all' } ); 537 } 538 }); 539 540 $window.on( 'deactivate-all-projects.rosetta', function() { 541 $projectAll.removeClass( 'active' ); 542 } ); 543 544 $window.on( 'uncheck-all-projects.rosetta', function() { 545 var checked = $projectAllCheckbox.prop( 'checked' ); 546 547 if ( checked ) { 548 projects.selection.remove( { id: 'all' } ); 549 $projectAllCheckbox.prop( 'checked', false ); 550 } 463 551 } ); 464 552 } )( jQuery ); -
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php
r2550 r2618 5 5 * Description: WordPress interface for managing roles. 6 6 * Author: ocean90 7 * Version: 1. 17 * Version: 1.2 8 8 */ 9 9 … … 209 209 #> 210 210 <label> 211 <input type="checkbox" class="input-checkbox" name="projects[]" value="{{data.id}}"211 <input type="checkbox" class="input-checkbox" 212 212 <# 213 213 if ( data.checked ) { … … 435 435 $all_projects = array_map( 'intval', $all_projects ); 436 436 437 $projects = (array) $_REQUEST['projects'];437 $projects = explode( ',', $_REQUEST['projects'] ); 438 438 if ( in_array( 'all', $projects, true ) ) { 439 439 $this->update_translation_editor( $user_details, array( 'all' ) ); -
sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/views/edit-translation-editor.php
r2545 r2618 18 18 <li id="project-all" class="active"> 19 19 <label> 20 <input name="projects[]" value="all"type="checkbox"<?php checked( in_array( 'all', $project_access_list ) ); ?>> <?php _e( 'All projects', 'rosetta' ); ?>20 <input type="checkbox"<?php checked( in_array( 'all', $project_access_list ) ); ?>> <?php _e( 'All projects', 'rosetta' ); ?> 21 21 </label> 22 22 <div class="sub-projects-wrapper"> … … 35 35 </table> 36 36 37 <input type="hidden" id="project-access-list" name="projects" value="<?php esc_attr( implode( ',', $project_access_list ) ); ?>"> 37 38 <input type="hidden" name="action" value="update-translation-editor"> 38 39 <input type="hidden" name="user_id" value="<?php echo esc_attr( $user_id ); ?>">
Note: See TracChangeset
for help on using the changeset viewer.