opds fix
[wolnelektury.git] / apps / wolnelektury_core / static / js / widgetInit.js
1
2 var wl_scripts_loaded = {};
3
4 function wl_load_search_if_ready(id) {
5     wl_scripts_loaded[id] = true;
6     if (wl_scripts_loaded['wl-search-script'] &&
7         wl_scripts_loaded['wl-jquery-ui-script']) 
8     {
9         var s = $('#id_qq');
10         s.search({source: s.attr('data-source')});
11     }
12 }
13
14 $('#wl-search-script').ready(function(){wl_load_search_if_ready('wl-search-script');});
15 $('#wl-jquery-ui-script').ready(function(){wl_load_search_if_ready('wl-jquery-ui-script');});
16
17 /*autocomplete({
18                         source: function(request, response) {
19                                 $.ajax({
20                                         url: "http://www.wolnelektury.pl/katalog/jtags/",
21                                         dataType: "jsonp",
22                                         data: {
23                                                 featureClass: "P",
24                                                 style: "full",
25                                                 maxRows: 10,
26                                                 q: request.term
27                                         },
28                                         success: function(data) {
29                                                 response($.map(data.matches, function(item) {
30                                                         return {
31                                                                 label: item,
32                                                                 value: item
33                                                         }
34                                                 }))
35                                         }                                       
36                                 })
37                         },
38                         minLength: 2,
39             select: function(event, ui) {
40                 $("#id_qq").val(ui.item.value);
41                 $("#wl-form").submit();
42             }                   
43                 });
44         });
45 */