Changeset 1019


Ignore:
Timestamp:
08/15/08 19:53:53 (11 years ago)
Author:
nicholasbs
Message:

Initial fix for ticket #1264

  • option to close modal dialogs when escape key is pressed
  • turned off modeless dialogs for the time being as their implementation is currently incomplete (see #1264 for discussion)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new-dialogs/modules/Dialogs/XinhaDialog.js

    r1018 r1019  
    4343  this.layer = (options && options.layer) ? options.layer : 0; 
    4444  this.centered = (options && options.centered === true) ? true : false; 
    45    
     45  this.closeOnEscape = (options && options.closeOnEscape === true) ? true : false; 
     46 
    4647  /* Check global config to see if we should override any of the above options 
    4748    If a global option is set, it will apply to all dialogs, regardless of their 
     
    6364      this.modal = globalOptions.modal; 
    6465    } 
    65   } 
     66    if (typeof(globalOptions.closeOnEscape) != 'undefined') { 
     67      this.closeOnEscape = globalOptions.closeOnEscape; 
     68    } 
     69  } 
     70 
     71  /* NOTE: Support for modeless dialogs is incomplete and all current plugins 
     72  /* use modal dialogs, so I'm deactivating modeless dialogs until these issues are fixed 
     73  /* Outstanding issues with modeless dialogs: 
     74  /*   - it's possible new modeless dialogs will be opened behind other dialogs 
     75  /*   - there's no visual indication as to which modeless dialog is frontmost and has focus 
     76  /*   - closing one dialog does not cause the dialog behind it to gain focus 
     77  /*   - no active modeless dialog is set until one is clicked, i.e., none is set by just calling show() 
     78  /*   - you can type in a form field of a dialog even when it's not frontmost (and doing so doesn't activate it) 
     79  /* See discussion on ticket #1264: http://xinha.webfactional.com/ticket/1264 
     80  */ 
     81  this.modal = true; 
    6682 
    6783  if (Xinha.is_ie) 
     
    171187  } 
    172188  rootElem.appendChild(this.buttons); 
    173    
     189 
     190  if (this.closeOnEscape) 
     191  { 
     192    Xinha._addEvent(document, 'keypress', function(ev) { 
     193      if (ev.keyCode == 27) // ESC key 
     194      { 
     195        if (Xinha.Dialog.activeModeless == dialog || dialog.modal) 
     196        { 
     197          dialog.hide(); 
     198          return true; 
     199        } 
     200      } 
     201    }); 
     202  } 
     203 
    174204  this.closer = null; 
    175205  if ( this.closable ) 
Note: See TracChangeset for help on using the changeset viewer.