uki 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/VERSION +1 -1
  2. data/bin/uki +1 -1
  3. data/frameworks/uki/README.rdoc +1 -1
  4. data/frameworks/uki/examples/core-examples/controls/controls.js +6 -6
  5. data/frameworks/uki/examples/core-examples/flow/flow.js +4 -4
  6. data/frameworks/uki/examples/core-examples/linearGradient/gradient.svg +11 -0
  7. data/frameworks/uki/examples/core-examples/linearGradient/linearGradient.js +87 -0
  8. data/frameworks/uki/examples/core-examples/popup/popup.js +23 -10
  9. data/frameworks/uki/examples/core-examples/resizeToContents/resizeToContents.js +12 -1
  10. data/frameworks/uki/examples/core-examples/slider/slider.js +1 -1
  11. data/frameworks/uki/examples/core-examples/splitPaneExtended/splitPaneExtended.js +1 -1
  12. data/frameworks/uki/examples/core-examples/table/table.js +19 -2
  13. data/frameworks/uki/examples/core-examples/wave/wave-theme.js +1 -1
  14. data/frameworks/uki/examples/core-examples/wave/wave.js +1 -1
  15. data/frameworks/uki/examples/more-examples/radioButton/radioButton.js +3 -3
  16. data/frameworks/uki/examples/more-examples/select/select.js +35 -0
  17. data/frameworks/uki/examples/touch-examples/scrollPane/scrollPane.js +53 -0
  18. data/frameworks/uki/spec/unit/background.spec.js +1 -1
  19. data/frameworks/uki/spec/unit/selector.spec.js +28 -12
  20. data/frameworks/uki/spec/unit/utils.spec.js +14 -0
  21. data/frameworks/uki/src/uki-core.js +3 -1
  22. data/frameworks/uki/src/uki-core/after.js +57 -0
  23. data/frameworks/uki/src/uki-core/attachment.js +15 -6
  24. data/frameworks/uki/src/uki-core/background.js +4 -3
  25. data/frameworks/uki/src/uki-core/background/css.js +1 -0
  26. data/frameworks/uki/src/uki-core/background/cssBox.js +5 -3
  27. data/frameworks/uki/src/uki-core/background/linearGradient.js +112 -0
  28. data/frameworks/uki/src/uki-core/background/multi.js +2 -2
  29. data/frameworks/uki/src/uki-core/background/rows.js +1 -0
  30. data/frameworks/uki/src/uki-core/background/sliced9.js +5 -2
  31. data/frameworks/uki/src/uki-core/builder.js +5 -4
  32. data/frameworks/uki/src/uki-core/collection.js +18 -13
  33. data/frameworks/uki/src/uki-core/dom/browser.js +114 -0
  34. data/frameworks/uki/src/uki-core/dom/event.js +3 -0
  35. data/frameworks/uki/src/uki-core/image.js +1 -26
  36. data/frameworks/uki/src/uki-core/selector.js +5 -0
  37. data/frameworks/uki/src/uki-core/theme.js +24 -23
  38. data/frameworks/uki/src/uki-core/theme/template.js +1 -1
  39. data/frameworks/uki/src/uki-core/uki.js +7 -4
  40. data/frameworks/uki/src/uki-core/utils.js +51 -26
  41. data/frameworks/uki/src/uki-core/view.js +6 -3
  42. data/frameworks/uki/src/uki-core/view/base.js +16 -1
  43. data/frameworks/uki/src/uki-core/view/container.js +15 -5
  44. data/frameworks/uki/src/uki-core/view/focusable.js +17 -4
  45. data/frameworks/uki/src/uki-core/view/observable.js +15 -2
  46. data/frameworks/uki/src/uki-core/view/styleable.js +4 -11
  47. data/frameworks/uki/src/uki-data/ajax.js +4 -30
  48. data/frameworks/uki/src/uki-data/json.js +191 -0
  49. data/frameworks/uki/src/uki-data/localStore.js +37 -0
  50. data/frameworks/uki/src/uki-data/model.js +1 -1
  51. data/frameworks/uki/src/uki-more.js +4 -0
  52. data/frameworks/uki/src/uki-more/more/background.js +2 -0
  53. data/frameworks/uki/src/uki-more/more/color.js +168 -0
  54. data/frameworks/uki/src/uki-more/more/utils.js +5 -12
  55. data/frameworks/uki/src/uki-more/more/view.js +3 -1
  56. data/frameworks/uki/src/uki-more/more/view/form.js +30 -0
  57. data/frameworks/uki/src/uki-more/more/view/hTile.js +59 -0
  58. data/frameworks/uki/src/uki-more/more/view/nativeButton.js +3 -0
  59. data/frameworks/uki/src/uki-more/more/view/nativeCheckbox.js +38 -0
  60. data/frameworks/uki/src/uki-more/more/view/nativeControl.js +40 -0
  61. data/frameworks/uki/src/uki-more/more/view/nativeInput.js +78 -0
  62. data/frameworks/uki/src/uki-more/more/view/nativeSelect.js +29 -0
  63. data/frameworks/uki/src/uki-more/more/view/radioButton.js +1 -1
  64. data/frameworks/uki/src/uki-more/more/view/select-theme.js +55 -0
  65. data/frameworks/uki/src/uki-more/more/view/select.js +208 -0
  66. data/frameworks/uki/src/uki-theme/airport.js +145 -88
  67. data/frameworks/uki/src/uki-theme/airport/i/table/a-down.png +0 -0
  68. data/frameworks/uki/src/uki-theme/airport/i/table/a-up.png +0 -0
  69. data/frameworks/uki/src/uki-touch.js +2 -0
  70. data/frameworks/uki/src/uki-touch/touch.js +1 -0
  71. data/frameworks/uki/src/uki-touch/touch/const.js +24 -0
  72. data/frameworks/uki/src/uki-touch/touch/setup.js +52 -0
  73. data/frameworks/uki/src/uki-touch/touch/view.js +4 -0
  74. data/frameworks/uki/src/uki-touch/touch/view/scrollPane.js +505 -0
  75. data/frameworks/uki/src/uki-touch/touch/view/scrollableList.js +27 -0
  76. data/frameworks/uki/src/uki-view/view/box.js +9 -0
  77. data/frameworks/uki/src/uki-view/view/button.js +36 -1
  78. data/frameworks/uki/src/uki-view/view/checkbox.js +32 -3
  79. data/frameworks/uki/src/uki-view/view/flow.js +37 -9
  80. data/frameworks/uki/src/uki-view/view/image.js +14 -1
  81. data/frameworks/uki/src/uki-view/view/label.js +72 -11
  82. data/frameworks/uki/src/uki-view/view/list.js +143 -13
  83. data/frameworks/uki/src/uki-view/view/list/render.js +1 -0
  84. data/frameworks/uki/src/uki-view/view/popup.js +46 -2
  85. data/frameworks/uki/src/uki-view/view/radio.js +19 -4
  86. data/frameworks/uki/src/uki-view/view/scrollPane.js +91 -33
  87. data/frameworks/uki/src/uki-view/view/slider.js +67 -54
  88. data/frameworks/uki/src/uki-view/view/splitPane.js +102 -9
  89. data/frameworks/uki/src/uki-view/view/table.js +59 -2
  90. data/frameworks/uki/src/uki-view/view/table/column.js +45 -17
  91. data/frameworks/uki/src/uki-view/view/table/header.js +40 -12
  92. data/frameworks/uki/src/uki-view/view/table/render.js +4 -0
  93. data/frameworks/uki/src/uki-view/view/textField.js +75 -21
  94. data/frameworks/uki/src/uki-view/view/toolbar.js +16 -0
  95. data/lib/uki/builder.rb +1 -1
  96. data/lib/uki/include_js.rb +2 -2
  97. data/lib/uki/project.rb +14 -14
  98. data/templates/index.html.erb +2 -2
  99. data/templates/myapp.js.erb +2 -2
  100. data/uki.gemspec +34 -48
  101. metadata +44 -47
  102. data/frameworks/uki/src/uki-core/dom/nativeLayout.js +0 -18
  103. data/frameworks/uki/src/uki-theme/airport/i/button/down-c.gif +0 -0
  104. data/frameworks/uki/src/uki-theme/airport/i/button/down-c.png +0 -0
  105. data/frameworks/uki/src/uki-theme/airport/i/button/down-h.gif +0 -0
  106. data/frameworks/uki/src/uki-theme/airport/i/button/down-h.png +0 -0
  107. data/frameworks/uki/src/uki-theme/airport/i/button/down-m.png +0 -0
  108. data/frameworks/uki/src/uki-theme/airport/i/button/down-v.png +0 -0
  109. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-c.png +0 -0
  110. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-h.png +0 -0
  111. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-m.png +0 -0
  112. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-v.png +0 -0
  113. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing.png +0 -0
  114. data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.gif +0 -0
  115. data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.png +0 -0
  116. data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.gif +0 -0
  117. data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.png +0 -0
  118. data/frameworks/uki/src/uki-theme/airport/i/button/hover-m.png +0 -0
  119. data/frameworks/uki/src/uki-theme/airport/i/button/hover-v.png +0 -0
  120. data/frameworks/uki/src/uki-theme/airport/i/button/hover.png +0 -0
  121. data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.gif +0 -0
  122. data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.png +0 -0
  123. data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.gif +0 -0
  124. data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.png +0 -0
  125. data/frameworks/uki/src/uki-theme/airport/i/button/normal-m.png +0 -0
  126. data/frameworks/uki/src/uki-theme/airport/i/button/normal-v.png +0 -0
  127. data/frameworks/uki/src/uki-theme/airport/i/button/normal.png +0 -0
  128. data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.gif +0 -0
  129. data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.png +0 -0
  130. data/frameworks/uki/src/uki-theme/airport/i/panel/dark-m.png +0 -0
  131. data/frameworks/uki/src/uki-theme/airport/i/panel/dark.png +0 -0
  132. data/frameworks/uki/src/uki-theme/airport/i/popup/normal.png +0 -0
  133. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-c.png +0 -0
  134. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-h.png +0 -0
  135. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-m.png +0 -0
  136. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-v.png +0 -0
  137. data/frameworks/uki/src/uki-theme/airport/i/shadow/large.png +0 -0
  138. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.gif +0 -0
  139. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.png +0 -0
  140. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.gif +0 -0
  141. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.png +0 -0
  142. data/frameworks/uki/src/uki-theme/airport/i/slider/bar.png +0 -0
  143. data/frameworks/uki/src/uki-theme/airport/i/slider/focus.png +0 -0
  144. data/frameworks/uki/src/uki-theme/airport/i/slider/handle.gif +0 -0
