Skip to content

Commit

Permalink
Make same changes to enterprise.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Holtslander committed Jan 22, 2017
1 parent 74f67a5 commit c6958a2
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions enterprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ var repositoryName;
var repositoryAuthor;
var autoCollapseExpressions;

function onFilesPage() {
return window.location.href.indexOf('files') !== -1;
}

function htmlIsInjected() {
return $('.pretty-pull-requests-inserted').length > 0;
}

function injectHtml() {
if (!onFilesPage()) return;
$('<span class="pretty-pull-requests collapse-lines">' +
'<label><input type="checkbox" class="js-collapse-additions" checked="yes">+</label>' +
'<label><input type="checkbox" class="js-collapse-deletions" checked="yes">-</label>' +
Expand Down Expand Up @@ -147,10 +152,10 @@ function initDiffs() {
autoCollapse();
}

function clickTitle() {
function clickTitle(e) {
e.preventDefault();
var path = $(this).attr('title') || this.innerText;
var id = getId(path);
debugger;

return toggleDiff(id);
}
Expand All @@ -170,23 +175,28 @@ function autoCollapse() {
}

chrome.storage.sync.get({url: '', saveCollapsedDiffs: true, tabSwitchingEnabled: false, autoCollapseExpressions: []}, function(items) {
if (items.url == window.location.origin ||
if (items.url === window.location.origin ||
"https://github.com" === window.location.origin) {

autoCollapseExpressions = items.autoCollapseExpressions;

var interval = null;
var injectHtmlIfNecessary = function () {
if (!htmlIsInjected()) {
collectUniquePageInfo();
injectHtml();
initDiffs();
$body.on('click', '.user-select-contain, .js-selectable-text, .file-info .link-gray-dark', clickTitle);
$body.on('click', '.bottom-collapse', clickCollapse);
$body.on('click', '.js-collapse-additions', collapseAdditions);
$body.on('click', '.js-collapse-deletions', collapseDeletions);
if (onFilesPage()) {
collectUniquePageInfo();
injectHtml();
initDiffs();
$body.on('click', '.user-select-contain, .js-selectable-text, .file-info .link-gray-dark', clickTitle);
$body.on('click', '.bottom-collapse', clickCollapse);
$body.on('click', '.js-collapse-additions', collapseAdditions);
$body.on('click', '.js-collapse-deletions', collapseDeletions);
}
} else {
cleartInterval(interval);
}
setTimeout(injectHtmlIfNecessary, 1000);
};
interval = setInterval(injectHtmlIfNecessary, 1000);
var $body = $('body');
useLocalStorage = items.saveCollapsedDiffs;

Expand Down

0 comments on commit c6958a2

Please sign in to comment.