Commit 9ae7e99a authored by Fatih Acet's avatar Fatih Acet

Use gl.utils.isInViewport and improve gl.utils.animateToElement.

parent 0f345935
......@@ -128,18 +128,17 @@
return e.metaKey || e.ctrlKey || e.altKey || e.shiftKey;
};
})(window);
gl.utils.isElementVisibleInViewport = function(el) {
var rect = el.getBoundingClientRect();
var height = Math.max(document.documentElement.clientHeight, window.innerHeight);
return !(rect.bottom - 110 < 0 || rect.top - height >= 0); // -110 for sticky GitLab navigation header
};
gl.utils.animateToElement = function($el) {
var top = $el.offset().top;
gl.navBarHeight = gl.navBarHeight || $('.navbar-gitlab').height();
gl.navLinksHieght = gl.navLinksHieght || $('.nav-links').height();
gl.mrTabsHeight = gl.mrTabsHeight || $('.merge-request-tabs').height();
return $('body, html').animate({
scrollTop: $el.offset().top - 110
scrollTop: top - (gl.navBarHeight + gl.navLinksHieght + gl.mrTabsHeight)
}, 200);
};
})(window);
}).call(this);
......@@ -498,10 +498,9 @@
}
else {
var $buttons = $el.find('.note-form-actions');
var isButtonsVisible = gl.utils.isElementVisibleInViewport($buttons[0]);
var isWidgetVisible = gl.utils.isElementVisibleInViewport($el[0]);
var isWidgetVisible = gl.utils.isInViewport($el[0]);
if (!isButtonsVisible || !isWidgetVisible) {
if (!isWidgetVisible) {
gl.utils.animateToElement($el);
}
......@@ -536,7 +535,7 @@
}
}
$note.find('.js-note-attachment-delete').show(); // Show the attachment delete link
$note.find('.js-note-attachment-delete').show();
$editForm.addClass('current-note-edit-form');
$note.addClass('is-editting');
this.putEditFormInPlace($target);
......@@ -580,11 +579,11 @@
};
Notes.prototype.removeNoteEditForm = function(note) {
var form = note.find(".current-note-edit-form");
note.removeClass("is-editting");
form.removeClass("current-note-edit-form");
var form = note.find('.current-note-edit-form');
note.removeClass('is-editting');
form.removeClass('current-note-edit-form');
// Replace markdown textarea text with original note text.
return form.find(".js-note-text").val(form.find('form.edit-note').data('original-note'));
return form.find('.js-note-text').val(form.find('form.edit-note').data('original-note'));
};
......@@ -885,7 +884,6 @@
};
Notes.prototype.putEditFormInPlace = function($el) {
var $editForm = $(this.getEditFormSelector($el));
var $note = $el.closest('.note');
......
......@@ -585,3 +585,17 @@ ul.notes {
}
}
}
// Merge request notes in diffs
.diff-file {
// Diff is side by side
.notes_content.parallel .note-header .note-headline-light {
display: block;
position: relative;
}
// Diff is inline
.notes_content .note-header .note-headline-light {
display: inline-block;
position: relative;
}
}
......@@ -67,7 +67,7 @@
return $('.notes-form .js-zen-enter').click();
};
exitZen = function() { // Ohmmmmmmm
exitZen = function() {
return $('.notes-form .js-zen-leave').click();
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment