ModalBar
Import :
const ModalBar = brackets.getModule("widgets/ModalBar")
ModalBar
Kind: global class
- ModalBar
- new ModalBar(template, autoClose, animate)
- .isLockedOpen :
function
- .height() ⇒
number
- .prepareClose([restoreScrollPos])
- .close([restoreScrollPos], [animate], [_reason]) ⇒
$.Promise
- .getRoot() ⇒
jQueryObject
new ModalBar(template, autoClose, animate)
Creates a modal bar whose contents are the given template.
Dispatches one event:
- close - When the bar is closed, either via close() or via autoClose. After this event, the bar may remain visible and in the DOM while its closing animation is playing. However, by the time "close" is fired, the bar has been "popped out" of the layout and the editor scroll position has already been restored. Second argument is the reason for closing (one of ModalBar.CLOSE_*). Third argument is the Promise that close() will be returning.
Param | Type | Description |
---|---|---|
template | string | The HTML contents of the modal bar. |
autoClose | boolean | If true, then close the dialog if the user hits Esc or if the bar loses focus. |
animate | boolean | If true (the default), animate the dialog closed, otherwise close it immediately. |
modalBar.isLockedOpen : function
Allows client code to block autoClose from closing the ModalBar: if set, this function is called whenever autoClose would normally close the ModalBar. Returning true prevents the close from occurring. Programmatically calling close() will still close the bar, however.
Kind: instance property of ModalBar
modalBar.height() ⇒ number
Kind: instance method of ModalBar
Returns: number
- Height of the modal bar in pixels, if open.
modalBar.prepareClose([restoreScrollPos])
Prepares the ModalBar for closing by popping it out of the main flow and resizing/
rescrolling the Editor to maintain its current apparent code position. Useful if
you want to do that as a separate operation from actually animating the ModalBar
closed and removing it (for example, if you need to switch full editors in between).
If you don't call this explicitly, it will get called at the beginning of close()
.
Kind: instance method of ModalBar
Param | Type | Description |
---|---|---|
[restoreScrollPos] | boolean | If true (the default), adjust the scroll position of the editor to account for the ModalBar disappearing. If not set, the caller should do it immediately on return of this function (before the animation completes), because the editor will already have been resized. |
modalBar.close([restoreScrollPos], [animate], [_reason]) ⇒ $.Promise
Closes the modal bar and returns focus to the active editor. Returns a promise that is resolved when the bar is fully closed and the container is removed from the DOM.
Kind: instance method of ModalBar
Returns: $.Promise
- promise resolved when close is finished
Param | Type | Description |
---|---|---|
[restoreScrollPos] | boolean | If true (the default), adjust the scroll position of the editor to account for the ModalBar disappearing. If not set, the caller should do it immediately on return of this function (before the animation completes), because the editor will already have been resized. Note that this is ignored if prepareClose() was already called (you need to pass the parameter to that function if you call it first). |
[animate] | boolean | If true (the default), animate the closing of the ModalBar, otherwise close it immediately. |
[_reason] | string | For internal use only. |
modalBar.getRoot() ⇒ jQueryObject
Kind: instance method of ModalBar
Returns: jQueryObject
- A jQuery object representing the root of the ModalBar.
MainViewManager
A "modal bar" component. This is a lightweight replacement for modal dialogs that appears at the top of the editor area for operations like Find and Quick Open.
Kind: global variable