From 94167443677c16effc99460b442f050b9135babf Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 26 Mar 2011 15:40:20 +0000 Subject: [PATCH] Merged [2958] from shane@time-travellers.org: Updated the JavaScript associated with the search page to control whether the 'search' button is enabled or not. It is now enabled if either the main search box has input, or if any of the sub-options have input, or both. Note that the Yahoo! widgets we were using did weird things to the button name, so I disabled that. This changes the look and feel of the button - that may be a contenious issue. OTOH, I think that this is probably a good thing, since this is the only place where we override the user's default appearance settings. Another possible issue is the use of JavaScript without JQuery. The existing code here did not use JQuery, so I decided to simply extend it. See the Trac ticket #480 for more. http://trac.tools.ietf.org/tools/ietfdb/ticket/480 - Legacy-Id: 2966 Note: SVN reference [2958] has been migrated to Git commit fc46dd1c9ebbe14c43a7e8726e194d197544e416 --- ietf/idrfc/views_search.py | 14 ++++++ ietf/templates/idrfc/search_form.html | 68 ++++++++++++++++++--------- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/ietf/idrfc/views_search.py b/ietf/idrfc/views_search.py index 03d99d758..ac2987c4e 100644 --- a/ietf/idrfc/views_search.py +++ b/ietf/idrfc/views_search.py @@ -42,8 +42,16 @@ from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect from ietf.idrfc.idrfc_wrapper import IdWrapper,RfcWrapper,IdRfcWrapper from ietf.utils import normalize_draftname +def addInputEvents(widget): + widget.attrs["oninput"] = 'inputEvent()' + widget.attrs["onpropertychange"] = 'propertyChange()' + +def addChangeEvent(widget): + widget.attrs["onchange"] = 'changeEvent()' + class SearchForm(forms.Form): name = forms.CharField(required=False) + addInputEvents(name.widget) rfcs = forms.BooleanField(required=False,initial=True) activeDrafts = forms.BooleanField(required=False,initial=True) oldDrafts = forms.BooleanField(required=False,initial=False) @@ -51,11 +59,17 @@ class SearchForm(forms.Form): by = forms.ChoiceField(choices=[(x,x) for x in ('author','group','area','ad','state')], required=False, initial='wg', label='Foobar') author = forms.CharField(required=False) + addInputEvents(author.widget) group = forms.CharField(required=False) + addInputEvents(group.widget) area = forms.ModelChoiceField(Area.active_areas(), empty_label="any area", required=False) + addChangeEvent(area.widget) ad = forms.ChoiceField(choices=(), required=False) + addChangeEvent(ad.widget) state = forms.ModelChoiceField(IDState.objects.all(), empty_label="any state", required=False) + addChangeEvent(state.widget) subState = forms.ChoiceField(choices=(), required=False) + addChangeEvent(subState.widget) def __init__(self, *args, **kwargs): super(SearchForm, self).__init__(*args, **kwargs) diff --git a/ietf/templates/idrfc/search_form.html b/ietf/templates/idrfc/search_form.html index f386c216f..9336e60da 100644 --- a/ietf/templates/idrfc/search_form.html +++ b/ietf/templates/idrfc/search_form.html @@ -77,10 +77,8 @@ Additional search criteria:
{# #} - - - +
@@ -88,28 +86,33 @@ Additional search criteria: