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/*--------------------------- 56 Create Modal BG 57----------------------------*/ 58 if(modalBG.length == 0) { 59 modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal); 60 } 61 62/*--------------------------- 63 Open & Close Animations 64----------------------------*/ 65 //Entrance Animations 66 modal.bind('reveal:open', function () { 67 modalBG.unbind('click.modalEvent'); 68 $('.' + options.dismissmodalclass).unbind('click.modalEvent'); 69 if(!locked) { 70 lockModal(); 71 if(options.animation == "fadeAndPop") { 72 modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'}); 73 modalBG.fadeIn(options.animationspeed/2); 74 modal.delay(options.animationspeed/2).animate({ 75 "top": $(document).scrollTop()+topMeasure + 'px', 76 "opacity" : 1 77 }, options.animationspeed,unlockModal()); 78 } 79 if(options.animation == "fade") { 80 modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure}); 81 modalBG.fadeIn(options.animationspeed/2); 82 modal.delay(options.animationspeed/2).animate({ 83 "opacity" : 1 84 }, options.animationspeed,unlockModal()); 85 } 86 if(options.animation == "none") { 87 modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure}); 88 modalBG.css({"display":"block"}); 89 unlockModal() 90 } 91 } 92 modal.unbind('reveal:open'); 93 }); 94 95 //Closing Animation 96 modal.bind('reveal:close', function () { 97 if(!locked) { 98 lockModal(); 99 if(options.animation == "fadeAndPop") { 100 modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 101 modal.animate({ 102 "top": $(document).scrollTop()-topOffset + 'px', 103 "opacity" : 0 104 }, options.animationspeed/2, function() { 105 modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'}); 106 unlockModal(); 107 }); 108 } 109 if(options.animation == "fade") { 110 modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 111 modal.animate({ 112 "opacity" : 0 113 }, options.animationspeed, function() { 114 modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure}); 115 unlockModal(); 116 }); 117 } 118 if(options.animation == "none") { 119 modal.css({'visibility' : 'hidden', 'top' : topMeasure}); 120 modalBG.css({'display' : 'none'}); 121 } 122 } 123 modal.unbind('reveal:close'); 124 }); 125 126/*--------------------------- 127 Open and add Closing Listeners 128----------------------------*/ 129 //Open Modal Immediately 130 modal.trigger('reveal:open') 131
132 //Close Modal Listeners 133 var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent', function () { 134 modal.trigger('reveal:close') 135 }); 136 137 if(options.closeonbackgroundclick) { 138 modalBG.css({"cursor":"pointer"}) 139 modalBG.bind('click.modalEvent', function () { 140 modal.trigger('reveal:close') 141 }); 142 } 143 $('body').keyup(function(e) { 144 if(e.which===27){ modal.trigger('reveal:close'); } // 27 is the keycode for the Escape key 145 }); 146 147 148/*--------------------------- 149 Animations Locks 150----------------------------*/ 151 function unlockModal() { 152 locked = false; 153 } 154 function lockModal() { 155 locked = true; 156 } 157 158 });//each call 159 }//orbit plugin call 160})(jQuery); 161 162
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.