tag MDL-16704 Fixed autocomplete of tags by reorganising the div nesting and upgrading the deprecated YUI calls

This commit is contained in:
samhemelryk
2009-10-22 05:55:00 +00:00
parent 1cc0286707
commit 18ec15e807
2 changed files with 25 additions and 15 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
<?php // $Id$
<?php
require_once($CFG->dirroot.'/lib/formslib.php');
@@ -31,8 +31,8 @@ class tag_edit_form extends moodleform {
$mform->addElement('html', '<br/><div id="relatedtags-autocomplete-container">');
$mform->addElement('textarea', 'relatedtags', get_string('relatedtags','tag'), 'cols="50" rows="3"');
$mform->setType('relatedtags', PARAM_TAGLIST);
$mform->addElement('html', '</div>');
$mform->addElement('html', '<div id="relatedtags-autocomplete"></div>');
$mform->addElement('html', '</div>');
$this->add_action_buttons(false, get_string('updatetag', 'tag'));
+23 -13
View File
@@ -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;
myDataSource.maxCacheEntries = 60;
myDataSource.queryMatchSubset = true;
var myAutoComp = new YAHOO.widget.AutoComplete("id_relatedtags","relatedtags-autocomplete", myDataSource);
myAutoComp.delimChar = ",";
myAutoComp.maxResultsDisplayed = 20;
myAutoComp.minQueryLength = 2;
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.minQueryLength = 3;
// 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) {