summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views/selectionView.js
diff options
context:
space:
mode:
Diffstat (limited to 'module/web/static/js/views/selectionView.js')
-rw-r--r--module/web/static/js/views/selectionView.js49
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