diff -r dbd90c784424 -r cc9deb3b3e13 client/js/list-bin.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/client/js/list-bin.js Wed Mar 13 10:19:24 2013 +0100
@@ -0,0 +1,71 @@
+Rkns.ListBin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+Rkns.ListBin.prototype.resultTemplate = Rkns._.template(
+ '
" data-description="<%-description%>" data-image="<%-image%>">'
+ + '<% if (image) { %>
<% } %>'
+ + '<% if (description) { %><%=hdescription%>
<% } %><% if (image) { %><% } %>'
+);
+
+Rkns.ListBin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.title_$.html(_opts.title);
+ if (_opts.list) {
+ this.data = _opts.list;
+ }
+ this.refresh();
+}
+
+Rkns.ListBin.prototype.render = function(searchstr) {
+ if (searchstr) {
+ var _rgxp = new RegExp('('+(searchstr).replace(/(\W)/g,'\\$1')+')','gi'),
+ rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i');
+ }
+ function highlight(_text) {
+ if (searchstr) {
+ return _text.replace(_rgxp, "$1");
+ } else {
+ return _text;
+ }
+ }
+ var _html = "",
+ _this = this,
+ count = 0;
+ Rkns._(this.data).each(function(_element) {
+ var title = _element.title || _element.url || "",
+ url = _element.url || "",
+ description = _element.description || "",
+ image = _element.image || "";
+ if (searchstr && !rxtest.test(title) && !rxtest.test(description)) {
+ return;
+ }
+ count++;
+ _html += _this.resultTemplate({
+ url: url,
+ title: title,
+ htitle: highlight(title),
+ image: image,
+ description: description,
+ hdescription: highlight(description),
+ static_url: _this.renkan.static_url
+ });
+ });
+ _this.main_$.html(_html);
+ if (searchstr && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (searchstr && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+}
+
+Rkns.ListBin.prototype.refresh = function() {
+ if (this.data) {
+ this.render();
+ }
+}
\ No newline at end of file