mirror of
https://github.com/fergalmoran/dss.git
synced 2026-02-02 22:24:52 +00:00
74 lines
2.4 KiB
JavaScript
Executable File
74 lines
2.4 KiB
JavaScript
Executable File
// Generated by CoffeeScript 1.6.2
|
|
(function() {
|
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
|
__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', 'marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView'], function($, Marionette, UserCollection, UserItemView, Template) {
|
|
var UserListView, _ref;
|
|
|
|
UserListView = (function(_super) {
|
|
__extends(UserListView, _super);
|
|
|
|
function UserListView() {
|
|
this.doSearch = __bind(this.doSearch, this);
|
|
this._fetchCollection = __bind(this._fetchCollection, this);
|
|
this.initialize = __bind(this.initialize, this); _ref = UserListView.__super__.constructor.apply(this, arguments);
|
|
return _ref;
|
|
}
|
|
|
|
UserListView.prototype.template = _.template(Template);
|
|
|
|
UserListView.prototype.events = {
|
|
"keyup #search-text": "doSearch"
|
|
};
|
|
|
|
UserListView.prototype.ui = {
|
|
searchText: "#search-text"
|
|
};
|
|
|
|
UserListView.prototype.className = "row";
|
|
|
|
UserListView.prototype.itemView = UserItemView;
|
|
|
|
UserListView.prototype.itemViewContainer = "#user-table";
|
|
|
|
UserListView.prototype.initialize = function() {
|
|
console.log("UserListView: initialize");
|
|
this.collection = new UserCollection();
|
|
this._fetchCollection(this.options);
|
|
};
|
|
|
|
UserListView.prototype._fetchCollection = function(options) {
|
|
var _this = this;
|
|
|
|
return this.collection.fetch({
|
|
data: options,
|
|
success: function() {
|
|
console.log("UserListView: Collection fetched");
|
|
}
|
|
});
|
|
};
|
|
|
|
UserListView.prototype.doSearch = function() {
|
|
var query;
|
|
|
|
console.log("UserListView: doSearch");
|
|
query = this.ui.searchText.val();
|
|
if (query) {
|
|
return this._fetchCollection({
|
|
q: query
|
|
});
|
|
} else {
|
|
return this._fetchCollection(this.options);
|
|
}
|
|
};
|
|
|
|
return UserListView;
|
|
|
|
})(Marionette.CompositeView);
|
|
return UserListView;
|
|
});
|
|
|
|
}).call(this);
|