Skip to content
Snippets Groups Projects
Commit 9ae7e99a authored by Fatih Acet's avatar Fatih Acet
Browse files

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

parent 0f345935
No related branches found
No related tags found
No related merge requests found
Loading
@@ -128,18 +128,17 @@
Loading
@@ -128,18 +128,17 @@
return e.metaKey || e.ctrlKey || e.altKey || e.shiftKey; return e.metaKey || e.ctrlKey || e.altKey || e.shiftKey;
}; };
   
})(window); 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: top - (gl.navBarHeight + gl.navLinksHieght + gl.mrTabsHeight)
}, 200);
};
   
gl.utils.isElementVisibleInViewport = function(el) { })(window);
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) {
return $('body, html').animate({
scrollTop: $el.offset().top - 110
}, 200);
};
   
}).call(this); }).call(this);
Loading
@@ -498,10 +498,9 @@
Loading
@@ -498,10 +498,9 @@
} }
else { else {
var $buttons = $el.find('.note-form-actions'); var $buttons = $el.find('.note-form-actions');
var isButtonsVisible = gl.utils.isElementVisibleInViewport($buttons[0]); var isWidgetVisible = gl.utils.isInViewport($el[0]);
var isWidgetVisible = gl.utils.isElementVisibleInViewport($el[0]);
   
if (!isButtonsVisible || !isWidgetVisible) { if (!isWidgetVisible) {
gl.utils.animateToElement($el); gl.utils.animateToElement($el);
} }
   
Loading
@@ -536,7 +535,7 @@
Loading
@@ -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'); $editForm.addClass('current-note-edit-form');
$note.addClass('is-editting'); $note.addClass('is-editting');
this.putEditFormInPlace($target); this.putEditFormInPlace($target);
Loading
@@ -580,11 +579,11 @@
Loading
@@ -580,11 +579,11 @@
}; };
   
Notes.prototype.removeNoteEditForm = function(note) { Notes.prototype.removeNoteEditForm = function(note) {
var form = note.find(".current-note-edit-form"); var form = note.find('.current-note-edit-form');
note.removeClass("is-editting"); note.removeClass('is-editting');
form.removeClass("current-note-edit-form"); form.removeClass('current-note-edit-form');
// Replace markdown textarea text with original note text. // 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'));
}; };
   
   
Loading
@@ -885,7 +884,6 @@
Loading
@@ -885,7 +884,6 @@
}; };
   
Notes.prototype.putEditFormInPlace = function($el) { Notes.prototype.putEditFormInPlace = function($el) {
var $editForm = $(this.getEditFormSelector($el)); var $editForm = $(this.getEditFormSelector($el));
var $note = $el.closest('.note'); var $note = $el.closest('.note');
   
Loading
Loading
Loading
@@ -585,3 +585,17 @@ ul.notes {
Loading
@@ -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;
}
}
Loading
@@ -67,7 +67,7 @@
Loading
@@ -67,7 +67,7 @@
return $('.notes-form .js-zen-enter').click(); return $('.notes-form .js-zen-enter').click();
}; };
   
exitZen = function() { // Ohmmmmmmm exitZen = function() {
return $('.notes-form .js-zen-leave').click(); return $('.notes-form .js-zen-leave').click();
}; };
   
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment