Ticket #5580: 5580.diff
| File 5580.diff, 4.7 KB (added by , 18 years ago) |
|---|
-
wp-includes/js/jquery/suggest.js
1 1 /* 2 * jquery.suggest 1.1 - 2007-08-06 2 * jquery.suggest 1.1b - 2007-08-06 3 * Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting 4 * See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228 3 5 * 4 6 * Uses code and techniques from following libraries: 5 7 * 1. http://www.dyve.net/jquery/?autocomplete … … 113 115 114 116 var q = $.trim($input.val()); 115 117 118 if ( options.multiple ) { 119 var multipleSepPos = q.lastIndexOf(options.multipleSep); 120 if ( multipleSepPos != -1 ) { 121 q = q.substr(multipleSepPos + options.multipleSep.length); 122 } 123 } 116 124 if (q.length >= options.minchars) { 117 125 118 126 cached = checkCache(q); … … 245 253 $currentResult = getCurrentResult(); 246 254 247 255 if ($currentResult) { 248 $input.val($currentResult.text()); 256 if ( options.multiple ) { 257 if ( $input.val().indexOf(options.multipleSep) != -1 ) { 258 $currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) ); 259 } else { 260 $currentVal = ""; 261 } 262 $input.val( $currentVal + $currentResult.text() + options.multipleSep); 263 $input.focus(); 264 } else { 265 $input.val($currentResult.text()); 266 } 249 267 $results.hide(); 250 268 251 269 if (options.onSelect) … … 291 309 return; 292 310 293 311 options = options || {}; 312 options.multiple = options.multiple || false; 313 options.multipleSep = options.multipleSep || ", "; 294 314 options.source = source; 295 315 options.delay = options.delay || 100; 296 316 options.resultsClass = options.resultsClass || 'ac_results'; -
wp-includes/script-loader.php
70 70 $scripts->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '2.02'); 71 71 $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.js', array('jquery'), '2.0-4561'); 72 72 $scripts->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2' ); 73 $scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1 ');73 $scripts->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('jquery'), '1.1b'); 74 74 $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); 75 75 $scripts->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1-20080430'); 76 76 $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.1.0'); … … 138 138 'save' => __('Save'), 139 139 'cancel' => __('Cancel'), 140 140 ) ); 141 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '2008062 3' );141 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080629' ); 142 142 $scripts->localize( 'post', 'postL10n', array( 143 143 'tagsUsed' => __('Tags used on this post:'), 144 144 'add' => attribute_escape(__('Add')), -
wp-admin/admin-ajax.php
13 13 14 14 $s = $_GET['q']; // is this slashed already? 15 15 16 if ( strstr( $s, ',' ) ) 17 die; // it's a multiple tag insert, we won't find anything 18 $results = $wpdb->get_col( $wpdb->prepare("SELECT name FROM $wpdb->terms WHERE name LIKE (%s)", '%' . $s . '%') ); 16 if ( strstr( $s, ',' ) ) { 17 $s = explode( ',', $s ); 18 $s = $s[count( $s ) - 1]; 19 } 20 $s = trim( $s ); 21 if ( strlen( $s ) < 2 ) 22 die; // require 2 chars for matching 23 $results = $wpdb->get_col( "SELECT name FROM $wpdb->terms WHERE name LIKE ('%". $s . "%')" ); 19 24 echo join( $results, "\n" ); 20 25 die; 21 26 } -
wp-admin/js/post.js
98 98 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 99 99 100 100 // auto-suggest stuff 101 jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } );101 jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); 102 102 jQuery('#newtag').keypress( tag_press_key ); 103 103 104 104 // category tabs