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,427 @@
|
|
|
1
|
+
import { UIObject } from "./UIObject"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export interface UIColorDescriptor {
|
|
5
|
+
|
|
6
|
+
red: number;
|
|
7
|
+
green: number;
|
|
8
|
+
blue: number;
|
|
9
|
+
alpha?: number;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export class UIColor extends UIObject {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
constructor(public stringValue: string) {
|
|
21
|
+
|
|
22
|
+
super()
|
|
23
|
+
|
|
24
|
+
this._class = UIColor
|
|
25
|
+
this.superclass = UIObject
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
toString() {
|
|
34
|
+
return this.stringValue
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static get redColor() {
|
|
38
|
+
return new UIColor("red")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get blueColor() {
|
|
42
|
+
return new UIColor("blue")
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static get greenColor() {
|
|
46
|
+
return new UIColor("green")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get yellowColor() {
|
|
50
|
+
return new UIColor("yellow")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static get blackColor() {
|
|
54
|
+
return new UIColor("black")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static get brownColor() {
|
|
58
|
+
return new UIColor("brown")
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static get whiteColor() {
|
|
62
|
+
return new UIColor("white")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get greyColor() {
|
|
66
|
+
return new UIColor("grey")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static get lightGreyColor() {
|
|
70
|
+
return new UIColor("lightgrey")
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static get transparentColor() {
|
|
74
|
+
return new UIColor("transparent")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static get undefinedColor() {
|
|
78
|
+
return new UIColor("")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static get nilColor() {
|
|
82
|
+
return new UIColor("")
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
static nameToHex(name: string) {
|
|
88
|
+
return {
|
|
89
|
+
"aliceblue": "#f0f8ff",
|
|
90
|
+
"antiquewhite": "#faebd7",
|
|
91
|
+
"aqua": "#00ffff",
|
|
92
|
+
"aquamarine": "#7fffd4",
|
|
93
|
+
"azure": "#f0ffff",
|
|
94
|
+
"beige": "#f5f5dc",
|
|
95
|
+
"bisque": "#ffe4c4",
|
|
96
|
+
"black": "#000000",
|
|
97
|
+
"blanchedalmond": "#ffebcd",
|
|
98
|
+
"blue": "#0000ff",
|
|
99
|
+
"blueviolet": "#8a2be2",
|
|
100
|
+
"brown": "#a52a2a",
|
|
101
|
+
"burlywood": "#deb887",
|
|
102
|
+
"cadetblue": "#5f9ea0",
|
|
103
|
+
"chartreuse": "#7fff00",
|
|
104
|
+
"chocolate": "#d2691e",
|
|
105
|
+
"coral": "#ff7f50",
|
|
106
|
+
"cornflowerblue": "#6495ed",
|
|
107
|
+
"cornsilk": "#fff8dc",
|
|
108
|
+
"crimson": "#dc143c",
|
|
109
|
+
"cyan": "#00ffff",
|
|
110
|
+
"darkblue": "#00008b",
|
|
111
|
+
"darkcyan": "#008b8b",
|
|
112
|
+
"darkgoldenrod": "#b8860b",
|
|
113
|
+
"darkgray": "#a9a9a9",
|
|
114
|
+
"darkgreen": "#006400",
|
|
115
|
+
"darkkhaki": "#bdb76b",
|
|
116
|
+
"darkmagenta": "#8b008b",
|
|
117
|
+
"darkolivegreen": "#556b2f",
|
|
118
|
+
"darkorange": "#ff8c00",
|
|
119
|
+
"darkorchid": "#9932cc",
|
|
120
|
+
"darkred": "#8b0000",
|
|
121
|
+
"darksalmon": "#e9967a",
|
|
122
|
+
"darkseagreen": "#8fbc8f",
|
|
123
|
+
"darkslateblue": "#483d8b",
|
|
124
|
+
"darkslategray": "#2f4f4f",
|
|
125
|
+
"darkturquoise": "#00ced1",
|
|
126
|
+
"darkviolet": "#9400d3",
|
|
127
|
+
"deeppink": "#ff1493",
|
|
128
|
+
"deepskyblue": "#00bfff",
|
|
129
|
+
"dimgray": "#696969",
|
|
130
|
+
"dodgerblue": "#1e90ff",
|
|
131
|
+
"firebrick": "#b22222",
|
|
132
|
+
"floralwhite": "#fffaf0",
|
|
133
|
+
"forestgreen": "#228b22",
|
|
134
|
+
"fuchsia": "#ff00ff",
|
|
135
|
+
"gainsboro": "#dcdcdc",
|
|
136
|
+
"ghostwhite": "#f8f8ff",
|
|
137
|
+
"gold": "#ffd700",
|
|
138
|
+
"goldenrod": "#daa520",
|
|
139
|
+
"gray": "#808080",
|
|
140
|
+
"green": "#008000",
|
|
141
|
+
"greenyellow": "#adff2f",
|
|
142
|
+
"honeydew": "#f0fff0",
|
|
143
|
+
"hotpink": "#ff69b4",
|
|
144
|
+
"indianred ": "#cd5c5c",
|
|
145
|
+
"indigo": "#4b0082",
|
|
146
|
+
"ivory": "#fffff0",
|
|
147
|
+
"khaki": "#f0e68c",
|
|
148
|
+
"lavender": "#e6e6fa",
|
|
149
|
+
"lavenderblush": "#fff0f5",
|
|
150
|
+
"lawngreen": "#7cfc00",
|
|
151
|
+
"lemonchiffon": "#fffacd",
|
|
152
|
+
"lightblue": "#add8e6",
|
|
153
|
+
"lightcoral": "#f08080",
|
|
154
|
+
"lightcyan": "#e0ffff",
|
|
155
|
+
"lightgoldenrodyellow": "#fafad2",
|
|
156
|
+
"lightgrey": "#d3d3d3",
|
|
157
|
+
"lightgreen": "#90ee90",
|
|
158
|
+
"lightpink": "#ffb6c1",
|
|
159
|
+
"lightsalmon": "#ffa07a",
|
|
160
|
+
"lightseagreen": "#20b2aa",
|
|
161
|
+
"lightskyblue": "#87cefa",
|
|
162
|
+
"lightslategray": "#778899",
|
|
163
|
+
"lightsteelblue": "#b0c4de",
|
|
164
|
+
"lightyellow": "#ffffe0",
|
|
165
|
+
"lime": "#00ff00",
|
|
166
|
+
"limegreen": "#32cd32",
|
|
167
|
+
"linen": "#faf0e6",
|
|
168
|
+
"magenta": "#ff00ff",
|
|
169
|
+
"maroon": "#800000",
|
|
170
|
+
"mediumaquamarine": "#66cdaa",
|
|
171
|
+
"mediumblue": "#0000cd",
|
|
172
|
+
"mediumorchid": "#ba55d3",
|
|
173
|
+
"mediumpurple": "#9370d8",
|
|
174
|
+
"mediumseagreen": "#3cb371",
|
|
175
|
+
"mediumslateblue": "#7b68ee",
|
|
176
|
+
"mediumspringgreen": "#00fa9a",
|
|
177
|
+
"mediumturquoise": "#48d1cc",
|
|
178
|
+
"mediumvioletred": "#c71585",
|
|
179
|
+
"midnightblue": "#191970",
|
|
180
|
+
"mintcream": "#f5fffa",
|
|
181
|
+
"mistyrose": "#ffe4e1",
|
|
182
|
+
"moccasin": "#ffe4b5",
|
|
183
|
+
"navajowhite": "#ffdead",
|
|
184
|
+
"navy": "#000080",
|
|
185
|
+
"oldlace": "#fdf5e6",
|
|
186
|
+
"olive": "#808000",
|
|
187
|
+
"olivedrab": "#6b8e23",
|
|
188
|
+
"orange": "#ffa500",
|
|
189
|
+
"orangered": "#ff4500",
|
|
190
|
+
"orchid": "#da70d6",
|
|
191
|
+
"palegoldenrod": "#eee8aa",
|
|
192
|
+
"palegreen": "#98fb98",
|
|
193
|
+
"paleturquoise": "#afeeee",
|
|
194
|
+
"palevioletred": "#d87093",
|
|
195
|
+
"papayawhip": "#ffefd5",
|
|
196
|
+
"peachpuff": "#ffdab9",
|
|
197
|
+
"peru": "#cd853f",
|
|
198
|
+
"pink": "#ffc0cb",
|
|
199
|
+
"plum": "#dda0dd",
|
|
200
|
+
"powderblue": "#b0e0e6",
|
|
201
|
+
"purple": "#800080",
|
|
202
|
+
"red": "#ff0000",
|
|
203
|
+
"rosybrown": "#bc8f8f",
|
|
204
|
+
"royalblue": "#4169e1",
|
|
205
|
+
"saddlebrown": "#8b4513",
|
|
206
|
+
"salmon": "#fa8072",
|
|
207
|
+
"sandybrown": "#f4a460",
|
|
208
|
+
"seagreen": "#2e8b57",
|
|
209
|
+
"seashell": "#fff5ee",
|
|
210
|
+
"sienna": "#a0522d",
|
|
211
|
+
"silver": "#c0c0c0",
|
|
212
|
+
"skyblue": "#87ceeb",
|
|
213
|
+
"slateblue": "#6a5acd",
|
|
214
|
+
"slategray": "#708090",
|
|
215
|
+
"snow": "#fffafa",
|
|
216
|
+
"springgreen": "#00ff7f",
|
|
217
|
+
"steelblue": "#4682b4",
|
|
218
|
+
"tan": "#d2b48c",
|
|
219
|
+
"teal": "#008080",
|
|
220
|
+
"thistle": "#d8bfd8",
|
|
221
|
+
"tomato": "#ff6347",
|
|
222
|
+
"turquoise": "#40e0d0",
|
|
223
|
+
"violet": "#ee82ee",
|
|
224
|
+
"wheat": "#f5deb3",
|
|
225
|
+
"white": "#ffffff",
|
|
226
|
+
"whitesmoke": "#f5f5f5",
|
|
227
|
+
"yellow": "#ffff00",
|
|
228
|
+
"yellowgreen": "#9acd32"
|
|
229
|
+
}[name.toLowerCase()]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
static hexToDescriptor(c: string): UIColorDescriptor {
|
|
235
|
+
if (c[0] === "#") {
|
|
236
|
+
c = c.substr(1)
|
|
237
|
+
}
|
|
238
|
+
const r = parseInt(c.slice(0, 2), 16)
|
|
239
|
+
const g = parseInt(c.slice(2, 4), 16)
|
|
240
|
+
const b = parseInt(c.slice(4, 6), 16)
|
|
241
|
+
const a = parseInt(c.slice(6, 8), 16)
|
|
242
|
+
|
|
243
|
+
const result = { "red": r, "green": g, "blue": b, "alpha": a }
|
|
244
|
+
|
|
245
|
+
return result
|
|
246
|
+
|
|
247
|
+
//return 'rgb(' + r + ',' + g + ',' + b + ')';
|
|
248
|
+
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static rgbToDescriptor(colorString: string) {
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
if (colorString.startsWith("rgba(")) {
|
|
255
|
+
|
|
256
|
+
colorString = colorString.slice(5, colorString.length - 1)
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (colorString.startsWith("rgb(")) {
|
|
261
|
+
|
|
262
|
+
colorString = colorString.slice(4, colorString.length - 1) + ", 0"
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
const components = colorString.split(",")
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
const result = {
|
|
272
|
+
"red": Number(components[0]),
|
|
273
|
+
"green": Number(components[1]),
|
|
274
|
+
"blue": Number(components[2]),
|
|
275
|
+
"alpha": Number(components[3])
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
return result
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
get colorDescriptor(): UIColorDescriptor {
|
|
287
|
+
|
|
288
|
+
var descriptor
|
|
289
|
+
|
|
290
|
+
const colorHEXFromName = UIColor.nameToHex(this.stringValue)
|
|
291
|
+
|
|
292
|
+
if (this.stringValue.startsWith("rgb")) {
|
|
293
|
+
|
|
294
|
+
descriptor = UIColor.rgbToDescriptor(this.stringValue)
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
else if (colorHEXFromName) {
|
|
298
|
+
|
|
299
|
+
descriptor = UIColor.hexToDescriptor(colorHEXFromName)
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
|
|
304
|
+
descriptor = UIColor.hexToDescriptor(this.stringValue)
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return descriptor
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
colorWithRed(red: number) {
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
const descriptor = this.colorDescriptor
|
|
318
|
+
|
|
319
|
+
const result = new UIColor("rgba(" + red + "," + descriptor.green + "," + descriptor.blue + "," +
|
|
320
|
+
descriptor.alpha + ")")
|
|
321
|
+
|
|
322
|
+
return result
|
|
323
|
+
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
colorWithGreen(green: number) {
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
const descriptor = this.colorDescriptor
|
|
330
|
+
|
|
331
|
+
const result = new UIColor("rgba(" + descriptor.red + "," + green + "," + descriptor.blue + "," +
|
|
332
|
+
descriptor.alpha + ")")
|
|
333
|
+
|
|
334
|
+
return result
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
colorWithBlue(blue: number) {
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
const descriptor = this.colorDescriptor
|
|
342
|
+
|
|
343
|
+
const result = new UIColor("rgba(" + descriptor.red + "," + descriptor.green + "," + blue + "," +
|
|
344
|
+
descriptor.alpha + ")")
|
|
345
|
+
|
|
346
|
+
return result
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
colorWithAlpha(alpha: number) {
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
const descriptor = this.colorDescriptor
|
|
355
|
+
|
|
356
|
+
const result = new UIColor("rgba(" + descriptor.red + "," + descriptor.green + "," + descriptor.blue + "," +
|
|
357
|
+
alpha + ")")
|
|
358
|
+
|
|
359
|
+
return result
|
|
360
|
+
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
static colorWithRGBA(red: number, green: number, blue: number, alpha: number = 1) {
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
const result = new UIColor("rgba(" + red + "," + green + "," + blue + "," + alpha + ")")
|
|
369
|
+
|
|
370
|
+
return result
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
static colorWithDescriptor(descriptor: UIColorDescriptor) {
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
const result = new UIColor("rgba(" + descriptor.red.toFixed(0) + "," + descriptor.green.toFixed(0) + "," +
|
|
379
|
+
descriptor.blue.toFixed(0) + "," + this.defaultAlphaToOne(descriptor.alpha) + ")")
|
|
380
|
+
|
|
381
|
+
return result
|
|
382
|
+
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
private static defaultAlphaToOne(value = 1) {
|
|
387
|
+
if (value != value) {
|
|
388
|
+
value = 1
|
|
389
|
+
}
|
|
390
|
+
return value
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
colorByMultiplyingRGB(multiplier: number) {
|
|
396
|
+
|
|
397
|
+
const descriptor = this.colorDescriptor
|
|
398
|
+
|
|
399
|
+
descriptor.red = descriptor.red * multiplier
|
|
400
|
+
descriptor.green = descriptor.green * multiplier
|
|
401
|
+
descriptor.blue = descriptor.blue * multiplier
|
|
402
|
+
|
|
403
|
+
const result = UIColor.colorWithDescriptor(descriptor)
|
|
404
|
+
|
|
405
|
+
return result
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { nil, NO, UIObject } from "./UIObject"
|
|
2
|
+
import { UIRoute } from "./UIRoute"
|
|
3
|
+
import { UIView } from "./UIView"
|
|
4
|
+
import { UIViewController } from "./UIViewController"
|
|
5
|
+
import "./UICoreExtensions"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface UILanguageService {
|
|
12
|
+
|
|
13
|
+
currentLanguageKey: string;
|
|
14
|
+
|
|
15
|
+
stringForKey(
|
|
16
|
+
key: string,
|
|
17
|
+
languageName: string,
|
|
18
|
+
defaultString: string,
|
|
19
|
+
parameters: { [x: string]: string | UILocalizedTextObject; }
|
|
20
|
+
): string | undefined;
|
|
21
|
+
|
|
22
|
+
stringForCurrentLanguage(localizedTextObject: UILocalizedTextObject);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export interface UILocalizedTextObject {
|
|
30
|
+
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export class UICore extends UIObject {
|
|
40
|
+
|
|
41
|
+
rootViewController: UIViewController = nil
|
|
42
|
+
static RootViewControllerClass: any
|
|
43
|
+
static main: UICore
|
|
44
|
+
|
|
45
|
+
static languageService: UILanguageService = nil
|
|
46
|
+
|
|
47
|
+
constructor(rootDivElementID: string, rootViewControllerClass: typeof UIViewController) {
|
|
48
|
+
|
|
49
|
+
super()
|
|
50
|
+
|
|
51
|
+
this._class = UICore
|
|
52
|
+
this.superclass = UIObject
|
|
53
|
+
|
|
54
|
+
UICore.RootViewControllerClass = rootViewControllerClass
|
|
55
|
+
|
|
56
|
+
UICore.main = this
|
|
57
|
+
|
|
58
|
+
const rootViewElement = document.getElementById(rootDivElementID)
|
|
59
|
+
|
|
60
|
+
const rootView = new UIView(rootDivElementID, rootViewElement)
|
|
61
|
+
|
|
62
|
+
rootView.pausesPointerEvents = NO //YES;
|
|
63
|
+
|
|
64
|
+
if (UICore.RootViewControllerClass) {
|
|
65
|
+
|
|
66
|
+
if (!(UICore.RootViewControllerClass.prototype instanceof UIViewController) ||
|
|
67
|
+
(UICore.RootViewControllerClass as any) === UIViewController) {
|
|
68
|
+
|
|
69
|
+
console.log(
|
|
70
|
+
"Error, UICore.RootViewControllerClass must be a or a subclass of UIViewController, falling back to UIViewController.")
|
|
71
|
+
|
|
72
|
+
UICore.RootViewControllerClass = UIViewController
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.rootViewController = new UICore.RootViewControllerClass(rootView)
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
|
|
81
|
+
this.rootViewController = new UIViewController(rootView)
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.rootViewController.viewWillAppear()
|
|
86
|
+
this.rootViewController.viewDidAppear()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
this.rootViewController.view.addTargetForControlEvent(
|
|
90
|
+
UIView.controlEvent.PointerUpInside,
|
|
91
|
+
function (sender, event) {
|
|
92
|
+
|
|
93
|
+
(document.activeElement as HTMLElement).blur()
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
const windowDidResize = function (this: UICore) {
|
|
101
|
+
|
|
102
|
+
// Doing layout two times to prevent page scrollbars from confusing the layout
|
|
103
|
+
this.rootViewController._layoutViewSubviews()
|
|
104
|
+
UIView.layoutViewsIfNeeded()
|
|
105
|
+
|
|
106
|
+
this.rootViewController._layoutViewSubviews()
|
|
107
|
+
//UIView.layoutViewsIfNeeded()
|
|
108
|
+
|
|
109
|
+
this.rootViewController.view.broadcastEventInSubtree({
|
|
110
|
+
|
|
111
|
+
name: UICore.broadcastEventName.WindowDidResize,
|
|
112
|
+
parameters: nil
|
|
113
|
+
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
window.addEventListener("resize", windowDidResize.bind(this))
|
|
119
|
+
|
|
120
|
+
const didScroll = function (this: UICore) {
|
|
121
|
+
|
|
122
|
+
//code
|
|
123
|
+
|
|
124
|
+
this.rootViewController.view.broadcastEventInSubtree({
|
|
125
|
+
|
|
126
|
+
name: UIView.broadcastEventName.PageDidScroll,
|
|
127
|
+
parameters: nil
|
|
128
|
+
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
}.bind(this)
|
|
134
|
+
|
|
135
|
+
window.addEventListener("scroll", didScroll, false)
|
|
136
|
+
|
|
137
|
+
const hashDidChange = function (this: UICore) {
|
|
138
|
+
|
|
139
|
+
//code
|
|
140
|
+
|
|
141
|
+
this.rootViewController.handleRouteRecursively(UIRoute.currentRoute)
|
|
142
|
+
|
|
143
|
+
this.rootViewController.view.broadcastEventInSubtree({
|
|
144
|
+
|
|
145
|
+
name: UICore.broadcastEventName.RouteDidChange,
|
|
146
|
+
parameters: nil
|
|
147
|
+
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
}.bind(this)
|
|
152
|
+
|
|
153
|
+
window.addEventListener("hashchange", hashDidChange.bind(this), false)
|
|
154
|
+
|
|
155
|
+
hashDidChange()
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
static broadcastEventName = {
|
|
163
|
+
|
|
164
|
+
"RouteDidChange": "RouteDidChange",
|
|
165
|
+
"WindowDidResize": "WindowDidResize"
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
static loadClass(className: string) {
|
|
171
|
+
|
|
172
|
+
if (window[className]) {
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
document.writeln("<script type='text/javascript' src='dist/UICore/" + className + ".js'></script>")
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
UICore.RootViewControllerClass = nil
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
export const IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf("firefox") > -1
|
|
188
|
+
export const IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
Array.prototype.indexOf || (Array.prototype.indexOf = function (d, e) {
|
|
192
|
+
var a
|
|
193
|
+
if (null == this) {
|
|
194
|
+
throw new TypeError("\"this\" is null or not defined")
|
|
195
|
+
}
|
|
196
|
+
const c = Object(this),
|
|
197
|
+
b = c.length >>> 0
|
|
198
|
+
if (0 === b) {
|
|
199
|
+
return -1
|
|
200
|
+
}
|
|
201
|
+
a = +e || 0
|
|
202
|
+
Infinity === Math.abs(a) && (a = 0)
|
|
203
|
+
if (a >= b) {
|
|
204
|
+
return -1
|
|
205
|
+
}
|
|
206
|
+
for (a = Math.max(0 <= a ? a : b - Math.abs(a), 0); a < b;) {
|
|
207
|
+
if (a in c && c[a] === d) {
|
|
208
|
+
return a
|
|
209
|
+
}
|
|
210
|
+
a++
|
|
211
|
+
}
|
|
212
|
+
return -1
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|