1/* 2 * jQuery Reveal Plugin 1.0 3 * www.ZURB.com 4 * Copyright 2010, ZURB 5 * Free to use under the MIT license. 6 * http://www.opensource.org/licenses/mit-license.php 7*/ 8 9 10(function($) { 11 12/*--------------------------- 13 Defaults for Reveal 14----------------------------*/ 15 16/*--------------------------- 17 Listener for data-reveal-id attributes 18----------------------------*/ 19 20 $('a[data-reveal-id]').live('click', function(e) { 21 e.preventDefault(); 22 var modalLocation = $(this).attr('data-reveal-id'); 23 $('#'+modalLocation).reveal($(this).data()); 24 }); 25 26/*--------------------------- 27 Extend and Execute 28----------------------------*/ 29 30 $.fn.reveal = function(options) { 31 32 33 var defaults = { 34 animation: 'fadeAndPop', //fade, fadeAndPop, none 35 animationspeed: 300, //how fast animtions are 36 closeonbackgroundclick: true, //if you click background will modal close? 37 dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal 38 }; 39 40 //Extend dem' options 41 var options = $.extend({}, defaults, options); 42 43 return this.each(function() { 44 45/*--------------------------- 46 Global Variables 47----------------------------*/ 48 var modal = $(this), 49 topMeasure = parseInt(modal.css('top')), 50 topOffset = modal.height() + topMeasure, 51 locked = false, 52 modalBG = $('.reveal-modal-bg'); 53 54/*--------------------------- 55 Create Modal BG 56----------------------------*/ 57 if(modalBG.length == 0) { 58 modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal); 59 } 60 61/*--------------------------- 62 Open and add Closing Listeners 63----------------------------*/ 64 //Open Modal Immediately 65 openModal(); 66 67 //Close Modal Listeners 68 var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent',closeModal) 69 if(options.closeonbackgroundclick) { 70 modalBG.css({"cursor":"pointer"}) 71 modalBG.bind('click.modalEvent',closeModal) 72 } 73 74 75/*--------------------------- 76 Open & Close Animations 77----------------------------*/ 78 //Entrance Animations 79 function openModal() { 80 modalBG.unbind('click.modalEvent'); 81 $('.' + options.dismissmodalclass).unbind('click.modalEvent'); 82 if(!locked) { 83 lockModal(); 84 if(options.animation == "fadeAndPop") { 85 modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'}); 86 modalBG.fadeIn(options.animationspeed/2); 87 modal.delay(options.animationspeed/2).animate({ 88 "top": $(document).scrollTop()+topMeasure, 89 "opacity" : 1 90 }, options.animationspeed,unlockModal()); 91 } 92 if(options.animation == "fade") { 93 modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure}); 94 modalBG.fadeIn(options.animationspeed/2); 95 modal.delay(options.animationspeed/2).animate({ 96 "opacity" : 1 97 }, options.animationspeed,unlockModal()); 98 } 99 if(options.animation == "none") { 100 modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure}); 101 modalBG.css({"display":"block"}); 102 unlockModal() 103 } 104 } 105 } 106 107 //Closing Animation 108 function closeModal() { 109 if(!locked) { 110 lockModal(); 111 if(options.animation == "fadeAndPop") { 112 modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 113 modal.animate({ 114 "top": $(document).scrollTop()-topOffset, 115 "opacity" : 0 116 }, options.animationspeed/2, function() { 117 modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'}); 118 unlockModal(); 119 }); 120 } 121 if(options.animation == "fade") { 122 modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 123 modal.animate({ 124 "opacity" : 0 125 }, options.animationspeed, function() { 126 modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure}); 127 unlockModal(); 128 }); 129 } 130 if(options.animation == "none") { 131 modal.css({'visibility' : 'hidden', 'top' : topMeasure}); 132 modalBG.css({'display' : 'none'}); 133 } 134 } 135 } 136 137/*--------------------------- 138 Animations Locks 139----------------------------*/ 140 function unlockModal() { 141 locked = false;
142 } 143 function lockModal() { 144 locked = true; 145 } 146 147 });//each call 148 }//orbit plugin call 149})(jQuery); 150
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.