mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 23:00:57 +00:00
new design
This commit is contained in:
@@ -22,21 +22,26 @@ define([
|
||||
'use strict';
|
||||
|
||||
var DirView = Backbone.View.extend({
|
||||
id: 'dir-view',
|
||||
el: '.main-panel',
|
||||
|
||||
template: _.template($('#dir-view-tmpl').html()),
|
||||
|
||||
path_bar_template: _.template($('#dir-path-bar-tmpl').html()),
|
||||
dir_op_bar_template: _.template($('#dir-op-bar-tmpl').html()),
|
||||
dirents_hd_template: _.template($('#dirents-hd-tmpl').html()),
|
||||
dirents_hd_mobile_template: _.template($('#dirents-hd-mobile-tmpl').html()),
|
||||
top_search_form_template: _.template($('#top-search-form-tmpl').html()),
|
||||
toolbarTemplate: _.template($('#dir-view-toolbar-tmpl').html()),
|
||||
toolbar2Template: _.template($('#dir-view-toolbar2-tmpl').html()),
|
||||
|
||||
pathTemplate: _.template($('#dir-view-path-tmpl').html()),
|
||||
|
||||
theadTemplate: _.template($('#dir-view-thead-tmpl').html()), // '<thead>'
|
||||
theadMobileTemplate: _.template($('#dir-view-thead-mobile-tmpl').html()),
|
||||
|
||||
newDirTemplate: _.template($("#add-new-dir-form-template").html()),
|
||||
newFileTemplate: _.template($("#add-new-file-form-template").html()),
|
||||
mvcpTemplate: _.template($("#mvcp-form-template").html()),
|
||||
mvProgressTemplate: _.template($("#mv-progress-popup-template").html()),
|
||||
|
||||
topSearchFormTemplate: _.template($('#top-search-form-tmpl').html()),
|
||||
repoDecryptFormTemplate: _.template($('#repo-decrypt-form-template').html()),
|
||||
|
||||
initialize: function(options) {
|
||||
var view_mode = Cookies.get('view_mode');
|
||||
if (view_mode == 'grid') {
|
||||
@@ -68,28 +73,13 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.dir = new DirentCollection();
|
||||
this.listenTo(this.dir, 'add', this.addOne);
|
||||
this.listenTo(this.dir, 'reset', this.reset);
|
||||
|
||||
this.fileUploadView = new FileUploadView({dirView: this});
|
||||
this.direntDetailsView = new DirentDetailsView();
|
||||
this.fileCommentsView = new FileCommentsView();
|
||||
|
||||
this.render();
|
||||
|
||||
|
||||
var _this = this;
|
||||
// scroll window: get 'more', fix 'op bar'
|
||||
$(window).scroll(function() {
|
||||
if ($(_this.el).is(':visible')) {
|
||||
_this.onWindowScroll();
|
||||
}
|
||||
});
|
||||
$(window).resize(function() {
|
||||
_this.updateDirOpBarUI();
|
||||
});
|
||||
this.direntDetailsView = new DirentDetailsView({dirView: this});
|
||||
this.fileCommentsView = new FileCommentsView({dirView: this});
|
||||
|
||||
// hide 'rename form'
|
||||
$(document).click(function(e) {
|
||||
@@ -116,19 +106,26 @@ define([
|
||||
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template());
|
||||
this.attached = false;
|
||||
this.$dirent_list = this.$('.repo-file-list');
|
||||
this.$dirent_grid = this.$('.grid-view');
|
||||
this.$dirent_list_body = this.$('.repo-file-list tbody');
|
||||
this.$loading_tip = this.$('.loading-tip');
|
||||
this.$error = this.$('.error');
|
||||
this.$el_con = this.$('.repo-file-list-topbar, .js-dir-content');
|
||||
renderMainCon: function() {
|
||||
if ($('#dir-view').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$path_bar = this.$('.path-bar');
|
||||
// For compatible with css, we use .repo-op instead of .dir-op
|
||||
this.$dir_op_bar = this.$('.repo-op');
|
||||
this.$mainCon = $('<div class="main-panel-main main-panel-main-with-side" id="dir-view"></div>').html(this.template());
|
||||
this.$el.append(this.$mainCon);
|
||||
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$con = this.$('.js-dir-content');
|
||||
this.$error = this.$('.error');
|
||||
|
||||
this.$table = this.$('.repo-file-list');
|
||||
this.$tbody = $('tbody', this.$table);
|
||||
this.$gridViewContainer = this.$('.grid-view');
|
||||
|
||||
var _this = this;
|
||||
$('.cur-view-main-con', this.$mainCon).scroll(function() {
|
||||
_this.getMore();
|
||||
});
|
||||
},
|
||||
|
||||
// public function
|
||||
@@ -136,32 +133,30 @@ define([
|
||||
// 'category' is sth. like url prefix
|
||||
// options: for rendering from group view, currently is { group_name: group_name }
|
||||
showDir: function(category, repo_id, path, options) {
|
||||
$('#top-search-form').html(this.top_search_form_template({
|
||||
$('#top-search-form').html(this.topSearchFormTemplate({
|
||||
search_repo_id: repo_id
|
||||
}));
|
||||
|
||||
this.contextOptions = options;
|
||||
if (!this.attached) {
|
||||
this.attached = true;
|
||||
$("#right-panel").html(this.$el);
|
||||
}
|
||||
this.renderMainCon();
|
||||
|
||||
this.dir.setPath(category, repo_id, path);
|
||||
this.dir.dirent_more = false;
|
||||
|
||||
this.renderDir();
|
||||
},
|
||||
|
||||
// public function
|
||||
// hide the folder view
|
||||
hide: function() {
|
||||
$('#top-search-form').html(this.top_search_form_template({
|
||||
$('#top-search-form').html(this.topSearchFormTemplate({
|
||||
search_repo_id: ''
|
||||
}));
|
||||
|
||||
this.$el.detach();
|
||||
this.attached = false;
|
||||
|
||||
this.direntDetailsView.hide();
|
||||
this.fileCommentsView.hide();
|
||||
if (this.$toolbar) { // when an enc lib is not decrypted, no $toolbar
|
||||
this.$toolbar.detach();
|
||||
}
|
||||
this.$mainCon.detach();
|
||||
},
|
||||
|
||||
/***** private functions *****/
|
||||
@@ -169,66 +164,55 @@ define([
|
||||
var view;
|
||||
if (this.view_mode == 'list') {
|
||||
view = new DirentView({model: dirent, dirView: this});
|
||||
this.$dirent_list_body.append(view.render().el);
|
||||
this.$tbody.append(view.render().el);
|
||||
} else {
|
||||
view = new DirentGridView({model: dirent, dirView: this});
|
||||
this.$dirent_grid.append(view.render().el);
|
||||
this.$gridViewContainer.append(view.render().el);
|
||||
}
|
||||
},
|
||||
|
||||
// this.view_mode == 'list'
|
||||
addListOne: function(dirent) {
|
||||
var view = new DirentView({model: dirent, dirView: this});
|
||||
this.$tbody.append(view.render().el);
|
||||
},
|
||||
|
||||
// 'grid'
|
||||
addGridOne: function(dirent) {
|
||||
var view = new DirentGridView({model: dirent, dirView: this});
|
||||
this.$gridViewContainer.append(view.render().el);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.direntDetailsView.hide();
|
||||
this.fileCommentsView.hide();
|
||||
|
||||
this.renderToolbar();
|
||||
this.renderPath();
|
||||
this.renderDirOpBar();
|
||||
|
||||
this.$el_con.show();
|
||||
this.$con.hide();
|
||||
|
||||
this.setFileInput();
|
||||
this.$table.hide();
|
||||
this.$tbody.empty();
|
||||
this.$gridViewContainer.hide().empty();
|
||||
|
||||
// there may be a 'style' added via 'onWindowScroll()' when visiting last dir
|
||||
this.$('.js-dir-content').removeAttr('style');
|
||||
this.$con.show();
|
||||
|
||||
if (this.view_mode == 'list') {
|
||||
this.renderDirentsHd();
|
||||
}
|
||||
|
||||
this.$dirent_grid.empty();
|
||||
this.$dirent_list_body.empty();
|
||||
|
||||
if (this.view_mode == 'list') {
|
||||
this.$dirent_list.show();
|
||||
this.$dirent_grid.hide();
|
||||
this.renderThead();
|
||||
Common.updateSortIconByMode({'context': this.$table});
|
||||
this.$table.show();
|
||||
} else {
|
||||
this.$dirent_list.hide();
|
||||
this.$dirent_grid.show();
|
||||
this.$gridViewContainer.show();
|
||||
}
|
||||
|
||||
// sort
|
||||
Common.updateSortIconByMode({'context': this.$el});
|
||||
this.sortDirents();
|
||||
|
||||
this.dir.last_start = 0;
|
||||
this.dir.limit = 100;
|
||||
this.render_dirents_slice(this.dir.last_start, this.dir.limit);
|
||||
|
||||
this.updateDirOpBarUI(); // after `render_dirents_slice`
|
||||
|
||||
this.getThumbnail();
|
||||
},
|
||||
|
||||
updateDirOpBarUI: function() {
|
||||
var width;
|
||||
if ($(window).width() > 500) {
|
||||
width = this.$('.repo-op').width() - parseInt(this.$('.repo-op-misc').css('margin-left')) - 5;
|
||||
width -= $('#multi-dirents-op').is(':visible') ? $('#multi-dirents-op').width() : $('#cur-dir-ops').width();
|
||||
this.$('.repo-op-misc').css({'width': width});
|
||||
} else {
|
||||
this.$('.repo-op-misc').removeAttr('style');
|
||||
}
|
||||
},
|
||||
|
||||
updateMagnificPopupOptions: function(options) {
|
||||
var repo_id = this.dir.repo_id,
|
||||
path = this.dir.path;
|
||||
@@ -402,13 +386,12 @@ define([
|
||||
|
||||
_showLibDecryptDialog: function() {
|
||||
var _this = this;
|
||||
var form = $($('#repo-decrypt-form-template').html());
|
||||
var $form = $(this.repoDecryptFormTemplate());
|
||||
var decrypt_success = false;
|
||||
form.modal({
|
||||
$form.modal({
|
||||
containerCss: {'padding': '1px'},
|
||||
onClose: function () {
|
||||
$.modal.close();
|
||||
_this.$el_con.show();
|
||||
if (!decrypt_success) {
|
||||
app.router.navigate(
|
||||
_this.dir.category + '/', // need to append '/' at end
|
||||
@@ -418,15 +401,15 @@ define([
|
||||
}
|
||||
});
|
||||
$('#simplemodal-container').css({'height':'auto'});
|
||||
form.submit(function() {
|
||||
var passwd = $.trim($('[name="password"]', form).val());
|
||||
$form.submit(function() {
|
||||
var passwd = $.trim($('[name="password"]', $form).val());
|
||||
if (!passwd) {
|
||||
$('.error', form).html(gettext("Password is required.")).removeClass('hide');
|
||||
$('.error', $form).html(gettext("Password is required.")).removeClass('hide');
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
form: $form,
|
||||
form_id: $form.attr('id'),
|
||||
post_url: Common.getUrl({
|
||||
'name': 'api_v2.1_repo_set_password',
|
||||
'repo_id': _this.dir.repo_id
|
||||
@@ -445,10 +428,10 @@ define([
|
||||
},
|
||||
|
||||
renderDir: function() {
|
||||
this.$loading_tip.show();
|
||||
this.$error.hide();
|
||||
this.$el_con.hide();
|
||||
|
||||
this.$loadingTip.show();
|
||||
this.$con.hide();
|
||||
this.$error.hide();
|
||||
|
||||
var _this = this;
|
||||
var thumbnail_size = app.pageOptions.thumbnail_default_size;
|
||||
@@ -464,12 +447,8 @@ define([
|
||||
'thumbnail_size': thumbnail_size
|
||||
},
|
||||
success: function() {
|
||||
_this.$loading_tip.hide();
|
||||
},
|
||||
error: function(collection, response, opts) {
|
||||
_this.$loading_tip.hide();
|
||||
_this.$el_con.hide();
|
||||
|
||||
var err_msg;
|
||||
if (response.responseText) {
|
||||
if (response.responseJSON.lib_need_decrypt) {
|
||||
@@ -482,6 +461,9 @@ define([
|
||||
err_msg = gettext('Please check the network.');
|
||||
}
|
||||
_this.$error.html(err_msg).show();
|
||||
},
|
||||
complete: function() {
|
||||
_this.$loadingTip.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -517,27 +499,33 @@ define([
|
||||
});
|
||||
}
|
||||
|
||||
this.$path_bar.html(this.path_bar_template(obj));
|
||||
this.$('.dir-path').html(this.pathTemplate(obj));
|
||||
},
|
||||
|
||||
renderDirOpBar: function() {
|
||||
renderToolbar: function() {
|
||||
var dir = this.dir;
|
||||
|
||||
this.$dir_op_bar.html($.trim(this.dir_op_bar_template({
|
||||
var data = {
|
||||
user_perm: dir.user_perm,
|
||||
no_quota: dir.no_quota,
|
||||
encrypted: dir.encrypted,
|
||||
mode: this.view_mode,
|
||||
path: dir.path,
|
||||
repo_id: dir.repo_id,
|
||||
site_root: app.pageOptions.site_root,
|
||||
is_repo_owner: dir.is_repo_owner,
|
||||
can_generate_share_link: app.pageOptions.can_generate_share_link,
|
||||
can_generate_upload_link: app.pageOptions.can_generate_upload_link,
|
||||
enable_upload_folder: app.pageOptions.enable_upload_folder
|
||||
})))
|
||||
.removeAttr('style'); // there may be a 'style' added via 'onWindowScroll()' when visiting last dir
|
||||
site_root: app.pageOptions.site_root
|
||||
};
|
||||
|
||||
if (!$('#dir-view-toolbar').length) {
|
||||
this.$toolbar = $('<div class="cur-view-toolbar d-flex" id="dir-view-toolbar"></div>').html(this.toolbarTemplate(data));
|
||||
this.$('.common-toolbar').before(this.$toolbar);
|
||||
} else {
|
||||
this.$toolbar.html(this.toolbarTemplate(data));
|
||||
}
|
||||
|
||||
this.$('.dir-toolbar-2').html(this.toolbar2Template(data));
|
||||
|
||||
// for 'upload'
|
||||
this.setFileInput();
|
||||
|
||||
if (dir.user_perm == 'rw') {
|
||||
// add new folder/file
|
||||
@@ -547,14 +535,15 @@ define([
|
||||
}
|
||||
},
|
||||
|
||||
renderDirentsHd: function() {
|
||||
var tmpl = $(window).width() < 768 ? this.dirents_hd_mobile_template : this.dirents_hd_template;
|
||||
renderThead: function() {
|
||||
var tmpl = $(window).width() < 768 ? this.theadMobileTemplate : this.theadTemplate;
|
||||
this.$('thead').html(tmpl());
|
||||
},
|
||||
|
||||
render_dirents_slice: function(start, limit) {
|
||||
var dir = this.dir;
|
||||
_.each(dir.slice(start, start + limit), this.addOne, this);
|
||||
var addOne = this.view_mode == 'list' ? this.addListOne : this.addGridOne;
|
||||
_.each(dir.slice(start, start + limit), addOne, this);
|
||||
if (dir.length > start + limit) {
|
||||
dir.dirent_more = true;
|
||||
dir.last_start = start + limit;
|
||||
@@ -565,6 +554,10 @@ define([
|
||||
|
||||
// Directory Operations
|
||||
events: {
|
||||
'click #dir-view-toolbar .basic-upload-btn': 'uploadFile',
|
||||
'click #dir-view-toolbar .advanced-upload-file': 'advancedUploadFile',
|
||||
'click #dir-view-toolbar .advanced-upload-folder': 'advancedUploadFolder',
|
||||
|
||||
'click #add-new li a': 'closeNewDropdown',
|
||||
'click #add-new-dir': 'newDir',
|
||||
'click #add-new-file': 'newCommonFile',
|
||||
@@ -572,19 +565,20 @@ define([
|
||||
'click #add-new-excel-file': 'newExcelFile',
|
||||
'click #add-new-ppt-file': 'newPPTFile',
|
||||
'click #add-new-word-file': 'newWordFile',
|
||||
|
||||
'click #share-cur-dir': 'share',
|
||||
'click #js-switch-grid-view': 'switchToGridView',
|
||||
'click #js-switch-list-view': 'switchToListView',
|
||||
'click th.select': 'select',
|
||||
|
||||
'click #mv-dirents': 'mv',
|
||||
'click #cp-dirents': 'cp',
|
||||
'click #del-dirents': 'del',
|
||||
'click #download-dirents': 'download',
|
||||
'click .by-name': 'sortByName',
|
||||
'click .by-time': 'sortByTime',
|
||||
'click .basic-upload-btn': 'uploadFile',
|
||||
'click .advanced-upload-file': 'advancedUploadFile',
|
||||
'click .advanced-upload-folder': 'advancedUploadFolder'
|
||||
|
||||
'click #dir-view th.select': 'select',
|
||||
'click #dir-view .by-name': 'sortByName',
|
||||
'click #dir-view .by-time': 'sortByTime'
|
||||
//'scroll #dir-view .cur-view-main-con': 'getMore' // It doesn't work.
|
||||
},
|
||||
|
||||
uploadFile: function() {
|
||||
@@ -611,7 +605,7 @@ define([
|
||||
dir = this.dir,
|
||||
dirView = this;
|
||||
|
||||
form.modal({appendTo:'#main'});
|
||||
form.modal();
|
||||
$('#simplemodal-container').css({'height':'auto'});
|
||||
|
||||
form.submit(function() {
|
||||
@@ -627,7 +621,7 @@ define([
|
||||
return false;
|
||||
}
|
||||
|
||||
var post_data = { 'operation': 'mkdir' },
|
||||
var post_data = {'operation': 'mkdir'},
|
||||
post_url = Common.getUrl({name: "new_dir", repo_id: dir.repo_id})
|
||||
+ '?p=' + encodeURIComponent(Common.pathJoin([dir.path, dirent_name]));
|
||||
var after_op_success = function(data) {
|
||||
@@ -646,10 +640,10 @@ define([
|
||||
|
||||
Common.ajaxPost({
|
||||
'form': form,
|
||||
'form_id': form_id,
|
||||
'post_url': post_url,
|
||||
'post_data': post_data,
|
||||
'after_op_success': after_op_success,
|
||||
'form_id': form_id
|
||||
'after_op_success': after_op_success
|
||||
});
|
||||
|
||||
return false;
|
||||
@@ -666,7 +660,6 @@ define([
|
||||
dirView = this;
|
||||
|
||||
$form.modal({
|
||||
appendTo: '#main',
|
||||
focus: false,
|
||||
containerCss: {'padding':'20px 25px'}
|
||||
});
|
||||
@@ -716,10 +709,10 @@ define([
|
||||
|
||||
Common.ajaxPost({
|
||||
'form': $form,
|
||||
'form_id': form_id,
|
||||
'post_url': post_url,
|
||||
'post_data': post_data,
|
||||
'after_op_success': after_op_success,
|
||||
'form_id': form_id
|
||||
'after_op_success': after_op_success
|
||||
});
|
||||
|
||||
return false;
|
||||
@@ -767,36 +760,34 @@ define([
|
||||
},
|
||||
|
||||
addNewFile: function(new_dirent) {
|
||||
var dirView = this,
|
||||
dir = this.dir;
|
||||
|
||||
var view, $el;
|
||||
if (this.view_mode == 'list') {
|
||||
var view = new DirentView({model: new_dirent, dirView: dirView});
|
||||
var new_file = view.render().el;
|
||||
view = new DirentView({model: new_dirent, dirView: this});
|
||||
$el = view.render().el;
|
||||
// put the new file as the first file
|
||||
if ($('tr', dirView.$dirent_list_body).length == 0) {
|
||||
dirView.$dirent_list_body.append(new_file);
|
||||
if ($('tr', this.$tbody).length == 0) {
|
||||
this.$tbody.append($el);
|
||||
} else {
|
||||
var dirs = dir.where({'is_dir':true});
|
||||
var dirs = this.dir.where({'is_dir':true});
|
||||
if (dirs.length == 0) {
|
||||
dirView.$dirent_list_body.prepend(new_file);
|
||||
this.$tbody.prepend($el);
|
||||
} else {
|
||||
// put the new file after the last dir
|
||||
$($('tr', dirView.$dirent_list_body)[dirs.length - 1]).after(new_file);
|
||||
$($('tr', this.$tbody)[dirs.length - 1]).after($el);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var gview = new DirentGridView({model: new_dirent, dirView: dirView});
|
||||
var grid_new_file = gview.render().el;
|
||||
if ($('.grid-item', dirView.$dirent_grid).length == 0) {
|
||||
dirView.$dirent_grid.append(grid_new_file);
|
||||
view = new DirentGridView({model: new_dirent, dirView: this});
|
||||
$el = view.render().el;
|
||||
if ($('.grid-item', this.$gridViewContainer).length == 0) {
|
||||
this.$gridViewContainer.append($el);
|
||||
} else {
|
||||
var dirs = dir.where({'is_dir':true});
|
||||
var dirs = this.dir.where({'is_dir':true});
|
||||
if (dirs.length == 0) {
|
||||
dirView.$dirent_grid.prepend(grid_new_file);
|
||||
this.$gridViewContainer.prepend($el);
|
||||
} else {
|
||||
// put the new file after the last dir
|
||||
$($('.grid-item', dirView.$dirent_grid)[dirs.length - 1]).after(grid_new_file);
|
||||
$($('.grid-item', this.$gridViewContainer)[dirs.length - 1]).after($el);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -807,14 +798,14 @@ define([
|
||||
},
|
||||
|
||||
addNewDir: function(new_dirent) {
|
||||
var dirView = this;
|
||||
// put the new dir as the first one
|
||||
var view;
|
||||
if (this.view_mode == 'list') {
|
||||
var view = new DirentView({model: new_dirent, dirView: dirView});
|
||||
// put the new dir as the first one
|
||||
dirView.$dirent_list_body.prepend(view.render().el);
|
||||
view = new DirentView({model: new_dirent, dirView: this});
|
||||
this.$tbody.prepend(view.render().el);
|
||||
} else {
|
||||
var gview = new DirentGridView({model: new_dirent, dirView: dirView});
|
||||
dirView.$dirent_grid.prepend(gview.render().el);
|
||||
view = new DirentGridView({model: new_dirent, dirView: this});
|
||||
this.$gridViewContainer.prepend(view.render().el);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -838,23 +829,25 @@ define([
|
||||
|
||||
switchToGridView: function() {
|
||||
if (this.view_mode == 'grid') {
|
||||
return false;
|
||||
return;
|
||||
} else {
|
||||
this.view_mode = 'grid';
|
||||
Cookies.set('view_mode', 'grid');
|
||||
this.$('.list-view-icon-btn').removeClass('active');
|
||||
this.$('.grid-view-icon-btn').addClass('active');
|
||||
this.renderDir();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
switchToListView: function() {
|
||||
if (this.view_mode == 'list') {
|
||||
return false;
|
||||
return;
|
||||
} else {
|
||||
this.view_mode = 'list';
|
||||
Cookies.set('view_mode', 'list');
|
||||
this.$('.grid-view-icon-btn').removeClass('active');
|
||||
this.$('.list-view-icon-btn').addClass('active');
|
||||
this.renderDir();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -916,10 +909,10 @@ define([
|
||||
|
||||
sortByName: function() {
|
||||
Common.toggleSortByNameMode();
|
||||
Common.updateSortIconByMode({'context': this.$el});
|
||||
Common.updateSortIconByMode({'context': this.$table});
|
||||
this.sortDirents();
|
||||
|
||||
this.$dirent_list_body.empty();
|
||||
this.$tbody.empty();
|
||||
this.render_dirents_slice(0, this.dir.limit);
|
||||
this.dir.comparator = null;
|
||||
return false;
|
||||
@@ -927,10 +920,10 @@ define([
|
||||
|
||||
sortByTime: function () {
|
||||
Common.toggleSortByTimeMode();
|
||||
Common.updateSortIconByMode({'context': this.$el});
|
||||
Common.updateSortIconByMode({'context': this.$table});
|
||||
this.sortDirents();
|
||||
|
||||
this.$dirent_list_body.empty();
|
||||
this.$tbody.empty();
|
||||
this.render_dirents_slice(0, this.dir.limit);
|
||||
this.dir.comparator = null;
|
||||
return false;
|
||||
@@ -950,7 +943,7 @@ define([
|
||||
dir.each(function(model) {
|
||||
model.set({'selected': true}, {silent: true});
|
||||
});
|
||||
$dirents_op.css({'display':'inline-block'});
|
||||
$dirents_op.show();
|
||||
$curDirOps.hide();
|
||||
} else {
|
||||
$all_dirent_checkbox.prop('checked', false);
|
||||
@@ -960,8 +953,6 @@ define([
|
||||
$dirents_op.hide();
|
||||
$curDirOps.show();
|
||||
}
|
||||
|
||||
this.updateDirOpBarUI();
|
||||
},
|
||||
|
||||
download: function () {
|
||||
@@ -1013,10 +1004,9 @@ define([
|
||||
if (del_len > 0) {
|
||||
if (del_len == selected_names.length) {
|
||||
dirents.remove(selected_dirents);
|
||||
_this.$('th [type=checkbox]').prop('checked', false);
|
||||
$('th [type=checkbox]', _this.$table).prop('checked', false);
|
||||
_this.$('#multi-dirents-op').hide();
|
||||
_this.$('#cur-dir-ops').show();
|
||||
_this.updateDirOpBarUI();
|
||||
} else {
|
||||
$(selected_dirents).each(function() {
|
||||
if (data['deleted'].indexOf(this.get('obj_name')) != -1) {
|
||||
@@ -1085,7 +1075,7 @@ define([
|
||||
show_cur_repo: show_cur_repo,
|
||||
show_other_repos: !dir.encrypted
|
||||
}));
|
||||
form.modal({appendTo:'#main', autoResize:true, focus:false});
|
||||
form.modal({autoResize:true, focus:false});
|
||||
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
|
||||
|
||||
if (show_cur_repo) {
|
||||
@@ -1161,7 +1151,6 @@ define([
|
||||
_this.$('th .checkbox').removeClass('checkbox-checked');
|
||||
_this.$('#multi-dirents-op').hide();
|
||||
_this.$('#cur-dir-ops').show();
|
||||
_this.updateDirOpBarUI();
|
||||
} else {
|
||||
$(dirs).each(function() {
|
||||
if (this.get('obj_name') in data['success']) {
|
||||
@@ -1375,36 +1364,14 @@ define([
|
||||
});
|
||||
},
|
||||
|
||||
onWindowScroll: function () {
|
||||
// 'more'
|
||||
getMore: function () {
|
||||
var $el = this.$('.cur-view-main-con')[0];
|
||||
if (this.dir.dirent_more &&
|
||||
$(window).scrollTop() + $(window).height() == $(document).height()) { // scroll to the bottom
|
||||
$el.scrollTop > 0 &&
|
||||
$el.clientHeight + $el.scrollTop == $el.scrollHeight) { // scroll to the bottom
|
||||
this.render_dirents_slice(this.dir.last_start, this.dir.limit);
|
||||
this.getThumbnail();
|
||||
}
|
||||
|
||||
// fixed 'dir-op-bar'
|
||||
var op_bar = this.$dir_op_bar,
|
||||
path_bar = this.$path_bar, // the element before op_bar
|
||||
repo_file_list = this.$('.js-dir-content'); // the element after op_bar
|
||||
var op_bar_top = path_bar.offset().top + path_bar.outerHeight(true);
|
||||
var fixed_styles = {
|
||||
'position': 'fixed',
|
||||
'top': 0,
|
||||
'left': path_bar.offset().left,
|
||||
'background-color': $('#header').css('background-color'),
|
||||
'z-index': 12 // make 'op_bar' shown on top of the checkboxes
|
||||
};
|
||||
if (!op_bar_top) {
|
||||
return;
|
||||
}
|
||||
if ($(window).scrollTop() >= op_bar_top) {
|
||||
repo_file_list.css({'margin-top':op_bar.outerHeight(true)});
|
||||
op_bar.outerWidth(this.$el.width()).css(fixed_styles);
|
||||
} else {
|
||||
repo_file_list.css({'margin-top':0});
|
||||
op_bar.removeAttr('style');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user