/** * Class constructor * * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @return void */ function HTML_QuickForm_text($elementName = null, $elementLabel = null, $attributes = null) { //HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); new HTML_QuickForm_input($elementName, $elementLabel, $attributes); self::$_persistantFreeze = true; self::setType('text'); }
/** * @return string */ public function toHtml() { $js = $this->getElementJS(); $this->removeAttribute('format'); $this->removeAttribute('timepicker'); $this->removeAttribute('validate_format'); return $js . parent::toHtml(); }
function toHtml() { if ($this->_hiddenLabel) { $this->_generateId(); return '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml(); } else { return parent::toHtml(); } }
/** * @param string $elementName * @param string $elementLabel * @param array $attributes */ public function DatePicker($elementName = null, $elementLabel = null, $attributes = null) { if (!isset($attributes['id'])) { $attributes['id'] = $elementName; } $attributes['class'] = 'form-control'; parent::__construct($elementName, $elementLabel, $attributes); $this->_appendName = true; $this->_type = 'date_picker'; }
/** * Constructor of Url class * @param type $elementName * @param type $elementLabel * @param type $attributes */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { if (!isset($attributes['id'])) { $attributes['id'] = $elementName; } $attributes['type'] = 'url'; $attributes['class'] = 'form-control'; parent::__construct($elementName, $elementLabel, $attributes); $this->setType('url'); }
function toHtml() { $oldFrozen = $this->_flagFrozen; $this->_flagFrozen = 0; if (intval($oldFrozen) !== 0) { $this->updateAttributes(array('data-depselect-frozen' => '1')); } $out = parent::toHtml(); $this->_flagFrozen = $oldFrozen; return $out; }
/** * Returns the textarea element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { ob_start(); if (!defined('HTML_QuickForm_yui_autocomplete_js_loaded')) { // Load the javascript files if they haven't been loaded yet define('HTML_QuickForm_yui_autocomplete_js_loaded', true); $yahoo_dom_event_src = DATAFACE_URL . '/HTML/QuickForm/yui_autocomplete/yahoo-dom-event.js'; $autocomplete_src = DATAFACE_URL . '/HTML/QuickForm/yui_autocomplete/autocomplete-min.js'; $df_autocomplete_src = DATAFACE_URL . '/HTML/QuickForm/yui_autocomplete/df_yui_autocomplete.js'; echo <<<END \t\t\t\t<script type="text/javascript" src="{$yahoo_dom_event_src}"></script> END; if (isset($this->datasourceUrl)) { // Since a datasource URL has been provided, we must be using // AJAX for autocompletion $xhr_src = DATAFACE_URL . '/HTML/QuickForm/yui_autocomplete/connection-min.js'; echo <<<END \t\t\t\t\t<script type="text/javascript" src="{$xhr_src}"></script> END; } echo <<<END \t\t\t\t<script type="text/javascript" src="{$autocomplete_src}"></script> \t\t\t\t<script language="javascript" src="{$df_autocomplete_src}"></script> END; } if ($this->vocabularyName and !defined('HTML_QuickForm_yui_autocomplete_js_valuelists_' . $this->vocabularyName . '_loaded')) { define('HTML_QuickForm_yui_autocomplete_js_valuelists_' . $this->vocabularyName . '_loaded', 1); // We must be using in-memory arrays for the vocabulary import('Services/JSON.php'); $json = new Services_JSON(); $js_options = $json->encode(array_values($this->options)); $valuelistName = $this->vocabularyName; echo <<<END \t\t\t<script language="javascript"> \t\t\tif ( !window.DATAFACE ) window.DATAFACE = {}; \t\t\tif ( window.DATAFACE.VALUELISTS == null) window.DATAFACE.VALUELISTS = {}; \t\t\tif ( window.DATAFACE.VALUELISTS['{$valuelistName}'] == null ) window.DATAFACE.VALUELISTS['{$valuelistName}'] = {$js_options}; \t\t\t</script> END; } echo '<div>' . parent::toHtml() . '</div>'; $out = ob_get_contents(); ob_end_clean(); return $out; } }
function HTML_QuickForm_calendar($elementName = null, $elementLabel = null, $attributes = null, $properties = null) { parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); $this->_type = 'calendar'; // Default language is english if (!@$properties['lang']) { $properties['lang'] = 'en'; } // Default theme is windows 2k. This is the name of a css file (without the .css extension) if (!@$properties['theme']) { $properties['theme'] = 'calendar-win2k-2'; } // Whether to load the stripped javascript files (i.e., the versions with spaces and whitespace stripped out). // for faster loading if (!isset($properties['stripped'])) { $properties['stripped'] = false; } // Default show Monday first (first day = 1) if (!isset($properties['firstDay'])) { $properties['firstDay'] = 1; } // Whether or not to show the time also if (!isset($properties['showsTime'])) { $properties['showsTime'] = true; } // Whether or not to show others (not sure what this means ... check jscalendar docs if (!isset($properties['showOthers'])) { $properties['showOthers'] = true; } // The Format to be placed in the input field. if (!isset($properties['ifFormat'])) { $properties['ifFormat'] = '%Y-%m-%d %I:%M %P'; } // The time format if (!isset($properties['timeFormat'])) { $properties['timeFormat'] = '12'; } foreach (array_keys($properties) as $key) { $this->setProperty($key, $properties[$key]); } $this->calendar = new DHTML_Calendar($GLOBALS['HTML_QuickForm_calendar']['jscalendar_BasePath'], $this->getProperty('lang'), $this->getProperty('theme'), $this->getProperty('stripped')); }
/** * Returns HTML for this form element. * * @return string */ function toHtml() { global $CFG, $COURSE, $USER, $PAGE, $OUTPUT; $id = $this->_attributes['id']; $elname = $this->_attributes['name']; if ($this->_hiddenLabel) { $this->_generateId(); $str = '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml(); } else { $str = parent::toHtml(); } if (empty($this->_options['usefilepicker'])) { return $str; } $strsaved = get_string('filesaved', 'repository'); $straddlink = get_string('choosealink', 'repository'); if ($COURSE->id == SITEID) { $context = context_system::instance(); } else { $context = context_course::instance($COURSE->id); } $client_id = uniqid(); $str .= <<<EOD <button id="filepicker-button-{$client_id}" style="display:none"> {$straddlink} </button> EOD; $args = new stdClass(); $args->accepted_types = '*'; $args->return_types = FILE_EXTERNAL; $args->context = $PAGE->context; $args->client_id = $client_id; $args->env = 'url'; $fp = new file_picker($args); $options = $fp->options; // print out file picker $str .= $OUTPUT->render($fp); $module = array('name' => 'form_url', 'fullpath' => '/lib/form/url.js', 'requires' => array('core_filepicker')); $PAGE->requires->js_init_call('M.form_url.init', array($options), true, $module); $PAGE->requires->js_function_call('show_item', array('filepicker-button-' . $client_id)); return $str; }
/** * HTML code to display this datepicker * * @return string */ public function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } $id = $this->getAttribute('id'); $value = $this->getValue(); if (!empty($value)) { $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H); } if (empty($this->getLabel())) { return $this->getElementJS() . ' <div class="input-group"> <span class="input-group-addon"> <input ' . $this->_getAttrString($this->_attributes) . '> </span> <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '"> </div> '; } return $this->getElementJS() . parent::toHtml(); }
/** * Returns HTML for this form element. * * @return string */ function toHtml() { global $PAGE, $OUTPUT; $id = $this->_attributes['id']; $elname = $this->_attributes['name']; if ($this->_hiddenLabel) { $this->_generateId(); $str = '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml(); } else { $str = parent::toHtml(); } if (empty($this->_options['usefilepicker'])) { return $str; } $client_id = uniqid(); $args = new stdClass(); $args->accepted_types = '*'; $args->return_types = FILE_EXTERNAL; $args->context = $PAGE->context; $args->client_id = $client_id; $args->env = 'url'; $fp = new file_picker($args); $options = $fp->options; if (count($options->repositories) > 0) { $straddlink = get_string('choosealink', 'repository'); $str .= <<<EOD <button id="filepicker-button-{$client_id}" class="visibleifjs"> {$straddlink} </button> EOD; } // print out file picker $str .= $OUTPUT->render($fp); $module = array('name' => 'form_url', 'fullpath' => '/lib/form/url.js', 'requires' => array('core_filepicker')); $PAGE->requires->js_init_call('M.form_url.init', array($options), true, $module); return $str; }
/** * Returns the element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); } $html = ''; $id = $this->getAttribute('id'); if (!$id) { $this->setAttribute('id', $this->getName()); $id = $this->getName(); } $value = $this->getAttribute('value'); if (!$id) { $value = '#ddd'; } if (!defined('HTML_QUICKFORM_colorpicker_LOADED')) { $html = " <input type=\"button\" value=\"\" "; $html .= sprintf('style="background-color:%s;border:1px solid #000;' . 'padding:0px;width:20px;cursor:pointer" id="%s_trigger"/>', $value, $id); if (isset($this->_options['jsFile'])) { $html .= sprintf("\n<script type=\"text/javascript\" src=\"%s\"></script>", $this->_options['jsFile']); } if (isset($this->_options['cssFile'])) { $html .= sprintf("\n<style type=\"text/css\">@import \"%s\";</style>", $this->_options['cssFile']); } $html .= sprintf("\n<script type=\"text/javascript\">\n" . "//<![CDATA[\n" . "connect(window, 'onload', function() { if(\$('%s')) " . "attachColorPicker(\$('%s'), \$('%s_trigger'), false); });\n" . "//]]>\n" . "</script>\n", $id, $id, $id); define('HTML_QUICKFORM_colorpicker_LOADED', true); } $html = parent::toHtml() . $html; return $html; }
/** * Returns Html for the LiveSearch_Select input text element * * @access public * @return string */ function toHtml() { $this->realName = $this->getName(); $liveform = ''; $scriptLoad = ''; $style = 'display: block;'; $divstyle = ' class="divstyle" '; $ulstyle = ' class="ulstyle" '; $listyle = ' class="listyle" '; $zeroLength = 0; $printStyle = 1; $this->updateAttributes(array('name' => $this->getPrivateName($this->realName))); if (isset($this->_options['style']) and $this->_options['style'] != '') { $style = $this->_options['style']; } if (isset($this->_options['divstyle']) and $this->_options['divstyle'] != '') { $divstyle = ' class="' . $this->_options['divstyle'] . '" '; } if (isset($this->_options['ulstyle']) and $this->_options['ulstyle'] != '') { $ulstyle = ' class="' . $this->_options['ulstyle'] . '" '; } if (isset($this->_options['listyle']) and $this->_options['listyle'] != '') { $listyle = ' class="' . $this->_options['listyle'] . '" '; } if (isset($this->_options['searchZeroLength']) and $this->_options['searchZeroLength'] == 1) { $zeroLength = 1; } else { $zeroLength = 0; } if (isset($this->_options['printStyle']) and $this->_options['printStyle'] != 1) { $printStyle = 0; } if (isset($this->_options['autoserverPath']) and $this->_options['autoserverPath'] != '') { $autoserverPath = $this->_options['autoserverPath']; } else { $autoserverPath = ''; } if (isset($this->_options['autoComplete']) and $this->_options['autoComplete'] != 0) { $this->updateAttributes(array('autocomplete' => 'off')); } $this->updateAttributes(array('onkeyup' => 'javascript:liveSearchKeyPress(this, event, \'' . $this->getName() . 'Result\', \'target_' . $this->_options['elementId'] . '\', \'' . $this->_options['elementId'] . '\', \'' . $this->realName . '\', ' . $zeroLength . ');', 'onblur' => 'javascript:liveSearchHide(\'' . $this->getName() . 'Result\');', 'id' => $this->_options['elementId'], 'style' => $style)); if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $liveform .= ' <div' . $divstyle . 'id="' . $this->getName() . 'Result"> <ul' . $ulstyle . 'id="target_' . $this->_options['elementId'] . '"> <li' . $listyle . '> </li> </ul> </div>'; if (!defined('HTML_QUICKFORM_LIVESEARCH_EXISTS')) { if ($printStyle != 0) { $scriptLoad = <<<EOS <style type="text/css"> <!-- .divstyle { position: absolute; background-color: #aaa; z-index: 1; min-width: 140px; float:left; clear:left; background: url(shadowAlpha.png) no-repeat bottom right !important; background: url(shadow.gif) no-repeat bottom right; margin: 10px 0 10px 10px !important; padding: 0px; display: none; } * html .divstyle { width: 140px;} .ulstyle { list-style-type: none; position: relative; right: 0px; z-index: 1; margin: 0px; padding: 0px; } .listyle { text-indent: -20px; z-index: 1; padding-right: 15px; padding-bottom: 2px; padding-top: 2px; padding-left: 20px; line-height:15px; margin-bottom: 0px; } .outerUl { list-style-type: none; position: relative; z-index: 1; background-color: #FFFFFF; color: inherit; bottom:6px; right: 6px; border: 1px solid #999999; text-indent: -20px; margin: 0px; padding: 0px; } .outerLi { text-indent: -20px; z-index: 1; padding: 2px 15px 2px 20px; line-height:15px; margin-bottom: 0px; } // --> </style> EOS; } $scriptLoad .= <<<EOS <script type='text/javascript' src="{$autoserverPath}auto_server.php?client=Util,main,dispatcher,httpclient,request,json,loading,queues,QfLiveSearch&stub=livesearch"></script> <script type='text/javascript'>//<![CDATA[ callback = {}; function searchRequest(searchBox, callfunc) { eval("remoteLiveSearch."+callfunc+"(searchBox.value)"); } //]]> </script> EOS; define('HTML_QUICKFORM_LIVESEARCH_EXISTS', true); } $scriptLoad .= ' <script type="text/javascript">//<![CDATA[ callback.' . $this->_options['elementId'] . ' = function(result) { var res = document.getElementById(\'' . $this->getName() . 'Result\'); res.style.display = "block"; var out = "<ul class=\\"outerUl\\" >"; for(var i in result) { if (i != \'______array\') { out += "<li class=\\"outerLi\\"><a href=\\"#\\" value=\\""+i+"\\" text=\\""+result[i]+"\\" onmouseover=\\"liveSearchHover(this);\\" onmousedown=\\"liveSearchClicked(this.getAttribute(\'value\'), this.getAttribute(\'text\'), \'' . $this->_options['elementId'] . '\', \'' . $this->realName . '\');\\">"+result[i]+"<\\/a><\\/li>"; } } out += "<\\/ul>"; document.getElementById(\'target_' . $this->_options['elementId'] . '\').innerHTML = out; } //]]> </script> '; if (!defined('HTML_QUICKFORM_JS_INIT_EXISTS')) { $scriptLoad .= ' <script type="text/javascript">//<![CDATA[ var remoteLiveSearch = new livesearch(callback); remoteLiveSearch.dispatcher.queue = \'rls\'; HTML_AJAX.queues[\'rls\'] = new HTML_AJAX_Queue_Interval_SingleBuffer(' . (int) $this->_options['buffer'] . '); //]]> </script> '; define('HTML_QUICKFORM_JS_INIT_EXISTS', true); } $scriptLoad .= ' <input type="hidden" name="' . $this->realName . '" id="' . $this->realName . '" value="' . $this->_hidden_value . '" />' . "\n"; } return $scriptLoad . parent::toHtml() . $liveform; }
/** * Returns the textarea element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { $out = ''; if (!defined('HTML_QuickForm_lookup_files_loaded')) { define('HTML_QuickForm_lookup_files_loaded', 1); $jt = Dataface_JavascriptTool::getInstance(); $jt->import('xataface/widgets/lookup.js'); } $properties = $this->getProperties(); if ($this->_flagFrozen) { $properties['frozen'] = 1; } if (!isset($properties['callback'])) { $properties['callback'] = 'function(out){}'; } ob_start(); $oldFrozen = $this->_flagFrozen; $this->_flagFrozen = 0; $this->updateAttributes(array('data-xf-lookup-options' => json_encode($properties))); echo parent::toHtml(); $this->_flagFrozen = $oldFrozen; $out .= ob_get_contents(); ob_end_clean(); $selector = null; if ($this->getName()) { $selector = "input[name='" . $this->getName() . "']"; } else { $selector = '.xf-lookup-' . $this->index_prefix . '-' . $this->index; } return '<span style="white-space:nowrap">' . $out . '</span>'; }
/** * Generates the HTML for this element * @global object $PAGE Moodle page object for fetching renderer * @return string Generated HTML * @version 2011070501 * @since 2011070501 */ public function toHtml() { global $PAGE; $output = $PAGE->get_renderer('block_moodletxt'); $renderedElement = parent::toHtml(); $renderedElement .= $output->render($this->getIcon()); return $renderedElement; }
/** * constructor * * @param string $elementName (optional) name of the text field * @param string $elementLabel (optional) text field label * @param string $attributes (optional) Either a typical HTML attribute string or an associative array */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $attributes); }
public function MoodleQuickForm_tccolourpopup($elementname = null, $elementlabel = null, $attributes = null, $options = null) { parent::__construct($elementname, $elementlabel, $attributes); $this->_type = 'colourtext'; }
/** * Returns the textarea element in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { $out = ''; if (!defined('HTML_QuickForm_lookup_files_loaded')) { define('HTML_QuickForm_lookup_files_loaded', 1); $out .= '<script type="text/javascript" src="' . DATAFACE_URL . '/js/jquery-ui-1.7.2.custom.min.js"></script>'; $out .= '<script type="text/javascript" src="' . DATAFACE_URL . '/js/RecordBrowser/RecordBrowser.js"></script> <script type="text/javascript" src="' . DATAFACE_URL . '/js/RecordDialog/RecordDialog.js"></script> '; } $properties = $this->getProperties(); if ($this->_flagFrozen) { $properties['frozen'] = 1; } ob_start(); $oldFrozen = $this->_flagFrozen; $this->_flagFrozen = 0; echo parent::toHtml(); $this->_flagFrozen = $oldFrozen; $out .= ob_get_contents(); ob_end_clean(); $selector = null; if ($this->getName()) { $selector = "input[name='" . $this->getName() . "']"; } else { $selector = '.xf-lookup-' . $this->index_prefix . '-' . $this->index; } $out .= ' <script type="text/javascript"> jQuery(document).ready(function($){ $("' . $selector . '").RecordBrowserWidget(' . json_encode($properties) . '); }); </script>'; return '<span style="white-space:nowrap">' . $out . '</span>'; }
public function MoodleQuickForm_tccolourpopup($elementname = null, $elementlabel = null, $attributes = null, $options = null) { parent::HTML_QuickForm_text($elementname, $elementlabel, $attributes); }
/** * HTML code to display this datepicker * @return string */ public function toHtml() { $js = $this->getElementJS(); return $js . parent::toHtml(); }
function MoodleQuickForm_tccolourpopup($elementName = null, $elementLabel = null, $attributes = null, $options = null) { global $CFG; parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes); }
/** * Class constructor * @param string $elementName (optional)Input field name attribute * @param string $elementLabel (optional)Input field label * @param mixed $attributes (optional)Either a typical HTML attribute string * or an associative array * @since 1.0 * @access public * @throws */ public function __construct($elementName = null, $elementLabel = null, $attributes = null) { $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : 'form-control'; parent::__construct($elementName, $elementLabel, $attributes); $this->setType('password'); }
/** * Returns HTML for this form element. * * @return string */ function toHtml() { $id = $this->_attributes['id']; $elname = $this->_attributes['name']; // Add the class at the last minute. if ($this->get_force_ltr()) { if (!isset($this->_attributes['class'])) { $this->_attributes['class'] = 'text-ltr'; } else { $this->_attributes['class'] .= ' text-ltr'; } } if ($this->_hiddenLabel) { $this->_generateId(); $str = '<label class="accesshide" for="' . $this->getAttribute('id') . '" >' . $this->getLabel() . '</label>' . parent::toHtml(); } else { $str = parent::toHtml(); } if (empty($this->_options['usefilepicker'])) { return $str; } // Print out file picker. $str .= $this->getFilePickerHTML(); return $str; }
/** * Returns the filter in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { $arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values'; $onFocus = 'javascript:QF_AJAXAutocomplete_Focus(this, "' . $this->sourceUrl . '" , ' . $arrayName . ');'; $this->updateAttributes(array('onfocus' => $onFocus)); if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $tabs = $this->_getTabs(); $js = '<script type="text/javascript">'; $js .= "\n"; $js .= '//<![CDATA['; $js .= "\n"; if (!defined('HTML_QUICKFORM_AJAXAUTOCOMPLETE_EXISTS')) { $js .= <<<EOS // begin javascript for filtered select qf_AJAXAC.configure = function() { // Timeout (in ms) after which the list is automatically hidden qf_AJAXAC.config.hideTimeout = 15000; // Timeout (in ms) after which the search is began qf_AJAXAC.config.acTimeout = 250; // How many items have to stay visibile in the list qf_AJAXAC.config.listMaxItem = 10; // How many characters are required before auto complete qf_AJAXAC.config.minchar = 0; } qf_AJAXAC.onInputKeyUp = function ( hEvent ) { if (qf_AJAXAC.hideTimer != null) clearTimeout(qf_AJAXAC.hideTimer); qf_AJAXAC.hideTimer = setTimeout("qf_AJAXAC.hideList()", qf_AJAXAC.config.hideTimeout); if (qf_AJAXAC.input.value.length < qf_AJAXAC.config.minchar && qf_AJAXAC.listShown) qf_AJAXAC.hideList(); } qf_AJAXAC.onInputKeyDown = function ( hEvent ) { if(!hEvent) hEvent = window.event; switch(hEvent.keyCode) { case 37: // left arrow case 39: // right arrow case 33: // page up case 34: // page down case 36: // home case 35: // end case 27: // esc case 16: // shift case 17: // ctrl case 18: // alt case 20: // caps lock case 38: // up arrow case 40: // down arrow break; default: break; } switch(hEvent.keyCode) { case 13: case 39: // Enter & Right qf_AJAXAC.setValue(); qf_AJAXAC.clearList(); qf_AJAXAC.hideList(); hEvent.returnValue = false; break; case 40: // Down if (!qf_AJAXAC.listShown) { if (qf_AJAXAC.acTimer != null) clearTimeout(qf_AJAXAC.acTimer); qf_AJAXAC.autoComplete(); qf_AJAXAC.selectCurrent(); break; } if (qf_AJAXAC.container && qf_AJAXAC.list.hasChildNodes()) { if (qf_AJAXAC.activeItem == null) { try { qf_AJAXAC.activeItem = qf_AJAXAC.list.childNodes.item(0).firstChild; qf_AJAXAC.activeItemIdx = 0; qf_AJAXAC.windowMax = qf_AJAXAC.config.listMaxItem - 1; qf_AJAXAC.windowMin = 0; } catch(e) {} } else { try { nextItem = qf_AJAXAC.list.childNodes.item(qf_AJAXAC.activeItemIdx + 1).firstChild; qf_AJAXAC.unselectCurrent(); qf_AJAXAC.activeItem = nextItem; qf_AJAXAC.activeItemIdx++; } catch(e) {} } } qf_AJAXAC.selectCurrent(); break; case 37: // Left break; case 38: // Up if (!qf_AJAXAC.listShown) break; if (qf_AJAXAC.container && qf_AJAXAC.list.hasChildNodes()) { if (qf_AJAXAC.activeItem != null) { qf_AJAXAC.unselectCurrent(); if (qf_AJAXAC.activeItemIdx > 0) { qf_AJAXAC.activeItemIdx--; qf_AJAXAC.activeItem = qf_AJAXAC.list.childNodes.item(qf_AJAXAC.activeItemIdx).firstChild; } } } qf_AJAXAC.selectCurrent(); break; case 27: // Esc if (!qf_AJAXAC.listShown) break; qf_AJAXAC.clearList(); qf_AJAXAC.hideList(); break; case 9: // TAB qf_AJAXAC.hideList(); qf_AJAXAC.onInputBlur(); break; default: if (qf_AJAXAC.acTimer != null) clearTimeout(qf_AJAXAC.acTimer); qf_AJAXAC.acTimer = setTimeout("qf_AJAXAC.autoComplete()", qf_AJAXAC.config.acTimeout); break; } return hEvent.returnValue; } qf_AJAXAC.setValue = function () { if (qf_AJAXAC.activeItem) { qf_AJAXAC.input.value = qf_AJAXAC.activeItem.innerHTML.replace(/<strong>(.*)<\\/strong>/ig, "\$1"); } } qf_AJAXAC.getMatchingElementKey = function(idx) { var i=0; for (match in qf_AJAXAC.matches) { if (i == idx) return match; i++; } } qf_AJAXAC.onFormSubmit = function (hEvent) { if( hEvent == null ) hEvent = window.event; qf_AJAXAC.clearList(); qf_AJAXAC.hideList(); if (qf_AJAXAC.acTimer != null) clearTimeout(qf_AJAXAC.acTimer); } qf_AJAXAC.onInputBlur = function ( hEvent ) { if (qf_AJAXAC.listShown) return; delete qf_AJAXAC.activeItem; qf_AJAXAC.activeItemIdx = 0; if (qf_AJAXAC.container) { qf_AJAXAC.clearList(); qf_AJAXAC.container.parentNode.removeChild(qf_AJAXAC.container); qf_AJAXAC.container = null; } } qf_AJAXAC.autoComplete = function () { var pattern = qf_AJAXAC.input.value.toLowerCase().trim(); if (pattern.length < qf_AJAXAC.config.minchar) return; if (qf_AJAXAC.xhr) { qf_AJAXAC.xhr.abort(); delete qf_AJAXAC.xhr; } qf_AJAXAC.xhr = new XHConn(); if (!qf_AJAXAC.xhr) alert("XMLHTTP not available. Try a newer/better browser."); if (qf_AJAXAC.cache) qf_AJAXAC.feedListFromCache(); else { query = "q=" + pattern; for (item in qf_AJAXAC.plugin) { \t query += "&" + qf_AJAXAC.plugin[item] + "=" + eval("qf_AJAXAC.input.form." + qf_AJAXAC.plugin[item] + ".value"); } if (!qf_AJAXAC.xhr.connect(qf_AJAXAC.dataurl, 'GET', query, qf_AJAXAC.feedListFromServer)) alert("Failed connecting"); } } qf_AJAXAC.feedListFromCache = function () { qf_AJAXAC.matches = qf_AJAXAC.cache; qf_AJAXAC.feedList(); } qf_AJAXAC.feedListFromServer = function (data) { if (data.status.toString() != "200") { alert("Can't connect [" + data.status.toString() + "]"); return; } eval("qf_AJAXAC.matches = " + data.responseText); if (!qf_AJAXAC.matches) { qf_AJAXAC.hideList(); return; } if (qf_AJAXAC.searchCacheLimit > 0) qf_AJAXAC.cache = qf_AJAXAC.matches; qf_AJAXAC.feedList(); } qf_AJAXAC.feedList = function() { qf_AJAXAC.clearList(); qf_AJAXAC.activeItem = null; qf_AJAXAC.activeItemIdx = 0; var pattern = qf_AJAXAC.input.value.toLowerCase().trim(); hItem = null; for (match in qf_AJAXAC.matches) { idx = qf_AJAXAC.matches[match].toLowerCase().indexOf(pattern); if (idx != -1 || qf_AJAXAC.matches[match] == "???") { hItem = document.createElement("li"); hAnchor = document.createElement("a"); hAnchor.href="#"; hAnchor.innerHTML = qf_AJAXAC.matches[match].substring(0, idx) + "<strong >" + qf_AJAXAC.matches[match].substring(idx, idx + pattern.length) + "</strong >" + qf_AJAXAC.matches[match].substring(idx + pattern.length); if (hAnchor.attachEvent) { hAnchor.attachEvent('onclick', qf_AJAXAC.onItemClick); hAnchor.attachEvent('onmouseover', qf_AJAXAC.onItemMouseOver); } else { hAnchor.addEventListener( 'click', qf_AJAXAC.onItemClick, false ); hAnchor.addEventListener( 'mouseover', qf_AJAXAC.onItemMouseOver, false ); } hItem.appendChild(hAnchor); qf_AJAXAC.list.appendChild(hItem); } } if (window.hItem) { qf_AJAXAC.showList(); if (qf_AJAXAC.container) qf_AJAXAC.container.style.height = hItem.offsetHeight * qf_AJAXAC.config.listMaxItem + "px"; } else qf_AJAXAC.hideList(); } qf_AJAXAC.onItemClick = function(hEvent) { var hItem = ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget; qf_AJAXAC.setValue(); qf_AJAXAC.clearList(); qf_AJAXAC.hideList(); hEvent.cancelBubble = true; hEvent.returnValue = false; return false; } qf_AJAXAC.onItemMouseOver = function(hEvent) { qf_AJAXAC.unselectCurrent(); qf_AJAXAC.activeItem = ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget; // We could run this only onclick, but I think it's better that activeIndex is always synchronized var i = 0; while(qf_AJAXAC.list.childNodes[i]) { if (qf_AJAXAC.list.childNodes[i] == qf_AJAXAC.activeItem.parentNode) { qf_AJAXAC.activeItemIdx = i; break; } i++; } if (qf_AJAXAC.hideTimer != null) clearTimeout(qf_AJAXAC.hideTimer); qf_AJAXAC.hideTimer = setTimeout("qf_AJAXAC.hideList()", qf_AJAXAC.config.hideTimeout); qf_AJAXAC.selectCurrent(); } qf_AJAXAC.showList = function() { if (!qf_AJAXAC.container) return; qf_AJAXAC.container.style.display = "block"; if (qf_AJAXAC.hideTimer != null) clearTimeout(qf_AJAXAC.hideTimer); qf_AJAXAC.hideTimer = setTimeout("qf_AJAXAC.hideList()", qf_AJAXAC.config.hideTimeout); qf_AJAXAC.listShown = true; } qf_AJAXAC.hideList = function() { if (!qf_AJAXAC.container) return; qf_AJAXAC.container.style.display = "none"; qf_AJAXAC.listShown = false; } qf_AJAXAC.selectCurrent = function() { if (qf_AJAXAC.activeItem) { qf_AJAXAC.activeItem.style.backgroundColor = "highlight"; qf_AJAXAC.activeItem.style.color = "highlighttext"; // Make sure the selected item is viewed if (qf_AJAXAC.activeItemIdx > qf_AJAXAC.windowMax) qf_AJAXAC.scrollListDown(); if (qf_AJAXAC.activeItemIdx < qf_AJAXAC.windowMin) qf_AJAXAC.scrollListUp(); //qf_AJAXAC.debug.value = qf_AJAXAC.activeItem.offsetTop + "-" + qf_AJAXAC.container.scrollTop + "-" + qf_AJAXAC.activeItemIdx; } } qf_AJAXAC.scrollListDown = function() { qf_AJAXAC.container.scrollTop += qf_AJAXAC.activeItem.offsetHeight; qf_AJAXAC.windowMax++; qf_AJAXAC.windowMin++; } qf_AJAXAC.scrollListUp = function() { qf_AJAXAC.container.scrollTop -= qf_AJAXAC.activeItem.offsetHeight; qf_AJAXAC.windowMax--; qf_AJAXAC.windowMin--; } qf_AJAXAC.unselectCurrent = function() { if (qf_AJAXAC.activeItem) { qf_AJAXAC.activeItem.style.backgroundColor = ""; qf_AJAXAC.activeItem.style.color = "black"; qf_AJAXAC.activeItem.className = ""; } } qf_AJAXAC.clearList = function () { while(qf_AJAXAC.list.hasChildNodes()) qf_AJAXAC.list.removeChild(qf_AJAXAC.list.childNodes[0]); } qf_AJAXAC.createContainer = function() { if (qf_AJAXAC.container) { qf_AJAXAC.container.parentNode.removeChild(qf_AJAXAC.container); qf_AJAXAC.container = null; qf_AJAXAC.list = null; } hC = document.createElement("div"); hC.style.width = qf_AJAXAC.input.offsetWidth + "px"; var nTop = qf_AJAXAC.getOffsetParam(qf_AJAXAC.input, 'offsetTop'); var nLeft = qf_AJAXAC.getOffsetParam(qf_AJAXAC.input, 'offsetLeft'); hC.style.position = "absolute"; hC.style.top = (nTop + qf_AJAXAC.input.offsetHeight) + 'px'; hC.style.left = nLeft + 'px'; hC.style.zIndex = "10000"; hC.className = "qf_AdvACContainer"; hC.style.display = 'none'; hC.style.visibility = 'visible'; hList = document.createElement("ul"); hList.className = "qf_AdvACList"; hC.appendChild(hList); document.body.appendChild(hC); qf_AJAXAC.container = hC; qf_AJAXAC.list = hList; } function qf_AJAXACConfiguration() { this.hideTimeout = 0; } function QF_AJAXAutocomplete_Focus(hInput, url, list) { \t// Turn off browser autocomplete \thInput.autocomplete = 'off'; // Create qf_AJAXAC object\t qf_AJAXAC.config = new qf_AJAXACConfiguration(); qf_AJAXAC.configure(); qf_AJAXAC.dataurl = url; qf_AJAXAC.plugin = list; qf_AJAXAC.input = hInput; qf_AJAXAC.searchBeginsWith = "1"; qf_AJAXAC.searchCacheLimit = 0; // first, remove the event handler if any (it is mandatory for IE to work well) if (hInput.attachEvent) { hInput.detachEvent('onkeyup', qf_AJAXAC.onInputKeyUp); hInput.detachEvent('onkeydown', qf_AJAXAC.onInputKeyDown); hInput.detachEvent('onblur', qf_AJAXAC.onInputBlur); hInput.attachEvent('onkeyup', qf_AJAXAC.onInputKeyUp); hInput.attachEvent('onkeydown', qf_AJAXAC.onInputKeyDown); hInput.attachEvent('onblur', qf_AJAXAC.onInputBlur); } else if (hInput.addEventListener) { hInput.removeEventListener('keyup', qf_AJAXAC.onInputKeyUp, false); hInput.removeEventListener('keydown', qf_AJAXAC.onInputKeyDown, false); hInput.removeEventListener('blur', qf_AJAXAC.onInputBlur, false); hInput.addEventListener('keyup', qf_AJAXAC.onInputKeyUp, false); hInput.addEventListener('keydown', qf_AJAXAC.onInputKeyDown, false); hInput.addEventListener('blur', qf_AJAXAC.onInputBlur, false); } if (hInput.form) { if (hInput.form.attachEvent) hInput.form.attachEvent( 'onsubmit', qf_AJAXAC.onFormSubmit ) else if ( hInput.form.addEventListener ) hInput.form.addEventListener( 'submit', qf_AJAXAC.onFormSubmit, false ) } qf_AJAXAC.createContainer(); } // // This script was created // by Mircho Mirev // mo /mo@momche.net/ qf_AJAXAC.getOffsetParam = function( hElement, sParam, hLimitParent ) { var nRes = 0 if (hLimitParent == null) { hLimitParent = document.body.parentElement } while (hElement != hLimitParent) { nRes += eval( 'hElement.' + sParam ) if( !hElement.offsetParent ) { break } hElement = hElement.offsetParent } return nRes; } /** XHConn - Simple XMLHTTP Interface - brad@xkr.us - 2005-01-24 ** ** Code licensed under Creative Commons Attribution-ShareAlike License ** ** http://creativecommons.org/licenses/by-sa/2.0/ **/ function XHConn() { var xmlhttp; var active; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; }}} if (!xmlhttp) return null; this.connect = function(sURL, sMethod, sVars, fnDone) { if (!xmlhttp) return false; sMethod = sMethod.toUpperCase(); try { if (sMethod == "GET") { xmlhttp.open(sMethod, sURL+"?"+sVars, true); sVars = ""; } else { xmlhttp.open(sMethod, sURL, true); xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1"); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) { fnDone(xmlhttp); }}; xmlhttp.send(sVars); } catch(z) { return false; } return true; }; this.abort = function() { try { //xmlhttp.abort(); } catch(z) { return false; } } return this; } // From // http://www.developingskills.com/ds.php?article=jstrim&page=1 function strtrim() { return this.replace(/^\\s+/,'').replace(/\\s+\$/,''); } String.prototype.trim = strtrim; function qf_AJAXAC() { } // end javascript for AJAXAutocomplete EOS; define('HTML_QUICKFORM_AJAXAUTOCOMPLETE_EXISTS', true); } $jsEscape = array("\r" => '\\r', "\n" => '\\n', "\t" => '\\t', "'" => "\\'", '"' => '\\"', '\\' => '\\\\'); $js .= 'var ' . $arrayName . " = new Array();\n"; for ($i = 0; $i < count($this->extraData); $i++) { $js .= $arrayName . '[' . $i . "] = '" . strtr($this->extraData[$i], $jsEscape) . "';\n"; } $js .= "//]]>\n</script>\n"; return $js . parent::toHtml(); } }
/** * Returns Html for the autocomplete input text element * * @access public * @return string */ function toHtml() { // prevent problems with grouped elements $arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values'; $this->updateAttributes(array('onkeypress' => 'return autocomplete(this, event, ' . $arrayName . ');')); if ($this->_flagFrozen) { $js = ''; } else { $js = "<script type=\"text/javascript\">\n//<![CDATA[\n"; if (!defined('HTML_QUICKFORM_AUTOCOMPLETE_EXISTS')) { $this->_js .= <<<EOS /* begin javascript for autocomplete */ function setSelectionRange(input, selectionStart, selectionEnd) { if (input.setSelectionRange) { input.setSelectionRange(selectionStart, selectionEnd); } else if (input.createTextRange) { var range = input.createTextRange(); range.collapse(true); range.moveEnd("character", selectionEnd); range.moveStart("character", selectionStart); range.select(); } input.focus(); } function setCaretToPosition(input, position) { setSelectionRange(input, position, position); } function replaceSelection (input, replaceString) { \tvar len = replaceString.length; if (input.setSelectionRange) { var selectionStart = input.selectionStart; var selectionEnd = input.selectionEnd; input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd); \t\tinput.selectionStart = selectionStart + len; \t\tinput.selectionEnd = selectionStart + len; } else if (document.selection) { var range = document.selection.createRange(); \t\tvar saved_range = range.duplicate(); if (range.parentElement() == input) { range.text = replaceString; \t\t\trange.moveEnd("character", saved_range.selectionStart + len); \t\t\trange.moveStart("character", saved_range.selectionStart + len); \t\t\trange.select(); } } input.focus(); } function autocompleteMatch (text, values) { for (var i = 0; i < values.length; i++) { if (values[i].toUpperCase().indexOf(text.toUpperCase()) == 0) { return values[i]; } } return null; } function autocomplete(textbox, event, values) { if (textbox.setSelectionRange || textbox.createTextRange) { switch (event.keyCode) { case 38: // up arrow case 40: // down arrow case 37: // left arrow case 39: // right arrow case 33: // page up case 34: // page down case 36: // home case 35: // end case 13: // enter case 9: // tab case 27: // esc case 16: // shift case 17: // ctrl case 18: // alt case 20: // caps lock case 8: // backspace case 46: // delete return true; break; default: var c = String.fromCharCode( (event.charCode == undefined) ? event.keyCode : event.charCode ); replaceSelection(textbox, c); sMatch = autocompleteMatch(textbox.value, values); var len = textbox.value.length; \t\t\t\t if (sMatch != null) { textbox.value = sMatch; setSelectionRange(textbox, len, textbox.value.length); } return false; } } else { return true; } } /* end javascript for autocomplete */ EOS; define('HTML_QUICKFORM_AUTOCOMPLETE_EXISTS', true); } $jsEscape = array("\r" => '\\r', "\n" => '\\n', "\t" => '\\t', "'" => "\\'", '"' => '\\"', '\\' => '\\\\'); $js .= $this->_js; $js .= 'var ' . $arrayName . " = new Array();\n"; for ($i = 0; $i < count($this->_options); $i++) { $js .= $arrayName . '[' . $i . "] = '" . strtr($this->_options[$i], $jsEscape) . "';\n"; } $js .= "//]]>\n</script>"; } return $js . parent::toHtml(); }
/** * Constructor for the colour picker. * * @param string $elementName * @param string $elementLabel * @param array $attributes */ function MoodleQuickForm_customcert_colourpicker($elementName = null, $elementLabel = null, $attributes = null) { parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes); }
public function MoodleQuickForm_gfcolourpopup($elementName = null, $elementLabel = null, $attributes = null, $options = null) { parent::HTML_QuickForm_text($elementName, $elementLabel, $attributes); $this->_type = 'colourtext'; }
function MoodleQuickForm_username($elementName = null, $elementLabel = null, $attributes = null) { HTML_QuickForm_text::HTML_QuickForm_text($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('user'); }
/** * Returns the filter in HTML * * @since 1.0 * @access public * @return string */ function toHtml() { $arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values'; $onFocus = 'javascript:QF_AdvAutocomplete_Focus(this, ' . $arrayName . ');'; $this->updateAttributes(array('onfocus' => $onFocus)); if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $tabs = $this->_getTabs(); $js = '<script type="text/javascript">'; $js .= "\n"; $js .= '//<![CDATA['; $js .= "\n"; if (!defined('HTML_QUICKFORM_ADVAUTOCOMPLETE_EXISTS')) { $js .= <<<EOS // begin javascript for filtered select qf_AdvAC.configure = function() { // Timeout (in ms) after which the list is automatically hidden qf_AdvAC.config.hideTimeout = 15000; // Timeout (in ms) after which the search is began qf_AdvAC.config.acTimeout = 250; // How many items have to stay visibile in the list qf_AdvAC.config.listMaxItem = 10; // How many characters are required before auto complete qf_AdvAC.config.minchar = 0; } qf_AdvAC.onInputKeyUp = function ( hEvent ) { if (qf_AdvAC.hideTimer != null) clearTimeout(qf_AdvAC.hideTimer); qf_AdvAC.hideTimer = setTimeout("qf_AdvAC.hideList()", qf_AdvAC.config.hideTimeout); if (qf_AdvAC.input.value.length < qf_AdvAC.config.minchar && qf_AdvAC.listShown) qf_AdvAC.hideList(); } qf_AdvAC.onInputKeyDown = function ( hEvent ) { if(!hEvent) hEvent = window.event; switch(hEvent.keyCode) { case 37: // left arrow case 39: // right arrow case 33: // page up case 34: // page down case 36: // home case 35: // end case 27: // esc case 16: // shift case 17: // ctrl case 18: // alt case 20: // caps lock case 38: // up arrow case 40: // down arrow break; default: break; } switch(hEvent.keyCode) { case 13: case 39: // Enter & Right qf_AdvAC.setValue(); qf_AdvAC.clearList(); qf_AdvAC.hideList(); hEvent.returnValue = false; break; case 40: // Down if (!qf_AdvAC.listShown) { if (qf_AdvAC.acTimer != null) clearTimeout(qf_AdvAC.acTimer); qf_AdvAC.autoComplete(); qf_AdvAC.selectCurrent(); break; } if (qf_AdvAC.container && qf_AdvAC.list.hasChildNodes()) { if (qf_AdvAC.activeItem == null) { try { qf_AdvAC.activeItem = qf_AdvAC.list.childNodes.item(0).firstChild; qf_AdvAC.activeItemIdx = 0; qf_AdvAC.windowMax = qf_AdvAC.config.listMaxItem - 1; qf_AdvAC.windowMin = 0; } catch(e) {} } else { try { nextItem = qf_AdvAC.list.childNodes.item(qf_AdvAC.activeItemIdx + 1).firstChild; qf_AdvAC.unselectCurrent(); qf_AdvAC.activeItem = nextItem; qf_AdvAC.activeItemIdx++; } catch(e) {} } } qf_AdvAC.selectCurrent(); break; case 37: // Left break; case 38: // Up if (!qf_AdvAC.listShown) break; if (qf_AdvAC.container && qf_AdvAC.list.hasChildNodes()) { if (qf_AdvAC.activeItem != null) { qf_AdvAC.unselectCurrent(); if (qf_AdvAC.activeItemIdx > 0) { qf_AdvAC.activeItemIdx--; qf_AdvAC.activeItem = qf_AdvAC.list.childNodes.item(qf_AdvAC.activeItemIdx).firstChild; } } } qf_AdvAC.selectCurrent(); break; case 27: // Esc if (!qf_AdvAC.listShown) break; qf_AdvAC.clearList(); qf_AdvAC.hideList(); break; case 9: // TAB qf_AdvAC.hideList(); qf_AdvAC.onInputBlur(); break; default: if (qf_AdvAC.acTimer != null) clearTimeout(qf_AdvAC.acTimer); qf_AdvAC.acTimer = setTimeout("qf_AdvAC.autoComplete()", qf_AdvAC.config.acTimeout); break; } return hEvent.returnValue; } qf_AdvAC.setValue = function () { if (qf_AdvAC.activeItem) { qf_AdvAC.input.value = qf_AdvAC.activeItem.innerHTML.replace(/<strong>(.*)<\\/strong>/ig, "\$1"); } } qf_AdvAC.getMatchingElementKey = function(idx) { var i=0; for (match in qf_AdvAC.matches) { if (i == idx) return match; i++; } } qf_AdvAC.onFormSubmit = function (hEvent) { if( hEvent == null ) hEvent = window.event; qf_AdvAC.clearList(); qf_AdvAC.hideList(); if (qf_AdvAC.acTimer != null) clearTimeout(qf_AdvAC.acTimer); } qf_AdvAC.onInputBlur = function ( hEvent ) { if (qf_AdvAC.listShown) return; delete qf_AdvAC.activeItem; qf_AdvAC.activeItemIdx = 0; if (qf_AdvAC.container) { qf_AdvAC.clearList(); qf_AdvAC.container.parentNode.removeChild(qf_AdvAC.container); qf_AdvAC.container = null; } } qf_AdvAC.autoComplete = function () { var pattern = qf_AdvAC.input.value.toLowerCase().trim(); if (pattern.length < qf_AdvAC.config.minchar) return; // Look through array given as plugin qf_AdvAC.matches = qf_AdvAC.plugin; qf_AdvAC.feedList(); } qf_AdvAC.feedList = function() { qf_AdvAC.clearList(); qf_AdvAC.activeItem = null; qf_AdvAC.activeItemIdx = 0; var pattern = qf_AdvAC.input.value.toLowerCase().trim(); hItem = null; for (match in qf_AdvAC.matches) { idx = qf_AdvAC.matches[match].toLowerCase().indexOf(pattern); if (idx != -1 || qf_AdvAC.matches[match] == "???") { hItem = document.createElement("li"); hAnchor = document.createElement("a"); hAnchor.href="#"; hAnchor.innerHTML = qf_AdvAC.matches[match].substring(0, idx) + "<strong >" + qf_AdvAC.matches[match].substring(idx, idx + pattern.length) + "</strong >" + qf_AdvAC.matches[match].substring(idx + pattern.length); if (hAnchor.attachEvent) { hAnchor.attachEvent('onclick', qf_AdvAC.onItemClick); hAnchor.attachEvent('onmouseover', qf_AdvAC.onItemMouseOver); } else { hAnchor.addEventListener( 'click', qf_AdvAC.onItemClick, false ); hAnchor.addEventListener( 'mouseover', qf_AdvAC.onItemMouseOver, false ); } hItem.appendChild(hAnchor); qf_AdvAC.list.appendChild(hItem); } } if (window.hItem) { qf_AdvAC.showList(); if (qf_AdvAC.container) qf_AdvAC.container.style.height = hItem.offsetHeight * qf_AdvAC.config.listMaxItem + "px"; } else qf_AdvAC.hideList(); } qf_AdvAC.onItemClick = function(hEvent) { var hItem = ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget; qf_AdvAC.setValue(); qf_AdvAC.clearList(); qf_AdvAC.hideList(); hEvent.cancelBubble = true; hEvent.returnValue = false; return false; } qf_AdvAC.onItemMouseOver = function(hEvent) { qf_AdvAC.unselectCurrent(); qf_AdvAC.activeItem = ( hEvent.srcElement ) ? hEvent.srcElement : hEvent.originalTarget; // We could run this only onclick, but I think it's better that activeIndex is always synchronized var i = 0; while(qf_AdvAC.list.childNodes[i]) { if (qf_AdvAC.list.childNodes[i] == qf_AdvAC.activeItem.parentNode) { qf_AdvAC.activeItemIdx = i; break; } i++; } if (qf_AdvAC.hideTimer != null) clearTimeout(qf_AdvAC.hideTimer); qf_AdvAC.hideTimer = setTimeout("qf_AdvAC.hideList()", qf_AdvAC.config.hideTimeout); qf_AdvAC.selectCurrent(); } qf_AdvAC.showList = function() { if (!qf_AdvAC.container) return; qf_AdvAC.container.style.display = "block"; if (qf_AdvAC.hideTimer != null) clearTimeout(qf_AdvAC.hideTimer); qf_AdvAC.hideTimer = setTimeout("qf_AdvAC.hideList()", qf_AdvAC.config.hideTimeout); qf_AdvAC.listShown = true; } qf_AdvAC.hideList = function() { if (!qf_AdvAC.container) return; qf_AdvAC.container.style.display = "none"; qf_AdvAC.listShown = false; } qf_AdvAC.selectCurrent = function() { if (qf_AdvAC.activeItem) { qf_AdvAC.activeItem.style.backgroundColor = "highlight"; qf_AdvAC.activeItem.style.color = "highlighttext"; // Make sure the selected item is viewed if (qf_AdvAC.activeItemIdx > qf_AdvAC.windowMax) qf_AdvAC.scrollListDown(); if (qf_AdvAC.activeItemIdx < qf_AdvAC.windowMin) qf_AdvAC.scrollListUp(); //qf_AdvAC.debug.value = qf_AdvAC.activeItem.offsetTop + "-" + qf_AdvAC.container.scrollTop + "-" + qf_AdvAC.activeItemIdx; } } qf_AdvAC.scrollListDown = function() { qf_AdvAC.container.scrollTop += qf_AdvAC.activeItem.offsetHeight; qf_AdvAC.windowMax++; qf_AdvAC.windowMin++; } qf_AdvAC.scrollListUp = function() { qf_AdvAC.container.scrollTop -= qf_AdvAC.activeItem.offsetHeight; qf_AdvAC.windowMax--; qf_AdvAC.windowMin--; } qf_AdvAC.unselectCurrent = function() { if (qf_AdvAC.activeItem) { qf_AdvAC.activeItem.style.backgroundColor = ""; qf_AdvAC.activeItem.style.color = "black"; qf_AdvAC.activeItem.className = ""; } } qf_AdvAC.clearList = function () { while(qf_AdvAC.list.hasChildNodes()) qf_AdvAC.list.removeChild(qf_AdvAC.list.childNodes[0]); } qf_AdvAC.createContainer = function() { if (qf_AdvAC.container) { qf_AdvAC.container.parentNode.removeChild(qf_AdvAC.container); qf_AdvAC.container = null; qf_AdvAC.list = null; } hC = document.createElement("div"); hC.style.width = qf_AdvAC.input.offsetWidth + "px"; var nTop = qf_AdvAC.getOffsetParam(qf_AdvAC.input, 'offsetTop'); var nLeft = qf_AdvAC.getOffsetParam(qf_AdvAC.input, 'offsetLeft'); hC.style.position = "absolute"; hC.style.top = (nTop + qf_AdvAC.input.offsetHeight) + 'px'; hC.style.left = nLeft + 'px'; hC.style.zIndex = "10000"; hC.className = "qf_AdvACContainer"; hC.style.display = 'none'; hC.style.visibility = 'visible'; hList = document.createElement("ul"); hList.className = "qf_AdvACList"; hC.appendChild(hList); document.body.appendChild(hC); qf_AdvAC.container = hC; qf_AdvAC.list = hList; } function qf_AdvACConfiguration() { this.hideTimeout = 0; } function QF_AdvAutocomplete_Focus(hInput, list) { \t// Turn off browser autocomplete \thInput.autocomplete = 'off'; // Create qf_AdvAC object\t qf_AdvAC.config = new qf_AdvACConfiguration(); qf_AdvAC.configure(); qf_AdvAC.plugin = list; qf_AdvAC.input = hInput; qf_AdvAC.searchBeginsWith = "1"; qf_AdvAC.searchCacheLimit = 0; // first, remove the event handler if any (it is mandatory for IE to work well) if (hInput.attachEvent) { hInput.detachEvent('onkeyup', qf_AdvAC.onInputKeyUp); hInput.detachEvent('onkeydown', qf_AdvAC.onInputKeyDown); hInput.detachEvent('onblur', qf_AdvAC.onInputBlur); hInput.attachEvent('onkeyup', qf_AdvAC.onInputKeyUp); hInput.attachEvent('onkeydown', qf_AdvAC.onInputKeyDown); hInput.attachEvent('onblur', qf_AdvAC.onInputBlur); } else if (hInput.addEventListener) { hInput.removeEventListener('keyup', qf_AdvAC.onInputKeyUp, false); hInput.removeEventListener('keydown', qf_AdvAC.onInputKeyDown, false); hInput.removeEventListener('blur', qf_AdvAC.onInputBlur, false); hInput.addEventListener('keyup', qf_AdvAC.onInputKeyUp, false); hInput.addEventListener('keydown', qf_AdvAC.onInputKeyDown, false); hInput.addEventListener('blur', qf_AdvAC.onInputBlur, false); } if (hInput.form) { if (hInput.form.attachEvent) hInput.form.attachEvent( 'onsubmit', qf_AdvAC.onFormSubmit ) else if ( hInput.form.addEventListener ) hInput.form.addEventListener( 'submit', qf_AdvAC.onFormSubmit, false ) } qf_AdvAC.createContainer(); } // // This script was created // by Mircho Mirev // mo /mo@momche.net/ qf_AdvAC.getOffsetParam = function( hElement, sParam, hLimitParent ) { var nRes = 0 if (hLimitParent == null) { hLimitParent = document.body.parentElement } while (hElement != hLimitParent) { nRes += eval( 'hElement.' + sParam ) if( !hElement.offsetParent ) { break } hElement = hElement.offsetParent } return nRes; } // From // http://www.developingskills.com/ds.php?article=jstrim&page=1 function strtrim() { return this.replace(/^\\s+/,'').replace(/\\s+\$/,''); } String.prototype.trim = strtrim; function qf_AdvAC() { } // end javascript for AdvAutocomplete EOS; define('HTML_QUICKFORM_ADVAUTOCOMPLETE_EXISTS', true); } $jsEscape = array("\r" => '\\r', "\n" => '\\n', "\t" => '\\t', "'" => "\\'", '"' => '\\"', '\\' => '\\\\'); $js .= 'var ' . $arrayName . " = new Array();\n"; for ($i = 0; $i < count($this->_options); $i++) { $js .= $arrayName . '[' . $i . "] = '" . strtr($this->_options[$i], $jsEscape) . "';\n"; } $js .= "//]]>\n</script>\n"; return $js . parent::toHtml(); } }