diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js index e39476c..3cd50a5 100644 --- a/core/misc/autocomplete.js +++ b/core/misc/autocomplete.js @@ -264,7 +264,7 @@ Drupal.ACDB = function (uri) { /** * Performs a cached and delayed search. */ -Drupal.ACDB.prototype.search = function (searchString, caretPosition) { +Drupal.ACDB.prototype.search = function (searchString, cursorPosition) { var db = this; this.searchString = searchString; @@ -290,7 +290,7 @@ Drupal.ACDB.prototype.search = function (searchString, caretPosition) { // Ajax GET request for autocompletion. $.ajax({ type: 'GET', - url: db.uri + '/' + encodeURIComponent(searchString) + '/' + caretPosition, + url: db.uri + '/' + encodeURIComponent(searchString) + '/' + cursorPosition, dataType: 'json', success: function (matches) { if (typeof matches.status == 'undefined' || matches.status != 0) { diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 31af8d0..24e5d0d 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -79,19 +79,19 @@ function taxonomy_term_feed($term) { /** * Helper function for autocompletion */ -function taxonomy_autocomplete($field_name, $tags_typed = '', $caret_position = 0) { +function taxonomy_autocomplete($field_name, $tags_typed = '', $cursor_position = 0) { $field = field_info_field($field_name); // The user enters a comma-separated list of tags. $tags_typed_array = drupal_explode_tags($tags_typed); - // Try to find the tag based on the current caret position. + // Try to find the tag based on the current cursor position. $tag_current = ''; $tag_positions = array_keys($tags_typed_array); $tag_positions[] = drupal_strlen($tags_typed) + 1; $position_last = -1; foreach ($tag_positions as $position) { - if ($caret_position >= $position_last && $caret_position < $position) { - // Tag found on caret position. + if ($cursor_position >= $position_last && $cursor_position < $position) { + // Tag found on cursor position. $tag_current = $tags_typed_array[$position_last]; break; } diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test index b6907df..86efa1a 100644 --- a/core/modules/taxonomy/taxonomy.test +++ b/core/modules/taxonomy/taxonomy.test @@ -632,30 +632,31 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { * Tests taxonomy term autocompletion functionality. */ function testTaxonomyAutocomplete() { - // Create taxonomy terms without comma. + // Create two taxonomy terms without commas. $term1 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary); - // Create taxonomy term with comma. + // Create a taxonomy term that contains a comma. $term3 = $this->createTerm($this->vocabulary, $this->randomName() . ', ' . $this->randomName()); - // Test autocomplete on term 1 - it is alphanumeric only, so no extra - // quoting. + // Test autocompletion of term 1. The term is alphanumeric only, so + // there is no extra quoting. $input = substr($term1->name, 0, 3); $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input); $this->assertRaw('{"' . $term1->name . '":"' . $term1->name . '"}', t('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term1->name))); - // Test autocomplete on term 3 - it contains a comma, so expect the key to - // be quoted. + // Test autocompletion of term 3. The term contains a comma, so expect + // the key to be quoted. $input = substr($term3->name, 0, 3); $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input); $this->assertRaw('{"\"' . $term3->name . '\"":"' . $term3->name . '"}', t('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term3->name))); - // Test autocomplete at specific position. + // Test autocompletion at a specific cursor position. $term1_name = substr($term1->name, 0, 3); $input = drupal_implode_tags(array($term1_name, $term2->name)); - // Call autocomplete with given input and set cursor after 3rd character. + // Retrieve the autocomplete callback results for the given input and set + // the cursor after the third character. $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input . '/3'); - // First term should be expanded and after second term. + // The first term should be completed and after the second term. $this->assertRaw('{"' . drupal_implode_tags(array($term2->name, $term1->name)) . '":"' . $term1->name . '"}', t('Autocomplete returns term %term1_name after %term2_name.', array('%term1_name' => $term1->name, '%term2_name' => $term2->name))); }