Set autocomplete cache search setting to 'word'.
jquery.autocomplete: escaping strings for regex.
jquery.countdown: minor fix.
class SearchForm(forms.Form):
- q = JQueryAutoCompleteField('/katalog/tags/', {'minChars': 2, 'selectFirst': True, 'cacheLength': 50})
+ q = JQueryAutoCompleteField('/katalog/tags/', {'minChars': 2, 'selectFirst': True, 'cacheLength': 50, 'matchContains': "word"})
tags = forms.CharField(widget=forms.HiddenInput, required=False)
def __init__(self, *args, **kwargs):
* Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
*/
+/*
+ * Modified by Radek Czajka, Fundacja Nowoczesna Polska, 2010-05-10:
+ * escape regex for word start checking in matchSubset
+ */
+
;(function($) {
$.fn.extend({
s = s.toLowerCase();
var i = s.indexOf(sub);
if (options.matchContains == "word"){
- i = s.toLowerCase().search("\\b" + sub.toLowerCase());
+ i = s.toLowerCase().search("\\b" + sub.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1").toLowerCase());
}
if (i == -1) return false;
return i == 0 || options.matchContains;
labels: ['lat', 'miesięcy', 'tygodni', 'dni', 'godzin', 'minut', 'sekund'],\r
labels1: ['rok', 'miesiąc', 'tydzień', 'dzień', 'godzina', 'minuta', 'sekunda'],\r
labels2: ['lata', 'miesiące', 'tygodnie', 'dni', 'godziny', 'minuty', 'sekundy'],\r
- compactLabels: ['l', 'm', 't', 'd'], compactLabels1: ['r', 'm', 't', 'd'],\r
+ compactLabels: ['l', 'm', 't', 'd'],\r
+ compactLabels1: ['r', 'm', 't', 'd'],\r
+ compactLabels2: ['l', 'm', 't', 'd'],\r
timeSeparator: ':', isRTL: false,\r
which: function(n){\r
return n==1 ? 1 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 2 : 0;\r
Please attribute the author if you use it. */
/* Modified by Radek Czajka, Fundacja Nowoczesna Polska (radoslaw.czajka(at)nowoczesnapolska.org.pl) */
-
+w
/* Display a countdown timer.
Attach it with options like:
$('div selector').countdown(
var timeSeparator = this._get(inst, 'timeSeparator');
var description = this._get(inst, 'description') || '';
var showCompact = function(period) {
- var labelsNum = $.countdown._get(inst, 'compactLabels' + periods[period]);
+ var which = $.countdown._get(inst, 'which');
+ if (which) {
+ var labelsNum = $.countdown._get(inst, 'compactLabels' + which(periods[period]));
+ }
return (show[period] ? periods[period] +
(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
};