Index: /trunk/src/wp-admin/css/list-tables.css
===================================================================
--- /trunk/src/wp-admin/css/list-tables.css (revision 28681)
+++ /trunk/src/wp-admin/css/list-tables.css (revision 28682)
@@ -635,5 +635,4 @@
.view-switch > a:before {
color: #bbb;
- content: '\f163';
display: inline-block;
float: left;
@@ -646,4 +645,8 @@
}
+.view-switch > .view-list:before {
+ content: '\f163';
+}
+
.view-switch a:hover:before {
color: #727272;
@@ -654,7 +657,14 @@
}
-.view-switch > a + a:before {
+.view-switch > a + a {
margin-left: 5px;
+}
+
+.view-switch > .view-excerpt:before {
content: '\f164';
+}
+
+.view-switch > .view-grid:before {
+ content: '\f180';
}
Index: /trunk/src/wp-admin/includes/class-wp-list-table.php
===================================================================
--- /trunk/src/wp-admin/includes/class-wp-list-table.php (revision 28681)
+++ /trunk/src/wp-admin/includes/class-wp-list-table.php (revision 28682)
@@ -494,6 +494,15 @@
$title ) {
- $class = ( $current_mode == $mode ) ? 'class="current"' : '';
- echo "\n";
+ $classes = array( 'view-' . $mode );
+ if ( $current_mode == $mode )
+ $classes[] = 'current';
+ printf(
+ "\n",
+ esc_url( add_query_arg( 'mode', $mode ) ),
+ implode( ' ', $classes ),
+ esc_url( includes_url( 'images/blank.gif' ) ),
+ $title,
+ $title
+ );
}
?>
Index: /trunk/src/wp-admin/includes/class-wp-media-list-table.php
===================================================================
--- /trunk/src/wp-admin/includes/class-wp-media-list-table.php (revision 28681)
+++ /trunk/src/wp-admin/includes/class-wp-media-list-table.php (revision 28682)
@@ -24,5 +24,5 @@
public function prepare_items() {
- global $lost, $wp_query, $post_mime_types, $avail_post_mime_types;
+ global $lost, $wp_query, $post_mime_types, $avail_post_mime_types, $mode;
$q = $_REQUEST;
@@ -34,4 +34,6 @@
$this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
+
+ $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
$this->set_pagination_args( array(
@@ -124,4 +126,47 @@
public function no_items() {
_e( 'No media attachments found.' );
+ }
+
+ protected function pagination( $which ) {
+ global $mode;
+
+ parent::pagination( $which );
+
+ $this->view_switcher( $mode );
+ }
+
+ /**
+ * Display a view switcher
+ *
+ * @since 3.1.0
+ * @access protected
+ */
+ protected function view_switcher( $current_mode ) {
+ $modes = array(
+ 'list' => __( 'List View' ),
+ 'grid' => __( 'Grid View' )
+ );
+
+?>
+
+
+ $title ) {
+ $classes = array( 'view-' . $mode );
+ if ( $current_mode == $mode )
+ $classes[] = 'current';
+ printf(
+ "
\n",
+ esc_url( add_query_arg( 'mode', $mode ) ),
+ implode( ' ', $classes ),
+ esc_url( includes_url( 'images/blank.gif' ) ),
+ $title,
+ $title
+
+ );
+ }
+ ?>
+
+
-
+
Index: /trunk/src/wp-includes/css/media-views.css
===================================================================
--- /trunk/src/wp-includes/css/media-views.css (revision 28681)
+++ /trunk/src/wp-includes/css/media-views.css (revision 28682)
@@ -296,8 +296,9 @@
}
-.media-sidebar .setting span {
+.media-sidebar .setting .name {
min-width: 30%;
margin-right: 4%;
font-size: 12px;
+ text-align: right;
}
@@ -320,11 +321,15 @@
padding-top: 8px;
line-height: 16px;
- text-align: right;
font-weight: normal;
color: #666;
}
+.compat-item label span {
+ text-align: right;
+}
+
.media-sidebar .setting input,
-.media-sidebar .setting textarea {
+.media-sidebar .setting textarea,
+.media-sidebar .setting .value {
margin: 1px;
width: 65%;
@@ -1813,5 +1818,5 @@
}
-.image-details .embed-media-settings .setting span {
+.image-details .embed-media-settings .setting .name {
float: left;
width: 25%;
@@ -2369,2 +2374,76 @@
}
}
+
+
+/**
+ * Media Grid
+ */
+
+.media-grid-view h1 {
+ color: #222;
+ font-size: 23px;
+ font-weight: 400;
+ margin: 10px 0 0;
+ padding: 9px 15px 4px 22px;
+ line-height: 29px;
+}
+
+.media-grid-view-switch {
+ position: fixed;
+ right: 10px;
+ top: 44px;
+ z-index: 300;
+}
+
+/**
+ * Position both the frame and the uploader window into the content
+ * area of the screen.
+ */
+.media-grid-view {
+ position: fixed;
+ bottom: 0;
+ left: 160px;
+ right: 0;
+ top: 32px;
+}
+@media screen and (max-width: 900px) {
+ .auto-fold .media-grid-view {
+ left: 36px;
+ }
+}
+@media screen and (max-width: 782px) {
+ .media-grid-view {
+ top: 46px;
+ }
+ .auto-fold .media-grid-view {
+ left: 0px;
+ bottom: 0px;
+ }
+}
+
+/* Regions we don't use at all */
+.media-grid-view .media-frame-toolbar,
+.media-grid-view .media-frame-menu {
+ display: none;
+}
+
+.media-grid-view .media-frame-content {
+ bottom: 40px;
+}
+@media screen and (max-width: 782px) {
+ .media-grid-view .media-frame-content {
+ border-bottom: none;
+ bottom: 0;
+ }
+}
+
+@media only screen and (max-width: 640px), screen and (max-height: 400px) {
+ .media-grid-view .media-frame-title {
+ display: block;
+ width: auto;
+ bottom: auto;
+ right: 0;
+ top: 0;
+ height: 60px;
+ }
+}
Index: /trunk/src/wp-includes/js/media-models.js
===================================================================
--- /trunk/src/wp-includes/js/media-models.js (revision 28681)
+++ /trunk/src/wp-includes/js/media-models.js (revision 28682)
@@ -31,4 +31,6 @@
} else if ( 'post' === attributes.frame && MediaFrame.Post ) {
frame = new MediaFrame.Post( attributes );
+ } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) {
+ frame = new MediaFrame.Manage( attributes );
} else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) {
frame = new MediaFrame.ImageDetails( attributes );
Index: /trunk/src/wp-includes/js/media-views.js
===================================================================
--- /trunk/src/wp-includes/js/media-views.js (revision 28681)
+++ /trunk/src/wp-includes/js/media-views.js (revision 28682)
@@ -616,5 +616,5 @@
this.get('selection').on( 'add remove reset', this.refreshContent, this );
- if ( this.get('contentUserSetting') ) {
+ if ( this.get( 'router' ) && this.get('contentUserSetting') ) {
this.frame.on( 'content:activate', this.saveContentMode, this );
this.set( 'content', getUserSetting( 'libraryContent', this.get('content') ) );
@@ -1919,4 +1919,158 @@
return this;
};
+ });
+
+ /**
+ * wp.media.view.MediaFrame.Manage
+ *
+ * A generic management frame workflow.
+ *
+ * Used in the media grid view.
+ *
+ * @constructor
+ * @augments wp.media.view.MediaFrame
+ * @augments wp.media.view.Frame
+ * @augments wp.media.View
+ * @augments wp.Backbone.View
+ * @augments Backbone.View
+ * @mixes wp.media.controller.StateMachine
+ */
+ media.view.MediaFrame.Manage = media.view.MediaFrame.extend({
+ /**
+ * @global wp.Uploader
+ */
+ initialize: function() {
+ _.defaults( this.options, {
+ title: l10n.mediaLibraryTitle,
+ modal: false,
+ selection: [],
+ library: {},
+ multiple: false,
+ state: 'library',
+ uploader: true
+ });
+
+ // Ensure core and media grid view UI is enabled.
+ this.$el.addClass('wp-core-ui media-grid-view');
+
+ // Force the uploader off if the upload limit has been exceeded or
+ // if the browser isn't supported.
+ if ( wp.Uploader.limitExceeded || ! wp.Uploader.browser.supported ) {
+ this.options.uploader = false;
+ }
+
+ // Initialize a window-wide uploader.
+ if ( this.options.uploader ) {
+ this.uploader = new media.view.UploaderWindow({
+ controller: this,
+ uploader: {
+ dropzone: $('body'),
+ container: $('body')
+ }
+ }).render();
+ this.uploader.ready();
+ $('body').append( this.uploader.el );
+
+ this.options.uploader = false;
+ }
+
+ /**
+ * call 'initialize' directly on the parent class
+ */
+ media.view.MediaFrame.prototype.initialize.apply( this, arguments );
+
+ // Since we're not using the default modal built into
+ // a media frame, append our $element to the supplied container.
+ this.$el.appendTo( this.options.container );
+
+ this.createSelection();
+ this.createStates();
+ this.bindHandlers();
+ this.render();
+ },
+
+ createSelection: function() {
+ var selection = this.options.selection;
+
+ if ( ! (selection instanceof media.model.Selection) ) {
+ this.options.selection = new media.model.Selection( selection, {
+ multiple: this.options.multiple
+ });
+ }
+
+ this._selection = {
+ attachments: new media.model.Attachments(),
+ difference: []
+ };
+ },
+
+ createStates: function() {
+ var options = this.options;
+
+ if ( this.options.states ) {
+ return;
+ }
+
+ // Add the default states.
+ this.states.add([
+ new media.controller.Library({
+ library: media.query( options.library ),
+ multiple: options.multiple,
+ title: options.title,
+ priority: 20,
+ toolbar: false,
+ router: false,
+ content: 'browse',
+ filterable: 'mime-types'
+ }),
+
+ new media.controller.EditImage( { model: options.editImage } )
+ ]);
+ },
+
+ bindHandlers: function() {
+ this.on( 'content:create:browse', this.browseContent, this );
+ this.on( 'content:render:edit-image', this.editImageContent, this );
+ },
+
+ /**
+ * Content
+ *
+ * @param {Object} content
+ * @this wp.media.controller.Region
+ */
+ browseContent: function( content ) {
+ var state = this.state();
+
+ // Browse our library of attachments.
+ content.view = new media.view.AttachmentsBrowser({
+ controller: this,
+ collection: state.get('library'),
+ selection: state.get('selection'),
+ model: state,
+ sortable: state.get('sortable'),
+ search: state.get('searchable'),
+ filters: state.get('filterable'),
+ display: state.get('displaySettings'),
+ dragInfo: state.get('dragInfo'),
+ bulkEdit: true,
+
+ suggestedWidth: state.get('suggestedWidth'),
+ suggestedHeight: state.get('suggestedHeight'),
+
+ AttachmentView: state.get('AttachmentView')
+ });
+ },
+
+ editImageContent: function() {
+ var image = this.state().get('image'),
+ view = new media.view.EditImage( { model: image, controller: this } ).render();
+
+ this.content.set( view );
+
+ // after creating the wrapper view, load the actual editor via an ajax call
+ view.loadEditor();
+
+ },
});
@@ -5364,4 +5518,43 @@
});
+ /**
+ * wp.media.view.AttachmentFilters.FileTypes
+ *
+ * @constructor
+ * @augments wp.media.view.AttachmentFilters
+ * @augments wp.media.View
+ * @augments wp.Backbone.View
+ * @augments Backbone.View
+ */
+ media.view.AttachmentFilters.mimeTypes = media.view.AttachmentFilters.extend({
+ createFilters: function() {
+ var filters = {};
+
+ _.each( media.view.settings.mimeTypes || {}, function( text, key ) {
+ filters[ key ] = {
+ text: text,
+ props: {
+ type: key,
+ uploadedTo: null,
+ orderby: 'date',
+ order: 'DESC'
+ }
+ };
+ });
+ filters.all = {
+ text: l10n.allMediaTypes,
+ props: {
+ type: null,
+ uploadedTo: null,
+ orderby: 'date',
+ order: 'DESC'
+ },
+ priority: 10
+ };
+
+ this.filters = filters;
+ }
+ });
+
/**
@@ -5418,4 +5611,6 @@
} else if ( 'all' === filters ) {
FiltersConstructor = media.view.AttachmentFilters.All;
+ } else if ( 'mime-types' === filters ) {
+ FiltersConstructor = media.view.AttachmentFilters.mimeTypes;
}
Index: /trunk/src/wp-includes/media-template.php
===================================================================
--- /trunk/src/wp-includes/media-template.php (revision 28681)
+++ /trunk/src/wp-includes/media-template.php (revision 28682)
@@ -309,4 +309,5 @@
{{ data.dateFormatted }}
+ {{ data.filesizeHumanReadable }}
<# if ( 'image' === data.type && ! data.uploading ) { #>
<# if ( data.width && data.height ) { #>
@@ -340,23 +341,37 @@
+
<# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #>
-
-
+
+
<# if ( 'image' === data.type ) { #>
<# } #>
-