本文整理匯總了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();
});