Skip to content

Commit 752902c

Browse files
author
VersatilityWerks
committed
Completely removed z-index handling. It's now entirely CSS based
1 parent 47fcbba commit 752902c

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed

src/jAlert-v3.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jAlert-v3.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,10 @@
243243

244244
if( $('.ja_background').length < 1 )
245245
{
246-
var zIndex = alert.maxZIndex + 1;
247-
$('body').append('<div class="ja_background '+backgroundClasses.join(' ')+'" style="z-index: '+zIndex+'"></div>').fadeIn(alert.options.backgroundFadeSpeed);
246+
$('body').append('<div class="ja_background '+backgroundClasses.join(' ')+'"></div>').fadeIn(alert.options.backgroundFadeSpeed);
248247
}
249248
}
250249

251-
alert.maxZIndex = function(){
252-
Math.max.apply(null, $.map($('body > *'), function(e,n){
253-
if($(e).css('position')=='absolute')
254-
return parseInt($(e).css('z-index'))||1;
255-
})
256-
);
257-
}
258-
259250
alert.centerAlert = function()
260251
{
261252

@@ -422,10 +413,7 @@
422413
showBackground();
423414

424415
/* Put this one above the last one */
425-
var zIndex = alert.maxZIndex + 1,
426-
wrap = alertInstance.parents('.ja_wrap');
427-
428-
wrap.css('z-index', zIndex).show();
416+
var wrap = alertInstance.parents('.ja_wrap');
429417

430418
animateAlert('show', alertInstance);
431419

@@ -448,13 +436,9 @@
448436
/* Adds a new alert to the dom */
449437
var addAlert = function(content){
450438

451-
var html = '',
452-
topMost = $('.ja_wrap:last')[0];
453-
454-
/* Put this one above the last one */
455-
var zIndex =alert.maxZIndex + 1;
439+
var html = '';
456440

457-
html += '<div class="ja_wrap" style="z-index: '+zIndex+';">'+
441+
html += '<div class="ja_wrap">'+
458442
'<div class="jAlert '+classes.join(' ')+ '" style="' +styles.join(' ')+ '" id="' +alert.options.id+ '">'+
459443
'<div>';
460444

src/jAlert-v3.min.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ loader+"</div>";onAjaxCallbacks=alert.options.onOpen;alert.options.onOpen=[funct
5656
var anyAlertsVisible=function(){return $('.jAlert:visible').length;}
5757
var hideBackground=function(){$('.ja_background').fadeOut(alert.options.backgroundFadeSpeed,function(){$(this).remove();$('body').css('overflow','auto');});}
5858
var showBackground=function(){if($('.ja_background').length<1)
59-
{var zIndex=alert.maxZIndex+1;$('body').append('<div class="ja_background '+backgroundClasses.join(' ')+'" style="z-index: '+zIndex+'"></div>').fadeIn(alert.options.backgroundFadeSpeed);}}
60-
alert.maxZIndex=function(){Math.max.apply(null,$.map($('body > *'),function(e,n){if($(e).css('position')=='absolute')
61-
return parseInt($(e).css('z-index'))||1;}));}
59+
{$('body').append('<div class="ja_background '+backgroundClasses.join(' ')+'"></div>').fadeIn(alert.options.backgroundFadeSpeed);}}
6260
alert.centerAlert=function()
6361
{var viewportHeight=$(window).height(),alertHeight=alert.instance.height(),diff=viewportHeight-alertHeight;var top=diff/2;if(top>200)
6462
{top=top-100;}
@@ -107,11 +105,11 @@ if(removeOthers!==false)
107105
{removeOthers=true;}
108106
if(replaceOthers)
109107
{$('.jAlert:visible').closeAlert(removeOthers);}
110-
showBackground();var zIndex=alert.maxZIndex+1,wrap=alertInstance.parents('.ja_wrap');wrap.css('z-index',zIndex).show();animateAlert('show',alertInstance);if(typeof onClose=='function')
108+
showBackground();var wrap=alertInstance.parents('.ja_wrap');animateAlert('show',alertInstance);if(typeof onClose=='function')
111109
{alert.options.onClose=onClose;}
112110
window.setTimeout(function(){if(typeof onOpen=='function')
113111
{onOpen(alertInstance);}},alert.options.animationTimeout);}
114-
var addAlert=function(content){var html='',topMost=$('.ja_wrap:last')[0];var zIndex=alert.maxZIndex+1;html+='<div class="ja_wrap" style="z-index: '+zIndex+';">'+'<div class="jAlert '+classes.join(' ')+'" style="'+styles.join(' ')+'" id="'+alert.options.id+'">'+'<div>';if(alert.options.closeBtn)
112+
var addAlert=function(content){var html='';html+='<div class="ja_wrap">'+'<div class="jAlert '+classes.join(' ')+'" style="'+styles.join(' ')+'" id="'+alert.options.id+'">'+'<div>';if(alert.options.closeBtn)
115113
{html+="<div class='closejAlert ja_close";if(alert.options.closeBtnAlt)
116114
{html+=' ja_close_alt';}
117115
html+="'>X</div>";}

0 commit comments

Comments
 (0)