1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

[backbone] Several small interface improvements

This commit is contained in:
Daniel Pan
2015-02-11 22:36:35 +08:00
parent 1a47494adb
commit e4036efab2
6 changed files with 79 additions and 26 deletions

View File

@@ -56,6 +56,7 @@ define([
this.$tabs.show();
this.$table.hide();
this.$loadingTip.show();
$('#mylib-tab', this.$tabs).parent().addClass('ui-state-active');
},
show: function() {
@@ -65,6 +66,7 @@ define([
hide: function() {
this.$el.hide();
this.$table.hide();
$('#mylib-tab', this.$tabs).parent().removeClass('ui-state-active');
},
createRepo: function() {

View File

@@ -56,6 +56,7 @@ define([
//this.$table.parent().show();
this.$table.hide();
this.$loadingTip.show();
$('#shared-lib-tab', this.$tabs).parent().addClass('ui-state-active');
},
show: function() {
@@ -65,6 +66,7 @@ define([
hide: function() {
this.$el.hide();
this.$table.hide();
$('#shared-lib-tab', this.$tabs).parent().removeClass('ui-state-active');
},

View File

@@ -28,6 +28,8 @@ define([
this.sharedReposView = new SharedReposView();
this.dirView = new DirView();
this.groupView = new GroupNavView();
Common.initAccountPopup();
},

View File

@@ -228,33 +228,80 @@ define([
return result;
},
fileSizeFormat: function (bytes, precision) {
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
var gigabyte = megabyte * 1024;
var terabyte = gigabyte * 1024;
closePopup: function(e, popup, popup_switch) {
var target = e.target || event.srcElement;
if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) {
popup.addClass('hide');
}
},
var precision = precision || 0;
initAccountPopup: function() {
// TODO: need improving
$('#my-info').click(function() {
var popup = $('#user-info-popup');
popup.toggleClass('hide');
if (!popup.hasClass('hide')) {
var loading_tip = $('.loading-tip', popup),
space_traffic = $('#space-traffic');
loading_tip.show();
space_traffic.addClass('hide');
$('.error', popup).addClass('hide');
$.ajax({
url: space_traffic.data('url'),
dataType: 'json',
cache: false,
success: function(data) {
loading_tip.hide();
space_traffic.html(data['html']).removeClass('hide');
},
error: function (xhr, textStatus, errorThrown) {
if (xhr.responseText) {
var error = $.parseJSON(xhr.responseText).error;
loading_tip.hide();
if ($('.error', popup).length == 0) {
loading_tip.after('<p class="error alc">' + error + '</p>');
} else {
$('.error', popup).removeClass('hide');
}
}
}
});
}
});
if ((bytes >= 0) && (bytes < kilobyte)) {
return bytes + ' B';
_this = this;
$(document).click(function(e) {
_this.closePopup(e, $('#user-info-popup'), $('#my-info'));
});
},
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
return (bytes / kilobyte).toFixed(precision) + ' KB';
fileSizeFormat: function(bytes, precision) {
var kilobyte = 1024;
var megabyte = kilobyte * 1024;
var gigabyte = megabyte * 1024;
var terabyte = gigabyte * 1024;
} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
return (bytes / megabyte).toFixed(precision) + ' MB';
var precision = precision || 0;
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
return (bytes / gigabyte).toFixed(precision) + ' GB';
if ((bytes >= 0) && (bytes < kilobyte)) {
return bytes + ' B';
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + ' TB';
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
return (bytes / kilobyte).toFixed(precision) + ' KB';
} else {
return bytes + ' B';
}
}
} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
return (bytes / megabyte).toFixed(precision) + ' MB';
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
return (bytes / gigabyte).toFixed(precision) + ' GB';
} else if (bytes >= terabyte) {
return (bytes / terabyte).toFixed(precision) + ' TB';
} else {
return bytes + ' B';
}
}
}
});

View File

@@ -11,7 +11,7 @@ from seaserv import FILE_SERVER_ROOT, FILE_SERVER_PORT
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)
DEBUG = True
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ADMINS = (

View File

@@ -1,5 +1,5 @@
{% load i18n %}
{% trans "Libraries" %} /
<a href="#" class="path-link normal">{% trans "Libraries" %}</a> /
<a href="#<%= category %>" class="path-link normal"><% if (category == 'my-libs') { %>{% trans "Mine" %}<% } %><% if (category == 'shared-libs') { %>{% trans "Shared" %}<% } %></a> /
<% if (path == '/') { %>
<%= repo_name %> /