/* * Interspire Modal 1.0 * (c) 2008 Interspire Pty. Ltd. * * Based on SimpleModal 1.1.1 - jQuery Plugin * http://www.ericmmartin.com/projects/simplemodal/ * http://plugins.jquery.com/project/SimpleModal * http://code.google.com/p/simplemodal/ * * Copyright (c) 2007 Eric Martin - http://ericmmartin.com * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Revision: $Id$ * */ (function ($) { $.iModal = function(options) { return $.iModal.modal.init(options); }; $.modal = function() { }; $.modal.close = function () { return $.iModal.modal.close(true); }; $.iModal.close = function () { return $.iModal.modal.close(true); }; $.fn.iModal = function (options) { options = $.extend({}, { type: 'inline', inline: $(this).html() }, options); return $.iModal.modal.init(options); }; $.iModal.defaults = { overlay: 50, overlayCss: {}, containerCss: {}, close: true, closeTitle: 'Close', closeTxt: false, onOpen: null, onShow: null, onClose: null, onBeforeClose: null, onAjaxError: null, type: 'string', width: '630', buttons: '', title: '', method: 'get', top: '15%' }; $.iModal.modal = { options: null, init: function(options) { // Can\'t have more than one modal window open at a time if($('#ModalContentContainer').length > 0) { return this; } this.options = $.extend({}, $.iModal.defaults, options); if(this.options.type == 'inline') { this.options.data = $(this.options.inline).html(); $(this.options.inline).html(''); } this.generateModal(); return this; }, checkHeight: function() { var winHeight = $(window).height(); var modalHeight = $("#ModalContentContainer").height(); if(modalHeight > winHeight * .85) { // modal height spans below the fold if ($("#ModalContainer").css('top') == '15%') { // use 15% of the remaining win height as top var top = (winHeight - modalHeight) * 0.15; if (top < 0) { top = 0; } // this stays until window height changes top += $(window).scrollTop(); $("#ModalContainer").css({ position: 'absolute', top: (top + 'px') }); } } else { $("#ModalContainer").css({ position: 'fixed', top: '15%' }); } }, ajaxError: function(xhr, status, error) { this.hideLoader(); if ($.isFunction(this.options.onAjaxError)) { this.options.onAjaxError.apply(this, [xhr, status, error]); } }, createFrame: function(container, html) { var frame = $('