Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Hynds committed Mar 17, 2010
1 parent c25b9e2 commit 5bad651
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/jquery.visualizestack.js
Expand Up @@ -3,15 +3,16 @@
$.fn.visualizeStack = function(options){
options = $.extend({}, $.fn.visualizeStack.defaults, options);

var zindexes = [];
// this array will hold all the z-index values
var zindexes = [],

// We only want to keep elements that have a legitimate z-index.
// If this plugin is called like $("div").visualizeStack(), for
// example, not all divs in that selection could have a set z-index.
//
// Because the default z-index property value is "auto" we can
// safely assume a z-index was set if the value is numeric
var elems = this.filter(function(){
elems = this.filter(function(){
return /^-?\d+$/.test( $(this).css("z-index") );
})

Expand All @@ -25,11 +26,11 @@ $.fn.visualizeStack = function(options){
// z-indexes or just elements does not help us.
.map(function(){
var val = parseFloat( $(this).css("z-index") );
// add this zindex to an array of just z-indexes. we'll later take this
// array and determine how many of them are unique.

// add this zindex to an array of just z-indexes. we'll later use this
// array to determine how many of them are unique.
zindexes.push( val );

// return an object of the z-index and element
return { element:this, stack:val };
})
Expand Down Expand Up @@ -68,16 +69,16 @@ $.fn.visualizeStack = function(options){

// figure out how many unique z-index there are
var uniqueStacks = (function(){

// where we'll store the unique z-indexes
var uniques = [];

$.each(zindexes, function(i,val){
if($.inArray(val, uniques) === -1){
uniques.push(val);
}
});

return uniques.length;
})();

Expand Down

0 comments on commit 5bad651

Please sign in to comment.