Permalink
Browse files

bringToFront() feature.

  • Loading branch information...
1 parent 89173ba commit a48d0885cd2fe05d159879c558b98ef362cf7b26 @rafalwrzeszcz rafalwrzeszcz committed Apr 13, 2011
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/ui/controls/dialog.js
View
@@ -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() {
@@ -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;
}
});

0 comments on commit a48d088

Please sign in to comment.