diff options
author | 2013-02-19 22:13:10 +0100 | |
---|---|---|
committer | 2013-02-19 22:13:10 +0100 | |
commit | c8bee03f8c0ca82c3981724e5bc661f630d9ab7e (patch) | |
tree | c81e552b54c210e74637437fd4eeca72eb24f510 /module/web/static/js/views/selectionView.js | |
parent | added shadow to package box (diff) | |
download | pyload-c8bee03f8c0ca82c3981724e5bc661f630d9ab7e.tar.xz |
integrated new package view
Diffstat (limited to 'module/web/static/js/views/selectionView.js')
-rw-r--r-- | module/web/static/js/views/selectionView.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/module/web/static/js/views/selectionView.js b/module/web/static/js/views/selectionView.js new file mode 100644 index 000000000..5cb22b776 --- /dev/null +++ b/module/web/static/js/views/selectionView.js @@ -0,0 +1,49 @@ +define(['jquery', 'backbone', 'underscore', 'app'], + function($, Backbone, _, App) { + + // Renders context actions for selection packages and files + return Backbone.View.extend({ + el: '#selection-area', + template: _.compile($("#template-select").html()), + + // available packages + tree: null, + // selected files + files: null, + // needed to know when slide down + current: 0, + + initialize: function(tree) { + this.tree = tree; + this.files = tree.get('files'); + + App.vent.on('dashboard:show', _.bind(this.set_files, this)); + App.vent.on('package:selection', _.bind(this.render, this)); + App.vent.on('file:selection', _.bind(this.render, this)); + }, + + render: function() { + var files = 0; + if (this.files) + files = this.files.where({selected: true}).length; + + var packs = this.tree.get('packages').where({selected: true}).length; + + if (files + packs > 0) + this.$el.html(this.template({files: files, packs: packs})); + + if (files + packs > 0 && this.current === 0) + this.$el.slideOut(); + else if (files + packs === 0 && this.current > 0) + this.$el.slideIn(); + + this.current = files + packs; + + }, + + set_files: function(files) { + this.files = files; + this.render(); + } + }); + });
\ No newline at end of file |