From 4a1937e01b457ed628ea4a6366a3001d6450644d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 16 Oct 2009 20:51:28 -0600 Subject: [PATCH] Track KeyNavList work in horde/js. --- imp/lib/Ajax/Imple/ContactAutoCompleter.php | 37 +++++++++++++++-------------- imp/themes/mozilla/screen.css | 10 -------- imp/themes/screen.css | 35 ++++++--------------------- 3 files changed, 26 insertions(+), 56 deletions(-) diff --git a/imp/lib/Ajax/Imple/ContactAutoCompleter.php b/imp/lib/Ajax/Imple/ContactAutoCompleter.php index a5ef36fc0..679275284 100644 --- a/imp/lib/Ajax/Imple/ContactAutoCompleter.php +++ b/imp/lib/Ajax/Imple/ContactAutoCompleter.php @@ -32,7 +32,6 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base * @param array $params Configuration parameters. *
      * 'triggerId' => TODO (optional)
-     * 'resultsId' => TODO (optional)
      * 
*/ public function __construct($params) @@ -40,9 +39,6 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base if (empty($params['triggerId'])) { $params['triggerId'] = $this->_randomid(); } - if (empty($params['resultsId'])) { - $params['resultsId'] = $params['triggerId'] . '_results'; - } parent::__construct($params); } @@ -54,16 +50,18 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base { Horde::addScriptFile('effects.js', 'horde'); Horde::addScriptFile('autocomplete.js', 'horde'); + Horde::addScriptFile('KeyNavList.js', 'horde'); + Horde::addScriptFile('liquidmetal.js', 'horde'); $params = array( - '"' . $this->_params['triggerId'] . '"', - '"' . $this->_params['resultsId'] . '"' + '"' . $this->_params['triggerId'] . '"' ); $js_params = array( - 'tokens: [",", ";"]', - 'indicator: "' . $this->_params['triggerId'] . '_loading_img"', - 'afterUpdateElement: function(f, t) { if (!f.value.endsWith(";")) { f.value += ","; } f.value += " "; }' + 'indicator' => $this->_params['triggerId'] . '_loading_img', + 'onSelect' => 1, + 'onType' => 1, + 'tokens' => array(',', ';') ); $ac_browser = empty($GLOBALS['conf']['compose']['ac_browser']) ? 0 : $GLOBALS['conf']['compose']['ac_browser']; @@ -92,7 +90,7 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base } $params[] = '"' . $this->_url . '"'; - $js_params[] = 'minChars: ' . intval($GLOBALS['conf']['compose']['ac_threshold'] ? $GLOBALS['conf']['compose']['ac_threshold'] : 1); + $js_params['minChars'] = intval($GLOBALS['conf']['compose']['ac_threshold'] ? $GLOBALS['conf']['compose']['ac_threshold'] : 1); } else { if (!self::$_listOutput) { if (!isset($addrlist)) { @@ -102,17 +100,20 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base self::$_listOutput = true; } - Horde::addScriptFile('liquidmetal.js', 'horde'); - $func = 'Autocompleter.Local'; $params[] = 'IMP.ac_list'; - $js_params[] = 'partialSearch: true'; - $js_params[] = 'fullSearch: true'; - $js_params[] = 'score: true'; + $js_params['partialSearch'] = 1; + $js_params['fullSearch'] = 1; + $js_params['score'] = 1; } - $params[] = '{' . implode(',', $js_params) . '}'; - Horde::addInlineScript('new ' . $func . '(' . implode(',', $params) . ')', 'dom'); + // There is no support for storing functions in JSON. Have to + // hack around this a bit. + $js_params = Horde_Serialize::serialize($js_params, Horde_Serialize::JSON); + $js_params = str_replace('"onSelect":1', '"onSelect":function (v) { if (!v.endsWith(";")) { v += ","; } return v + " "; }', $js_params); + $js_params = str_replace('"onType":1', '"onType":function (e) { return e.include("<") ? "" : e; }', $js_params); + + Horde::addInlineScript($this->_params['triggerId'] . '1 = new ' . $func . '(' . implode(',', $params) . ',' . $js_params . ')', 'dom'); } /** @@ -130,7 +131,7 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base return array(); } - return array_map('htmlspecialchars', IMP_Compose::expandAddresses($input, array('levenshtein' => true))); + return IMP_Compose::expandAddresses($input, array('levenshtein' => true)); } } diff --git a/imp/themes/mozilla/screen.css b/imp/themes/mozilla/screen.css index 43a7fb0b3..f0bc114db 100644 --- a/imp/themes/mozilla/screen.css +++ b/imp/themes/mozilla/screen.css @@ -12,13 +12,3 @@ #messageBody { padding: 2px; } - -/* Autocomplete styles. */ -.autocomplete ul li { - text-decoration: none; -} -.autocomplete ul .selected { - color: #000; - background-color: #e8f1ff; - text-decoration: underline; -} diff --git a/imp/themes/screen.css b/imp/themes/screen.css index 705e906f8..53dc4a098 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -258,6 +258,13 @@ span.trashImg { background: #fff; } +.addressTr { + width: 580px; +} +.addressTr span { + vertical-align: top; +} + /* Message flags definitions. * For background color, see config/prefs.php [msgflags preference]. */ div.msgflags { @@ -374,34 +381,6 @@ table.multipleMsgs td.msgheader { padding: 1px 1px 1px 2px; } -/* Autocomplete styles. */ -.autocomplete { - background: #f4f4f4; - border: 1px solid #d4d4d4; - position: absolute; - padding: 2px; -} -.autocomplete ul { - margin: 1px; - padding: 1px; - list-style-type: none; -} -.autocomplete ul li { - padding: 3px 4px 4px; - cursor: pointer; - color: #000; -} -.autocomplete ul .selected { - background: gray; - color: #fff; -} -.addressTr { - width: 580px; -} -.addressTr span { - vertical-align: top; -} - /* Contacts styles. */ #contactstable #search { width: 150px; -- 2.11.0