Ticket #22637: 22637.2.diff
File 22637.2.diff, 8.4 KB (added by , 13 years ago) |
---|
-
wp-includes/css/media-views.css
267 267 *max-width: 55%; /* IE7 */ 268 268 } 269 269 270 .media-sidebar .setting input[type="checkbox"] { 271 margin-top: 10px; 272 } 273 270 274 .media-sidebar .setting span, 271 275 .compat-item label span { 272 276 float: left; -
wp-includes/js/media-editor.js
189 189 args.type = 'image'; 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 ) ) 194 198 args.orderby = 'menuOrder'; … … 232 236 if ( props.uploadedTo ) 233 237 attrs.id = props.uploadedTo; 234 238 239 // Check if the gallery is randomly ordered. 240 if ( attrs._orderbyRandom ) 241 attrs.orderby = 'rand'; 242 delete attrs._orderbyRandom; 243 235 244 // If the `ids` attribute is set and `orderby` attribute 236 245 // is the default value, clear it for cleaner output. 237 246 if ( attrs.ids && 'post__in' === attrs.orderby ) -
wp-includes/js/media-models.js
832 832 // If the workflow does not support multiple 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 839 }, 842 840 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 },863 864 841 single: function( model ) { 865 842 var previous = this._single; 866 843 … … 869 846 this._single = model; 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 875 852 this._single = this._single || this.last(); -
wp-includes/js/media-views.js
329 329 }, 330 330 331 331 reset: function() { 332 this.get('selection'). clear();332 this.get('selection').reset(); 333 333 this.resetDisplays(); 334 334 }, 335 335 … … 534 534 }, 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 ) 540 541 return; 541 542 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, 547 550 model: library.gallery, 548 551 priority: 40 549 552 }) 550 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 } 562 }); 551 563 } 552 564 }); 553 565 … … 2497 2509 buttons: {}, 2498 2510 2499 2511 initialize: function() { 2512 var selection = this.options.selection; 2513 2500 2514 this.controller = this.options.controller; 2501 2515 2502 2516 this.model.on( 'change:sizes change:uploading change:caption change:title', this.render, this ); 2503 2517 this.model.on( 'change:percent', this.progress, this ); 2518 2519 // Update the selection. 2504 2520 this.model.on( 'add', this.select, this ); 2505 2521 this.model.on( 'remove', this.deselect, this ); 2522 if ( selection ) 2523 selection.on( 'reset', this.updateSelect, this ); 2506 2524 2507 2525 // Update the model's details view. 2508 2526 this.model.on( 'selection:single selection:unsingle', this.details, this ); … … 2510 2528 }, 2511 2529 2512 2530 dispose: function() { 2531 var selection = this.options.selection; 2532 2533 // Make sure all settings are saved before removing the view. 2513 2534 this.updateAll(); 2535 2536 if ( selection ) 2537 selection.off( null, null, this ); 2538 2514 2539 media.View.prototype.dispose.apply( this, arguments ); 2515 2540 return this; 2516 2541 }, … … 2549 2574 delete this.$bar; 2550 2575 2551 2576 // Check if the model is selected. 2552 if ( this.selected() ) 2553 this.select(); 2577 this.updateSelect(); 2554 2578 2555 2579 this.views.render(); 2556 2580 return this; … … 2568 2592 if ( ! selection ) 2569 2593 return; 2570 2594 2571 if ( selection.has( model) ) {2595 if ( this.selected() ) { 2572 2596 // If the model is the single model, remove it. 2573 2597 // If it is not the same as the single model, 2574 2598 // it now becomes the single model. … … 2578 2602 } 2579 2603 }, 2580 2604 2605 updateSelect: function() { 2606 this[ this.selected() ? 'select' : 'deselect' ](); 2607 }, 2608 2581 2609 selected: function() { 2582 2610 var selection = this.options.selection; 2583 2611 if ( selection ) 2584 return selection.has( this.model);2612 return !! selection.getByCid( this.model.cid ); 2585 2613 }, 2586 2614 2587 2615 select: function( model, collection ) { … … 3326 3354 3327 3355 clear: function( event ) { 3328 3356 event.preventDefault(); 3329 this.collection. clear();3357 this.collection.reset(); 3330 3358 } 3331 3359 }); 3332 3360 … … 3402 3430 3403 3431 clear: function( event ) { 3404 3432 event.preventDefault(); 3405 this.collection. clear();3433 this.collection.reset(); 3406 3434 } 3407 3435 }); 3408 3436 … … 3482 3510 } else if ( $setting.is('input[type="text"], textarea') ) { 3483 3511 if ( ! $setting.is(':focus') ) 3484 3512 $setting.val( value ); 3513 3514 // Handle checkboxes. 3515 } else if ( $setting.is('input[type="checkbox"]') ) { 3516 $setting.attr( 'checked', !! value ); 3485 3517 } 3486 3518 }, 3487 3519 … … 3495 3527 if ( ! $setting.length ) 3496 3528 return; 3497 3529 3530 // Use the correct value for checkboxes. 3531 if ( $setting.is('input[type="checkbox"]') ) 3532 value = $setting[0].checked; 3533 3534 // Update the corresponding setting. 3498 3535 this.model.set( $setting.data('setting'), value ); 3499 3536 3500 3537 // If the setting has a corresponding user setting, … … 3564 3601 3565 3602 $input.show(); 3566 3603 3567 if ( 'post' == linkTo ) {3604 if ( 'post' === linkTo ) { 3568 3605 $input.val( attachment.get('link') ); 3569 } else if ( 'file' == linkTo ) {3606 } else if ( 'file' === linkTo ) { 3570 3607 $input.val( attachment.get('url') ); 3571 3608 } else if ( ! this.model.get('linkUrl') ) { 3572 3609 $input.val('http://'); 3573 3610 } 3574 3611 3575 $input.prop( 'readonly', 'custom' !== linkTo);3612 $input.prop( 'readonly', 'custom' !== linkTo ); 3576 3613 3577 3614 // If the input is visible, focus and select its contents. 3578 3615 if ( $input.is(':visible') ) -
wp-includes/media.php
670 670 $instance++; 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 } 677 678 … … 1489 1490 'updateGallery' => __( 'Update gallery' ), 1490 1491 'continueEditing' => __( 'Continue editing' ), 1491 1492 'addToGallery' => __( 'Add to gallery' ), 1493 'reverseOrder' => __( 'Reverse order' ), 1492 1494 ); 1493 1495 1494 1496 $settings = apply_filters( 'media_view_settings', $settings, $post ); … … 1865 1867 <?php endfor; ?> 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 1870 1877 <script type="text/html" id="tmpl-embed-link-settings">