diff options
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r-- | module/web/static/js/views/abstract/itemView.js | 11 | ||||
-rw-r--r-- | module/web/static/js/views/dashboardView.js | 20 | ||||
-rw-r--r-- | module/web/static/js/views/fileView.js | 6 | ||||
-rw-r--r-- | module/web/static/js/views/packageView.js | 23 | ||||
-rw-r--r-- | module/web/static/js/views/selectionView.js | 19 |
5 files changed, 46 insertions, 33 deletions
diff --git a/module/web/static/js/views/abstract/itemView.js b/module/web/static/js/views/abstract/itemView.js index 1c14e7dc3..75b058874 100644 --- a/module/web/static/js/views/abstract/itemView.js +++ b/module/web/static/js/views/abstract/itemView.js @@ -8,14 +8,13 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { destroy: function() { this.undelegateEvents(); this.unbind(); - if (this.onDestroy){ + if (this.onDestroy) { this.onDestroy(); } this.$el.removeData().unbind(); this.remove(); }, - hide: function() { this.$el.slideUp(); }, @@ -25,9 +24,15 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { }, deleteItem: function(e) { - if(e) + if (e) e.stopPropagation(); this.model.destroy(); + }, + + restart: function(e) { + if(e) + e.stopPropagation(); + this.model.restart(); } }); diff --git a/module/web/static/js/views/dashboardView.js b/module/web/static/js/views/dashboardView.js index 7f2b9809a..9d5b62cc6 100644 --- a/module/web/static/js/views/dashboardView.js +++ b/module/web/static/js/views/dashboardView.js @@ -8,7 +8,6 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', el: '#content', events: { - 'click #show_active': 'filter' }, // <ul> holding the packages @@ -64,7 +63,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', packs.each(_.bind(this.appendPackage, this)); this.fileUL = this.$('.file-list'); - this.files.each(_.bind(this.appendFile, this)); + if (this.files.length === 0) + this.fileUL.append($('<li>No package selected</li>')); + else + this.files.each(_.bind(this.appendFile, this)); return this; }, @@ -115,19 +117,5 @@ define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', this.fileUL.fadeIn(); App.vent.trigger('dashboard:show', this.files); }, - - // TODO: remove this debug stuff - toggle: false, - filter: function(e) { - var self = this; - this.tree.get('packages').each(function(item) { - if (!self.toggle) - item.trigger('filter:added'); - else - item.trigger('filter:removed'); - - }); - self.toggle ^= true; - } }); });
\ No newline at end of file diff --git a/module/web/static/js/views/fileView.js b/module/web/static/js/views/fileView.js index 86f7b33d2..c7b87e871 100644 --- a/module/web/static/js/views/fileView.js +++ b/module/web/static/js/views/fileView.js @@ -13,13 +13,11 @@ define(['jquery', 'backbone', 'underscore', 'app', 'views/abstract/itemView'], }, initialize: function() { - this.model.on('change', this.render, this); - this.model.on('remove', this.destroy, this); + this.listenTo(this.model, 'change', this.render); + this.listenTo(this.model, 'remove', this.destroy); }, onDestroy: function() { - this.model.off('change', this.render); - this.model.off('remove', this.destroy); }, render: function() { diff --git a/module/web/static/js/views/packageView.js b/module/web/static/js/views/packageView.js index eb3edccd8..93ebfb7e4 100644 --- a/module/web/static/js/views/packageView.js +++ b/module/web/static/js/views/packageView.js @@ -10,6 +10,7 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore'], events: { 'click .package-name': 'open', 'click .iconf-trash': 'deleteItem', + 'click .iconf-refresh': 'restart', 'click .select': 'select' }, @@ -19,19 +20,31 @@ define(['jquery', 'app', 'views/abstract/itemView', 'underscore'], expanded: false, initialize: function() { - this.model.on('filter:added', this.hide, this); - this.model.on('filter:removed', this.show, this); - this.model.on('change', this.render, this); - this.model.on('remove', this.unrender, this); + this.listenTo(this.model, 'filter:added', this.hide); + this.listenTo(this.model, 'filter:removed', this.show); + this.listenTo(this.model, 'change', this.render); + this.listenTo(this.model, 'remove', this.unrender); + + // Clear drop down menu + var self = this; + this.$el.on('mouseleave', function() { + self.$('.dropdown-menu').hide(); + }); }, onDestroy: function() { - this.model.off('filter:added', this.hide); // TODO }, // Render everything, optional only the fileViews render: function() { this.$el.html(this.template(this.model.toJSON())); + this.$el.initTooltips(); + + // Init the dropdown-menu + var self = this; + this.$('.iconf-chevron-down').click(function() { + self.$('.dropdown-menu').stop(true, true).delay(200).animate({opacity: 'toggle'}); + }); return this; }, diff --git a/module/web/static/js/views/selectionView.js b/module/web/static/js/views/selectionView.js index 673753cba..8dbd069bd 100644 --- a/module/web/static/js/views/selectionView.js +++ b/module/web/static/js/views/selectionView.js @@ -10,7 +10,7 @@ define(['jquery', 'backbone', 'underscore', 'app'], 'click .iconf-check': 'deselect', 'click .iconf-pause': 'pause', 'click .iconf-trash': 'trash', - 'click .iconf-refresh': 'refresh' + 'click .iconf-refresh': 'restart' }, // available packages @@ -48,8 +48,10 @@ define(['jquery', 'backbone', 'underscore', 'app'], var files = this.get_files().length; var packs = this.get_packs().length; - if (files + packs > 0) + if (files + packs > 0) { this.$el.html(this.template({files: files, packs: packs})); + this.$el.initTooltips('bottom'); + } if (files + packs > 0 && this.current === 0) this.$el.slideOut(); @@ -90,11 +92,18 @@ define(['jquery', 'backbone', 'underscore', 'app'], pack.destroy(); }); - this.render(); + this.deselect(); }, - refresh: function() { - // TODO + restart: function() { + this.get_files().map(function(file) { + file.restart(); + }); + this.get_packs().map(function(pack) { + pack.restart(); + }); + + this.deselect(); } }); });
\ No newline at end of file |