Skip to content

Commit

Permalink
Merge branch 'refs/heads/pr/4'
Browse files Browse the repository at this point in the history
  • Loading branch information
trjast committed Apr 19, 2016
2 parents 1c1da51 + 939a8dd commit 5870e6c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Slacky",
"author": "SociallyTied",
"version": "1.5",
"version": "1.6",
"minimum_chrome_version": "23",
"description": "Simple Slack app for Chrome I created because I hate having it open in another tab :)",
"icons": {
Expand Down
80 changes: 40 additions & 40 deletions app/slacky.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,47 @@ var height = 700;

// Setup the initial Slack window
chrome.app.runtime.onLaunched.addListener(function() {
createWindow(baseUrl);
createWindow(baseUrl);
});

function createWindow(destUrl) {
chrome.app.window.create(
view, {
// Set the height and width and then rander it in the middle of the screen
bounds: {
width: width,
height: height,
left: Math.round((screen.availWidth - width) / 2),
top: Math.round((screen.availHeight - height) / 2)
},
// Minimum sizes
innerBounds: {
minWidth: width,
minHeight: height
}
}, function(createdWindow) {
createdWindow.contentWindow.onload = function() {
// Retrieve the webview element
var webview = createdWindow.contentWindow.document.querySelector('webview');
// When the window is resized, resize the webview to conform to the new size
createdWindow.onBoundsChanged.addListener(function() {
var bounds = createdWindow.getBounds();
webview.style.height = bounds.height;
webview.style.width = bounds.width;
});
// Render the page requested inside the webview
webview.src = destUrl;
// Add event listener for when webview finishes loading
webview.addEventListener("contentload", function() {
// Focus on the webview, so focus can go to the proper elements within it
webview.focus();
// Add event listener for when window becomes focused
createdWindow.contentWindow.onfocus = function() {
// Focus on the webview, so focus can go to the proper elements within it
webview.focus();
};
});
};
}
);
chrome.app.window.create(
view, {
// Set the height and width and then rander it in the middle of the screen
bounds: {
width: width,
height: height,
left: Math.round((screen.availWidth - width) / 2),
top: Math.round((screen.availHeight - height) / 2)
},
// Minimum sizes
innerBounds: {
minWidth: width,
minHeight: height
}
}, function(createdWindow) {
createdWindow.contentWindow.onload = function() {
// Retrieve the webview element
var webview = createdWindow.contentWindow.document.querySelector('webview');
// When the window is resized, resize the webview to conform to the new size
createdWindow.onBoundsChanged.addListener(function() {
var bounds = createdWindow.getBounds();
webview.style.height = bounds.height;
webview.style.width = bounds.width;
});
// Render the page requested inside the webview
webview.src = destUrl;
// Add event listener for when webview finishes loading
webview.addEventListener("contentload", function() {
// Focus on the webview, so focus can go to the proper elements within it
webview.focus();
// Add event listener for when window becomes focused
createdWindow.contentWindow.onfocus = function() {
// Focus on the webview, so focus can go to the proper elements within it
webview.focus();
};
});
};
}
);
}

0 comments on commit 5870e6c

Please sign in to comment.