1/* 2 TopZIndex plugin for jQuery 3 Version: 1.2 4 5 http://topzindex.googlecode.com/ 6 7 Copyright (c) 2009-2011 Todd Northrop 8 http://www.speednet.biz/ 9 10 October 21, 2010 11 12 Calculates the highest CSS z-index value in the current document 13 or specified set of elements. Provides ability to push one or more 14 elements to the top of the z-index. Useful for dynamic HTML 15 popup windows/panels. 16 17 Based on original idea by Rick Strahl 18 http://west-wind.com/weblog/posts/876332.aspx 19 20 This program is free software: you can redistribute it and/or modify 21 it under the terms of the GNU General Public License as published by 22 the Free Software Foundation, either version 3 of the License, or 23 (at your option) any later version, subject to the following conditions: 24 25 The above copyright notice and this permission notice shall be 26 included in all copies or substantial portions of the Software. 27 28 This program is distributed in the hope that it will be useful, 29 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 GNU General Public License for more details. 32 33 You should have received a copy of the GNU General Public License 34 along with this program. If not, see <http://www.gnu.org/licenses/>. 35------------------------------------------------------*/ 36 37(function ($) { 38 39 $.topZIndex = function (selector) { 40 /// <summary> 41 /// Returns the highest (top-most) zIndex in the document 42 /// (minimum value returned: 0). 43 /// </summary> 44 /// <param name="selector" type="String" optional="true"> 45 /// (optional, default = "*") jQuery selector specifying 46 /// the elements to use for calculating the highest zIndex. 47 /// </param> 48 /// <returns type="Number"> 49 /// The minimum number returned is 0 (zero). 50 /// </returns> 51 52 return Math.max(0, Math.max.apply(null, $.map(((selector || "*") === "*")? $.makeArray(document.getElementsByTagName("*")) : $(selector), 53 function (v) { 54 return parseFloat($(v).css("z-index")) || null; 55 } 56 ))); 57 }; 58 59 $.fn.topZIndex = function (opt) { 60 /// <summary> 61 /// Increments the CSS z-index of each element in the matched set 62 /// to a value larger than the highest current zIndex in the document. 63 /// (i.e., brings all elements in the matched set to the top of the 64 /// z-index order.) 65 /// </summary> 66 /// <param name="opt" type="Object" optional="true"> 67 /// (optional) Options, with the following possible values: 68 /// increment: (Number, default = 1) increment value added to the 69 /// highest z-index number to bring an element to the top. 70 /// selector: (String, default = "*") jQuery selector specifying 71 /// the elements to use for calculating the highest zIndex. 72 /// </param> 73 /// <returns type="jQuery" /> 74 75 // Do nothing if matched set is empty 76 if (this.length === 0) { 77 return this; 78 } 79 80 opt = $.extend({ 81 increment: 1 82 }, opt); 83 84 // Get the highest current z-index value 85 var zmax = $.topZIndex(opt.selector), 86 inc = opt.increment; 87 88 // Increment the z-index of each element in the matched set to the next highest number 89 return this.each(function () { 90 this.style.zIndex = (zmax += inc); 91 }); 92 }; 93 94})(jQuery); 95
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.