diff --git a/src/adapter.github.js b/src/adapter.github.js index 4e254153..f0c3bc20 100644 --- a/src/adapter.github.js +++ b/src/adapter.github.js @@ -13,26 +13,7 @@ const , GH_PJAX_SEL = '#js-repo-pjax-container' , GH_CONTAINERS = 'body > .container, .header > .container, .site > .container, .repohead > .container' -function GitHub() { - // Fix #151 by detecting when page layout is updated. - // In this case, split-diff page has a wider layout, so need to recompute margin. - // In addition, can't do this in response to URL change, since new DOM might not be ready. - var observer = new MutationObserver(function(mutations) { - for (var i = 0, len = mutations.length; i < len; i++) { - var mutation = mutations[i] - if (~mutation.oldValue.indexOf('split-diff') || - ~mutation.target.className.indexOf('split-diff')) { - return $(document).trigger(EVENT.LAYOUT_CHANGE) - } - } - }) - - observer.observe(document.body, { - attributes: true, - attributeFilter: ['class'], - attributeOldValue: true - }) -} +function GitHub() {} /** * Selects a submodule. @@ -63,28 +44,9 @@ GitHub.prototype.selectPath = function(path, tabSize) { */ GitHub.prototype.updateLayout = function(sidebarVisible, sidebarWidth) { var $containers = $(GH_CONTAINERS) - , isSplitView = $(document.body).hasClass('split-diff') - , spacing = 10 - , autoMarginLeft - , shouldPushLeft - - if ($containers.length === 4) { - autoMarginLeft = ($('body').width() - $containers.width()) / 2 - - if (isSplitView) { - $containers.css('margin-left', 'auto') - if (sidebarVisible) $containers.css('padding-left', sidebarWidth + spacing) - else $containers.css('padding-left', 30) - } - else { - $containers.css('padding-left', 0) - if (sidebarVisible) $containers.css('margin-left', sidebarWidth + spacing) - else $containers.css('margin-left', 'auto') - } - } - - // falls-back if GitHub DOM has been updated - else $('html').css('margin-left', sidebarVisible ? sidebarWidth - spacing : 0) + $containers = $containers.length === 4 ? $containers : $('html') // falls-back if GH DOM is changed + if (sidebarVisible) $containers.css('margin-left', sidebarWidth + 10) + else $containers.css('margin-left', 'auto') } /** diff --git a/src/constants.js b/src/constants.js index 28ee744b..92c3af55 100644 --- a/src/constants.js +++ b/src/constants.js @@ -37,7 +37,6 @@ const , EVENT = { TOGGLE : 'octotree:toggle', LOC_CHANGE : 'octotree:location', - LAYOUT_CHANGE : 'octotree:layout', REQ_START : 'octotree:start', REQ_END : 'octotree:end', OPTS_CHANGE : 'octotree:change', diff --git a/src/octotree.js b/src/octotree.js index 4c9c2280..9681b42e 100755 --- a/src/octotree.js +++ b/src/octotree.js @@ -63,7 +63,6 @@ $(document).ready(function() { event.preventDefault() }) .on(EVENT.LOC_CHANGE, tryLoadRepo) - .on(EVENT.LAYOUT_CHANGE, layoutChanged) .on(EVENT.TOGGLE, layoutChanged) return tryLoadRepo()