@@ -45,12 +45,17 @@ define(function (require, exports, module) {
4545 * remove the popup from the _popUps array when the popup is closed. Specify false
4646 * when the popup is always persistant in the _popUps array.
4747 * @param {object } options
48- * @param {boolean } options.popupManagesFocus - set to true if the popup manages focus restore on close
48+ * @param {boolean } [options.popupManagesFocus] - set to true if the popup manages focus restore on close
49+ * @param {boolean } [options.closeCurrentPopups] - set to true if you want to dismiss all exiting popups before
50+ * adding this. Useful when this should be the only popup visible.
4951 *
5052 */
5153 function addPopUp ( $popUp , removeHandler , autoRemove , options ) {
5254 autoRemove = autoRemove || false ;
5355 options = options || { } ;
56+ if ( options . closeCurrentPopups ) {
57+ closeAllPopups ( ) ;
58+ }
5459 const popupManagesFocus = options . popupManagesFocus || false ;
5560
5661 _popUps . push ( $popUp [ 0 ] ) ;
@@ -130,7 +135,7 @@ define(function (require, exports, module) {
130135 function _keydownCaptureListener ( keyEvent ) {
131136 // Escape key or Alt key (Windows-only)
132137 if ( keyEvent . keyCode !== KeyEvent . DOM_VK_ESCAPE &&
133- ! ( keyEvent . keyCode === KeyEvent . DOM_VK_ALT && brackets . platform === "win" ) ) {
138+ ! ( keyEvent . keyCode === KeyEvent . DOM_VK_ALT && brackets . platform === "win" ) ) {
134139 return ;
135140 }
136141
@@ -184,10 +189,14 @@ define(function (require, exports, module) {
184189 WorkspaceManager . addEscapeKeyEventHandler ( "PopUpManager" , _dontToggleWorkspacePanel ) ;
185190 } ) ;
186191
192+ function closeAllPopups ( ) {
193+ removeCurrentPopUp ( ) ;
194+ }
187195
188196 EventDispatcher . makeEventDispatcher ( exports ) ;
189197
190198 exports . addPopUp = addPopUp ;
191199 exports . removePopUp = removePopUp ;
200+ exports . closeAllPopups = closeAllPopups ;
192201 exports . listenToContextMenu = listenToContextMenu ;
193202} ) ;
0 commit comments