Skip to content
This repository
Browse code

bringToFront() feature.

  • Loading branch information...
commit a48d0885cd2fe05d159879c558b98ef362cf7b26 1 parent 89173ba
Rafał Wrzeszcz rafalwrzeszcz authored

Showing 1 changed file with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. +30 0 src/ui/controls/dialog.js
30 src/ui/controls/dialog.js
@@ -160,6 +160,8 @@
160 160 keypress: this.keypress.bind(this)
161 161 };
162 162
  163 + // brings window on top when it's region is clicked
  164 + this.element.on('click', this.bringToFront.bind(this) );
163 165 },
164 166
165 167 toElement: function() {
@@ -370,6 +372,34 @@
370 372 (function() { next.focus(); }).defer();
371 373 }
372 374 }
  375 + },
  376 +
  377 + /**
  378 + * S2.UI.Dialog#bringToFront() -> this
  379 + *
  380 + * Brings dialog on top of display stack.
  381 + *
  382 + * This method ignores elements, that has class ".alwaysOnTop".
  383 + **/
  384 + bringToFront: function() {
  385 + var zIndex = parseInt( this.element.getStyle('zIndex') || 1);
  386 +
  387 + // searches for the gighest zIndex value
  388 + // alwaysOnTop - class reserved for further "alwaysOnTop" feature
  389 + $$('body *:not(.alwaysOnTop)').each( function(element) {
  390 + var position = element.getStyle('position');
  391 + if (element !== this && (position == 'absolute' || position == 'fixed')) {
  392 + var value = parseInt( element.getStyle('zIndex') );
  393 + if ( !isNaN(value) && value > zIndex) {
  394 + zIndex = value;
  395 + }
  396 + }
  397 + }.bind(this) );
  398 +
  399 + // puts window one step higher then current most top.
  400 + this.element.setStyle( { zIndex: zIndex + 1 } );
  401 +
  402 + return this;
373 403 }
374 404 });
375 405

0 comments on commit a48d088

Please sign in to comment.
Something went wrong with that request. Please try again.