mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 23:48:47 +00:00
use dropdown for publib create button
This commit is contained in:
@@ -1229,9 +1229,9 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
}
|
}
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
position:absolute;
|
position:absolute;
|
||||||
left:0px;
|
|
||||||
background:#fff;
|
background:#fff;
|
||||||
padding:6px 1px;
|
padding:6px 1px;
|
||||||
|
margin:2px 0 0;
|
||||||
border:1px solid rgba(34,36,38,.15);
|
border:1px solid rgba(34,36,38,.15);
|
||||||
border-radius:3px;
|
border-radius:3px;
|
||||||
box-shadow:0 2px 3px 0 rgba(34,36,38,.15);
|
box-shadow:0 2px 3px 0 rgba(34,36,38,.15);
|
||||||
@@ -1415,9 +1415,6 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
background:#fff;
|
background:#fff;
|
||||||
line-height:17px;
|
line-height:17px;
|
||||||
}
|
}
|
||||||
#add-pub-lib {
|
|
||||||
outline:none;
|
|
||||||
}
|
|
||||||
/* info-bar */
|
/* info-bar */
|
||||||
#info-bar {
|
#info-bar {
|
||||||
color: #1f0600;
|
color: #1f0600;
|
||||||
@@ -3534,6 +3531,5 @@ img.thumbnail {
|
|||||||
}
|
}
|
||||||
/* devices */
|
/* devices */
|
||||||
.device-libs-dropdown-menu {
|
.device-libs-dropdown-menu {
|
||||||
left:-60px;
|
|
||||||
min-width:200px;
|
min-width:200px;
|
||||||
}
|
}
|
||||||
|
@@ -182,12 +182,14 @@
|
|||||||
<div class="hd">
|
<div class="hd">
|
||||||
<h3 class="fleft">{% trans "Organization" %}</h3>
|
<h3 class="fleft">{% trans "Organization" %}</h3>
|
||||||
{% if can_add_pub_repo %}
|
{% if can_add_pub_repo %}
|
||||||
<button id="add-pub-lib" class="fright "><span class="icon-plus-square add vam"></span><span class="vam">{% trans "Add Library"%}</span></button>
|
<div class="fright dropdown js-dropdown js-add-pub-lib-dropdown">
|
||||||
|
<button class="js-dropdown-toggle"><span class="icon-plus-square add vam"></span><span class="vam">{% trans "Add Library"%}</span></button>
|
||||||
|
<ul class="add-pub-lib-dropdown-menu dropdown-menu js-dropdown-content hide">
|
||||||
|
<li><a class="op js-repo-rename share-existing" href="#">{% trans "Share existing libraries" %}</a></li>
|
||||||
|
<li><a class="op js-repo-rename create-new" href="#">{% trans "Create a new library" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<ul id="add-pub-lib-menu" class="hide">
|
|
||||||
<li class="item share-existing">{% trans "Share existing libraries" %}</li>
|
|
||||||
<li class="item create-new">{% trans "Create a new library" %}</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="repo-list hide">
|
<table class="repo-list hide">
|
||||||
|
@@ -42,7 +42,8 @@ define([
|
|||||||
this.$el.html(this.template(data));
|
this.$el.html(this.template(data));
|
||||||
|
|
||||||
new DropdownView({
|
new DropdownView({
|
||||||
el: this.$('.js-dropdown')
|
el: this.$('.js-dropdown'),
|
||||||
|
left: '-60px'
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@@ -6,9 +6,10 @@ define([
|
|||||||
'app/collections/pub-repos',
|
'app/collections/pub-repos',
|
||||||
'app/views/organization-repo',
|
'app/views/organization-repo',
|
||||||
'app/views/create-pub-repo',
|
'app/views/create-pub-repo',
|
||||||
'app/views/add-pub-repo'
|
'app/views/add-pub-repo',
|
||||||
|
'app/views/widgets/dropdown'
|
||||||
], function($, _, Backbone, Common, PubRepoCollection, OrganizationRepoView,
|
], function($, _, Backbone, Common, PubRepoCollection, OrganizationRepoView,
|
||||||
CreatePubRepoView, AddPubRepoView) {
|
CreatePubRepoView, AddPubRepoView, DropdownView) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var OrganizationView = Backbone.View.extend({
|
var OrganizationView = Backbone.View.extend({
|
||||||
@@ -29,26 +30,9 @@ define([
|
|||||||
|
|
||||||
this.dirView = options.dirView;
|
this.dirView = options.dirView;
|
||||||
|
|
||||||
// show/hide 'add lib' menu
|
this.dropdown = new DropdownView({
|
||||||
var $add_lib = $('#add-pub-lib'),
|
el: this.$('.js-add-pub-lib-dropdown'),
|
||||||
$add_lib_menu = $('#add-pub-lib-menu');
|
right: '0px'
|
||||||
$add_lib.click(function() {
|
|
||||||
$add_lib_menu.toggleClass('hide');
|
|
||||||
$add_lib_menu.css({
|
|
||||||
'top': $add_lib.position().top + $add_lib.outerHeight(),
|
|
||||||
'right': 10 // align right with $add_lib
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('.item', $add_lib_menu).hover(
|
|
||||||
function() {
|
|
||||||
$(this).css({'background':'#f3f3f3'});
|
|
||||||
},
|
|
||||||
function() {
|
|
||||||
$(this).css({'background':'transparent'});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$(document).click(function(e) {
|
|
||||||
Common.closePopup(e, $add_lib_menu, $add_lib);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -61,10 +45,14 @@ define([
|
|||||||
|
|
||||||
createRepo: function() {
|
createRepo: function() {
|
||||||
new CreatePubRepoView(this.repos);
|
new CreatePubRepoView(this.repos);
|
||||||
|
this.dropdown.hide();
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
addRepo: function() {
|
addRepo: function() {
|
||||||
new AddPubRepoView(this.repos);
|
new AddPubRepoView(this.repos);
|
||||||
|
this.dropdown.hide();
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
addOne: function(repo, collection, options) {
|
addOne: function(repo, collection, options) {
|
||||||
|
@@ -35,8 +35,14 @@ define([
|
|||||||
toggleClass: '.js-dropdown-toggle',
|
toggleClass: '.js-dropdown-toggle',
|
||||||
popupClass: '.js-dropdown-content',
|
popupClass: '.js-dropdown-content',
|
||||||
|
|
||||||
|
defaultOptions: {
|
||||||
|
'left': '0px'
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.$el.on('click', '.js-dropdown-toggle', _.bind(this.toggleDropdown, this));
|
this.$el.on('click', '.js-dropdown-toggle', _.bind(this.toggleDropdown, this));
|
||||||
|
this.options = {};
|
||||||
|
_.extend(this.options, this.defaultOptions, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
hide: function() {
|
hide: function() {
|
||||||
@@ -45,7 +51,13 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
|
var $menu = this.$('.js-dropdown-content');
|
||||||
app.ui.currentDropdown = this;
|
app.ui.currentDropdown = this;
|
||||||
|
if (this.options.right) {
|
||||||
|
$menu.css('right', this.options.right);
|
||||||
|
} else {
|
||||||
|
$menu.css('left', this.options.left);
|
||||||
|
}
|
||||||
this.$('.js-dropdown-content').removeClass('hide');
|
this.$('.js-dropdown-content').removeClass('hide');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user