uki 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. data/.gitignore +7 -0
  2. data/.gitmodules +3 -0
  3. data/LICENSE +20 -0
  4. data/Rakefile +23 -0
  5. data/Readme.rdoc +9 -0
  6. data/VERSION +1 -0
  7. data/bin/uki +102 -0
  8. data/frameworks/jspec/lib/images/bg.png +0 -0
  9. data/frameworks/jspec/lib/images/hr.png +0 -0
  10. data/frameworks/jspec/lib/images/loading.gif +0 -0
  11. data/frameworks/jspec/lib/images/sprites.bg.png +0 -0
  12. data/frameworks/jspec/lib/images/sprites.png +0 -0
  13. data/frameworks/jspec/lib/images/vr.png +0 -0
  14. data/frameworks/jspec/lib/jspec.css +149 -0
  15. data/frameworks/jspec/lib/jspec.growl.js +115 -0
  16. data/frameworks/jspec/lib/jspec.jquery.js +72 -0
  17. data/frameworks/jspec/lib/jspec.js +1756 -0
  18. data/frameworks/jspec/lib/jspec.shell.js +39 -0
  19. data/frameworks/jspec/lib/jspec.timers.js +90 -0
  20. data/frameworks/jspec/lib/jspec.xhr.js +195 -0
  21. data/frameworks/uki/README.rdoc +179 -0
  22. data/frameworks/uki/compiler.jar +0 -0
  23. data/frameworks/uki/run.rb +2 -0
  24. data/frameworks/uki/spec/commands/example_command.rb +19 -0
  25. data/frameworks/uki/spec/dom.html +39 -0
  26. data/frameworks/uki/spec/support/images/bg.png +0 -0
  27. data/frameworks/uki/spec/support/images/hr.png +0 -0
  28. data/frameworks/uki/spec/support/images/loading.gif +0 -0
  29. data/frameworks/uki/spec/support/images/sprites.bg.png +0 -0
  30. data/frameworks/uki/spec/support/images/sprites.png +0 -0
  31. data/frameworks/uki/spec/support/images/vr.png +0 -0
  32. data/frameworks/uki/spec/support/jspec.css +149 -0
  33. data/frameworks/uki/spec/support/jspec.js +1773 -0
  34. data/frameworks/uki/spec/support/jspec.xhr.js +193 -0
  35. data/frameworks/uki/spec/support/spec.helper.js +1 -0
  36. data/frameworks/uki/spec/unit/background.spec.js +29 -0
  37. data/frameworks/uki/spec/unit/builder.spec.js +51 -0
  38. data/frameworks/uki/spec/unit/data/model.spec.js +29 -0
  39. data/frameworks/uki/spec/unit/dom/dnd.spec.js +71 -0
  40. data/frameworks/uki/spec/unit/dom/event.spec.js +78 -0
  41. data/frameworks/uki/spec/unit/dom.spec.js +28 -0
  42. data/frameworks/uki/spec/unit/geometry.spec.js +79 -0
  43. data/frameworks/uki/spec/unit/selector.spec.js +140 -0
  44. data/frameworks/uki/spec/unit/theme/template.spec.js +31 -0
  45. data/frameworks/uki/spec/unit/utils.spec.js +176 -0
  46. data/frameworks/uki/spec/unit/view/base.spec.js +86 -0
  47. data/frameworks/uki/spec/unit/view/container.spec.js +73 -0
  48. data/frameworks/uki/spec/unit/view.spec.js +13 -0
  49. data/frameworks/uki/src/airport.js +1 -0
  50. data/frameworks/uki/src/uki-core/attachment.js +175 -0
  51. data/frameworks/uki/src/uki-core/background/css.js +37 -0
  52. data/frameworks/uki/src/uki-core/background/cssBox.js +73 -0
  53. data/frameworks/uki/src/uki-core/background/multi.js +20 -0
  54. data/frameworks/uki/src/uki-core/background/null.js +10 -0
  55. data/frameworks/uki/src/uki-core/background/rows.js +77 -0
  56. data/frameworks/uki/src/uki-core/background/sliced9.js +206 -0
  57. data/frameworks/uki/src/uki-core/background.js +35 -0
  58. data/frameworks/uki/src/uki-core/builder.js +68 -0
  59. data/frameworks/uki/src/uki-core/collection.js +278 -0
  60. data/frameworks/uki/src/uki-core/const.js +17 -0
  61. data/frameworks/uki/src/uki-core/dom/dnd.js +93 -0
  62. data/frameworks/uki/src/uki-core/dom/event.js +194 -0
  63. data/frameworks/uki/src/uki-core/dom/nativeLayout.js +18 -0
  64. data/frameworks/uki/src/uki-core/dom/offset.js +130 -0
  65. data/frameworks/uki/src/uki-core/dom/w3cdnd.js +333 -0
  66. data/frameworks/uki/src/uki-core/dom.js +109 -0
  67. data/frameworks/uki/src/uki-core/geometry.js +658 -0
  68. data/frameworks/uki/src/uki-core/image.js +90 -0
  69. data/frameworks/uki/src/uki-core/selector.js +201 -0
  70. data/frameworks/uki/src/uki-core/theme/base.js +39 -0
  71. data/frameworks/uki/src/uki-core/theme/template.js +26 -0
  72. data/frameworks/uki/src/uki-core/theme.js +45 -0
  73. data/frameworks/uki/src/uki-core/uki.js +45 -0
  74. data/frameworks/uki/src/uki-core/utils.js +399 -0
  75. data/frameworks/uki/src/uki-core/view/base.js +480 -0
  76. data/frameworks/uki/src/uki-core/view/container.js +155 -0
  77. data/frameworks/uki/src/uki-core/view/focusable.js +93 -0
  78. data/frameworks/uki/src/uki-core/view/observable.js +66 -0
  79. data/frameworks/uki/src/uki-core/view/styleable.js +70 -0
  80. data/frameworks/uki/src/uki-core/view/utils.js +66 -0
  81. data/frameworks/uki/src/uki-core/view.js +21 -0
  82. data/frameworks/uki/src/uki-core.js +36 -0
  83. data/frameworks/uki/src/uki-data/data.js +1 -0
  84. data/frameworks/uki/src/uki-data/model.js +28 -0
  85. data/frameworks/uki/src/uki-data/observable.js +34 -0
  86. data/frameworks/uki/src/uki-data.js +1 -0
  87. data/frameworks/uki/src/uki-more/more/utils.js +20 -0
  88. data/frameworks/uki/src/uki-more/more/view/listContainer.js +4 -0
  89. data/frameworks/uki/src/uki-more/more/view/multiselectList.js +196 -0
  90. data/frameworks/uki/src/uki-more/more/view/radioButton.js +27 -0
  91. data/frameworks/uki/src/uki-more/more/view/splitTable.js +79 -0
  92. data/frameworks/uki/src/uki-more/more/view/toggleButton.js +24 -0
  93. data/frameworks/uki/src/uki-more/more/view/treeList/render.js +53 -0
  94. data/frameworks/uki/src/uki-more/more/view/treeList.js +110 -0
  95. data/frameworks/uki/src/uki-more/more/view.js +2 -0
  96. data/frameworks/uki/src/uki-more/more.js +1 -0
  97. data/frameworks/uki/src/uki-more.js +4 -0
  98. data/frameworks/uki/src/uki-theamless.js +15 -0
  99. data/frameworks/uki/src/uki-theme/airport/i/button/down-c.gif +0 -0
  100. data/frameworks/uki/src/uki-theme/airport/i/button/down-c.png +0 -0
  101. data/frameworks/uki/src/uki-theme/airport/i/button/down-h.gif +0 -0
  102. data/frameworks/uki/src/uki-theme/airport/i/button/down-h.png +0 -0
  103. data/frameworks/uki/src/uki-theme/airport/i/button/down-m.png +0 -0
  104. data/frameworks/uki/src/uki-theme/airport/i/button/down-v.png +0 -0
  105. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-c.png +0 -0
  106. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-h.png +0 -0
  107. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-m.png +0 -0
  108. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-v.png +0 -0
  109. data/frameworks/uki/src/uki-theme/airport/i/button/focusRing.png +0 -0
  110. data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.gif +0 -0
  111. data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.png +0 -0
  112. data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.gif +0 -0
  113. data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.png +0 -0
  114. data/frameworks/uki/src/uki-theme/airport/i/button/hover-m.png +0 -0
  115. data/frameworks/uki/src/uki-theme/airport/i/button/hover-v.png +0 -0
  116. data/frameworks/uki/src/uki-theme/airport/i/button/hover.png +0 -0
  117. data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.gif +0 -0
  118. data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.png +0 -0
  119. data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.gif +0 -0
  120. data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.png +0 -0
  121. data/frameworks/uki/src/uki-theme/airport/i/button/normal-m.png +0 -0
  122. data/frameworks/uki/src/uki-theme/airport/i/button/normal-v.png +0 -0
  123. data/frameworks/uki/src/uki-theme/airport/i/button/normal.png +0 -0
  124. data/frameworks/uki/src/uki-theme/airport/i/checkbox/checkbox.png +0 -0
  125. data/frameworks/uki/src/uki-theme/airport/i/checkbox/focus.png +0 -0
  126. data/frameworks/uki/src/uki-theme/airport/i/checkbox/normal.gif +0 -0
  127. data/frameworks/uki/src/uki-theme/airport/i/checkbox/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/radio/focus.png +0 -0
  134. data/frameworks/uki/src/uki-theme/airport/i/radio/normal.gif +0 -0
  135. data/frameworks/uki/src/uki-theme/airport/i/radio/normal.png +0 -0
  136. data/frameworks/uki/src/uki-theme/airport/i/radio/radio.png +0 -0
  137. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-c.png +0 -0
  138. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-h.png +0 -0
  139. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-m.png +0 -0
  140. data/frameworks/uki/src/uki-theme/airport/i/shadow/large-v.png +0 -0
  141. data/frameworks/uki/src/uki-theme/airport/i/shadow/large.png +0 -0
  142. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.gif +0 -0
  143. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.png +0 -0
  144. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.gif +0 -0
  145. data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.png +0 -0
  146. data/frameworks/uki/src/uki-theme/airport/i/slider/bar.png +0 -0
  147. data/frameworks/uki/src/uki-theme/airport/i/slider/focus.png +0 -0
  148. data/frameworks/uki/src/uki-theme/airport/i/slider/handle.gif +0 -0
  149. data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.gif +0 -0
  150. data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.png +0 -0
  151. data/frameworks/uki/src/uki-theme/airport/i/splitPane/vertical.gif +0 -0
  152. data/frameworks/uki/src/uki-theme/airport/i/x.gif +0 -0
  153. data/frameworks/uki/src/uki-theme/airport.js +322 -0
  154. data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.gif +0 -0
  155. data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.png +0 -0
  156. data/frameworks/uki/src/uki-theme/aristo/i/button/down-h.png +0 -0
  157. data/frameworks/uki/src/uki-theme/aristo/i/button/down-m.png +0 -0
  158. data/frameworks/uki/src/uki-theme/aristo/i/button/down-v.png +0 -0
  159. data/frameworks/uki/src/uki-theme/aristo/i/button/down.png +0 -0
  160. data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-c.png +0 -0
  161. data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-h.png +0 -0
  162. data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-m.png +0 -0
  163. data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-v.png +0 -0
  164. data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing.png +0 -0
  165. data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.gif +0 -0
  166. data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.png +0 -0
  167. data/frameworks/uki/src/uki-theme/aristo/i/button/normal-h.png +0 -0
  168. data/frameworks/uki/src/uki-theme/aristo/i/button/normal-m.png +0 -0
  169. data/frameworks/uki/src/uki-theme/aristo/i/button/normal-v.png +0 -0
  170. data/frameworks/uki/src/uki-theme/aristo/i/button/normal.png +0 -0
  171. data/frameworks/uki/src/uki-theme/aristo/i/checkbox/focus.png +0 -0
  172. data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.gif +0 -0
  173. data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.png +0 -0
  174. data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-h.png +0 -0
  175. data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-m.png +0 -0
  176. data/frameworks/uki/src/uki-theme/aristo/i/panel/normal.png +0 -0
  177. data/frameworks/uki/src/uki-theme/aristo/i/popup/normal.png +0 -0
  178. data/frameworks/uki/src/uki-theme/aristo/i/radio/focus.png +0 -0
  179. data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.gif +0 -0
  180. data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.png +0 -0
  181. data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-c.png +0 -0
  182. data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-h.png +0 -0
  183. data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-m.png +0 -0
  184. data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-v.png +0 -0
  185. data/frameworks/uki/src/uki-theme/aristo/i/shadow/large.png +0 -0
  186. data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.gif +0 -0
  187. data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.png +0 -0
  188. data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.gif +0 -0
  189. data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.png +0 -0
  190. data/frameworks/uki/src/uki-theme/aristo/i/slider/bar.png +0 -0
  191. data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.gif +0 -0
  192. data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.png +0 -0
  193. data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.gif +0 -0
  194. data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.png +0 -0
  195. data/frameworks/uki/src/uki-theme/aristo/i/splitPane/vertical.gif +0 -0
  196. data/frameworks/uki/src/uki-theme/aristo/i/x.gif +0 -0
  197. data/frameworks/uki/src/uki-theme/aristo.js +217 -0
  198. data/frameworks/uki/src/uki-view/view/box.js +1 -0
  199. data/frameworks/uki/src/uki-view/view/button.js +126 -0
  200. data/frameworks/uki/src/uki-view/view/checkbox.js +36 -0
  201. data/frameworks/uki/src/uki-view/view/flow.js +48 -0
  202. data/frameworks/uki/src/uki-view/view/image.js +9 -0
  203. data/frameworks/uki/src/uki-view/view/label.js +123 -0
  204. data/frameworks/uki/src/uki-view/view/list/render.js +23 -0
  205. data/frameworks/uki/src/uki-view/view/list.js +442 -0
  206. data/frameworks/uki/src/uki-view/view/popup.js +113 -0
  207. data/frameworks/uki/src/uki-view/view/radio.js +57 -0
  208. data/frameworks/uki/src/uki-view/view/scrollPane.js +139 -0
  209. data/frameworks/uki/src/uki-view/view/slider.js +154 -0
  210. data/frameworks/uki/src/uki-view/view/splitPane.js +213 -0
  211. data/frameworks/uki/src/uki-view/view/table/column.js +96 -0
  212. data/frameworks/uki/src/uki-view/view/table/header.js +53 -0
  213. data/frameworks/uki/src/uki-view/view/table/render.js +25 -0
  214. data/frameworks/uki/src/uki-view/view/table.js +71 -0
  215. data/frameworks/uki/src/uki-view/view/textField.js +145 -0
  216. data/frameworks/uki/src/uki-view/view/toolbar.js +93 -0
  217. data/frameworks/uki/src/uki-view.js +15 -0
  218. data/frameworks/uki/src/uki.js +2 -0
  219. data/frameworks/uki/thin.yaml +11 -0
  220. data/frameworks/uki/uki.rb +38 -0
  221. data/frameworks/uki/uki.ru +2 -0
  222. data/lib/uki/include_js.rb +50 -0
  223. data/lib/uki/project.rb +207 -0
  224. data/lib/uki/routes.rb +20 -0
  225. data/lib/uki/server.rb +42 -0
  226. data/lib/uki.rb +9 -0
  227. data/templates/index.html.erb +10 -0
  228. data/templates/model.js.erb +5 -0
  229. data/templates/myapp.js.erb +44 -0
  230. data/templates/package.js.erb +3 -0
  231. data/templates/spec.html.erb +23 -0
  232. data/templates/spec.js.erb +6 -0
  233. data/templates/view.js.erb +10 -0
  234. data/uki.gemspec +281 -0
  235. metadata +317 -0
