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.
Files changed (128) hide show
  1. package/.idea/misc.xml +6 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/uicore.iml +9 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/LICENSE +21 -0
  6. package/README.md +5 -0
  7. package/compiledScripts/UIActionIndicator.d.ts +12 -0
  8. package/compiledScripts/UIActionIndicator.js +54 -0
  9. package/compiledScripts/UIActionIndicator.js.map +1 -0
  10. package/compiledScripts/UIBaseButton.d.ts +52 -0
  11. package/compiledScripts/UIBaseButton.js +268 -0
  12. package/compiledScripts/UIBaseButton.js.map +1 -0
  13. package/compiledScripts/UIButton.d.ts +54 -0
  14. package/compiledScripts/UIButton.js +247 -0
  15. package/compiledScripts/UIButton.js.map +1 -0
  16. package/compiledScripts/UIColor.d.ts +41 -0
  17. package/compiledScripts/UIColor.js +286 -0
  18. package/compiledScripts/UIColor.js.map +1 -0
  19. package/compiledScripts/UICore.d.ts +27 -0
  20. package/compiledScripts/UICore.js +105 -0
  21. package/compiledScripts/UICore.js.map +1 -0
  22. package/compiledScripts/UICoreExtensions.d.ts +60 -0
  23. package/compiledScripts/UICoreExtensions.js +527 -0
  24. package/compiledScripts/UICoreExtensions.js.map +1 -0
  25. package/compiledScripts/UIDateTimeInput.d.ts +40 -0
  26. package/compiledScripts/UIDateTimeInput.js +38 -0
  27. package/compiledScripts/UIDateTimeInput.js.map +1 -0
  28. package/compiledScripts/UIDialogView.d.ts +23 -0
  29. package/compiledScripts/UIDialogView.js +118 -0
  30. package/compiledScripts/UIDialogView.js.map +1 -0
  31. package/compiledScripts/UIImageView.d.ts +36 -0
  32. package/compiledScripts/UIImageView.js +170 -0
  33. package/compiledScripts/UIImageView.js.map +1 -0
  34. package/compiledScripts/UIKeyValueStringFilter.d.ts +21 -0
  35. package/compiledScripts/UIKeyValueStringFilter.js +98 -0
  36. package/compiledScripts/UIKeyValueStringFilter.js.map +1 -0
  37. package/compiledScripts/UIKeyValueStringSorter.d.ts +38 -0
  38. package/compiledScripts/UIKeyValueStringSorter.js +117 -0
  39. package/compiledScripts/UIKeyValueStringSorter.js.map +1 -0
  40. package/compiledScripts/UILayoutGrid.d.ts +8 -0
  41. package/compiledScripts/UILayoutGrid.js +22 -0
  42. package/compiledScripts/UILayoutGrid.js.map +1 -0
  43. package/compiledScripts/UILink.d.ts +25 -0
  44. package/compiledScripts/UILink.js +81 -0
  45. package/compiledScripts/UILink.js.map +1 -0
  46. package/compiledScripts/UILinkButton.d.ts +18 -0
  47. package/compiledScripts/UILinkButton.js +60 -0
  48. package/compiledScripts/UILinkButton.js.map +1 -0
  49. package/compiledScripts/UINativeScrollView.d.ts +20 -0
  50. package/compiledScripts/UINativeScrollView.js +121 -0
  51. package/compiledScripts/UINativeScrollView.js.map +1 -0
  52. package/compiledScripts/UIObject.d.ts +69 -0
  53. package/compiledScripts/UIObject.js +442 -0
  54. package/compiledScripts/UIObject.js.map +1 -0
  55. package/compiledScripts/UIPoint.d.ts +18 -0
  56. package/compiledScripts/UIPoint.js +68 -0
  57. package/compiledScripts/UIPoint.js.map +1 -0
  58. package/compiledScripts/UIRectangle.d.ts +61 -0
  59. package/compiledScripts/UIRectangle.js +421 -0
  60. package/compiledScripts/UIRectangle.js.map +1 -0
  61. package/compiledScripts/UIRoute.d.ts +39 -0
  62. package/compiledScripts/UIRoute.js +202 -0
  63. package/compiledScripts/UIRoute.js.map +1 -0
  64. package/compiledScripts/UIScrollView.d.ts +19 -0
  65. package/compiledScripts/UIScrollView.js +121 -0
  66. package/compiledScripts/UIScrollView.js.map +1 -0
  67. package/compiledScripts/UISlideScrollerView.d.ts +40 -0
  68. package/compiledScripts/UISlideScrollerView.js +242 -0
  69. package/compiledScripts/UISlideScrollerView.js.map +1 -0
  70. package/compiledScripts/UIStringFilter.d.ts +26 -0
  71. package/compiledScripts/UIStringFilter.js +107 -0
  72. package/compiledScripts/UIStringFilter.js.map +1 -0
  73. package/compiledScripts/UITableView.d.ts +61 -0
  74. package/compiledScripts/UITableView.js +383 -0
  75. package/compiledScripts/UITableView.js.map +1 -0
  76. package/compiledScripts/UITextArea.d.ts +7 -0
  77. package/compiledScripts/UITextArea.js +27 -0
  78. package/compiledScripts/UITextArea.js.map +1 -0
  79. package/compiledScripts/UITextField.d.ts +44 -0
  80. package/compiledScripts/UITextField.js +83 -0
  81. package/compiledScripts/UITextField.js.map +1 -0
  82. package/compiledScripts/UITextView.d.ts +89 -0
  83. package/compiledScripts/UITextView.js +237 -0
  84. package/compiledScripts/UITextView.js.map +1 -0
  85. package/compiledScripts/UITimer.d.ts +13 -0
  86. package/compiledScripts/UITimer.js +45 -0
  87. package/compiledScripts/UITimer.js.map +1 -0
  88. package/compiledScripts/UIView.d.ts +330 -0
  89. package/compiledScripts/UIView.js +1533 -0
  90. package/compiledScripts/UIView.js.map +1 -0
  91. package/compiledScripts/UIViewController.d.ts +38 -0
  92. package/compiledScripts/UIViewController.js +153 -0
  93. package/compiledScripts/UIViewController.js.map +1 -0
  94. package/compiledScripts/index.d.ts +29 -0
  95. package/compiledScripts/index.js +46 -0
  96. package/compiledScripts/index.js.map +1 -0
  97. package/package.json +36 -0
  98. package/scripts/UIActionIndicator.ts +139 -0
  99. package/scripts/UIBaseButton.ts +563 -0
  100. package/scripts/UIButton.ts +552 -0
  101. package/scripts/UIColor.ts +427 -0
  102. package/scripts/UICore.ts +223 -0
  103. package/scripts/UICoreExtensions.ts +949 -0
  104. package/scripts/UIDateTimeInput.ts +109 -0
  105. package/scripts/UIDialogView.ts +297 -0
  106. package/scripts/UIImageView.ts +366 -0
  107. package/scripts/UIKeyValueStringFilter.ts +260 -0
  108. package/scripts/UIKeyValueStringSorter.ts +337 -0
  109. package/scripts/UILayoutGrid.ts +83 -0
  110. package/scripts/UILink.ts +292 -0
  111. package/scripts/UILinkButton.ts +238 -0
  112. package/scripts/UINativeScrollView.ts +254 -0
  113. package/scripts/UIObject.ts +827 -0
  114. package/scripts/UIPoint.ts +123 -0
  115. package/scripts/UIRectangle.ts +730 -0
  116. package/scripts/UIRoute.ts +391 -0
  117. package/scripts/UIScrollView.ts +290 -0
  118. package/scripts/UISlideScrollerView.ts +530 -0
  119. package/scripts/UIStringFilter.ts +293 -0
  120. package/scripts/UITableView.ts +790 -0
  121. package/scripts/UITextArea.ts +91 -0
  122. package/scripts/UITextField.ts +218 -0
  123. package/scripts/UITextView.ts +561 -0
  124. package/scripts/UITimer.ts +107 -0
  125. package/scripts/UIView.ts +2789 -0
  126. package/scripts/UIViewController.ts +304 -0
  127. package/scripts/index.ts +36 -0
  128. package/tsconfig.json +59 -0
