mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
redesigned side nav; removed 'top group nav'
This commit is contained in:
@@ -690,6 +690,10 @@ textarea:-moz-placeholder {/* for FF */
|
||||
color:#333;
|
||||
font-weight:normal;
|
||||
}
|
||||
.side-tabnav-tabs .tab .grp-list a {
|
||||
font-size:14px;
|
||||
padding:0;
|
||||
}
|
||||
.side-tabnav-tabs .tab a:hover {
|
||||
background-color:#feefb8;
|
||||
text-decoration:none;
|
||||
@@ -712,9 +716,30 @@ textarea:-moz-placeholder {/* for FF */
|
||||
.side-tabnav-tabs .tab-cur a {
|
||||
color:#fff;
|
||||
}
|
||||
.side-tabnav-tabs .tab-cur a {
|
||||
.side-tabnav-tabs .tab-cur a,
|
||||
.side-tabnav-tabs .tab-cur .grp-list .cur a {
|
||||
font-weight:bold;
|
||||
}
|
||||
.side-tabnav-tabs .tab-cur .grp-list a {
|
||||
background:transparent;
|
||||
font-weight:normal;
|
||||
color:#333;
|
||||
}
|
||||
.side-tabnav-tabs .tab .grp-list a:hover,
|
||||
.side-tabnav-tabs .tab-cur .grp-list a:hover {
|
||||
background-color:#feefb8;
|
||||
}
|
||||
#group-nav .grp-list {
|
||||
max-height:105px;
|
||||
overflow:auto;
|
||||
}
|
||||
#group-nav .sharp {
|
||||
display:inline-block;
|
||||
width:42px;
|
||||
margin-right:5px;
|
||||
text-align:right;
|
||||
color:#aaa;
|
||||
}
|
||||
.side-textnav .hd {
|
||||
margin:2em 0 .5em;
|
||||
}
|
||||
|
@@ -18,19 +18,19 @@
|
||||
{% if user.permissions.can_view_org %}
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}#org/"><span class="sf2-icon-organization"></span>{% trans "Organization" %}</a></li>
|
||||
{% endif %}
|
||||
<li class="tab">
|
||||
{% if grps %}
|
||||
<a href="#"><span class="sf2-icon-group"></span>{% trans "Groups" %}</a>
|
||||
<ul class="group-list">
|
||||
|
||||
<li class="tab" id="group-nav">
|
||||
<a href="#"><span class="sf2-icon-group"></span>{% trans "Groups" %}<span class="toggle-icon icon-caret-left fright"></span></a>
|
||||
<ul class="grp-list hide">
|
||||
<li>
|
||||
<a href="{% url 'group_list' %}"><span class="sharp">#</span>{% trans "All Groups" %}</a>
|
||||
</li>
|
||||
{% for grp in grps %}
|
||||
<li class="item">
|
||||
<a class="name ellipsis" href="{{SITE_ROOT}}#group/{{ grp.id }}/" title="{{ grp.group_name }}">{{ grp.group_name }}</a>
|
||||
<li>
|
||||
<a class="ellipsis" href="{{SITE_ROOT}}#group/{{ grp.id }}/" title="{{ grp.group_name }}"><span class="sharp">#</span>{{ grp.group_name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<a href="{% url 'group_list' %}"><span class="sf2-icon-group"></span>{% trans "Groups" %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -93,6 +93,11 @@ $('#enable-mods').click(function() {
|
||||
$('#simplemodal-container').css('height', 'auto');
|
||||
return false;
|
||||
});
|
||||
$('#group-nav a:first').click(function() {
|
||||
$('#group-nav .toggle-icon').toggleClass('icon-caret-left icon-caret-down');
|
||||
$('#group-nav .grp-list').slideToggle();
|
||||
return false;
|
||||
});
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@@ -90,23 +90,6 @@
|
||||
<td><%= mtime_relative %></td>
|
||||
<td><span title="<%- owner %>"><%- owner_nickname %></span></td>
|
||||
</script>
|
||||
<script type="text/template" id="top-group-nav-tmpl">
|
||||
<div id="top-nav-grp-info" class="top-info-popup hide">
|
||||
<div class="outer-caret up-outer-caret">
|
||||
<div class="inner-caret"></div>
|
||||
</div>
|
||||
<ul id="top-nav-grp-list">
|
||||
<% for (var i = 0, len = groups.length; i < len; i++) { %>
|
||||
<li class="item" data-url="#group/<%= groups[i].id %>/" title="<%= groups[i].name %>">
|
||||
<%= groups[i].avatar %>
|
||||
<span class="name ellipsis vam"><%= groups[i].name %></span>
|
||||
<a href="{{SITE_ROOT}}group/<%= groups[i].id %>/discuss/" title="{% trans "Discussion" %}" class="op-icon sf2-icon-msgs vh"></a>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<a href="{% url 'group_list' %}" class="item all-grp">{% trans 'All Groups' %}</a>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/template" id="dir-op-bar-tmpl">
|
||||
<% if (user_perm == 'rw') { %>
|
||||
<div id="multi-dirents-op" class="hide">
|
||||
@@ -547,27 +530,70 @@
|
||||
<td><a href="#my-libs/lib/<%= origin_repo_id %><%- origin_path %>"><%- abbrev_origin_path %></a></td>
|
||||
<td><%= mtime_relative %></td>
|
||||
</script>
|
||||
<script type="text/template" id="myhome-side-nav-tmpl">
|
||||
<div class="hd w100 ovhd">
|
||||
<h3 class="fleft">{% trans "Personal" %}</h3>
|
||||
<% if (can_add_repo) { %>
|
||||
<span id="myhome-enable-mods" class="sf2-icon-cog2 op-icon fright" title="{% trans "Enable Modules" %}"></span>
|
||||
<script type="text/template" id="side-nav-tmpl">
|
||||
<h3 class="hd">{% trans "Files" %}</h3>
|
||||
<ul class="side-tabnav-tabs">
|
||||
{% if user.permissions.can_add_repo %}
|
||||
<li class="tab<% if (cur_tab == 'mine') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#my-libs/"><span class="sf2-icon-user"></span>{% trans "Mine" %}</a></li>
|
||||
{% comment %}
|
||||
{% if sub_lib_enabled %}
|
||||
<li class="tab<% if (cur_tab == 'sub-libs') { %> tab-cur<% } %>"><a href="#my-sub-libs/">{% trans "Sub-libraries" %}</a></li>
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
{% endif %}
|
||||
|
||||
<li class="tab<% if (cur_tab == 'shared') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#shared-libs/"><span class="sf2-icon-share"></span>{% trans "Shared" %}</a></li>
|
||||
|
||||
{% if user.permissions.can_view_org %}
|
||||
<li class="tab<% if (cur_tab == 'org') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#org/"><span class="sf2-icon-organization"></span>{% trans "Organization" %}</a></li>
|
||||
{% endif %}
|
||||
|
||||
<% if (cur_tab == 'group') { %>
|
||||
<li class="tab tab-cur" id="group-nav">
|
||||
<a href="#"><span class="sf2-icon-group"></span>{% trans "Groups" %}<span class="toggle-icon icon-caret-down fright"></span></a>
|
||||
<ul class="grp-list">
|
||||
<li><a href="{% url 'group_list' %}"><span class="sharp">#</span>{% trans "All Groups" %}</a></li>
|
||||
{% for grp in grps %}
|
||||
<li<% if (cur_group_id == '{{ grp.id }}') { %> class="cur"<% }%>>
|
||||
<a class="ellipsis" href="{{SITE_ROOT}}#group/{{ grp.id }}/" title="{{ grp.group_name }}"><span class="sharp">#</span>{{ grp.group_name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<% } else { %>
|
||||
<li class="tab" id="group-nav">
|
||||
<a href="#"><span class="sf2-icon-group"></span>{% trans "Groups" %}<span class="toggle-icon icon-caret-left fright"></span></a>
|
||||
<ul class="grp-list hide">
|
||||
<li>
|
||||
<a href="{% url 'group_list' %}"><span class="sharp">#</span>{% trans "All Groups" %}</a>
|
||||
</li>
|
||||
{% for grp in grps %}
|
||||
<li>
|
||||
<a class="ellipsis" href="{{SITE_ROOT}}#group/{{ grp.id }}/" title="{{ grp.group_name }}"><span class="sharp">#</span>{{ grp.group_name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
|
||||
<div class="hd w100 ovhd">
|
||||
<h3 class="fleft">{% trans "Tools" %}</h3>
|
||||
{% if user.permissions.can_add_repo %}
|
||||
<span id="enable-mods" class="sf2-icon-cog2 op-icon fright" title="{% trans "Enable Modules" %}"></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<ul class="side-tabnav-tabs">
|
||||
<li class="tab<% if (cur_tab == 'libs') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a></li>
|
||||
<li class="tab<% if (cur_tab == 'starred') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#starred/"><span class="sf2-icon-star"></span>{% trans "Starred" %}</a></li>
|
||||
<% if (events_enabled) { %>
|
||||
{% if events_enabled %}
|
||||
<li class="tab<% if (cur_tab == 'activities') { %> tab-cur<% } %>"><a href="{{ SITE_ROOT }}#activities/"><span class="sf2-icon-clock"></span>{% trans "Activities" %}</a></li>
|
||||
<% } %>
|
||||
|
||||
<% for (var i = 0, len = mods_enabled.length; i < len; i++) { %>
|
||||
<% if (mods_enabled[i] == 'personal wiki') { %>
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}home/wiki/"><span class="sf2-icon-wiki"></span>{% trans "Personal Wiki" %}</a></li>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}devices/"><span class="sf2-icon-monitor"></span>{% trans "Devices" %}</a></li>
|
||||
{% endif %}
|
||||
{% for mod in request.user.mods_enabled %}
|
||||
{% if mod == 'personal wiki' %}
|
||||
<li class="tab"><a href="{% url 'personal_wiki' %}"><span class="sf2-icon-wiki"></span>{% trans "Personal Wiki" %}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<li class="tab"><a href="{% url 'devices' %}"><span class="sf2-icon-monitor"></span>{% trans "Devices" %}</a></li>
|
||||
</ul>
|
||||
|
||||
<h3 class="hd">{% trans "Share Admin" %}</h3>
|
||||
@@ -579,6 +605,7 @@
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}share/links/"><span class="sf2-icon-link"></span>{% trans "Links" %}</a></li>
|
||||
</ul>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="myhome-mods-enable-form-tmpl">
|
||||
<form id="myhome-mods-enable-form" method="post" action="" class="hide">{% csrf_token%}
|
||||
<h3>{% trans "Enable Modules"%}</h3>
|
||||
@@ -601,38 +628,6 @@
|
||||
<input type="submit" value="{% trans "Submit"%}" class="submit" />
|
||||
</form>
|
||||
</script>
|
||||
<script type="text/template" id="group-side-nav-tmpl">
|
||||
<div class="hd w100 ovhd">
|
||||
<h3 class="fleft">
|
||||
<%= avatar %> <span title="<%- name %>" class="grp-name ellipsis vam"><%- name %></span>
|
||||
</h3>
|
||||
<% if (is_staff) { %>
|
||||
<span id="enable-mods" class="sf2-icon-cog2 op-icon fright" title="{% trans "Enable Modules" %}" style="margin:6px 0 0 5px;"></span>
|
||||
<% } %>
|
||||
<% if (is_pub) { %>
|
||||
<img src="{{MEDIA_URL}}img/grp_public.png" alt="" title="{% trans "This group is public." %}" class="fright" style="margin:8px 0 0 5px;" />
|
||||
<% } %>
|
||||
</div>
|
||||
<ul class="side-tabnav-tabs">
|
||||
<li class="tab tab-cur"><a href="#group/<%= id %>/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a></li>
|
||||
|
||||
<% if (!is_pub) { %>
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/discuss/"><span class="sf2-icon-msgs"></span>{% trans "Discussion" %}</a></li>
|
||||
<% } %>
|
||||
|
||||
<% for (var i = 0, len = mods_enabled.length; i < len; i++) { %>
|
||||
<% if (mods_enabled[i] == 'group wiki') { %>
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/wiki/"><span class="sf2-icon-wiki"></span>{% trans "Wiki" %}</a></li>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/members/"><span class="sf2-icon-user"></span>{% trans "Members" %}</a></li>
|
||||
|
||||
<% if (is_staff) { %>
|
||||
<li class="tab"><a href="{{ SITE_ROOT }}group/<%= id %>/manage/"><span class="sf2-icon-wrench"></span>{% trans "Admin" %}</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</script>
|
||||
<script type="text/template" id="group-mods-enable-form-tmpl">
|
||||
<form id="mods-enable-form" method="post" action="" class="hide">{% csrf_token%}
|
||||
<h3>{% trans "Enable Modules"%}</h3>
|
||||
|
@@ -11,17 +11,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block left_panel %}
|
||||
<div class="side-tabnav hide" id="myhome-side-nav">
|
||||
</div>
|
||||
<div class="side-tabnav hide" id="group-side-nav">
|
||||
</div>
|
||||
<div class="side-tabnav hide" id="org-side-nav">
|
||||
<h3 class="hd">{% trans "Organization" %}</h3>
|
||||
<ul class="side-tabnav-tabs">
|
||||
<li class="tab tab-cur"><a href="{{ SITE_ROOT }}#org/"><span class="sf2-icon-library"></span>{% trans "Libraries" %}</a></li>
|
||||
<li class="tab"><a href="{% url 'pubuser' %}"><span class="sf2-icon-user"></span>{% trans "Members" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="info-item hide" id="groups-side-tips">
|
||||
<h3 class="info-item-top">{% trans "Tips" %}</h3>
|
||||
<div class="info-item-bottom">
|
||||
@@ -32,6 +21,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="side-tabnav hide" id="side-nav"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block right_panel %}
|
||||
@@ -255,17 +245,6 @@ app["pageOptions"] = {
|
||||
{% endfor %}
|
||||
return groups;
|
||||
})(),
|
||||
top_nav_groups: (function () {
|
||||
var groups = [];
|
||||
{% for group in grps %}
|
||||
groups.push({
|
||||
'name': '{{group.group_name}}',
|
||||
'id': '{{group.id}}',
|
||||
'avatar': '{% grp_avatar group.id 36 %}'
|
||||
});
|
||||
{% endfor %}
|
||||
return groups;
|
||||
})(),
|
||||
user_mods_available: (function () {
|
||||
var mods_available = [];
|
||||
{% for mod in request.user.mods_available %}
|
||||
|
@@ -3,14 +3,14 @@ define([
|
||||
'jquery',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/views/side-nav',
|
||||
'app/views/myhome',
|
||||
'app/views/groups',
|
||||
'app/views/group',
|
||||
'app/views/organization',
|
||||
'app/views/dir',
|
||||
'app/views/top-group-nav'
|
||||
], function($, Backbone, Common, MyHomeView, GroupsView, GroupView, OrgView,
|
||||
DirView, GroupNavView) {
|
||||
'app/views/dir'
|
||||
], function($, Backbone, Common, SideNavView, MyHomeView, GroupsView, GroupView,
|
||||
OrgView, DirView) {
|
||||
"use strict";
|
||||
|
||||
var Router = Backbone.Router.extend({
|
||||
@@ -39,6 +39,8 @@ define([
|
||||
Common.initAccountPopup();
|
||||
Common.initNoticePopup();
|
||||
|
||||
this.sideNavView = new SideNavView();
|
||||
|
||||
this.dirView = new DirView();
|
||||
|
||||
this.myHomeView = new MyHomeView({dirView: this.dirView});
|
||||
@@ -49,10 +51,6 @@ define([
|
||||
|
||||
this.currentView = this.myHomeView;
|
||||
|
||||
if (app.pageOptions.top_nav_groups.length > 0) {
|
||||
this.topGroupNavView = new GroupNavView();
|
||||
}
|
||||
|
||||
$('#info-bar .close').click(Common.closeTopNoticeBar);
|
||||
$('#top-browser-tip .close').click(function () {
|
||||
$('#top-browser-tip').addClass('hide');
|
||||
@@ -72,12 +70,14 @@ define([
|
||||
this.myHomeView.showMyRepos();
|
||||
} else {
|
||||
this.myHomeView.showSharedRepos();
|
||||
this.sideNavView.setCurTab('shared');
|
||||
}
|
||||
},
|
||||
|
||||
showMyRepos: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showMyRepos();
|
||||
this.sideNavView.setCurTab('mine');
|
||||
},
|
||||
|
||||
showMySubRepos: function() {
|
||||
@@ -88,16 +88,19 @@ define([
|
||||
showSharedRepos: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showSharedRepos();
|
||||
this.sideNavView.setCurTab('shared');
|
||||
},
|
||||
|
||||
showStarredFile: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showStarredFile();
|
||||
this.sideNavView.setCurTab('starred');
|
||||
},
|
||||
|
||||
showActivities: function() {
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showActivities();
|
||||
this.sideNavView.setCurTab('activities');
|
||||
},
|
||||
|
||||
showMyRepoDir: function(repo_id, path) {
|
||||
@@ -108,6 +111,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('my-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('mine');
|
||||
},
|
||||
|
||||
showCommonDir: function(repo_id, path) {
|
||||
@@ -128,6 +132,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('my-sub-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('sub-libs');
|
||||
},
|
||||
|
||||
showSharedRepoDir: function(repo_id, path) {
|
||||
@@ -138,6 +143,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.myHomeView);
|
||||
this.myHomeView.showDir('shared-libs', repo_id, path);
|
||||
this.sideNavView.setCurTab('shared');
|
||||
},
|
||||
|
||||
showGroups: function () {
|
||||
@@ -148,6 +154,7 @@ define([
|
||||
showGroupRepos: function(group_id) {
|
||||
this.switchCurrentView(this.groupView);
|
||||
this.groupView.showRepoList(group_id);
|
||||
this.sideNavView.setCurTab('group', {'cur_group_id': group_id});
|
||||
},
|
||||
|
||||
showGroupRepoDir: function(group_id, repo_id, path) {
|
||||
@@ -158,11 +165,13 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.groupView);
|
||||
this.groupView.showDir(group_id, repo_id, path);
|
||||
this.sideNavView.setCurTab('group', {'cur_group_id': group_id});
|
||||
},
|
||||
|
||||
showOrgRepos: function() {
|
||||
this.switchCurrentView(this.orgView);
|
||||
this.orgView.showRepoList();
|
||||
this.sideNavView.setCurTab('org');
|
||||
},
|
||||
|
||||
showOrgRepoDir: function(repo_id, path) {
|
||||
@@ -173,6 +182,7 @@ define([
|
||||
}
|
||||
this.switchCurrentView(this.orgView);
|
||||
this.orgView.showDir(repo_id, path);
|
||||
this.sideNavView.setCurTab('org');
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -1,96 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var GroupSideNavView = Backbone.View.extend({
|
||||
el: '#group-side-nav',
|
||||
|
||||
template: _.template($("#group-side-nav-tmpl").html()),
|
||||
enableModTemplate: _.template($("#group-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({
|
||||
'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');
|
||||
});
|
||||
var checkbox = $('[name="group_wiki"]');
|
||||
var original_checked = checkbox.prop('checked');
|
||||
var _this = this;
|
||||
form.submit(function() {
|
||||
var cur_checked = checkbox.prop('checked');
|
||||
if (cur_checked == original_checked) {
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
post_url: Common.getUrl({
|
||||
'name': 'toggle_group_modules',
|
||||
'group_id': _this.group_id
|
||||
}),
|
||||
post_data: {'group_wiki': cur_checked },
|
||||
after_op_success: function () {
|
||||
$.modal.close();
|
||||
_this.render(_this.group_id);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this.$el.show();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return GroupSideNavView;
|
||||
});
|
@@ -5,10 +5,9 @@ define([
|
||||
'common',
|
||||
'app/collections/group-repos',
|
||||
'app/views/group-repo',
|
||||
'app/views/add-group-repo',
|
||||
'app/views/group-side-nav'
|
||||
'app/views/add-group-repo'
|
||||
], function($, _, Backbone, Common, GroupRepos, GroupRepoView,
|
||||
AddGroupRepoView, GroupSideNavView) {
|
||||
AddGroupRepoView) {
|
||||
'use strict';
|
||||
|
||||
var GroupView = Backbone.View.extend({
|
||||
@@ -30,8 +29,6 @@ define([
|
||||
this.$loadingTip = this.$('.loading-tip');
|
||||
this.$emptyTip = this.$('.empty-tips');
|
||||
|
||||
this.sideNavView = new GroupSideNavView();
|
||||
|
||||
this.repos = new GroupRepos();
|
||||
this.listenTo(this.repos, 'add', this.addOne);
|
||||
this.listenTo(this.repos, 'reset', this.reset);
|
||||
@@ -71,19 +68,8 @@ define([
|
||||
}
|
||||
},
|
||||
|
||||
showSideNav: function () {
|
||||
var sideNavView = this.sideNavView;
|
||||
if (sideNavView.group_id && sideNavView.group_id == this.group_id) {
|
||||
sideNavView.show();
|
||||
return;
|
||||
}
|
||||
sideNavView.render(this.group_id);
|
||||
sideNavView.show();
|
||||
},
|
||||
|
||||
showRepoList: function(group_id) {
|
||||
this.group_id = group_id;
|
||||
this.showSideNav();
|
||||
this.dirView.hide();
|
||||
this.$emptyTip.hide();
|
||||
this.$tabs.show();
|
||||
@@ -122,7 +108,6 @@ define([
|
||||
|
||||
showDir: function(group_id, repo_id, path) {
|
||||
this.group_id = group_id;
|
||||
this.showSideNav();
|
||||
this.hideRepoList();
|
||||
this.dirView.showDir('group/' + this.group_id, repo_id, path);
|
||||
},
|
||||
@@ -169,7 +154,6 @@ define([
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.sideNavView.hide();
|
||||
this.hideRepoList();
|
||||
this.dirView.hide();
|
||||
this.$emptyTip.hide();
|
||||
|
@@ -1,100 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var MyhomeSideNavView = Backbone.View.extend({
|
||||
el: '#myhome-side-nav',
|
||||
|
||||
template: _.template($("#myhome-side-nav-tmpl").html()),
|
||||
enableModTemplate: _.template($("#myhome-mods-enable-form-tmpl").html()),
|
||||
|
||||
initialize: function() {
|
||||
this.default_cur_tab = 'libs';
|
||||
this.data = {
|
||||
'cur_tab': this.default_cur_tab,
|
||||
'mods_enabled': app.pageOptions.user_mods_enabled,
|
||||
'can_add_repo': app.pageOptions.can_add_repo,
|
||||
'events_enabled': app.pageOptions.events_enabled
|
||||
};
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.data));
|
||||
return this;
|
||||
},
|
||||
|
||||
events: {
|
||||
'click #myhome-enable-mods': 'enableMods'
|
||||
},
|
||||
|
||||
enableMods: function () {
|
||||
var mods_enabled = app.pageOptions.user_mods_enabled;
|
||||
var form = $(this.enableModTemplate({
|
||||
'mods_available': app.pageOptions.user_mods_available,
|
||||
'mods_enabled': mods_enabled
|
||||
}));
|
||||
form.modal();
|
||||
$('#simplemodal-container').css('height', 'auto');
|
||||
|
||||
$('.checkbox-orig', form).click(function() {
|
||||
$(this).parent().toggleClass('checkbox-checked');
|
||||
});
|
||||
|
||||
var checkbox = $('[name="personal_wiki"]'),
|
||||
original_checked = checkbox.prop('checked'),
|
||||
_this = this;
|
||||
form.submit(function() {
|
||||
var cur_checked = checkbox.prop('checked');
|
||||
if (cur_checked == original_checked) {
|
||||
return false;
|
||||
}
|
||||
Common.ajaxPost({
|
||||
form: form,
|
||||
form_id: form.attr('id'),
|
||||
post_url: Common.getUrl({
|
||||
'name': 'toggle_personal_modules'
|
||||
}),
|
||||
post_data: {'personal_wiki': cur_checked },
|
||||
after_op_success: function () {
|
||||
if (cur_checked) {
|
||||
mods_enabled.push('personal wiki');
|
||||
} else {
|
||||
var index = mods_enabled.indexOf('personal wiki');
|
||||
if (index > -1) {
|
||||
mods_enabled.splice(index, 1); // rm the item
|
||||
}
|
||||
}
|
||||
$.modal.close();
|
||||
_this.render();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
show: function(options) {
|
||||
if (options && options.cur_tab) {
|
||||
this.data.cur_tab = options.cur_tab;
|
||||
this.render();
|
||||
} else {
|
||||
if (this.data.cur_tab != this.default_cur_tab) {
|
||||
this.data.cur_tab = this.default_cur_tab;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
this.$el.show();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$el.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return MyhomeSideNavView;
|
||||
});
|
@@ -7,17 +7,15 @@ define([
|
||||
'app/views/myhome-sub-repos',
|
||||
'app/views/myhome-shared-repos',
|
||||
'app/views/starred-file',
|
||||
'app/views/activities',
|
||||
'app/views/myhome-side-nav'
|
||||
'app/views/activities'
|
||||
], function($, _, Backbone, Common, ReposView, SubReposView,
|
||||
SharedReposView, StarredFileView, ActivitiesView, MyhomeSideNavView) {
|
||||
SharedReposView, StarredFileView, ActivitiesView) {
|
||||
'use strict';
|
||||
|
||||
var MyHomeView = Backbone.View.extend({
|
||||
el: '#main',
|
||||
|
||||
initialize: function(options) {
|
||||
this.sideNavView = new MyhomeSideNavView();
|
||||
this.reposView = new ReposView();
|
||||
this.subReposView = new SubReposView();
|
||||
this.sharedReposView = new SharedReposView();
|
||||
@@ -32,42 +30,36 @@ define([
|
||||
},
|
||||
|
||||
showMyRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.reposView.show();
|
||||
this.currentView = this.reposView;
|
||||
},
|
||||
|
||||
showMySubRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.subReposView.show();
|
||||
this.currentView = this.subReposView;
|
||||
},
|
||||
|
||||
showSharedRepos: function() {
|
||||
this.sideNavView.show();
|
||||
this.currentView.hide();
|
||||
this.sharedReposView.show();
|
||||
this.currentView = this.sharedReposView;
|
||||
},
|
||||
|
||||
showStarredFile: function() {
|
||||
this.sideNavView.show({'cur_tab': 'starred'});
|
||||
this.currentView.hide();
|
||||
this.starredFileView.show();
|
||||
this.currentView = this.starredFileView;
|
||||
},
|
||||
|
||||
showActivities: function() {
|
||||
this.sideNavView.show({'cur_tab': 'activities'});
|
||||
this.currentView.hide();
|
||||
this.activitiesView.show();
|
||||
this.currentView = this.activitiesView;
|
||||
},
|
||||
|
||||
showDir: function(category, repo_id, path) {
|
||||
this.sideNavView.show();
|
||||
var path = path || '/';
|
||||
this.currentView.hide();
|
||||
this.dirView.showDir(category, repo_id, path);
|
||||
@@ -76,7 +68,6 @@ define([
|
||||
|
||||
hide: function() {
|
||||
this.currentView.hide();
|
||||
this.sideNavView.hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
@@ -18,7 +18,6 @@ define([
|
||||
|
||||
initialize: function(options) {
|
||||
|
||||
this.$sideNav = $('#org-side-nav');
|
||||
this.$reposDiv = $('#organization-repos');
|
||||
this.$table = $('#organization-repos table');
|
||||
this.$tableHead = $('thead', this.$table);
|
||||
@@ -99,7 +98,6 @@ define([
|
||||
},
|
||||
|
||||
showRepoList: function() {
|
||||
this.$sideNav.show();
|
||||
this.dirView.hide();
|
||||
this.$reposDiv.show();
|
||||
var $loadingTip = this.$loadingTip;
|
||||
@@ -133,7 +131,6 @@ define([
|
||||
},
|
||||
|
||||
showDir: function(repo_id, path) {
|
||||
this.$sideNav.show();
|
||||
var path = path || '/';
|
||||
this.hideRepoList();
|
||||
this.dirView.showDir('org', repo_id, path);
|
||||
@@ -177,7 +174,6 @@ define([
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.$sideNav.hide();
|
||||
this.hideRepoList();
|
||||
this.$emptyTip.hide();
|
||||
this.dirView.hide();
|
||||
|
@@ -1,52 +0,0 @@
|
||||
define([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common'
|
||||
], function($, _, Backbone, Common) {
|
||||
'use strict';
|
||||
|
||||
var GroupNavView = Backbone.View.extend({
|
||||
el: '.nav .nav-item-group',
|
||||
|
||||
popupTemplate: _.template($('#top-group-nav-tmpl').html()),
|
||||
|
||||
initialize: function() {
|
||||
var popup = $(this.popupTemplate({groups: app.pageOptions.top_nav_groups}));
|
||||
this.$el.append(popup);
|
||||
popup.css({'right': ($('#top-nav-grp').outerWidth() - popup.outerWidth())/6 * 5});
|
||||
this.popup = popup;
|
||||
},
|
||||
|
||||
events: {
|
||||
'mouseenter': 'showPopup',
|
||||
'mouseleave': 'hidePopup',
|
||||
'mouseenter #top-nav-grp-list .item': 'highlightGroupItem',
|
||||
'mouseleave #top-nav-grp-list .item': 'rmHighlightGroupItem',
|
||||
'click #top-nav-grp-list .item': 'visitGroup'
|
||||
},
|
||||
|
||||
showPopup: function(e) {
|
||||
this.popup.removeClass('hide');
|
||||
},
|
||||
|
||||
hidePopup: function(e) {
|
||||
this.popup.addClass('hide');
|
||||
},
|
||||
|
||||
highlightGroupItem: function(e) {
|
||||
$(e.currentTarget).addClass('hl').children('a').removeClass('vh');
|
||||
},
|
||||
|
||||
rmHighlightGroupItem: function(e) {
|
||||
$(e.currentTarget).removeClass('hl').children('a').addClass('vh');
|
||||
},
|
||||
|
||||
visitGroup: function(e) {
|
||||
this.hidePopup(e);
|
||||
location.href = $(e.currentTarget).attr('data-url');
|
||||
}
|
||||
});
|
||||
|
||||
return GroupNavView;
|
||||
});
|
Reference in New Issue
Block a user