From 9682ba3b7adcac116b0f2fbf8d1a9b620f767fba Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 9 Jul 2013 20:55:43 +0200 Subject: little fixes for actionbar and selection --- pyload/web/.jshintrc | 29 ---------------------- pyload/web/Gruntfile.js | 2 +- pyload/web/app/scripts/controller.js | 11 +++++--- .../web/app/scripts/views/dashboard/filterView.js | 8 +++++- .../app/scripts/views/dashboard/selectionView.js | 7 +++--- .../app/templates/default/dashboard/actionbar.html | 2 +- 6 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 pyload/web/.jshintrc diff --git a/pyload/web/.jshintrc b/pyload/web/.jshintrc deleted file mode 100644 index 0cff430d9..000000000 --- a/pyload/web/.jshintrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "node": true, - "browser": true, - "esnext": true, - "bitwise": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 4, - "latedef": true, - "newcap": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "unused": false, - "camelcase": false, - "-W030": false, - "-W015": false, - "-W116": false, - "predef": [ - "require", - "define", - "alert" - ] -} diff --git a/pyload/web/Gruntfile.js b/pyload/web/Gruntfile.js index aa2077c0c..92bb33da9 100644 --- a/pyload/web/Gruntfile.js +++ b/pyload/web/Gruntfile.js @@ -105,7 +105,7 @@ module.exports = function(grunt) { }, jshint: { options: { - jshintrc: '.jshintrc' + jshintrc: '<%= yeoman.app %>/components/pyload-common/.jshintrc' }, all: [ 'Gruntfile.js', diff --git a/pyload/web/app/scripts/controller.js b/pyload/web/app/scripts/controller.js index 05237914d..60f604e5b 100644 --- a/pyload/web/app/scripts/controller.js +++ b/pyload/web/app/scripts/controller.js @@ -1,6 +1,7 @@ define([ 'app', 'backbone', + 'underscore', // Views 'views/headerView', @@ -12,7 +13,7 @@ define([ 'views/settings/settingsView', 'views/accounts/accountListView' ], function( - App, Backbone, HeaderView, NotificationView, DashboardView, SelectionView, FilterView, LoginView, SettingsView, AccountListView) { + App, Backbone, _, HeaderView, NotificationView, DashboardView, SelectionView, FilterView, LoginView, SettingsView, AccountListView) { 'use strict'; // TODO some views does not need to be loaded instantly @@ -30,8 +31,12 @@ define([ this.header(); App.actionbar.show(new FilterView()); - // TODO: not completly visible after reattaching - App.selection.attachView(new SelectionView()); + + // TODO: not completely visible after reattaching + // now visible every time + if (_.isUndefined(App.selection.currentView) || _.isNull(App.selection.currentView)) + App.selection.attachView(new SelectionView()); + App.content.show(new DashboardView()); }, diff --git a/pyload/web/app/scripts/views/dashboard/filterView.js b/pyload/web/app/scripts/views/dashboard/filterView.js index 64bc56724..ceb2a9a6e 100644 --- a/pyload/web/app/scripts/views/dashboard/filterView.js +++ b/pyload/web/app/scripts/views/dashboard/filterView.js @@ -17,6 +17,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac return Backbone.Marionette.ItemView.extend({ events: { + 'click .li-check': 'toggle_selection', 'click .filter-type': 'filter_type', 'click .filter-state': 'switch_filter', 'submit .form-search': 'search' @@ -24,7 +25,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac ui: { 'search': '.search-query', - 'stateMenu': '.dropdown-toggle .state' + 'stateMenu': '.dropdown-toggle .state', + 'select': '.btn-check' }, template: template, @@ -125,6 +127,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Pac return true; }, + toggle_selection: function() { + App.vent.trigger('selection:toggle'); + }, + filter_type: function(e) { } diff --git a/pyload/web/app/scripts/views/dashboard/selectionView.js b/pyload/web/app/scripts/views/dashboard/selectionView.js index 8685fd849..f25bf3cca 100644 --- a/pyload/web/app/scripts/views/dashboard/selectionView.js +++ b/pyload/web/app/scripts/views/dashboard/selectionView.js @@ -28,9 +28,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'hbs!tpl/dashboard/select'], App.vent.on('dashboard:filtered', render); App.vent.on('package:selection', render); App.vent.on('file:selection', render); + App.vent.on('selection:toggle', _.bind(this.select_toggle, this)); - this.actionBar = $('.actionbar .btn-check'); - this.actionBar.parent().click(_.bind(this.select_toggle, this)); // API events, maybe better to rely on internal ones? App.vent.on('package:deleted', render); @@ -71,11 +70,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'hbs!tpl/dashboard/select'], // TODO: accessing ui directly, should be events if (files > 0) { - this.actionBar.addClass('icon-check').removeClass('icon-check-empty'); + App.actionbar.currentView.ui.select.addClass('icon-check').removeClass('icon-check-empty'); App.dashboard.ui.packages.addClass('ui-files-selected'); } else { - this.actionBar.addClass('icon-check-empty').removeClass('icon-check'); + App.actionbar.currentView.ui.select.addClass('icon-check-empty').removeClass('icon-check'); App.dashboard.ui.packages.removeClass('ui-files-selected'); } diff --git a/pyload/web/app/templates/default/dashboard/actionbar.html b/pyload/web/app/templates/default/dashboard/actionbar.html index 815d4593c..a8b2ebecd 100644 --- a/pyload/web/app/templates/default/dashboard/actionbar.html +++ b/pyload/web/app/templates/default/dashboard/actionbar.html @@ -16,7 +16,7 @@ -
  • +