Reorganizing UI, adding TimelineListView.
This commit is contained in:
51
www/js/ts.js
51
www/js/ts.js
@ -71,6 +71,10 @@ $(document).ready(function(){
|
||||
_.bindAll(this, 'url');
|
||||
},
|
||||
|
||||
comparator: function(timeline) {
|
||||
return timeline.get('id');
|
||||
},
|
||||
|
||||
url: function() {
|
||||
return "/ts_api/timelines/" + this.user.get('id');
|
||||
}
|
||||
@ -93,7 +97,8 @@ $(document).ready(function(){
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
_.bindAll(this, 'render', 'close');
|
||||
_.bindAll(this, 'render', 'close', 'editTImestamp',
|
||||
'editMark', 'updateOnEnter');
|
||||
this.model.bind('change', this.render);
|
||||
this.model.view = this;
|
||||
},
|
||||
@ -129,21 +134,33 @@ $(document).ready(function(){
|
||||
|
||||
TS.EntryListView = Backbone.View.extend({
|
||||
|
||||
el: $("#entries"),
|
||||
el: $("#entry-list"),
|
||||
|
||||
events: {
|
||||
"#new-entry" : "createNewEntry"
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
_.bindAll(this, 'addOne', 'render');
|
||||
_.bindAll(this, 'addOne', 'createNewEntry', 'render');
|
||||
this.collection.bind('add', this.addOne);
|
||||
this.collection.bind('refresh', this.render);
|
||||
this.collection.view = this;
|
||||
this.entryContainer = this.$("#entries")
|
||||
},
|
||||
|
||||
addOne: function(entry) {
|
||||
$(this.el).append(entry.view.render().el);
|
||||
if (!entry.view) { new TS.EntryView({model: entry}); }
|
||||
this.entryContainer.prepend(entry.view.render().el);
|
||||
},
|
||||
|
||||
createNewEntry: function() {
|
||||
var entryMark = this.$("#new-entry-input").val();
|
||||
var newEntry = TS.EntryModel({mark: entryMark});
|
||||
this.collection.create({mark: entryMark}).fetch();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).empty();
|
||||
this.entryContainer.empty();
|
||||
this.collection.each(this.addOne);
|
||||
}
|
||||
});
|
||||
@ -199,6 +216,30 @@ $(document).ready(function(){
|
||||
}
|
||||
});
|
||||
|
||||
TS.TimelineListView = Backbone.View.extend({
|
||||
el: $("#timeline .drop-menu-items"),
|
||||
|
||||
collection: TS.TimelineList,
|
||||
|
||||
initialize: function() {
|
||||
_.bindAll(this, 'render', 'renderOne');
|
||||
this.collection.bind('add', this.renderOne);
|
||||
this.collection.bind('refresh', this.render);
|
||||
this.collection.view = this;
|
||||
},
|
||||
|
||||
renderOne: function(timeline) {
|
||||
if (!timeline.view) { new TS.TimelineView(timeline); }
|
||||
$(this.el).append(ich.timelineLink(timeline.toJSON()));
|
||||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).remove(".timeline-link");
|
||||
this.collection.each(this.renderOne);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
TS.UserView = Backbone.View.extend({
|
||||
|
||||
el: $("#user"),
|
||||
|
Reference in New Issue
Block a user