@@ -1,7 +1,7 @@
1
1
  describe 'uki.Selector'
2
2
  it 'should tokenize expression'
3
- tokens = uki.Selector.tokenize('label > * > project.views.CustomView Label[name^="wow"]')[0];
4
- tokens.should_eql ['label', '>', '*', '>', 'project.views.CustomView', 'Label[name^="wow"]']
3
+ tokens = uki.Selector.tokenize('label > * > project.views.CustomView Label[ name ^= "wow"]')[0];
4
+ tokens.should_eql ['label', '>', '*', '>', 'project.views.CustomView', 'Label[ name ^= "wow"]']
5
5
  end
6
6
 
7
7
  it 'should copy find to uki'
@@ -16,7 +16,8 @@ describe 'uki.Selector'
16
16
  { view: 'Box', rect: '10 10 100 100', name: 'third', someAttribute: true, childViews: [
17
17
  { view: 'Label', rect: '10 10 100 100', name: 'label1', someAttribute: false }
18
18
  ]},
19
- { view: 'Label', rect: '200 10 100 100', name: 'label2' }
19
+ { view: 'Label', rect: '200 10 100 100', name: 'label2' },
20
+ { view: 'Label', rect: '400 10 100 100', name: 'label3' }
20
21
  ]}
21
22
  ]}