@@ -0,0 +1,37 @@
1
+ include('../background.js');
2
+ include('../image.js');
3
+
4
+ /**
5
+ * Writes css properties to targets dom()
6
+ *
7
+ * @class
8
+ */
9
+ uki.background.Css = uki.newClass(new function() {
10
+
11
+ /**#@+ @memberOf uki.background.Css.prototype */
12
+ this.init = function(options) {
13
+ this._options = typeof options == 'string' ? {background: options} : options;
14
+ };
15
+
16
+ this.attachTo = function(comp) {
17
+ this._comp = comp;
18
+ this._originalValues = {};
19
+
20
+ uki.each(this._options, function(name, value) {
21
+ // this._originalValues[name] = dom.style[name];
22
+ // dom.style[name] = value;
23
+ this._originalValues[name] = comp.style(name);
24
+ comp.style(name, value);
25
+ }, this);
26
+ };
27
+
28
+ this.detach = function() {
29
+ if (this._comp) {
30
+ uki.each(this._options, function(name, value) {
31
+ this._comp.style(name, this._originalValues[name]);
32
+ }, this);
33
+ }
34
+
35
+ };
36
+ /**#@-*/
37
+ });
@@ -0,0 +1,73 @@
1
+ include('../background.js');
2
+ include('../geometry.js');
3
+
4
+ /**
5
+ * Adds a div with given cssText to dom()
6
+ *
7
+ * @class
8
+ */
9
+ uki.background.CssBox = uki.newClass(new function() {
10
+
11
+ var cache = {};
12
+ /** @ignore */
13
+ function getInsets(options) {
14
+ if (!cache[options]) {
15
+ uki.dom.probe(
16
+ uki.createElement('div', options + ';position:absolute;overflow:hidden;left:-999em;width:10px;height:10px;'),
17
+ function(c) {
18
+ cache[options] = new Inset(
19
+ c.offsetHeight - 10,
20
+ c.offsetWidth - 10
21
+ );
22
+ }
23
+ );
24
+ }
25
+ return cache[options];
26
+ }
27
+
28
+ /**#@+ @memberOf uki.background.CssBox.prototype */
29
+
30
+ this.init = function(options, ext) {
31
+ this._options = options;
32
+ ext = ext || {};
33
+ this._inset = inset = Inset.create(ext.inset) || new Inset();
34
+ this._insetWidth = getInsets(options).left + inset.left + inset.right;
35
+ this._insetHeight = getInsets(options).top + inset.top + inset.bottom;
36
+
37
+ this._container = uki.createElement(
38
+ 'div',
39
+ options + ';position:absolute;overflow:hidden;z-index:' + (ext.zIndex || '-1') + ';' +
40
+ 'left:' + inset.left + ';top:' + inset.top + 'px;right:' + inset.right + 'px;bottom:' + inset.bottom + 'px',
41
+ ext.innerHTML
42
+ );
43
+ this._attached = false;
44
+ };
45
+
46
+ this.attachTo = function(comp) {
47
+ this._comp = comp;
48
+ this._comp.dom().appendChild(this._container);
49
+
50
+ if (uki.supportNativeLayout) return;
51
+
52
+ this._layoutHandler = this._layoutHandler || uki.proxy(function(e) { this.layout(e.rect); }, this);
53
+ this._comp.bind('layout', this._layoutHandler);
54
+ this.layout(this._comp.rect());
55
+ };
56
+
57
+ this.layout = function(size) {
58
+ this._prevLayout = uki.dom.layout(this._container.style, {
59
+ width: size.width - this._insetWidth,
60
+ height: size.height - this._insetHeight
61
+ }, this._prevLayout);
62
+ };
63
+
64
+ this.detach = function() {
65
+ if (this._comp) {
66
+ this._comp.dom().removeChild(this._container);
67
+ if (!uki.supportNativeLayout) this._comp.unbind('layout', this._layoutHandler);
68
+ this._attached = false;
69
+ }
70
+ };
71
+
72
+ /**#@-*/
73
+ });
@@ -0,0 +1,20 @@
1
+ include('../background.js');
2
+
3
+ /**
4
+ * @class
5
+ */
6
+ uki.background.Multi = uki.newClass({
7
+ init: function() {
8
+ this._bgs = Array.prototype.slice.call(arguments, 0);
9
+ },
10
+ attachTo: function(comp) {
11
+ for (var i=0; i < this._bgs.length; i++) {
12
+ this._bgs[i].attachTo(comp);
13
+ };
14
+ },
15
+ detach: function() {
16
+ for (var i=0; i < this._bgs.length; i++) {
17
+ this._bgs[i].detach();
18
+ };
19
+ }
20
+ });
@@ -0,0 +1,10 @@
1
+ include('../background.js');
2
+
3
+ /**
4
+ * @class
5
+ */
6
+ uki.background.Base = uki.background.Null = uki.newClass({
7
+ init: uki.F,
8
+ attachTo: uki.F,
9
+ detach: uki.F
10
+ });
@@ -0,0 +1,77 @@
1
+ include('../background.js');
2
+
3
+ /**
4
+ * Adds a div with colored rows to dom
5
+ *
6
+ * @class
7
+ */
8
+ uki.background.Rows = uki.newClass(new function() {
9
+ var proto = this,
10
+ cache = [],
11
+ packSize = 100;
12
+
13
+ /**#@+ @memberOf uki.background.Rows.prototype */
14
+
15
+ proto.init = function(height, colors) {
16
+ this._height = height || 20;
17
+ this._colors = uki.isArray(colors) ? colors : colors.split(' ');
18
+ this._packSize = CEIL(packSize/this._colors.length)*this._colors.length;
19
+ this._renderedHeight = 0;
20
+ this._visibleExt = 200;
21
+ if (this._colors.length == 1) this._colors = this._colors.concat(['#FFF']);
22
+ };
23
+
24
+ proto.attachTo = function(comp) {
25
+ this._comp && this.detach();
26
+ this._comp = comp;
27
+ if (!this._container) {
28
+ this._container = uki.createElement(
29
+ 'div',
30
+ 'position:absolute;left:0;top:0;width:100%;z-index:-1'
31
+ );
32
+ }
33
+ this._layoutHandler = this._layoutHandler || uki.proxy(function(e) { this.layout(e.rect, e.visibleRect); }, this);
34
+ this._comp.dom().appendChild(this._container);
35
+ this._comp.bind('layout', this._layoutHandler);
36
+ };
37
+
38
+ proto.layout = function(rect, visibleRect) {
39
+ var height = visibleRect ? visibleRect.height + this._visibleExt*2 : rect.maxY();
40
+ while (this._renderedHeight < height) {
41
+ var h = packSize * this._height,
42
+ c = uki.createElement('div', 'height:' + h + 'px;overflow:hidden;width:100%;', getPackHTML(this._height, this._colors));
43
+ this._renderedHeight += h;
44
+ this._container.appendChild(c);
45
+ }
46
+ if (visibleRect) {
47
+ this._container.style.top = CEIL((visibleRect.y - this._visibleExt)/this._height/this._colors.length)*this._height*this._colors.length + 'px';
48
+ }
49
+ };
50
+
51
+ proto.detach = function() {
52
+ this._comp.dom().removeChild(this._container);
53
+ this._comp.unbind('layout', this._layoutHandler);
54
+ this._comp = null;
55
+ };
56
+
57
+ /**#@-*/
58
+
59
+ function getPackHTML (height, colors) {
60
+ var key = height + ' ' + colors.join(' '),
61
+ rows = [],
62
+ html = [],
63
+ i, l = colors.length;
64
+ if (!cache[key]) {
65
+ for (i=0; i < l; i++) {
66
+ rows[i] = ['<div style="height:', height, 'px;width:100%;overflow:hidden;',
67
+ (colors[i] ? 'background:' + colors[i] : ''),
68
+ '"></div>'].join('');
69
+ };
70
+ for (i=0; i < packSize; i++) {
71
+ html[i] = rows[i%l];
72
+ };
73
+ cache[key] = html.join('');
74
+ }
75
+ return cache[key];
76
+ }
77
+ });
@@ -0,0 +1,206 @@
1
+ include('../background.js');
2
+ include('../image.js');
3
+
4
+ /**
5
+ * Adds a div with 9 sliced images in the corners, sides and center
6
+ *
7
+ * @class
8
+ */
9
+ uki.background.Sliced9 = uki.newClass(new function() {
10
+ var nativeCss = ['MozBorderImage', 'WebkitBorderImage', 'borderImage'],
11
+ dom = uki.dom;
12
+
13
+ var LEFT = 'left:',
14
+ TOP = 'top:',
15
+ RIGHT = 'right:',
16
+ BOTTOM = 'bottom:',
17
+ WIDTH = 'width:',
18
+ HEIGHT = 'height:',
19
+ PX = 'px',
20
+ P100 = '100%';
21
+
22
+ var cache = {};
23
+
24
+ /**#@+ @memberOf uki.background.Sliced9.prototype */
25
+
26
+ this.init = function(partSettings, inset, options) {
27
+ this._settings = uki.extend({}, partSettings);
28
+ this._inset = Inset.create(inset);
29
+ this._size = null;
30
+ this._inited = false;
31
+
32
+ options = options || {};
33
+ this._fixedSize = Size.create(options.fixedSize) || new Size();
34
+ this._bgInset = Inset.create(options.inset) || new Inset();
35
+ this._zIndex = options.zIndex || -1;
36
+
37
+ this._container = this._getContainer();
38
+ this._container.style.zIndex = this._zIndex;
39
+ };
40
+
41
+ /** @ignore */
42
+ function makeDiv (name, style, setting, imgStyle, bgSettings) {
43
+ var inner = setting[3] ? img(setting, imgStyle) : '';
44
+ if (!setting[3]) style += bgStyle(setting, bgSettings);
45
+ return '<div class="' + name + '" style="position:absolute;overflow:hidden;' + style + '">' + inner + '</div>';
46
+ }
47
+
48
+ /** @ignore */
49
+ function bgStyle (setting, bgSettings) {
50
+ return ';background: url(' + uki.imageSrc(setting[0], setting[1], setting[2]) + ') ' + bgSettings;
51
+ }
52
+
53
+ /** @ignore */
54
+ function img (setting, style) {
55
+ return uki.imageHTML(setting[0], setting[1], setting[2], ' galleryimg="no" style="-webkit-user-drag:none;position:absolute;' + style + '"');
56
+ }
57
+
58
+ /** @ignore */
59
+ this._getContainer = function() {
60
+ var key = this._getKey();
61
+ if (!cache[key]) {
62
+ return cache[key] = this._createContainer();
63
+ }
64
+ return cache[key].cloneNode(true);
65
+ };
66
+
67
+ /** @ignore */
68
+ this._createContainer = function() {
69
+ var inset = this._inset,
70
+ bgInset = this._bgInset,
71
+ settings = this._settings,
72
+ width = inset.left + inset.right,
73
+ height = inset.top + inset.bottom,
74
+ css = [LEFT + bgInset.left + PX, RIGHT + bgInset.right + PX, TOP + bgInset.top + PX, BOTTOM + bgInset.bottom + PX].join(';'),
75
+ html = [];
76
+
77
+ if (inset.top && inset.left) {
78
+ html[html.length] = makeDiv('tl',
79
+ [LEFT + 0, TOP + 0, WIDTH + inset.left + PX, HEIGHT + inset.top + PX].join(';'),
80
+ settings.c, [LEFT + 0, TOP + 0, WIDTH + width + PX, HEIGHT + height + PX].join(';'), 'top left'
81
+ );
82
+ }
83
+ if (inset.top) {
84
+ html[html.length] = makeDiv('t',
85
+ [LEFT + inset.left + PX, TOP + 0, HEIGHT + inset.top + PX, RIGHT + inset.right + PX].join(';'),
86
+ settings.h, [LEFT + 0, TOP + 0, WIDTH + P100, HEIGHT + height + PX].join(';'), 'repeat-x top'
87
+ );
88
+ }
89
+ if (inset.top && inset.right) {
90
+ html[html.length] = makeDiv('tr',
91
+ [RIGHT + 0, TOP + 0, WIDTH + inset.right + PX, HEIGHT + inset.top + PX].join(';'),
92
+ settings.c, [LEFT + '-' + inset.left + PX, TOP + 0, WIDTH + width + PX, HEIGHT + height + PX].join(';'), 'top right'
93
+ );
94
+ }
95
+
96
+ if (inset.left) {
97
+ html[html.length] = makeDiv('l',
98
+ [LEFT + 0, TOP + inset.top + PX, WIDTH + inset.left + PX, BOTTOM + inset.bottom + PX].join(';'),
99
+ settings.v, [LEFT + 0, TOP + 0, HEIGHT + P100, WIDTH + width + PX].join(';'), 'repeat-y left'
100
+ );
101
+ }
102
+ if (settings.m) {
103
+ html[html.length] = makeDiv('m',
104
+ [LEFT + inset.left + PX, TOP + inset.top + PX, RIGHT + inset.left + PX, BOTTOM + inset.bottom + PX].join(';'),
105
+ settings.m, [LEFT + 0, TOP + 0, HEIGHT + P100, WIDTH + P100].join(';'), ''
106
+ );
107
+ }
108
+ if (inset.right) {
109
+ html[html.length] = makeDiv('r',
110
+ [RIGHT + 0, TOP + inset.top + PX, WIDTH + inset.right + PX, BOTTOM + inset.bottom + PX].join(';'),
111
+ settings.v, [LEFT + '-' + inset.left + PX, TOP + 0, HEIGHT + P100, WIDTH + width + PX].join(';'), 'repeat-y right'
112
+ );
113
+ }
114
+
115
+ if (inset.bottom && inset.left) {
116
+ html[html.length] = makeDiv('bl',
117
+ [LEFT + 0, BOTTOM + 0, WIDTH + inset.left + PX, HEIGHT + inset.bottom + PX].join(';'),
118
+ settings.c, [LEFT + 0, TOP + '-' + inset.top + PX, WIDTH + width + PX, HEIGHT + height + PX].join(';'), 'left -' + inset.top + PX
119
+ );
120
+ }
121
+ if (inset.bottom) {
122
+ html[html.length] = makeDiv('b',
123
+ [LEFT + inset.left + PX, BOTTOM + 0, HEIGHT + inset.bottom + PX, RIGHT + inset.right + PX].join(';'),
124
+ settings.h, [LEFT + 0, TOP + '-' + inset.top + PX, WIDTH + P100, HEIGHT + height + PX].join(';'), 'repeat-x 0 -' + inset.top + PX
125
+ );
126
+ }
127
+ if (inset.bottom && inset.right) {
128
+ html[html.length] = makeDiv('br',
129
+ [RIGHT + 0, BOTTOM + 0, WIDTH + inset.right + PX, HEIGHT + inset.bottom + PX].join(';'),
130
+ settings.c, [LEFT + '-' + inset.left + PX, TOP + '-' + inset.top + PX, WIDTH + width + PX, HEIGHT + height + PX].join(';'), 'right -' + inset.top + PX
131
+ );
132
+ }
133
+ return uki.createElement('div', 'position:absolute;overflow:hidden;' + css, html.join(''));
134
+ };
135
+
136
+ /** @ignore */
137
+ this._getKey = function() {
138
+ return uki.map(['v', 'h', 'm', 'c'], function(x) {
139
+ return this._settings[x] && this._settings[x][0] || '';
140
+ }, this).concat([this._inset, this._bgInset, this._fixedSize]).join(',');
141
+ };
142
+
143
+ this.attachTo = function(comp) {
144
+ this._comp = comp;
145
+
146
+ this._container.style.visibility = 'visible';
147
+ this._comp.dom().appendChild(this._container);
148
+
149
+ if (!uki.supportNativeLayout) {
150
+ this._layoutHandler = this._layoutHandler || uki.proxy(function(e) {
151
+ if (this._size && this._size.eq(e.rect)) return;
152
+ this._size = e.rect;
153
+ this.layout();
154
+ }, this);
155
+ this._comp.bind('layout', this._layoutHandler);
156
+ this.layout();
157
+ }
158
+ };
159
+
160
+ this.detach = function() {
161
+ if (this._comp) {
162
+ // this._comp.dom().removeChild(this._container);
163
+ this._container.style.visibility = 'hidden';
164
+ if (!uki.supportNativeLayout) this._comp.unbind('layout', this._layoutHandler);
165
+ this._size = this._comp = null;
166
+ this._attached = this._inited = false;
167
+ }
168
+ };
169
+
170
+ this.layout = function(e) {
171
+ var size = this._comp.rect(),
172
+ parts = this._parts,
173
+ inset = this._inset,
174
+ bgInset = this._bgInset,
175
+ fixedSize = this._fixedSize,
176
+ width = FLOOR(fixedSize.width || size.width - bgInset.left - bgInset.right),
177
+ height = FLOOR(fixedSize.height || size.height - bgInset.top - bgInset.bottom),
178
+ insetWidth = inset.left + inset.right,
179
+ insetHeight = inset.top + inset.bottom;
180
+
181
+ if (!parts) {
182
+ parts = {};
183
+ uki.each(this._container.childNodes, function() {
184
+ if (this.className) parts[this.className] = this;
185
+ });
186
+ this._parts = parts;
187
+ }
188
+ // parts.b.style.bottom = ''
189
+ // parts.b.style.top = '100%';
190
+ // parts.b.style.marginTop = - inset.bottom + 'px';
191
+ if (parts.t) dom.layout(parts.t.style, { width: width - insetWidth });
192
+ if (parts.b) dom.layout(parts.b.style, { width: width - insetWidth });
193
+ if (parts.l) dom.layout(parts.l.style, { height: height - insetHeight });
194
+ if (parts.r) dom.layout(parts.r.style, { height: height - insetHeight });
195
+ if (parts.m) dom.layout(parts.m.style, {
196
+ height: height - insetHeight,
197
+ width: width - insetWidth
198
+ });
199
+ dom.layout(this._container.style, {
200
+ width: width,
201
+ height: height
202
+ });
203
+ };
204
+
205
+ /**#@-*/
206
+ });
@@ -0,0 +1,35 @@
1
+ include('uki.js');
2
+
3
+ (function() {
4
+ var nullRegexp = /^\s*null\s*$/,
5
+ themeRegexp = /theme\s*\(\s*([^)]*\s*)\)/,
6
+ rowsRegexp = /rows\s*\(\s*([^)]*\s*)\)/,
7
+ cssBoxRegexp = /cssBox\s*\(\s*([^)]*\s*)\)/;
8
+
9
+ /**
10
+ * Transforms a bg string into a background object
11
+ * <p>Supported strings:<br />
12
+ * theme(bg-name) Takes background with bg-name from uki.theme<br />
13
+ * rows(30, #CCFFFF, #FFCCFF, #FFFFCC) Creates Rows background with 30px rowHeight and 3 colors<br />
14
+ * cssBox(border:1px solid red;background:blue) Creates CssBox background with given cssText<br />
15
+ * url(i.png) or #FFFFFF Creates Css background with single property</p>
16
+ *
17
+ * @param {String} bg
18
+ * @name uki.background
19
+ * @namespace
20
+ * @returns {uki.background.Base} created background
21
+ */
22
+ var self = uki.background = function(bg) {
23
+ if (typeof(bg) === 'string') {
24
+ var match;
25
+ /*jsl:ignore*/
26
+ if ( match = bg.match(nullRegexp) ) return new self.Null();
27
+ if ( match = bg.match(themeRegexp) ) return uki.theme.background( match[1] );
28
+ if ( match = bg.match(rowsRegexp) ) return new self.Rows( match[1].split(',')[0], match[1].split(/\s*,\s*/).slice(1) );
29
+ if ( match = bg.match(cssBoxRegexp) ) return new self.CssBox( match[1] );
30
+ /*jsl:end*/
31
+ return new self.Css(bg);
32
+ }
33
+ return bg;
34
+ };
35
+ })();
@@ -0,0 +1,68 @@
1
+ include('uki.js');
2
+ include('utils.js');
3
+ include('collection.js');
4
+
5
+
6
+ (function() {
7
+
8
+ /**
9
+ * Creates uki view tree from JSON-like markup
10
+ *
11
+ * @example
12
+ * uki.build( {view: 'Button', rect: '100 100 100 24', text: 'Hello world' } )
13
+ * // Creates uki.view.Button with '100 100 100 24' passed to constructor,
14
+ * // and calls text('Hello world') on it
15
+ *
16
+ * @function
17
+ * @name uki.build
18
+ *
19
+ * @param {object} ml JSON-like markup
20
+ * @returns {uki.view.Collection} collection of created elements
21
+ */
22
+ uki.build = function(ml) {
23
+ if (ml.length === undefined) ml = [ml];
24
+ return new uki.Collection(createMulti(ml));
25
+ };
26
+
27
+ function createMulti (ml) {
28
+ return uki.map(ml, function(mlRow) { return createSingle(mlRow); });
29
+ }
30
+
31
+ function createSingle (mlRow) {
32
+ if (uki.isFunction(mlRow.typeName)) {
33
+ return mlRow;
34
+ }
35
+
36
+ var c = mlRow.view || mlRow.type,
37
+ result;
38
+ if (uki.isFunction(c)) {
39
+ result = c();
40
+ } else if (typeof c === 'string') {
41
+ var parts = c.split('.'),
42
+ obj = root;
43
+ if (!root[parts[0]] || parts[0] == 'Image') {
44
+ parts = ['uki', 'view'].concat(parts); // try with default prefix
45
+ }
46
+ for (var i=0; i < parts.length; i++) {
47
+ obj = obj[parts[i]];
48
+ };
49
+ if (!obj) throw 'No view of type ' + c + ' found';
50
+ result = new obj(mlRow.rect);
51
+ } else {
52
+ result = c;
53
+ }
54
+
55
+ copyAttrs(result, mlRow);
56
+ return result;
57
+ }
58
+
59
+ function copyAttrs(comp, mlRow) {
60
+ uki.each(mlRow, function(name, value) {
61
+ if (name == 'view' || name == 'type' || name == 'rect') return;
62
+ uki.attr(comp, name, value);
63
+ });
64
+ return comp;
65
+ }
66
+
67
+ uki.build.copyAttrs = copyAttrs;
68
+ })();