From 3ebde0c4d6d1f4fd3a58f93fb8312343c63d3863 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 10 Jul 2014 20:59:12 +0000 Subject: [PATCH] Media Grid: Move toggling of visible fields to Screen Options. This moves us in a better direction... but this will probably need to be massaged again. See #24716. git-svn-id: https://develop.svn.wordpress.org/trunk@29077 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/common.css | 2 ++ src/wp-admin/includes/screen.php | 18 +++++++++++- src/wp-admin/js/common.js | 14 +++++++++ src/wp-admin/upload.php | 5 ++++ src/wp-includes/css/media-views.css | 1 + src/wp-includes/js/media-grid.js | 28 ------------------ src/wp-includes/js/media-views.js | 10 +------ src/wp-includes/media-template.php | 45 +++++++++-------------------- 8 files changed, 53 insertions(+), 70 deletions(-) diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index 67e8b1c065..a84b97b49d 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -1025,6 +1025,7 @@ form.upgrade .hint { display: none; margin: 0 20px -1px 0px; position: relative; + z-index: 10; background-color: #fff; border: 1px solid #ddd; border-top: none; @@ -1047,6 +1048,7 @@ form.upgrade .hint { #screen-meta-links .screen-meta-toggle { position: relative; top: 0; + z-index: 10; } #screen-meta-links a { diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index ad7140f28e..fa3141ab3f 100644 --- a/src/wp-admin/includes/screen.php +++ b/src/wp-admin/includes/screen.php @@ -1019,7 +1019,12 @@ final class WP_Screen { ?> + get_option( 'media_grid_title' ) ): ?> +
+ _options as $column => $args ) { + $id = "$column-hide"; + echo '\n"; + } ?> +
+
render_screen_layout(); diff --git a/src/wp-admin/js/common.js b/src/wp-admin/js/common.js index 2c8b8ff93a..f853493be6 100644 --- a/src/wp-admin/js/common.js +++ b/src/wp-admin/js/common.js @@ -28,6 +28,20 @@ columns = { saveManageColumnsState : function() { var hidden = this.hidden(); + if ( $( '#media_grid_title-hide' ).length ) { + hidden = []; + $( '.hide-column-tog', '.media-grid-prefs' ).each( function() { + var $el, field = this.value.replace( 'media_grid_', '' ); + $el = $( '.data-' + field ); + if ( ! this.checked ) { + hidden.push( field ); + $el.removeClass( 'data-visible' ).addClass( 'data-hidden' ); + } else { + $el.removeClass( 'data-hidden' ).addClass( 'data-visible' ); + } + } ); + hidden = hidden.join( ',' ); + } $.post(ajaxurl, { action: 'hidden-columns', hidden: hidden, diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index cdb49ef516..04a8688de4 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -26,6 +26,11 @@ if ( 'grid' === $mode ) { wp_enqueue_script( 'media' ); wp_localize_script( 'media-grid', 'mediaGridSettings', array( 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ) ) ); + add_screen_option( 'media_grid_title', array( 'label' => __( 'Name' ) ) ); + add_screen_option( 'media_grid_uploadedTo', array( 'label' => __( 'Uploaded To' ) ) ); + add_screen_option( 'media_grid_dateFormatted', array( 'label' => __( 'Date' ) ) ); + add_screen_option( 'media_grid_mime', array( 'label' => __( 'Mime-type' ) ) ); + require_once( ABSPATH . 'wp-admin/admin-header.php' ); include( ABSPATH . 'wp-admin/admin-footer.php' ); exit; diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css index b1b94df52b..0a2ced67a2 100644 --- a/src/wp-includes/css/media-views.css +++ b/src/wp-includes/css/media-views.css @@ -2575,6 +2575,7 @@ video#inline-media-node { * area of the screen. */ .media-grid-view { + z-index: 1; position: fixed; bottom: 0; left: 160px; diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js index b1f0428838..71dc812024 100644 --- a/src/wp-includes/js/media-grid.js +++ b/src/wp-includes/js/media-grid.js @@ -597,34 +597,6 @@ } }); - media.view.GridFieldOptions = media.View.extend({ - className: 'media-grid-field-options', - template: media.template( 'media-grid-field-options' ), - - events: { - 'change input': 'toggleFields' - }, - - toggleFields: function(e) { - var $el = $( e.currentTarget ), fields, setting; - setting = $el.data( 'setting' ); - fields = $( '.data-' + setting, '.data-fields' ); - if ( $el.is( ':checked' ) ) { - fields.show(); - deleteUserSetting( 'hidegrid' + setting ); - } else { - fields.hide(); - setUserSetting( 'hidegrid' + setting, 1 ); - } - - if ( $( ':checked', this.$el ).length ) { - fields.parent().show(); - } else { - fields.parent().hide(); - } - } - }); - media.view.BulkSelectionToggleButton = media.view.Button.extend({ initialize: function() { media.view.Button.prototype.initialize.apply( this, arguments ); diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index acdb808706..5f53808a16 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -5228,8 +5228,7 @@ controller: this.controller, model: attachment, collection: this.collection, - selection: this.options.selection, - showAttachmentFields: this.options.showAttachmentFields + selection: this.options.selection }); return this._viewsByCid[ attachment.cid ] = view; @@ -5544,7 +5543,6 @@ search: true, display: false, sidebar: true, - showAttachmentFields: getUserSetting( 'showAttachmentFields', [ 'title', 'uploadedTo', 'dateFormatted', 'mime' ] ), AttachmentView: media.view.Attachment.Library }); @@ -5609,11 +5607,6 @@ controller: this.controller, priority: -69 }).render() ); - - this.toolbar.set( 'gridFieldOptions', new media.view.GridFieldOptions({ - controller: this.controller, - priority: -50 - }).render() ); } filters = this.options.filters; @@ -5705,7 +5698,6 @@ selection: this.options.selection, model: this.model, sortable: this.options.sortable, - showAttachmentFields: this.options.showAttachmentFields, // The single `Attachment` view to be used in the `Attachments` view. AttachmentView: this.options.AttachmentView diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 05e7def0dc..78c899ea66 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -229,25 +229,6 @@ function wp_print_media_templates() { - -