From 18ec15e80763e48d7575cdfc1e89d9bb522c0782 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Thu, 22 Oct 2009 05:55:00 +0000 Subject: [PATCH] tag MDL-16704 Fixed autocomplete of tags by reorganising the div nesting and upgrading the deprecated YUI calls --- tag/edit_form.php | 4 ++-- tag/tag.js | 34 ++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tag/edit_form.php b/tag/edit_form.php index 5aaec36198..8e781a580d 100644 --- a/tag/edit_form.php +++ b/tag/edit_form.php @@ -1,4 +1,4 @@ -dirroot.'/lib/formslib.php'); @@ -31,8 +31,8 @@ class tag_edit_form extends moodleform { $mform->addElement('html', '
'); $mform->addElement('textarea', 'relatedtags', get_string('relatedtags','tag'), 'cols="50" rows="3"'); $mform->setType('relatedtags', PARAM_TAGLIST); - $mform->addElement('html', '
'); $mform->addElement('html', '
'); + $mform->addElement('html', ''); $this->add_action_buttons(false, get_string('updatetag', 'tag')); diff --git a/tag/tag.js b/tag/tag.js index 6aff427421..0031dce0e1 100644 --- a/tag/tag.js +++ b/tag/tag.js @@ -2,21 +2,31 @@ var coursetagdivs = null; var coursetag_tags = new Array(); function init_tag_autocomplete() { - // An XHR DataSource - var myServer = "./tag_autocomplete.php"; - var myDataSource = new YAHOO.widget.DS_XHR(myServer, ["\n", "\t"]); - myDataSource.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT; + + var myDataSource = new YAHOO.util.XHRDataSource("./tag_autocomplete.php"); + myDataSource.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT; + myDataSource.responseSchema = { + recordDelim: "\n", + fieldDelim: "\t" + }; myDataSource.maxCacheEntries = 60; - myDataSource.queryMatchSubset = true; + myDataSource.minQueryLength = 3; - var myAutoComp = new YAHOO.widget.AutoComplete("id_relatedtags","relatedtags-autocomplete", myDataSource); - myAutoComp.delimChar = ","; - myAutoComp.maxResultsDisplayed = 20; - myAutoComp.minQueryLength = 2; + // Instantiate the AutoComplete + var myAutoComp = new YAHOO.widget.AutoComplete("id_relatedtags", "relatedtags-autocomplete", myDataSource); + document.getElementById('id_relatedtags').style.width = '30%'; myAutoComp.allowBrowserAutocomplete = false; - myAutoComp.formatResult = function(aResultItem, sQuery) { - return aResultItem[1]; - } + myAutoComp.maxResultsDisplayed = 20; + myAutoComp.delimChar = [","," "]; + myAutoComp.formatResult = function(oResultData, sQuery, sResultMatch) { + return (sResultMatch); + }; + + return { + myDataSource: myDataSource, + myAutoComp: myAutoComp + }; + } function ctags_checkinput(val) { -- 2.39.5