// jQuery plugin to center an element: // http://plugins.jquery.com/project/autocenter (function ($) { $.fn.extend({ center: function (options) { options = $.extend({ // Default values inside: window, // element, center into window transition: 0, // millisecond, transition time minX: 0, // pixel, minimum left element value minY: 0, // pixel, minimum top element value vertical: true, // booleen, center vertical withScrolling: true, // booleen, take care of element inside scrollTop when minX < 0 and window is small or when window is big horizontal: true // booleen, center horizontal }, options); return this.each(function () { var props = { position: 'absolute' }; if (options.vertical) { var top = ($(options.inside).height() - $(this).outerHeight()) / 2; if (options.withScrolling) top += $(options.inside).scrollTop() || 0; top = (top > options.minY ? top : options.minY); $.extend(props, { top: top + 'px' }); } if (options.horizontal) { var left = ($(options.inside).width() - $(this).outerWidth()) / 2; if (options.withScrolling) left += $(options.inside).scrollLeft() || 0; left = (left > options.minX ? left : options.minX); $.extend(props, { left: left + 'px' }); } if (options.transition > 0) $(this).animate(props, options.transition); else $(this).css(props); return $(this); }); } }); })(jQuery); // jQuery plugin to centre popup windows consistently across all browsers // http://swip.codylindley.com/popupWindowDemo.html // http://swip.codylindley.com/jquery.popupWindow.js // Heavily altered, but the principle remains. function popupWindow(instanceSettings) { var defaultSettings = { centerBrowser: 0, // center window over browser window? {1 (YES) or 0 (NO)}. overrides top and left centerScreen: 0, // center window over entire screen? {1 (YES) or 0 (NO)}. overrides top and left height: 500, // sets the height in pixels of the window. left: 0, // left position when the window appears. location: 0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}. menubar: 0, // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}. resizable: 0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable. scrollbars: 0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}. status: 0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}. width: 500, // sets the width in pixels of the window. windowName: null, // name of window set from the name attribute of the element that invokes the click windowURL: null, // url used for the popup top: 0, // top position when the window appears. toolbar: 0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}. dependent: false, // adds 'dependent' to the features modal: false, // open window modally modalArgument: null // an argument to pass to the modal window }; settings = $.extend({}, defaultSettings, instanceSettings || {}); settings.modal = false; var paramSeparator = ','; var valueSeparator = '='; var AddParam = function (Features, Param, Value) { if (Features != '') Features += paramSeparator; Features += Param + valueSeparator + Value; return Features; }; var windowFeatures = ''; windowFeatures = AddParam(windowFeatures, (settings.modal ? 'dialogW' : 'w') + 'idth', settings.width + (settings.modal ? 'px' : '')); windowFeatures = AddParam(windowFeatures, (settings.modal ? 'dialogH' : 'h') + 'eight', settings.height + (settings.modal ? 'px' : '')); if (settings.toolbar && !settings.modal) windowFeatures = AddParam(windowFeatures, 'toolbar', settings.toolbar); if (settings.scrollbars) windowFeatures = AddParam(windowFeatures, 'scroll' + (settings.modal ? '' : 'bars'), settings.scrollbars); if (settings.status) windowFeatures = AddParam(windowFeatures, 'status', settings.status); if (settings.resizable) windowFeatures = AddParam(windowFeatures, 'resizable', settings.resizable); if (settings.location && !settings.modal) windowFeatures = AddParam(windowFeatures, 'location', settings.location); if (settings.menubar && !settings.modal) windowFeatures = AddParam(windowFeatures, 'menuBar', settings.menubar); if (settings.dependent && !settings.modal) windowFeatures = AddParam(windowFeatures, 'dependent', 'yes'); var openLeft, openTop, win; if (settings.centerBrowser) { openTop = window.screenY + (((window.outerHeight / 2) - (settings.height / 2))); openLeft = window.screenX + (((window.outerWidth / 2) - (settings.width / 2))); } else if (settings.centerScreen) { openTop = (screen.height - settings.height) / 2; openLeft = (screen.width - settings.width) / 2; } else { openTop = settings.top; openLeft = settings.left; } windowFeatures = AddParam(windowFeatures, (settings.modal ? 'dialogL' : 'l') + 'eft', Math.floor(openLeft) + (settings.modal ? 'px' : '')); windowFeatures = AddParam(windowFeatures, (settings.modal ? 'dialogT' : 't') + 'op', Math.floor(openTop) + (settings.modal ? 'px' : '')); win = window.open(settings.windowURL, settings.windowName, windowFeatures); win.focus(); return win; }