jpf 5.0.3 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controls/codeMirror/Editor/Editor.d.ts +19 -0
- package/dist/controls/codeMirror/Editor/Editor.js +151 -0
- package/dist/controls/codeMirror/Editor/Editor.js.map +1 -0
- package/dist/controls/codeMirror/index.d.ts +1 -2
- package/dist/controls/codeMirror/index.js +1 -2
- package/dist/controls/codeMirror/index.js.map +1 -1
- package/dist/controls/custom/FileSelector/FileSelector.d.ts +18 -18
- package/dist/controls/custom/FileSelector/FileSelector.js +47 -46
- package/dist/controls/custom/FileSelector/FileSelector.js.map +1 -1
- package/dist/controls/custom/LabeledControl/LabeledControl.d.ts +15 -15
- package/dist/controls/custom/LabeledControl/LabeledControl.js +31 -36
- package/dist/controls/custom/LabeledControl/LabeledControl.js.map +1 -1
- package/dist/controls/custom/ListItem/ListItem.d.ts +37 -36
- package/dist/controls/custom/ListItem/ListItem.js +62 -62
- package/dist/controls/custom/ListItem/ListItem.js.map +1 -1
- package/dist/controls/custom/index.d.ts +3 -3
- package/dist/controls/custom/index.js +3 -3
- package/dist/controls/html/Button/Button.d.ts +16 -16
- package/dist/controls/html/Button/Button.js +47 -50
- package/dist/controls/html/Button/Button.js.map +1 -1
- package/dist/controls/html/Div/Div.d.ts +14 -14
- package/dist/controls/html/Div/Div.js +23 -24
- package/dist/controls/html/Div/Div.js.map +1 -1
- package/dist/controls/html/Image/Image.d.ts +16 -16
- package/dist/controls/html/Image/Image.js +29 -28
- package/dist/controls/html/Image/Image.js.map +1 -1
- package/dist/controls/html/Input/Input.d.ts +34 -34
- package/dist/controls/html/Input/Input.js +166 -170
- package/dist/controls/html/Input/Input.js.map +1 -1
- package/dist/controls/html/Select/Select.d.ts +30 -30
- package/dist/controls/html/Select/Select.js +109 -110
- package/dist/controls/html/Select/Select.js.map +1 -1
- package/dist/controls/html/Span/Span.d.ts +11 -11
- package/dist/controls/html/Span/Span.js +22 -22
- package/dist/controls/html/Span/Span.js.map +1 -1
- package/dist/controls/html/index.d.ts +6 -6
- package/dist/controls/html/index.js +6 -6
- package/dist/controls/index.d.ts +14 -14
- package/dist/controls/index.js +14 -14
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/index.d.ts +1 -1
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/index.js +1 -1
- package/dist/controls/jsonViewerAwesome/index.js.map +1 -0
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.d.ts +28 -0
- package/dist/controls/{jsonViewAwesome → jsonViewerAwesome}/jsonFormatter/JsonFormatter.js +65 -65
- package/dist/controls/jsonViewerAwesome/jsonFormatter/JsonFormatter.js.map +1 -0
- package/dist/controls/kendo/Chart/Chart.d.ts +19 -19
- package/dist/controls/kendo/Chart/Chart.js +62 -62
- package/dist/controls/kendo/Chart/Chart.js.map +1 -1
- package/dist/controls/kendo/Culture/Culture.d.ts +1 -1
- package/dist/controls/kendo/Culture/Culture.js +25 -25
- package/dist/controls/kendo/Culture/Culture.js.map +1 -1
- package/dist/controls/kendo/DataSource/DataSource.d.ts +4 -4
- package/dist/controls/kendo/DataSource/DataSource.js +1 -1
- package/dist/controls/kendo/Editor/Editor.d.ts +14 -19
- package/dist/controls/kendo/Editor/Editor.js +94 -104
- package/dist/controls/kendo/Editor/Editor.js.map +1 -1
- package/dist/controls/kendo/Grid/Grid.d.ts +54 -54
- package/dist/controls/kendo/Grid/Grid.js +201 -218
- package/dist/controls/kendo/Grid/Grid.js.map +1 -1
- package/dist/controls/kendo/Menu/Menu.d.ts +15 -15
- package/dist/controls/kendo/Menu/Menu.js +90 -90
- package/dist/controls/kendo/Menu/Menu.js.map +1 -1
- package/dist/controls/kendo/ObservableObject/ObservableObject.d.ts +0 -5
- package/dist/controls/kendo/ObservableObject/ObservableObject.js +0 -34
- package/dist/controls/kendo/ObservableObject/ObservableObject.js.map +1 -1
- package/dist/controls/kendo/Treeview/Treeview.d.ts +17 -0
- package/dist/controls/kendo/{Tree/Tree.js → Treeview/Treeview.js} +107 -107
- package/dist/controls/kendo/Treeview/Treeview.js.map +1 -0
- package/dist/controls/kendo/Window/Window.d.ts +14 -0
- package/dist/controls/kendo/{Dialog/Dialog.js → Window/Window.js} +49 -49
- package/dist/controls/kendo/Window/Window.js.map +1 -0
- package/dist/controls/kendo/index.d.ts +8 -9
- package/dist/controls/kendo/index.js +8 -9
- package/dist/controls/kendo/index.js.map +1 -1
- package/dist/controls/leaflet/LabelControl/LabelControl.d.ts +12 -12
- package/dist/controls/leaflet/LabelControl/LabelControl.js +33 -33
- package/dist/controls/leaflet/LabelControl/LabelControl.js.map +1 -1
- package/dist/controls/leaflet/Map/Map.d.ts +45 -45
- package/dist/controls/leaflet/Map/Map.js +116 -115
- package/dist/controls/leaflet/Map/Map.js.map +1 -1
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.d.ts +8 -8
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js +13 -13
- package/dist/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.js.map +1 -1
- package/dist/controls/leaflet/PointerEvent/PointerEvent.d.ts +2 -2
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js +7 -7
- package/dist/controls/leaflet/PointerEvent/PointerEvent.js.map +1 -1
- package/dist/controls/leaflet/index.d.ts +4 -4
- package/dist/controls/leaflet/index.js +4 -4
- package/dist/controls/svg/Circle/Circle.d.ts +12 -12
- package/dist/controls/svg/Circle/Circle.js +20 -20
- package/dist/controls/svg/Circle/Circle.js.map +1 -1
- package/dist/controls/svg/Ellipse/Ellipse.d.ts +13 -13
- package/dist/controls/svg/Ellipse/Ellipse.js +21 -21
- package/dist/controls/svg/Ellipse/Ellipse.js.map +1 -1
- package/dist/controls/svg/ForeignObject/ForeignObject.d.ts +15 -14
- package/dist/controls/svg/ForeignObject/ForeignObject.js +21 -22
- package/dist/controls/svg/ForeignObject/ForeignObject.js.map +1 -1
- package/dist/controls/svg/Group/Group.d.ts +15 -14
- package/dist/controls/svg/Group/Group.js +21 -22
- package/dist/controls/svg/Group/Group.js.map +1 -1
- package/dist/controls/svg/Line/Line.d.ts +13 -13
- package/dist/controls/svg/Line/Line.js +21 -21
- package/dist/controls/svg/Line/Line.js.map +1 -1
- package/dist/controls/svg/Pattern/Pattern.d.ts +22 -22
- package/dist/controls/svg/Pattern/Pattern.js +22 -23
- package/dist/controls/svg/Pattern/Pattern.js.map +1 -1
- package/dist/controls/svg/Polygon/Polygon.d.ts +11 -11
- package/dist/controls/svg/Polygon/Polygon.js +20 -20
- package/dist/controls/svg/Polygon/Polygon.js.map +1 -1
- package/dist/controls/svg/Polyline/Polyline.d.ts +11 -11
- package/dist/controls/svg/Polyline/Polyline.js +19 -19
- package/dist/controls/svg/Polyline/Polyline.js.map +1 -1
- package/dist/controls/svg/Rectangle/Rectangle.d.ts +13 -13
- package/dist/controls/svg/Rectangle/Rectangle.js +21 -21
- package/dist/controls/svg/Rectangle/Rectangle.js.map +1 -1
- package/dist/controls/svg/Svg/Svg.d.ts +17 -17
- package/dist/controls/svg/Svg/Svg.js +23 -24
- package/dist/controls/svg/Svg/Svg.js.map +1 -1
- package/dist/controls/svg/Text/Text.d.ts +14 -14
- package/dist/controls/svg/Text/Text.js +22 -22
- package/dist/controls/svg/Text/Text.js.map +1 -1
- package/dist/controls/svg/Title/Title.d.ts +10 -10
- package/dist/controls/svg/Title/Title.js +16 -16
- package/dist/controls/svg/Title/Title.js.map +1 -1
- package/dist/controls/svg/index.d.ts +13 -13
- package/dist/controls/svg/index.js +13 -13
- package/dist/controls/svg/svg.d.ts +6 -6
- package/dist/controls/svg/svg.js +12 -12
- package/dist/controls/svg/svg.js.map +1 -1
- package/dist/framework/attributes.d.ts +90 -90
- package/dist/framework/attributes.js +1 -1
- package/dist/framework/{View.d.ts → element.d.ts} +61 -62
- package/dist/framework/{View.js → element.js} +157 -150
- package/dist/framework/element.js.map +1 -0
- package/dist/framework/event.d.ts +80 -80
- package/dist/framework/event.js +25 -25
- package/dist/framework/event.js.map +1 -1
- package/dist/framework/observable.d.ts +37 -12
- package/dist/framework/observable.js +66 -58
- package/dist/framework/observable.js.map +1 -1
- package/dist/framework/properties.d.ts +40 -0
- package/dist/framework/{ViewModel.js → properties.js} +303 -312
- package/dist/framework/properties.js.map +1 -0
- package/dist/framework/root.d.ts +9 -0
- package/dist/framework/root.js +38 -0
- package/dist/framework/root.js.map +1 -0
- package/dist/framework/style.d.ts +657 -658
- package/dist/framework/style.js +146 -153
- package/dist/framework/style.js.map +1 -1
- package/dist/framework/types.d.ts +87 -87
- package/dist/framework/types.js +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/utilities/blob/blob.d.ts +1 -1
- package/dist/utilities/blob/blob.js +17 -17
- package/dist/utilities/blob/blob.js.map +1 -1
- package/dist/utilities/contextMenu/contextMenu.d.ts +2 -0
- package/dist/utilities/contextMenu/contextMenu.js +11 -0
- package/dist/utilities/contextMenu/contextMenu.js.map +1 -0
- package/dist/utilities/cookie/cookie.d.ts +3 -3
- package/dist/utilities/cookie/cookie.js +26 -26
- package/dist/utilities/cookie/cookie.js.map +1 -1
- package/dist/utilities/dataReaderTable/dataReaderTable.d.ts +9 -9
- package/dist/utilities/dataReaderTable/dataReaderTable.js +23 -23
- package/dist/utilities/dataReaderTable/dataReaderTable.js.map +1 -1
- package/dist/utilities/fetch/fetch.d.ts +7 -8
- package/dist/utilities/fetch/fetch.js +139 -137
- package/dist/utilities/fetch/fetch.js.map +1 -1
- package/dist/utilities/float/float.d.ts +1 -1
- package/dist/utilities/float/float.js +3 -3
- package/dist/utilities/formData/formData.d.ts +1 -1
- package/dist/utilities/formData/formData.js +11 -11
- package/dist/utilities/formData/formData.js.map +1 -1
- package/dist/utilities/formatting/formatting.d.ts +4 -0
- package/dist/utilities/formatting/formatting.js +26 -0
- package/dist/utilities/formatting/formatting.js.map +1 -0
- package/dist/utilities/htmlElement/htmlElement.d.ts +1 -1
- package/dist/utilities/htmlElement/htmlElement.js +16 -16
- package/dist/utilities/htmlElement/htmlElement.js.map +1 -1
- package/dist/utilities/image/image.d.ts +1 -1
- package/dist/utilities/image/image.js +1 -1
- package/dist/utilities/index.d.ts +40 -36
- package/dist/utilities/index.js +40 -36
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/integer/integer.d.ts +3 -3
- package/dist/utilities/integer/integer.js +27 -27
- package/dist/utilities/integer/integer.js.map +1 -1
- package/dist/utilities/key/key.d.ts +2 -2
- package/dist/utilities/key/key.js +6 -6
- package/dist/utilities/navigator/navigator.d.ts +1 -1
- package/dist/utilities/navigator/navigator.js +8 -8
- package/dist/utilities/navigator/navigator.js.map +1 -1
- package/dist/utilities/notification/notification.d.ts +5 -5
- package/dist/utilities/notification/notification.js +66 -66
- package/dist/utilities/notification/notification.js.map +1 -1
- package/dist/utilities/querystring/querystring.d.ts +6 -6
- package/dist/utilities/querystring/querystring.js +53 -53
- package/dist/utilities/querystring/querystring.js.map +1 -1
- package/dist/utilities/router/router.d.ts +19 -19
- package/dist/utilities/router/router.js +80 -80
- package/dist/utilities/router/router.js.map +1 -1
- package/dist/utilities/stylesheet/stylesheet.d.ts +2 -2
- package/dist/utilities/stylesheet/stylesheet.js +47 -47
- package/dist/utilities/stylesheet/stylesheet.js.map +1 -1
- package/dist/utilities/uniqueId/uniqueId.d.ts +1 -1
- package/dist/utilities/uniqueId/uniqueId.js +4 -4
- package/dist/{framework → utilities/userAgent}/userAgent.d.ts +31 -31
- package/dist/{framework → utilities/userAgent}/userAgent.js +46 -46
- package/dist/utilities/userAgent/userAgent.js.map +1 -0
- package/dist/utilities/webSocket/webSocket.d.ts +1 -1
- package/dist/utilities/webSocket/webSocket.js +54 -54
- package/dist/utilities/webSocket/webSocket.js.map +1 -1
- package/package.json +15 -11
- package/src/controls/codeMirror/Editor/Editor.ts +207 -0
- package/src/controls/codeMirror/index.ts +1 -2
- package/src/controls/custom/FileSelector/FileSelector.ts +30 -28
- package/src/controls/custom/LabeledControl/LabeledControl.ts +32 -36
- package/src/controls/custom/ListItem/ListItem.ts +36 -36
- package/src/controls/html/Button/Button.ts +36 -29
- package/src/controls/html/Div/Div.ts +20 -21
- package/src/controls/html/Image/Image.ts +22 -20
- package/src/controls/html/Input/Input.ts +59 -61
- package/src/controls/html/Select/Select.ts +37 -39
- package/src/controls/html/Span/Span.ts +14 -14
- package/src/controls/index.ts +2 -2
- package/src/controls/{jsonViewAwesome → jsonViewerAwesome}/jsonFormatter/JsonFormatter.ts +23 -23
- package/src/controls/kendo/Chart/Chart.ts +34 -34
- package/src/controls/kendo/DataSource/DataSource.ts +1 -1
- package/src/controls/kendo/Editor/Editor.ts +58 -68
- package/src/controls/kendo/Grid/Grid.ts +77 -80
- package/src/controls/kendo/Menu/Menu.ts +22 -22
- package/src/controls/kendo/ObservableObject/ObservableObject.ts +45 -45
- package/src/controls/kendo/{Tree/Tree.ts → Treeview/Treeview.ts} +15 -15
- package/src/controls/kendo/{Dialog/Dialog.ts → Window/Window.ts} +21 -19
- package/src/controls/kendo/index.ts +3 -3
- package/src/controls/leaflet/LabelControl/LabelControl.ts +10 -10
- package/src/controls/leaflet/Map/Map.ts +41 -38
- package/src/controls/leaflet/OpenStreetMapTileLayer/OpenStreetMapTileLayer.ts +3 -3
- package/src/controls/svg/Circle/Circle.ts +14 -14
- package/src/controls/svg/Ellipse/Ellipse.ts +15 -15
- package/src/controls/svg/ForeignObject/ForeignObject.ts +19 -20
- package/src/controls/svg/Group/Group.ts +19 -19
- package/src/controls/svg/Line/Line.ts +15 -15
- package/src/controls/svg/Pattern/Pattern.ts +25 -25
- package/src/controls/svg/Polygon/Polygon.ts +13 -13
- package/src/controls/svg/Polyline/Polyline.ts +13 -13
- package/src/controls/svg/Rectangle/Rectangle.ts +15 -15
- package/src/controls/svg/Svg/Svg.ts +19 -19
- package/src/controls/svg/Text/Text.ts +16 -16
- package/src/controls/svg/Title/Title.ts +12 -12
- package/src/controls/svg/svg.ts +4 -4
- package/src/framework/attributes.ts +46 -46
- package/src/framework/{View.ts → element.ts} +52 -39
- package/src/framework/event.ts +7 -7
- package/src/framework/observable.ts +94 -60
- package/src/framework/properties.ts +393 -0
- package/src/framework/root.ts +45 -0
- package/src/framework/style.ts +330 -340
- package/src/index.ts +4 -4
- package/src/utilities/contextMenu/contextMenu.ts +16 -0
- package/src/utilities/fetch/fetch.ts +16 -14
- package/src/utilities/formatting/formatting.ts +29 -0
- package/src/utilities/index.ts +7 -3
- package/src/utilities/router/router.ts +3 -3
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.d.ts +0 -16
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js +0 -120
- package/dist/controls/codeMirror/HtmlEditor/HtmlEditor.js.map +0 -1
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.d.ts +0 -16
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js +0 -104
- package/dist/controls/codeMirror/JsonEditor/JsonEditor.js.map +0 -1
- package/dist/controls/jsonViewAwesome/index.js.map +0 -1
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.d.ts +0 -28
- package/dist/controls/jsonViewAwesome/jsonFormatter/JsonFormatter.js.map +0 -1
- package/dist/controls/kendo/Dialog/Dialog.d.ts +0 -14
- package/dist/controls/kendo/Dialog/Dialog.js.map +0 -1
- package/dist/controls/kendo/Tree/Tree.d.ts +0 -17
- package/dist/controls/kendo/Tree/Tree.js.map +0 -1
- package/dist/framework/View.js.map +0 -1
- package/dist/framework/ViewModel.d.ts +0 -42
- package/dist/framework/ViewModel.js.map +0 -1
- package/dist/framework/userAgent.js.map +0 -1
- package/dist/utilities/html/html.d.ts +0 -1
- package/dist/utilities/html/html.js +0 -8
- package/dist/utilities/html/html.js.map +0 -1
- package/src/controls/codeMirror/HtmlEditor/HtmlEditor.ts +0 -153
- package/src/controls/codeMirror/JsonEditor/JsonEditor.ts +0 -136
- package/src/framework/ViewModel.ts +0 -528
- package/src/utilities/html/html.ts +0 -8
- /package/src/controls/{jsonViewAwesome → jsonViewerAwesome}/index.ts +0 -0
- /package/src/{framework → utilities/userAgent}/userAgent.ts +0 -0
|
@@ -1,528 +0,0 @@
|
|
|
1
|
-
import { unwrap, Subscribable, isSubscribable, Subscription, isObservable } from "knockout";
|
|
2
|
-
import { CssProperty } from "./types";
|
|
3
|
-
import { userAgent } from "./userAgent";
|
|
4
|
-
import { EventListeners, UiElementEventMap, IEventListenerOptions, IGenericEventListener, IMouseEventListener, MouseEventListeners, mouseEvents, touchEvents, isGlobalEvent } from "./event";
|
|
5
|
-
import { Attributes, AttributesSubscribable } from "./attributes";
|
|
6
|
-
import { extend } from "jquery";
|
|
7
|
-
import { Style, StyleSubscribable, defaultStyle } from "./style"
|
|
8
|
-
|
|
9
|
-
export interface WebSocketMessageHandler {
|
|
10
|
-
handleWebSocketMessage: (message: any) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function handleWebSocketMessage(object: object, message: any) {
|
|
14
|
-
bubbleDownObjectTreeAndExecuteHandler(
|
|
15
|
-
object,
|
|
16
|
-
(object) => {
|
|
17
|
-
const webSocketMessageHandler = object as WebSocketMessageHandler;
|
|
18
|
-
if (webSocketMessageHandler.handleWebSocketMessage && typeof webSocketMessageHandler.handleWebSocketMessage === "function") {
|
|
19
|
-
//Call the handleWebSocketMessage method
|
|
20
|
-
webSocketMessageHandler.handleWebSocketMessage(message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//This function bubbles down an object tree
|
|
27
|
-
//The given handler is executed on the given object and all its child properties of type object
|
|
28
|
-
export function bubbleDownObjectTreeAndExecuteHandler(object: object, handler: (object) => void) {
|
|
29
|
-
//Find out if the object is an array
|
|
30
|
-
if (object.constructor === Array) {
|
|
31
|
-
for (const arrayEntry of object as Array<any>) {
|
|
32
|
-
if (typeof arrayEntry === "object") {
|
|
33
|
-
bubbleDownObjectTreeAndExecuteHandler(arrayEntry, handler);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
//Find out if the object implements the WebSocketMessageHandler interface
|
|
38
|
-
if (isSubscribable(object)) {
|
|
39
|
-
var unwrapped = unwrap(object);
|
|
40
|
-
if (typeof unwrapped === "object") {
|
|
41
|
-
bubbleDownObjectTreeAndExecuteHandler(unwrapped, handler);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
handler(object);
|
|
45
|
-
//Find out if the object has properties of type object
|
|
46
|
-
for (const key in Object.keys(object)) {
|
|
47
|
-
const property = object[key];
|
|
48
|
-
if (property && typeof property === "object") {
|
|
49
|
-
//Call handleWebSocketMessage method on the property to bubble down the object tree.
|
|
50
|
-
bubbleDownObjectTreeAndExecuteHandler(property, handler);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//#region Null check
|
|
58
|
-
export function isNullOrUndefined(value): boolean {
|
|
59
|
-
return value === null || typeof value === "undefined";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface Properties {
|
|
63
|
-
attributes?: Attributes | AttributesSubscribable;
|
|
64
|
-
classNames?: Array<string> | Subscribable<Array<string>>;
|
|
65
|
-
style?: Style | StyleSubscribable;
|
|
66
|
-
visible?: boolean | Subscribable<boolean>;
|
|
67
|
-
disabled?: boolean | Subscribable<boolean>;
|
|
68
|
-
innerHtml?: any | Subscribable<any>;
|
|
69
|
-
textContent?: string | Subscribable<string>;
|
|
70
|
-
addViewModelToDataObject?: boolean;
|
|
71
|
-
userSelectable?: boolean;
|
|
72
|
-
eventListeners?: EventListeners;
|
|
73
|
-
viewType?: string;
|
|
74
|
-
focused?: boolean | Subscribable<boolean>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export abstract class ViewModel implements Properties {
|
|
78
|
-
protected constructor(properties?: Properties) {
|
|
79
|
-
this.setProperties(this, properties);
|
|
80
|
-
}
|
|
81
|
-
setProperties<TProperties>(object: object, properties?: TProperties) {
|
|
82
|
-
if (properties) {
|
|
83
|
-
Object.keys(properties).forEach((property) => {
|
|
84
|
-
object[property] = properties[property];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
attributes?: Attributes | AttributesSubscribable;
|
|
90
|
-
classNames?: Array<string> | Subscribable<Array<string>>;
|
|
91
|
-
style?: Style | StyleSubscribable;
|
|
92
|
-
visible?: boolean | Subscribable<boolean>;
|
|
93
|
-
disabled?: boolean | Subscribable<boolean>;
|
|
94
|
-
innerHtml?: any | Subscribable<any>;
|
|
95
|
-
textContent?: string | Subscribable<string>;
|
|
96
|
-
addViewModelToDataObject?: boolean;
|
|
97
|
-
userSelectable?: boolean;
|
|
98
|
-
eventListeners?: EventListeners;
|
|
99
|
-
viewType?: string;
|
|
100
|
-
focused?: boolean | Subscribable<boolean>;
|
|
101
|
-
|
|
102
|
-
//protected getStyle(...cssProperties: Array<CssProperty>): Style {
|
|
103
|
-
// if (cssProperties && this.style) {
|
|
104
|
-
// const style: Style = {};
|
|
105
|
-
// cssProperties.forEach((cssProperty) => {
|
|
106
|
-
// style[cssProperty] = this.style[cssProperty] as never;
|
|
107
|
-
// });
|
|
108
|
-
// return style;
|
|
109
|
-
// }
|
|
110
|
-
|
|
111
|
-
// return null as Style;
|
|
112
|
-
//}
|
|
113
|
-
//protected getStyleValue(cssProperty: CssProperty): any {
|
|
114
|
-
// if (this.style) {
|
|
115
|
-
// return unwrap(this.style[cssProperty]);
|
|
116
|
-
// }
|
|
117
|
-
// return null;
|
|
118
|
-
//}
|
|
119
|
-
|
|
120
|
-
//addMouseEventListener(event: keyof MouseEventListeners, mouseEventListener: IMouseEventListener) {
|
|
121
|
-
// if (!this.eventListeners[event]) {
|
|
122
|
-
// this.eventListeners[event] = mouseEventListener;
|
|
123
|
-
// }
|
|
124
|
-
//}
|
|
125
|
-
|
|
126
|
-
//addEventListener(event: keyof EventListeners, genericEventListener: IGenericEventListener) {
|
|
127
|
-
// if (!this.eventListeners[event]) {
|
|
128
|
-
// this.eventListeners[event] = genericEventListener;
|
|
129
|
-
// }
|
|
130
|
-
//}
|
|
131
|
-
|
|
132
|
-
//setClasses(classNames: string[], replace: boolean) {
|
|
133
|
-
// if (isSubscribable(this.classNames)) {
|
|
134
|
-
|
|
135
|
-
// var currentClassNames = unwrap(this.classNames);
|
|
136
|
-
// if (replace) {
|
|
137
|
-
// currentClassNames = new Array<string>();
|
|
138
|
-
// }
|
|
139
|
-
|
|
140
|
-
// if (classNames) {
|
|
141
|
-
// classNames.forEach((className) => {
|
|
142
|
-
// currentClassNames.push(className);
|
|
143
|
-
// });
|
|
144
|
-
// }
|
|
145
|
-
// const observable = this.classNames;
|
|
146
|
-
// if (isObservable(observable)) {
|
|
147
|
-
// observable(currentClassNames);
|
|
148
|
-
// }
|
|
149
|
-
// }
|
|
150
|
-
//}
|
|
151
|
-
//setAttributes(attributes: Attributes) {
|
|
152
|
-
// if (attributes) {
|
|
153
|
-
// Object.keys(attributes).forEach((key) => {
|
|
154
|
-
// let newValue = attributes[key];
|
|
155
|
-
// if (newValue === null || newValue === undefined) {
|
|
156
|
-
// newValue = null;
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
// if (isSubscribable(this.attributes[key])) {
|
|
160
|
-
// this.attributes[key](unwrap(newValue));
|
|
161
|
-
// } else {
|
|
162
|
-
// this.attributes[key] = newValue;
|
|
163
|
-
// }
|
|
164
|
-
// });
|
|
165
|
-
// }
|
|
166
|
-
//}
|
|
167
|
-
//setStyle(style: Style): void {
|
|
168
|
-
// if (style) {
|
|
169
|
-
// Object.keys(style).forEach((key: string) => {
|
|
170
|
-
// let newValue = style[key];
|
|
171
|
-
// if (newValue === null || newValue === undefined) {
|
|
172
|
-
// if (userAgent.browser.isInternetExplorer) {
|
|
173
|
-
// //Setting a css style property to null does not work for internet explorer
|
|
174
|
-
// //so we reset to the default value for the given property.
|
|
175
|
-
// newValue = defaultStyle[key];
|
|
176
|
-
// } else {
|
|
177
|
-
// newValue = null;
|
|
178
|
-
// }
|
|
179
|
-
// }
|
|
180
|
-
|
|
181
|
-
// if (isSubscribable(this.style[key])) {
|
|
182
|
-
// this.style[key](unwrap(newValue));
|
|
183
|
-
// } else {
|
|
184
|
-
// this.style[key] = newValue;
|
|
185
|
-
// }
|
|
186
|
-
// });
|
|
187
|
-
// }
|
|
188
|
-
//}
|
|
189
|
-
//setVisible(visible: boolean) {
|
|
190
|
-
// const visibleObservable = this.visible;
|
|
191
|
-
// if (isSubscribable(visibleObservable)) {
|
|
192
|
-
// visibleObservable(visible);
|
|
193
|
-
// }
|
|
194
|
-
//}
|
|
195
|
-
//setDisabled(disabled: boolean) {
|
|
196
|
-
// const disableObservable = this.disabled;
|
|
197
|
-
// if (isSubscribable(disableObservable)) {
|
|
198
|
-
// disableObservable(disabled);
|
|
199
|
-
// }
|
|
200
|
-
//}
|
|
201
|
-
//setInnerHtml(innerHtml: string) {
|
|
202
|
-
// const innerHtmlObservable = this.innerHtml;
|
|
203
|
-
// if (isSubscribable(innerHtmlObservable)) {
|
|
204
|
-
// innerHtmlObservable(innerHtml);
|
|
205
|
-
// }
|
|
206
|
-
//}
|
|
207
|
-
|
|
208
|
-
//setTextContent(textContent: string) {
|
|
209
|
-
// const textContentObservable = this.textContent;
|
|
210
|
-
// if (isSubscribable(textContentObservable)) {
|
|
211
|
-
// textContentObservable(textContent);
|
|
212
|
-
// }
|
|
213
|
-
//}
|
|
214
|
-
|
|
215
|
-
//removeClasses(classNames: string[]) {
|
|
216
|
-
// const classNamesObservable = this.classNames;
|
|
217
|
-
// if (isSubscribable(classNamesObservable)) {
|
|
218
|
-
// const currentClassNames = unwrap(classNamesObservable);
|
|
219
|
-
// for (let i = 0; i < currentClassNames.length; i++) {
|
|
220
|
-
// if (classNames.includes(currentClassNames[i])) {
|
|
221
|
-
// currentClassNames.splice(i, 1);
|
|
222
|
-
// }
|
|
223
|
-
// }
|
|
224
|
-
// classNamesObservable(currentClassNames);
|
|
225
|
-
// }
|
|
226
|
-
//}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
//#region ViewModel helper functions
|
|
230
|
-
|
|
231
|
-
//Function to merge two viewModels. The source is applied to the target. Corresponding properties are overwritten in the target.
|
|
232
|
-
export function extendProperties<TResult = Properties, TTarget = Properties, TSource = Properties>(target: TTarget, source: TSource): TResult {
|
|
233
|
-
return extend(true, target, source) as any as TResult;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
//Functions to bind the viewModel to a html element
|
|
237
|
-
export function applyBindings(properties: Properties, element: HTMLElement, subscriptions: Array<Subscription>) {
|
|
238
|
-
element.setAttribute("viewtype", properties.viewType || "View");
|
|
239
|
-
|
|
240
|
-
if (properties.classNames) {
|
|
241
|
-
applyClassesToElement(unwrap<string[]>(properties.classNames), true, element);
|
|
242
|
-
|
|
243
|
-
if (isSubscribable(properties.classNames)) {
|
|
244
|
-
const subscription = properties.classNames.subscribe((classNames: Array<string>) => {
|
|
245
|
-
applyClassesToElement(classNames, true, element);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
if (subscriptions) {
|
|
249
|
-
subscriptions.push(subscription);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (properties.attributes) {
|
|
255
|
-
Object.keys(properties.attributes).forEach((key) => {
|
|
256
|
-
var value = properties.attributes[key];
|
|
257
|
-
applyAttributeToElement(key as keyof Attributes, unwrap(value), element);
|
|
258
|
-
if (isSubscribable(value)) {
|
|
259
|
-
const subscription = value.subscribe((newValue: string) => {
|
|
260
|
-
applyAttributeToElement(key as keyof Attributes, newValue, element);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
if (subscriptions) {
|
|
264
|
-
subscriptions.push(subscription);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (properties.style) {
|
|
271
|
-
Object.keys(properties.style).forEach((key) => {
|
|
272
|
-
const style = properties.style[key];
|
|
273
|
-
element.style[key] = unwrap(style);
|
|
274
|
-
if (isSubscribable(style)) {
|
|
275
|
-
const subscription = style.subscribe((newStyle) => {
|
|
276
|
-
element.style[key] = newStyle;
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
if (subscriptions) {
|
|
280
|
-
subscriptions.push(subscription);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (!isNullOrUndefined(properties.innerHtml)) {
|
|
287
|
-
element.innerHTML = unwrap(properties.innerHtml);
|
|
288
|
-
if (isSubscribable(properties.innerHtml)) {
|
|
289
|
-
const subscription = properties.innerHtml.subscribe((innerHtml: string) => {
|
|
290
|
-
element.innerHTML = innerHtml;
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
if (subscriptions) {
|
|
294
|
-
subscriptions.push(subscription);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (!isNullOrUndefined(properties.textContent)) {
|
|
300
|
-
element.textContent = unwrap(properties.textContent);
|
|
301
|
-
if (isSubscribable(properties.textContent)) {
|
|
302
|
-
const subscription = properties.textContent.subscribe((textContent: string) => {
|
|
303
|
-
if (element.hasChildNodes() && element.childNodes.length === 1 && element.childNodes[0].nodeType === 3) {
|
|
304
|
-
//The first child is a text node so the most efficient way is to use the nodeValue property
|
|
305
|
-
element.firstChild.nodeValue = textContent;
|
|
306
|
-
} else {
|
|
307
|
-
element.textContent = textContent;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
if (subscriptions) {
|
|
312
|
-
subscriptions.push(subscription);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
//Find out if the element is none selectable
|
|
318
|
-
if (properties.userSelectable === false) {
|
|
319
|
-
applyEventListenerToElement("selectstart", () => { return false; }, { passive: true }, element);
|
|
320
|
-
element.style.userSelect = "none";
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (properties.addViewModelToDataObject) {
|
|
324
|
-
if (!element["data"]) {
|
|
325
|
-
element["data"] = {};
|
|
326
|
-
}
|
|
327
|
-
element["data"].viewModel = properties;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (properties.eventListeners) {
|
|
331
|
-
applyEventListenersToElement(properties, element);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
applyVisibilityToElement(unwrap(properties.visible), element);
|
|
335
|
-
if (isSubscribable(properties.visible)) {
|
|
336
|
-
const subscription = properties.visible.subscribe((visible) => {
|
|
337
|
-
applyVisibilityToElement(visible, element);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
if (subscriptions) {
|
|
341
|
-
subscriptions.push(subscription);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
applyDisabledToElement(unwrap(properties.disabled), element);
|
|
346
|
-
if (isSubscribable(properties.disabled)) {
|
|
347
|
-
const subscription = properties.disabled.subscribe((disabled) => {
|
|
348
|
-
applyDisabledToElement(disabled, element);
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
if (subscriptions) {
|
|
352
|
-
subscriptions.push(subscription);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
applyFocusToElement(unwrap(properties.focused), element);
|
|
357
|
-
if (isSubscribable(properties.focused)) {
|
|
358
|
-
const subscription = properties.focused.subscribe((focused) => {
|
|
359
|
-
applyFocusToElement(focused, element);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
if (subscriptions) {
|
|
363
|
-
subscriptions.push(subscription);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function applyVisibilityToElement(visible: boolean, element: HTMLElement) {
|
|
369
|
-
if (visible === false) {
|
|
370
|
-
element.classList.add("hidden");
|
|
371
|
-
} else {
|
|
372
|
-
element.classList.remove("hidden");
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function applyDisabledToElement(disabled: boolean, element: HTMLElement) {
|
|
377
|
-
if (disabled) {
|
|
378
|
-
element.setAttribute("disabled", "disabled");
|
|
379
|
-
} else {
|
|
380
|
-
element.removeAttribute("disabled");
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function applyEventListenersToElement(viewModel: Properties, element: HTMLElement) {
|
|
385
|
-
//Add the eventListeners to the element
|
|
386
|
-
const clickEventListeners = new Array<IGenericEventListener>();
|
|
387
|
-
const doubleClickEventListeners = new Array<IGenericEventListener>();
|
|
388
|
-
|
|
389
|
-
Object.entries(viewModel.eventListeners).forEach((entry) => {
|
|
390
|
-
var eventName = entry[0] as keyof UiElementEventMap;
|
|
391
|
-
var eventListener = entry[1] as IGenericEventListener;
|
|
392
|
-
|
|
393
|
-
if (eventName === "click") {
|
|
394
|
-
clickEventListeners.push(eventListener);
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
if (eventName === "dblclick") {
|
|
398
|
-
doubleClickEventListeners.push(eventListener);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (eventName === "dragstart") {
|
|
403
|
-
element.setAttribute("draggable", "true");
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (isGlobalEvent(eventName)) {
|
|
407
|
-
applyEventListenerToElement(
|
|
408
|
-
eventName,
|
|
409
|
-
(event: Event) => {
|
|
410
|
-
if (eventListener.options) {
|
|
411
|
-
const options = eventListener.options as IEventListenerOptions;
|
|
412
|
-
const keyEvent = event as KeyboardEvent;
|
|
413
|
-
if (options.altKey && !keyEvent.altKey) {
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
if (options.shiftKey && !keyEvent.shiftKey) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
if (options.ctrlKey && !keyEvent.ctrlKey) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (options.eventKey && options.eventKey !== keyEvent.key) {
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
eventListener.listener.call(viewModel, event);
|
|
428
|
-
},
|
|
429
|
-
eventListener.options,
|
|
430
|
-
element
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
else if (mouseEvents[eventName] && userAgent.device.supportsMouseEvents) {
|
|
434
|
-
applyEventListenerToElement(eventName, eventListener.listener, eventListener.options, element);
|
|
435
|
-
}
|
|
436
|
-
else if (touchEvents[eventName] && userAgent.device.supportsTouchEvents) {
|
|
437
|
-
applyEventListenerToElement(eventName, eventListener.listener, eventListener.options, element);
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
clickEventListeners.forEach((clickEventListener) => {
|
|
442
|
-
if (userAgent.device.supportsTouchEvents) {
|
|
443
|
-
// ReSharper disable once Html.EventNotResolved
|
|
444
|
-
applyEventListenerToElement("tap", clickEventListener.listener, clickEventListener.options, element);
|
|
445
|
-
}
|
|
446
|
-
if (userAgent.device.supportsMouseEvents) {
|
|
447
|
-
applyEventListenerToElement("click", clickEventListener.listener, clickEventListener.options, element);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
doubleClickEventListeners.forEach((doubleClickEventListener) => {
|
|
452
|
-
if (userAgent.device.supportsTouchEvents) {
|
|
453
|
-
// ReSharper disable once Html.EventNotResolved
|
|
454
|
-
applyEventListenerToElement("dbltap", doubleClickEventListener.listener, doubleClickEventListener.options, element);
|
|
455
|
-
}
|
|
456
|
-
if (userAgent.device.supportsMouseEvents) {
|
|
457
|
-
applyEventListenerToElement("dblclick", doubleClickEventListener.listener, doubleClickEventListener.options, element);
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function applyEventListenerToElement(type: keyof UiElementEventMap, listener: (event: any) => any, options: IEventListenerOptions, element: HTMLElement) {
|
|
463
|
-
if (!type) {
|
|
464
|
-
throw new Error("type is mandatory");
|
|
465
|
-
}
|
|
466
|
-
if (!listener) {
|
|
467
|
-
throw new Error("listener is mandatory");
|
|
468
|
-
}
|
|
469
|
-
if (!options) {
|
|
470
|
-
options = {};
|
|
471
|
-
}
|
|
472
|
-
if (!options.passive) {
|
|
473
|
-
options.passive = false;
|
|
474
|
-
}
|
|
475
|
-
if (!options.once) {
|
|
476
|
-
options.once = false;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (element.addEventListener) {
|
|
480
|
-
element.addEventListener(
|
|
481
|
-
type,
|
|
482
|
-
(event) => {
|
|
483
|
-
listener(event);
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
passive: options.passive,
|
|
487
|
-
once: options.once
|
|
488
|
-
});
|
|
489
|
-
} else if (element["attachEvent"]) {
|
|
490
|
-
element["attachEvent"](
|
|
491
|
-
type,
|
|
492
|
-
(event) => {
|
|
493
|
-
listener(event);
|
|
494
|
-
}
|
|
495
|
-
);
|
|
496
|
-
} else {
|
|
497
|
-
throw "Your browser does not support 'addEventListener'";
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
function applyClassesToElement(classNames: string[], replace: boolean, element: HTMLElement) {
|
|
502
|
-
//If all existing classes need to be replace we reset the classes object to an empty object
|
|
503
|
-
if (replace) {
|
|
504
|
-
element.className = "";
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
//Add all the classNames to the classes object
|
|
508
|
-
if (classNames) {
|
|
509
|
-
classNames.forEach((className) => {
|
|
510
|
-
element.classList.add(className);
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function applyAttributeToElement(name: keyof Attributes, value: string, element: HTMLElement) {
|
|
516
|
-
if (isNullOrUndefined(value)) {
|
|
517
|
-
element.removeAttribute(name);
|
|
518
|
-
} else {
|
|
519
|
-
element.setAttribute(name, value);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function applyFocusToElement(focused: boolean, element: HTMLElement) {
|
|
524
|
-
if (focused) {
|
|
525
|
-
element.focus();
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
//#endregion
|
|
File without changes
|
|
File without changes
|