Changeset 31765
- Timestamp:
- 03/13/2015 04:56:45 PM (10 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/press-this.css
r31693 r31765 964 964 } 965 965 966 .categories-select input { 967 clear: none; 968 position: absolute; 969 top: 0; 970 left: 0; 966 .category { 967 position: relative; 971 968 display: block; 972 line-height: 0; 973 width: 100%; 974 height: 100%; 969 padding: 13px 16px 14px 16px; 970 cursor: pointer; 971 background: #fff; 972 } 973 974 .category:focus, 975 .category.selected:focus { 975 976 outline: 0; 976 padding: 0; 977 border: 0; 978 -webkit-border-radius: 0; 979 border-radius: 0; 980 text-align: center; 981 vertical-align: middle; 982 -webkit-appearance: none; 983 appearance: none; 984 cursor: pointer; 985 } 986 987 .categories-select input:checked { 977 background: #2ea2cc; 978 color: #fff; 979 } 980 981 .category.selected { 988 982 -webkit-box-shadow: inset 6px 0 0 #2ea2cc; 989 983 box-shadow: inset 6px 0 0 #2ea2cc; 990 background: rgba(46, 162, 204, 0.1);991 } 992 993 .categor ies-select input:checked:after {984 background: #E9F5F9; 985 } 986 987 .category.selected:after { 994 988 display: inline-block; 995 989 content: "\f147"; … … 1015 1009 } 1016 1010 1017 .categories-select input:focus { 1018 -webkit-box-shadow: inset 6px 0 0 #2ea2cc; 1019 box-shadow: inset 6px 0 0 #2ea2cc; 1020 background: rgba(46, 162, 204, 0.05); 1021 } 1022 1023 .categories-select label { 1024 position: relative; 1025 display: block; 1026 padding: 13px 16px 14px 16px; 1027 cursor: pointer; 1028 background: #fff; 1029 } 1030 1031 .categories-select ul label { 1011 .category.selected:focus:after { 1012 color: #fff; 1013 } 1014 1015 .categories-select ul .category { 1032 1016 padding-left: 24px; 1033 1017 } 1034 1018 1035 .categories-select ul ul label{1019 .categories-select ul ul .category { 1036 1020 padding-left: 32px; 1037 1021 } 1038 1022 1039 .categories-select ul ul ul label{1023 .categories-select ul ul ul .category { 1040 1024 padding-left: 40px; 1041 1025 } 1042 1026 1043 .categories-select ul ul ul ul label{1027 .categories-select ul ul ul ul .category { 1044 1028 padding-left: 48px; 1045 1029 } 1046 1030 1047 .categories-select ul ul ul ul ul label{1031 .categories-select ul ul ul ul ul .category { 1048 1032 padding-left: 56px; 1049 1033 } 1050 1034 1051 .categories-select ul ul ul ul ul ul label{1035 .categories-select ul ul ul ul ul ul .category { 1052 1036 padding-left: 64px; 1053 1037 } … … 1059 1043 .categories-select .is-hidden.searched-parent { 1060 1044 display: block; 1061 }1062 1063 .lt-ie9 .categories-select input {1064 top: 50%;1065 right: 10px;1066 left: auto;1067 margin-top: -8px;1068 width: 16px;1069 height: 16px;1070 }1071 1072 /* TODO Reformats checkbox on Firefox until we remove checkbox in merge */1073 @-moz-document url-prefix() {1074 .categories-select input {1075 top: 50%;1076 right: 10px;1077 left: auto;1078 margin-top: -8px;1079 width: 16px;1080 height: 16px;1081 }1082 1045 } 1083 1046 … … 1832 1795 -webkit-box-shadow: 5001px 5000px 0 5000px #fff, 5000px 5000px 0 5000px #e5e5e5; 1833 1796 box-shadow: 5001px 5000px 0 5000px #fff, 5000px 5000px 0 5000px #e5e5e5; 1797 outline: 0; 1834 1798 } 1835 1799 -
trunk/src/wp-admin/includes/class-wp-press-this.php
r31739 r31765 795 795 </div> 796 796 <ul class="categories-select" aria-label="<?php esc_attr_e( 'Categories' ); ?>"> 797 <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'category' ) ); ?>797 <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'category', 'list_only' => true ) ); ?> 798 798 </ul> 799 799 <?php -
trunk/src/wp-admin/includes/template.php
r31610 r31765 83 83 $name = 'tax_input[' . $taxonomy . ']'; 84 84 } 85 85 86 $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; 86 87 $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : ''; … … 89 90 90 91 /** This filter is documented in wp-includes/category-template.php */ 91 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . 92 '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . 93 checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) . 94 disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . 95 esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>'; 92 if ( ! empty( $args['list_only'] ) ) { 93 $aria_cheched = 'false'; 94 $inner_class = 'category'; 95 96 if ( in_array( $category->term_id, $args['selected_cats'] ) ) { 97 $inner_class .= ' selected'; 98 $aria_cheched = 'true'; 99 } 100 101 $output .= "\n" . '<li' . $class . '>' . 102 '<div class="' . $inner_class . '" data-term-id=' . $category->term_id . 103 ' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' . 104 esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>'; 105 } else { 106 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . 107 '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . 108 checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) . 109 disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . 110 esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>'; 111 } 96 112 } 97 113 … … 203 219 $tax = get_taxonomy( $taxonomy ); 204 220 $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); 221 222 $args['list_only'] = ! empty( $r['list_only'] ); 205 223 206 224 if ( is_array( $r['selected_cats'] ) ) { -
trunk/src/wp-admin/js/press-this.js
r31693 r31765 122 122 */ 123 123 function prepareFormData() { 124 var $form = $( '#pressthis-form' ), 125 $input = $( '<input type="hidden" name="post_category[]" value="">' ); 126 124 127 editor && editor.save(); 125 128 … … 132 135 } ); 133 136 } 137 138 // Get selected categories 139 $( '.categories-select .category' ).each( function( i, element ) { 140 var $cat = $( element ); 141 142 if ( $cat.hasClass( 'selected' ) ) { 143 // Have to append a node as we submit the actual form on preview 144 $form.append( $input.clone().val( $cat.attr( 'data-term-id' ) || '' ) ); 145 } 146 }); 134 147 } 135 148 … … 233 246 renderError( response.data.errorMessage ); 234 247 } else { 235 // TODO: change if/when the html changes.236 248 var $parent, $ul, 237 249 $wrap = $( 'ul.categories-select' ); 238 250 239 251 $.each( response.data, function( i, newCat ) { 240 var $node = $( '<li>' ).a ttr( 'id', 'category-' + newCat.term_id)241 .a ppend( $( '<label class="selectit">' ).text( newCat.name)242 .append( $( '<input type="checkbox" name="post_category[]" checked>' ).attr( 'value', newCat.term_id )) );243 252 var $node = $( '<li>' ).append( $( '<div class="category selected" tabindex="0" role="checkbox" aria-checked="true">' ) 253 .attr( 'data-term-id', newCat.term_id ) 254 .text( newCat.name ) ); 255 244 256 if ( newCat.parent ) { 245 257 if ( ! $ul || ! $ul.length ) { 246 $parent = $wrap.find( ' #category-' + newCat.parent);258 $parent = $wrap.find( 'div[data-term-id="' + newCat.parent + '"]' ).parent(); 247 259 $ul = $parent.find( 'ul.children:first' ); 248 260 … … 252 264 } 253 265 254 $ul.append( $node ); 255 // TODO: set focus on 266 $ul.prepend( $node ); 256 267 } else { 257 268 $wrap.prepend( $node ); 258 269 } 270 271 $node.focus(); 259 272 } ); 260 273 … … 510 523 } 511 524 525 function toggleCatItem( $element ) { 526 if ( $element.hasClass( 'selected' ) ) { 527 $element.removeClass( 'selected' ).attr( 'aria-checked', 'false' ); 528 } else { 529 $element.addClass( 'selected' ).attr( 'aria-checked', 'true' ); 530 } 531 } 532 533 function monitorCatList() { 534 $( '.categories-select' ).on( 'click.press-this keydown.press-this', function( event ) { 535 var $element = $( event.target ); 536 537 if ( $element.is( 'div.category' ) ) { 538 if ( event.type === 'keydown' && event.keyCode !== 32 ) { 539 return; 540 } 541 542 toggleCatItem( $element ); 543 event.preventDefault(); 544 } 545 }); 546 } 547 512 548 /* *************************************************************** 513 549 * PROCESSING FUNCTIONS … … 565 601 monitorOptionsModal(); 566 602 monitorPlaceholder(); 603 monitorCatList(); 567 604 568 605 $( '.options-open' ).on( 'click.press-this', openSidebar ); … … 642 679 node: $this, 643 680 parents: $this.parents( 'li' ), 644 text: $this.children( ' label' ).text().toLowerCase()681 text: $this.children( '.category' ).text().toLowerCase() 645 682 } ); 646 683 } );
Note: See TracChangeset
for help on using the changeset viewer.