22
23
  ]);
@@ -25,26 +26,29 @@ describe 'uki.Selector'
25
26
 
26
27
  it 'by *'
27
28
  elements = uki.Selector.find('*', tree);
28
- elements.length.should.be 4
29
+ elements.length.should.be 5
29
30
  uki.attr(elements[0], 'name').should.be 'second'
30
31
  uki.attr(elements[1], 'name').should.be 'third'
31
32
  uki.attr(elements[2], 'name').should.be 'label1'
32
33
  uki.attr(elements[3], 'name').should.be 'label2'
34
+ uki.attr(elements[4], 'name').should.be 'label3'
33
35
  end
34
36
 
35
37
  it 'by * *'
36
38
  elements = uki.Selector.find('* *', tree);
37
- elements.length.should.be 3
39
+ elements.length.should.be 4
38
40
  uki.attr(elements[0], 'name').should.be 'third'
39
41
  uki.attr(elements[1], 'name').should.be 'label1'
40
42
  uki.attr(elements[2], 'name').should.be 'label2'
43
+ uki.attr(elements[3], 'name').should.be 'label3'
41
44
  end
42
45
 
43
46
  it 'by full typeName()'
44
47
  elements = uki.Selector.find('uki.view.Label', tree);
45
- elements.length.should.be 2
48
+ elements.length.should.be 3
46
49
  uki.attr(elements[0], 'name').should.be 'label1'
