Make WordPress Core

Ticket #28946: 28946.2.diff

File 28946.2.diff, 12.3 KB (added by pento, 12 years ago)
  • src/wp-admin/css/list-tables.css

     
    595595        padding: 2px 8px 0 0;
    596596}
    597597
     598.wp-filter .actions {
     599        display: inline-block;
     600        vertical-align: middle;
     601}
     602
    598603.tablenav .delete {
    599604        margin-right: 20px;
    600605}
     
    617622        color: #2ea2cc;
    618623}
    619624
    620 .view-switch {
     625tablenav .view-switch {
    621626        float: right;
    622627        margin: 5px 16px 0 8px;
    623628}
    624629
     630.wp-filter .view-switch {
     631        display: inline-block;
     632        vertical-align: middle;
     633        padding: 14px 0;
     634        margin: 0 20px 0 0;
     635}
     636
    625637.view-switch a {
    626638        text-decoration: none;
    627639}
     
    14371449                display: block;
    14381450        }
    14391451
    1440         .tablenav.top .actions, .view-switch {
     1452        .tablenav.top .actions,
     1453        .tablenav .view-switch {
    14411454                display: none;
    14421455        }
    14431456
  • src/wp-admin/css/media.css

     
    513513        border: 4px dashed #bbb;
    514514}
    515515
    516 .media-frame.mode-grid .media-toolbar select {
    517         margin-top: 1px;
    518         font-size: inherit;
    519 }
    520 
    521 .media-frame.mode-grid .attachments-browser .bulk-select {
    522         display: inline-block;
    523         margin: 0 10px 0 0;
    524 }
    525 
    526516.media-frame.mode-grid .attachments,
    527517.media-frame.mode-select .attachments {
    528518        padding: 2px;
     
    530520
    531521.media-frame.mode-select .attachments-browser.fixed .attachments {
    532522        position: relative;
    533         top: 80px; /* prevent jumping up when the toolbar becomes fixed */
    534         padding-bottom: 80px; /* offset for above so the bottom doesn't get cut off */
     523        top: 97px; /* prevent jumping up when the toolbar becomes fixed */
     524        padding-bottom: 97px; /* offset for above so the bottom doesn't get cut off */
    535525}
    536526
    537527.media-frame.mode-grid .attachment:focus,
     
    577567 *
    578568 * This should be OOCSS'd so both use a shared selector.
    579569 */
    580 .media-frame.mode-grid .attachments-browser .media-toolbar {
    581         background: #fff;
    582         -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    583         box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    584         -webkit-box-sizing: border-box;
    585         -moz-box-sizing: border-box;
    586         box-sizing: border-box;
    587         color: #555;
    588         display: inline-block;
    589         font-size: 13px;
    590         margin: 20px 0;
    591         padding: 0 20px;
    592         position: relative;
    593         width: 100%;
     570
     571.media-frame.mode-grid .media-toolbar {
     572        margin: 20px 0 16px;
    594573        height: auto;
    595         border: none;
    596574}
    597575
    598 .media-frame.mode-select .attachments-browser.fixed .media-toolbar {
    599         position: fixed;
    600         top: 32px;
    601         left: auto;
    602         right: 20px;
    603         margin-top: 0;
     576.media-frame.mode-grid .media-toolbar select {
     577        margin: 0 10px 0 0;
     578        font-size: inherit;
    604579}
    605580
    606 .media-frame.mode-grid input[type="search"] {
    607         margin: 1px;
    608         padding: 3px 5px;
    609         position: absolute;
    610         right: 10px;
    611         top: 9px;
    612         font-size: 16px;
    613         font-weight: 300;
    614         line-height: 1.5;
    615         width: 280px;
     581.media-frame.mode-grid .media-toolbar-secondary > .media-button {
     582        margin-top: 10px;
     583        margin-bottom: 10px;
    616584}
    617585
    618 .media-frame.mode-grid .view-switch {
     586.media-frame.mode-grid .attachments-browser .bulk-select {
    619587        display: inline-block;
    620         float: none;
    621         vertical-align: middle;
    622         padding: 15px 0;
    623         margin: 0 20px 0 0;
     588        margin: 0 10px 0 0;
    624589}
    625590
    626 .media-frame.mode-grid select {
    627         margin: 0 10px 0 0;
     591.media-frame.mode-grid .search {
     592        margin-top: 0;
    628593}
    629594
    630595.media-frame.mode-grid .spinner {
     
    635600        margin-right: 10px;
    636601}
    637602
     603.media-frame.mode-select .attachments-browser.fixed .media-toolbar {
     604        position: fixed;
     605        top: 32px;
     606        left: auto;
     607        right: 20px;
     608        margin-top: 0;
     609}
     610
    638611.media-frame.mode-grid .attachments-browser {
    639612        padding: 0;
    640613}
     
    11581131 */
    11591132
    11601133@media only screen and (max-width: 1120px) {
    1161         .media-frame.mode-grid .attachments-browser .media-toolbar-primary,
    11621134        .media-frame.mode-grid .attachments-browser .media-toolbar-secondary {
    11631135                float: none;
    11641136        }
    1165 
    1166         .media-frame.mode-grid input[type="search"] {
    1167                 margin: 20px 0;
    1168                 position: static;
    1169                 width: 100%;
    1170                 max-width: 280px;
    1171         }
    11721137}
    11731138
    11741139@media only screen and ( max-width: 782px ) {
  • src/wp-admin/includes/class-wp-media-list-table.php

     
    6060                        foreach ( $reals as $real )
    6161                                $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
    6262
    63                 $class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : '';
    64                 $type_links['all'] = "<a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
     63                $selected = empty( $_GET['attachment-filter'] ) ? ' selected="selected"' : '';
     64                $type_links['all'] = "<option value=''$selected>" . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</option>';
    6565                foreach ( $post_mime_types as $mime_type => $label ) {
    6666                        $class = '';
    6767
    6868                        if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
    6969                                continue;
    7070
    71                         if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
    72                                 $class = ' class="current"';
     71                        $selected = '';
     72                        if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) )
     73                                $selected = ' selected="selected"';
    7374                        if ( !empty( $num_posts[$mime_type] ) )
    74                                 $type_links[$mime_type] = '<a href="upload.php?post_mime_type=' . urlencode( $mime_type ) . '"' . $class . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
     75                                $type_links[$mime_type] = '<option value="post_mime_type:' . urlencode( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
    7576                }
    76                 $type_links['detached'] = '<a href="upload.php?detached=1"' . ( $this->detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
     77                $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
    7778
    7879                if ( !empty($_num_posts['trash']) )
    79                         $type_links['trash'] = '<a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
     80                        $type_links['trash'] = '<option value="trash"' . ( (isset($_GET['attachment-filter']) && $_GET['attachment-filter'] == 'trash' ) ? ' selected="selected"' : '') . '>' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</option>';
    8081
    8182                return $type_links;
    8283        }
     
    9192        }
    9293
    9394        protected function extra_tablenav( $which ) {
     95                if ( 'bar' !== $which ) {
     96                        return;
     97                }
    9498?>
    95                 <div class="alignleft actions">
     99                <div class="actions">
    96100<?php
    97                 if ( 'top' == $which && !is_singular() && !$this->detached && !$this->is_trash ) {
     101                if ( ! is_singular() && ! $this->detached && ! $this->is_trash ) {
    98102                        $this->months_dropdown( 'attachment' );
    99103
    100104                        /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
     
    131135                global $mode;
    132136
    133137                parent::pagination( $which );
    134 
    135                 $this->view_switcher( $mode );
    136138        }
    137139
    138140        /**
     
    167169<?php
    168170        }
    169171
     172        /**
     173         * Override parent views so we can use the filter bar display.
     174         */
     175        public function views() {
     176                global $mode;
     177
     178                $views = $this->get_views();
     179
     180                /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
     181                $views = apply_filters( "views_{$this->screen->id}", $views );
     182?>
     183<div class="wp-filter">
     184        <?php $this->view_switcher( $mode ); ?>
     185
     186        <select class="attachment-filters" name="attachment-filter">
     187                <?php
     188                if ( ! empty( $views ) ) {
     189                        foreach ( $views as $class => $view ) {
     190                                echo "\t$view\n";
     191                        }
     192                }
     193                ?>
     194        </select>
     195
     196        <?php $this->extra_tablenav( 'bar' ); ?>
     197        <div class="media-toolbar-primary search-form">
     198                <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label>
     199                <input type="search" placeholder="Search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
     200        </div>
     201        <?php
     202        }
     203
    170204        public function get_columns() {
    171205                $posts_columns = array();
    172206                $posts_columns['cb'] = '<input type="checkbox" />';
  • src/wp-admin/includes/post.php

     
    10321032                $states .= ',private';
    10331033
    10341034        $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
     1035        $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states;
     1036
    10351037        $media_per_page = (int) get_user_option( 'upload_per_page' );
    10361038        if ( empty( $media_per_page ) || $media_per_page < 1 )
    10371039                $media_per_page = 20;
     
    10511053        if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
    10521054                unset($q['post_mime_type']);
    10531055
    1054         if ( isset($q['detached']) )
     1056        foreach( array_keys( $post_mime_types ) as $type ) {
     1057                if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) {
     1058                        $q['post_mime_type'] = $type;
     1059                        break;
     1060                }
     1061        }
     1062
     1063        if ( isset( $q['detached'] ) || ( isset( $q['attachment-filter'] ) && 'detached' == $q['attachment-filter'] ) ) {
    10551064                $q['post_parent'] = 0;
     1065        }
    10561066
    10571067        wp( $q );
    10581068
  • src/wp-admin/upload.php

     
    265265<div id="message" class="updated"><p><?php echo $message; ?></p></div>
    266266<?php } ?>
    267267
    268 <?php $wp_list_table->views(); ?>
    269 
    270268<form id="posts-filter" action="" method="get">
    271269
    272 <?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
     270<?php $wp_list_table->views(); ?>
    273271
    274272<?php $wp_list_table->display(); ?>
    275273
  • src/wp-includes/js/media-grid.js

     
    179179                        $browser = this.$('.attachments-browser');
    180180                        $toolbar = $browser.find('.media-toolbar');
    181181
    182                         if ( $browser.offset().top < this.$window.scrollTop() + this.$adminBar.height() ) {
     182                        // Offset doesn't appear to take top margin into account, hence +20
     183                        if ( ( $browser.offset().top + 20 ) < this.$window.scrollTop() + this.$adminBar.height() ) {
    183184                                $browser.addClass( 'fixed' );
    184185                                $toolbar.css('width', $browser.width() + 'px');
    185186                        } else {
  • src/wp-includes/js/media-views.js

     
    39113911         */
    39123912        media.view.Toolbar = media.View.extend({
    39133913                tagName:   'div',
    3914                 className: 'media-toolbar',
     3914                className: 'media-toolbar wp-filter',
    39153915
    39163916                initialize: function() {
    39173917                        var state = this.controller.state(),
     
    39233923                        // The toolbar is composed of two `PriorityList` views.
    39243924                        this.primary   = new media.view.PriorityList();
    39253925                        this.secondary = new media.view.PriorityList();
    3926                         this.primary.$el.addClass('media-toolbar-primary');
     3926                        this.primary.$el.addClass('media-toolbar-primary search-form');
    39273927                        this.secondary.$el.addClass('media-toolbar-secondary');
    39283928
    39293929                        this.views.set([ this.secondary, this.primary ]);