Commit 2e217bc8 authored by Mike Greiling's avatar Mike Greiling

refactor awkward bind workarounds into arrow functions

parent f14c5ae8
...@@ -201,14 +201,12 @@ ...@@ -201,14 +201,12 @@
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: source + ".json",
success: (function(_this) { success: (data) => {
return function(data) {
document.querySelector("div#commits").innerHTML = data.html; document.querySelector("div#commits").innerHTML = data.html;
gl.utils.localTimeAgo($('.js-timeago', 'div#commits')); gl.utils.localTimeAgo($('.js-timeago', 'div#commits'));
_this.commitsLoaded = true; this.commitsLoaded = true;
_this.scrollToElement("#commits"); this.scrollToElement("#commits");
}; }
})(this)
}); });
} }
...@@ -224,8 +222,7 @@ ...@@ -224,8 +222,7 @@
this.ajaxGet({ this.ajaxGet({
url: (url.pathname + ".json") + this._location.search, url: (url.pathname + ".json") + this._location.search,
success: (function(_this) { success: (data) => {
return function(data) {
$('#diffs').html(data.html); $('#diffs').html(data.html);
if (typeof gl.diffNotesCompileComponents !== 'undefined') { if (typeof gl.diffNotesCompileComponents !== 'undefined') {
...@@ -235,15 +232,14 @@ ...@@ -235,15 +232,14 @@
gl.utils.localTimeAgo($('.js-timeago', 'div#diffs')); gl.utils.localTimeAgo($('.js-timeago', 'div#diffs'));
$('#diffs .js-syntax-highlight').syntaxHighlight(); $('#diffs .js-syntax-highlight').syntaxHighlight();
if (_this.diffViewType() === 'parallel' && (_this.isDiffAction(_this.currentAction)) ) { if (this.diffViewType() === 'parallel' && this.isDiffAction(this.currentAction) ) {
_this.expandViewContainer(); this.expandViewContainer();
} }
_this.diffsLoaded = true; this.diffsLoaded = true;
_this.scrollToElement("#diffs"); this.scrollToElement("#diffs");
new Diff(); new Diff();
}; }
})(this)
}); });
} }
...@@ -253,15 +249,13 @@ ...@@ -253,15 +249,13 @@
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: source + ".json",
success: (function(_this) { success: (data) => {
return function(data) {
document.querySelector("div#builds").innerHTML = data.html; document.querySelector("div#builds").innerHTML = data.html;
gl.utils.localTimeAgo($('.js-timeago', 'div#builds')); gl.utils.localTimeAgo($('.js-timeago', 'div#builds'));
_this.buildsLoaded = true; this.buildsLoaded = true;
if (!this.pipelines) this.pipelines = new gl.Pipelines(); new gl.Pipelines();
_this.scrollToElement("#builds"); this.scrollToElement("#builds");
}; }
})(this)
}); });
} }
...@@ -271,12 +265,12 @@ ...@@ -271,12 +265,12 @@
} }
this.ajaxGet({ this.ajaxGet({
url: source + ".json", url: source + ".json",
success: function(data) { success: (data) => {
$('#pipelines').html(data.html); $('#pipelines').html(data.html);
gl.utils.localTimeAgo($('.js-timeago', '#pipelines')); gl.utils.localTimeAgo($('.js-timeago', '#pipelines'));
this.pipelinesLoaded = true; this.pipelinesLoaded = true;
this.scrollToElement("#pipelines"); this.scrollToElement("#pipelines");
}.bind(this) }
}); });
} }
...@@ -289,16 +283,8 @@ ...@@ -289,16 +283,8 @@
ajaxGet(options) { ajaxGet(options) {
var defaults = { var defaults = {
beforeSend: (function(_this) { beforeSend: () => this.toggleLoading(true),
return function() { complete: () => this.toggleLoading(false),
_this.toggleLoading(true);
};
})(this),
complete: (function(_this) {
return function() {
_this.toggleLoading(false);
};
})(this),
dataType: 'json', dataType: 'json',
type: 'GET' type: 'GET'
}; };
...@@ -334,7 +320,7 @@ ...@@ -334,7 +320,7 @@
$gutterIcon = $('.js-sidebar-toggle i:visible'); $gutterIcon = $('.js-sidebar-toggle i:visible');
// Wait until listeners are set // Wait until listeners are set
setTimeout(function() { setTimeout(() => {
// Only when sidebar is expanded // Only when sidebar is expanded
if ($gutterIcon.is('.fa-angle-double-right')) { if ($gutterIcon.is('.fa-angle-double-right')) {
$gutterIcon.closest('a').trigger('click', [true]); $gutterIcon.closest('a').trigger('click', [true]);
...@@ -351,7 +337,7 @@ ...@@ -351,7 +337,7 @@
$gutterIcon = $('.js-sidebar-toggle i:visible'); $gutterIcon = $('.js-sidebar-toggle i:visible');
// Wait until listeners are set // Wait until listeners are set
setTimeout(function() { setTimeout(() => {
// Only when sidebar is collapsed // Only when sidebar is collapsed
if ($gutterIcon.is('.fa-angle-double-left')) { if ($gutterIcon.is('.fa-angle-double-left')) {
$gutterIcon.closest('a').trigger('click', [true]); $gutterIcon.closest('a').trigger('click', [true]);
...@@ -371,24 +357,13 @@ ...@@ -371,24 +357,13 @@
$layoutNav = $('.layout-nav'); $layoutNav = $('.layout-nav');
$tabs.off('affix.bs.affix affix-top.bs.affix') $tabs.off('affix.bs.affix affix-top.bs.affix')
.affix({ .affix({ offset: {
offset: { top: () => (
top: function () { $diffTabs.offset().top - $tabs.height() - $fixedNav.height() - $layoutNav.height()
var tabsTop = $diffTabs.offset().top - $tabs.height(); )
tabsTop = tabsTop - ($fixedNav.height() + $layoutNav.height()); }})
.on('affix.bs.affix', () => $diffTabs.css({ marginTop: $tabs.height() }))
return tabsTop; .on('affix-top.bs.affix', () => $diffTabs.css({ marginTop: '' }));
}
}
}).on('affix.bs.affix', function () {
$diffTabs.css({
marginTop: $tabs.height()
});
}).on('affix-top.bs.affix', function () {
$diffTabs.css({
marginTop: ''
});
});
// Fix bug when reloading the page already scrolling // Fix bug when reloading the page already scrolling
if ($tabs.hasClass('affix')) { if ($tabs.hasClass('affix')) {
......
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