47
50
  uki.attr(elements[1], 'name').should.be 'label2'
51
+ uki.attr(elements[2], 'name').should.be 'label3'
48
52
  end
49
53
 
50
54
  it 'by contracted typeName()'
@@ -74,9 +78,10 @@ describe 'uki.Selector'
74
78
 
75
79
  it 'by ^= attribute'
76
80
  elements = uki.Selector.find('[name^="label"]', tree);
77
- elements.length.should.be 2
81
+ elements.length.should.be 3
78
82
  uki.attr(elements[0], 'name').should.be 'label1'
79
83
  uki.attr(elements[1], 'name').should.be 'label2'
84
+ uki.attr(elements[2], 'name').should.be 'label3'
80
85
  end
81
86
 
82
87
  it 'by $= attribute'
@@ -87,9 +92,10 @@ describe 'uki.Selector'
87
92
 
88
93
  it 'by ~= attribute'
89
94
  elements = uki.Selector.find('*[name~="abe"]', tree);
90
- elements.length.should.be 2
95
+ elements.length.should.be 3
91
96
  uki.attr(elements[0], 'name').should.be 'label1'
92
97
  uki.attr(elements[1], 'name').should.be 'label2'
98
+ uki.attr(elements[2], 'name').should.be 'label3'
93
99
  end
94
100
 
95
101
  it 'by attribute presence'
@@ -100,16 +106,18 @@ describe 'uki.Selector'
100
106
 
101
107
  it 'direct children with >'
102
108
  elements = uki.Selector.find('>', [tree[0].childViews()[0]]);
103
- elements.length.should.be 2
109
+ elements.length.should.be 3
104
110
  uki.attr(elements[0], 'name').should.be 'third'
105
111
  uki.attr(elements[1], 'name').should.be 'label2'
112
+ uki.attr(elements[2], 'name').should.be 'label3'
106
113
  end
107
114
 
108
115
  it 'direct children with > *'
109
116
  elements = uki.Selector.find('> *', [tree[0].childViews()[0]]);
110
- elements.length.should.be 2
117
+ elements.length.should.be 3
111
118
  uki.attr(elements[0], 'name').should.be 'third'
112
119
  uki.attr(elements[1], 'name').should.be 'label2'
120
+ uki.attr(elements[2], 'name').should.be 'label3'
113
121
  end
114
122
 
115
123
  it 'right after with +'
@@ -118,11 +126,19 @@ describe 'uki.Selector'
118
126
  uki.attr(elements[0], 'name').should.be 'label2'
119
127
  end
120
128
 
129
+ it 'right after with ~'
130
+ elements = uki.Selector.find('Box ~ Label', tree);
131
+ elements.length.should.be 2
132
+ uki.attr(elements[0], 'name').should.be 'label2'
133
+ uki.attr(elements[1], 'name').should.be 'label3'
134
+ end
135
+
121
136
  it 'direct children within container >'
