summaryrefslogtreecommitdiffstats
path: root/web/js/labitrack.d/47-recent.js
blob: bb49e1fddc51032c82b86c473ae9496e33373061 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function(){
	function hdl_add(){
		console.log('add');
	}

	function hdl_remove(){
		console.log('remove');
	}

	function hdl_reset(){
		console.log('reset');
		this.render();
	}

	var collection = Backbone.Collection.extend({
		model: λ.o,
		url: 'recent.json',
		comparator: function(object){
			return -object.get('updated');
		}
	});

	var recent = Backbone.View.extend({
		initialize: function() {
			var messages = this.collection;
			messages.bind("reset", hdl_reset, this);
			messages.bind("add", hdl_add, this);
			messages.bind("remove", hdl_remove, this);
		},
		render: function(){
			var data = {
				rows: this.collection.toJSON()
			};
			console.log(data);
			$(this.el).html(λ.template('objecttable', data));
		}
	});

	var view = λ.routableview.extend({
		initialize: function() {
			λ.routableview.prototype.initialize.call(this);
			this.browse = new recent({collection: new collection()});
		},
		render: function (page) {
			page || (page = 1);
			λ.setcontent('recent');
			this.browse.el = $(this.el).find('#objecttable_ph')[0];
			this.browse.render();
			this.browse.collection.fetch();
		}
	});

	view.route('recent');
}());