From 2cf160d497e501bf254bd8be054c0f5880ab90ca Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 8 Jun 2013 17:37:43 +0200 Subject: restructured webui to single-page-app, removed jinja --- module/web/static/js/views/abstract/itemView.js | 46 ---- module/web/static/js/views/abstract/modalView.js | 124 ----------- .../static/js/views/accounts/accountListView.js | 46 ---- .../web/static/js/views/accounts/accountModal.js | 69 ------ module/web/static/js/views/accounts/accountView.js | 24 --- .../web/static/js/views/dashboard/dashboardView.js | 164 --------------- module/web/static/js/views/dashboard/fileView.js | 101 --------- module/web/static/js/views/dashboard/filterView.js | 133 ------------ .../web/static/js/views/dashboard/packageView.js | 74 ------- .../web/static/js/views/dashboard/selectionView.js | 150 ------------- module/web/static/js/views/headerView.js | 232 --------------------- module/web/static/js/views/input/inputLoader.js | 7 - module/web/static/js/views/input/inputView.js | 85 -------- module/web/static/js/views/input/textInput.js | 35 ---- module/web/static/js/views/linkGrabberModal.js | 48 ----- module/web/static/js/views/notificationView.js | 80 ------- module/web/static/js/views/progressView.js | 31 --- module/web/static/js/views/queryModal.js | 68 ------ .../static/js/views/settings/configSectionView.js | 97 --------- .../static/js/views/settings/pluginChooserModal.js | 65 ------ .../web/static/js/views/settings/settingsView.js | 170 --------------- 21 files changed, 1849 deletions(-) delete mode 100644 module/web/static/js/views/abstract/itemView.js delete mode 100644 module/web/static/js/views/abstract/modalView.js delete mode 100644 module/web/static/js/views/accounts/accountListView.js delete mode 100644 module/web/static/js/views/accounts/accountModal.js delete mode 100644 module/web/static/js/views/accounts/accountView.js delete mode 100644 module/web/static/js/views/dashboard/dashboardView.js delete mode 100644 module/web/static/js/views/dashboard/fileView.js delete mode 100644 module/web/static/js/views/dashboard/filterView.js delete mode 100644 module/web/static/js/views/dashboard/packageView.js delete mode 100644 module/web/static/js/views/dashboard/selectionView.js delete mode 100644 module/web/static/js/views/headerView.js delete mode 100644 module/web/static/js/views/input/inputLoader.js delete mode 100644 module/web/static/js/views/input/inputView.js delete mode 100644 module/web/static/js/views/input/textInput.js delete mode 100644 module/web/static/js/views/linkGrabberModal.js delete mode 100644 module/web/static/js/views/notificationView.js delete mode 100644 module/web/static/js/views/progressView.js delete mode 100644 module/web/static/js/views/queryModal.js delete mode 100644 module/web/static/js/views/settings/configSectionView.js delete mode 100644 module/web/static/js/views/settings/pluginChooserModal.js delete mode 100644 module/web/static/js/views/settings/settingsView.js (limited to 'module/web/static/js/views') diff --git a/module/web/static/js/views/abstract/itemView.js b/module/web/static/js/views/abstract/itemView.js deleted file mode 100644 index 394044ec4..000000000 --- a/module/web/static/js/views/abstract/itemView.js +++ /dev/null @@ -1,46 +0,0 @@ -define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { - - // A view that is meant for temporary displaying - // All events must be unbound in onDestroy - return Backbone.View.extend({ - - tagName: 'li', - destroy: function() { - this.undelegateEvents(); - this.unbind(); - if (this.onDestroy) { - this.onDestroy(); - } - this.$el.removeData().unbind(); - this.remove(); - }, - - hide: function() { - this.$el.slideUp(); - }, - - show: function() { - this.$el.slideDown(); - }, - - unrender: function() { - var self = this; - this.$el.slideUp(function() { - self.destroy(); - }); - }, - - deleteItem: function(e) { - if (e) - e.stopPropagation(); - this.model.destroy(); - }, - - restart: function(e) { - if(e) - e.stopPropagation(); - this.model.restart(); - } - - }); -}); \ No newline at end of file diff --git a/module/web/static/js/views/abstract/modalView.js b/module/web/static/js/views/abstract/modalView.js deleted file mode 100644 index 170681f06..000000000 --- a/module/web/static/js/views/abstract/modalView.js +++ /dev/null @@ -1,124 +0,0 @@ -define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone, _) { - - return Backbone.View.extend({ - - events: { - 'click .btn-confirm': 'confirm', - 'click .btn-close': 'hide', - 'click .close': 'hide' - }, - - template: null, - dialog: null, - - onHideDestroy: false, - confirmCallback: null, - - initialize: function(template, confirm) { - this.confirmCallback = confirm; - var self = this; - if (this.template === null) { - if (template) { - this.template = template; - // When template was provided this is a temporary dialog - this.onHideDestroy = true; - } - else - require(['text!tpl/default/modal.html'], function(template) { - self.template = template; - }); - } - - }, - - // TODO: whole modal stuff is not very elegant - render: function() { - this.$el.html(this.template(this.renderContent())); - this.onRender(); - - if (this.dialog === null) { - this.$el.addClass('modal hide'); - this.$el.css({opacity: 0, scale: 0.7}); - - var self = this; - $("body").append(this.el); - this.dialog = this.$el.omniWindow({ - overlay: { - selector: '#modal-overlay', - hideClass: 'hide', - animations: { - hide: function(subjects, internalCallback) { - subjects.overlay.transition({opacity: 'hide', delay: 100}, 300, function() { - internalCallback(subjects); - self.onHide(); - if (self.onHideDestroy) - self.destroy(); - }); - }, - show: function(subjects, internalCallback) { - subjects.overlay.fadeIn(300); - internalCallback(subjects); - }}}, - modal: { - hideClass: 'hide', - animations: { - hide: function(subjects, internalCallback) { - subjects.modal.transition({opacity: 'hide', scale: 0.7}, 300); - internalCallback(subjects); - }, - - show: function(subjects, internalCallback) { - subjects.modal.transition({opacity: 'show', scale: 1, delay: 100}, 300, function() { - internalCallback(subjects); - }); - }} - }}); - } - - return this; - }, - - onRender: function() { - - }, - - renderContent: function() { - return {}; - }, - - show: function() { - if (this.dialog === null) - this.render(); - - this.dialog.trigger('show'); - - this.onShow(); - }, - - onShow: function() { - - }, - - hide: function() { - this.dialog.trigger('hide'); - }, - - onHide: function() { - - }, - - confirm: function() { - if (this.confirmCallback) - this.confirmCallback.apply(); - - this.hide(); - }, - - destroy: function() { - this.$el.remove(); - this.dialog = null; - this.remove(); - } - - }); -}); \ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountListView.js b/module/web/static/js/views/accounts/accountListView.js deleted file mode 100644 index 68dffaa98..000000000 --- a/module/web/static/js/views/accounts/accountListView.js +++ /dev/null @@ -1,46 +0,0 @@ -define(['jquery', 'underscore', 'backbone', 'app', 'collections/AccountList', './accountView'], - function($, _, Backbone, App, AccountList, accountView) { - - // Renders settings over view page - return Backbone.View.extend({ - - el: "body", - - events: { - 'click .btn-add': 'addAccount' - }, - - content: null, - accounts: null, - modal: null, - - initialize: function() { - this.content = this.$('#account-content'); - this.accounts = new AccountList(); - this.refresh(); - }, - - refresh: function() { - this.accounts.fetch({success: _.bind(this.render, this)}); - }, - - render: function() { - var self = this; - App.vent.trigger('accounts:destroyContent'); - // TODO trs cant' be animated - this.accounts.each(function(account) { - self.content.appendWithHeight(new accountView({model: account}).render().el); - }); - }, - - addAccount: function() { - var self = this; - _.requireOnce(['views/accounts/accountModal'], function(Modal) { - if (self.modal === null) - self.modal = new Modal(); - - self.modal.show(); - }); - } - }); - }); \ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountModal.js b/module/web/static/js/views/accounts/accountModal.js deleted file mode 100644 index 755ffd510..000000000 --- a/module/web/static/js/views/accounts/accountModal.js +++ /dev/null @@ -1,69 +0,0 @@ -define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/accountDialog.html', 'select2'], - function($, _, App, modalView, template) { - return modalView.extend({ - - events: { - 'click .btn-add': 'add' - }, - template: _.compile(template), - plugins: null, - select: null, - - initialize: function() { - // Inherit parent events - this.events = _.extend({}, modalView.prototype.events, this.events); - var self = this; - $.ajax(App.apiRequest('getAccountTypes', null, {success: function(data) { - self.plugins = _.sortBy(data, function(item) { - return item; - }); - self.render(); - }})); - }, - - onRender: function() { - // TODO: could be a seperate input type if needed on multiple pages - if (this.plugins) - this.select = this.$('#pluginSelect').select2({ - escapeMarkup: function(m) { - return m; - }, - formatResult: this.format, - formatSelection: this.format, - data: {results: this.plugins, text: function(item) { - return item; - }}, - id: function(item) { - return item; - } - }); - }, - - onShow: function() { - }, - - onHide: function() { - }, - - format: function(data) { - return ' ' + data; - }, - - add: function(e) { - e.stopPropagation(); - if (this.select) { - var plugin = this.select.val(), - login = this.$('#login').val(), - password = this.$('#password').val(), - self = this; - - $.ajax(App.apiRequest('updateAccount', { - plugin: plugin, login: login, password: password - }, { success: function() { - App.accountView.refresh(); - self.hide(); - }})); - } - } - }); - }); \ No newline at end of file diff --git a/module/web/static/js/views/accounts/accountView.js b/module/web/static/js/views/accounts/accountView.js deleted file mode 100644 index 7c3d492c3..000000000 --- a/module/web/static/js/views/accounts/accountView.js +++ /dev/null @@ -1,24 +0,0 @@ -define(['jquery', 'underscore', 'backbone', 'app', '../abstract/itemView'], - function($, _, Backbone, App, itemView) { - - // Renders settings over view page - return itemView.extend({ - - tagName: "tr", - template: _.compile($('#template-account').html()), - - events: { - 'click .btn-danger': 'deleteItem' - }, - - initialize: function() { - this.listenTo(this.model, 'remove', this.unrender); - this.listenTo(App.vent, 'accounts:destroyContent', this.destroy); - }, - - render: function() { - this.$el.html(this.template(this.model.toJSON())); - return this; - } - }); - }); \ No newline at end of file diff --git a/module/web/static/js/views/dashboard/dashboardView.js b/module/web/static/js/views/dashboard/dashboardView.js deleted file mode 100644 index c888214df..000000000 --- a/module/web/static/js/views/dashboard/dashboardView.js +++ /dev/null @@ -1,164 +0,0 @@ -define(['jquery', 'backbone', 'underscore', 'app', 'models/TreeCollection', - './packageView', './fileView', './selectionView', './filterView', 'select2'], - function($, Backbone, _, App, TreeCollection, packageView, fileView, selectionView, filterView) { - - // Renders whole dashboard - return Backbone.View.extend({ - - el: '#content', - active: $('.breadcrumb .active'), - - events: { - }, - - //