122
137
  elements = uki.Selector.find('Box > Label', tree);
123
- elements.length.should.be 2
138
+ elements.length.should.be 3
124
139
  uki.attr(elements[0], 'name').should.be 'label2'
125
- uki.attr(elements[1], 'name').should.be 'label1'
140
+ uki.attr(elements[1], 'name').should.be 'label3'
141
+ uki.attr(elements[2], 'name').should.be 'label1'
126
142
  end
127
143
 
128
144
  it 'by :eq modifier'
@@ -173,4 +173,18 @@ describe 'uki.utils'
173
173
  uki.unique(a).should.eql [x, y, z]
174
174
  end
175
175
 
176
+
177
+ it 'should dasherize cammelcased literals'
178
+ uki.dasherize('WebkitBorderRadius').should.eql '-webkit-border-radius'
179
+ uki.dasherize('X').should.eql '-x'
180
+ uki.dasherize('').should.eql ''
181
+ end
182
+
183
+ it 'should camalize dashed literals'
184
+ uki.camalize('-webkit-border-radius').should.eql 'WebkitBorderRadius'
185
+ uki.camalize('-x').should.eql 'X'
186
+ uki.camalize('foo_bar').should.eql 'fooBar'
187
+ uki.camalize('').should.eql ''
188
+ end
189
+
176
190
  end
@@ -8,19 +8,21 @@ include('uki-core/dom/event.js');
8
8
  include('uki-core/dom/dnd.js');
9
9
  include('uki-core/dom/w3cdnd.js');
10
10
  include('uki-core/dom/offset.js');
11
- include('uki-core/dom/nativeLayout.js');
11
+ include('uki-core/dom/browser.js');
12
12
 
13
13
  include('uki-core/attachment.js');
14
14
  include('uki-core/builder.js');
15
15
  include('uki-core/selector.js');
16
16
 
17
17
  include('uki-core/image.js');
18
+ include('uki-core/after.js');
18
19
 
19
20
  include('uki-core/background.js');
20
21
  include('uki-core/background/null.js');
21
22
  include('uki-core/background/sliced9.js');
22
23
  include('uki-core/background/css.js');
23
24
  include('uki-core/background/cssBox.js');
25
+ include('uki-core/background/linearGradient.js');
24
26
  include('uki-core/background/rows.js');
25
27
  include('uki-core/background/multi.js');
26
28
 
@@ -0,0 +1,57 @@
1
+ include('uki.js');
2
+
3
+ /**
4
+ * Executes callback at or after the end of processing.
5
+ * Example: execute flow layout after all child views were added.
6
+ * Runs either at the end of event handling or after a timeout.
7
+ * Each callback (by huid) is executed once
8
+ * @function
9
+ * @param {function()} callback
10
+ */
11
+ uki.after = (function() {
12
+ var after = function(callback) {
13
+ callback.huid = callback.huid || uki.guid++;
14
+ if (after._bound[callback.huid]) return;
15
+ after._bound[callback.huid] = true;
16
+ after._queue.push(callback);
17
+ if (!after._running) after._startTimer();
18
+ };
19
+
20
+ after._bound = {};
21
+ after._running = false;
22
+ after._timer = 0;
23
+ after._queue = [];
24
+
25
+ after.start = function() {
26
+ after._clearTimer();
27
+ after._running++;
28
+ };
29
+
30
+ after.stop = function() {
31
+ if (--after._running) return;
32
+ after._runCallbacks();
33
+ };
34
+
35
+
36
+
37
+ after._runCallbacks = function() {
38
+ after._clearTimer();
39
+ var queue = after._queue;
40
+ after._queue = [];
41
+ after._bound = {};
42
+ for (var i=0; i < queue.length; i++) queue[i]();
43
+ };
44
+
45
+ after._startTimer = function() {
46
+ if (after._timer) return;
47
+ after._timer = setTimeout(after._runCallbacks, 1);
48
+ };
49
+
50
+ after._clearTimer = function() {
51
+ if (!after._timer) return;
52
+ clearTimeout(after._timer);
53
+ after._timer = 0;
54
+ };
55
+
56
+ return after;
57
+ })();
@@ -1,5 +1,6 @@
1
1
  include('const.js');
2
2
  include('utils.js');
3
+ include('after.js');
3
4
  include('dom.js');
4
5
  include('geometry.js');
5
6
  include('view/observable.js');
@@ -86,9 +87,12 @@ include('view/observable.js');
86
87
  /**
87
88
  * uki.view.Base api
88
89
  */
89
- parent: function() {
90
- return null;
91
- },
90
+ parent: uki.F,
91
+
92
+ /**
93
+ * uki.view.Base api
94
+ */
95
+ childResized: uki.F,
92
96
 
93
97
  /**
94
98
  * On window resize resizes and layout its child view
@@ -149,10 +153,15 @@ include('view/observable.js');
149
153
  uki.dom.bind(root, 'resize', function() {
150
154
  if (!timeout) {
151
155
  timeout = true;
152
- setTimeout(function() {
156
+ setTimeout(function(i,len) {
157
+ uki.after.start();
158
+
153
159
  timeout = false;
154
- uki.each(self.instances, function() { this.layout(); });
155
- }, 1)
160
+ for (i=0,len=self.instances.length;i<len;i++)
161
+ self.instances[i].layout();
162
+
163
+ uki.after.stop();
164
+ }, 1);
156
165
  }
157
166
  });
158
167
  }
@@ -2,9 +2,9 @@ include('uki.js');
2
2
 
3
3
  (function() {
4
4
  var nullRegexp = /^\s*null\s*$/,
5
- themeRegexp = /theme\s*\(\s*([^)]*\s*)\)/,
6
- rowsRegexp = /rows\s*\(\s*([^)]*\s*)\)/,
7
- cssBoxRegexp = /cssBox\s*\(\s*([^)]*\s*)\)/;
5
+ themeRegexp = /theme\s*\(\s*(.*\s*)\)/,
6
+ rowsRegexp = /rows\s*\(\s*(.*\s*)\)/,
7
+ cssBoxRegexp = /cssBox\s*\(\s*(.*\s*)\)/;
8
8
 
9
9
  /**
10
10
  * Transforms a bg string into a background object
@@ -24,6 +24,7 @@ include('uki.js');
24
24
  var match;
25
25
  /*jsl:ignore*/
26
26
  if ( match = bg.match(nullRegexp) ) return new self.Null();
27
+
27
28
  if ( match = bg.match(themeRegexp) ) return uki.theme.background( match[1] );
28
29
  if ( match = bg.match(rowsRegexp) ) return new self.Rows( match[1].split(',')[0], match[1].split(/\s*,\s*/).slice(1) );
29
30
  if ( match = bg.match(cssBoxRegexp) ) return new self.CssBox( match[1] );
