From: Michael J. Rubinsky Date: Wed, 1 Apr 2009 21:58:10 +0000 (-0400) Subject: Allow choice between 'normal' and pretty tag UI X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=42827f6c45a4a30b4b788a1d82130e7c61c45380;p=horde.git Allow choice between 'normal' and pretty tag UI --- diff --git a/kronolith/lib/Imple/TagAutoCompleter.php b/kronolith/lib/Imple/TagAutoCompleter.php index d35574bd2..09d5eb8b0 100644 --- a/kronolith/lib/Imple/TagAutoCompleter.php +++ b/kronolith/lib/Imple/TagAutoCompleter.php @@ -33,30 +33,65 @@ class Kronolith_Imple_TagAutoCompleter extends Kronolith_Imple /** * Attach the Imple object to a javascript event. + * Assume that if the 'container' parameter is empty then we want a + * traditional autocompleter, otherwise we get a spiffy pretty one. + * */ public function attach() { + global $registry; parent::attach(); Horde::addScriptFile('autocomplete.js', 'horde', true); - $params = array( - '"' . $this->_params['triggerId'] . '"', - '"' . $this->_params['resultsId'] . '"', - '"' . Horde::url($GLOBALS['registry']->get('webroot', 'kronolith') . '/imple.php?imple=TagAutoCompleter/input=' . rawurlencode($this->_params['triggerId']), true) . '"' - ); + if ($pretty = !empty($this->_params['container'])) { + Horde::addScriptFile('taggerAutoCompleter.js', 'kronolith', true); + } + $this->_params['uri'] = Horde::url($GLOBALS['registry']->get('webroot', 'kronolith') . '/imple.php?imple=TagAutoCompleter/input=' . rawurlencode($this->_params['triggerId']), true); + + if (!$pretty) { + $params = array( + '"' . $this->_params['triggerId'] . '"', + '"' . $this->_params['resultsId'] . '"', + '"' . $this->_params['uri'] . '"' + ); + } $js_params = array( 'tokens: [","]', 'indicator: "' . $this->_params['triggerId'] . '_loading_img"' ); - if (!empty($this->_params['updateElement'])) { + // The pretty version needs to set this callback itself... + if (!$pretty && !empty($this->_params['updateElement'])) { $js_params[] = 'updateElement: ' . $this->_params['updateElement']; } $params[] = '{' . implode(',', $js_params) . '}'; - Kronolith::addInlineScript('new Ajax.Autocompleter(' . implode(',', $params) . ')', 'dom'); + if ($pretty) { + $js_vars = array('resultsId' => $this->_params['resultsId'], + 'uri' => $this->_params['uri'], + 'selectedTags' => array(), + 'trigger' => $this->_params['triggerId'], + 'tags' => $this->_params['tags'], + 'container' => $this->_params['container'], + 'URI_IMG_HORDE' => $registry->getImageDir('horde'), + 'params' => $params); + // These are optional + if ($this->_params['debug']) { + $js_vars['debug'] = $this->_params['debug']; + } + + if ($this->_params['existing']) { + $js_vars['existing'] = $this->_params['existing']; + } + + $script = array('new KronolithTagger(' . Horde_Serialize::serialize($js_vars, Horde_Serialize::JSON, NLS::getCharset()) . ')'); + } else { + $script = array('new Ajax.Autocompleter(' . implode(',', $params) . ')'); + } + + Kronolith::addInlineScript($script, 'dom'); } /**