Remove picture models.
[wolnelektury.git] / src / wolnelektury / static / js / search.js
index 7f2a698..536164b 100644 (file)
@@ -20,8 +20,8 @@ var __bind = function (self, fn) {
             };
 
             this.element.autocomplete($.extend(opts, this.options));
             };
 
             this.element.autocomplete($.extend(opts, this.options));
-            this.element.autocomplete('instance')._renderItem = __bind(this, this.render_item_2022);
-            this.element.data('autocomplete')._renderItem = __bind(this, this.render_item);;
+            if (this.element.autocomplete('instance') !== undefined) this.element.autocomplete('instance')._renderItem = __bind(this, this.render_item_2022);
+            if (this.element.data('autocomplete') !== undefined) this.element.data('autocomplete')._renderItem = __bind(this, this.render_item);;
         },
 
         enter: function(event, ui) {
         },
 
         enter: function(event, ui) {
@@ -46,14 +46,19 @@ var __bind = function (self, fn) {
 
         render_item_2022: function (ul, item) {
             var label;
 
         render_item_2022: function (ul, item) {
             var label;
-            if (item['author']) {
+            var $label = $("<li><a><div></div><span></span></a></li>");
+            if (item.img) {
+                $('div', $label).append($('<img>').attr('src', item.img));
+            }
+            if (item.author) {
                 label = '<cite>' + item.label + '</cite>, ' + item['author'];
             } else {
                 label = item.label;
             }
                 label = '<cite>' + item.label + '</cite>, ' + item['author'];
             } else {
                 label = item.label;
             }
-            return $("<li></li>")
-            .append('<a href="'+this.options.host+item.url+'">'+label+'</a>')
-            .appendTo(ul);
+            $('span', $label).html(label);
+            $label.addClass('type-' + item.type);
+            $label.appendTo(ul);
+            return $label;
         },
 
         destroy: function() {
         },
 
         destroy: function() {