Skip to content

Commit

Permalink
bringToFront() feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalwrzeszcz committed Apr 13, 2011
1 parent 89173ba commit a48d088
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ui/controls/dialog.js
Expand Up @@ -160,6 +160,8 @@
keypress: this.keypress.bind(this)
};

// brings window on top when it's region is clicked
this.element.on('click', this.bringToFront.bind(this) );
},

toElement: function() {
Expand Down Expand Up @@ -370,6 +372,34 @@
(function() { next.focus(); }).defer();
}
}
},

/**
* S2.UI.Dialog#bringToFront() -> this
*
* Brings dialog on top of display stack.
*
* This method ignores elements, that has class ".alwaysOnTop".
**/
bringToFront: function() {
var zIndex = parseInt( this.element.getStyle('zIndex') || 1);

// searches for the gighest zIndex value
// alwaysOnTop - class reserved for further "alwaysOnTop" feature
$$('body *:not(.alwaysOnTop)').each( function(element) {
var position = element.getStyle('position');
if (element !== this && (position == 'absolute' || position == 'fixed')) {
var value = parseInt( element.getStyle('zIndex') );
if ( !isNaN(value) && value > zIndex) {
zIndex = value;
}
}
}.bind(this) );

// puts window one step higher then current most top.
this.element.setStyle( { zIndex: zIndex + 1 } );

return this;
}
});

Expand Down

0 comments on commit a48d088

Please sign in to comment.