Track KeyNavList work in horde/js.
authorMichael M Slusarz <slusarz@curecanti.org>
Sat, 17 Oct 2009 02:51:28 +0000 (20:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 19 Oct 2009 17:40:28 +0000 (11:40 -0600)
imp/lib/Ajax/Imple/ContactAutoCompleter.php
imp/themes/mozilla/screen.css
imp/themes/screen.css

index a5ef36f..6792752 100644 (file)
@@ -32,7 +32,6 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_Base
      * @param array $params  Configuration parameters.
      * <pre>
      * 'triggerId' => TODO (optional)
-     * 'resultsId' => TODO (optional)
      * </pre>
      */
     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));
     }
 
 }
index 43a7fb0..f0bc114 100644 (file)
 #messageBody {
     padding: 2px;
 }
-
-/* Autocomplete styles. */
-.autocomplete ul li {
-    text-decoration: none;
-}
-.autocomplete ul .selected {
-    color: #000;
-    background-color: #e8f1ff;
-    text-decoration: underline;
-}
index 705e906..53dc4a0 100644 (file)
@@ -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;