Changeset 22987
- Timestamp:
- 12/03/2012 05:32:25 AM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/css/media-views.css
r22986 r22987 272 272 } 273 273 274 .media-sidebar .setting input[type="checkbox"] { 275 margin-top: 10px; 276 } 277 274 278 .media-sidebar .setting span, 275 279 .compat-item label span { -
trunk/wp-includes/js/media-editor.js
r22984 r22987 190 190 args.perPage = -1; 191 191 192 // Mark the `orderby` override attribute. 193 if ( 'rand' === attrs.orderby ) 194 attrs._orderbyRandom = true; 195 192 196 // Map the `orderby` attribute to the corresponding model property. 193 197 if ( ! attrs.orderby || /^menu_order(?: ID)?$/i.test( attrs.orderby ) ) … … 232 236 if ( props.uploadedTo ) 233 237 attrs.id = props.uploadedTo; 238 239 // Check if the gallery is randomly ordered. 240 if ( attrs._orderbyRandom ) 241 attrs.orderby = 'rand'; 242 delete attrs._orderbyRandom; 234 243 235 244 // If the `ids` attribute is set and `orderby` attribute -
trunk/wp-includes/js/media-models.js
r22979 r22987 833 833 // selected attachments, reset the selection. 834 834 add: function( models, options ) { 835 if ( ! this.multiple ) { 836 models = _.isArray( models ) && models.length ? _.first( models ) : models; 837 this.clear( options ); 838 } 835 if ( ! this.multiple ) 836 this.remove( this.models ); 839 837 840 838 return Attachments.prototype.add.call( this, models, options ); 841 },842 843 // Removes all models from the selection.844 clear: function( options ) {845 this.remove( this.models, options ).single();846 return this;847 },848 849 // Override the selection's reset method.850 // Always direct items through add and remove,851 // as we need them to fire.852 reset: function( models, options ) {853 this.clear( options ).add( models, options ).single();854 return this;855 },856 857 // Create selection.has, which determines if a model858 // exists in the collection based on cid and id,859 // instead of direct comparison.860 has: function( attachment ) {861 return !! ( this.getByCid( attachment.cid ) || this.get( attachment.id ) );862 839 }, 863 840 … … 870 847 871 848 // If the single model isn't in the selection, remove it. 872 if ( this._single && ! this. has( this._single) )849 if ( this._single && ! this.getByCid( this._single.cid ) ) 873 850 delete this._single; 874 851 -
trunk/wp-includes/js/media-views.js
r22985 r22987 330 330 331 331 reset: function() { 332 this.get('selection'). clear();332 this.get('selection').reset(); 333 333 this.resetDisplays(); 334 334 }, … … 535 535 536 536 gallerySettings: function() { 537 var library = this.get('library'); 537 var library = this.get('library'), 538 browser; 538 539 539 540 if ( ! library ) … … 542 543 library.gallery = library.gallery || new Backbone.Model(); 543 544 544 this.frame.content.view().sidebar.set({ 545 browser = this.frame.content.view(); 546 547 browser.sidebar.set({ 545 548 gallery: new media.view.Settings.Gallery({ 546 549 controller: this, … … 548 551 priority: 40 549 552 }) 553 }); 554 555 browser.toolbar.set( 'reverse', { 556 text: l10n.reverseOrder, 557 priority: 80, 558 559 click: function() { 560 library.reset( library.toArray().reverse() ); 561 } 550 562 }); 551 563 } … … 2506 2518 2507 2519 initialize: function() { 2520 var selection = this.options.selection; 2521 2508 2522 this.controller = this.options.controller; 2509 2523 2510 2524 this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this ); 2511 2525 this.model.on( 'change:percent', this.progress, this ); 2526 2527 // Update the selection. 2512 2528 this.model.on( 'add', this.select, this ); 2513 2529 this.model.on( 'remove', this.deselect, this ); 2530 if ( selection ) 2531 selection.on( 'reset', this.updateSelect, this ); 2514 2532 2515 2533 // Update the model's details view. … … 2519 2537 2520 2538 dispose: function() { 2539 var selection = this.options.selection; 2540 2541 // Make sure all settings are saved before removing the view. 2521 2542 this.updateAll(); 2543 2544 if ( selection ) 2545 selection.off( null, null, this ); 2546 2522 2547 media.View.prototype.dispose.apply( this, arguments ); 2523 2548 return this; … … 2558 2583 2559 2584 // Check if the model is selected. 2560 if ( this.selected() ) 2561 this.select(); 2585 this.updateSelect(); 2562 2586 2563 2587 this.views.render(); … … 2577 2601 return; 2578 2602 2579 if ( selection.has( model) ) {2603 if ( this.selected() ) { 2580 2604 // If the model is the single model, remove it. 2581 2605 // If it is not the same as the single model, … … 2587 2611 }, 2588 2612 2613 updateSelect: function() { 2614 this[ this.selected() ? 'select' : 'deselect' ](); 2615 }, 2616 2589 2617 selected: function() { 2590 2618 var selection = this.options.selection; 2591 2619 if ( selection ) 2592 return selection.has( this.model);2620 return !! selection.getByCid( this.model.cid ); 2593 2621 }, 2594 2622 … … 3313 3341 clear: function( event ) { 3314 3342 event.preventDefault(); 3315 this.collection. clear();3343 this.collection.reset(); 3316 3344 } 3317 3345 }); … … 3389 3417 clear: function( event ) { 3390 3418 event.preventDefault(); 3391 this.collection. clear();3419 this.collection.reset(); 3392 3420 } 3393 3421 }); … … 3469 3497 if ( ! $setting.is(':focus') ) 3470 3498 $setting.val( value ); 3499 3500 // Handle checkboxes. 3501 } else if ( $setting.is('input[type="checkbox"]') ) { 3502 $setting.attr( 'checked', !! value ); 3471 3503 } 3472 3504 }, … … 3482 3514 return; 3483 3515 3516 // Use the correct value for checkboxes. 3517 if ( $setting.is('input[type="checkbox"]') ) 3518 value = $setting[0].checked; 3519 3520 // Update the corresponding setting. 3484 3521 this.model.set( $setting.data('setting'), value ); 3485 3522 … … 3551 3588 $input.show(); 3552 3589 3553 if ( 'post' == linkTo ) {3590 if ( 'post' === linkTo ) { 3554 3591 $input.val( attachment.get('link') ); 3555 } else if ( 'file' == linkTo ) {3592 } else if ( 'file' === linkTo ) { 3556 3593 $input.val( attachment.get('url') ); 3557 3594 } else if ( ! this.model.get('linkUrl') ) { … … 3559 3596 } 3560 3597 3561 $input.prop( 'readonly', 'custom' !== linkTo);3598 $input.prop( 'readonly', 'custom' !== linkTo ); 3562 3599 3563 3600 // If the input is visible, focus and select its contents. -
trunk/wp-includes/media.php
r22983 r22987 671 671 672 672 if ( ! empty( $attr['ids'] ) ) { 673 // 'ids' is explicitly ordered 674 $attr['orderby'] = 'post__in'; 673 // 'ids' is explicitly ordered, unless you specify otherwise. 674 if ( empty( $attr['orderby'] ) ) 675 $attr['orderby'] = 'post__in'; 675 676 $attr['include'] = $attr['ids']; 676 677 } … … 1490 1491 'continueEditing' => __( 'Continue editing' ), 1491 1492 'addToGallery' => __( 'Add to gallery' ), 1493 'reverseOrder' => __( 'Reverse order' ), 1492 1494 ); 1493 1495 … … 1866 1868 </select> 1867 1869 </label> 1870 1871 <label class="setting"> 1872 <span><?php _e('Random'); ?></span> 1873 <input type="checkbox" data-setting="_orderbyRandom" /> 1874 </label> 1868 1875 </script> 1869 1876
Note: See TracChangeset
for help on using the changeset viewer.