@breakside/jskit 2021.36.0 → 2021.39.0

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 (105) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  3. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  4. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  5. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  6. package/Frameworks/Foundation.jsframework/JS/JSColor+HTML.js +11 -2
  7. package/Frameworks/Foundation.jsframework/JS/JSColor.js +62 -26
  8. package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +209 -1
  9. package/Frameworks/Foundation.jsframework/JS/JSSpec.js +1 -1
  10. package/Frameworks/Foundation.jsframework/JS/JSSynchronizer.js +9 -1
  11. package/Frameworks/Foundation.jsframework/JS/JSURL.js +42 -3
  12. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  13. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  14. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  15. package/Info.json +2 -2
  16. package/Node/HTMLBuilder.js +10 -10
  17. package/Node/NodeBuilder.js +10 -7
  18. package/Node/io.breakside.jskit-bundle.js +4 -4
  19. package/Resources/doc-default.css +86 -0
  20. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  21. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  22. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  23. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  24. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  25. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  26. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  27. package/Root/Frameworks/DOM/Info.yaml +1 -1
  28. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  29. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  30. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  31. package/Root/Frameworks/Foundation/JSColor+HTML.js +11 -2
  32. package/Root/Frameworks/Foundation/JSColor.js +62 -26
  33. package/Root/Frameworks/Foundation/JSColorSpace.js +209 -1
  34. package/Root/Frameworks/Foundation/JSSpec.js +1 -1
  35. package/Root/Frameworks/Foundation/JSSynchronizer.js +9 -1
  36. package/Root/Frameworks/Foundation/JSURL.js +42 -3
  37. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  38. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  39. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  40. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  41. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  42. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  43. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  44. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  45. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  46. package/Root/Frameworks/ServerKit/SKValidatingObject.js +21 -0
  47. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  48. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  49. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  50. package/Root/Frameworks/UIKit/JSColor+UIKit.js +75 -0
  51. package/Root/Frameworks/UIKit/UIAccessibility.js +15 -0
  52. package/Root/Frameworks/UIKit/UIActivityIndicatorView.js +2 -1
  53. package/Root/Frameworks/UIKit/UIAlertController.js +4 -3
  54. package/Root/Frameworks/UIKit/UIAnimation.js +7 -13
  55. package/Root/Frameworks/UIKit/UIApplication.js +3 -0
  56. package/Root/Frameworks/UIKit/UIBasicAnimation.js +6 -0
  57. package/Root/Frameworks/UIKit/UIButton.js +48 -25
  58. package/Root/Frameworks/UIKit/UICheckbox.js +11 -22
  59. package/Root/Frameworks/UIKit/UIColorPanel.js +27 -15
  60. package/Root/Frameworks/UIKit/UIColorSpace.js +132 -0
  61. package/Root/Frameworks/UIKit/UIColorWell.js +18 -2
  62. package/Root/Frameworks/UIKit/UIControl.js +15 -4
  63. package/Root/Frameworks/UIKit/UIHTMLDisplayServer.js +1 -5
  64. package/Root/Frameworks/UIKit/UIHTMLTextField.js +3 -15
  65. package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +72 -1
  66. package/Root/Frameworks/UIKit/UIImageView.js +4 -0
  67. package/Root/Frameworks/UIKit/UIKit.js +2 -0
  68. package/Root/Frameworks/UIKit/UILabel.js +14 -2
  69. package/Root/Frameworks/UIKit/UILayer.js +29 -1
  70. package/Root/Frameworks/UIKit/UIListView.js +23 -12
  71. package/Root/Frameworks/UIKit/UIListViewCell.js +10 -2
  72. package/Root/Frameworks/UIKit/UIMenu.js +21 -13
  73. package/Root/Frameworks/UIKit/UIMenuBar.js +5 -4
  74. package/Root/Frameworks/UIKit/UIMenuView.js +9 -5
  75. package/Root/Frameworks/UIKit/UINavigationBar.js +8 -5
  76. package/Root/Frameworks/UIKit/UINavigationController.js +3 -2
  77. package/Root/Frameworks/UIKit/UIOutlineViewCell.js +2 -1
  78. package/Root/Frameworks/UIKit/UIPopupButton.js +13 -24
  79. package/Root/Frameworks/UIKit/UIPopupWindow.js +3 -2
  80. package/Root/Frameworks/UIKit/UIProgressIndicatorView.js +1 -1
  81. package/Root/Frameworks/UIKit/UIRadioGroup.js +11 -22
  82. package/Root/Frameworks/UIKit/UIScroller.js +4 -3
  83. package/Root/Frameworks/UIKit/UISegmentedControl.js +16 -15
  84. package/Root/Frameworks/UIKit/UISlider.js +20 -36
  85. package/Root/Frameworks/UIKit/UISplitView.js +40 -0
  86. package/Root/Frameworks/UIKit/UISplitViewController.js +7 -7
  87. package/Root/Frameworks/UIKit/UISplitViewDivider.js +9 -0
  88. package/Root/Frameworks/UIKit/UITabView.js +34 -31
  89. package/Root/Frameworks/UIKit/UITextEditor.js +2 -1
  90. package/Root/Frameworks/UIKit/UITextField.js +34 -23
  91. package/Root/Frameworks/UIKit/UITextLayer.js +5 -0
  92. package/Root/Frameworks/UIKit/UITokenField.js +3 -3
  93. package/Root/Frameworks/UIKit/UIToolbar.js +84 -38
  94. package/Root/Frameworks/UIKit/UIToolbarOverflow.svg +8 -0
  95. package/Root/Frameworks/UIKit/UITooltipWindow.js +38 -15
  96. package/Root/Frameworks/UIKit/UITraitCollection.js +21 -0
  97. package/Root/Frameworks/UIKit/UIUserInterface.js +6 -0
  98. package/Root/Frameworks/UIKit/UIWebView.js +3 -2
  99. package/Root/Frameworks/UIKit/UIWindow.js +139 -21
  100. package/Root/Frameworks/UIKit/UIWindowButtonCloseInactive.svg +1 -1
  101. package/Root/Frameworks/UIKit/UIWindowButtonCloseNormal.svg +1 -1
  102. package/Root/Frameworks/UIKit/UIWindowServer.js +72 -9
  103. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  104. package/Root/Templates/html/${PROJECT_NAME}/www/index.html +24 -4
  105. package/package.json +1 -1
