@breakside/jskit 2021.37.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 (93) 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/io.breakside.JSKit.Foundation-bundle.js +2 -2
  11. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  12. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  13. package/Info.json +2 -2
  14. package/Node/io.breakside.jskit-bundle.js +4 -4
  15. package/Resources/doc-default.css +86 -0
  16. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  17. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  18. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  19. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  20. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  21. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  22. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  23. package/Root/Frameworks/DOM/Info.yaml +1 -1
  24. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  25. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  26. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  27. package/Root/Frameworks/Foundation/JSColor+HTML.js +11 -2
  28. package/Root/Frameworks/Foundation/JSColor.js +62 -26
  29. package/Root/Frameworks/Foundation/JSColorSpace.js +209 -1
  30. package/Root/Frameworks/Foundation/JSSpec.js +1 -1
  31. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  32. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  33. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  34. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  35. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  36. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  37. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  38. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  39. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  40. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  41. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  42. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  43. package/Root/Frameworks/UIKit/JSColor+UIKit.js +75 -0
  44. package/Root/Frameworks/UIKit/UIAccessibility.js +15 -0
  45. package/Root/Frameworks/UIKit/UIActivityIndicatorView.js +2 -1
  46. package/Root/Frameworks/UIKit/UIAlertController.js +4 -3
  47. package/Root/Frameworks/UIKit/UIAnimation.js +7 -13
  48. package/Root/Frameworks/UIKit/UIApplication.js +3 -0
  49. package/Root/Frameworks/UIKit/UIBasicAnimation.js +6 -0
  50. package/Root/Frameworks/UIKit/UIButton.js +17 -25
  51. package/Root/Frameworks/UIKit/UICheckbox.js +11 -22
  52. package/Root/Frameworks/UIKit/UIColorPanel.js +27 -15
  53. package/Root/Frameworks/UIKit/UIColorSpace.js +132 -0
  54. package/Root/Frameworks/UIKit/UIColorWell.js +18 -2
  55. package/Root/Frameworks/UIKit/UIHTMLDisplayServer.js +1 -5
  56. package/Root/Frameworks/UIKit/UIHTMLTextField.js +3 -15
  57. package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +72 -1
  58. package/Root/Frameworks/UIKit/UIImageView.js +4 -0
  59. package/Root/Frameworks/UIKit/UIKit.js +2 -0
  60. package/Root/Frameworks/UIKit/UILabel.js +14 -2
  61. package/Root/Frameworks/UIKit/UILayer.js +29 -1
  62. package/Root/Frameworks/UIKit/UIListView.js +10 -9
  63. package/Root/Frameworks/UIKit/UIMenu.js +10 -9
  64. package/Root/Frameworks/UIKit/UIMenuBar.js +5 -4
  65. package/Root/Frameworks/UIKit/UIMenuView.js +8 -4
  66. package/Root/Frameworks/UIKit/UINavigationBar.js +8 -5
  67. package/Root/Frameworks/UIKit/UINavigationController.js +3 -2
  68. package/Root/Frameworks/UIKit/UIOutlineViewCell.js +2 -1
  69. package/Root/Frameworks/UIKit/UIPopupButton.js +13 -24
  70. package/Root/Frameworks/UIKit/UIPopupWindow.js +3 -2
  71. package/Root/Frameworks/UIKit/UIProgressIndicatorView.js +1 -1
  72. package/Root/Frameworks/UIKit/UIRadioGroup.js +11 -22
  73. package/Root/Frameworks/UIKit/UIScroller.js +4 -3
  74. package/Root/Frameworks/UIKit/UISegmentedControl.js +16 -15
  75. package/Root/Frameworks/UIKit/UISlider.js +20 -36
  76. package/Root/Frameworks/UIKit/UITabView.js +34 -31
  77. package/Root/Frameworks/UIKit/UITextEditor.js +2 -1
  78. package/Root/Frameworks/UIKit/UITextField.js +13 -14
  79. package/Root/Frameworks/UIKit/UITextLayer.js +5 -0
  80. package/Root/Frameworks/UIKit/UITokenField.js +3 -3
  81. package/Root/Frameworks/UIKit/UIToolbar.js +84 -38
  82. package/Root/Frameworks/UIKit/UIToolbarOverflow.svg +8 -0
  83. package/Root/Frameworks/UIKit/UITooltipWindow.js +5 -5
  84. package/Root/Frameworks/UIKit/UITraitCollection.js +21 -0
  85. package/Root/Frameworks/UIKit/UIUserInterface.js +6 -0
  86. package/Root/Frameworks/UIKit/UIWebView.js +3 -2
  87. package/Root/Frameworks/UIKit/UIWindow.js +18 -24
  88. package/Root/Frameworks/UIKit/UIWindowButtonCloseInactive.svg +1 -1
  89. package/Root/Frameworks/UIKit/UIWindowButtonCloseNormal.svg +1 -1
  90. package/Root/Frameworks/UIKit/UIWindowServer.js +53 -8
  91. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  92. package/Root/Templates/html/${PROJECT_NAME}/www/index.html +24 -4
  93. package/package.json +1 -1
