widgets.popup([url], [name], [features], [debug])
The Popup Window Widget extends the default functionality of window.open(url, name, features)
with the ability to process name
and features
from powerful custom profiles. Profiles are an efficient method of dealing with repeated code, especially in arguments.
Consider the need for several popup windows that have the same features in common. A custom profile can be used as an argument to widgets.popup(this, 'profiles.name')
that produces the same popups without repeating the features
arguments. Popup Window Widget takes this concept a little further by allowing the programmer to extend or overwrite a profile using similar markup: widgets.popup(this, 'profiles.name', 'width=100,height=100')
.
Profiles are created within the JavaScript code enclosure (limits polluting the window scope) and follow the format: profiles.[name].name
(string) and profiles.[name].features
(string).
Arguments | Type | Description |
---|---|---|
url | mixed | The popup url or object containing an href. Example: Use object [this] or string 'http://www.google.com' |
name | mixed | The popup name or profile name (prefixed with "profiles.") Example: 'profiles.video' |
features | string | The features as a comma separated key=value list |
debug | bool | Set to true to disable opening the popup thru window.open() while testing |
Properties | Type | Description |
return | false | |
Profiles | Type | Description |
profiles | object | The object containing the popup properties |
profiles.name | string | The popup window's name |
profiles.features | string | The popup window's features |
<script type="text/javascript" src="javascript/popup.js"></script>
widgets.popup([url], [name], [features])
from any element or function<a href="http://www.google.com" onclick="return widgets.popup(this, 'profiles.smallbox', 'width=800,height=600');">Google.com</a>
Try it out: Google.com
widgets.popup(this, 'MyName');
widgets.popup(this.href, 'My Name');
widgets.popup(this, 'profiles.smallbox');
widgets.popup(this, 'profile.smallbox');
widgets.popup(this, 'profiles.video');
widgets.popup(this, 'profiles.notreal');
widgets.popup(this, 'profiles.notreal', 'width=100, height=100');
widgets.popup(this, 'profiles.video');
widgets.popup(this, 'profiles.video', 'width=100px,height=100px');
widgets.popup(this, 'profiles.video', 'width=100px,height=100px,tango=120px');
Basic object popup(this)
Basic string popup(this.href)
Profile popup(this, "profiles.basic")
Invalid Profile popup(this, "profiles.noprofile")
Profile+Features popup(this, "profiles.basic", "width=100, height=100")