diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-02-26 19:18:34 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-02-26 19:18:34 +0100 |
commit | a4bc6867bd42fca9b37156e080d1c8b058fc9ca5 (patch) | |
tree | 00cb06f2e7acf339afe822b347f02f251ad31db9 /module/web/static/js | |
parent | improved package and global menu (diff) | |
download | pyload-a4bc6867bd42fca9b37156e080d1c8b058fc9ca5.tar.xz |
improved file view, added default plugin icon
Diffstat (limited to 'module/web/static/js')
-rw-r--r-- | module/web/static/js/views/fileView.js | 91 |
1 files changed, 58 insertions, 33 deletions
diff --git a/module/web/static/js/views/fileView.js b/module/web/static/js/views/fileView.js index c7b87e871..ef1f5bba8 100644 --- a/module/web/static/js/views/fileView.js +++ b/module/web/static/js/views/fileView.js @@ -1,38 +1,63 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], function($, Backbone, _, App, ItemView) { - // Renders single file item - return ItemView.extend({ + // Renders single file item + return ItemView.extend({ - tagName: 'li', - className: 'file-view', + tagName: 'li', + className: 'file-view', // template: _.template($("#template-file").html()), - template: _.compile($("#template-file").html()), - events: { - 'click .checkbox': 'select' - }, - - initialize: function() { - this.listenTo(this.model, 'change', this.render); - this.listenTo(this.model, 'remove', this.destroy); - }, - - onDestroy: function() { - }, - - render: function() { - this.$el.html(this.template(this.model.toJSON())); - return this; - }, - - select: function(e) { - e.preventDefault(); - var checked = this.$('.checkbox').hasClass('checked'); - // toggle class immediately, so no re-render needed - this.model.set('selected', !checked, {silent: true}); - this.$('.checkbox').toggleClass('checked'); - App.vent.trigger('file:selection'); - } - - }); -});
\ No newline at end of file + template: _.compile($("#template-file").html()), + events: { + 'click .checkbox': 'select' + }, + + initialize: function() { + this.listenTo(this.model, 'change', this.render); + this.listenTo(this.model, 'remove', this.destroy); + }, + + onDestroy: function() { + }, + + render: function() { + var data = this.model.toJSON(); + if (data.download) { + var status = data.download.status; + // TODO: remove hardcoded states + if (status === 1 || status === 11) + data.offline = true; + else if (status === 7) + data.failed = true; + else if (status === 2) + data.online = true; + else if (status === 9) + data.waiting = true; + else if (status === 10) + data.downloading = true; + else if (status === 5 || status === 6) + data.finished = true; + } + + this.$el.html(this.template(data)); + if (this.model.get('selected')) + this.$el.addClass('selected'); + else + this.$el.removeClass('selected'); + + this.$('.iconf-chevron-down').dropdown(); + + return this; + }, + + select: function(e) { + e.preventDefault(); + var checked = this.$el.hasClass('selected'); + // toggle class immediately, so no re-render needed + this.model.set('selected', !checked, {silent: true}); + this.$el.toggleClass('selected'); + App.vent.trigger('file:selection'); + } + + }); + });
\ No newline at end of file |