# HG changeset patch # User rougeronj # Date 1423649680 -3600 # Node ID 7eee076e994e9b583e1af7120ad1288a778116d3 # Parent 4c4cfe573486447e77625413850c73b00216694f Close #53 - add auto-completion to HDA Notices research diff -r 4c4cfe573486 -r 7eee076e994e src/hdalab/static/hdalab/css/additionnal_renkan.css --- a/src/hdalab/static/hdalab/css/additionnal_renkan.css Thu Feb 05 13:18:29 2015 +0100 +++ b/src/hdalab/static/hdalab/css/additionnal_renkan.css Wed Feb 11 11:14:40 2015 +0100 @@ -19,6 +19,11 @@ position: relative; box-shadow: 0 0 5px rgba(0, 0, 0, 0.4); } + +.ui-autocomplete.ui-widget-content{ + background: rgb(255, 255, 255); +} + .Rk-HdaNotices-Title-Icon { background: url("../img/page_icon.png") no-repeat -3px -5px; height: 20px; diff -r 4c4cfe573486 -r 7eee076e994e src/hdalab/static/hdalab/js/hdalab-renkan-bins.js --- a/src/hdalab/static/hdalab/js/hdalab-renkan-bins.js Thu Feb 05 13:18:29 2015 +0100 +++ b/src/hdalab/static/hdalab/js/hdalab-renkan-bins.js Wed Feb 11 11:14:40 2015 +0100 @@ -8,6 +8,29 @@ this.lang = _opts.lang || "fr"; this.image = _opts.image; this.url = _opts.url; + this.autoComplete(); +}; + +Rkns.HdaNotices.Search.prototype.autoComplete = function() { + var _this = this; + this.renkan.$.find(".Rk-Web-Search-Input").on("change keyup paste", function() { + if (_this.renkan.$.find(".Rk-Search-Current").hasClass(_this.getBgClass())){ + $.ajax({ + url: _this.url + "?q=" + _this.renkan.$.find(".Rk-Web-Search-Input").val() + "&format=json&limit=10", + success: function(data){ + var results = []; + if (typeof(data.results) != 'undefined'){ + data.results.forEach(function(result){ + results.push(result.title); + }); + _this.renkan.$.find(".Rk-Web-Search-Input").autocomplete({ + source: results + }); + } + } + }); + } + }); }; Rkns.HdaNotices.Search.prototype.getBgClass = function() {