Ticket #6387: post-taxonomy-ui-r7493-2.patch
File post-taxonomy-ui-r7493-2.patch, 7.5 KB (added by , 17 years ago) |
---|
-
wp-admin/js/post.js
2 2 3 3 function new_tag_remove_tag() { 4 4 var id = jQuery( this ).attr( 'id' ); 5 var num = id.substr( 10 ); 6 var current_tags = jQuery( '#tags-input' ).val().split(','); 5 var num = id.split('-check-num-')[1]; 6 var obj = jQuery(this).parents('.tagsdiv'); 7 var current_tags = jQuery(obj).find( '.tags-input' ).val().split(','); 7 8 delete current_tags[num]; 8 9 var new_tags = []; 9 10 jQuery.each( current_tags, function( key, val ) { … … 11 12 new_tags = new_tags.concat( val ); 12 13 } 13 14 }); 14 jQuery( '#tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) );15 tag_update_quickclicks( );16 jQuery( '#newtag').focus();15 jQuery( obj ).find( '.tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) ); 16 tag_update_quickclicks(obj); 17 jQuery( obj ).find('input.newtag').focus(); 17 18 return false; 18 19 } 19 20 20 function tag_update_quickclicks( ) {21 var current_tags = jQuery( '#tags-input').val().split(',');22 jQuery( '#tagchecklist' ).empty();21 function tag_update_quickclicks(obj) { 22 var current_tags = jQuery(obj).find('.tags-input').val().split(','); 23 jQuery(obj).find( '.tagchecklist' ).empty(); 23 24 shown = false; 24 25 // jQuery.merge( current_tags, current_tags ); // this doesn't work anymore, need something to array_unique 25 26 jQuery.each( current_tags, function( key, val ) { 26 27 val = val.replace( /^\s+/, '' ).replace( /\s+$/, '' ); // trim 27 28 if ( !val.match(/^\s+$/) && '' != val ) { 28 txt = '<span><a id="tag-check-' + key + '" class="ntdelbutton">X</a> ' + val + '</span> '; 29 jQuery( '#tagchecklist' ).append( txt ); 30 jQuery( '#tag-check-' + key ).click( new_tag_remove_tag ); 29 var button_id = jQuery(obj).attr('id') + '-check-num-' + key; 30 txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> '; 31 jQuery(obj).find( '.tagchecklist' ).append( txt ); 32 jQuery( '#' + button_id ).click( new_tag_remove_tag ); 31 33 shown = true; 32 34 } 33 35 }); 34 36 if ( shown ) 35 jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );37 jQuery(obj).find( '.tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' ); 36 38 } 37 39 38 40 function tag_flush_to_text() { 39 var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val(); 41 obj = jQuery(this).parents('.tagsdiv'); 42 43 var newtags = jQuery(obj).find('.tags-input').val() + ',' + jQuery(obj).find('input.newtag').val(); 40 44 // massage 41 45 newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' ); 42 jQuery( '#tags-input').val( newtags );43 tag_update_quickclicks( );44 jQuery( '#newtag').val('');45 jQuery( '#newtag').focus();46 jQuery(obj).find('.tags-input').val( newtags ); 47 tag_update_quickclicks(obj); 48 jQuery(obj).find('input.newtag').val(''); 49 jQuery(obj).find('input.newtag').focus(); 46 50 return false; 47 51 } 48 52 49 53 function tag_save_on_publish() { 50 if ( jQuery('#newtag').val() != postL10n.addTag ) 51 tag_flush_to_text(); 54 jQuery('.tagsdiv').each( function(i) { 55 if ( jQuery(this).find('input.newtag').val() != postL10n.addTag ) 56 tag_flush_to_text(); 57 } ); 52 58 } 53 59 54 60 function tag_press_key( e ) { … … 58 64 } 59 65 } 60 66 61 jQuery(document).ready( function() { 62 // postboxes 63 add_postbox_toggles('post'); 64 65 // Editable slugs 66 make_slugedit_clickable(); 67 68 // hide advanced slug field 69 jQuery('#slugdiv').hide(); 70 71 jQuery('#tags-input').hide(); 72 tag_update_quickclicks(); 67 function tag_init() { 68 jQuery('.ajaxtag').show(); 69 jQuery('.tags-input').hide(); 70 jQuery('.tagsdiv').each( function(i) { 71 tag_update_quickclicks(this); 72 } ); 73 73 74 // add the quickadd form 74 jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); 75 jQuery('#tagadd').click( tag_flush_to_text ); 76 jQuery('#newtag').focus(function() { 75 jQuery('.ajaxtag input.tagadd').click( tag_flush_to_text ); 76 jQuery('.ajaxtag input.newtag').focus(function() { 77 77 if ( this.value == postL10n.addTag ) 78 78 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 79 79 }); 80 jQuery(' #newtag').blur(function() {80 jQuery('.ajaxtag input.newtag').blur(function() { 81 81 if ( this.value == '' ) 82 82 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 83 83 }); … … 86 86 jQuery('#publish').click( tag_save_on_publish ); 87 87 jQuery('#save-post').click( tag_save_on_publish ); 88 88 89 } 90 91 92 jQuery(document).ready( function() { 93 // postboxes 94 add_postbox_toggles('post'); 95 96 // Editable slugs 97 make_slugedit_clickable(); 98 99 // hide advanced slug field 100 jQuery('#slugdiv').hide(); 101 102 // prepare the tag UI 103 tag_init(); 104 89 105 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 90 106 91 107 // auto-suggest stuff -
wp-admin/edit-form-advanced.php
204 204 <?php echo $form_pingback ?> 205 205 <?php echo $form_prevstatus ?> 206 206 207 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> 208 <h3><?php _e('Tags'); ?></h3> 207 <?php 208 209 register_taxonomy( 'post_keyword', 'post' ); 210 register_taxonomy( 'post_place', 'post' ); 211 212 // all tag-style post taxonomies 213 foreach ( get_object_taxonomies('post') as $_tax ) { 214 if ( !is_taxonomy_hierarchical($_tax) ) { 215 // TODO: this requires plugins to supply their own get_foo_to_edit() function. 216 // It'd probably be neater to fetch them all automatically. 217 if ( $_tax == 'post_tag' ) { 218 $tags_to_edit = get_tags_to_edit( $post_ID ); 219 $input_name = 'tags_input'; 220 } 221 else { 222 $tags_to_edit = apply_filters('get_tax_to_edit', '', $post_ID, $_tax); 223 $input_name = "tax_input[{$_tax}]"; 224 } 225 226 ?> 227 <div id="tagsdiv-<?php echo $_tax; ?>" class="postbox tagsdiv <?php echo postbox_classes('tagsdiv-'.$_tax, 'post'); ?>"> 228 <h3><?php _e($_tax); ?></h3> 209 229 <div class="inside"> 210 <p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></p> 211 <div id="tagchecklist"></div> 230 <p class="jaxtag"><input type="text" name="<?php echo $input_name; ?>" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo $tags_to_edit; ?>" /> 231 232 <span class="ajaxtag" style="display:none;"><input type="text" name="newtag[]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php _e('Add new tag'); ?>" /><input type="button" class="button tagadd" value="<?php _e('Add'); ?>" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto"><?php _e('Separate tags with commas'); ?></span></span> 233 234 </p> 235 <div class="tagchecklist"></div> 212 236 </div> 213 237 </div> 238 <? 239 } 240 } 214 241 242 ?> 243 215 244 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> 216 245 <h3><?php _e('Categories') ?></h3> 217 246 <div class="inside">