Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll the share menu into sight when it's hidden outside the viewport #15817

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions core/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,32 @@ OC.Share={
dropDownEl.attr('data-item-source-name', filename);
$('#dropdown').slideDown(OC.menuSpeed, function() {
OC.Share.droppedDown = true;
OC.Share._scrollIntoView();
});
if ($('html').hasClass('lte9')){
$('#dropdown input[placeholder]').placeholder();
}
$('#shareWith').focus();
},

_scrollIntoView: function () {
var dropDownEl = $('#dropdown');
var dropDownElTopLocation = dropDownEl.offset().top;
var dropDownElHeight = dropDownEl.outerHeight();
var dropDownElBottomLocation = dropDownElTopLocation + dropDownElHeight + 50;
var windowHeight = $(window).height();

if (dropDownElBottomLocation > windowHeight) {
var scrollContainer = $('#app-content');
var currentPosition = scrollContainer[0].scrollTop;
var scrollDistance = dropDownElBottomLocation - windowHeight;
scrollContainer.stop();
scrollContainer.animate({
scrollTop: currentPosition + scrollDistance
}, 700);
}
},

hideDropDown:function(callback) {
OC.Share.currentShares = null;
$('#dropdown').slideUp(OC.menuSpeed, function() {
Expand Down Expand Up @@ -735,6 +755,8 @@ OC.Share={
}
OC.Share.currentShares[shareType].push(shareItem);
}

OC.Share._scrollIntoView();
},
showLink:function(token, password, itemSource) {
OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true;
Expand Down Expand Up @@ -772,14 +794,15 @@ OC.Share={
}
}
$('#linkText').val(link);
$('#linkText').slideDown(OC.menuSpeed);
$('#linkText').slideDown(OC.menuSpeed, OC.Share._scrollIntoView);
$('#linkText').css('display','block');
if (oc_appconfig.core.enforcePasswordForPublicLink === false || password === null) {
$('#showPassword').show();
$('#showPassword+label').show();
OC.Share._scrollIntoView();
}
if (password != null) {
$('#linkPass').slideDown(OC.menuSpeed);
$('#linkPass').slideDown(OC.menuSpeed, OC.Share._scrollIntoView);
$('#showPassword').attr('checked', true);
$('#linkPassText').attr('placeholder', '**********');
}
Expand Down Expand Up @@ -824,7 +847,7 @@ OC.Share={
}
$('#expirationCheckbox').attr('checked', true);
$('#expirationDate').val(date);
$('#expirationDate').slideDown(OC.menuSpeed);
$('#expirationDate').slideDown(OC.menuSpeed, OC.Share._scrollIntoView);
$('#expirationDate').css('display','block');
$('#expirationDate').datepicker({
dateFormat : 'dd-mm-yy'
Expand All @@ -836,7 +859,7 @@ OC.Share={
datePickerOptions.maxDate = new Date(shareTime + oc_appconfig.core.defaultExpireDate * 24 * 3600 * 1000);
}
if(oc_appconfig.core.defaultExpireDateEnabled) {
$('#defaultExpireMessage').slideDown(OC.menuSpeed);
$('#defaultExpireMessage').slideDown(OC.menuSpeed, OC.Share._scrollIntoView);
}
$.datepicker.setDefaults(datePickerOptions);
}
Expand Down Expand Up @@ -1011,7 +1034,7 @@ $(document).ready(function() {
OC.Share.updateIcon(itemType, itemSource);
});
} else {
$('#linkPass').slideToggle(OC.menuSpeed);
$('#linkPass').slideToggle(OC.menuSpeed, OC.Share._scrollIntoView);
// TODO drop with IE8 drop
if($('html').hasClass('ie8')) {
$('#linkPassText').attr('placeholder', null);
Expand Down Expand Up @@ -1091,7 +1114,7 @@ $(document).ready(function() {
});

$(document).on('click', '#dropdown #showPassword', function() {
$('#linkPass').slideToggle(OC.menuSpeed);
$('#linkPass').slideToggle(OC.menuSpeed, OC.Share._scrollIntoView);
if (!$('#showPassword').is(':checked') ) {
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
Expand Down Expand Up @@ -1162,7 +1185,7 @@ $(document).ready(function() {
}
$('#expirationDate').slideUp(OC.menuSpeed);
if (oc_appconfig.core.defaultExpireDateEnforced === false) {
$('#defaultExpireMessage').slideDown(OC.menuSpeed);
$('#defaultExpireMessage').slideDown(OC.menuSpeed, OC.Share._scrollIntoView);
}
});
}
Expand Down