/************************************************************************************************************ * SIMPLE MODAL v 2.0 * © 2009 FISHBOWL MEDIA LLC * http://fishbowlmedia.com ***********************************************************************************************************/ (function ($) { /********************************** * CUSTOMIZE THE DEFAULT SETTINGS * Ex: * var _settings = { * id: 'modal', * src: function(sender){ * return jQuery(sender).attr('href'); * }, * width: 800, * height: 600 * } **********************************/ var _settings = { width: 800, // Use this value if not set in CSS or HTML height: 600, // Use this value if not set in CSS or HTML overlayOpacity: .85, // Use this value if not set in CSS or HTML id: 'modal', src: function (sender) { return jQuery(sender).attr('href'); }, fadeInSpeed: 0, fadeOutSpeed: 0 } /********************************** * DO NOT CUSTOMIZE BELOW THIS LINE **********************************/ $.modal = function (options) { return _modal(this, options); } $.modal.open = function () { _modal.open(); } $.modal.close = function () { _modal.close(); } $.fn.modal = function (options) { return _modal(this, options); } _modal = function (sender, params) { this.options = { parent: null, overlayOpacity: null, id: null, content: null, width: null, height: null, modalClassName: null, imageClassName: null, closeClassName: null, overlayClassName: null, src: null } this.options = $.extend({}, options, _defaults); this.options = $.extend({}, options, _settings); this.options = $.extend({}, options, params); this.close = function () { jQuery('.' + options.modalClassName + ', .' + options.overlayClassName).fadeOut(_settings.fadeOutSpeed, function () { jQuery(this).unbind().remove(); }); } this.open = function () { if (typeof options.src == 'function') { options.src = options.src(sender) } else { options.src = options.src || _defaults.src(sender); } var fileExt = /^.+\.((jpg)|(gif)|(jpeg)|(png)|(jpg))$/i; var contentHTML = ''; if (fileExt.test(options.src)) { contentHTML = '
'; } else { contentHTML = '