From 1da5d741272de374bd11d4224be347bc6aa45053 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 27 Feb 2013 14:02:03 +0100 Subject: prepared dashboard actionbar --- module/web/static/css/default/dashboard.less | 7 +++--- module/web/static/js/models/File.js | 6 ++++- module/web/static/js/views/fileView.js | 8 +++---- module/web/static/js/views/selectionView.js | 33 +++++++++++++++++++++++++--- 4 files changed, 42 insertions(+), 12 deletions(-) (limited to 'module/web/static') diff --git a/module/web/static/css/default/dashboard.less b/module/web/static/css/default/dashboard.less index 12d833168..e9d313d32 100644 --- a/module/web/static/css/default/dashboard.less +++ b/module/web/static/css/default/dashboard.less @@ -167,14 +167,13 @@ .gradient(top, @blue, @blueDark); } - &.selected { + &.ui-selected { .gradient(top, @yellow, @yellowDark); color: @dark; .iconf-chevron-down:hover { color: @light; } - } img { @@ -252,6 +251,6 @@ FANCY CHECKBOXES cursor: pointer; } -.file-view.selected .checkbox { +.file-view.ui-selected .checkbox { background: url(../../img/default/checks_sheet.png) -21px top no-repeat; -} +} \ No newline at end of file diff --git a/module/web/static/js/models/File.js b/module/web/static/js/models/File.js index efea23254..e965df9df 100644 --- a/module/web/static/js/models/File.js +++ b/module/web/static/js/models/File.js @@ -14,7 +14,11 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { media: -1, added: -1, fileorder: -1, - download: null + download: null, + + // UI attributes + selected: false, + visible: true }, 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 -- cgit v1.2.3