@@ -21,6 +21,7 @@
21
21
  // #import "UITextAttachmentView.js"
22
22
  // #import "UIImageView.js"
23
23
  // #import "UIPasteboard.js"
24
+ // #import "JSColor+UIKit.js"
24
25
  'use strict';
25
26
 
26
27
  (function(){
@@ -133,6 +134,9 @@ JSClass("UITextField", UIControl, {
133
134
  if (this._styler === null){
134
135
  this._styler = UITextField.Styler.default;
135
136
  }
137
+ this.hasOverState = this._styler.showsOverState;
138
+ this.textColor = JSColor.text;
139
+ this._placeholderColor = JSColor.placeholderText;
136
140
  this._styler.initializeControl(this);
137
141
  },
138
142
 
@@ -237,22 +241,11 @@ JSClass("UITextField", UIControl, {
237
241
  this._placeholderLabel.hidden = true;
238
242
  this._placeholderLabel.layer.widthTracksText = this._textLayer.widthTracksText;
239
243
  this._placeholderLabel.layer.heightTracksText = true;
240
- if (this._placeholderColor === null){
241
- this._createPlaceholderColor();
242
- }
243
244
  this._placeholderLabel.textColor = this._placeholderColor;
244
245
  this._clipView.insertSubviewAtIndex(this._placeholderLabel, 0);
245
246
  this._clipView.layer.insertSublayerBelowSibling(this._placeholderLabel.layer, this._textLayer);
246
247
  },
247
248
 
248
- _createPlaceholderColor: function(){
249
- var backgroundColor = this.backgroundColor;
250
- if (backgroundColor === null){
251
- backgroundColor = JSColor.white;
252
- }
253
- this._placeholderColor = backgroundColor.colorByBlendingColor(this.textColor, 0.3);
254
- },
255
-
256
249
  _placeholderLabel: null,
257
250
 
258
251
  _isShowingPlaceholder: false,
@@ -1266,7 +1259,7 @@ JSClass("UITextFieldStyler", UIControlStyler, {
1266
1259
 
1267
1260
  _commonStylerInit: function(){
1268
1261
  if (this.localCursorColor === null){
1269
- this.localCursorColor = JSColor.initWithRGBA(0, 128/255.0, 255/255.0, 1);
1262
+ this.localCursorColor = JSColor.highlight;
1270
1263
  }
1271
1264
  },
1272
1265
 
@@ -1316,8 +1309,8 @@ JSClass("UITextFieldDefaultStyler", UITextFieldStyler, {
1316
1309
  },
1317
1310
 
1318
1311
  _commonDefaultStylerInit: function(){
1319
- this.activeColor = JSColor.black;
1320
- this.inactiveColor = JSColor.initWithWhite(0.8);
1312
+ this.activeColor = JSColor.highlight;
1313
+ this.inactiveColor = JSColor.text.colorWithAlpha(0.2);
1321
1314
  this.textInsets = JSInsets(3, 0);
1322
1315
  },
1323
1316
 
@@ -1354,6 +1347,8 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1354
1347
  activeBackgroundColor: null,
1355
1348
  disabledBackgroundColor: null,
1356
1349
  borderColor: null,
1350
+ overBackgroundColor: null,
1351
+ overBorderColor: null,
1357
1352
  activeBorderColor: null,
1358
1353
  disabledBorderColor: null,
1359
1354
  borderWidth: 0,
@@ -1363,6 +1358,11 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1363
1358
  textInsets: null,
1364
1359
  showsFocusRing: true,
1365
1360
 
1361
+ init: function(){
1362
+ UITextFieldCustomStyler.$super.init.call(this);
1363
+ this.textColor = JSColor.text;
1364
+ },
1365
+
1366
1366
  initWithSpec: function(spec){
1367
1367
  UITextFieldCustomStyler.$super.initWithSpec.call(this, spec);
1368
1368
  if (spec.containsKey("backgroundColor")){
@@ -1385,6 +1385,8 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1385
1385
  }
1386
1386
  if (spec.containsKey("textColor")){
1387
1387
  this.textColor = spec.valueForKey("textColor", JSColor);
1388
+ }else{
1389
+ this.textColor = JSColor.text;
1388
1390
  }
1389
1391
  if (spec.containsKey("placeholderColor")){
1390
1392
  this.placeholderColor = spec.valueForKey("placeholderColor", JSColor);
@@ -1399,7 +1401,13 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1399
1401
  this.textInsets = spec.valueForKey("textInsets", JSInsets);
1400
1402
  }
1401
1403
  if (spec.containsKey("showsFocusRing")){
1402
- this.showsFocusRing = spec.valueForKey("showsFocusRing", JSInsets);
1404
+ this.showsFocusRing = spec.valueForKey("showsFocusRing");
1405
+ }
1406
+ if (spec.containsKey("overBackgroundColor")){
1407
+ this.overBackgroundColor = spec.valueForKey("overBackgroundColor", JSColor);
1408
+ }
1409
+ if (spec.containsKey("overBorderColor")){
1410
+ this.overBorderColor = spec.valueForKey("overBorderColor", JSColor);
1403
1411
  }
1404
1412
  },
1405
1413
 
@@ -1422,16 +1430,19 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1422
1430
  updateControl: function(textField){
1423
1431
  UITextFieldCustomStyler.$super.updateControl.call(this, textField);
1424
1432
  if (textField.active){
1425
- if (this.activeBackgroundColor){
1426
- textField.backgroundColor = this.activeBackgroundColor;
1427
- textField.borderColor = this.activeBorderColor;
1433
+ textField.backgroundColor = this.activeBackgroundColor || this.backgroundColor;
1434
+ textField.borderColor = this.activeBorderColor || this.borderColor;
1435
+ }else if (textField.enabled){
1436
+ if (textField.over){
1437
+ textField.backgroundColor = this.overBackgroundColor || this.backgroundColor;
1438
+ textField.borderColor = this.overBorderColor || this.borderColor;
1439
+ }else{
1440
+ textField.backgroundColor = this.backgroundColor;
1441
+ textField.borderColor = this.borderColor;
1428
1442
  }
1429
- }else if (!textField.enabled && this.disabledBackgroundColor !== null){
1430
- textField.backgroundColor = this.disabledBackgroundColor;
1431
- textField.borderColor = this.disabledBorderColor;
1432
1443
  }else{
1433
- textField.backgroundColor = this.backgroundColor;
1434
- textField.borderColor = this.borderColor;
1444
+ textField.backgroundColor = this.disabledBackgroundColor || this.backgroundColor;
1445
+ textField.borderColor = this.disabledBorderColor || this.borderColor;
1435
1446
  }
1436
1447
  },
1437
1448
 
@@ -261,6 +261,11 @@ JSClass("UITextLayer", UILayer, {
261
261
  return this._textContainer;
262
262
  },
263
263
 
264
+ setNeedsRedisplay: function(){
265
+ UITextLayer.$super.setNeedsRedisplay.call(this);
266
+ this._textLayoutManager.setNeedsLayout();
267
+ }
268
+
264
269
  });
265
270
 
266
271
  })();
@@ -173,7 +173,7 @@ JSClass("UITokenField", UITextField, {
173
173
  }
174
174
  str = representedObject.toString();
175
175
  return UITokenFieldTokenView.initWithString(str, this);
176
- },
176
+ }
177
177
 
178
178
  });
179
179
 
@@ -194,8 +194,8 @@ JSClass("UITokenFieldTokenView", UIView, {
194
194
  this.textField = textField;
195
195
  this.tokenLabel.font = this.textField.font;
196
196
  this.tokenLabel.text = str;
197
- this.tokenLabel.backgroundColor = JSColor.initWithRGBA(210/255, 231/255, 251/255, 1.0);
198
- this.tokenLabel.borderColor = JSColor.initWithRGBA(116/255, 181/255, 243/255, 1.0);
197
+ this.tokenLabel.backgroundColor = JSColor.initWithUIStyles(JSColor.highlight.colorLightenedByPercentage(0.8), JSColor.highlight.colorDarkenedByPercentage(0.6));
198
+ this.tokenLabel.borderColor = JSColor.initWithUIStyles(JSColor.highlight, JSColor.black);
199
199
  this.backgroundColor = null;
200
200
  this.tokenLabel.borderWidth = 0.5;
201
201
  this.tokenLabel.cornerRadius = 3.0;
@@ -32,6 +32,7 @@ JSClass("UIToolbar", UIView, {
32
32
  },
33
33
 
34
34
  initWithStyler: function(styler){
35
+ UIToolbar.$super.init.call(this);
35
36
  this._items = [];
36
37
  this._imageSize = UIToolbar.ImageSize.default;
37
38
  this._styler = styler;
@@ -117,7 +118,7 @@ JSClass("UIToolbar", UIView, {
117
118
 
118
119
  setShowsTitles: function(showsTitles){
119
120
  this._showsTitles = showsTitles;
120
- this._styler.updateToolbar();
121
+ this._styler.updateToolbar(this);
121
122
  },
122
123
 
123
124
  imageSize: JSDynamicProperty('_imageSize', 0),
@@ -176,7 +177,7 @@ UIToolbar.Styler = Object.create({}, {
176
177
  default: {
177
178
  configurable: true,
178
179
  get: function UIToolbarStyler_getDefault(){
179
- var styler = UIToolbarCustomStyler.initWithItemColor(JSColor.initWithWhite(0.2));
180
+ var styler = UIToolbarCustomStyler.init();
180
181
  styler.itemSpacing = 7;
181
182
  Object.defineProperty(this, 'default', {writable: true, value: styler});
182
183
  return styler;
@@ -235,6 +236,14 @@ JSClass("UIToolbarItemView", UIView, {
235
236
  break;
236
237
  }
237
238
  }
239
+ if (item.toolbar.showsTitles){
240
+ this.titleLabel.hidden = false;
241
+ this.titleLabel.text = item.title;
242
+ }else{
243
+ if (this._titleLabel !== null){
244
+ this._titleLabel.hidden = true;
245
+ }
246
+ }
238
247
  this.contentView.tooltip = item.tooltip;
239
248
  this.addSubview(this.contentView);
240
249
  },
@@ -242,38 +251,64 @@ JSClass("UIToolbarItemView", UIView, {
242
251
  _createTitleLabel: function(){
243
252
  var label = UILabel.init();
244
253
  label.textAlignment = JSTextAlignment.center;
254
+ label.font = this.item.toolbar.styler.itemFont;
245
255
  this.addSubview(label);
246
256
  return label;
247
257
  },
248
258
 
249
259
  layoutSubviews: function(){
250
260
  var toolbar = this._item.toolbar;
251
- if (this._item.identifier == UIToolbarItem.Identifier.custom && toolbar.showsTitles){
252
- var titleHeight = toolbar.styler.itemFont.displayLineHeight;
261
+ if (this._item.identifier == UIToolbarItem.Identifier.custom){
262
+ var bounds = this.bounds;
263
+ if (toolbar.showsTitles){
264
+ var titleHeight = toolbar.styler.itemFont.displayLineHeight;
265
+ this.titleLabel.frame = JSRect(0, bounds.size.height - titleHeight, bounds.size.width, titleHeight);
266
+ bounds = bounds.rectWithInsets(0, 0, titleHeight, 0);
267
+ }
253
268
  var width;
269
+ var height;
270
+ if (!isNaN(this._item.minimumWidth) && this._item.minimumWidth > 0){
271
+ width = this._item.minimumWidth;
272
+ }else if (this._item.view !== null){
273
+ width = this._item.view.intrinsicSize.width;
274
+ }else{
275
+ width = this._item.image.size.width * toolbar._imageSize / this._item.image.size.height;
276
+ }
254
277
  if (this._item.view !== null){
255
- width = this._item.minimumSize.width;
278
+ height = this._item.view.intrinsicSize.height;
279
+ if (height === UIView.noIntrinsicSize){
280
+ height = bounds.size.height;
281
+ }
256
282
  }else{
257
- width = this._item.image.size.width * toolbar.imageSize / this._item.image.size.height;
283
+ height = bounds.size.height;
258
284
  }
259
- this.contentView.frame = JSRect((this.bounds.size.width - width) / 2.0, 0, width, this.bounds.size.height - titleHeight);
260
- this.titleLabel.frame = JSRect(0, this.bounds.size.height - titleHeight, this.bounds.size.width, titleHeight);
285
+ this.contentView.frame = JSRect((bounds.size.width - width) / 2.0, (bounds.size.height - height) / 2.0, width, height);
261
286
  }else{
262
287
  this.contentView.frame = this.bounds;
263
288
  }
264
289
  },
265
290
 
266
291
  getIntrinsicSize: function(){
267
- var minWidth = this._item.minimumWidth;
268
- if (!isNaN(minWidth) && minWidth > 0){
269
- return JSSize(minWidth, UIView.noIntrinsicSize);
270
- }
271
- var contentSize = this.contentView.intrinsicSize;
272
- if (this._item.toolbar.showsTitles){
273
- var titleSize = this.titleLabel.intrinsicSize;
274
- return JSSize(Math.max(contentSize.width, titleSize.width), UIView.noIntrinsicSize);
292
+ var toolbar = this._item.toolbar;
293
+ var width;
294
+ if (this._item.identifier == UIToolbarItem.Identifier.custom){
295
+ if (!isNaN(this._item.minimumWidth) && this._item.minimumWidth > 0){
296
+ width = this._item.minimumWidth;
297
+ }else if (this._item.view !== null){
298
+ width = this._item.view.intrinsicSize.width;
299
+ }else{
300
+ width = this._item.image.size.width * toolbar._imageSize / this._item.image.size.height;
301
+ }
302
+ if (toolbar.showsTitles){
303
+ var titleSize = this.titleLabel.intrinsicSize;
304
+ if (titleSize.width > width){
305
+ width = Math.ceil(titleSize.width);
306
+ }
307
+ }
308
+ }else{
309
+ width = this.contentView.intrinsicSize.width;
275
310
  }
276
- return contentSize;
311
+ return JSSize(width, UIView.noIntrinsicSize);
277
312
  },
278
313
 
279
314
  mouseDown: function(event){
@@ -432,9 +467,14 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
432
467
  contentInsets: null,
433
468
  itemSpacing: 0,
434
469
 
435
- initWithItemColor: function(itemColor){
470
+ init: function(){
436
471
  this.contentInsets = JSInsets(5);
472
+ this._fillInMissingStyles();
473
+ },
474
+
475
+ initWithItemColor: function(itemColor){
437
476
  this.itemColor = itemColor;
477
+ this.contentInsets = JSInsets(5);
438
478
  this._fillInMissingStyles();
439
479
  },
440
480
 
@@ -468,13 +508,14 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
468
508
  this.itemFont = JSFont.systemFontOfSize(JSFont.Size.detail).fontWithWeight(JSFont.Weight.normal);
469
509
  }
470
510
  if (this.itemColor === null){
471
- this.itemColor = JSColor.initWithWhite(0.8);
511
+ this.itemColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.7), JSColor.white.colorWithAlpha(0.7));
512
+ this.activeItemColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.9), JSColor.white.colorWithAlpha(0.5));
472
513
  }
473
514
  if (this.activeItemColor === null){
474
515
  this.activeItemColor = this.itemColor.colorDarkenedByPercentage(0.5);
475
516
  }
476
517
  if (this.disabledItemColor === null){
477
- this.disabledItemColor = this.itemColor.colorWithAlpha(0.5);
518
+ this.disabledItemColor = this.itemColor.colorWithAlpha(0.4);
478
519
  }
479
520
  },
480
521
 
@@ -517,14 +558,22 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
517
558
  itemView.contentView.alpha = 0.4;
518
559
  }
519
560
  }
561
+ if (itemView.contentView instanceof UIImageView){
562
+ if (itemView.active){
563
+ itemView.contentView.templateColor = this.activeItemColor;
564
+ }else if (item.enabled){
565
+ itemView.contentView.templateColor = this.itemColor;
566
+ }else{
567
+ itemView.contentView.templateColor = this.disabledItemColor;
568
+ }
569
+ }
520
570
  if (toolbar.showsTitles){
521
- item.titleLabel.text = item.title;
522
571
  if (itemView.active){
523
- item.titleLabel.textColor = this.activeItemColor;
572
+ itemView.titleLabel.textColor = this.activeItemColor;
524
573
  }else if (item.enabled){
525
- item.titleLabel.textColor = this.itemColor;
574
+ itemView.titleLabel.textColor = this.itemColor;
526
575
  }else{
527
- item.titleLabel.textColor = this.disabledItemColor;
576
+ itemView.titleLabel.textColor = this.disabledItemColor;
528
577
  }
529
578
  }
530
579
  },
@@ -532,7 +581,7 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
532
581
  createOverflowButtonForToolbar: function(toolbar){
533
582
  var styler = UIButtonCustomStyler.initWithColor(this.itemColor);
534
583
  var button = UIButton.initWithStyler(styler);
535
- button.image = images.toolbarOverflow;
584
+ button.setImageForState(images.toolbarOverflow, UIControl.State.normal);
536
585
  button.addAction(function(){
537
586
  var menu = this.createOverflowMenuForToolbar(toolbar);
538
587
  if (menu !== null){
@@ -581,7 +630,7 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
581
630
  },
582
631
 
583
632
  showOverflowMenuForToolbar: function(menu, toolbar, overflowButton){
584
- menu.openAdjacentToView(overflowButton, UIMenu.placement.below);
633
+ menu.openAdjacentToView(overflowButton, UIMenu.Placement.below);
585
634
  },
586
635
 
587
636
  layoutToolbar: function(toolbar){
@@ -619,9 +668,9 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
619
668
  props.overflowButton = this.createOverflowButtonForToolbar(toolbar);
620
669
  }
621
670
  size = props.overflowButton.intrinsicSize;
622
- props.overflowButton.frame = JSRect(toolbar.width - this.contentInsets.right - size.width, y + (maxHeight - size.height) / 2.0, size.width, size.height);
671
+ props.overflowButton.frame = JSRect(toolbar.bounds.size.width - this.contentInsets.right - size.width, y + (maxHeight - size.height) / 2.0, size.width, size.height);
623
672
  // reduce available width by overflow button width
624
- availableWidth -= props.overflowButton.frame.width - this.itemSpacing;
673
+ availableWidth -= props.overflowButton.bounds.size.width - this.itemSpacing;
625
674
  // Back up over any overflowing items
626
675
  for (; props.lastVisibleIndex >= 0 && itemsWidth > availableWidth; --props.lastVisibleIndex){
627
676
  size = itemSizes[props.lastVisibleIndex];
@@ -647,20 +696,17 @@ JSClass("UIToolbarCustomStyler", UIToolbarStyler, {
647
696
  }
648
697
 
649
698
  // Position each item, centered vertically in the middle
699
+ var titleHeight = this.itemFont.displayLineHeight;
650
700
  for (i = 0, l = props.itemViews.length; i <= props.lastVisibleIndex; ++i){
651
701
  itemView = props.itemViews[i];
652
702
  itemView.hidden = false;
653
703
  item = itemView.item;
654
704
  size = itemSizes[i];
655
- if (item.view !== null){
656
- size.height = item.minimumSize.height;
657
- }else{
658
- size.height = toolbar.imageSize;
659
- }
660
- itemView.frame = JSRect(x, y + (maxHeight - size.height) / 2.0, size.width, size.height);
705
+ size.height = maxHeight;
706
+ itemView.frame = JSRect(x, y, size.width, size.height);
661
707
  x += size.width + this.itemSpacing;
662
708
  }
663
- for (i = props.lastVisibleIndex + 1; i < itemView.length; ++i){
709
+ for (i = props.lastVisibleIndex + 1; i < props.itemViews.length; ++i){
664
710
  itemView = props.itemViews[i];
665
711
  itemView.hidden = true;
666
712
  }
@@ -693,9 +739,9 @@ var images = Object.create({}, {
693
739
  toolbarOverflow: {
694
740
  configurable: true,
695
741
  get: function(){
696
- var image = JSImage.initWithResourceName("UIToolbarOverflow", this.bundle);
697
- Object.defineProperty(this, 'toolbarOverflow', {value: image.imageWithRenderingMode(JSImage.RenderMode.template) });
698
- return this.toolbarOverflow;
742
+ var image = JSImage.initWithResourceName("UIToolbarOverflow", this.bundle).imageWithRenderMode(JSImage.RenderMode.template);
743
+ Object.defineProperty(this, 'toolbarOverflow', {value: image });
744
+ return image;
699
745
  }
700
746
  },
701
747
 
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="15px" height="15px" viewBox="0 0 15 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>UIToolbarOverflow</title>
4
+ <g id="UIToolbarOverflow" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <polygon id="Path-Copy" fill="#000000" fill-rule="nonzero" points="8 1 8 4 11 7.5 8 11 8 14 14 7.5"></polygon>
6
+ <polygon id="Path" fill="#000000" fill-rule="nonzero" points="2 1 2 4 5 7.5 2 11 2 14 8 7.5"></polygon>
7
+ </g>
8
+ </svg>
@@ -20,18 +20,12 @@
20
20
  JSClass("UITooltipWindow", UIWindow, {
21
21
 
22
22
  initWithString: function(str, maxSize){
23
- var font = JSFont.systemFontOfSize(12.0);
24
- var color = JSColor.initWithRGBA(0.2, 0.2, 0.2, 1.0);
25
- var labelInsets = JSInsets(4, 6);
26
- this.initWithProperties(str, font, color, labelInsets, maxSize);
27
- },
28
-
29
- initWithProperties: function(str, font, textColor, labelInsets, maxSize){
30
- this._styler = UIWindow.Styler.custom;
23
+ this._styler = UIWindow.Styler.tooltip;
31
24
  UITooltipWindow.$super.init.call(this);
25
+ this.layer._domPointerEventsNone = true;
32
26
  var label = UILabel.init();
33
- label.font = font;
34
- label.textInsets = labelInsets;
27
+ label.font = this._styler.font;
28
+ label.textInsets = this._styler.textInsets;
35
29
  if (str.isKindOfClass && str.isKindOfClass(JSAttributedString)){
36
30
  label.attributedText = str;
37
31
  }else{
@@ -42,11 +36,6 @@ JSClass("UITooltipWindow", UIWindow, {
42
36
  this.contentView = UIView.init();
43
37
  this.contentView.addSubview(label);
44
38
  this.frame = JSRect(JSPoint.Zero, label.frame.size);
45
- this.backgroundColor = JSColor.initWithRGBA(240/255, 240/255, 240/255, 1.0);
46
- this.borderColor = JSColor.initWithRGBA(0.7, 0.7, 0.7, 1.0);
47
- this.shadowColor = JSColor.initWithRGBA(0.0, 0.0, 0.0, 0.2);
48
- this.borderWidth = 0.5;
49
- this.shadowRadius = 15;
50
39
  },
51
40
 
52
41
  canBecomeKey: function(){
@@ -61,4 +50,38 @@ JSClass("UITooltipWindow", UIWindow, {
61
50
 
62
51
  accessibilitySubrole: UIAccessibility.Subrole.tooltip
63
52
 
53
+ });
54
+
55
+ JSClass("UITooltipWindowStyler", UIWindowStyler, {
56
+
57
+ font: null,
58
+ textColor: null,
59
+ textInsets: null,
60
+ backgroundColor: null,
61
+ borderColor: null,
62
+ borderWidth: 0.5,
63
+ shadowColor: null,
64
+ shadowRadius: 15,
65
+ cornerRadius: 0,
66
+
67
+ init: function(){
68
+ UITooltipWindowStyler.$super.init.call(this);
69
+ this.backgroundColor = JSColor.tooltip;
70
+ this.borderColor = JSColor.tooltipBorder;
71
+ this.shadowColor = JSColor.tooltipShadow;
72
+ this.font = JSFont.systemFontOfSize(JSFont.Size.detail);
73
+ this.textColor = JSColor.tooltipText;
74
+ this.textInsets = JSInsets(4, 6);
75
+ },
76
+
77
+ initializeWindow: function(window){
78
+ UITooltipWindowStyler.$super.initializeWindow.call(this, window);
79
+ window.backgroundColor = this.backgroundColor;
80
+ window.borderColor = this.borderColor;
81
+ window.shadowColor = this.shadowColor;
82
+ window.borderWidth = this.borderWidth;
83
+ window.shadowRadius = this.shadowRadius;
84
+ window.cornerRadius = this.cornerRadius;
85
+ }
86
+
64
87
  });
@@ -27,12 +27,30 @@ JSClass("UITraitCollection", JSObject, {
27
27
  var traits = UITraitCollection.init();
28
28
  traits.horizontalSizeClass = this.horizontalSizeClass;
29
29
  traits.verticalSizeClass = this.verticalSizeClass;
30
+ traits.userInterfaceStyle = this.userInterfaceStyle;
30
31
  traits.accessibilityContrast = contrast;
31
32
  return traits;
32
33
  },
33
34
 
35
+ traitsWithUserInterfaceStyle: function(style){
36
+ var traits = UITraitCollection.init();
37
+ traits.horizontalSizeClass = this.horizontalSizeClass;
38
+ traits.verticalSizeClass = this.verticalSizeClass;
39
+ traits.userInterfaceStyle = style;
40
+ traits.accessibilityContrast = this.accessibilityContrast;
41
+ return traits;
42
+ },
43
+
44
+ traitsWithSize: function(size){
45
+ var traits = UITraitCollection.initWithSize(size);
46
+ traits.accessibilityContrast = this.accessibilityContrast;
47
+ traits.userInterfaceStyle = this.userInterfaceStyle;
48
+ return traits;
49
+ },
50
+
34
51
  horizontalSizeClass: UIUserInterface.SizeClass.unspecified,
35
52
  verticalSizeClass: UIUserInterface.SizeClass.unspecified,
53
+ userInterfaceStyle: UIUserInterface.Style.unspecified,
36
54
  accessibilityContrast: UIUserInterface.Contrast.unspecified,
37
55
 
38
56
  isEqual: function(other){
@@ -45,6 +63,9 @@ JSClass("UITraitCollection", JSObject, {
45
63
  if (this.accessibilityContrast !== other.accessibilityContrast){
46
64
  return false;
47
65
  }
66
+ if (this.userInterfaceStyle !== other.userInterfaceStyle){
67
+ return false;
68
+ }
48
69
  return true;
49
70
  }
50
71
 
@@ -49,4 +49,10 @@ UIUserInterface.Contrast = {
49
49
  unspecified: 0,
50
50
  normal: 1,
51
51
  high: 2
52
+ };
53
+
54
+ UIUserInterface.Style = {
55
+ unspecified: 0,
56
+ light: 1,
57
+ dark: 2
52
58
  };
@@ -14,6 +14,7 @@
14
14
  // limitations under the License.
15
15
 
16
16
  // #import "UIView.js"
17
+ // #import "JSColor+UIKit.js"
17
18
  'use strict';
18
19
 
19
20
  (function(){
@@ -30,14 +31,14 @@ JSClass("UIWebView", UIView, {
30
31
 
31
32
  initWithFrame: function(frame){
32
33
  UIWebView.$super.initWithFrame.call(this, frame);
33
- this.backgroundColor = JSColor.white;
34
+ this.backgroundColor = JSColor.background;
34
35
  this.setNeedsDisplay();
35
36
  },
36
37
 
37
38
  initWithSpec: function(spec){
38
39
  UIWebView.$super.initWithSpec.call(this, spec);
39
40
  if (this.backgroundColor === null){
40
- this.backgroundColor = JSColor.white;
41
+ this.backgroundColor = JSColor.background;
41
42
  }
42
43
  if (spec.containsKey("delegate")){
43
44
  this.delegate = spec.valueForKey("delegate");