1/** 2 * @license 3 * jQuery Tools @VERSION / Expose - Dim the lights 4 * 5 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE. 6 * 7 * http://flowplayer.org/tools/toolbox/expose.html 8 * 9 * Since: Mar 2010 10 * Date: @DATE 11 */ 12(function($) { 13 14 // static constructs 15 $.tools = $.tools || {version: '@VERSION'}; 16 17 var tool; 18 19 tool = $.tools.expose = { 20 21 conf: { 22 maskId: 'exposeMask', 23 loadSpeed: 'slow', 24 closeSpeed: 'fast', 25 closeOnClick: true, 26 closeOnEsc: true, 27 28 // css settings 29 zIndex: 9998, 30 opacity: 0.8, 31 startOpacity: 0, 32 color: '#fff', 33 34 // callbacks 35 onLoad: null, 36 onClose: null 37 } 38 }; 39 40 /* one of the greatest headaches in the tool. finally made it */ 41 function viewport() { 42 43 // the horror case 44 if (/msie/.test(navigator.userAgent.toLowerCase())) { 45 46 // if there are no scrollbars then use window.height 47 var d = $(document).height(), w = $(window).height(); 48 49 return [ 50 window.innerWidth || // ie7+ 51 document.documentElement.clientWidth || // ie6 52 document.body.clientWidth, // ie6 quirks mode 53 d - w < 20 ? w : d 54 ]; 55 } 56 57 // other well behaving browsers 58 return [$(document).width(), $(document).height()]; 59 } 60 61 function call(fn) { 62 if (fn) { return fn.call($.mask); } 63 } 64 65 var mask, exposed, loaded, config, overlayIndex; 66 67 68 $.mask = { 69 70 load: function(conf, els) { 71 72 // already loaded ? 73 if (loaded) { return this; } 74 75 // configuration 76 if (typeof conf == 'string') { 77 conf = {color: conf}; 78 } 79 80 // use latest config 81 conf = conf || config; 82 83 config = conf = $.extend($.extend({}, tool.conf), conf); 84 85 // get the mask 86 mask = $("#" + conf.maskId); 87 88 // or create it 89 if (!mask.length) { 90 mask = $('<div/>').attr("id", conf.maskId); 91 $("body").append(mask); 92 } 93 94 // set position and dimensions 95 var size = viewport(); 96 97 mask.css({ 98 position:'absolute', 99 top: 0, 100 left: 0, 101 width: size[0], 102 height: size[1], 103 display: 'none', 104 opacity: conf.startOpacity, 105 zIndex: conf.zIndex 106 }); 107 108 if (conf.color) { 109 mask.css("backgroundColor", conf.color); 110 } 111 112 // onBeforeLoad 113 if (call(conf.onBeforeLoad) === false) { 114 return this; 115 } 116 117 // esc button 118 if (conf.closeOnEsc) { 119 $(document).on("keydown.mask", function(e) { 120 if (e.keyCode == 27) { 121 $.mask.close(e); 122 } 123 }); 124 } 125 126 // mask click closes 127 if (conf.closeOnClick) { 128 mask.on("click.mask", function(e) { 129 $.mask.close(e); 130 }); 131 } 132 133 // resize mask when window is resized 134 $(window).on("resize.mask", function() { 135 $.mask.fit(); 136 }); 137 138 // exposed elements 139 if (els && els.length) { 140 141 overlayIndex = els.eq(0).css("zIndex"); 142 143 // make sure element is positioned absolutely or relatively 144 $.each(els, function() { 145 var el = $(this); 146 if (!/relative|absolute|fixed/i.test(el.css("position"))) { 147 el.css("position", "relative"); 148 } 149 }); 150 151 // make elements sit on top of the mask 152 exposed = els.css({ zIndex: Math.max(conf.zIndex + 1, overlayIndex == 'auto' ? 0 : overlayIndex)}); 153 } 154 155 // reveal mask 156 mask.css({display: 'block'}).fadeTo(conf.loadSpeed, conf.opacity, function() { 157 $.mask.fit(); 158 call(conf.onLoad); 159 loaded = "full"; 160 }); 161 162 loaded = true; 163 return this; 164 }, 165 166 close: function() { 167 if (loaded) { 168 169 // onBeforeClose 170 if (call(config.onBeforeClose) === false) { return this; } 171 172 mask.fadeOut(config.closeSpeed, function() { 173 if (exposed) { 174 exposed.css({zIndex: overlayIndex}); 175 } 176 loaded = false; 177 call(config.onClose); 178 }); 179 180 // unbind various event listeners 181 $(document).off("keydown.mask"); 182 mask.off("click.mask"); 183 $(window).off("resize.mask"); 184 } 185 186 return this; 187 }, 188 189 fit: function() { 190 if (loaded) { 191 var size = viewport(); 192 mask.css({width: size[0], height: size[1]}); 193 } 194 }, 195 196 getMask: function() { 197 return mask; 198 }, 199 200 isLoaded: function(fully) { 201 return fully ? loaded == 'full' : loaded; 202 }, 203 204 getConf: function() { 205 return config; 206 }, 207 208 getExposed: function() { 209 return exposed; 210 } 211 }; 212 213 $.fn.mask = function(conf) { 214 $.mask.load(conf); 215 return this; 216 }; 217 218 $.fn.expose = function(conf) { 219 $.mask.load(conf, this); 220 return this; 221 }; 222 223 224})(jQuery);
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.