From: Jan Schneider Date: Wed, 9 Jun 2010 21:44:17 +0000 (+0200) Subject: Modernize javascript. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1deecf3d614527f672bcdb27c299498289201a31;p=horde.git Modernize javascript. --- diff --git a/turba/js/search.js b/turba/js/search.js new file mode 100644 index 000000000..108a24897 --- /dev/null +++ b/turba/js/search.js @@ -0,0 +1,40 @@ +/** + * Provides the javascript for the search.php script (basic view). + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file LICENSE for license information (ASL). If you + * did not receive this file, see http://www.horde.org/licenses/asl.php. + * + * @author Jan Schneider + */ + +TurbaSearch = { + + criteria: {}, + shareSources: {}, + + updateCriteria: function() + { + if (!$('turbaSearchSource').options) { + return; + } + + var source = $F('turbaSearchSource'); + + $('turbaSearchCriteria').update(); + $H(this.criteria[source]).each(function(criterion) { + $('turbaSearchCriteria').insert(new Element('option', { value: criterion.key }).insert(criterion.value.escapeHTML())); + }); + + if ($('vbook-form')) { + if (this.shareSources[source] == true) { + $('vbook-form').show(); + } else { + $('vbook-form').hide(); + } + } + } +} + +document.observe('dom:loaded', TurbaSearch.updateCriteria.bind(TurbaSearch)); diff --git a/turba/search.php b/turba/search.php index 8769e9135..ba6f41492 100644 --- a/turba/search.php +++ b/turba/search.php @@ -188,6 +188,7 @@ if ($_SESSION['turba']['search_mode'] == 'basic') { Horde::addScriptFile('quickfinder.js', 'horde'); Horde::addScriptFile('effects.js', 'horde'); Horde::addScriptFile('redbox.js', 'horde'); +Horde::addScriptFile('search.js', 'turba'); require TURBA_TEMPLATES . '/common-header.inc'; require TURBA_TEMPLATES . '/menu.inc'; require TURBA_TEMPLATES . '/search/header.inc'; diff --git a/turba/templates/search/advanced.html.php b/turba/templates/search/advanced.html.php new file mode 100644 index 000000000..b173e3344 --- /dev/null +++ b/turba/templates/search/advanced.html.php @@ -0,0 +1,31 @@ + + + + + + 1): ?> + + + + + + $v) { + if (substr($name, 0, 2) != '__') { +?> + + + + + +
  + " /> + " /> +
+ +
diff --git a/turba/templates/search/advanced.inc b/turba/templates/search/advanced.inc deleted file mode 100644 index b173e3344..000000000 --- a/turba/templates/search/advanced.inc +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - 1): ?> - - - - - - $v) { - if (substr($name, 0, 2) != '__') { -?> - - - - - -
  - " /> - " /> -
- -
diff --git a/turba/templates/search/basic.inc b/turba/templates/search/basic.inc index f20cc85e0..f39e68ccc 100644 --- a/turba/templates/search/basic.inc +++ b/turba/templates/search/basic.inc @@ -1,50 +1,17 @@ 1): ?> - - diff --git a/turba/templates/search/header.inc b/turba/templates/search/header.inc index b3a1a4e15..7862d84f2 100644 --- a/turba/templates/search/header.inc +++ b/turba/templates/search/header.inc @@ -6,20 +6,20 @@ $js_criteria = "var criteriaOptions = [];\n" . "var shareSources = [];\n"; $source_count = 0; +$criteria = $shareSources = array(); foreach (Turba::getAddressBooks() as $key => $entry) { - $js_criteria .= "criteriaOptions[$source_count] = []\n" - . "criteriaOptions[$source_count][0] = '$key';\n"; + $criteria[$key] = array(); /* Build the criteria select widget. */ $field_count = 1; foreach ($entry['search'] as $field) { - $js_criteria .= "criteriaOptions[$source_count][$field_count] = ['$field', '" . $GLOBALS['attributes'][$field]['label'] . "'];\n"; if ($key == $source) { $selected = ($criteria == $field) ? ' selected="selected"' : ''; $criteria_options .= "\n"; } $field_count++; + $criteria[$key][$field] = $GLOBALS['attributes'][$field]['label']; } $selected = ($key == $source) ? ' selected="selected"' : ''; @@ -30,11 +30,7 @@ foreach (Turba::getAddressBooks() as $key => $entry) { $source_count++; /* Remember vbooks and sources that are using shares. */ - if ($entry['type'] != 'vbook') { - $js_criteria .= "shareSources['$key'] = true;\n"; - } else { - $js_criteria .= "shareSources['$key'] = false;\n"; - } + $shareSources[$key] = $entry['type'] != 'vbook'; } /* Build search mode tabs. */ @@ -50,5 +46,5 @@ echo $tabs->render($_SESSION['turba']['search_mode']);
- +