Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected attachWidget(widget: Widget): void {
// Send a `'before-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);
}
// Add the widget's node to the parent.
this.parent!.node.appendChild(widget.node);
// Send an `'after-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);
}
// Post a fit request for the parent widget.
this.parent!.fit();
}
previousWidget.hide();
}
// Show the current widget.
if (currentWidget) {
currentWidget.show();
}
// Emit the `currentChanged` signal for the tab panel.
this._currentChanged.emit({
previousIndex, previousWidget, currentIndex, currentWidget
});
// Flush the message loop on IE and Edge to prevent flicker.
if (Platform.IS_EDGE || Platform.IS_IE) {
MessageLoop.flush();
}
}
protected attachWidget(widget: Widget): void {
// Send a `'before-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);
}
// Add the widget's node to the parent.
this.parent!.node.appendChild(widget.node);
// Send an `'after-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);
}
}
createBody(value: Body): Widget {
let body: Widget;
if (typeof value === 'string') {
body = new Widget({ node: document.createElement('span') });
body.node.textContent = value;
} else if (value instanceof Widget) {
body = value;
} else {
body = ReactWidget.create(value);
// Immediately update the body even though it has not yet attached in
// order to trigger a render of the DOM nodes from the React element.
MessageLoop.sendMessage(body, Widget.Msg.UpdateRequest);
}
body.addClass('jp-Dialog-body');
Styling.styleNode(body.node);
return body;
}
protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void {
// Send a `'before-detach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);
}
// Remove the widget's node from the parent.
this.parent!.node.removeChild(widget.node);
// Send an `'after-detach'` and message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);
}
// Look up the next sibling reference node.
let ref = this.parent!.node.children[toIndex];
// Send a `'before-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.BeforeAttach);
}
// Insert the widget's node before the sibling.
this.parent!.node.insertBefore(widget.node, ref);
// Send an `'after-attach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.AfterAttach);
function openRootMenu(menu: Menu, x: number, y: number, forceX: boolean, forceY: boolean): void {
// Ensure the menu is updated before attaching and measuring.
MessageLoop.sendMessage(menu, Widget.Msg.UpdateRequest);
// Get the current position and size of the main viewport.
let px = window.pageXOffset;
let py = window.pageYOffset;
let cw = document.documentElement.clientWidth;
let ch = document.documentElement.clientHeight;
// Compute the maximum allowed height for the menu.
let maxHeight = ch - (forceY ? y : 0);
// Fetch common variables.
let node = menu.node;
let style = node.style;
// Clear the menu geometry and prepare it for measuring.
style.top = '';
protected detachWidget(index: number, widget: Widget): void {
// Send a `'before-detach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.BeforeDetach);
}
// Remove the widget's node from the parent.
this.parent!.node.removeChild(widget.node);
// Send an `'after-detach'` message if the parent is attached.
if (this.parent!.isAttached) {
MessageLoop.sendMessage(widget, Widget.Msg.AfterDetach);
}
}
if (previousTitle) {
previousTitle.owner.hide();
}
// Show the current widget.
if (currentTitle) {
currentTitle.owner.show();
}
// Flush the message loop on IE and Edge to prevent flicker.
if (Platform.IS_EDGE || Platform.IS_IE) {
MessageLoop.flush();
}
// Schedule an emit of the layout modified signal.
MessageLoop.postMessage(this, Private.LayoutModified);
}
addWidget(widget: Widget, options: DockPanel.IAddOptions = {}): void {
// Add the widget to the layout.
if (this._mode === 'single-document') {
(this.layout as DockLayout).addWidget(widget);
} else {
(this.layout as DockLayout).addWidget(widget, options);
}
// Schedule an emit of the layout modified signal.
MessageLoop.postMessage(this, Private.LayoutModified);
}
private _evtMouseUp(event: MouseEvent): void {
// Do nothing if the left mouse button is not released.
if (event.button !== 0) {
return;
}
// Stop the event when releasing a handle.
event.preventDefault();
event.stopPropagation();
// Finalize the mouse release.
this._releaseMouse();
// Schedule an emit of the layout modified signal.
MessageLoop.postMessage(this, Private.LayoutModified);
}