Make WordPress Core

Ticket #22637: 22637.diff

File 22637.diff, 4.5 KB (added by koopersmith, 13 years ago)
  • wp-includes/css/media-views.css

     
    267267        *max-width: 55%; /* IE7 */
    268268}
    269269
     270.media-sidebar .setting input[type="checkbox"] {
     271        margin-top: 10px;
     272}
     273
    270274.media-sidebar .setting span,
    271275.compat-item label span {
    272276        float: left;
  • wp-includes/js/media-editor.js

     
    189189                                args.type    = 'image';
    190190                                args.perPage = -1;
    191191
     192                                // Mark the `orderby` override attribute.
     193                                if ( 'rand' === attrs.orderby )
     194                                        attrs._orderbyRandom = true;
     195
    192196                                // Map the `orderby` attribute to the corresponding model property.
    193197                                if ( ! attrs.orderby || /^menu_order(?: ID)?$/i.test( attrs.orderby ) )
    194198                                        args.orderby = 'menuOrder';
     
    232236                                if ( props.uploadedTo )
    233237                                        attrs.id = props.uploadedTo;
    234238
     239                                // Check if the gallery is randomly ordered.
     240                                if ( attrs._orderbyRandom )
     241                                        attrs.orderby = 'rand';
     242                                delete attrs._orderbyRandom;
     243
    235244                                // If the `ids` attribute is set and `orderby` attribute
    236245                                // is the default value, clear it for cleaner output.
    237246                                if ( attrs.ids && 'post__in' === attrs.orderby )
  • wp-includes/js/media-views.js

     
    530530                },
    531531
    532532                gallerySettings: function() {
    533                         var library = this.get('library');
     533                        var library = this.get('library'),
     534                                browser;
    534535
    535536                        if ( ! library )
    536537                                return;
    537538
    538539                        library.gallery = library.gallery || new Backbone.Model();
    539540
    540                         this.frame.content.view().sidebar.set({
     541                        browser = this.frame.content.view();
     542
     543                        browser.sidebar.set({
    541544                                gallery: new media.view.Settings.Gallery({
    542545                                        controller: this,
    543546                                        model:      library.gallery,
    544547                                        priority:   40
    545548                                })
    546549                        });
     550
     551                        browser.toolbar.set( 'reverse', {
     552                                text:     l10n.reverseOrder,
     553                                priority: 80,
     554
     555                                click: function() {
     556                                        library.reset( library.toArray().reverse() );
     557                                }
     558                        });
    547559                }
    548560        });
    549561
     
    33693381                        } else if ( $setting.is('input[type="text"], textarea') ) {
    33703382                                if ( ! $setting.is(':focus') )
    33713383                                        $setting.val( value );
     3384
     3385                        // Handle checkboxes.
     3386                        } else if ( $setting.is('input[type="checkbox"]') ) {
     3387                                $setting.attr( 'checked', !! value );
    33723388                        }
    33733389                },
    33743390
     
    33823398                        if ( ! $setting.length )
    33833399                                return;
    33843400
     3401                        // Use the correct value for checkboxes.
     3402                        if ( $setting.is('input[type="checkbox"]') )
     3403                                value = $setting[0].checked;
     3404
     3405                        // Update the corresponding setting.
    33853406                        this.model.set( $setting.data('setting'), value );
    33863407
    33873408                        // If the setting has a corresponding user setting,
     
    34513472
    34523473                        $input.show();
    34533474
    3454                         if ( 'post' == linkTo ) {
     3475                        if ( 'post' === linkTo ) {
    34553476                                $input.val( attachment.get('link') );
    3456                         } else if ( 'file' == linkTo ) {
     3477                        } else if ( 'file' === linkTo ) {
    34573478                                $input.val( attachment.get('url') );
    34583479                        } else if ( ! this.model.get('linkUrl') ) {
    34593480                                $input.val('http://');
    34603481                        }
    34613482
    3462                         $input.prop('readonly', 'custom' !== linkTo);
     3483                        $input.prop( 'readonly', 'custom' !== linkTo );
    34633484
    34643485                        // If the input is visible, focus and select its contents.
    34653486                        if ( $input.is(':visible') )
  • wp-includes/media.php

     
    670670        $instance++;
    671671
    672672        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';
    675676                $attr['include'] = $attr['ids'];
    676677        }
    677678
     
    14741475                'updateGallery'      => __( 'Update gallery' ),
    14751476                'continueEditing'    => __( 'Continue editing' ),
    14761477                'addToGallery'       => __( 'Add to gallery' ),
     1478                'reverseOrder'       => __( 'Reverse order' ),
    14771479        );
    14781480
    14791481        $settings = apply_filters( 'media_view_settings', $settings, $post );
     
    18471849                                <?php endfor; ?>
    18481850                        </select>
    18491851                </label>
     1852
     1853                <label class="setting">
     1854                        <span><?php _e('Random'); ?></span>
     1855                        <input type="checkbox" data-setting="_orderbyRandom" />
     1856                </label>
    18501857        </script>
    18511858
    18521859        <script type="text/html" id="tmpl-embed-link-settings">