mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
Rewrite account info popup and clean css
This commit is contained in:
71
static/scripts/app/views/account.js
Normal file
71
static/scripts/app/views/account.js
Normal file
@@ -0,0 +1,71 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/views/widgets/popover'
|
||||
], function($, _, Backbone, Common, PopoverView) {
|
||||
'use strict';
|
||||
|
||||
var View = PopoverView.extend({
|
||||
id: 'user-info-popup',
|
||||
className: 'popover account-popup',
|
||||
|
||||
template: _.template($('#user-info-popup-tmpl').html()),
|
||||
|
||||
initialize: function(options) {
|
||||
PopoverView.prototype.initialize.call(this);
|
||||
|
||||
this.render();
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$error = this.$('.error');
|
||||
this.$space = this.$('#space-traffic');
|
||||
this.$account = $('#account');
|
||||
|
||||
var _this = this;
|
||||
$('#my-info').click(function() {
|
||||
_this.toggle();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template());
|
||||
return this;
|
||||
},
|
||||
|
||||
showContent: function() {
|
||||
var _this = this;
|
||||
|
||||
this.$error.hide();
|
||||
this.$loadingTip.show();
|
||||
this.$space.addClass('hide');
|
||||
|
||||
$.ajax({
|
||||
url: this.$space.data('url'),
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
_this.$loadingTip.hide();
|
||||
_this.$space.html(data['html']).removeClass('hide');
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
_this.$loadingTip.hide();
|
||||
var err_msg;
|
||||
if (xhr.responseText) {
|
||||
err_msg = $.parseJSON(xhr.responseText).error;
|
||||
} else {
|
||||
err_msg = gettext('Please check the network.');
|
||||
}
|
||||
_this.$error.html(err_msg).show();
|
||||
}
|
||||
});
|
||||
|
||||
this.$account.append(this.$el);
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return View;
|
||||
});
|
Reference in New Issue
Block a user