summaryrefslogtreecommitdiffstats
path: root/web/js/labitrack.d/47-recent.js
diff options
context:
space:
mode:
authorAsbjørn Sloth Tønnesen <asbjorn@asbjorn.biz>2012-06-28 19:49:45 +0000
committerAsbjørn Sloth Tønnesen <asbjorn@asbjorn.biz>2012-06-28 19:49:45 +0000
commit5e54ba7aa27b95d1e0568693915e735ab8058ff7 (patch)
tree1c2743605a6cce00edb82b5f15b9a3f08f6ace30 /web/js/labitrack.d/47-recent.js
downloadlabitrack-5e54ba7aa27b95d1e0568693915e735ab8058ff7.tar.gz
labitrack-5e54ba7aa27b95d1e0568693915e735ab8058ff7.tar.xz
labitrack-5e54ba7aa27b95d1e0568693915e735ab8058ff7.zip
Initial version
Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz>
Diffstat (limited to 'web/js/labitrack.d/47-recent.js')
-rw-r--r--web/js/labitrack.d/47-recent.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/web/js/labitrack.d/47-recent.js b/web/js/labitrack.d/47-recent.js
new file mode 100644
index 0000000..bb49e1f
--- /dev/null
+++ b/web/js/labitrack.d/47-recent.js
@@ -0,0 +1,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');
+}());