Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Fixes dual-screen position #190

Merged
merged 4 commits into from
Dec 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/social-likes.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,21 @@
},

openPopup: function(url, params) {
var left = Math.round(screen.width/2 - params.width/2);
var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ?
document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ?
document.documentElement.clientHeight : screen.height;

var left = Math.round(width/2 - params.width/2) + dualScreenLeft;
var top = 0;
if (screen.height > params.height) {
top = Math.round(screen.height/3 - params.height/2);
if (height > params.height) {
top = Math.round(height/3 - params.height/2) + dualScreenTop;
}

var win = window.open(url, 'sl_' + this.service, 'left=' + left + ',top=' + top + ',' +
'width=' + params.width + ',height=' + params.height + ',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
'width=' + params.width + ',height=' + params.height + ',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
if (win) {
win.focus();
this.widget.trigger('popup_opened.' + prefix, [this.service, win]);
Expand Down