Code layout change.
[wolnelektury.git] / src / wolnelektury / static / js / widget_run.js
diff --git a/src/wolnelektury/static/js/widget_run.js b/src/wolnelektury/static/js/widget_run.js
new file mode 100644 (file)
index 0000000..c2453e7
--- /dev/null
@@ -0,0 +1,26 @@
+var s = $('#id_qq');
+var url = s.attr('data-source');
+s.search({
+    source: function(req, cb) {
+        $.ajax({url: url,
+            dataType: "jsonp",
+            data: {term: req.term},
+            type: "GET",
+            success: function(data) {cb(data);},
+            error: function() {cb([]);}
+        });
+    },
+    dataType: "jsonp",
+    select: function(event, ui) {
+        if (ui.item.url != undefined) {
+            window.top.location.href = '//wolnelektury.pl' + ui.item.url;
+        } else {
+            $('form').submit();
+        }
+    },
+    position: {
+        my: "center bottom",
+        at: "center bottom",
+        of: "#wl a"
+    },
+});