@@ -0,0 +1,530 @@
1
+ import { UIButton } from "./UIButton"
2
+ import { UIColor } from "./UIColor"
3
+ import { UICore } from "./UICore"
4
+ import { IS, nil, NO, YES } from "./UIObject"
5
+ import { UIRectangle } from "./UIRectangle"
6
+ import { UIScrollView } from "./UIScrollView"
7
+ import { UITimer } from "./UITimer"
8
+ import { UIView, UIViewBroadcastEvent } from "./UIView"
9
+
10
+
11
+ export class UISlideScrollerView extends UIView {
12
+
13
+
14
+
15
+ _previousLayoutBounds: UIRectangle
16
+ _targetIndex: number = 0
17
+ pageIndicatorsView: UIView
18
+ _isAnimating: boolean = NO
19
+ _isAnimationOngoing: boolean = NO
20
+ _animationTimer: UITimer = nil
21
+ _scrollView: UIScrollView
22
+ _slideViews: UIView[] = []
23
+
24
+ wrapAround: boolean = YES
25
+
26
+ animationDuration: number = 0.35
27
+ animationDelay: number = 2
28
+
29
+ _currentPageIndex: number = 0
30
+
31
+ constructor(elementID: string, viewHTMLElement?: HTMLElement) {
32
+
33
+ super(elementID, viewHTMLElement)
34
+
35
+ this._class = UIScrollView
36
+ this.superclass = UIView
37
+
38
+
39
+ this._scrollView = new UIScrollView(elementID + "ScrollView")
40
+
41
+ this.addSubview(this._scrollView)
42
+
43
+
44
+ this._scrollView._scrollEnabled = NO
45
+
46
+ this._scrollView.addTargetForControlEvent(
47
+ UIView.controlEvent.PointerMove,
48
+ function (sender: UIView, event: Event) {
49
+
50
+ if (event instanceof MouseEvent) {
51
+ this._animationTimer.invalidate()
52
+ }
53
+
54
+ }.bind(this)
55
+ )
56
+
57
+ this._scrollView.addTargetForControlEvent(UIView.controlEvent.PointerLeave, function () {
58
+
59
+ if (this._isAnimating && event instanceof MouseEvent) {
60
+ this.startAnimating()
61
+ }
62
+
63
+ }.bind(this))
64
+
65
+ // Touch events
66
+ this._scrollView.addTargetForControlEvent(UIView.controlEvent.PointerDown, function (sender, event) {
67
+
68
+ if (event instanceof TouchEvent) {
69
+ this._animationTimer.invalidate()
70
+ }
71
+
72
+ }.bind(this))
73
+
74
+ this._scrollView.addTargetForControlEvents([
75
+ UIView.controlEvent.PointerUp, UIView.controlEvent.PointerCancel
76
+ ], function (sender, event) {
77
+
78
+ if (event instanceof TouchEvent && this._isAnimating) {
79
+
80
+ this.startAnimating()
81
+
82
+ }
83
+
84
+ }.bind(this))
85
+
86
+
87
+ // Page indicator
88
+
89
+ this.pageIndicatorsView = new UIView(elementID + "PageIndicatorsView")
90
+ this.addSubview(this.pageIndicatorsView)
91
+
92
+
93
+
94
+
95
+
96
+ }
97
+
98
+
99
+
100
+
101
+
102
+ buttonForPageIndicatorWithIndex(index: number): UIButton {
103
+
104
+ const result = new UIButton(this.viewHTMLElement.id + "PageIndicatorButton" + index)
105
+
106
+ result.addTargetForControlEvents([
107
+ UIView.controlEvent.PointerUpInside, UIView.controlEvent.EnterUp
108
+ ], function (sender, event) {
109
+
110
+ this.scrollToPageWithIndex(index, YES)
111
+
112
+ if (this._isAnimating) {
113
+
114
+ this.startAnimating()
115
+
116
+ }
117
+
118
+
119
+
120
+ }.bind(this))
121
+
122
+ result.addTargetForControlEvent(UIView.controlEvent.PointerMove, function () {
123
+
124
+ this._animationTimer.invalidate()
125
+
126
+ }.bind(this))
127
+
128
+
129
+ result.updateContentForNormalState = function () {
130
+
131
+ result.backgroundColor = UIColor.blueColor
132
+ result.titleLabel.textColor = UIColor.whiteColor
133
+
134
+ }
135
+
136
+
137
+ result.frame = new UIRectangle(nil, nil, 20, 50)
138
+
139
+ // result.style.height = "20px";
140
+ // result.style.width = "50px";
141
+ result.style.display = "table-cell"
142
+ result.style.position = "relative"
143
+
144
+
145
+ // var resultContent = new UIView(result.viewHTMLElement.id + "Content");
146
+ // resultContent.backgroundColor = UIColor.whiteColor;
147
+ // resultContent.centerYInContainer();
148
+ // resultContent.style.height = "10px";
149
+ // resultContent.style.height = "100%";
150
+ // resultContent.style.borderRadius = "5px";
151
+
152
+ // result.addSubview(resultContent);
153
+
154
+
155
+ return result
156
+
157
+ }
158
+
159
+
160
+
161
+ addSlideView(view: UIView) {
162
+
163
+ this.slideViews.push(view)
164
+
165
+ this.updateSlideViews()
166
+
167
+ }
168
+
169
+ set slideViews(views: UIView[]) {
170
+
171
+ this._slideViews = views
172
+
173
+ this.updateSlideViews()
174
+
175
+ }
176
+
177
+ get slideViews() {
178
+ return this._slideViews
179
+ }
180
+
181
+
182
+
183
+ get currentPageIndex() {
184
+
185
+ const result = this._currentPageIndex
186
+
187
+ return result
188
+
189
+ }
190
+
191
+ set currentPageIndex(index: number) {
192
+
193
+ this._currentPageIndex = index
194
+
195
+ this._slideViews[index].willAppear()
196
+
197
+ //this._scrollView.contentOffset.x = -this._slideViews[index].frame.min.x; //-this.bounds.width * index;
198
+ //this._scrollView.contentOffset.x = Math.round(this._scrollView.contentOffset.x);
199
+
200
+ this._scrollView.contentOffset = this._scrollView.contentOffset.pointWithX(-this._slideViews[index].frame.min.x)
201
+
202
+
203
+ this.pageIndicatorsView.subviews.forEach(function (button: UIButton, index, array) {
204
+
205
+ button.selected = NO
206
+
207
+ });
208
+
209
+
210
+
211
+ (this.pageIndicatorsView.subviews[index] as UIButton).selected = YES
212
+
213
+
214
+
215
+ }
216
+
217
+
218
+
219
+ scrollToPreviousPage(animated: boolean) {
220
+
221
+ if (this.slideViews.length == 0) {
222
+ return
223
+ }
224
+
225
+ var targetIndex = this.currentPageIndex
226
+
227
+ if (this.wrapAround) {
228
+ targetIndex = (this.currentPageIndex - 1) % (this.slideViews.length)
229
+ }
230
+ else if (this.currentPageIndex - 1 < this.slideViews.length) {
231
+ targetIndex = this.currentPageIndex - 1
232
+ }
233
+ else {
234
+ return
235
+ }
236
+
237
+ this.scrollToPageWithIndex(targetIndex, animated)
238
+
239
+ }
240
+
241
+ scrollToNextPage(animated: boolean) {
242
+
243
+ if (this.slideViews.length == 0) {
244
+ return
245
+ }
246
+
247
+ var targetIndex = this.currentPageIndex
248
+
249
+ if (this.wrapAround) {
250
+ targetIndex = (this.currentPageIndex + 1) % (this.slideViews.length)
251
+ }
252
+ else if (this.currentPageIndex + 1 < this.slideViews.length) {
253
+ targetIndex = this.currentPageIndex + 1
254
+ }
255
+ else {
256
+ return
257
+ }
258
+
259
+ this.scrollToPageWithIndex(targetIndex, animated)
260
+
261
+ }
262
+
263
+
264
+
265
+ scrollToPageWithIndex(targetIndex: number, animated: boolean = YES) {
266
+
267
+ this._targetIndex = targetIndex
268
+
269
+ // this._slideViews[this.currentPageIndex]._shouldLayout = NO;
270
+ // this._slideViews[this._targetIndex]._shouldLayout = YES;
271
+
272
+ //this._slideViews[this._targetIndex].hidden = NO;
273
+
274
+ this.willScrollToPageWithIndex(targetIndex)
275
+
276
+ this._isAnimationOngoing = YES
277
+
278
+ //var previousView = this._slideViews[this.currentPageIndex];
279
+
280
+ if (animated) {
281
+
282
+
283
+
284
+ UIView.animateViewOrViewsWithDurationDelayAndFunction(
285
+ this._scrollView.containerView,
286
+ this.animationDuration,
287
+ 0,
288
+ undefined,
289
+ function (this: UISlideScrollerView) {
290
+
291
+
292
+ this.currentPageIndex = targetIndex
293
+
294
+
295
+
296
+ }.bind(this),
297
+ function (this: UISlideScrollerView) {
298
+
299
+ this.didScrollToPageWithIndex(targetIndex)
300
+
301
+ this._isAnimationOngoing = NO
302
+
303
+ //previousView.hidden = YES;
304
+
305
+ }.bind(this)
306
+ )
307
+
308
+ }
309
+ else {
310
+
311
+
312
+ this.currentPageIndex = targetIndex
313
+ this.didScrollToPageWithIndex(targetIndex)
314
+
315
+ //previousView.hidden = YES;
316
+
317
+ }
318
+
319
+ }
320
+
321
+
322
+
323
+ willScrollToPageWithIndex(index: number) {
324
+
325
+ const targetView = this.slideViews[index]
326
+
327
+ if (IS(targetView) && (targetView as any).willAppear && (targetView as any).willAppear instanceof Function) {
328
+
329
+ (targetView as any).willAppear()
330
+
331
+ }
332
+
333
+ }
334
+
335
+ didScrollToPageWithIndex(index: number) {
336
+
337
+
338
+
339
+ }
340
+
341
+
342
+
343
+ startAnimating() {
344
+
345
+ this._isAnimating = YES
346
+
347
+ this._animationTimer.invalidate()
348
+
349
+ this._animationTimer = new UITimer(this.animationDelay + this.animationDuration, YES, function () {
350
+
351
+ this.scrollToNextPage(YES)
352
+
353
+ }.bind(this))
354
+
355
+ }
356
+
357
+ stopAnimating() {
358
+
359
+ this._isAnimating = NO
360
+ this._animationTimer.invalidate()
361
+
362
+ }
363
+
364
+
365
+
366
+
367
+
368
+ updateSlideViews() {
369
+
370
+ this._scrollView.containerView.subviews.slice().forEach(function (subview, index, array) {
371
+
372
+ subview.removeFromSuperview()
373
+
374
+ })
375
+
376
+ this.pageIndicatorsView.subviews.slice().forEach(function (subview, index, array) {
377
+
378
+ subview.removeFromSuperview()
379
+
380
+ })
381
+
382
+ this._slideViews.forEach(function (view, index, array) {
383
+
384
+ this._scrollView.addSubview(view)
385
+
386
+ this.pageIndicatorsView.addSubview(this.buttonForPageIndicatorWithIndex(index))
387
+
388
+ }.bind(this))
389
+
390
+ }
391
+
392
+
393
+ didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {
394
+
395
+ super.didReceiveBroadcastEvent(event)
396
+
397
+ if (event.name == UICore.broadcastEventName.WindowDidResize) {
398
+
399
+ this.currentPageIndex = this.currentPageIndex
400
+
401
+
402
+ }
403
+
404
+
405
+ }
406
+
407
+
408
+ set frame(frame: UIRectangle) {
409
+
410
+ super.frame = frame
411
+
412
+ this.currentPageIndex = this.currentPageIndex
413
+
414
+ }
415
+
416
+ get frame() {
417
+
418
+ return super.frame
419
+
420
+ }
421
+
422
+
423
+
424
+
425
+
426
+ layoutSubviews() {
427
+
428
+ super.layoutSubviews()
429
+
430
+ if (this.bounds.isEqualTo(this._previousLayoutBounds)) {
431
+ return
432
+ }
433
+
434
+ const bounds = this.bounds
435
+
436
+ this._previousLayoutBounds = bounds
437
+
438
+ this._scrollView.frame = bounds
439
+
440
+
441
+
442
+ this._scrollView.containerView.frame = bounds.rectangleWithWidth(bounds.width *
443
+ this.slideViews.length).performFunctionWithSelf(function (this: UISlideScrollerView, self: UIRectangle) {
444
+
445
+ self.offsetByPoint(this._scrollView.contentOffset)
446
+
447
+ return self
448
+
449
+ }.bind(this))
450
+
451
+ this._slideViews.forEach(function (view, index, array) {
452
+
453
+ view.frame = bounds.rectangleWithX((this.bounds.width + 1) * index)
454
+
455
+ }.bind(this))
456
+
457
+
458
+ this.layoutPageIndicators()
459
+
460
+
461
+ }
462
+
463
+
464
+ layoutPageIndicators() {
465
+
466
+ this.pageIndicatorsView.centerXInContainer()
467
+ this.pageIndicatorsView.style.bottom = "20px"
468
+ this.pageIndicatorsView.style.height = "20px"
469
+ this.pageIndicatorsView.style.display = "table-row"
470
+
471
+ }
472
+
473
+
474
+
475
+
476
+ removeFromSuperview() {
477
+
478
+
479
+ super.removeFromSuperview()
480
+
481
+ this.stopAnimating()
482
+
483
+
484
+ }
485
+
486
+
487
+
488
+
489
+
490
+ }
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+