OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
themes
/
silver
/
main
/
ts
/
ui
/
dialog
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:40:48 AM
rwxr-xr-x
📄
AlertDialog.ts
1.7 KB
02/20/2020 06:38:15 AM
rw-r--r--
📄
Autocomplete.ts
1.78 KB
02/20/2020 06:38:15 AM
rw-r--r--
📄
Bar.ts
689 bytes
02/20/2020 06:38:16 AM
rw-r--r--
📄
BodyPanel.ts
2.11 KB
02/20/2020 06:38:16 AM
rw-r--r--
📄
Collection.ts
5.65 KB
02/20/2020 06:38:17 AM
rw-r--r--
📄
ColorInput.ts
5.81 KB
02/20/2020 06:38:17 AM
rw-r--r--
📄
ColorPicker.ts
4.06 KB
02/20/2020 06:38:19 AM
rw-r--r--
📄
ConfirmDialog.ts
2.13 KB
02/20/2020 06:38:19 AM
rw-r--r--
📄
CustomEditor.ts
2.04 KB
02/20/2020 06:38:20 AM
rw-r--r--
📄
Dialogs.ts
3.91 KB
02/20/2020 06:38:20 AM
rw-r--r--
📄
Dropzone.ts
4.89 KB
02/20/2020 06:38:21 AM
rw-r--r--
📄
Grid.ts
735 bytes
02/20/2020 06:38:21 AM
rw-r--r--
📄
IFrame.ts
3.3 KB
02/20/2020 06:38:22 AM
rw-r--r--
📄
Label.ts
1.29 KB
02/20/2020 06:38:22 AM
rw-r--r--
📄
SelectBox.ts
2.37 KB
02/20/2020 06:38:23 AM
rw-r--r--
📄
SizeInput.ts
4.96 KB
02/20/2020 06:38:23 AM
rw-r--r--
📄
TabPanel.ts
5.41 KB
02/20/2020 06:38:24 AM
rw-r--r--
📄
Table.ts
1.52 KB
02/20/2020 06:38:24 AM
rw-r--r--
📄
TextField.ts
4.24 KB
02/20/2020 06:38:25 AM
rw-r--r--
📄
TypeAheadInput.ts
1.31 KB
02/20/2020 06:38:26 AM
rw-r--r--
📄
UrlInput.ts
9.25 KB
02/20/2020 06:38:26 AM
rw-r--r--
📄
WindowManager.ts
6.3 KB
02/20/2020 06:38:27 AM
rw-r--r--
📁
imagetools
-
02/20/2020 06:42:42 AM
rwxr-xr-x
Editing: Collection.ts
Close
/** * 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 { AddEventsBehaviour, AlloyComponent, AlloyEvents, AlloyTriggers, Behaviour, EventFormat, FormField as AlloyFormField, Keying, NativeEvents, Replacing, Representing, SimulatedEvent, SketchSpec, SugarEvent, SystemEvents, Tabstopping, } from '@ephox/alloy'; import { Types } from '@ephox/bridge'; import { Arr, Fun } from '@ephox/katamari'; import { Attr, Element, Focus, Html, SelectorFind, Class } from '@ephox/sugar'; import { renderFormFieldWith, renderLabel } from 'tinymce/themes/silver/ui/alien/FieldLabeller'; import { detectSize } from '../alien/FlatgridAutodetect'; import { formActionEvent, formResizeEvent } from '../general/FormEvents'; import { deriveCollectionMovement } from '../menus/menu/MenuMovement'; import * as ItemClasses from '../menus/item/ItemClasses'; import { UiFactoryBackstageProviders } from '../../backstage/Backstage'; export const renderCollection = (spec: Types.Collection.Collection, providersBackstage: UiFactoryBackstageProviders): SketchSpec => { // DUPE with TextField. const pLabel = spec.label.map((label) => renderLabel(label, providersBackstage)); const runOnItem = (f: (c: AlloyComponent, tgt: Element, itemValue: string) => void) => <T extends EventFormat>(comp: AlloyComponent, se: SimulatedEvent<T>) => { SelectorFind.closest(se.event().target(), '[data-collection-item-value]').each((target) => { f(comp, target, Attr.get(target, 'data-collection-item-value')); }); }; const escapeAttribute = (ch) => { if (ch === '"') { return '"'; } return ch; }; const setContents = (comp, items) => { const htmlLines = Arr.map(items, (item) => { const textContent = spec.columns === 1 ? `<div class="tox-collection__item-label">${item.text}</div>` : ''; const iconContent = `<div class="tox-collection__item-icon">${item.icon}</div>`; // Replacing the hyphens and underscores in collection items with spaces // to ensure the screen readers pronounce the words correctly. // This is only for aria purposes. Emoticon and Special Character names will still use _ and - for autocompletion. const mapItemName = { '_': ' ', ' - ': ' ', '-': ' ' }; // Title attribute is added here to provide tooltips which might be helpful to sighted users. // Using aria-label here overrides the Apple description of emojis and special characters in Mac/ MS description in Windows. // But if only the title attribute is used instead, the names are read out twice. i.e., the description followed by the item.text. const ariaLabel = item.text.replace(/\_| \- |\-/g, (match) => { return mapItemName[match]; }); return `<div class="tox-collection__item" tabindex="-1" data-collection-item-value="${escapeAttribute(item.value)}" title="${ariaLabel}" aria-label="${ariaLabel}">${iconContent}${textContent}</div>`; }); const chunks = spec.columns > 1 && spec.columns !== 'auto' ? Arr.chunk(htmlLines, spec.columns) : [ htmlLines ]; const html = Arr.map(chunks, (ch) => { return `<div class="tox-collection__group">${ch.join('')}</div>`; }); Html.set(comp.element(), html.join('')); }; const collectionEvents = [ AlloyEvents.run<SugarEvent>(NativeEvents.mouseover(), runOnItem((comp, tgt) => { Focus.focus(tgt); })), AlloyEvents.run<SugarEvent>(SystemEvents.tapOrClick(), runOnItem((comp, tgt, itemValue) => { AlloyTriggers.emitWith(comp, formActionEvent, { name: spec.name, value: itemValue }); })), AlloyEvents.run(NativeEvents.focusin(), runOnItem((comp, tgt, itemValue) => { SelectorFind.descendant(comp.element(), '.' + ItemClasses.activeClass).each((currentActive) => { Class.remove(currentActive, ItemClasses.activeClass); }); Class.add(tgt, ItemClasses.activeClass); })), AlloyEvents.run(NativeEvents.focusout(), runOnItem((comp, tgt, itemValue) => { SelectorFind.descendant(comp.element(), '.' + ItemClasses.activeClass).each((currentActive) => { Class.remove(currentActive, ItemClasses.activeClass); }); })), AlloyEvents.runOnExecute(runOnItem((comp, tgt, itemValue) => { AlloyTriggers.emitWith(comp, formActionEvent, { name: spec.name, value: itemValue }); })) ]; const pField = AlloyFormField.parts().field({ dom: { tag: 'div', // FIX: Read from columns classes: [ 'tox-collection' ].concat(spec.columns !== 1 ? [ 'tox-collection--grid' ] : [ 'tox-collection--list' ]) }, components: [ ], factory: { sketch: Fun.identity }, behaviours: Behaviour.derive([ Replacing.config({ }), Representing.config({ store: { mode: 'memory', initialValue: [ ] }, onSetValue: (comp, items) => { setContents(comp, items); if (spec.columns === 'auto') { detectSize(comp, 5, 'tox-collection__item').each(({ numRows, numColumns }) => { Keying.setGridSize(comp, numRows, numColumns); }); } AlloyTriggers.emit(comp, formResizeEvent); } }), Tabstopping.config({ }), Keying.config( deriveCollectionMovement(spec.columns, 'normal') ), AddEventsBehaviour.config('collection-events', collectionEvents) ]) }); const extraClasses = ['tox-form__group--collection']; return renderFormFieldWith(pLabel, pField, extraClasses); };