/* * 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', onOpen: null, onShow: null, onClose: null, onBeforeClose: null, type: 'string', width: '630', buttons: '', title: '' }; $.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; }, displayModal: function(data) { this.hideLoader(); modalContent = ''; if(!$.browser.msie || $.browser.version >= 7) { modalContent = '
'; } if(data.indexOf('ModalTitle')>0 && data.indexOf('ModalContent')>0){ modalContent += '
'+data+'
'; }else{ buttons = ''; if(this.options.buttons) { buttons = '
'+this.options.buttons+'
'; } modalContent += '
'+this.options.title+'
'+data+ '
'+buttons+'
'; } cssProperties = { position: 'fixed', zIndex: 3100, width: this.options.width+'px' }; if($.browser.msie && $.browser.version < 7) { cssProperties.position = 'absolute'; } // If direction is rtl then we need to flip our margin positions if ($.browser.msie && $.browser.version <= 7 && $('body').css('direction') == 'rtl') { cssProperties.marginRight = (this.options.width/2)+'px'; } else { cssProperties.marginLeft = '-'+(this.options.width/2)+'px'; } $('
') .attr('id', 'ModalContainer') .addClass('modalContainer') .css(cssProperties) .hide() .appendTo('body') .html('
'+modalContent+'
') ; if($('#ModalContainer').find('.ModalButtonRow, #ModalButtonRow').length > 0) { $('#ModalContainer').addClass('ModalContentWithButtons'); } if(this.options.close) { modal = this; $('') .addClass('modalClose') .attr('title', this.options.closeTitle) .appendTo('#ModalContainer') .click(function(e) { e.preventDefault(); modal.close(); }) ; $(document).bind('keypress', function(e) { if(e.keyCode == 27) { $('#ModalContainer .modalClose').click(); } }); } if($.isFunction(this.options.onOpen)) { this.options.onOpen.apply(this); } else { $('#ModalContainer').show(); if($.isFunction(this.options.onShow)) { this.options.onShow.apply(this); } } }, showLoader: function() { $('
') .attr('id', 'ModalLoadingIndicator') .appendTo('body'); ; }, showOverlayLoader: function(){ $('
') .attr('id', 'ModalOverlay') .addClass('modalOverlay') .css({ opacity: 50 / 100, height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, zIndex: 3000 }) .appendTo('body') ; $('
') .attr('id', 'ModalLoadingIndicator') .appendTo('body'); ; }, hideOverlayLoader: function(){ $('#ModalLoadingIndicator').remove(); $('.modalOverlay').remove(); }, hideLoader: function() { $('#ModalLoadingIndicator').remove(); }, generateModal: function() { $('
') .attr('id', 'ModalOverlay') .addClass('modalOverlay') .css({ opacity: this.options.overlay / 100, height: '100%', width: '100%', position: 'fixed', left: 0, top: 0, zIndex: 3000 }) .appendTo('body') ; if($.browser.msie && $.browser.version < 7) { wHeight = $(document.body).height()+'px'; wWidth = $(document.body).width()+'px'; $('#ModalOverlay').css({ position: 'absolute', height: wHeight, width: wWidth }); $('