2016-12-02 18:43:20 -05:00
|
|
|
/* eslint-disable no-new, class-methods-use-this */
|
2016-12-01 14:09:45 -05:00
|
|
|
/* global Breakpoints */
|
|
|
|
/* global Flash */
|
2016-10-27 16:32:30 -04:00
|
|
|
|
2017-03-11 01:45:34 -05:00
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
|
2017-03-22 22:39:09 -04:00
|
|
|
import CommitPipelinesTable from './commit/pipelines/pipelines_table';
|
|
|
|
|
|
|
|
import './breakpoints';
|
|
|
|
import './flash';
|
2016-10-27 16:32:30 -04:00
|
|
|
|
|
|
|
/* eslint-disable max-len */
|
2016-07-26 23:32:10 -04:00
|
|
|
// MergeRequestTabs
|
|
|
|
//
|
|
|
|
// Handles persisting and restoring the current tab selection and lazily-loading
|
|
|
|
// content on the MergeRequests#show page.
|
|
|
|
//
|
|
|
|
// ### Example Markup
|
|
|
|
//
|
|
|
|
// <ul class="nav-links merge-request-tabs">
|
|
|
|
// <li class="notes-tab active">
|
|
|
|
// <a data-action="notes" data-target="#notes" data-toggle="tab" href="/foo/bar/merge_requests/1">
|
|
|
|
// Discussion
|
|
|
|
// </a>
|
|
|
|
// </li>
|
|
|
|
// <li class="commits-tab">
|
|
|
|
// <a data-action="commits" data-target="#commits" data-toggle="tab" href="/foo/bar/merge_requests/1/commits">
|
|
|
|
// Commits
|
|
|
|
// </a>
|
|
|
|
// </li>
|
|
|
|
// <li class="diffs-tab">
|
|
|
|
// <a data-action="diffs" data-target="#diffs" data-toggle="tab" href="/foo/bar/merge_requests/1/diffs">
|
|
|
|
// Diffs
|
|
|
|
// </a>
|
|
|
|
// </li>
|
|
|
|
// </ul>
|
|
|
|
//
|
|
|
|
// <div class="tab-content">
|
|
|
|
// <div class="notes tab-pane active" id="notes">
|
|
|
|
// Notes Content
|
|
|
|
// </div>
|
|
|
|
// <div class="commits tab-pane" id="commits">
|
|
|
|
// Commits Content
|
|
|
|
// </div>
|
|
|
|
// <div class="diffs tab-pane" id="diffs">
|
|
|
|
// Diffs Content
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
//
|
|
|
|
// <div class="mr-loading-status">
|
|
|
|
// <div class="loading">
|
|
|
|
// Loading Animation
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
//
|
2016-10-27 16:32:30 -04:00
|
|
|
/* eslint-enable max-len */
|
|
|
|
|
2016-12-02 18:43:20 -05:00
|
|
|
(() => {
|
2016-10-27 16:32:30 -04:00
|
|
|
// Store the `location` object, allowing for easier stubbing in tests
|
|
|
|
let location = window.location;
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
class MergeRequestTabs {
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-12-15 18:26:14 -05:00
|
|
|
constructor({ action, setUrl, stubLocation } = {}) {
|
2016-10-25 11:42:25 -04:00
|
|
|
this.diffsLoaded = false;
|
2017-02-13 22:27:32 -05:00
|
|
|
this.pipelinesLoaded = false;
|
2016-10-25 11:42:25 -04:00
|
|
|
this.commitsLoaded = false;
|
|
|
|
this.fixedLayoutPref = null;
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
this.setUrl = setUrl !== undefined ? setUrl : true;
|
|
|
|
this.setCurrentAction = this.setCurrentAction.bind(this);
|
|
|
|
this.tabShown = this.tabShown.bind(this);
|
|
|
|
this.showTab = this.showTab.bind(this);
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-27 16:32:30 -04:00
|
|
|
if (stubLocation) {
|
|
|
|
location = stubLocation;
|
|
|
|
}
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
this.bindEvents();
|
2016-10-25 11:42:25 -04:00
|
|
|
this.activateTab(action);
|
2016-09-16 05:45:23 -04:00
|
|
|
this.initAffix();
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
bindEvents() {
|
2016-10-25 02:27:21 -04:00
|
|
|
$(document)
|
|
|
|
.on('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown)
|
|
|
|
.on('click', '.js-show-tab', this.showTab);
|
2017-01-31 04:14:22 -05:00
|
|
|
|
|
|
|
$('.merge-request-tabs a[data-toggle="tab"]')
|
|
|
|
.on('click', this.clickTab);
|
2016-10-25 02:27:21 -04:00
|
|
|
}
|
2016-09-19 19:02:52 -04:00
|
|
|
|
2017-04-07 00:19:30 -04:00
|
|
|
// Used in tests
|
2016-10-25 11:42:25 -04:00
|
|
|
unbindEvents() {
|
2016-10-25 02:27:21 -04:00
|
|
|
$(document)
|
|
|
|
.off('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown)
|
|
|
|
.off('click', '.js-show-tab', this.showTab);
|
2017-01-31 04:14:22 -05:00
|
|
|
|
|
|
|
$('.merge-request-tabs a[data-toggle="tab"]')
|
|
|
|
.off('click', this.clickTab);
|
2016-10-25 02:27:21 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-04-05 19:55:49 -04:00
|
|
|
destroyPipelinesView() {
|
2017-03-22 22:39:09 -04:00
|
|
|
if (this.commitPipelinesTable) {
|
2017-04-05 19:55:49 -04:00
|
|
|
document.querySelector('#commit-pipeline-table-view')
|
|
|
|
.removeChild(this.commitPipelinesTable.$el);
|
2017-04-07 00:19:30 -04:00
|
|
|
|
2017-03-22 22:39:09 -04:00
|
|
|
this.commitPipelinesTable.$destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 12:35:26 -05:00
|
|
|
showTab(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.activateTab($(e.target).data('action'));
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-01-31 04:14:22 -05:00
|
|
|
clickTab(e) {
|
2017-02-09 17:19:12 -05:00
|
|
|
if (e.currentTarget && gl.utils.isMetaClick(e)) {
|
|
|
|
const targetLink = e.currentTarget.getAttribute('href');
|
2017-02-07 11:46:10 -05:00
|
|
|
e.stopImmediatePropagation();
|
2017-02-09 17:19:12 -05:00
|
|
|
e.preventDefault();
|
2017-02-07 11:46:10 -05:00
|
|
|
window.open(targetLink, '_blank');
|
2017-01-31 04:14:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-01 12:35:26 -05:00
|
|
|
tabShown(e) {
|
|
|
|
const $target = $(e.target);
|
2016-10-25 14:33:03 -04:00
|
|
|
const action = $target.data('action');
|
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
if (action === 'commits') {
|
|
|
|
this.loadCommits($target.attr('href'));
|
|
|
|
this.expandView();
|
2016-09-19 19:02:52 -04:00
|
|
|
this.resetViewContainer();
|
2017-04-05 19:55:49 -04:00
|
|
|
this.destroyPipelinesView();
|
2016-08-11 03:00:17 -04:00
|
|
|
} else if (this.isDiffAction(action)) {
|
2016-07-24 16:45:11 -04:00
|
|
|
this.loadDiff($target.attr('href'));
|
2016-10-27 16:32:30 -04:00
|
|
|
if (Breakpoints.get().getBreakpointSize() !== 'lg') {
|
2016-07-24 16:45:11 -04:00
|
|
|
this.shrinkView();
|
|
|
|
}
|
2016-09-19 19:02:52 -04:00
|
|
|
if (this.diffViewType() === 'parallel') {
|
|
|
|
this.expandViewContainer();
|
|
|
|
}
|
2017-04-05 19:55:49 -04:00
|
|
|
this.destroyPipelinesView();
|
2017-02-13 22:27:32 -05:00
|
|
|
} else if (action === 'pipelines') {
|
2017-03-22 22:39:09 -04:00
|
|
|
this.resetViewContainer();
|
2017-04-05 19:55:49 -04:00
|
|
|
this.mountPipelinesView();
|
2016-07-24 16:45:11 -04:00
|
|
|
} else {
|
|
|
|
this.expandView();
|
2016-09-19 19:02:52 -04:00
|
|
|
this.resetViewContainer();
|
2017-04-05 19:55:49 -04:00
|
|
|
this.destroyPipelinesView();
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
if (this.setUrl) {
|
2016-08-17 23:51:49 -04:00
|
|
|
this.setCurrentAction(action);
|
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
scrollToElement(container) {
|
2016-10-27 16:32:30 -04:00
|
|
|
if (location.hash) {
|
2017-01-18 16:25:35 -05:00
|
|
|
const offset = -$('.js-tabs-affix').outerHeight();
|
2016-10-27 16:32:30 -04:00
|
|
|
const $el = $(`${container} ${location.hash}:not(.match)`);
|
2016-12-01 13:19:22 -05:00
|
|
|
if ($el.length) {
|
2016-11-10 18:24:57 -05:00
|
|
|
$.scrollTo($el[0], { offset });
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Activate a tab based on the current action
|
2016-10-25 11:42:25 -04:00
|
|
|
activateTab(action) {
|
2016-10-27 16:32:30 -04:00
|
|
|
const activate = action === 'show' ? 'notes' : action;
|
2016-11-13 10:18:04 -05:00
|
|
|
// important note: the .tab('show') method triggers 'shown.bs.tab' event itself
|
2016-10-27 16:32:30 -04:00
|
|
|
$(`.merge-request-tabs a[data-action='${activate}']`).tab('show');
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Replaces the current Merge Request-specific action in the URL with a new one
|
|
|
|
//
|
|
|
|
// If the action is "notes", the URL is reset to the standard
|
|
|
|
// `MergeRequests#show` route.
|
|
|
|
//
|
|
|
|
// Examples:
|
|
|
|
//
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1"
|
|
|
|
// setCurrentAction('diffs')
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
|
|
|
|
//
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
|
|
|
|
// setCurrentAction('notes')
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1"
|
|
|
|
//
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1/diffs"
|
|
|
|
// setCurrentAction('commits')
|
|
|
|
// location.pathname # => "/namespace/project/merge_requests/1/commits"
|
|
|
|
//
|
|
|
|
// Returns the new URL String
|
2016-10-25 11:42:25 -04:00
|
|
|
setCurrentAction(action) {
|
2016-10-27 16:32:30 -04:00
|
|
|
this.currentAction = action === 'show' ? 'notes' : action;
|
2016-10-25 14:33:03 -04:00
|
|
|
|
2016-12-15 18:26:14 -05:00
|
|
|
// Remove a trailing '/commits' '/diffs' '/pipelines' '/new' '/new/diffs'
|
|
|
|
let newState = location.pathname.replace(/\/(commits|diffs|pipelines|new|new\/diffs)(\.html)?\/?$/, '');
|
2016-08-11 03:00:17 -04:00
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Append the new action if we're on a tab other than 'notes'
|
2016-10-27 16:32:30 -04:00
|
|
|
if (this.currentAction !== 'notes') {
|
|
|
|
newState += `/${this.currentAction}`;
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
2016-10-25 14:33:03 -04:00
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Ensure parameters and hash come along for the ride
|
2016-10-27 16:32:30 -04:00
|
|
|
newState += location.search + location.hash;
|
2016-10-25 11:42:25 -04:00
|
|
|
|
2017-01-13 16:54:16 -05:00
|
|
|
// TODO: Consider refactoring in light of turbolinks removal.
|
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Replace the current history state with the new one without breaking
|
|
|
|
// Turbolinks' history.
|
|
|
|
//
|
|
|
|
// See https://github.com/rails/turbolinks/issues/363
|
2016-10-27 16:32:30 -04:00
|
|
|
window.history.replaceState({
|
|
|
|
url: newState,
|
|
|
|
}, document.title, newState);
|
2016-10-25 11:42:25 -04:00
|
|
|
|
2016-10-27 16:32:30 -04:00
|
|
|
return newState;
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
loadCommits(source) {
|
2016-07-24 16:45:11 -04:00
|
|
|
if (this.commitsLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
this.ajaxGet({
|
2016-10-25 14:33:03 -04:00
|
|
|
url: `${source}.json`,
|
2016-10-25 14:15:11 -04:00
|
|
|
success: (data) => {
|
2016-10-27 16:32:30 -04:00
|
|
|
document.querySelector('div#commits').innerHTML = data.html;
|
2016-10-25 14:15:11 -04:00
|
|
|
gl.utils.localTimeAgo($('.js-timeago', 'div#commits'));
|
|
|
|
this.commitsLoaded = true;
|
2016-10-27 16:32:30 -04:00
|
|
|
this.scrollToElement('#commits');
|
|
|
|
},
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-04-05 19:55:49 -04:00
|
|
|
mountPipelinesView() {
|
|
|
|
this.commitPipelinesTable = new CommitPipelinesTable().$mount();
|
|
|
|
// $mount(el) replaces the el with the new rendered component. We need it in order to mount
|
|
|
|
// it everytime this tab is clicked - https://vuejs.org/v2/api/#vm-mount
|
|
|
|
document.querySelector('#commit-pipeline-table-view')
|
|
|
|
.appendChild(this.commitPipelinesTable.$el);
|
2017-03-22 22:39:09 -04:00
|
|
|
}
|
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
loadDiff(source) {
|
2016-07-24 16:45:11 -04:00
|
|
|
if (this.diffsLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
2016-08-11 03:00:17 -04:00
|
|
|
|
|
|
|
// We extract pathname for the current Changes tab anchor href
|
|
|
|
// some pages like MergeRequestsController#new has query parameters on that anchor
|
2016-12-03 17:04:21 -05:00
|
|
|
const urlPathname = gl.utils.parseUrlPathname(source);
|
2016-08-11 03:00:17 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
this.ajaxGet({
|
2016-11-17 07:05:32 -05:00
|
|
|
url: `${urlPathname}.json${location.search}`,
|
2016-10-25 14:15:11 -04:00
|
|
|
success: (data) => {
|
|
|
|
$('#diffs').html(data.html);
|
|
|
|
|
|
|
|
if (typeof gl.diffNotesCompileComponents !== 'undefined') {
|
|
|
|
gl.diffNotesCompileComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
gl.utils.localTimeAgo($('.js-timeago', 'div#diffs'));
|
|
|
|
$('#diffs .js-syntax-highlight').syntaxHighlight();
|
|
|
|
|
2016-10-27 16:32:30 -04:00
|
|
|
if (this.diffViewType() === 'parallel' && this.isDiffAction(this.currentAction)) {
|
2016-10-25 14:15:11 -04:00
|
|
|
this.expandViewContainer();
|
|
|
|
}
|
|
|
|
this.diffsLoaded = true;
|
|
|
|
|
2017-01-07 16:58:25 -05:00
|
|
|
new gl.Diff();
|
|
|
|
this.scrollToElement('#diffs');
|
2016-10-27 16:32:30 -04:00
|
|
|
},
|
2016-07-24 16:45:11 -04:00
|
|
|
});
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-25 17:14:14 -04:00
|
|
|
|
2016-07-26 23:32:10 -04:00
|
|
|
// Show or hide the loading spinner
|
|
|
|
//
|
|
|
|
// status - Boolean, true to show, false to hide
|
2016-10-25 11:42:25 -04:00
|
|
|
toggleLoading(status) {
|
|
|
|
$('.mr-loading-status .loading').toggle(status);
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
ajaxGet(options) {
|
2016-10-25 14:33:03 -04:00
|
|
|
const defaults = {
|
2016-10-25 14:15:11 -04:00
|
|
|
beforeSend: () => this.toggleLoading(true),
|
2016-12-01 14:09:45 -05:00
|
|
|
error: () => new Flash('An error occurred while fetching this tab.', 'alert'),
|
2016-10-25 14:15:11 -04:00
|
|
|
complete: () => this.toggleLoading(false),
|
2016-07-24 16:45:11 -04:00
|
|
|
dataType: 'json',
|
2016-10-27 16:32:30 -04:00
|
|
|
type: 'GET',
|
2016-07-24 16:45:11 -04:00
|
|
|
};
|
2016-10-27 16:32:30 -04:00
|
|
|
$.ajax($.extend({}, defaults, options));
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
diffViewType() {
|
2016-07-24 16:45:11 -04:00
|
|
|
return $('.inline-parallel-buttons a.active').data('view-type');
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
isDiffAction(action) {
|
2016-10-27 16:32:30 -04:00
|
|
|
return action === 'diffs' || action === 'new/diffs';
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-08-11 03:00:17 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
expandViewContainer() {
|
2016-10-25 14:33:03 -04:00
|
|
|
const $wrapper = $('.content-wrapper .container-fluid');
|
2016-09-19 19:02:52 -04:00
|
|
|
if (this.fixedLayoutPref === null) {
|
|
|
|
this.fixedLayoutPref = $wrapper.hasClass('container-limited');
|
|
|
|
}
|
|
|
|
$wrapper.removeClass('container-limited');
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-09-19 19:02:52 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
resetViewContainer() {
|
2016-09-19 19:02:52 -04:00
|
|
|
if (this.fixedLayoutPref !== null) {
|
|
|
|
$('.content-wrapper .container-fluid')
|
|
|
|
.toggleClass('container-limited', this.fixedLayoutPref);
|
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
shrinkView() {
|
2016-10-25 14:33:03 -04:00
|
|
|
const $gutterIcon = $('.js-sidebar-toggle i:visible');
|
2016-10-25 11:42:25 -04:00
|
|
|
|
|
|
|
// Wait until listeners are set
|
2016-10-25 14:15:11 -04:00
|
|
|
setTimeout(() => {
|
2016-10-25 11:42:25 -04:00
|
|
|
// Only when sidebar is expanded
|
2016-07-24 16:45:11 -04:00
|
|
|
if ($gutterIcon.is('.fa-angle-double-right')) {
|
2016-10-25 11:42:25 -04:00
|
|
|
$gutterIcon.closest('a').trigger('click', [true]);
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
}, 0);
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
// Expand the issuable sidebar unless the user explicitly collapsed it
|
|
|
|
expandView() {
|
2016-10-24 17:26:41 -04:00
|
|
|
if (Cookies.get('collapsed_gutter') === 'true') {
|
2016-07-24 16:45:11 -04:00
|
|
|
return;
|
|
|
|
}
|
2016-10-25 14:33:03 -04:00
|
|
|
const $gutterIcon = $('.js-sidebar-toggle i:visible');
|
2016-10-25 11:42:25 -04:00
|
|
|
|
|
|
|
// Wait until listeners are set
|
2016-10-25 14:15:11 -04:00
|
|
|
setTimeout(() => {
|
2016-10-25 11:42:25 -04:00
|
|
|
// Only when sidebar is collapsed
|
2016-07-24 16:45:11 -04:00
|
|
|
if ($gutterIcon.is('.fa-angle-double-left')) {
|
2016-10-25 11:42:25 -04:00
|
|
|
$gutterIcon.closest('a').trigger('click', [true]);
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
}, 0);
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-10-25 11:42:25 -04:00
|
|
|
initAffix() {
|
2016-10-25 14:33:03 -04:00
|
|
|
const $tabs = $('.js-tabs-affix');
|
2016-09-16 09:32:43 -04:00
|
|
|
|
2016-09-16 05:45:23 -04:00
|
|
|
// Screen space on small screens is usually very sparse
|
|
|
|
// So we dont affix the tabs on these
|
2016-09-16 09:32:43 -04:00
|
|
|
if (Breakpoints.get().getBreakpointSize() === 'xs' || !$tabs.length) return;
|
2016-09-16 05:45:23 -04:00
|
|
|
|
2016-10-25 14:33:03 -04:00
|
|
|
const $diffTabs = $('#diff-notes-app');
|
2016-09-16 05:45:23 -04:00
|
|
|
|
|
|
|
$tabs.off('affix.bs.affix affix-top.bs.affix')
|
2016-10-27 16:32:30 -04:00
|
|
|
.affix({
|
|
|
|
offset: {
|
|
|
|
top: () => (
|
2017-01-04 13:21:28 -05:00
|
|
|
$diffTabs.offset().top - $tabs.height()
|
2016-10-27 16:32:30 -04:00
|
|
|
),
|
|
|
|
},
|
|
|
|
})
|
2016-10-25 14:15:11 -04:00
|
|
|
.on('affix.bs.affix', () => $diffTabs.css({ marginTop: $tabs.height() }))
|
|
|
|
.on('affix-top.bs.affix', () => $diffTabs.css({ marginTop: '' }));
|
2016-09-16 05:45:23 -04:00
|
|
|
|
|
|
|
// Fix bug when reloading the page already scrolling
|
|
|
|
if ($tabs.hasClass('affix')) {
|
|
|
|
$tabs.trigger('affix.bs.affix');
|
|
|
|
}
|
2016-10-25 11:42:25 -04:00
|
|
|
}
|
|
|
|
}
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2016-12-02 18:43:20 -05:00
|
|
|
window.gl = window.gl || {};
|
|
|
|
window.gl.MergeRequestTabs = MergeRequestTabs;
|
|
|
|
})();
|