Created
November 28, 2011 16:08
-
-
Save jimevans/1400913 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine the outer size of the window. | |
* | |
* @param {!Window=} opt_win Window to determine the size of. Defaults to | |
* bot.getWindow(). | |
* @return {!goog.math.Size} The calculated size. | |
*/ | |
bot.window.getSize = function(opt_win) { | |
var win = opt_win || bot.getWindow(); | |
var width = 0; | |
var height = 0; | |
if (goog.userAgent.IE && !win['outerWidth']) { | |
if(!(win.document.documentElement.clientWidth == 0)) { | |
//strict mode | |
width = win.document.documentElement.clientWidth; | |
height = win.document.documentElement.clientHeight; | |
} else { | |
//quirks mode | |
width = win.document.body.clientWidth; | |
height = win.document.body.clientHeight; | |
} | |
} else { | |
width = win.outerWidth; | |
height = win.outerHeight; | |
} | |
return new goog.math.Size(width, height); | |
}; | |
/** Get the position of the window. | |
* | |
* @param {!Window=} opt_win Window to determine the position of. Defaults to | |
* bot.getWindow(). | |
* @return {!goog.math.Coordinate} The position of the window. | |
*/ | |
bot.window.getPosition = function(opt_win) { | |
var win = opt_win || bot.getWindow(); | |
var x = 0; | |
var y = 0; | |
if (goog.userAgent.IE && !win['screenX']) { | |
x = win.screenLeft; | |
y = win.screenTop; | |
} else { | |
x = win.screenX; | |
y = win.screenY; | |
} | |
return new goog.math.Coordinate(x, y); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment