Ticket #34923: 34923.ui.0.diff
File 34923.ui.0.diff, 7.6 KB (added by , 9 years ago) |
---|
-
src/wp-admin/css/customize-nav-menus.css
479 479 color: #23282d; 480 480 } 481 481 482 #available-menu-items .a ccordion-section-content {482 #available-menu-items .available-menu-items-list { 483 483 overflow-y: auto; 484 484 max-height: 200px; /* This gets set in JS to fit the screen size, and based on # of sections. */ 485 485 background: transparent; … … 516 516 } 517 517 518 518 #available-menu-items .accordion-section-content { 519 padding: 1px 15px 15px 15px;519 max-height: 290px; 520 520 margin: 0; 521 max-height: 290px; 521 padding: 0; 522 position: relative; 523 background: transparent; 522 524 } 523 525 526 #available-menu-items .accordion-section-content .available-menu-items-list { 527 margin: 0 0 45px 0; 528 padding: 1px 15px 15px 15px; 529 } 530 531 #available-menu-items .accordion-section-content .available-menu-items-list:only-child { /* Types that do not support new items for the current user */ 532 margin-bottom: 0; 533 } 534 535 #new-custom-menu-item .accordion-section-content { 536 padding: 0 15px 15px 15px; 537 } 538 539 #available-menu-items .accordion-section-content .new-content-item { 540 width: calc(100% - 30px); 541 padding: 8px 15px; 542 position: absolute; 543 bottom: 0; 544 z-index: 10; 545 background: #eee; 546 } 547 548 #available-menu-items .new-content-item .add-content { 549 float: right; 550 padding-left: 6px; 551 } 552 553 #available-menu-items .new-content-item .add-content:before { 554 content: "\f543"; 555 font: 20px/16px dashicons; 556 position: relative; 557 display: inline-block; 558 top: 5px; 559 left: -2px; 560 } 561 524 562 #available-menu-items .menu-item-tpl { 525 563 margin: 0; 526 564 } -
src/wp-admin/js/customize-nav-menus.js
124 124 } 125 125 126 126 this.$search = $( '#menu-items-search' ); 127 this.sectionContent = this.$el.find( '.a ccordion-section-content' );127 this.sectionContent = this.$el.find( '.available-menu-items-list' ); 128 128 129 129 this.debounceSearch = _.debounce( self.search, 500 ); 130 130 … … 168 168 169 169 // Load more items. 170 170 this.sectionContent.scroll( function() { 171 var totalHeight = self.$el.find( '.accordion-section.open .a ccordion-section-content' ).prop( 'scrollHeight' ),171 var totalHeight = self.$el.find( '.accordion-section.open .available-menu-items-list' ).prop( 'scrollHeight' ), 172 172 visibleHeight = self.$el.find( '.accordion-section.open' ).height(); 173 173 174 174 if ( ! self.loading && $( this ).scrollTop() > 3 / 4 * totalHeight - visibleHeight ) { … … 349 349 } 350 350 items = new api.Menus.AvailableItemCollection( items ); // @todo Why is this collection created and then thrown away? 351 351 self.collection.add( items.models ); 352 typeInner = availableMenuItemContainer.find( '.a ccordion-section-content' );352 typeInner = availableMenuItemContainer.find( '.available-menu-items-list' ); 353 353 items.each(function( menuItem ) { 354 354 typeInner.append( itemTemplate( menuItem.attributes ) ); 355 355 }); … … 368 368 369 369 // Adjust the height of each section of items to fit the screen. 370 370 itemSectionHeight: function() { 371 var sections, totalHeight, accordionHeight, diff;371 var sections, lists, totalHeight, accordionHeight, diff, totalWidth, button, buttonWidth; 372 372 totalHeight = window.innerHeight; 373 373 sections = this.$el.find( '.accordion-section:not( #available-menu-items-search ) .accordion-section-content' ); 374 accordionHeight = 46 * ( 2 + sections.length ) - 13; // Magic numbers. 374 lists = this.$el.find( '.accordion-section:not( #available-menu-items-search ) .available-menu-items-list:not(":only-child")' ); 375 accordionHeight = 46 * ( 1 + sections.length ) + 14; // Magic numbers. 375 376 diff = totalHeight - accordionHeight; 376 377 if ( 120 < diff && 290 > diff ) { 377 378 sections.css( 'max-height', diff ); 379 lists.css( 'max-height', ( diff - 60 ) ); 378 380 } 381 // Fit the new-content input and button in the available space. 382 totalWidth = this.$el.width(); 383 // Clone button to get width of invisible element. 384 button = this.$el.find( '.accordion-section .new-content-item .add-content' ).first().clone().appendTo( 'body' ).css({ 'display': 'block', 'visibility': 'hidden' }); 385 buttonWidth = button.outerWidth(); 386 button.remove(); 387 this.$el.find( '.accordion-section .new-content-item .create-item-input' ).width( ( totalWidth - buttonWidth - 70 ) ); // 70 = additional margins and padding. 379 388 }, 380 389 381 390 // Highlights a menu item. -
src/wp-includes/class-wp-customize-nav-menus.php
763 763 <span class="spinner"></span> 764 764 <span class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></span> 765 765 </div> 766 <ul class="accordion-section-content " data-type="search"></ul>766 <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul> 767 767 </div> 768 768 <div id="new-custom-menu-item" class="accordion-section"> 769 769 <h4 class="accordion-section-title" role="presentation"> … … 792 792 </div> 793 793 </div> 794 794 <?php 795 // Containers for per-post-type item browsing; items added with JS. 795 /** 796 * Filter the content types that do not allow new items to be created from nav menus. 797 * 798 * Types are formated as 'post_type'|'taxonomy' _ post_type_name; for example, 'taxonomy_post_format'. 799 * 800 * @since 4.6.0 801 * 802 * @param array $types Array of disallowed types. 803 */ 804 $disallowed_new_content_types = apply_filters( 'customize_nav_menus_disallow_new_content_types', array( 'taxonomy_post_format' ) ); 805 806 // Containers for per-post-type item browsing; items are added with JS. 796 807 foreach ( $this->available_item_types() as $available_item_type ) { 797 808 $id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] ); 798 809 ?> … … 808 819 <span class="toggle-indicator" aria-hidden="true"></span> 809 820 </button> 810 821 </h4> 811 <ul class="accordion-section-content" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>"></ul> 822 <div class="accordion-section-content"> 823 <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>"></ul> 824 <?php if ( 'post_type' === $available_item_type['type'] ) { 825 $post_type = get_post_type_object( $available_item_type['object'] ); 826 $cap = $post_type->cap->publish_posts; 827 $label = $post_type->labels->singular_name; 828 } else { 829 $taxonomy = get_taxonomy( $available_item_type['object'] ); 830 $cap = $taxonomy->cap->manage_terms; 831 $label = $taxonomy->labels->singular_name; 832 } 833 if ( current_user_can( $cap ) && ! in_array( $available_item_type['type'] . '_' . $available_item_type['object'], $disallowed_new_content_types ) ) : ?> 834 <div class="new-content-item"> 835 <input type="text" class="create-item-input" placeholder="<?php 836 /* translators: %s: Singular title of post type or taxonomy */ 837 printf( __( 'Create New %s' ), $label ); ?>"> 838 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> 839 </div> 840 <?php endif; ?> 841 </div> 812 842 </div> 813 843 <?php 814 844 }