Created
January 3, 2014 18:54
-
-
Save stefbowerman/8244065 to your computer and use it in GitHub Desktop.
Coffeescript class for creating a popup window in the center of the screen.
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
# Requires jQuery | |
class @PopupWindow | |
attributes = | |
title : "Popup Window Title" | |
windowHeight : 600 | |
windowWidth : 600 | |
openOnCreate : true | |
constructor : (@url, attrs = {}) -> | |
throw new Error('A url is required to create a popup') unless url? | |
$.extend attributes, attrs | |
@title = attributes.title | |
@windowHeight = attributes.windowHeight | |
@windowWidth = attributes.windowWidth | |
@left = (screen.width/2) - (@windowWidth/2) | |
@top = (screen.height/2) - (@windowHeight/2) | |
@open() if attributes.openOnCreate | |
open : -> window.open @url, @title, "toolbar=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=#{@windowWidth}, height=#{@windowHeight}, top=#{@top}, left=#{@left}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment