當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript alloy.Button類代碼示例

本文整理匯總了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);
          })
        ])
      ])
    })
  };
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:60,代碼來源:Inputs.ts

示例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);
    }
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:25,代碼來源:SilverDialogHeader.ts

示例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();
    }
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:35,代碼來源:ImagePicker.ts

示例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);
        });
      }
    })
  );
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:12,代碼來源:CommonRealm.ts

示例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
    )
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:13,代碼來源:Buttons.ts

示例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
    )
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:Buttons.ts

示例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
       })
     ])
   });
 };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:14,代碼來源:SerialisedDialog.ts

示例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({ })
    ])
  })
);
開發者ID:tinymce,項目名稱:tinymce,代碼行數:17,代碼來源:Dialogs.ts

示例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
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:17,代碼來源:CommonMenuItem.ts

示例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);
    }
  });
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:18,代碼來源:UrlInput.ts


注:本文中的@ephox/alloy.Button類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。