Skip to content

Instantly share code, notes, and snippets.

@tanraya
Created February 8, 2012 12:12
Show Gist options
  • Save tanraya/1768619 to your computer and use it in GitHub Desktop.
Save tanraya/1768619 to your computer and use it in GitHub Desktop.
/*
Useful tools.
Author: venom
Date: 22.01.2009
*/
// Merging two objects
Object.prototype.extend = function(extended) {
for (var key in (extended || {})) this[key] = extended[key];
return this;
}
// Utilities object
var Utils = {
// Show popup window
popup: function(options) {
var options = {
url : '/',
width : 800,
height : 600,
name : 'popup',
location : 1,
status : 0,
scrollbars : 0,
}.extend(options);
options.x = (screen.width/2)-(options.width/2);
options.y = (screen.height/2)-(options.height/2);
var w = window.open(options.url, options.name,
"location="+options.location+
",status="+options.status+
",scrollbars="+options.scrollbars+
",width="+options.width+
",height="+options.height+
",top="+options.y+
",left="+options.x);
w.focus();
return w;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment