## jquery
##
JQUERY_VERSION=1.4.2
-JQUERY_PLUGINS=color
+JQUERY_PLUGINS=color form
JQUERY_PLUGINS_PATHES=$(addprefix htdocs/javascript/jquery.,$(addsuffix .js,$(JQUERY_PLUGINS)))
JQUERY_UI_VERSION=1.6
htdocs/javascript/jquery.js: htdocs/javascript/jquery-$(JQUERY_VERSION).min.js
ln -snf $(<F) $@
-$(JQUERY_PLUGINS_PATHES): DOWNLOAD_SRC = http://plugins.jquery.com/files/$(@F).txt
+$(JQUERY_PLUGINS_PATHES): DOWNLOAD_SRC = http://plugins.jquery.com/files/$(@F)_0.txt
$(JQUERY_PLUGINS_PATHES):
@-rm htdocs/javascript/jquery.ui*.$*.js
@$(download)
<h1>Recherche dans l'annuaire</h1>
+{javascript name=jquery.form}
+
<script type="text/javascript">// <!--
var baseurl = platal_baseurl + "search/";
{literal}
$(this).parent().find('.autocompleteTarget').val('');
});
});
+/** Regexps to wipe out from search queries */
+var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&[^&=]+=(&|$)/g ];
+/** Uses javascript to clean form from all empty fields */
+function cleanForm(f) {
+ var query = $(f).formSerialize();
+ var old_query;
+ for each (var reg in default_form_values) if (typeof(reg) != "undefined") {
+ do {
+ old_query = query;
+ query = query.replace(reg, '$1');
+ } while (old_query != query);
+ }
+ query = query.replace(/^&*(.*)&*$/, '$1');
+ if (query == "") {
+ alert("Aucun critère n'a été spécifié");
+ return false;
+ }
+ document.location = f.action + '?' + query;
+ return false;
+}
-->
{/literal}</script>
<p class="center">[<a href="search">Revenir à la recherche simple</a>]</p>
-<form id="recherche" action="search/adv" method="get">
+<form id="recherche" action="search/adv" method="get" onsubmit="return cleanForm(this)">
<table class="bicol" cellpadding="3" summary="Recherche">
<tr>
<th colspan="2">