本文整理汇总了TypeScript中phosphor/lib/ui/widget.Widget类的典型用法代码示例。如果您正苦于以下问题:TypeScript Widget类的具体用法?TypeScript Widget怎么用?TypeScript Widget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Widget类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createKernelNameItem
function createKernelNameItem(kernelOwner: IKernelOwner): Widget {
let widget = new Widget();
widget.addClass(TOOLBAR_KERNEL_CLASS);
updateKernelNameItem(widget, kernelOwner.kernel);
kernelOwner.kernelChanged.connect(() => {
updateKernelNameItem(widget, kernelOwner.kernel);
});
return widget;
}
示例2: it
it('should save when clicked', () => {
let button = ToolbarItems.createSaveButton(panel);
Widget.attach(button, document.body);
button.node.click();
expect(context.methods).to.contain('save');
button.dispose();
});
示例3: it
it('should create a widget for a simple realistic model', () => {
let model = new NotebookMergeModel(
notebook, NBdecisions);
let widget = new NotebookMergeWidget(model, rendermime);
expect(widget).to.not.be(null);
Widget.attach(widget, document.body);
});
示例4: function
return Promise.resolve(view).then((view) => {
PWidget.Widget.attach(view.pWidget, this.el);
view.on('remove', function() {
console.log('view removed', view);
});
return view;
});
示例5: function
return Promise.resolve(view).then(function(view) {
PhosphorWidget.Widget.attach(view.pWidget, options.el);
view.on('remove', function() {
console.log('View removed', view);
});
return view;
});
示例6: insertWidget
/**
* Insert a widget into the tab panel at a specified index.
*
* @param index - The index at which to insert the widget.
*
* @param widget - The widget to insert into to the tab panel.
*
* #### Notes
* If the widget is already contained in the panel, it will be moved.
*
* The widget's `title` is used to populate the tab.
*/
insertWidget(index: number, widget: Widget): void {
if (widget !== this.currentWidget) {
widget.hide();
}
this._tabContents.insertWidget(index, widget);
this._tabBar.insertTab(index, widget.title);
}
示例7: constructor
/**
* Create a dialog panel instance.
*
* @param options - The dialog setup options.
*
* @param resolve - The function that resolves the dialog promise.
*
* @param reject - The function that rejects the dialog promise.
*
* #### Notes
* Currently the dialog resolves with `cancelButton` rather than
* rejecting the dialog promise.
*/
constructor(options: IDialogOptions, resolve: (value: IButtonItem) => void, reject?: (error: any) => void) {
super();
if (!(options.body instanceof Widget)) {
throw 'A widget dialog can only be created with a widget as its body.';
}
this.resolve = resolve;
this.reject = reject;
// Create the dialog nodes (except for the buttons).
let content = new Panel();
let header = new Widget({node: document.createElement('div')});
let body = new Panel();
let footer = new Widget({node: document.createElement('div')});
let title = document.createElement('span');
this.addClass(DIALOG_CLASS);
if (options.dialogClass) {
this.addClass(options.dialogClass);
}
content.addClass(CONTENT_CLASS);
header.addClass(HEADER_CLASS);
body.addClass(BODY_CLASS);
footer.addClass(FOOTER_CLASS);
title.className = TITLE_CLASS;
this.addWidget(content);
content.addWidget(header);
content.addWidget(body);
content.addWidget(footer);
header.node.appendChild(title);
// Populate the nodes.
title.textContent = options.title || '';
let child = options.body as Widget;
child.addClass(BODY_CONTENT_CLASS);
body.addWidget(child);
this._buttons = options.buttons.slice();
this._buttonNodes = options.buttons.map(createButton);
this._buttonNodes.map(buttonNode => {
footer.node.appendChild(buttonNode);
});
let primary = options.primary || this.lastButtonNode;
if (typeof primary === 'number') {
primary = this._buttonNodes[primary];
}
this._primary = primary as HTMLElement;
}
示例8: it
it('should insert below when clicked', () => {
let button = ToolbarItems.createInsertButton(panel);
Widget.attach(button, document.body);
button.node.click();
expect(panel.content.activeCellIndex).to.be(1);
expect(panel.content.activeCell).to.be.a(CodeCellWidget);
button.dispose();
});