@@ -11,6 +11,7 @@ uki.background.Css = uki.newClass(new function() {
11
11
  /**#@+ @memberOf uki.background.Css.prototype */
12
12
  this.init = function(options) {
13
13
  this._options = typeof options == 'string' ? {background: options} : options;
14
+ this._options = uki.browser.css(this._options);
14
15
  };
15
16
 
16
17
  this.attachTo = function(comp) {
@@ -36,16 +36,18 @@ uki.background.CssBox = uki.newClass(new function() {
36
36
 
37
37
  this._container = uki.createElement(
38
38
  'div',
39
- options + ';position:absolute;overflow:hidden;z-index:' + (ext.zIndex || '-1') + ';' +
40
- 'left:' + inset.left + 'px;top:' + inset.top + 'px;right:' + inset.right + 'px;bottom:' + inset.bottom + 'px',
39
+ 'position:absolute;overflow:hidden;z-index:' + (ext.zIndex || '-1') + ';' +
40
+ 'left:' + inset.left + 'px;top:' + inset.top + 'px;right:' + inset.right + 'px;bottom:' + inset.bottom + 'px;' +
41
+ uki.browser.css(options),
41
42
  ext.innerHTML
42
43
  );
44
+ this._container.className = 'uki-background-CssBox';
43
45
  this._attached = false;
44
46
  };
45
47
 
46
48
  this.attachTo = function(comp) {
47
49
  this._comp = comp;
48
- this._comp.dom().appendChild(this._container);
50
+ this._comp.dom().insertBefore(this._container, this._comp.dom().firstChild);
49
51
 
50
52
  if (uki.supportNativeLayout) return;
51
53
 
@@ -0,0 +1,112 @@
1
+ include('../background.js');
2
+
3
+ /**
4
+ * Adds a div with given cssText to dom()
5
+ *
6
+ * @class
7
+ */
8
+ uki.background.LinearGradient = uki.newClass(uki.background.CssBox, new function() {
9
+
10
+ var CANVAS_GRADIENT_SIZE = 200;
11
+
12
+ /**
13
+ * @param options Object { startColor: '#FFFFFF', endColor: '#CCCCCC', horizontal: true, css: 'border: 1px solid #CCC' }
14
+ */
15
+ this.init = function(options) {
16
+ this._options = options;
17
+ var inset = this._inset = uki.geometry.Inset.create(this._options.inset) || new uki.geometry.Inset();
18
+
19
+ this._container = this._createContainer();
20
+ var clone = this._container.cloneNode(true);
21
+ clone.style.cssText += ';width:100px;height:100px;';
22
+ uki.dom.probe(clone, uki.proxy(function(c) {
23
+ this._insetWidth = c.offsetWidth - 100 + inset.width();
24
+ this._insetHeight = c.offsetHeight - 100 + inset.height();
25
+ }, this));
26
+ this._container.style.cssText += ';left:' + inset.left + 'px;top:' + inset.top + 'px;right:' + inset.right + 'px;bottom:' + inset.bottom + 'px;';
27
+
28
+ this._attached = false;
29
+ };
30
+
31
+ var urlCache = {};
32
+ function getGradientURL (startColor, endColor, horizontal, stops) {
33
+ var key = startColor + endColor + (horizontal ? 1 : 0) + uki.map(stops, function(stop) { return stop.pos + '-' + stop.color; });
34
+ if (!urlCache[key]) {
35
+
36
+ var canvas = document.createElement('canvas');
37
+ canvas.width = canvas.height = CANVAS_GRADIENT_SIZE;
38
+
39
+ var context = canvas.getContext('2d'),
40
+ gradient = context.createLinearGradient(0, 0, horizontal ? CANVAS_GRADIENT_SIZE : 0, horizontal ? 0 : CANVAS_GRADIENT_SIZE);
41
+
42
+ gradient.addColorStop(0, startColor);
43
+ gradient.addColorStop(1, endColor);
44
+ for (var i=0; i < stops.length; i++) {
45
+ gradient.addColorStop(stops[i].pos, stops[i].color);
46
+ };
47
+ context.fillStyle = gradient;
48
+ context.fillRect(0, 0, CANVAS_GRADIENT_SIZE, CANVAS_GRADIENT_SIZE);
49
+ urlCache[key] = canvas.toDataURL && canvas.toDataURL();
50
+ }
51
+ return urlCache[key];
52
+ }
53
+
54
+ function mosFilter (horizontal, startColor, endColor) {
55
+ return 'filter:progid:DXImageTransform.Microsoft.gradient(gradientType=' + (horizontal ? '1' : '0') + ', startColorstr=#FF' + startColor.substr(1) + ', endColorstr=#FF' + endColor.substr(1) + ');';
56
+ }
57
+
58
+
59
+ this._createContainer = function() {
60
+ var startColor = this._options.startColor || '#FFFFFF',
61
+ endColor = this._options.endColor || '#CCCCCC',
62
+ horizontal = this._options.horizontal,
63
+ stops = this._options.stops || [],
64
+ css = '',
65
+ i = 0,
66
+ cssProp = uki.browser.cssLinearGradient(),
67
+ url;
68
+
69
+ if (cssProp == '-moz-linear-gradient' || cssProp == 'linear-gradient') {
70
+ css += 'background-image:' + cssProp + '(' + (horizontal ? 'left' : 'top') + ', ' + startColor;
71
+ for (;i<stops.length;i++) {
72
+ css += ',' + stops[i].color + ' ' + (stops[i].pos * 100) + '%';
73
+ }
74
+ css += ', ' + endColor + ');';
75
+ } else if (cssProp == '-webkit-gradient') {
76
+ css += 'background-image:' + cssProp + '(linear, 0% 0%, ' + (horizontal ? '100% 0%' : '0% 100%') + ', from(' + startColor + '), to(' + endColor + ')';
77
+ for (;i<stops.length;i++) {
78
+ css += ',color-stop(' + (stops[i].pos * 100) + '%,' + stops[i].color +')';
79
+ }
80
+ css += ');';
81
+ } else if (!uki.browser.canvas() && uki.browser.cssFilter() && stops.length == 0) {
82
+ css += mosFilter(horizontal, startColor, endColor);
83
+ }
84
+
85
+ var container = uki.createElement('div', uki.browser.css(this._options.css) + ';position:absolute;overflow:hidden;z-index:' + (this._options.zIndex || '-1') + ';' + css, this._options.innerHTML);
86
+ container.className = 'uki-background-CssBox';
87
+ if (css) return container;
88
+
89
+ if (uki.browser.canvas() && (url = getGradientURL(startColor, endColor, horizontal, stops))) {
90
+ var img = uki.createElement('img', 'position:absolute;left:0;top:0;width:100%;height:100%;z-index:0;');
91
+ img.src = url;
92
+ container.appendChild(img);
93
+ } else if (uki.browser.cssFilter() && stops.length > 0) {
94
+ stops.unshift({ pos: 0, color: startColor });
95
+ stops.push({ pos: 1, color: endColor });
96
+ var child;
97
+ for (;i<stops.length-1;i++) {
98
+ child = uki.createElement('div', 'position:absolute;z-index:-1' +
99
+ ';left:' + (horizontal ? stops[i].pos * 100 - (i && 1) + '%' : '0') +
100
+ ';top:' + (horizontal ? '0' : stops[i].pos * 100 - (i && 1) + '%') +
101
+ ';width:' + (horizontal ? (stops[i+1].pos - stops[i].pos) * 100 + 1 + '%' : '100%') +
102
+ ';height:' + (horizontal ? '100%' : (stops[i+1].pos - stops[i].pos) * 100 + 1 + '%') +
103
+ ';' + mosFilter(horizontal, stops[i].color, stops[i+1].color)
104
+ );
105
+ container.appendChild(child);
106
+ }
107
+ }
108
+ return container;
109
+ };
110
+
111
+ /**#@-*/
112
+ });
@@ -8,12 +8,12 @@ uki.background.Multi = uki.newClass({
8
8
  this._bgs = Array.prototype.slice.call(arguments, 0);
9
9
  },
10
10
  attachTo: function(comp) {
11
- for (var i=0; i < this._bgs.length; i++) {
11
+ for (var i=0, $this$_bgs$length = this._bgs.length; i < $this$_bgs$length; i++) {
12
12
  this._bgs[i].attachTo(comp);
13
13
  };
14
14
  },
15
15
  detach: function() {
16
- for (var i=0; i < this._bgs.length; i++) {
16
+ for (var i=0, $this$_bgs$length = this._bgs.length; i < $this$_bgs$length; i++) {
17
17
  this._bgs[i].detach();
18
18
  };
19
19
  }
@@ -28,6 +28,7 @@ uki.background.Rows = uki.newClass(new function() {
28
28
  'div',
29
29
  'position:absolute;left:0;top:0;width:100%;z-index:-1'
30
30
  );
31
+ this._container.className = 'uki-background-Rows' ;
31
32
  }
32
33
  this._layoutHandler = this._layoutHandler || uki.proxy(function(e) { this.layout(e.rect, e.visibleRect); }, this);
33
34
  this._comp.dom().appendChild(this._container);