@@ -60,9 +60,10 @@ JSClass("UITabView", UIView, {
60
60
  this.delegate = spec.valueForKey("delegate");
61
61
  }
62
62
  if (spec.containsKey('items')){
63
- var items = spec.valueForKey('items');
64
- for (var i = 0, l = items.length; i < l; ++i){
65
- items.push(items.valueForKey(i, UITabViewItem));
63
+ var items = [];
64
+ var specItems = spec.valueForKey('items');
65
+ for (var i = 0, l = specItems.length; i < l; ++i){
66
+ items.push(specItems.valueForKey(i, UITabViewItem));
66
67
  }
67
68
  this.items = items;
68
69
  }
@@ -689,18 +690,18 @@ JSClass("UITabViewDefaultStyler", UITabViewStyler, {
689
690
 
690
691
  init: function(){
691
692
  UITabViewDefaultStyler.$super.init.call(this);
692
- this.normalItemColor = JSColor.initWithRGBA(250/255,250/255,250/255);
693
- this.activeItemColor = JSColor.initWithRGBA(224/255,224/255,224/255);
694
- this.selectedItemColor = JSColor.initWithRGBA(70/255,153/255,254/255);
695
- this.activeSelectedItemColor = JSColor.initWithRGBA(63/255,138/255,230/255);
696
- this.normalBorderColor = JSColor.initWithRGBA(204/255,204/255,204/255);
697
- this.activeBorderColor = JSColor.initWithRGBA(192/255,192/255,192/255);
698
- this.selectedBorderColor = JSColor.initWithRGBA(63/255,138/255,230/255);
699
- this.activeSelectedBorderColor = JSColor.initWithRGBA(54/255,123/255,205/255);
700
- this.normalTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
701
- this.activeTitleColor = JSColor.initWithRGBA(51/255,51/255,51/255);
702
- this.selectedTitleColor = JSColor.initWithRGBA(255/255,255/255,255/255);
703
- this.selectedActiveTitleColor = JSColor.initWithRGBA(255/255,255/255,255/255);
693
+ this.normalItemColor = JSColor.controlBackground;
694
+ this.activeItemColor = JSColor.activeControlBackground;
695
+ this.selectedItemColor = JSColor.highlight;
696
+ this.activeSelectedItemColor = JSColor.highlight.colorDarkenedByPercentage(0.2);
697
+ this.normalBorderColor = JSColor.controlBorder;
698
+ this.activeBorderColor = JSColor.activeControlBorder;
699
+ this.selectedBorderColor = JSColor.highlight.colorDarkenedByPercentage(0.2);
700
+ this.activeSelectedBorderColor = JSColor.highlight.colorDarkenedByPercentage(0.4);
701
+ this.normalTitleColor = JSColor.controlTitle;
702
+ this.activeTitleColor = JSColor.activeControlTitle;
703
+ this.selectedTitleColor = JSColor.highlightedText;
704
+ this.selectedActiveTitleColor = JSColor.highlightedText;
704
705
  this._fillInMissingStyles();
705
706
  },
706
707
 
@@ -777,22 +778,22 @@ JSClass("UITabViewDefaultStyler", UITabViewStyler, {
777
778
  this.itemsInsets = JSInsets(4);
778
779
  }
779
780
  if (this.normalTitleColor === null){
780
- this.normalTitleColor = JSColor.black;
781
+ this.normalTitleColor = JSColor.controlTitle;
781
782
  }
782
783
  if (this.activeTitleColor === null){
783
784
  this.activeTitleColor = this.normalTitleColor;
784
785
  }
785
786
  if (this.selectedTitleColor === null){
786
- this.selectedTitleColor = JSColor.white;
787
+ this.selectedTitleColor = JSColor.highlightedText;
787
788
  }
788
789
  if (this.activeSelectedTitleColor === null){
789
790
  this.activeSelectedTitleColor = this.selectedTitleColor;
790
791
  }
791
792
  if (this.normalItemColor === null){
792
- this.normalItemColor = JSColor.initWithRGBA(250/255,250/255,250/255);
793
+ this.normalItemColor = JSColor.highlight;
793
794
  }
794
795
  if (this.selectedItemColor === null){
795
- this.selectedItemColor = JSColor.initWithRGBA(70/255,153/255,254/255);
796
+ this.selectedItemColor = JSColor.highlight.colorDarkenedByPercentage(0.2);
796
797
  }
797
798
  if (this.activeItemColor === null){
798
799
  this.activeItemColor = this.normalItemColor.colorDarkenedByPercentage(0.1);
@@ -813,7 +814,7 @@ JSClass("UITabViewDefaultStyler", UITabViewStyler, {
813
814
  this.activeSelectedBorderColor = this.selectedBorderColor.colorDarkenedByPercentage(0.05);
814
815
  }
815
816
  if (this.dividerColor === null){
816
- this.dividerColor = this.normalBorderColor;
817
+ this.dividerColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2));
817
818
  }
818
819
  },
819
820
 
@@ -824,7 +825,7 @@ JSClass("UITabViewDefaultStyler", UITabViewStyler, {
824
825
  tabView.addSubview(props.contentViewContainer);
825
826
  props.itemsView = UITabViewItemsView.init();
826
827
  props.itemsView.tabView = tabView;
827
- props.itemsView.shadowColor = JSColor.initWithRGBA(0, 0, 0, 0.1);
828
+ props.itemsView.shadowColor = JSColor.controlShadow;
828
829
  props.itemsView.shadowOffset = JSPoint(0, 1);
829
830
  props.itemsView.shadowRadius = 1;
830
831
  props.itemsView.cornerRadius = this.cornerRadius;
@@ -1038,6 +1039,7 @@ UITabView.Styler = Object.defineProperties({}, {
1038
1039
  },
1039
1040
 
1040
1041
  tabless: {
1042
+ configurable: true,
1041
1043
  get: function UITabView_getTablessStyler(){
1042
1044
  var styler = UITabViewTablessStyler.init();
1043
1045
  Object.defineProperty(this, 'tabless', {writable: true, value: styler});
@@ -1046,6 +1048,7 @@ UITabView.Styler = Object.defineProperties({}, {
1046
1048
  },
1047
1049
 
1048
1050
  images: {
1051
+ configurable: true,
1049
1052
  get: function UITabView_getImagesStyler(){
1050
1053
  var styler = UITabViewImagesStyler.init();
1051
1054
  Object.defineProperty(this, 'images', {writable: true, value: styler});
@@ -1163,8 +1166,8 @@ JSClass("UITabViewImagesStyler", UITabViewStyler, {
1163
1166
  initializeTabView: function(tabView){
1164
1167
  UITabViewDefaultStyler.$super.initializeTabView.call(this, tabView);
1165
1168
  if (this.borderColor === null){
1166
- var backgroundColor = tabView.backgroundColor || JSColor.white;
1167
- this.borderColor = backgroundColor.colorDarkenedByPercentage(0.2);
1169
+ var backgroundColor = tabView.backgroundColor || JSColor.background;
1170
+ this.borderColor = JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2));
1168
1171
  }
1169
1172
  var props = tabView.stylerProperties;
1170
1173
  props.contentViewContainer = UITabViewContentContainer.init();
@@ -1234,14 +1237,14 @@ JSClass("UITabViewImagesStyler", UITabViewStyler, {
1234
1237
  });
1235
1238
 
1236
1239
  var defaultStateImageColors = [
1237
- JSColor.initWithRGBA(0,0,0,0.2), // 0 normal
1238
- JSColor.initWithRGBA(0,0,0,0.2), // 1 over
1239
- JSColor.initWithRGBA(0,0,0,0.5), // 2 active
1240
- JSColor.initWithRGBA(0,0,0,0.5), // 3 active + over
1241
- JSColor.initWithRGBA(70/255,153/255,254/255), // 4 selected
1242
- JSColor.initWithRGBA(70/255,153/255,254/255), // 5 selected + over
1243
- JSColor.initWithRGBA(54/255,123/255,205/255), // 6 selected + active
1244
- JSColor.initWithRGBA(54/255,123/255,205/255), // 7 selected + active + over
1240
+ JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2)), // 0 normal
1241
+ JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.2), JSColor.white.colorWithAlpha(0.2)), // 1 over
1242
+ JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.5), JSColor.white.colorWithAlpha(0.1)), // 2 active
1243
+ JSColor.initWithUIStyles(JSColor.black.colorWithAlpha(0.5), JSColor.white.colorWithAlpha(0.1)), // 3 active + over
1244
+ JSColor.highlight, // 4 selected
1245
+ JSColor.highlight, // 5 selected + over
1246
+ JSColor.highlight.colorDarkenedByPercentage(0.2), // 6 selected + active
1247
+ JSColor.highlight.colorDarkenedByPercentage(0.2), // 7 selected + active + over
1245
1248
  ];
1246
1249
 
1247
1250
  })();
@@ -16,6 +16,7 @@
16
16
  // #import Foundation
17
17
  // #import "UILayer.js"
18
18
  // #import "UITextInput.js"
19
+ // #import "JSColor+UIKit.js"
19
20
  'use strict';
20
21
 
21
22
  (function(){
@@ -49,7 +50,7 @@ JSClass("UITextEditor", JSObject, {
49
50
  this._selectionHighlightLayers = [];
50
51
  this.textLayoutManager = textLayer.textLayoutManager;
51
52
  this.textLayoutManager.editor = this;
52
- this.cursorColor = JSColor.black;
53
+ this.cursorColor = JSColor.highlight;
53
54
  this.selections = [
54
55
  this._createSelection(JSRange(0, 0), UITextInput.SelectionInsertionPoint.end)
55
56
  ];
@@ -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(){
@@ -134,6 +135,8 @@ JSClass("UITextField", UIControl, {
134
135
  this._styler = UITextField.Styler.default;
135
136
  }
136
137
  this.hasOverState = this._styler.showsOverState;
138
+ this.textColor = JSColor.text;
139
+ this._placeholderColor = JSColor.placeholderText;
137
140
  this._styler.initializeControl(this);
138
141
  },
139
142
 
@@ -238,22 +241,11 @@ JSClass("UITextField", UIControl, {
238
241
  this._placeholderLabel.hidden = true;
239
242
  this._placeholderLabel.layer.widthTracksText = this._textLayer.widthTracksText;
240
243
  this._placeholderLabel.layer.heightTracksText = true;
241
- if (this._placeholderColor === null){
242
- this._createPlaceholderColor();
243
- }
244
244
  this._placeholderLabel.textColor = this._placeholderColor;
245
245
  this._clipView.insertSubviewAtIndex(this._placeholderLabel, 0);
246
246
  this._clipView.layer.insertSublayerBelowSibling(this._placeholderLabel.layer, this._textLayer);
247
247
  },
248
248
 
249
- _createPlaceholderColor: function(){
250
- var backgroundColor = this.backgroundColor;
251
- if (backgroundColor === null){
252
- backgroundColor = JSColor.white;
253
- }
254
- this._placeholderColor = backgroundColor.colorByBlendingColor(this.textColor, 0.3);
255
- },
256
-
257
249
  _placeholderLabel: null,
258
250
 
259
251
  _isShowingPlaceholder: false,
@@ -1267,7 +1259,7 @@ JSClass("UITextFieldStyler", UIControlStyler, {
1267
1259
 
1268
1260
  _commonStylerInit: function(){
1269
1261
  if (this.localCursorColor === null){
1270
- this.localCursorColor = JSColor.initWithRGBA(0, 128/255.0, 255/255.0, 1);
1262
+ this.localCursorColor = JSColor.highlight;
1271
1263
  }
1272
1264
  },
1273
1265
 
@@ -1317,8 +1309,8 @@ JSClass("UITextFieldDefaultStyler", UITextFieldStyler, {
1317
1309
  },
1318
1310
 
1319
1311
  _commonDefaultStylerInit: function(){
1320
- this.activeColor = JSColor.black;
1321
- this.inactiveColor = JSColor.initWithWhite(0.8);
1312
+ this.activeColor = JSColor.highlight;
1313
+ this.inactiveColor = JSColor.text.colorWithAlpha(0.2);
1322
1314
  this.textInsets = JSInsets(3, 0);
1323
1315
  },
1324
1316
 
@@ -1366,6 +1358,11 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1366
1358
  textInsets: null,
1367
1359
  showsFocusRing: true,
1368
1360
 
1361
+ init: function(){
1362
+ UITextFieldCustomStyler.$super.init.call(this);
1363
+ this.textColor = JSColor.text;
1364
+ },
1365
+
1369
1366
  initWithSpec: function(spec){
1370
1367
  UITextFieldCustomStyler.$super.initWithSpec.call(this, spec);
1371
1368
  if (spec.containsKey("backgroundColor")){
@@ -1388,6 +1385,8 @@ JSClass("UITextFieldCustomStyler", UITextFieldStyler, {
1388
1385
  }
1389
1386
  if (spec.containsKey("textColor")){
1390
1387
  this.textColor = spec.valueForKey("textColor", JSColor);
1388
+ }else{
1389
+ this.textColor = JSColor.text;
1391
1390
  }
1392
1391
  if (spec.containsKey("placeholderColor")){
1393
1392
  this.placeholderColor = spec.valueForKey("placeholderColor", JSColor);
@@ -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>
@@ -66,11 +66,11 @@ JSClass("UITooltipWindowStyler", UIWindowStyler, {
66
66
 
67
67
  init: function(){
68
68
  UITooltipWindowStyler.$super.init.call(this);
69
- this.backgroundColor = JSColor.initWithRGBA(240/255, 240/255, 240/255, 1.0);
70
- this.borderColor = JSColor.initWithRGBA(0.7, 0.7, 0.7, 1.0);
71
- this.shadowColor = JSColor.initWithRGBA(0.0, 0.0, 0.0, 0.2);
72
- this.font = JSFont.systemFontOfSize(12.0);
73
- this.textColor = JSColor.initWithRGBA(0.2, 0.2, 0.2, 1.0);
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
74
  this.textInsets = JSInsets(4, 6);
75
75
  },
76
76
 
@@ -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");