本文整理汇总了TypeScript中@ephox/alloy.Button类的典型用法代码示例。如果您正苦于以下问题:TypeScript Button类的具体用法?TypeScript Button怎么用?TypeScript Button使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const field = function (name, placeholder) {
const inputSpec = Memento.record(Input.sketch({
placeholder,
onSetValue (input, data) {
// If the value changes, inform the container so that it can update whether the "x" is visible
AlloyTriggers.emit(input, NativeEvents.input());
},
inputBehaviours: Behaviour.derive([
Composing.config({
find: Option.some
}),
Tabstopping.config({ }),
Keying.config({
mode: 'execution'
})
]),
selectOnFocus: false
}));
const buttonSpec = Memento.record(
Button.sketch({
dom: UiDomFactory.dom('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),
action (button) {
const input = inputSpec.get(button);
Representing.setValue(input, '');
}
})
);
return {
name,
spec: Container.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-input-container"></div>'),
components: [
inputSpec.asSpec(),
buttonSpec.asSpec()
],
containerBehaviours: Behaviour.derive([
Toggling.config({
toggleClass: Styles.resolve('input-container-empty')
}),
Composing.config({
find (comp) {
return Option.some(inputSpec.get(comp));
}
}),
AddEventsBehaviour.config(clearInputBehaviour, [
// INVESTIGATE: Because this only happens on input,
// it won't reset unless it has an initial value
AlloyEvents.run(NativeEvents.input(), function (iContainer) {
const input = inputSpec.get(iContainer);
const val = Representing.getValue(input);
const f = val.length > 0 ? Toggling.off : Toggling.on;
f(iContainer);
})
])
])
})
};
};
示例2:
const renderClose = (providersBackstage: UiFactoryBackstageProviders) => {
return Button.sketch({
dom: {
tag: 'button',
classes: ['tox-button', 'tox-button--icon', 'tox-button--naked'],
attributes: {
'type': 'button',
'aria-label': providersBackstage.translate('Close'),
'title': providersBackstage.translate('Close'), // TODO tooltips: AP-213
}
},
components: [
{
dom: {
tag: 'div',
classes: ['tox-icon'],
innerHtml: '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg"><path d="M17.953 7.453L13.422 12l4.531 4.547-1.406 1.406L12 13.422l-4.547 4.531-1.406-1.406L10.578 12 6.047 7.453l1.406-1.406L12 10.578l4.547-4.531z" fill-rule="evenodd"></path></svg>'
}
}
],
action: (comp) => {
AlloyTriggers.emit(comp, formCancelEvent);
}
});
};
示例3: function
const sketch = function (editor): SketchSpec {
const pickerDom = {
tag: 'input',
attributes: { accept: 'image/*', type: 'file', title: '' },
// Visibility hidden so that it cannot be seen, and position absolute so that it doesn't
// disrupt the layout
styles: { visibility: 'hidden', position: 'absolute' }
};
const memPicker = Memento.record({
dom: pickerDom,
events: AlloyEvents.derive([
// Stop the event firing again at the button level
AlloyEvents.cutter(NativeEvents.click()),
AlloyEvents.run(NativeEvents.change(), function (picker, simulatedEvent) {
extractBlob(simulatedEvent).each(function (blob) {
addImage(editor, blob);
});
})
])
});
return Button.sketch({
dom: Buttons.getToolbarIconButton('image', editor),
components: [
memPicker.asSpec()
],
action (button) {
const picker = memPicker.get(button);
// Trigger a dom click for the file input
picker.element().dom().click();
}
});
};
示例4: function
const makeEditSwitch = function (webapp): AlloyComponent {
return GuiFactory.build(
Button.sketch({
dom: UiDomFactory.dom('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),
action () {
webapp.run(function (w) {
w.setReadOnly(false);
});
}
})
);
};
示例5: function
const forToolbar = function (clazz, action, extraBehaviours): SketchSpec {
return Button.sketch({
dom: UiDomFactory.dom('<span class="${prefix}-toolbar-button ${prefix}-icon-' + clazz + ' ${prefix}-icon"></span>'),
action,
buttonBehaviours: Merger.deepMerge(
Behaviour.derive([
Unselecting.config({ })
]),
extraBehaviours
)
});
};
示例6: function
const forToolbar = function (clazz, action, extraBehaviours, editor): SketchSpec {
return Button.sketch({
dom: getToolbarIconButton(clazz, editor),
action,
buttonBehaviours: Merger.deepMerge(
Behaviour.derive([
Unselecting.config({ })
]),
extraBehaviours
)
});
};
示例7: function
const navigationButton = function (direction, directionName, enabled) {
return Button.sketch({
dom: UiDomFactory.dom('<span class="${prefix}-icon-' + directionName + ' ${prefix}-icon"></span>'),
action (button) {
AlloyTriggers.emitWith(button, navigateEvent, { direction });
},
buttonBehaviours: Behaviour.derive([
Disabling.config({
disableClass: Styles.resolve('toolbar-navigation-disabled'),
disabled: !enabled
})
])
});
};
示例8:
const pClose = (onClose, providersBackstage: UiFactoryBackstageProviders) => ModalDialog.parts().close(
// Need to find a way to make it clear in the docs whether parts can be sketches
Button.sketch({
dom: {
tag: 'button',
classes: [ 'tox-button', 'tox-button--icon', 'tox-button--naked' ],
attributes: {
'type': 'button',
'aria-label': providersBackstage.translate('Close')
}
},
action: onClose,
buttonBehaviours: Behaviour.derive([
Tabstopping.config({ })
])
})
);
示例9: componentRenderPipeline
const renderCommonChoice = <T>(spec: CommonCollectionItemSpec, structure: ItemStructure, itemResponse: ItemResponse): AlloySpec => {
return Button.sketch({
dom: structure.dom,
components: componentRenderPipeline(structure.optComponents),
eventOrder: menuItemEventOrder,
buttonBehaviours: Behaviour.derive(
[
AddEventsBehaviour.config('item-events', [
AlloyEvents.run(NativeEvents.mouseover(), Focusing.focus)
]),
DisablingConfigs.item(spec.disabled)
]
),
action: spec.onAction
});
};
示例10:
const renderInputButton = (label: Option<string>, eventName: string, className: string, iconName: string, providersBackstage: UiFactoryBackstageProviders) => {
return AlloyButton.sketch({
dom: {
tag: 'button',
classes: [ ToolbarButtonClasses.Button, className ],
innerHtml: Icons.get(iconName, providersBackstage.icons),
attributes: {
title: providersBackstage.translate(label.getOr('')) // TODO: tooltips AP-213
}
},
buttonBehaviours: Behaviour.derive([
Tabstopping.config({})
]),
action: (component) => {
AlloyTriggers.emit(component, eventName);
}
});
};