/*! * jQuery Modal Plugin v1.0 * http://bobcravens.com/ * * Copyright 2011, Bob Cravens * Dual licensed under the MIT or GPL Version 2 licenses. * http://bobcravens.com/files/license/mit-license.txt * http://bobcravens.com/files/license/gpl-license.txt * * Date: Wed Feb 25 12:00:00 2011 -0600 */ ;(function($){ // create namespace to use $.fn.modal = $.modal = {}; // close the modal dialog $.fn.modal.close = $.modal.close = function(){ $('.modal').slideUp('slow', function(){ $('#'+$.fn.modal.overlayId).fadeOut(); }); } // show the modal dialog $.fn.doModal = function(options){ var defaults = { controlsCssClass: 'controls', buttons: {} }; var options = $.extend(defaults, options); // ensure overlay exists in the dom if($.fn.modal.overlayId === undefined){ $.fn.modal.overlayId = uniqueId('overlay'); var html = "
"; var overlay = $(html).css({ 'display': 'none', 'background-color': '#000', 'position': 'absolute', 'top': 0, 'left': 0, 'z-index': topZIndex()+1, 'cursor': 'pointer' }).appendTo('body'); } var overlayId = $.fn.modal.overlayId; // create a unique id for the controls if($.fn.modal.controlsId === undefined){ $.fn.modal.controlsId = uniqueId('controls'); } var controlsId = $.fn.modal.controlsId; return this.each(function(){ // reposition the modal if sized $(window).resize(function(){ positionModal(); }) // grab some references var overlay = $('#'+overlayId); var modal = $(this); // set the minimal css on the modal modal.css({ 'position': 'absolute', 'z-index': overlay.css('z-index')+1 }).appendTo('body'); /* Note: The above appendTo moves the element to the end of the body tag. This is a work around for the