diff options
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r-- | module/web/static/js/views/fileView.js | 8 | ||||
-rw-r--r-- | module/web/static/js/views/selectionView.js | 33 |
2 files changed, 34 insertions, 7 deletions
diff --git a/module/web/static/js/views/fileView.js b/module/web/static/js/views/fileView.js index ef1f5bba8..3a4183289 100644 --- a/module/web/static/js/views/fileView.js +++ b/module/web/static/js/views/fileView.js @@ -41,9 +41,9 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], this.$el.html(this.template(data)); if (this.model.get('selected')) - this.$el.addClass('selected'); + this.$el.addClass('ui-selected'); else - this.$el.removeClass('selected'); + this.$el.removeClass('ui-selected'); this.$('.iconf-chevron-down').dropdown(); @@ -52,10 +52,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], select: function(e) { e.preventDefault(); - var checked = this.$el.hasClass('selected'); + var checked = this.$el.hasClass('ui-selected'); // toggle class immediately, so no re-render needed this.model.set('selected', !checked, {silent: true}); - this.$el.toggleClass('selected'); + this.$el.toggleClass('ui-selected'); App.vent.trigger('file:selection'); } diff --git a/module/web/static/js/views/selectionView.js b/module/web/static/js/views/selectionView.js index 6d346b6ee..4c433e31c 100644 --- a/module/web/static/js/views/selectionView.js +++ b/module/web/static/js/views/selectionView.js @@ -17,6 +17,8 @@ define(['jquery', 'backbone', 'underscore', 'app'], tree: null, // selected files files: null, + // Element of the action bar + actionBar: null, // needed to know when slide down current: 0, @@ -28,7 +30,10 @@ define(['jquery', 'backbone', 'underscore', 'app'], App.vent.on('package:selection', _.bind(this.render, this)); App.vent.on('file:selection', _.bind(this.render, this)); - // TODO + this.actionBar = $('.actionbar .btn-check'); + this.actionBar.parent().click(_.bind(this.select_toggle, this)); + + // TODO when something gets deleted // this.tree.get('packages').on('delete', _.bind(this.render, this)); }, @@ -58,8 +63,12 @@ define(['jquery', 'backbone', 'underscore', 'app'], else if (files + packs === 0 && this.current > 0) this.$el.slideIn(); - this.current = files + packs; + if (files > 0) + this.actionBar.addClass('iconf-check').removeClass('iconf-check-empty'); + else + this.actionBar.addClass('iconf-check-empty').removeClass('iconf-check'); + this.current = files + packs; }, set_files: function(files) { @@ -67,7 +76,8 @@ define(['jquery', 'backbone', 'underscore', 'app'], this.render(); }, - deselect: function() { + // Deselects all items, optional only files + deselect: function(filesOnly) { this.get_files().map(function(file) { file.set('selected', false); }); @@ -107,6 +117,23 @@ define(['jquery', 'backbone', 'underscore', 'app'], }); this.deselect(); + }, + + // Select or deselect all visible files + select_toggle: function() { + var files = this.get_files(); + if (files.length === 0) { + // TODO Select only visible files + this.files.map(function(file) { + file.set('selected', true); + }); + + } else + files.map(function(file) { + file.set('selected', false); + }); + + this.render(); } }); });
\ No newline at end of file |