{% blocktrans with site_name=site_name %}Welcome to {{site_name}}{% endblocktrans %}
- {% if user.permissions.can_add_repo %} -{% blocktrans with site_name=site_name %}{{site_name}} organizes files into libraries. Each library can be synced and shared separately. We have created a personal library for you. You can create more libraries later.{% endblocktrans %}
- {% else %} -{% blocktrans with site_name=site_name %}{{site_name}} organizes files into libraries. Each library can be synced and shared separately. Howerver, since you are a guest user now, you can not create libraries.{% endblocktrans %}
- {% endif %} - -{% blocktrans with site_name=site_name %}Welcome to {{site_name}}{% endblocktrans %}
+ {% if user.permissions.can_add_repo %} +{% blocktrans with site_name=site_name %}{{site_name}} organizes files into libraries. Each library can be synced and shared separately. We have created a personal library for you. You can create more libraries later.{% endblocktrans %}
+ {% else %} +{% blocktrans with site_name=site_name %}{{site_name}} organizes files into libraries. Each library can be synced and shared separately. Howerver, since you are a guest user now, you can not create libraries.{% endblocktrans %}
+ {% endif %} +你可以从 Seafile 的官方下载页面下载 Windows,Mac 以及 Linux 的客户端。
{% else %}You can download Seafile desktop client for Windows, Mac and Linux from Seafile's official download page.
{% endif %} -diff --git a/seahub/templates/home_base.html b/seahub/templates/home_base.html index 00fcd23100..a0c8fcf6b3 100644 --- a/seahub/templates/home_base.html +++ b/seahub/templates/home_base.html @@ -1,8 +1,10 @@ {% extends "base.html" %} {% load i18n %} +{% block main_class %}d-flex ovhd{% endblock %} + {% block main_content %} -
' + err_msg + '
'); + _this.$toolbar.addClass('hide'); + _this.$path.empty(); + _this.$toolbar2.empty(); + _this.$loadingTip.hide(); + _this.$error.html(err_msg).show(); } }); }, - showRepoList: function(group_id, options) { - this.group_id = group_id; - this.$emptyTip.hide(); - this.renderGroupTop(options); - this.$table.hide(); - var $loadingTip = this.$loadingTip; - $loadingTip.show(); + showRepoList: function() { var _this = this; - this.repos.setGroupID(group_id); + this.repos.setGroupID(this.group_id); this.repos.fetch({ cache: false, reset: true, data: {from: 'web'}, - success: function (collection, response, opts) { + success: function(collection, response, opts) { }, - error: function (collection, response, opts) { - $loadingTip.hide(); - var $error = _this.$('.error'); + error: function(collection, response, opts) { var err_msg; if (response.responseText) { if (response['status'] == 401 || response['status'] == 403) { @@ -142,34 +150,59 @@ define([ } else { err_msg = gettext('Please check the network.'); } - $error.html(err_msg).show(); + _this.$error.html(err_msg).show(); + }, + complete: function() { + _this.$loadingTip.hide(); } }); }, - render: function() { - this.$el.html(this.template()); - this.$table = this.$('table'); - this.$tableHead = this.$('thead'); - this.$tableBody = this.$('tbody'); - this.$loadingTip = this.$('#group-repos .loading-tip'); + renderToolbar: function() { + this.$toolbar = $('').html(this.toolbarTemplate()); + this.$('.common-toolbar').before(this.$toolbar); + }, + + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + + this.$path = $('.group-path', this.$mainCon); + this.$toolbar2 = $('.group-toolbar-2', this.$mainCon); + this.$table = $('table', this.$mainCon); + this.$tableHead = $('thead', this.$table); + this.$tableBody = $('tbody', this.$table); + this.$loadingTip = $('.loading-tip', this.$mainCon); this.$emptyTip = this.$('#group-repos .empty-tips'); - this.attached = false; + this.$error = $('.error', this.$mainCon); + }, + + renderPath: function(data) { + this.$path.html(this.pathTemplate(data)); + }, + + renderToolbar2: function(data) { + this.$toolbar2.html(this.toolbar2Template(data)); + }, + + // update group name. e.g 'rename' + updateName: function(new_name) { + this.group.name = new_name; + $('.group-name', this.$mainCon).html(Common.HTMLescape(new_name)); }, show: function(group_id, options) { - if (!this.attached) { - // if the user swith bettern different groups, - // the group view is already attached. - $("#right-panel").html(this.$el); - this.attached = true; + if (!$('#group').length) { + this.renderToolbar(); + this.renderMainCon(); } - this.showRepoList(group_id, options); + this.group_id = group_id; + this.showGroup(options); }, hide: function() { - this.attached = false; - this.$el.detach(); + this.$toolbar.detach(); + this.$mainCon.detach(); }, createRepo: function() { diff --git a/static/scripts/app/views/groups.js b/static/scripts/app/views/groups.js index 5ac9f0a9b0..663f0eb3f2 100644 --- a/static/scripts/app/views/groups.js +++ b/static/scripts/app/views/groups.js @@ -9,16 +9,16 @@ define([ 'use strict'; var GroupsView = Backbone.View.extend({ - id: 'groups', + el: '.main-panel', template: _.template($('#groups-tmpl').html()), + toolbarTemplate: _.template($('#groups-toolbar-tmpl').html()), + addGroupTemplate: _.template($('#add-group-form-tmpl').html()), initialize: function(options) { this.groups = new Groups(); this.listenTo(this.groups, 'add', this.addOne); this.listenTo(this.groups, 'reset', this.reset); - - this.render(); }, events: { @@ -50,8 +50,15 @@ define([ } }, - render: function() { - this.$el.html(this.template()); + renderToolbar: function() { + this.$toolbar = $('').html(this.toolbarTemplate()); + this.$('.common-toolbar').before(this.$toolbar); + }, + + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$loadingTip = this.$('.loading-tip'); this.$groupList = this.$('#group-list'); this.$emptyTip = this.$('.empty-tips'); @@ -88,16 +95,19 @@ define([ }, show: function() { - $("#right-panel").html(this.$el); + this.renderToolbar(); + this.renderMainCon(); + this.showGroups(); }, hide: function() { - this.$el.detach(); + this.$toolbar.detach(); + this.$mainCon.detach(); }, addGroup: function () { - var $form = $('#group-add-form'); + var $form = $(this.addGroupTemplate()); $form.modal(); $('#simplemodal-container').css({'height':'auto'}); diff --git a/static/scripts/app/views/invitations.js b/static/scripts/app/views/invitations.js index e610dcf385..2dc2be486a 100644 --- a/static/scripts/app/views/invitations.js +++ b/static/scripts/app/views/invitations.js @@ -12,20 +12,27 @@ define([ var InvitationsView = Backbone.View.extend({ - id: 'invitations', + el: '.main-panel', template: _.template($('#invitations-tmpl').html()), + toolbarTemplate: _.template($('#invitations-toolbar-tmpl').html()), inviteFormTemplate: _.template($('#invitation-form-tmpl').html()), initialize: function() { this.collection = new InvitedPeopleCollection(); this.listenTo(this.collection, 'add', this.addOne); this.listenTo(this.collection, 'reset', this.reset); - this.render(); }, - render: function() { - this.$el.html(this.template()); + renderToolbar: function() { + this.$toolbar = $('').html(this.toolbarTemplate()); + this.$('.common-toolbar').before(this.$toolbar); + }, + + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$loadingTip = this.$('.loading-tip'); this.$table = this.$('table'); this.$tableBody = $('tbody', this.$table); @@ -42,7 +49,7 @@ define([ var $form = $(this.inviteFormTemplate()); var form_id = $form.attr('id'); - $form.modal({appendTo:'#main'}); + $form.modal(); $('#simplemodal-container').css({'height':'auto'}); $form.submit(function() { @@ -120,10 +127,9 @@ define([ }, show: function() { - if (!this.attached) { - this.attached = true; - $("#right-panel").html(this.$el); - } + this.renderToolbar(); + this.renderMainCon(); + this.showContent(); }, @@ -154,8 +160,8 @@ define([ }, hide: function() { - this.$el.detach(); - this.attached = false; + this.$toolbar.detach(); + this.$mainCon.detach(); } }); diff --git a/static/scripts/app/views/my-deleted-repos.js b/static/scripts/app/views/my-deleted-repos.js index 27f67bc48a..5b2e669375 100644 --- a/static/scripts/app/views/my-deleted-repos.js +++ b/static/scripts/app/views/my-deleted-repos.js @@ -9,11 +9,11 @@ define([ 'use strict'; var ReposView = Backbone.View.extend({ - id: "my-deleted-repos", + el: ".main-panel", template: _.template($('#my-deleted-repos-tmpl').html()), - reposHdTemplate: _.template($('#my-deleted-repos-hd-tmpl').html()), - mobileReposHdTemplate: _.template($('#my-deleted-repos-hd-mobile-tmpl').html()), + theadTemplate: _.template($('#my-deleted-repos-hd-tmpl').html()), + theadMobileTemplate: _.template($('#my-deleted-repos-hd-mobile-tmpl').html()), events: { }, @@ -22,12 +22,12 @@ define([ this.repos = new RepoCollection(); this.listenTo(this.repos, 'add', this.addOne); this.listenTo(this.repos, 'reset', this.reset); - - this.render(); }, - render: function() { - this.$el.html(this.template()); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$tableHead = $('thead', this.$table); this.$tableBody = $('tbody', this.$table); @@ -42,8 +42,8 @@ define([ this.$tableBody.append(view.render().el); }, - renderReposHd: function() { - var tmpl = $(window).width() >= 768 ? this.reposHdTemplate : this.mobileReposHdTemplate; + renderThead: function() { + var tmpl = $(window).width() >= 768 ? this.theadTemplate : this.theadMobileTemplate; this.$tableHead.html(tmpl()); }, @@ -52,7 +52,7 @@ define([ this.$loadingTip.hide(); if (this.repos.length) { this.$emptyTip.hide(); - this.renderReposHd(); + this.renderThead(); this.$tableBody.empty(); this.repos.each(this.addOne, this); @@ -91,12 +91,12 @@ define([ }, show: function() { - $("#right-panel").html(this.$el); + this.renderMainCon(); this.showRepos(); }, hide: function() { - this.$el.detach(); + this.$mainCon.detach(); } }); diff --git a/static/scripts/app/views/myhome-repos.js b/static/scripts/app/views/myhome-repos.js index 754d6ae1e0..f38e4d69a3 100644 --- a/static/scripts/app/views/myhome-repos.js +++ b/static/scripts/app/views/myhome-repos.js @@ -13,17 +13,19 @@ define([ 'use strict'; var ReposView = Backbone.View.extend({ - id: "my-own-repos", + el: '.main-panel', template: _.template($('#my-own-repos-tmpl').html()), - reposHdTemplate: _.template($('#my-repos-hd-tmpl').html()), - mobileReposHdTemplate: _.template($('#my-repos-hd-mobile-tmpl').html()), + toolbarTemplate: _.template($('#my-repos-toolbar-tmpl').html()), + theadTemplate: _.template($('#my-repos-thead-tmpl').html()), + theadMobileTemplate: _.template($('#my-repos-thead-mobile-tmpl').html()), events: { - 'click .repo-create': 'createRepo', - 'click .by-name': 'sortByName', - 'click .by-time': 'sortByTime', - 'click #my-libs-more-op a': 'closeDropdown' + 'click #my-repos-toolbar .repo-create': 'createRepo', + 'click #my-libs-more-op a': 'closeDropdown', + + 'click #my-repos .by-name': 'sortByName', + 'click #my-repos .by-time': 'sortByTime' }, initialize: function(options) { @@ -32,13 +34,6 @@ define([ this.listenTo(this.repos, 'reset', this.reset); this.repoDetailsView = new RepoDetailsView(); - - this.render(); - - this.more_op_dropdown = new DropdownView({ - el: this.$("#my-libs-more-op"), - right: 0 - }) }, addOne: function(repo, collection, options) { @@ -50,21 +45,16 @@ define([ } }, - renderReposHd: function() { - var tmpl = $(window).width() >= 768 ? this.reposHdTemplate : this.mobileReposHdTemplate; - this.$tableHead.html(tmpl()); - }, - reset: function() { this.$('.error').hide(); this.$loadingTip.hide(); if (this.repos.length) { this.$emptyTip.hide(); - this.renderReposHd(); + this.renderThead(); this.$tableBody.empty(); // sort - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.repos.each(this.addOne, this); @@ -75,7 +65,7 @@ define([ } if (app.pageOptions.guide_enabled) { - $('#guide-for-new').modal({appendTo: '#main', focus:false}); + $('#guide-for-new').modal({focus:false}); $('#simplemodal-container').css({'height':'auto'}); app.pageOptions.guide_enabled = false; } @@ -86,7 +76,7 @@ define([ this.$loadingTip.show(); var _this = this; this.repos.fetch({ - cache: false, // for IE + cache: false, reset: true, success: function (collection, response, opts) { }, @@ -108,26 +98,43 @@ define([ }); }, - render: function() { - this.$el.html(this.template()); + renderThead: function() { + var tmpl = $(window).width() >= 768 ? this.theadTemplate : this.theadMobileTemplate; + this.$tableHead.html(tmpl()); + }, + + renderToolbar: function() { + this.$toolbar = $('').html(this.toolbarTemplate()); + this.$('.common-toolbar').before(this.$toolbar); + + this.more_op_dropdown = new DropdownView({ + el: this.$("#my-libs-more-op") + }); + }, + + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$tableHead = $('thead', this.$table); this.$tableBody = $('tbody', this.$table); this.$loadingTip = this.$('.loading-tip'); this.$emptyTip = this.$('.empty-tips'); - this.$repoCreateBtn = this.$('.repo-create'); - return this; }, show: function() { - $("#right-panel").html(this.$el); + if (!$('#my-repos').length) { + this.renderToolbar(); + this.renderMainCon(); + } + this.showMyRepos(); }, hide: function() { - this.$el.detach(); - - this.repoDetailsView.hide(); + this.$toolbar.detach(); + this.$mainCon.detach(); }, createRepo: function() { @@ -136,7 +143,7 @@ define([ sortByName: function() { Common.toggleSortByNameMode(); - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.$tableBody.empty(); @@ -148,7 +155,7 @@ define([ sortByTime: function() { Common.toggleSortByTimeMode(); - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.$tableBody.empty(); diff --git a/static/scripts/app/views/myhome-shared-repos.js b/static/scripts/app/views/myhome-shared-repos.js index 00cde31e3f..122ad646af 100644 --- a/static/scripts/app/views/myhome-shared-repos.js +++ b/static/scripts/app/views/myhome-shared-repos.js @@ -9,17 +9,16 @@ define([ 'use strict'; var SharedReposView = Backbone.View.extend({ - id: 'repos-shared-to-me', + el: '.main-panel', template: _.template($('#repos-shared-to-me-tmpl').html()), - reposHdTemplate: _.template($('#shared-repos-hd-tmpl').html()), - mobileReposHdTemplate: _.template($('#shared-repos-hd-mobile-tmpl').html()), + theadTemplate: _.template($('#shared-repos-hd-tmpl').html()), + theadMobileTemplate: _.template($('#shared-repos-hd-mobile-tmpl').html()), initialize: function(options) { this.repos = new RepoCollection({type: 'shared'}); this.listenTo(this.repos, 'add', this.addOne); this.listenTo(this.repos, 'reset', this.reset); - this.render(); }, addOne: function(repo, collection, options) { @@ -31,8 +30,8 @@ define([ } }, - renderReposHd: function() { - var tmpl = $(window).width() >= 768 ? this.reposHdTemplate : this.mobileReposHdTemplate; + renderThead: function() { + var tmpl = $(window).width() >= 768 ? this.theadTemplate : this.theadMobileTemplate; this.$tableHead.html(tmpl()); }, @@ -41,11 +40,11 @@ define([ this.$loadingTip.hide(); if (this.repos.length) { this.$emptyTip.hide(); - this.renderReposHd(); + this.renderThead(); this.$tableBody.empty(); // sort - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.repos.each(this.addOne, this); @@ -58,7 +57,6 @@ define([ }, showSharedRepos: function() { - this.$el.show(); this.$table.hide(); var $loadingTip = this.$loadingTip; $loadingTip.show(); @@ -85,33 +83,37 @@ define([ }); }, - render: function() { - this.$el.html(this.template()); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$tableHead = this.$('thead'); this.$tableBody = this.$('tbody'); this.$loadingTip = this.$('.loading-tip'); this.$emptyTip = this.$('.empty-tips'); - return this; }, show: function() { - $("#right-panel").html(this.$el); + if (!$('#shared-repos').length) { + this.renderMainCon(); + } + this.showSharedRepos(); }, hide: function() { - this.$el.detach(); + this.$mainCon.detach(); }, events: { - 'click .by-name': 'sortByName', - 'click .by-time': 'sortByTime' + 'click #shared-repos .by-name': 'sortByName', + 'click #shared-repos .by-time': 'sortByTime' }, sortByName: function() { Common.toggleSortByNameMode(); - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.$tableBody.empty(); @@ -122,7 +124,7 @@ define([ sortByTime: function() { Common.toggleSortByTimeMode(); - Common.updateSortIconByMode({'context': this.$el}); + Common.updateSortIconByMode({'context': this.$table}); Common.sortLibs({'libs': this.repos}); this.$tableBody.empty(); diff --git a/static/scripts/app/views/organization.js b/static/scripts/app/views/organization.js index 2481360b25..4fb3005b47 100644 --- a/static/scripts/app/views/organization.js +++ b/static/scripts/app/views/organization.js @@ -13,47 +13,57 @@ define([ 'use strict'; var OrganizationView = Backbone.View.extend({ - id: 'organization', + el: '.main-panel', template: _.template($('#organization-repos-tmpl').html()), - reposHdTemplate: _.template($('#shared-repos-hd-tmpl').html()), - mobileReposHdTemplate: _.template($('#shared-repos-hd-mobile-tmpl').html()), + toolbarTemplate: _.template($('#org-repos-toolbar-tmpl').html()), + theadTemplate: _.template($('#shared-repos-hd-tmpl').html()), + theadMobileTemplate: _.template($('#shared-repos-hd-mobile-tmpl').html()), initialize: function(options) { this.repos = new PubRepoCollection(); this.listenTo(this.repos, 'add', this.addOne); this.listenTo(this.repos, 'reset', this.reset); - this.render(); }, - render: function() { - this.$el.html(this.template()); + renderToolbar: function() { + this.$toolbar = $('').html(this.toolbarTemplate()); + this.$('.common-toolbar').before(this.$toolbar); + + this.dropdown = new DropdownView({ + el: this.$('#org-repos-toolbar .js-add-pub-lib-dropdown') + }); + }, + + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$tableHead = $('thead', this.$table); this.$tableBody = $('tbody', this.$table); this.$loadingTip = this.$('.loading-tip'); this.$emptyTip = this.$('.empty-tips'); - - this.dropdown = new DropdownView({ - el: this.$('.js-add-pub-lib-dropdown'), - right: '0px' - }); + return this; }, show: function() { - $("#right-panel").html(this.$el); + this.renderToolbar(); + this.renderMainCon(); + this.showRepoList(); }, hide: function() { - this.$el.detach(); + this.$toolbar.detach(); + this.$mainCon.detach(); }, events: { - 'click .share-existing': 'addRepo', - 'click .create-new': 'createRepo', - 'click .by-name': 'sortByName', - 'click .by-time': 'sortByTime' + 'click #org-repos-toolbar .share-existing': 'addRepo', + 'click #org-repos-toolbar .create-new': 'createRepo', + 'click #org-repos .by-name': 'sortByName', + 'click #org-repos .by-time': 'sortByTime' }, createRepo: function() { @@ -77,8 +87,8 @@ define([ } }, - renderReposHd: function() { - var tmpl = $(window).width() >= 768 ? this.reposHdTemplate : this.mobileReposHdTemplate; + renderThead: function() { + var tmpl = $(window).width() >= 768 ? this.theadTemplate : this.theadMobileTemplate; this.$tableHead.html(tmpl()); }, @@ -87,7 +97,7 @@ define([ this.$loadingTip.hide(); if (this.repos.length) { this.$emptyTip.hide(); - this.renderReposHd(); + this.renderThead(); this.$tableBody.empty(); // sort diff --git a/static/scripts/app/views/repo-details.js b/static/scripts/app/views/repo-details.js index f62a93a911..36d383bebf 100644 --- a/static/scripts/app/views/repo-details.js +++ b/static/scripts/app/views/repo-details.js @@ -8,13 +8,11 @@ define([ var View = Backbone.View.extend({ id: 'repo-details', - className: 'details-panel right-side-panel', + className: 'details-panel', template: _.template($('#repo-details-tmpl').html()), initialize: function() { - $("#main").append(this.$el); - var _this = this; $(document).keydown(function(e) { // ESCAPE key pressed @@ -22,10 +20,6 @@ define([ _this.hide(); } }); - - $(window).resize(function() { - _this.setConMaxHeight(); - }); }, events: { @@ -44,15 +38,8 @@ define([ } }, - setConMaxHeight: function() { - this.$('.right-side-panel-con').css({ - 'height': $(window).height() - // this.$el `position:fixed; top:0;` - this.$('.right-side-panel-hd').outerHeight(true) - }); - }, - hide: function() { - this.$el.css({'right': '-320px'}); + this.$el.hide(); }, close: function() { @@ -63,8 +50,15 @@ define([ show: function(options) { this.data = options; this.render(); - this.$el.css({'right': '0px'}); - this.setConMaxHeight(); + + if (!$('#' + this.id).length) { + $('#my-repos').append(this.$el); + if (!this.$el.is(':visible')) { + this.$el.show(); + } + } else { + this.$el.show(); + } } }); diff --git a/static/scripts/app/views/repo.js b/static/scripts/app/views/repo.js index a66ddd8d23..cc4a64d5b9 100644 --- a/static/scripts/app/views/repo.js +++ b/static/scripts/app/views/repo.js @@ -74,7 +74,7 @@ define([ clickItem: function(e) { var target = e.target || event.srcElement; if (this.$('td').is(target) && - $('#repo-details').css('right') == '0px') { // after `#repo-details` is shown + this.myReposView.repoDetailsView.$el.is(':visible')) { this.viewDetails(); } }, diff --git a/static/scripts/app/views/share-admin-folders.js b/static/scripts/app/views/share-admin-folders.js index 4c66154f8c..ff26fead83 100644 --- a/static/scripts/app/views/share-admin-folders.js +++ b/static/scripts/app/views/share-admin-folders.js @@ -10,7 +10,7 @@ define([ var ShareAdminFoldersView = Backbone.View.extend({ - id: 'share-admin-folders', + el: '.main-panel', template: _.template($('#share-admin-folders-tmpl').html()), @@ -18,7 +18,6 @@ define([ this.folders = new ShareAdminFolderCollection(); this.listenTo(this.folders, 'add', this.addOne); this.listenTo(this.folders, 'reset', this.reset); - this.render(); var _this = this; $(document).click(function(e) { @@ -32,7 +31,7 @@ define([ }, events: { - 'click .by-name': 'sortByName' + 'click #share-admin-folders .by-name': 'sortByName' }, sortByName: function() { @@ -57,8 +56,10 @@ define([ return false; }, - render: function() { - this.$el.html(this.template()); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$sortIcon = $('.by-name .sort-icon', this.$table); this.$tableBody = $('tbody', this.$table); @@ -67,15 +68,12 @@ define([ }, hide: function() { - this.$el.detach(); - this.attached = false; + this.$mainCon.detach(); }, show: function() { - if (!this.attached) { - this.attached = true; - $("#right-panel").html(this.$el); - } + this.renderMainCon(); + this.showContent(); }, diff --git a/static/scripts/app/views/share-admin-repos.js b/static/scripts/app/views/share-admin-repos.js index 63d94fec4a..2097446592 100644 --- a/static/scripts/app/views/share-admin-repos.js +++ b/static/scripts/app/views/share-admin-repos.js @@ -10,7 +10,7 @@ define([ var ShareAdminReposView = Backbone.View.extend({ - id: 'share-admin-repos', + el: '.main-panel', template: _.template($('#share-admin-repos-tmpl').html()), @@ -18,7 +18,6 @@ define([ this.repos = new ShareAdminRepoCollection(); this.listenTo(this.repos, 'add', this.addOne); this.listenTo(this.repos, 'reset', this.reset); - this.render(); var _this = this; $(document).click(function(e) { @@ -32,7 +31,7 @@ define([ }, events: { - 'click .by-name': 'sortByName' + 'click #share-admin-repos .by-name': 'sortByName' }, sortByName: function() { @@ -57,26 +56,23 @@ define([ return false; }, - render: function() { - this.$el.html(this.template()); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$sortIcon = $('.by-name .sort-icon', this.$table); this.$tableBody = $('tbody', this.$table); this.$loadingTip = this.$('.loading-tip'); this.$emptyTip = this.$('.empty-tips'); - }, hide: function() { - this.$el.detach(); - this.attached = false; + this.$mainCon.detach(); }, show: function() { - if (!this.attached) { - this.attached = true; - $("#right-panel").html(this.$el); - } + this.renderMainCon(); this.showContent(); }, diff --git a/static/scripts/app/views/share-admin-share-links.js b/static/scripts/app/views/share-admin-share-links.js index b0df314524..7c1d97a0ff 100644 --- a/static/scripts/app/views/share-admin-share-links.js +++ b/static/scripts/app/views/share-admin-share-links.js @@ -12,7 +12,7 @@ define([ var ShareAdminShareLinksView = Backbone.View.extend({ - id: 'share-admin-download-links', + el: '.main-panel', template: _.template($('#share-admin-download-links-tmpl').html()), @@ -20,12 +20,11 @@ define([ this.links = new ShareAdminShareLinkCollection(); this.listenTo(this.links, 'add', this.addOne); this.listenTo(this.links, 'reset', this.reset); - this.render(); }, events: { - 'click .by-name': 'sortByName', - 'click .by-time': 'sortByTime' + 'click #share-admin-download-links .by-name': 'sortByName', + 'click #share-admin-download-links .by-time': 'sortByTime' }, // initialSort: dirs come first @@ -107,8 +106,10 @@ define([ return false; }, - render: function() { - this.$el.html(this.template({'can_generate_upload_link': app.pageOptions.can_generate_upload_link})); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$sortByNameIcon = this.$('.by-name .sort-icon'); this.$sortByTimeIcon = this.$('.by-time .sort-icon'); @@ -118,15 +119,11 @@ define([ }, hide: function() { - this.$el.detach(); - this.attached = false; + this.$mainCon.detach(); }, show: function() { - if (!this.attached) { - this.attached = true; - $("#right-panel").html(this.$el); - } + this.renderMainCon(); this.showContent(); }, diff --git a/static/scripts/app/views/share-admin-upload-links.js b/static/scripts/app/views/share-admin-upload-links.js index c0a32302bc..eafc1f46b0 100644 --- a/static/scripts/app/views/share-admin-upload-links.js +++ b/static/scripts/app/views/share-admin-upload-links.js @@ -12,7 +12,7 @@ define([ var ShareAdminUploadLinksView = Backbone.View.extend({ - id: 'share-admin-upload-links', + el: '.main-panel', template: _.template($('#share-admin-upload-links-tmpl').html()), @@ -20,11 +20,12 @@ define([ this.links = new ShareAdminUploadLinkCollection(); this.listenTo(this.links, 'add', this.addOne); this.listenTo(this.links, 'reset', this.reset); - this.render(); }, - render: function() { - this.$el.html(this.template({'can_generate_share_link': app.pageOptions.can_generate_share_link})); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); + this.$table = this.$('table'); this.$tableBody = $('tbody', this.$table); this.$loadingTip = this.$('.loading-tip'); @@ -32,15 +33,11 @@ define([ }, hide: function() { - this.$el.detach(); - this.attached = false; + this.$mainCon.detach(); }, show: function() { - if (!this.attached) { - this.attached = true; - $("#right-panel").html(this.$el); - } + this.renderMainCon(); this.showContent(); }, diff --git a/static/scripts/app/views/side-nav.js b/static/scripts/app/views/side-nav.js index bd4a51b04f..961278f27c 100644 --- a/static/scripts/app/views/side-nav.js +++ b/static/scripts/app/views/side-nav.js @@ -8,7 +8,7 @@ define([ 'use strict'; var sideNavView = Backbone.View.extend({ - el: '#side-nav', + el: '.side-panel', template: _.template($("#side-nav-tmpl").html()), enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()), @@ -42,7 +42,7 @@ define([ }, render: function() { - this.$el.html(this.template(this.data)); + this.$('#side-nav').html(this.template(this.data)); return this; }, @@ -50,8 +50,8 @@ define([ 'click #group-nav a:first': 'toggleGroupList', 'click #share-admin-nav a:first': 'toggleShareAdminList', 'click #enable-mods': 'enableMods', - 'click .js-close-side-nav': 'closeNav', - 'click li > a': 'visitLink', + 'click .js-close': 'close', + 'click #side-nav li > a': 'visitLink', 'click .js-about': 'showAbout', // for touch devices @@ -203,7 +203,7 @@ define([ this.$el.css({ 'left':'-300px' }); }, - closeNav: function() { + close: function() { this.hide(); return false; }, diff --git a/static/scripts/app/views/starred-file.js b/static/scripts/app/views/starred-file.js index 15d0d10383..986ffbeddc 100644 --- a/static/scripts/app/views/starred-file.js +++ b/static/scripts/app/views/starred-file.js @@ -11,7 +11,7 @@ define([ 'use strict'; var StarredFileView = Backbone.View.extend({ - id: 'starred-file', + el: '.main-panel', template: _.template($('#starred-file-tmpl').html()), theadTemplate: _.template($('#starred-file-thead-tmpl').html()), @@ -19,7 +19,6 @@ define([ initialize: function() { this.starredFiles = new StarredFilesCollection(); this.listenTo(this.starredFiles, 'reset', this.reset); - this.render(); }, addOne: function(starredFile) { @@ -92,8 +91,9 @@ define([ this.starredFiles.fetch({reset: true}); }, - render: function() { - this.$el.html(this.template()); + renderMainCon: function() { + this.$mainCon = $('').html(this.template()); + this.$el.append(this.$mainCon); this.$table = this.$('table'); this.$tableBody = this.$('tbody'); @@ -128,12 +128,12 @@ define([ }, show: function() { - $("#right-panel").html(this.$el); + this.renderMainCon(); this.showStarredFiles(); }, hide: function() { - this.$el.detach(); + this.$mainCon.detach(); } }); diff --git a/static/scripts/app/views/widgets/dropdown.js b/static/scripts/app/views/widgets/dropdown.js index 76f1358476..9e72943bb5 100644 --- a/static/scripts/app/views/widgets/dropdown.js +++ b/static/scripts/app/views/widgets/dropdown.js @@ -19,9 +19,8 @@ define([ return true; } - if (!view.$('.sf-dropdown-menu').is(target) - && !view.$('.sf-dropdown-menu').find('*').is(target)) - { + if (!view.$('.sf-dropdown-menu').is(target) && + !view.$('.sf-dropdown-menu').find('*').is(target)) { view.hide(); if (app.ui.currentHighlightedItem) { app.ui.currentHighlightedItem.rmHighlight(); diff --git a/static/scripts/common.js b/static/scripts/common.js index 6a6cb31384..8bd6482d84 100644 --- a/static/scripts/common.js +++ b/static/scripts/common.js @@ -339,7 +339,7 @@ define([ var $yesBtn = $('#confirm-yes'); $cont.html('' + title + '
' + content + '
'); - $popup.modal({appendTo: '#main'}); + $popup.modal(); $('#simplemodal-container').css({'height':'auto'}); $yesBtn.click(yesCallback); @@ -360,7 +360,7 @@ define([ }); $cont.html(html); - $popup.modal({appendTo: '#main'}); + $popup.modal(); $('#simplemodal-container').css({'height':'auto'}); $yesBtn.click(function() { @@ -379,7 +379,7 @@ define([ $('.messages').html('- ' + this.HTMLescape(con) + '