Created
January 19, 2012 04:04
-
-
Save tylersticka/1637746 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* Plugin for creating new windows in JS | |
*/ | |
(function($){ | |
$.newWindow = function (el, w, h) { | |
var base = this; | |
base.$el = $(el); | |
base.init = function () { | |
base.features = 'width=' + w + ',height=' + h + ',left=' + ((screen.width-w)/2) + ',top=' + ((screen.height-h)/2 - 110); | |
base.$el.click(base.open); | |
} | |
base.open = function (e) { | |
e.preventDefault(); | |
base.win = window.open(base.$el.attr('href'), 'newWindow' + (Math.round(Math.random() * 999999)), base.features); | |
} | |
base.init(); | |
} | |
$.fn.newWindow = function (w, h, pos) { | |
return this.each(function(){ | |
(new $.newWindow(this, w, h, pos)); | |
}); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment