Browse Source

[enh] new plugin: search on category select (currently only in oscar theme)

TODO
purge mootools from default/courgette and integrate jquery ++ this theme
Adam Tauber 10 years ago
parent
commit
973c97c85b

+ 3
- 1
searx/plugins/__init__.py View File

@@ -1,4 +1,5 @@
1
-from searx.plugins import self_ip
1
+from searx.plugins import (self_ip,
2
+                           search_on_category_select)
2 3
 from searx import logger
3 4
 from sys import exit
4 5
 
@@ -52,3 +53,4 @@ class PluginStore():
52 53
 
53 54
 plugins = PluginStore()
54 55
 plugins.register(self_ip)
56
+plugins.register(search_on_category_select)

+ 6
- 0
searx/plugins/search_on_category_select.py View File

@@ -0,0 +1,6 @@
1
+from flask.ext.babel import gettext
2
+name = 'Search on category select'
3
+description = gettext('Perform search immediately if a category selected')
4
+default_on = False
5
+
6
+js_dependencies = ('js/search_on_category_select.js',)

+ 14
- 0
searx/static/js/search_on_category_select.js View File

@@ -0,0 +1,14 @@
1
+$(document).ready(function() {
2
+    if($('#q')) {
3
+        $('#categories label').click(function(e) {
4
+            $('#categories input[type="checkbox"]').each(function(i, checkbox) {
5
+                $(checkbox).prop('checked', false);
6
+            });
7
+            $('#categories label').removeClass('btn-primary').removeClass('active').addClass('btn-default');
8
+            $(this).removeClass('btn-default').addClass('btn-primary').addClass('active');
9
+            $($(this).children()[0]).prop('checked', 'checked');
10
+            $('#search_form').submit();
11
+            return false;
12
+        });
13
+    }
14
+});