Some styling
[scpubgit/stemmaweb.git] / root / js / jquery.popupWindow.js
CommitLineData
e847b186 1(function($){
2 $.fn.popupWindow = function(instanceSettings){
3
4 return this.each(function(){
5
6 $(this).click(function(){
7
8 $.fn.popupWindow.defaultSettings = {
9 centerBrowser:0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left
10 centerScreen:0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left
11 height:500, // sets the height in pixels of the window.
12 left:0, // left position when the window appears.
13 location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
14 menubar:0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
15 resizable:0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
16 scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
17 status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
18 width:500, // sets the width in pixels of the window.
19 windowName:null, // name of window set from the name attribute of the element that invokes the click
20 windowURL:null, // url used for the popup
21 top:0, // top position when the window appears.
22 toolbar:0 // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
23 };
24
25 settings = $.extend({}, $.fn.popupWindow.defaultSettings, instanceSettings || {});
26
27 var windowFeatures = 'height=' + settings.height +
28 ',width=' + settings.width +
29 ',toolbar=' + settings.toolbar +
30 ',scrollbars=' + settings.scrollbars +
31 ',status=' + settings.status +
32 ',resizable=' + settings.resizable +
33 ',location=' + settings.location +
34 ',menuBar=' + settings.menubar;
35
36 settings.windowName = this.name || settings.windowName;
37 settings.windowURL = this.href || settings.windowURL;
38 var centeredY,centeredX;
39
40 if(settings.centerBrowser){
41
42 if ($.browser.msie) {//hacked together for IE browsers
43 centeredY = (window.screenTop - 120) + ((((document.documentElement.clientHeight + 120)/2) - (settings.height/2)));
44 centeredX = window.screenLeft + ((((document.body.offsetWidth + 20)/2) - (settings.width/2)));
45 }else{
46 centeredY = window.screenY + (((window.outerHeight/2) - (settings.height/2)));
47 centeredX = window.screenX + (((window.outerWidth/2) - (settings.width/2)));
48 }
49 window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
50 }else if(settings.centerScreen){
51 centeredY = (screen.height - settings.height)/2;
52 centeredX = (screen.width - settings.width)/2;
53 window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + centeredX +',top=' + centeredY).focus();
54 }else{
55 window.open(settings.windowURL, settings.windowName, windowFeatures+',left=' + settings.left +',top=' + settings.top).focus();
56 }
57 return false;
58 });
59
60 });
61 };
62})(jQuery);