Changeset 28682
- Timestamp:
- 06/05/2014 10:00:24 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/list-tables.css
r27956 r28682 635 635 .view-switch > a:before { 636 636 color: #bbb; 637 content: '\f163';638 637 display: inline-block; 639 638 float: left; … … 646 645 } 647 646 647 .view-switch > .view-list:before { 648 content: '\f163'; 649 } 650 648 651 .view-switch a:hover:before { 649 652 color: #727272; … … 654 657 } 655 658 656 .view-switch > a + a :before{659 .view-switch > a + a { 657 660 margin-left: 5px; 661 } 662 663 .view-switch > .view-excerpt:before { 658 664 content: '\f164'; 665 } 666 667 .view-switch > .view-grid:before { 668 content: '\f180'; 659 669 } 660 670 -
trunk/src/wp-admin/includes/class-wp-list-table.php
r28524 r28682 494 494 <?php 495 495 foreach ( $modes as $mode => $title ) { 496 $class = ( $current_mode == $mode ) ? 'class="current"' : ''; 497 echo "<a href='" . esc_url( add_query_arg( 'mode', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n"; 496 $classes = array( 'view-' . $mode ); 497 if ( $current_mode == $mode ) 498 $classes[] = 'current'; 499 printf( 500 "<a href='%s' class='%s'><img id='view-switch-$mode' src='%s' width='20' height='20' title='%s' alt='%s' /></a>\n", 501 esc_url( add_query_arg( 'mode', $mode ) ), 502 implode( ' ', $classes ), 503 esc_url( includes_url( 'images/blank.gif' ) ), 504 $title, 505 $title 506 ); 498 507 } 499 508 ?> -
trunk/src/wp-admin/includes/class-wp-media-list-table.php
r28553 r28682 24 24 25 25 public function prepare_items() { 26 global $lost, $wp_query, $post_mime_types, $avail_post_mime_types ;26 global $lost, $wp_query, $post_mime_types, $avail_post_mime_types, $mode; 27 27 28 28 $q = $_REQUEST; … … 34 34 35 35 $this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status']; 36 37 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; 36 38 37 39 $this->set_pagination_args( array( … … 124 126 public function no_items() { 125 127 _e( 'No media attachments found.' ); 128 } 129 130 protected function pagination( $which ) { 131 global $mode; 132 133 parent::pagination( $which ); 134 135 $this->view_switcher( $mode ); 136 } 137 138 /** 139 * Display a view switcher 140 * 141 * @since 3.1.0 142 * @access protected 143 */ 144 protected function view_switcher( $current_mode ) { 145 $modes = array( 146 'list' => __( 'List View' ), 147 'grid' => __( 'Grid View' ) 148 ); 149 150 ?> 151 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> 152 <div class="view-switch"> 153 <?php 154 foreach ( $modes as $mode => $title ) { 155 $classes = array( 'view-' . $mode ); 156 if ( $current_mode == $mode ) 157 $classes[] = 'current'; 158 printf( 159 "<a href='%s' class='%s'><img id='view-switch-$mode' src='%s' width='20' height='20' title='%s' alt='%s' /></a>\n", 160 esc_url( add_query_arg( 'mode', $mode ) ), 161 implode( ' ', $classes ), 162 esc_url( includes_url( 'images/blank.gif' ) ), 163 $title, 164 $title 165 166 ); 167 } 168 ?> 169 </div> 170 <?php 126 171 } 127 172 -
trunk/src/wp-admin/js/media.js
r27403 r28682 73 73 74 74 $( document ).ready( function() { 75 // Open up a manage media frame into the grid. 76 wp.media && wp.media({ 77 frame: 'manage', 78 container: $('#wpbody-content') 79 }).open(); 80 75 81 $( '#find-posts-submit' ).click( function( event ) { 76 82 if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length ) -
trunk/src/wp-admin/upload.php
r27469 r28682 12 12 if ( !current_user_can('upload_files') ) 13 13 wp_die( __( 'You do not have permission to upload files.' ) ); 14 15 $mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; 16 $modes = array( 'grid', 'list' ); 17 18 if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes ) ) { 19 $mode = $_GET['mode']; 20 update_user_option( get_current_user_id(), 'media_library_mode', $mode ); 21 } 22 23 if ( 'grid' === $mode ) { 24 wp_enqueue_media(); 25 wp_enqueue_script( 'media' ); 26 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 27 ?><div class="view-switch media-grid-view-switch"> 28 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-list"> 29 <img id="view-switch-list" src="<?php echo includes_url( 'images/blank.gif' ) ?>" width="20" height="20" title="List View" alt="List View"/> 30 </a> 31 <a href="<?php echo esc_url( add_query_arg( 'mode', 'grid', $_SERVER['REQUEST_URI'] ) ) ?>" class="view-grid current"> 32 <img id="view-switch-excerpt" src="<?php echo includes_url( 'images/blank.gif' ) ?>" width="20" height="20" title="Grid View" alt="Grid View"/> 33 </a> 34 </div><?php 35 include( ABSPATH . 'wp-admin/admin-footer.php' ); 36 exit; 37 } 14 38 15 39 $wp_list_table = _get_list_table('WP_Media_List_Table'); … … 238 262 239 263 <div id="ajax-response"></div> 240 <?php find_posts_div(); ?> 264 <?php find_posts_div(); ?> 241 265 </form> 242 266 </div> -
trunk/src/wp-includes/css/media-views.css
r28607 r28682 296 296 } 297 297 298 .media-sidebar .setting span{298 .media-sidebar .setting .name { 299 299 min-width: 30%; 300 300 margin-right: 4%; 301 301 font-size: 12px; 302 text-align: right; 302 303 } 303 304 … … 320 321 padding-top: 8px; 321 322 line-height: 16px; 322 text-align: right;323 323 font-weight: normal; 324 324 color: #666; 325 325 } 326 326 327 .compat-item label span { 328 text-align: right; 329 } 330 327 331 .media-sidebar .setting input, 328 .media-sidebar .setting textarea { 332 .media-sidebar .setting textarea, 333 .media-sidebar .setting .value { 329 334 margin: 1px; 330 335 width: 65%; … … 1813 1818 } 1814 1819 1815 .image-details .embed-media-settings .setting span{1820 .image-details .embed-media-settings .setting .name { 1816 1821 float: left; 1817 1822 width: 25%; … … 2369 2374 } 2370 2375 } 2376 2377 2378 /** 2379 * Media Grid 2380 */ 2381 2382 .media-grid-view h1 { 2383 color: #222; 2384 font-size: 23px; 2385 font-weight: 400; 2386 margin: 10px 0 0; 2387 padding: 9px 15px 4px 22px; 2388 line-height: 29px; 2389 } 2390 2391 .media-grid-view-switch { 2392 position: fixed; 2393 right: 10px; 2394 top: 44px; 2395 z-index: 300; 2396 } 2397 2398 /** 2399 * Position both the frame and the uploader window into the content 2400 * area of the screen. 2401 */ 2402 .media-grid-view { 2403 position: fixed; 2404 bottom: 0; 2405 left: 160px; 2406 right: 0; 2407 top: 32px; 2408 } 2409 @media screen and (max-width: 900px) { 2410 .auto-fold .media-grid-view { 2411 left: 36px; 2412 } 2413 } 2414 @media screen and (max-width: 782px) { 2415 .media-grid-view { 2416 top: 46px; 2417 } 2418 .auto-fold .media-grid-view { 2419 left: 0px; 2420 bottom: 0px; 2421 } 2422 } 2423 2424 /* Regions we don't use at all */ 2425 .media-grid-view .media-frame-toolbar, 2426 .media-grid-view .media-frame-menu { 2427 display: none; 2428 } 2429 2430 .media-grid-view .media-frame-content { 2431 bottom: 40px; 2432 } 2433 @media screen and (max-width: 782px) { 2434 .media-grid-view .media-frame-content { 2435 border-bottom: none; 2436 bottom: 0; 2437 } 2438 } 2439 2440 @media only screen and (max-width: 640px), screen and (max-height: 400px) { 2441 .media-grid-view .media-frame-title { 2442 display: block; 2443 width: auto; 2444 bottom: auto; 2445 right: 0; 2446 top: 0; 2447 height: 60px; 2448 } 2449 } -
trunk/src/wp-includes/js/media-models.js
r28095 r28682 31 31 } else if ( 'post' === attributes.frame && MediaFrame.Post ) { 32 32 frame = new MediaFrame.Post( attributes ); 33 } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) { 34 frame = new MediaFrame.Manage( attributes ); 33 35 } else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) { 34 36 frame = new MediaFrame.ImageDetails( attributes ); -
trunk/src/wp-includes/js/media-views.js
r28675 r28682 616 616 this.get('selection').on( 'add remove reset', this.refreshContent, this ); 617 617 618 if ( this.get( 'contentUserSetting') ) {618 if ( this.get( 'router' ) && this.get('contentUserSetting') ) { 619 619 this.frame.on( 'content:activate', this.saveContentMode, this ); 620 620 this.set( 'content', getUserSetting( 'libraryContent', this.get('content') ) ); … … 1919 1919 return this; 1920 1920 }; 1921 }); 1922 1923 /** 1924 * wp.media.view.MediaFrame.Manage 1925 * 1926 * A generic management frame workflow. 1927 * 1928 * Used in the media grid view. 1929 * 1930 * @constructor 1931 * @augments wp.media.view.MediaFrame 1932 * @augments wp.media.view.Frame 1933 * @augments wp.media.View 1934 * @augments wp.Backbone.View 1935 * @augments Backbone.View 1936 * @mixes wp.media.controller.StateMachine 1937 */ 1938 media.view.MediaFrame.Manage = media.view.MediaFrame.extend({ 1939 /** 1940 * @global wp.Uploader 1941 */ 1942 initialize: function() { 1943 _.defaults( this.options, { 1944 title: l10n.mediaLibraryTitle, 1945 modal: false, 1946 selection: [], 1947 library: {}, 1948 multiple: false, 1949 state: 'library', 1950 uploader: true 1951 }); 1952 1953 // Ensure core and media grid view UI is enabled. 1954 this.$el.addClass('wp-core-ui media-grid-view'); 1955 1956 // Force the uploader off if the upload limit has been exceeded or 1957 // if the browser isn't supported. 1958 if ( wp.Uploader.limitExceeded || ! wp.Uploader.browser.supported ) { 1959 this.options.uploader = false; 1960 } 1961 1962 // Initialize a window-wide uploader. 1963 if ( this.options.uploader ) { 1964 this.uploader = new media.view.UploaderWindow({ 1965 controller: this, 1966 uploader: { 1967 dropzone: $('body'), 1968 container: $('body') 1969 } 1970 }).render(); 1971 this.uploader.ready(); 1972 $('body').append( this.uploader.el ); 1973 1974 this.options.uploader = false; 1975 } 1976 1977 /** 1978 * call 'initialize' directly on the parent class 1979 */ 1980 media.view.MediaFrame.prototype.initialize.apply( this, arguments ); 1981 1982 // Since we're not using the default modal built into 1983 // a media frame, append our $element to the supplied container. 1984 this.$el.appendTo( this.options.container ); 1985 1986 this.createSelection(); 1987 this.createStates(); 1988 this.bindHandlers(); 1989 this.render(); 1990 }, 1991 1992 createSelection: function() { 1993 var selection = this.options.selection; 1994 1995 if ( ! (selection instanceof media.model.Selection) ) { 1996 this.options.selection = new media.model.Selection( selection, { 1997 multiple: this.options.multiple 1998 }); 1999 } 2000 2001 this._selection = { 2002 attachments: new media.model.Attachments(), 2003 difference: [] 2004 }; 2005 }, 2006 2007 createStates: function() { 2008 var options = this.options; 2009 2010 if ( this.options.states ) { 2011 return; 2012 } 2013 2014 // Add the default states. 2015 this.states.add([ 2016 new media.controller.Library({ 2017 library: media.query( options.library ), 2018 multiple: options.multiple, 2019 title: options.title, 2020 priority: 20, 2021 toolbar: false, 2022 router: false, 2023 content: 'browse', 2024 filterable: 'mime-types' 2025 }), 2026 2027 new media.controller.EditImage( { model: options.editImage } ) 2028 ]); 2029 }, 2030 2031 bindHandlers: function() { 2032 this.on( 'content:create:browse', this.browseContent, this ); 2033 this.on( 'content:render:edit-image', this.editImageContent, this ); 2034 }, 2035 2036 /** 2037 * Content 2038 * 2039 * @param {Object} content 2040 * @this wp.media.controller.Region 2041 */ 2042 browseContent: function( content ) { 2043 var state = this.state(); 2044 2045 // Browse our library of attachments. 2046 content.view = new media.view.AttachmentsBrowser({ 2047 controller: this, 2048 collection: state.get('library'), 2049 selection: state.get('selection'), 2050 model: state, 2051 sortable: state.get('sortable'), 2052 search: state.get('searchable'), 2053 filters: state.get('filterable'), 2054 display: state.get('displaySettings'), 2055 dragInfo: state.get('dragInfo'), 2056 bulkEdit: true, 2057 2058 suggestedWidth: state.get('suggestedWidth'), 2059 suggestedHeight: state.get('suggestedHeight'), 2060 2061 AttachmentView: state.get('AttachmentView') 2062 }); 2063 }, 2064 2065 editImageContent: function() { 2066 var image = this.state().get('image'), 2067 view = new media.view.EditImage( { model: image, controller: this } ).render(); 2068 2069 this.content.set( view ); 2070 2071 // after creating the wrapper view, load the actual editor via an ajax call 2072 view.loadEditor(); 2073 2074 }, 1921 2075 }); 1922 2076 … … 5364 5518 }); 5365 5519 5520 /** 5521 * wp.media.view.AttachmentFilters.FileTypes 5522 * 5523 * @constructor 5524 * @augments wp.media.view.AttachmentFilters 5525 * @augments wp.media.View 5526 * @augments wp.Backbone.View 5527 * @augments Backbone.View 5528 */ 5529 media.view.AttachmentFilters.mimeTypes = media.view.AttachmentFilters.extend({ 5530 createFilters: function() { 5531 var filters = {}; 5532 5533 _.each( media.view.settings.mimeTypes || {}, function( text, key ) { 5534 filters[ key ] = { 5535 text: text, 5536 props: { 5537 type: key, 5538 uploadedTo: null, 5539 orderby: 'date', 5540 order: 'DESC' 5541 } 5542 }; 5543 }); 5544 filters.all = { 5545 text: l10n.allMediaTypes, 5546 props: { 5547 type: null, 5548 uploadedTo: null, 5549 orderby: 'date', 5550 order: 'DESC' 5551 }, 5552 priority: 10 5553 }; 5554 5555 this.filters = filters; 5556 } 5557 }); 5558 5366 5559 5367 5560 /** … … 5418 5611 } else if ( 'all' === filters ) { 5419 5612 FiltersConstructor = media.view.AttachmentFilters.All; 5613 } else if ( 'mime-types' === filters ) { 5614 FiltersConstructor = media.view.AttachmentFilters.mimeTypes; 5420 5615 } 5421 5616 -
trunk/src/wp-includes/media-template.php
r28607 r28682 309 309 <div class="uploaded">{{ data.dateFormatted }}</div> 310 310 311 <div class="file-size">{{ data.filesizeHumanReadable }}</div> 311 312 <# if ( 'image' === data.type && ! data.uploading ) { #> 312 313 <# if ( data.width && data.height ) { #> … … 340 341 </div> 341 342 343 <label class="setting" data-setting="url"> 344 <span class="name"><?php _e('URL'); ?></span> 345 <input type="text" value="{{ data.url }}" readonly /> 346 </label> 342 347 <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> 343 344 <span><?php _e('Title'); ?></span>345 346 347 348 <span><?php _e('Caption'); ?></span>349 350 348 <label class="setting" data-setting="title"> 349 <span class="name"><?php _e('Title'); ?></span> 350 <input type="text" value="{{ data.title }}" {{ maybeReadOnly }} /> 351 </label> 352 <label class="setting" data-setting="caption"> 353 <span class="name"><?php _e('Caption'); ?></span> 354 <textarea {{ maybeReadOnly }}>{{ data.caption }}</textarea> 355 </label> 351 356 <# if ( 'image' === data.type ) { #> 352 357 <label class="setting" data-setting="alt"> 353 <span ><?php _e('Alt Text'); ?></span>358 <span class="name"><?php _e('Alt Text'); ?></span> 354 359 <input type="text" value="{{ data.alt }}" {{ maybeReadOnly }} /> 355 360 </label> 356 361 <# } #> 357 <label class="setting" data-setting="description"> 358 <span><?php _e('Description'); ?></span> 359 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> 362 <label class="setting" data-setting="description"> 363 <span class="name"><?php _e('Description'); ?></span> 364 <textarea {{ maybeReadOnly }}>{{ data.description }}</textarea> 365 </label> 366 <label class="setting"> 367 <span class="name"><?php _e( 'Uploaded By' ); ?></span> 368 <span class="value">{{ data.authorName }}</span> 360 369 </label> 370 <# if ( data.uploadedTo ) { #> 371 <label class="setting"> 372 <span class="name"><?php _e('Uploaded To'); ?></span> 373 <span class="value"><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a></span> 374 </label> 375 <# } #> 361 376 </script> 362 377 -
trunk/src/wp-includes/media.php
r28653 r28682 2593 2593 ); 2594 2594 2595 $author = new WP_User( $attachment->post_author ); 2596 $response['authorName'] = $author->display_name; 2597 2598 if ( $attachment->post_parent ) { 2599 $post_parent = get_post( $attachment->post_parent ); 2600 $response['uploadedToLink'] = get_edit_post_link( $attachment->post_parent, 'raw' ); 2601 $response['uploadedToTitle'] = $post_parent->post_title ? $post_parent->post_title : __( '(No title)' ); 2602 } 2603 2604 $bytes = filesize( get_attached_file( $attachment->ID ) ); 2605 $response['filesizeInBytes'] = $bytes; 2606 $response['filesizeHumanReadable'] = size_format( $bytes ); 2607 2595 2608 if ( current_user_can( 'edit_post', $attachment->ID ) ) { 2596 2609 $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment->ID ); … … 2850 2863 'returnToLibrary' => __( '← Return to library' ), 2851 2864 'allMediaItems' => __( 'All media items' ), 2865 'allMediaTypes' => __( 'All media types' ), 2852 2866 'noItemsFound' => __( 'No items found.' ), 2853 2867 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ),
Note: See TracChangeset
for help on using the changeset viewer.