diff --git a/media/css/seahub.css b/media/css/seahub.css
index 975c5d8f35..45cf04f1c3 100644
--- a/media/css/seahub.css
+++ b/media/css/seahub.css
@@ -1183,6 +1183,24 @@ textarea:-moz-placeholder {/* for FF */
.user-item .txt-item {
margin:0;
}
+/**** dropdown menu ******/
+.dropdown-menu {
+ position:absolute;
+ background:#fff;
+ padding:6px 1px;
+ border:1px solid #eee;
+ border-radius:5px;
+ z-index:10;
+}
+.dropdown-menu li a,
+.dropdown-menu a {
+ display:block;
+ padding:4px 12px;
+ width:180px;
+}
+.dropdown-menu a:hover {
+ background:#eee;
+}
/********** container ***********/
#main, #footer {
width:950px;
@@ -1945,25 +1963,25 @@ textarea:-moz-placeholder {/* for FF */
#mv-dir-list .icon-caret-right {
margin-right:15px;
}
-#rename-form .input {
+.inline-rename-form .input {
font-size:14px;
}
.web-setting-form .submit,
-#rename-form .submit {
+.inline-rename-form .submit {
color:green;
}
.web-setting-form .cancel,
-#rename-form .cancel {
+.inline-rename-form .cancel {
color:#666;
}
-#rename-form .input,
-#rename-form .submit {
+.inline-rename-form .input,
+.inline-rename-form .submit {
margin:0;
}
.web-setting-form .submit,
.web-setting-form .cancel,
-#rename-form .submit,
-#rename-form .cancel {
+.inline-rename-form .submit,
+.inline-rename-form .cancel {
font-size:16px;
line-height:1;
}
@@ -2090,7 +2108,7 @@ textarea:-moz-placeholder {/* for FF */
.fixed-upload-file-dialog .op-icon {
font-size:18px;
color: #b8b8b8;
- margin:0;
+ margin:0;
}
.fixed-upload-file-dialog .close,
.fileupload-buttonbar .cancel {
diff --git a/seahub/templates/js/lib-op-popups.html b/seahub/templates/js/lib-op-popups.html
index 5f60854274..81aefb22f5 100644
--- a/seahub/templates/js/lib-op-popups.html
+++ b/seahub/templates/js/lib-op-popups.html
@@ -32,7 +32,7 @@
+
+
diff --git a/seahub/templates/js/templates.html b/seahub/templates/js/templates.html
index d250f5f990..d4441982b3 100644
--- a/seahub/templates/js/templates.html
+++ b/seahub/templates/js/templates.html
@@ -37,14 +37,24 @@
<% } %>
<% if (name) { %>
-
<%- name %> |
+ <%- name %> |
<% } else { %>
{% trans "Broken (please contact your administrator to fix this library)" %} |
<% } %>
-
+ |
+
+
|
<%= size_formatted %> |
@@ -218,7 +228,7 @@
<% if (dirent.perm == 'rw') { %>
-
+
- {% trans "Rename" %}
- {% trans "Move" %}
- {% trans "Copy" %}
@@ -299,7 +309,7 @@
<% if (dirent.perm == 'rw') { %>
-
+
- {% trans "Rename" %}
- {% trans "Move" %}
- {% trans "Copy" %}
@@ -732,7 +742,7 @@
-
+
|
+
+
+
+
+
+
+
diff --git a/seahub/templates/libraries.html b/seahub/templates/libraries.html
index a9a9d9e236..1c5c04623f 100644
--- a/seahub/templates/libraries.html
+++ b/seahub/templates/libraries.html
@@ -21,7 +21,7 @@
{% trans "Mine" %}
-
+
@@ -278,6 +278,7 @@ app["pageOptions"] = {
enable_resumable_fileupload: {% if enable_resumable_fileupload %} true {% else %} false {% endif %},
enable_thumbnail: {% if enable_thumbnail %} true {% else %} false {% endif %},
enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
+ enable_repo_history_setting: {% if enable_repo_history_setting %} true {% else %} false {% endif %},
max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %},
folder_perm_enabled: {% if folder_perm_enabled %} true {% else %} false {% endif %},
is_pro: {% if is_pro %} true {% else %} false {% endif %},
diff --git a/seahub/views/__init__.py b/seahub/views/__init__.py
index 01e1ef1fe0..9114a3fbd8 100644
--- a/seahub/views/__init__.py
+++ b/seahub/views/__init__.py
@@ -1238,6 +1238,7 @@ def libraries(request):
'enable_resumable_fileupload': settings.ENABLE_RESUMABLE_FILEUPLOAD,
'enable_thumbnail': settings.ENABLE_THUMBNAIL,
'enable_encrypted_library': config.ENABLE_ENCRYPTED_LIBRARY,
+ 'enable_repo_history_setting': config.ENABLE_REPO_HISTORY_SETTING,
'max_upload_file_size': max_upload_file_size,
'folder_perm_enabled': folder_perm_enabled,
'is_pro': True if is_pro_version() else False,
diff --git a/static/scripts/app/views/dialogs/history-settings.js b/static/scripts/app/views/dialogs/history-settings.js
new file mode 100644
index 0000000000..7dd331287a
--- /dev/null
+++ b/static/scripts/app/views/dialogs/history-settings.js
@@ -0,0 +1,48 @@
+define([
+ 'jquery',
+ 'underscore',
+ 'backbone',
+ 'common'
+], function($, _, Backbone, Common) {
+ 'use strict';
+
+ var HistorySettingsDialog = Backbone.View.extend({
+ tagName: 'div',
+ id: 'history-settings-dialog',
+ template: _.template($('#history-settings-dialog-tmpl').html()),
+
+ initialize: function(options) {
+ this.repo_name = options.repo_name;
+ this.repo_id = options.repo_id;
+
+ this.render();
+ this.$el.modal();
+ $("#simplemodal-container").css({'height':'auto'});
+ },
+
+ render: function() {
+ this.$el.html(this.template({
+ title: gettext("{placeholder} History Settings")
+ .replace('{placeholder}',
+ ''
+ + Common.HTMLescape(this.repo_name) + ''),
+ repo_id: this.repo_id,
+ // TODO: get settings from server
+ full_history_checked: true,
+ no_history_checked: false,
+ partial_history_checked: false,
+ history_limit: 30
+ }));
+
+ return this;
+ },
+
+ events: {
+
+ }
+
+ });
+
+ return HistorySettingsDialog;
+});
diff --git a/static/scripts/app/views/dir.js b/static/scripts/app/views/dir.js
index ad48aa5e11..d8959d25bf 100644
--- a/static/scripts/app/views/dir.js
+++ b/static/scripts/app/views/dir.js
@@ -73,7 +73,7 @@ define([
// hide 'hidden-op' popup
$(document).click(function(e) {
var target = e.target || event.srcElement;
- var $popup = $('.hidden-op:visible');
+ var $popup = $('.dirent-hidden-op:visible');
if ($popup.length > 0 && // There is a visible popup
!$('.more-op-icon', $popup.closest('tr')).is(target) &&
!$popup.is(target) &&
diff --git a/static/scripts/app/views/dirent.js b/static/scripts/app/views/dirent.js
index 542ba3ad71..c65a56288e 100644
--- a/static/scripts/app/views/dirent.js
+++ b/static/scripts/app/views/dirent.js
@@ -144,7 +144,7 @@ define([
return false;
},
- togglePopup: function () {
+ togglePopup: function() {
var icon = this.$('.more-op-icon'),
popup = this.$('.hidden-op');
diff --git a/static/scripts/app/views/myhome-repos.js b/static/scripts/app/views/myhome-repos.js
index 79ac306216..8876269ba4 100644
--- a/static/scripts/app/views/myhome-repos.js
+++ b/static/scripts/app/views/myhome-repos.js
@@ -31,6 +31,31 @@ define([
this.repos = new RepoCollection();
this.listenTo(this.repos, 'add', this.addOne);
this.listenTo(this.repos, 'reset', this.reset);
+
+ // hide 'hidden-op' popup
+ $(document).click(function(e) {
+ var target = e.target || event.srcElement;
+ var $popup = $('.repo-hidden-op:visible');
+ if ($popup.length > 0 && // There is a visible repo op popup
+ !$('.more-op-icon', $popup.closest('tr')).is(target) &&
+ !$popup.is(target) &&
+ !$popup.find('*').is(target)) {
+ // when the popup and op-icon is not target
+ // hide the popup and remove the highlight if the current repo
+ // is not the target
+ $popup.addClass('hide');
+ var $tr = $popup.closest('tr');
+ if (!$tr.find('*').is(target)) {
+ $tr.removeClass('hl').find('.op-icon').addClass('vh');
+ $('.my-own-repos-table tr:gt(0)').each(function() {
+ if ($(this).find('*').is(target)) {
+ $(this).addClass('hl').find('.op-icon').removeClass('vh');
+ }
+ });
+ }
+ }
+ });
+
},
addOne: function(repo, collection, options) {
diff --git a/static/scripts/app/views/repo.js b/static/scripts/app/views/repo.js
index 2caa2fb4d9..faaeabbf5b 100644
--- a/static/scripts/app/views/repo.js
+++ b/static/scripts/app/views/repo.js
@@ -3,8 +3,9 @@ define([
'underscore',
'backbone',
'common',
- 'app/views/share'
-], function($, _, Backbone, Common, ShareView) {
+ 'app/views/share',
+ 'app/views/dialogs/history-settings'
+], function($, _, Backbone, Common, ShareView, HistorySettingsDialog) {
'use strict';
var RepoView = Backbone.View.extend({
@@ -12,31 +13,44 @@ define([
template: _.template($('#repo-tmpl').html()),
repoDelConfirmTemplate: _.template($('#repo-del-confirm-template').html()),
+ renameTemplate: _.template($("#repo-rename-form-template").html()),
events: {
'mouseenter': 'highlight',
'mouseleave': 'rmHighlight',
'click .repo-delete-btn': 'del',
- 'click .repo-share-btn': 'share'
+ 'click .repo-share-btn': 'share',
+ 'click .js-toggle-popup': 'togglePopup',
+ 'click .js-repo-rename': 'rename',
+ 'click .js-popup-history-settings': 'popupHistorySettings',
+ 'click .js-popup-permission-settings': 'popupPermissionSettings'
},
initialize: function() {
},
render: function() {
- this.$el.html(this.template(this.model.toJSON()));
+ var obj = this.model.toJSON();
+ $.extend(obj, {
+ enable_repo_history_setting: app.pageOptions.enable_repo_history_setting
+ });
+ this.$el.html(this.template(obj));
return this;
},
// disable 'hover' when 'repo-del-confirm' popup is shown
highlight: function() {
- if ($('#my-own-repos .repo-del-confirm').length == 0) {
+ if ($('#my-own-repos .repo-del-confirm').length == 0
+ && !$('.hidden-op:visible').length
+ && !$('#repo-rename-form').length) {
this.$el.addClass('hl').find('.op-icon').removeClass('vh');
}
},
rmHighlight: function() {
- if ($('#my-own-repos .repo-del-confirm').length == 0) {
+ if ($('#my-own-repos .repo-del-confirm').length == 0
+ && !$('.hidden-op:visible').length
+ && !$('#repo-rename-form').length) {
this.$el.removeClass('hl').find('.op-icon').addClass('vh');
}
},
@@ -100,6 +114,78 @@ define([
'obj_name': this.model.get('name')
};
new ShareView(options);
+ },
+
+ togglePopup: function() {
+ var icon = this.$('.js-toggle-popup'),
+ popup = this.$('.hidden-op');
+
+ if (popup.hasClass('hide')) { // the popup is not shown
+ popup.css({'left': icon.position().left});
+ if (icon.offset().top + popup.height() <= $('#main').offset().top + $('#main').height()) {
+ // below the icon
+ popup.css('top', icon.position().top + icon.height() + 3);
+ } else {
+ popup.css('bottom', icon.parent().outerHeight() - icon.position().top + 3);
+ }
+ popup.removeClass('hide');
+ } else {
+ popup.addClass('hide');
+ }
+ },
+
+ rename: function() {
+ var repo_name = this.model.get('name');
+
+ var form = $(this.renameTemplate({
+ repo_name: repo_name
+ }));
+
+
+ var $name_span = this.$('.repo-name-span'),
+ $op_td = this.$('.repo-op-td'),
+ $name_td = $name_span.closest('td');
+ $name_td.attr('colspan', 2).css({
+ 'width': $name_span.width() + $op_td.outerWidth(),
+ 'height': $name_span.height()
+ }).append(form);
+ $op_td.hide();
+ $name_span.hide();
+
+ this.togglePopup();
+
+ var cancelRename = function() {
+ form.remove();
+ $op_td.show();
+ $name_span.show();
+ $name_td.attr('colspan', 1).css({
+ 'width': $name_span.width()
+ });
+ return false; // stop bubbling (to 'doc click to hide .hidden-op')
+ };
+ $('.cancel', form).click(cancelRename);
+
+ return false;
+ },
+
+ popupHistorySettings: function() {
+ var options = {
+ 'repo_name': this.model.get('name'),
+ 'repo_id': this.model.get('id')
+ };
+ this.togglePopup(); // close the popup
+ new HistorySettingsDialog(options);
+ return false;
+ },
+
+ popupPermissionSettings: function() {
+ var options = {
+ 'repo_name': this.model.get('name'),
+ 'repo_id': this.model.get('id')
+ };
+ this.togglePopup(); // close the popup
+ new HistorySettingsDialog(options);
+ return false;
}
});