uicore-ts 1.0.1
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/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/uicore.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/compiledScripts/UIActionIndicator.d.ts +12 -0
- package/compiledScripts/UIActionIndicator.js +54 -0
- package/compiledScripts/UIActionIndicator.js.map +1 -0
- package/compiledScripts/UIBaseButton.d.ts +52 -0
- package/compiledScripts/UIBaseButton.js +268 -0
- package/compiledScripts/UIBaseButton.js.map +1 -0
- package/compiledScripts/UIButton.d.ts +54 -0
- package/compiledScripts/UIButton.js +247 -0
- package/compiledScripts/UIButton.js.map +1 -0
- package/compiledScripts/UIColor.d.ts +41 -0
- package/compiledScripts/UIColor.js +286 -0
- package/compiledScripts/UIColor.js.map +1 -0
- package/compiledScripts/UICore.d.ts +27 -0
- package/compiledScripts/UICore.js +105 -0
- package/compiledScripts/UICore.js.map +1 -0
- package/compiledScripts/UICoreExtensions.d.ts +60 -0
- package/compiledScripts/UICoreExtensions.js +527 -0
- package/compiledScripts/UICoreExtensions.js.map +1 -0
- package/compiledScripts/UIDateTimeInput.d.ts +40 -0
- package/compiledScripts/UIDateTimeInput.js +38 -0
- package/compiledScripts/UIDateTimeInput.js.map +1 -0
- package/compiledScripts/UIDialogView.d.ts +23 -0
- package/compiledScripts/UIDialogView.js +118 -0
- package/compiledScripts/UIDialogView.js.map +1 -0
- package/compiledScripts/UIImageView.d.ts +36 -0
- package/compiledScripts/UIImageView.js +170 -0
- package/compiledScripts/UIImageView.js.map +1 -0
- package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
- package/compiledScripts/UIKeyValueStringFilter.js +98 -0
- package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
- package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
- package/compiledScripts/UIKeyValueStringSorter.js +117 -0
- package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
- package/compiledScripts/UILayoutGrid.d.ts +8 -0
- package/compiledScripts/UILayoutGrid.js +22 -0
- package/compiledScripts/UILayoutGrid.js.map +1 -0
- package/compiledScripts/UILink.d.ts +25 -0
- package/compiledScripts/UILink.js +81 -0
- package/compiledScripts/UILink.js.map +1 -0
- package/compiledScripts/UILinkButton.d.ts +18 -0
- package/compiledScripts/UILinkButton.js +60 -0
- package/compiledScripts/UILinkButton.js.map +1 -0
- package/compiledScripts/UINativeScrollView.d.ts +20 -0
- package/compiledScripts/UINativeScrollView.js +121 -0
- package/compiledScripts/UINativeScrollView.js.map +1 -0
- package/compiledScripts/UIObject.d.ts +69 -0
- package/compiledScripts/UIObject.js +442 -0
- package/compiledScripts/UIObject.js.map +1 -0
- package/compiledScripts/UIPoint.d.ts +18 -0
- package/compiledScripts/UIPoint.js +68 -0
- package/compiledScripts/UIPoint.js.map +1 -0
- package/compiledScripts/UIRectangle.d.ts +61 -0
- package/compiledScripts/UIRectangle.js +421 -0
- package/compiledScripts/UIRectangle.js.map +1 -0
- package/compiledScripts/UIRoute.d.ts +39 -0
- package/compiledScripts/UIRoute.js +202 -0
- package/compiledScripts/UIRoute.js.map +1 -0
- package/compiledScripts/UIScrollView.d.ts +19 -0
- package/compiledScripts/UIScrollView.js +121 -0
- package/compiledScripts/UIScrollView.js.map +1 -0
- package/compiledScripts/UISlideScrollerView.d.ts +40 -0
- package/compiledScripts/UISlideScrollerView.js +242 -0
- package/compiledScripts/UISlideScrollerView.js.map +1 -0
- package/compiledScripts/UIStringFilter.d.ts +26 -0
- package/compiledScripts/UIStringFilter.js +107 -0
- package/compiledScripts/UIStringFilter.js.map +1 -0
- package/compiledScripts/UITableView.d.ts +61 -0
- package/compiledScripts/UITableView.js +383 -0
- package/compiledScripts/UITableView.js.map +1 -0
- package/compiledScripts/UITextArea.d.ts +7 -0
- package/compiledScripts/UITextArea.js +27 -0
- package/compiledScripts/UITextArea.js.map +1 -0
- package/compiledScripts/UITextField.d.ts +44 -0
- package/compiledScripts/UITextField.js +83 -0
- package/compiledScripts/UITextField.js.map +1 -0
- package/compiledScripts/UITextView.d.ts +89 -0
- package/compiledScripts/UITextView.js +237 -0
- package/compiledScripts/UITextView.js.map +1 -0
- package/compiledScripts/UITimer.d.ts +13 -0
- package/compiledScripts/UITimer.js +45 -0
- package/compiledScripts/UITimer.js.map +1 -0
- package/compiledScripts/UIView.d.ts +330 -0
- package/compiledScripts/UIView.js +1533 -0
- package/compiledScripts/UIView.js.map +1 -0
- package/compiledScripts/UIViewController.d.ts +38 -0
- package/compiledScripts/UIViewController.js +153 -0
- package/compiledScripts/UIViewController.js.map +1 -0
- package/compiledScripts/index.d.ts +29 -0
- package/compiledScripts/index.js +46 -0
- package/compiledScripts/index.js.map +1 -0
- package/package.json +36 -0
- package/scripts/UIActionIndicator.ts +139 -0
- package/scripts/UIBaseButton.ts +563 -0
- package/scripts/UIButton.ts +552 -0
- package/scripts/UIColor.ts +427 -0
- package/scripts/UICore.ts +223 -0
- package/scripts/UICoreExtensions.ts +949 -0
- package/scripts/UIDateTimeInput.ts +109 -0
- package/scripts/UIDialogView.ts +297 -0
- package/scripts/UIImageView.ts +366 -0
- package/scripts/UIKeyValueStringFilter.ts +260 -0
- package/scripts/UIKeyValueStringSorter.ts +337 -0
- package/scripts/UILayoutGrid.ts +83 -0
- package/scripts/UILink.ts +292 -0
- package/scripts/UILinkButton.ts +238 -0
- package/scripts/UINativeScrollView.ts +254 -0
- package/scripts/UIObject.ts +827 -0
- package/scripts/UIPoint.ts +123 -0
- package/scripts/UIRectangle.ts +730 -0
- package/scripts/UIRoute.ts +391 -0
- package/scripts/UIScrollView.ts +290 -0
- package/scripts/UISlideScrollerView.ts +530 -0
- package/scripts/UIStringFilter.ts +293 -0
- package/scripts/UITableView.ts +790 -0
- package/scripts/UITextArea.ts +91 -0
- package/scripts/UITextField.ts +218 -0
- package/scripts/UITextView.ts +561 -0
- package/scripts/UITimer.ts +107 -0
- package/scripts/UIView.ts +2789 -0
- package/scripts/UIViewController.ts +304 -0
- package/scripts/index.ts +36 -0
- package/tsconfig.json +59 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { UICore } from "./UICore"
|
|
2
|
+
import { IS_NOT, nil, NO, YES } from "./UIObject"
|
|
3
|
+
import { UIRectangle } from "./UIRectangle"
|
|
4
|
+
import { UIView, UIViewBroadcastEvent } from "./UIView"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export class UIImageView extends UIView {
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
//actionIndicator: UIActionIndicator;
|
|
14
|
+
_sourceKey: string
|
|
15
|
+
_defaultSource: string
|
|
16
|
+
|
|
17
|
+
_fillMode: any
|
|
18
|
+
|
|
19
|
+
_hiddenWhenEmpty = NO
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
constructor(elementID?, viewHTMLElement = null) {
|
|
23
|
+
|
|
24
|
+
super(elementID, viewHTMLElement, "img")
|
|
25
|
+
|
|
26
|
+
this._class = UIImageView
|
|
27
|
+
this.superclass = UIView
|
|
28
|
+
|
|
29
|
+
//this.actionIndicator = new UIActionIndicator(elementID + "ActionIndicator");
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
static fillMode = {
|
|
38
|
+
|
|
39
|
+
"stretchToFill": "fill",
|
|
40
|
+
"aspectFit": "contain",
|
|
41
|
+
"aspectFill": "cover",
|
|
42
|
+
"center": "none",
|
|
43
|
+
"aspectFitIfLarger": "scale-down"
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
get viewHTMLElement() {
|
|
52
|
+
|
|
53
|
+
return super.viewHTMLElement as HTMLImageElement
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
static objectURLFromDataURL(dataURL: string) {
|
|
62
|
+
|
|
63
|
+
// if (IS_NOT(dataURL)) {
|
|
64
|
+
|
|
65
|
+
// return nil;
|
|
66
|
+
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
const blob = dataURLtoBlob(dataURL)
|
|
71
|
+
|
|
72
|
+
const objectURL = URL.createObjectURL(blob)
|
|
73
|
+
|
|
74
|
+
return objectURL
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
static dataURL(url, callback) {
|
|
82
|
+
const xhr = new XMLHttpRequest()
|
|
83
|
+
xhr.open("get", url)
|
|
84
|
+
xhr.responseType = "blob"
|
|
85
|
+
xhr.onload = function () {
|
|
86
|
+
const fr = new FileReader()
|
|
87
|
+
|
|
88
|
+
fr.onload = function () {
|
|
89
|
+
callback(this.result)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fr.readAsDataURL(xhr.response) // async call
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
xhr.send()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void) {
|
|
101
|
+
|
|
102
|
+
const imageView = new UIImageView()
|
|
103
|
+
imageView.imageSource = URLString
|
|
104
|
+
|
|
105
|
+
imageView.viewHTMLElement.onload = function () {
|
|
106
|
+
|
|
107
|
+
const originalSize = imageView.intrinsicContentSize()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
var multiplier = maxSize / Math.max(originalSize.height, originalSize.width)
|
|
111
|
+
|
|
112
|
+
multiplier = Math.min(1, multiplier)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const result = imageView.getDataURL((originalSize.height * multiplier).integerValue, (originalSize.width *
|
|
116
|
+
multiplier).integerValue)
|
|
117
|
+
|
|
118
|
+
completion(result)
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
static dataURLWithSizes(
|
|
126
|
+
URLString: string,
|
|
127
|
+
height: number,
|
|
128
|
+
width: number,
|
|
129
|
+
completion: (resultURLString: string) => void
|
|
130
|
+
) {
|
|
131
|
+
|
|
132
|
+
const imageView = new UIImageView()
|
|
133
|
+
imageView.imageSource = URLString
|
|
134
|
+
|
|
135
|
+
imageView.viewHTMLElement.onload = function () {
|
|
136
|
+
|
|
137
|
+
const result = imageView.getDataURL(height, width)
|
|
138
|
+
completion(result)
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
getDataURL(height?: number, width?: number) {
|
|
146
|
+
|
|
147
|
+
const img = this.viewHTMLElement
|
|
148
|
+
|
|
149
|
+
// Create an empty canvas element
|
|
150
|
+
const canvas = document.createElement("canvas")
|
|
151
|
+
canvas.width = width
|
|
152
|
+
canvas.height = height
|
|
153
|
+
|
|
154
|
+
// Copy the image contents to the canvas
|
|
155
|
+
const ctx = canvas.getContext("2d")
|
|
156
|
+
ctx.drawImage(img, 0, 0, width, height)
|
|
157
|
+
|
|
158
|
+
// Get the data-URL formatted image
|
|
159
|
+
// Firefox supports PNG and JPEG. You could check img.src to
|
|
160
|
+
// guess the original format, but be aware the using "image/jpg"
|
|
161
|
+
// will re-encode the image.
|
|
162
|
+
const dataURL = canvas.toDataURL("image/png")
|
|
163
|
+
|
|
164
|
+
return dataURL
|
|
165
|
+
|
|
166
|
+
//return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
get imageSource() {
|
|
174
|
+
|
|
175
|
+
return this.viewHTMLElement.src
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
set imageSource(sourceString: string) {
|
|
180
|
+
|
|
181
|
+
if (IS_NOT(sourceString)) {
|
|
182
|
+
sourceString = ""
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
this.viewHTMLElement.src = sourceString
|
|
186
|
+
|
|
187
|
+
if (this.hiddenWhenEmpty) {
|
|
188
|
+
this.hidden = IS_NOT(this.imageSource)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!sourceString || !sourceString.length) {
|
|
192
|
+
|
|
193
|
+
//this.actionIndicator.stop();
|
|
194
|
+
this.hidden = YES
|
|
195
|
+
|
|
196
|
+
return
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
|
|
201
|
+
this.hidden = NO
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// this.superview.addSubview(this.actionIndicator);
|
|
206
|
+
// this.actionIndicator.frame = this.frame;
|
|
207
|
+
// this.actionIndicator.start();
|
|
208
|
+
// this.actionIndicator.backgroundColor = UIColor.redColor
|
|
209
|
+
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
this.viewHTMLElement.onload = function (this: UIImageView, event: Event) {
|
|
212
|
+
|
|
213
|
+
this.superview.setNeedsLayout()
|
|
214
|
+
|
|
215
|
+
//this.actionIndicator.removeFromSuperview();
|
|
216
|
+
|
|
217
|
+
}.bind(this)
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
setImageSource(key: string, defaultString: string) {
|
|
224
|
+
|
|
225
|
+
const languageName = UICore.languageService.currentLanguageKey
|
|
226
|
+
this.imageSource = UICore.languageService.stringForKey(key, languageName, defaultString, nil)
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {
|
|
233
|
+
|
|
234
|
+
super.didReceiveBroadcastEvent(event)
|
|
235
|
+
|
|
236
|
+
if (event.name == UIView.broadcastEventName.LanguageChanged || event.name ==
|
|
237
|
+
UIView.broadcastEventName.AddedToViewTree) {
|
|
238
|
+
|
|
239
|
+
this._setImageSourceFromKeyIfPossible()
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
willMoveToSuperview(superview: UIView) {
|
|
247
|
+
|
|
248
|
+
super.willMoveToSuperview(superview)
|
|
249
|
+
|
|
250
|
+
this._setImageSourceFromKeyIfPossible()
|
|
251
|
+
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
_setImageSourceFromKeyIfPossible() {
|
|
255
|
+
|
|
256
|
+
if (this._sourceKey && this._defaultSource) {
|
|
257
|
+
|
|
258
|
+
this.setImageSource(this._sourceKey, this._defaultSource)
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
get fillMode() {
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
return this._fillMode
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
set fillMode(fillMode) {
|
|
274
|
+
|
|
275
|
+
this._fillMode = fillMode;
|
|
276
|
+
|
|
277
|
+
(this.style as any).objectFit = fillMode
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
get hiddenWhenEmpty() {
|
|
283
|
+
return this._hiddenWhenEmpty
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
set hiddenWhenEmpty(hiddenWhenEmpty: boolean) {
|
|
287
|
+
this._hiddenWhenEmpty = hiddenWhenEmpty
|
|
288
|
+
if (hiddenWhenEmpty) {
|
|
289
|
+
this.hidden = IS_NOT(this.imageSource)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
didMoveToSuperview(superview: UIView) {
|
|
298
|
+
|
|
299
|
+
super.didMoveToSuperview(superview)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
layoutSubviews() {
|
|
312
|
+
|
|
313
|
+
super.layoutSubviews()
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
intrinsicContentSize() {
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
const result = new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth)
|
|
326
|
+
|
|
327
|
+
return result
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
intrinsicContentSizeWithConstraints(constrainingHeight = 0, constrainingWidth = 0) {
|
|
333
|
+
|
|
334
|
+
const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight
|
|
335
|
+
|
|
336
|
+
const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth
|
|
337
|
+
|
|
338
|
+
const multiplier = Math.max(heightRatio, widthRatio)
|
|
339
|
+
|
|
340
|
+
const result = new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight *
|
|
341
|
+
multiplier, this.viewHTMLElement.naturalWidth * multiplier)
|
|
342
|
+
|
|
343
|
+
return result
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { IS, IS_NOT, NO, UIObject, YES } from "./UIObject"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class UIKeyValueStringFilter extends UIObject {
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
static _sharedWebWorkerHolder = { webWorker: new Worker("compiledScripts//UIKeyValueStringFilterWebWorker.js") }
|
|
11
|
+
|
|
12
|
+
static _instanceNumber = -1
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_instanceNumber: number
|
|
16
|
+
|
|
17
|
+
_isThreadClosed = NO
|
|
18
|
+
|
|
19
|
+
private _webWorkerHolder = UIKeyValueStringFilter._sharedWebWorkerHolder
|
|
20
|
+
|
|
21
|
+
constructor(useSeparateWebWorkerHolder = NO) {
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
super()
|
|
25
|
+
|
|
26
|
+
this._class = UIKeyValueStringFilter
|
|
27
|
+
this.superclass = UIObject
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if (useSeparateWebWorkerHolder) {
|
|
31
|
+
|
|
32
|
+
this._webWorkerHolder = { webWorker: new Worker("compiledScripts//UIKeyValueStringFilterWebWorker.js") }
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
UIKeyValueStringFilter._instanceNumber = UIKeyValueStringFilter._instanceNumber + 1
|
|
37
|
+
this._instanceNumber = UIKeyValueStringFilter._instanceNumber
|
|
38
|
+
|
|
39
|
+
if (IS_NOT(this._webWorkerHolder.webWorker.onmessage)) {
|
|
40
|
+
|
|
41
|
+
this._webWorkerHolder.webWorker.onmessage = message => {
|
|
42
|
+
|
|
43
|
+
this.isWorkerBusy = NO
|
|
44
|
+
this.postNextMessageIfNeeded()
|
|
45
|
+
|
|
46
|
+
const key = "" + message.data.identifier + message.data.instanceIdentifier
|
|
47
|
+
|
|
48
|
+
const completionFunction = this.completionFunctions[key]
|
|
49
|
+
|
|
50
|
+
if (IS(completionFunction)) {
|
|
51
|
+
|
|
52
|
+
//console.log("Filtering took " + (Date.now() - startTime) + " ms");
|
|
53
|
+
|
|
54
|
+
completionFunction(message.data.filteredData, message.data.filteredIndexes, message.data.identifier)
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
delete this.completionFunctions[key]
|
|
59
|
+
|
|
60
|
+
var asd = 1
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
get instanceIdentifier() {
|
|
77
|
+
|
|
78
|
+
return this._instanceNumber
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
get completionFunctions() {
|
|
84
|
+
|
|
85
|
+
const key = "UICore_completionFunctions"
|
|
86
|
+
var result: {
|
|
87
|
+
|
|
88
|
+
[x: string]: (filteredData: string[], filteredIndexes: number[], identifier: any) => void;
|
|
89
|
+
|
|
90
|
+
} = this._webWorkerHolder[key]
|
|
91
|
+
|
|
92
|
+
if (IS_NOT(result)) {
|
|
93
|
+
|
|
94
|
+
result = {}
|
|
95
|
+
this._webWorkerHolder[key] = result
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return result
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get messagesToPost() {
|
|
104
|
+
|
|
105
|
+
const key = "UICore_messagesToPost"
|
|
106
|
+
var result: any[] = this._webWorkerHolder[key]
|
|
107
|
+
|
|
108
|
+
if (IS_NOT(result)) {
|
|
109
|
+
|
|
110
|
+
result = []
|
|
111
|
+
this._webWorkerHolder[key] = result
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return result
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
set isWorkerBusy(isWorkerBusy: boolean) {
|
|
121
|
+
|
|
122
|
+
this._webWorkerHolder["UICore_isWorking"] = isWorkerBusy
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get isWorkerBusy() {
|
|
127
|
+
|
|
128
|
+
return IS(this._webWorkerHolder["UICore_isWorking"])
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
postNextMessageIfNeeded() {
|
|
134
|
+
|
|
135
|
+
if (this.messagesToPost.length && IS_NOT(this.isWorkerBusy)) {
|
|
136
|
+
|
|
137
|
+
this._webWorkerHolder.webWorker.postMessage(this.messagesToPost.firstElement)
|
|
138
|
+
this.messagesToPost.removeElementAtIndex(0)
|
|
139
|
+
|
|
140
|
+
this.isWorkerBusy = YES
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
filterData(
|
|
150
|
+
filteringString: string,
|
|
151
|
+
data: any[],
|
|
152
|
+
excludedData: string[],
|
|
153
|
+
dataKeyPath: string,
|
|
154
|
+
identifier: any,
|
|
155
|
+
completion: (filteredData: string[], filteredIndexes: number[], identifier: any) => void
|
|
156
|
+
) {
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (this._isThreadClosed) {
|
|
160
|
+
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
const instanceIdentifier = this.instanceIdentifier
|
|
168
|
+
|
|
169
|
+
const key = "" + identifier + instanceIdentifier
|
|
170
|
+
|
|
171
|
+
this.completionFunctions[key] = completion
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
|
|
176
|
+
this.messagesToPost.push({
|
|
177
|
+
|
|
178
|
+
"filteringString": filteringString,
|
|
179
|
+
"data": data,
|
|
180
|
+
"excludedData": excludedData,
|
|
181
|
+
"dataKeyPath": dataKeyPath,
|
|
182
|
+
"identifier": identifier,
|
|
183
|
+
"instanceIdentifier": instanceIdentifier
|
|
184
|
+
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
this.postNextMessageIfNeeded()
|
|
188
|
+
|
|
189
|
+
} catch (exception) {
|
|
190
|
+
|
|
191
|
+
completion([], [], identifier)
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
closeThread() {
|
|
206
|
+
|
|
207
|
+
this._isThreadClosed = YES
|
|
208
|
+
|
|
209
|
+
if (this._webWorkerHolder != UIKeyValueStringFilter._sharedWebWorkerHolder) {
|
|
210
|
+
|
|
211
|
+
this._webWorkerHolder.webWorker.terminate()
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|