/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ import { Behaviour, Button, Container, Memento, Toggling, SketchSpec } from '@ephox/alloy'; import { Throttler } from '@ephox/katamari'; import Styles from '../../style/Styles'; import * as UiDomFactory from '../../util/UiDomFactory'; const sketch = function (onView, translate): SketchSpec { const memIcon = Memento.record( Container.sketch({ dom: UiDomFactory.dom('
'), containerBehaviours: Behaviour.derive([ Toggling.config({ toggleClass: Styles.resolve('mask-tap-icon-selected'), toggleOnExecute: false }) ]) }) ); const onViewThrottle = Throttler.first(onView, 200); return Container.sketch({ dom: UiDomFactory.dom(''), components: [ Container.sketch({ dom: UiDomFactory.dom(''), components: [ Button.sketch({ dom: UiDomFactory.dom(''), components: [ memIcon.asSpec() ], action (button) { onViewThrottle.throttle(); }, buttonBehaviours: Behaviour.derive([ Toggling.config({ toggleClass: Styles.resolve('mask-tap-icon-selected') }) ]) }) ] }) ] }); }; export default { sketch };