From: Marcin Koziej Date: Wed, 28 Dec 2011 09:14:23 +0000 (+0100) Subject: merge wyszukiwania. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/9fbf0c4158a9427442171629a564e2de7780b5b7 merge wyszukiwania. Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty Conflicts: lib/librarian wolnelektury/templates/base.html --- 9fbf0c4158a9427442171629a564e2de7780b5b7 diff --cc wolnelektury/settings.py index fe2572904,18e8d7573..f01ab182f --- a/wolnelektury/settings.py +++ b/wolnelektury/settings.py @@@ -206,10 -201,9 +207,11 @@@ COMPRESS_JS = 'js/locale.js', 'js/dialogs.js', 'js/sponsors.js', + 'js/base.js', 'js/pdcounter.js', + 'js/search.js', + #~ 'js/jquery.autocomplete.js', #~ 'js/jquery.labelify.js', 'js/catalogue.js', ), diff --cc wolnelektury/static/js/search.js index e58d37256,000000000..c41a672d0 mode 100644,000000..100644 --- a/wolnelektury/static/js/search.js +++ b/wolnelektury/static/js/search.js @@@ -1,49 -1,0 +1,49 @@@ + +var __bind = function (self, fn) { + return function() { fn.apply(self, arguments); }; +}; + +(function($){ + $.widget("wl.search", { + options: { + minLength: 0, + }, + + _create: function() { + var opts = { + minLength: this.options.minLength, + select: __bind(this, this.enter), + focus: function() { return false; }, + source: this.element.data('source'), + }; + this.element.autocomplete(opts).data("autocomplete")._renderItem = __bind(this, this.render_item); + }, + + enter: function(event, ui) { + if (ui.item.url != undefined) { + location.href = ui.item.url; + } else { + this.element.closest('form').submit(); + } + }, + + render_item: function (ul, item) { + return $("
  • ").data('item.autocomplete', item) + .append(''+item.label+ ' ('+item.category+')') + .appendTo(ul); + }, + + destroy: function() { + + }, + + + + }); + + $(function() { - $("#search input[name=q]").search(); ++ $("#search-area input[name=q]").search(); + + }); + +})(jQuery); diff --cc wolnelektury/templates/base.html index d1bf19e8a,4409486ed..48f13adb2 --- a/wolnelektury/templates/base.html +++ b/wolnelektury/templates/base.html @@@ -62,10 -72,10 +72,10 @@@ -