mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 17:48:51 +00:00
69 lines
2.2 KiB
JavaScript
69 lines
2.2 KiB
JavaScript
// Generated by CoffeeScript 1.3.3
|
|
(function() {
|
|
var __hasProp = {}.hasOwnProperty,
|
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
|
|
define(['jquery', 'underscore', 'libs/bootstrap/bootstrap-typeahead', 'marionette', 'vent', 'text!/tpl/SearchView', 'text!/tpl/SearchResultView'], function($, _, Typeahead, Marionette, vent, Template, SearchResultView) {
|
|
var SearchView;
|
|
SearchView = (function(_super) {
|
|
|
|
__extends(SearchView, _super);
|
|
|
|
function SearchView() {
|
|
return SearchView.__super__.constructor.apply(this, arguments);
|
|
}
|
|
|
|
SearchView.prototype.template = _.template(Template);
|
|
|
|
SearchView.prototype.ui = {
|
|
searchText: '#search-text'
|
|
};
|
|
|
|
SearchView.prototype.engine = {
|
|
compile: function(template) {
|
|
var compiled;
|
|
compiled = _.template(template);
|
|
return {
|
|
render: function(context) {
|
|
return compiled(context);
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
SearchView.prototype.onShow = function() {
|
|
var t;
|
|
console.log("SearchView: onShow");
|
|
t = $('#search-text', this.el).typeahead({
|
|
name: "search",
|
|
engine: this.engine,
|
|
valueKey: "title",
|
|
template: SearchResultView,
|
|
remote: {
|
|
url: "/api/v1/mix/search?q=%QUERY",
|
|
dataType: "json",
|
|
filter: function(parsedResponse) {
|
|
return parsedResponse.objects;
|
|
}
|
|
}
|
|
});
|
|
$('.tt-hint', this.el).addClass('search-query');
|
|
$('.tt-hint', this.el).addClass('span3');
|
|
return t.on({
|
|
'typeahead:selected': function(event, datum, dataset_name) {
|
|
console.log("SearchView: Selected");
|
|
vent.trigger('navigate:mix', datum.slug);
|
|
$('#search-text', this.el).blur();
|
|
return $('.tt-hint', this.el).blur();
|
|
}
|
|
});
|
|
};
|
|
|
|
return SearchView;
|
|
|
|
})(Marionette.CompositeView);
|
|
return SearchView;
|
|
});
|
|
|
|
}).call(this);
|