Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0RC1

Request #4566 Add short delay before applying filter
Submitted: 2005-06-10 14:41 UTC
From: studio at peptolab dot com Assigned:
Status: Open Package: HTML_QuickForm_SelectFilter
PHP Version: Irrelevant OS: Any
Roadmaps: (Not assigned)    
Subscription  


 [2005-06-10 14:41 UTC] studio at peptolab dot com
Description: ------------ The filter function will slow down, naturally, when the select element contains many hundreds or even thousands of elements. This delay can force, for example, 5 long-ish delays for a 5 letter filter word, as the filter is applied for each keystroke. It would be great to add a default behaviour to allow a small timer (300 - 400milliseconds) to delay the filter to allow enough time to capture many user keystrokes before it is fully applied. Reproduce code: --------------- I have modified the javascript code below (a hack to get it to work) that demonstrates the desired behaviour:- ...existing code... <script type="text/javascript"> //<![CDATA[ // begin javascript for filtered select var values = new Array(); var QF_SelectFilterObj, QF_SelectFilterValue, QF_SelectFilterTimeout, QF_SelectFilterMustStart; var QF_SelectFilterCnt = 0; function QF_SelectFilterTimeOut(str, list, muststart) { QF_SelectFilterCnt++; QF_SelectFilterObj = list; QF_SelectFilterValue = str; QF_SelectFilterMustStart = muststart; QF_SelectFilterTimeout = setTimeout("QF_SelectFilter(QF_SelectFilterValue, QF_SelectFilterObj, QF_SelectFilterMustStart)",350); } function QF_SelectFilter(str, list, muststart) { QF_SelectFilterCnt--; if (QF_SelectFilterCnt) { return false; } str = QF_SelectFilterValue.value; if (!values[list.name]) { // first use of this list, we store initial elements ...continue... The 'QF_SelectFilterCnt' allows for all keystrokes to set and clear timeouts before proceeding to apply the filter. I think there's certainly a more graceful way to handle the timeout syntax, but you get the idea! Expected result: ---------------- The above code snippet will implement a Javascript timer to allow extra keystrokes before the buffer is applied. It would be also in keeping with the flexibility of the class to allow a 'setDelay' method to the Quickform object to tweak the delay as required.

Comments