Skip to content

Commit 75073ae

Browse files
authored
Merge pull request #34 from intercom/jp/center-oauth-auth-window
Center Oauth authorization window
2 parents b8d458e + ba74b75 commit 75073ae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

addon/services/ember-oauth2.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ export default Ember.Service.extend(Ember.Evented, {
8080
@return {Object} On resolve returns reference to the opened window.
8181
On reject returns Object with reference to dialog and error.
8282
*/
83-
openWindow(url) {
84-
let dialog = window.open(url, 'Authorize', 'height=600, width=450');
85-
if (window.focus && dialog) {
86-
dialog.focus();
87-
}
83+
openWindow(url, windowWidth=600, windowHeight=800) {
84+
const windowLeft = (window.screen.width / 2) - (windowWidth / 2);
85+
const windowTop = (window.screen.height / 2) - (windowHeight / 2);
86+
const options = `menubar, width=${windowWidth}, height=${windowHeight}, top=${windowTop}, left=${windowLeft}`;
87+
const dialog = window.open(url, 'Authorize', options);
88+
if (window.focus && dialog) { dialog.focus(); }
8889
return new Ember.RSVP.Promise(function(resolve, reject) {
8990
if (dialog) {
9091
resolve(dialog);

0 commit comments

Comments
 (0)