From d4fabd4878050fdfea4e88dfe54eb90b4e35690f Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 20 Feb 2013 17:05:30 +0100 Subject: tooltips and other improvements on webui --- module/web/static/js/app.js | 5 +++++ module/web/static/js/models/File.js | 13 ++++++++++++- module/web/static/js/models/Package.js | 15 ++++++++++----- module/web/static/js/utils/animations.js | 12 +++++++++++- module/web/static/js/views/abstract/itemView.js | 11 ++++++++--- module/web/static/js/views/dashboardView.js | 20 ++++---------------- module/web/static/js/views/fileView.js | 6 ++---- module/web/static/js/views/packageView.js | 23 ++++++++++++++++++----- module/web/static/js/views/selectionView.js | 19 ++++++++++++++----- 9 files changed, 84 insertions(+), 40 deletions(-) (limited to 'module/web/static/js') diff --git a/module/web/static/js/app.js b/module/web/static/js/app.js index d39ef6a63..dcc9594af 100644 --- a/module/web/static/js/app.js +++ b/module/web/static/js/app.js @@ -27,6 +27,11 @@ define([ // Add Global Helper functions _.extend(Application.prototype, Backbone.Events, { + restartFailed: function(pids, options) { + options || (options = {}); + options.url = 'api/restartFailed'; + $.ajax(options); + } }); diff --git a/module/web/static/js/models/File.js b/module/web/static/js/models/File.js index 66d9ef050..efea23254 100644 --- a/module/web/static/js/models/File.js +++ b/module/web/static/js/models/File.js @@ -23,13 +23,24 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { }, + destroy: function() { + + }, + + restart: function(options) { + options || (options = {}); + options.url = 'api/restartFile/' + this.get('fid'); + + return $.ajax(options); + }, + // Any time a model attribute is set, this method is called validate: function(attrs) { }, isDownload : function() { - return this.has('download') + return this.has('download'); } }); diff --git a/module/web/static/js/models/Package.js b/module/web/static/js/models/Package.js index 24f04519e..c5eb3eaac 100644 --- a/module/web/static/js/models/Package.js +++ b/module/web/static/js/models/Package.js @@ -54,6 +54,16 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'], return Backbone.Model.prototype.destroy.call(this, options); }, + restart: function(options) { + options || (options = {}); + var self = this; + options.url = 'api/restartPackage/' + this.get('pid'); + options.success = function() { + self.fetch(); + }; + return $.ajax(options); + }, + parse: function(resp) { // Package is loaded from tree collection if (_.has(resp, 'root')) { @@ -75,11 +85,6 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'], return Backbone.model.prototype.parse.call(this, resp); }, - // Package data is complete when it contains collection for containing files or packs - isLoaded: function() { - return this.has('files'); - }, - // Any time a model attribute is set, this method is called validate: function(attrs) { diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js index 798f69358..789359e0c 100644 --- a/module/web/static/js/utils/animations.js +++ b/module/web/static/js/utils/animations.js @@ -38,7 +38,7 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) { if (animation === true) element.fadeIn(); - element.calculateHeight(); +// element.calculateHeight(); return this; }; @@ -61,6 +61,7 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) { return this; }; + // TODO: carry arguments, optional height argument jQuery.fn.slideOut = function() { var o = jQuery(this[0]); o.animate({height: o.data('height'), opacity: 'show'}); @@ -73,6 +74,15 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) { return this; }; + jQuery.fn.initTooltips = function(placement) { + placement || (placement = 'top'); + + var o = jQuery(this[0]); + o.find('[data-toggle="tooltip"]').tooltip({delay: {show: 500, hide: 100}, placement: placement}); + + return this; + }; + jQuery.fn._transit = jQuery.fn.transit; // Overriding transit plugin to support hide and show 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' }, //