mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-05 19:26:30 +00:00
76 lines
2.2 KiB
JavaScript
76 lines
2.2 KiB
JavaScript
|
define([
|
||
|
'jquery',
|
||
|
'underscore',
|
||
|
'backbone',
|
||
|
'common'
|
||
|
], function($, _, Backbone, Common) {
|
||
|
'use strict';
|
||
|
|
||
|
var GroupSideNavView = Backbone.View.extend({
|
||
|
el: '#grp-side-nav',
|
||
|
|
||
|
template: _.template($("#grp-side-nav-tmpl").html()),
|
||
|
enableModTemplate: _.template($("#grp-mods-enable-form-tmpl").html()),
|
||
|
|
||
|
initialize: function() {
|
||
|
},
|
||
|
|
||
|
render: function (group_id) {
|
||
|
this.group_id = group_id;
|
||
|
var _this = this;
|
||
|
$.ajax({
|
||
|
url: Common.getUrl({
|
||
|
'name': 'group_basic_info',
|
||
|
'group_id': this.group_id
|
||
|
}),
|
||
|
cache: false,
|
||
|
dataType: 'json',
|
||
|
success: function (data) {
|
||
|
_this.$el.html(_this.template(data));
|
||
|
// for 'enable mod'
|
||
|
_this.mods_available = data.mods_available;
|
||
|
_this.mods_enabled = data.mods_enabled;
|
||
|
},
|
||
|
error: function(xhr) {
|
||
|
var err_msg;
|
||
|
if (xhr.responseText) {
|
||
|
err_msg = $.parseJSON(xhr.responseText).error;
|
||
|
} else {
|
||
|
err_msg = gettext("Please check the network.");
|
||
|
}
|
||
|
_this.$el.html('<p class="error">' + err_msg + '</p>');
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
events: {
|
||
|
'click #enable-mods': 'enableMods'
|
||
|
},
|
||
|
|
||
|
enableMods: function () {
|
||
|
var form = $(this.enableModTemplate({
|
||
|
'id': this.group_id,
|
||
|
'mods_available': this.mods_available,
|
||
|
'mods_enabled': this.mods_enabled
|
||
|
}));
|
||
|
form.modal();
|
||
|
$('#simplemodal-container').css('height', 'auto');
|
||
|
$('.checkbox-orig', form).click(function() {
|
||
|
$(this).parent().toggleClass('checkbox-checked');
|
||
|
});
|
||
|
// TODO: after form submit, page goes to http://127.0.0.1:8000/
|
||
|
},
|
||
|
|
||
|
show: function() {
|
||
|
this.$el.show();
|
||
|
},
|
||
|
|
||
|
hide: function() {
|
||
|
this.$el.hide();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
return GroupSideNavView;
|
||
|
});
|