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,278 @@
1
+ include('uki.js');
2
+ include('attachment.js');
3
+ include('dom/event.js');
4
+
5
+ /**
6
+ * Collection performs group operations on uki.view objects.
7
+ * <p>Behaves much like result jQuery(dom nodes).
8
+ * Most methods are chainable like .attr('text', 'somevalue').bind('click', function() { ... })</p>
9
+ *
10
+ * <p>Its easier to call uki([view1, view2]) or uki('selector') instead of creating collection directly</p>
11
+ *
12
+ * @author voloko
13
+ * @constructor
14
+ * @class
15
+ */
16
+ uki.Collection = function( elems ) {
17
+ this.length = 0;
18
+ Array.prototype.push.apply( this, elems );
19
+ };
20
+
21
+ uki.fn = uki.Collection.prototype = new function() {
22
+ var proto = this;
23
+
24
+ /**#@+ @memberOf uki.Collection# */
25
+ /**
26
+ * Iterates trough all items within itself
27
+ *
28
+ * @function
29
+ *
30
+ * @param {function(this:uki.view.Base, number, uki.view.Base)} callback Callback to call for every item
31
+ * @returns {uki.view.Collection} self
32
+ */
33
+ this.each = function( callback ) {
34
+ uki.each( this, callback );
35
+ return this;
36
+ };
37
+
38
+ /**
39
+ * Creates a new uki.Collection populated with found items
40
+ *
41
+ * @function
42
+ *
43
+ * @param {function(uki.view.Base, number):boolean} callback Callback to call for every item
44
+ * @returns {uki.view.Collection} created collection
45
+ */
46
+ this.grep = function( callback ) {
47
+ return new uki.Collection( uki.grep(this, callback) );
48
+ };
49
+
50
+ /**
51
+ * Sets an attribute on all views or gets the value of the attribute on the first view
52
+ *
53
+ * @example
54
+ * c.attr('text', 'my text') // sets text to 'my text' on all collection views
55
+ * c.attr('name') // gets name attribute on the first view
56
+ *
57
+ * @function
58
+ *
59
+ * @param {string} name Name of the attribute
60
+ * @param {object=} value Value to set
61
+ * @returns {uki.view.Collection|Object} Self or attribute value
62
+ */
63
+ this.attr = function( name, value ) {
64
+ if (value !== undefined) {
65
+ this.each(function() {
66
+ uki.attr( this, name, value );
67
+ });
68
+ return this;
69
+ } else {
70
+ return this[0] ? uki.attr( this[0], name ) : '';
71
+ }
72
+ };
73
+
74
+ /**
75
+ * Finds views within collection context
76
+ * @example
77
+ * c.find('Button')
78
+ *
79
+ * @function
80
+ *
81
+ * @param {string} selector
82
+ * @returns {uki.view.Collection} Collection of found items
83
+ */
84
+ this.find = function( selector ) {
85
+ return uki.find( selector, this );
86
+ };
87
+
88
+ /**
89
+ * Attaches all child views to dom container
90
+ *
91
+ * @function
92
+ *
93
+ * @param {Element} dom Container dom element
94
+ * @param {uki.geometry.Rect} rect Default size
95
+ * @returns {uki.view.Collection} self
96
+ */
97
+ this.attachTo = function( dom, rect ) {
98
+ this.each(function() {
99
+ new uki.Attachment( dom, this, rect );
100
+ });
101
+ return this;
102
+ };
103
+
104
+ /**
105
+ * Appends views to the first item in collection
106
+ *
107
+ * @function
108
+ *
109
+ * @param {Array.<uki.view.Base>} views Views to append
110
+ * @returns {uki.view.Collection} self
111
+ */
112
+ this.append = function( views ) {
113
+ if (!this[0]) return this;
114
+ views = views.length !== undefined ? views : [views];
115
+ for (var i=0; i < views.length; i++) {
116
+ this[0].appendChild(views[i]);
117
+ };
118
+ return this;
119
+ };
120
+
121
+ this.appendTo = function( target ) {
122
+ target = uki(target)[0];
123
+ this.each(function() {
124
+ target.appendChild(this);
125
+ });
126
+ return this;
127
+ };
128
+
129
+ /**#@-*/
130
+
131
+ /**
132
+ * @function
133
+ */
134
+ uki.Collection.addAttrs = function(attrNames) {
135
+ uki.each(attrNames, function(i, name) {
136
+ proto[name] = function( value ) { return this.attr( name, value ); };
137
+ });
138
+ };
139
+
140
+ /** @function
141
+ @name uki.Collection#html */
142
+ /** @function
143
+ @name uki.Collection#text */
144
+ /** @function
145
+ @name uki.Collection#background */
146
+ /** @function
147
+ @name uki.Collection#value */
148
+ /** @function
149
+ @name uki.Collection#rect */
150
+ /** @function
151
+ @name uki.Collection#checked */
152
+ /** @function
153
+ @name uki.Collection#anchors */
154
+ /** @function
155
+ @name uki.Collection#childViews */
156
+ /** @function
157
+ @name uki.Collection#typeName */
158
+ /** @function
159
+ @name uki.Collection#id */
160
+ /** @function
161
+ @name uki.Collection#name */
162
+ /** @function
163
+ @name uki.Collection#visible */
164
+ /** @function
165
+ @name uki.Collection#disabled */
166
+ /** @function
167
+ @name uki.Collection#focusable */
168
+ /** @function
169
+ @name uki.Collection#style */
170
+ uki.Collection.addAttrs(('dom,html,text,background,value,rect,checked,anchors,' +
171
+ 'childViews,typeName,id,name,visible,disabled,focusable,style').split(','));
172
+
173
+ /** @function
174
+ @name uki.Collection#parent */
175
+ /** @function
176
+ @name uki.Collection#next */
177
+ /** @function
178
+ @name uki.Collection#prev */
179
+ uki.each([
180
+ ['parent', 'parent'],
181
+ ['next', 'nextView'],
182
+ ['prev', 'prevView']
183
+ ], function(i, desc) {
184
+ proto[desc[0]] = function() {
185
+ return new uki.Collection( uki.unique( uki.map(this, desc[1]) ) );
186
+ };
187
+ });
188
+
189
+
190
+ /** @function
191
+ @name uki.Collection#bind */
192
+ /** @function
193
+ @name uki.Collection#unload */
194
+ /** @function
195
+ @name uki.Collection#trigger */
196
+ /** @function
197
+ @name uki.Collection#layout */
198
+ /** @function
199
+ @name uki.Collection#appendChild */
200
+ /** @function
201
+ @name uki.Collection#removeChild */
202
+ /** @function
203
+ @name uki.Collection#insertBefore */
204
+ /** @function
205
+ @name uki.Collection#addRow */
206
+ /** @function
207
+ @name uki.Collection#removeRow */
208
+ /** @function
209
+ @name uki.Collection#resizeToContents */
210
+ /** @function
211
+ @name uki.Collection#toggle */
212
+ uki.each('bind unbind trigger layout appendChild removeChild insertBefore addRow removeRow resizeToContents toggle'.split(' '), function(i, name) {
213
+ proto[name] = function() {
214
+ for (var i=0; i < this.length; i++) {
215
+ this[i][name].apply(this[i], arguments);
216
+ };
217
+ return this;
218
+ };
219
+ });
220
+
221
+ /** @function
222
+ @name uki.Collection#blur */
223
+ /** @function
224
+ @name uki.Collection#focus */
225
+ /** @function
226
+ @name uki.Collection#load */
227
+ /** @function
228
+ @name uki.Collection#resize */
229
+ /** @function
230
+ @name uki.Collection#scroll */
231
+ /** @function
232
+ @name uki.Collection#unload */
233
+ /** @function
234
+ @name uki.Collection#click */
235
+ /** @function
236
+ @name uki.Collection#dblclick */
237
+ /** @function
238
+ @name uki.Collection#mousedown */
239
+ /** @function
240
+ @name uki.Collection#mouseup */
241
+ /** @function
242
+ @name uki.Collection#mousemove */
243
+ /** @function
244
+ @name uki.Collection#mouseover */
245
+ /** @function
246
+ @name uki.Collection#mouseout */
247
+ /** @function
248
+ @name uki.Collection#mouseenter */
249
+ /** @function
250
+ @name uki.Collection#mouseleave */
251
+ /** @function
252
+ @name uki.Collection#change */
253
+ /** @function
254
+ @name uki.Collection#select */
255
+ /** @function
256
+ @name uki.Collection#submit */
257
+ /** @function
258
+ @name uki.Collection#keydown */
259
+ /** @function
260
+ @name uki.Collection#keypress */
261
+ /** @function
262
+ @name uki.Collection#keyup */
263
+ /** @function
264
+ @name uki.Collection#error */
265
+ uki.each( uki.dom.events, function(i, name){
266
+ proto[name] = function( handler ){
267
+ if (handler) {
268
+ this.bind(name, handler);
269
+ } else {
270
+ for (var i=0; i < this.length; i++) {
271
+ this[i].trigger(name);
272
+ };
273
+ }
274
+ return this;
275
+ };
276
+ });
277
+ };
278
+
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Global uki constants, for speed optimization and better merging
3
+ */
4
+ /** @ignore */
5
+ var root = this,
6
+ doc = document,
7
+ nav = navigator,
8
+ ua = nav.userAgent,
9
+ expando = 'uki' + (+new Date),
10
+
11
+ MAX = Math.max,
12
+ MIN = Math.min,
13
+ FLOOR = Math.floor,
14
+ CEIL = Math.ceil,
15
+
16
+ PX = 'px';
17
+
@@ -0,0 +1,93 @@
1
+ include('event.js');
2
+
3
+
4
+ (function() {
5
+ /**
6
+ * Drag and Drop support for uki
7
+ * @namespace
8
+ */
9
+ var dnd = uki.dom.dnd = {
10
+ draggable: null,
11
+ nativeDnD: false,
12
+ position: null
13
+ };
14
+
15
+ // detect if native DnD is supported
16
+ try {
17
+ if (
18
+ // typeof doc.createElement('div').ondragstart == 'object' || // ie support
19
+ typeof doc.createEvent('MouseEvent').dataTransfer == 'object' || // safari
20
+ doc.createEvent('DragEvent').initDragEvent // w3c support
21
+ ) {
22
+ dnd.nativeDnD = true;
23
+ }
24
+ } catch (e) {}
25
+
26
+ // bind single drag set of drag events for an element
27
+ // regardless of the number of listeners
28
+ var bindDraggestures = {
29
+ setup: function() {
30
+ if (this.__draggesturebound) {
31
+ this.__draggesturebound++;
32
+ } else {
33
+ this.__draggesturebound = 1;
34
+ uki.dom.bind( this, 'mousedown', draggesturestart );
35
+ // prevent interference with ie drag events
36
+ if (!dnd.nativeDnD && typeof this.ondragstart == 'object')
37
+ this.ondragstart = function() { event.returnValue = false; };
38
+ }
39
+ },
40
+ teardown: function() {
41
+ this.__draggesturebound--;
42
+ if (!this.__draggesturebound) uki.dom.unbind( this, 'mousedown', draggesturestart );
43
+ }
44
+ };
45
+
46
+ // drag gestures
47
+ uki.extend(uki.dom.special, {
48
+ draggesturestart: bindDraggestures,
49
+ draggestureend: bindDraggestures,
50
+ draggesture: bindDraggestures
51
+ });
52
+
53
+ var dragEndEvents = 'mouseup ' + (dnd.nativeDnD ? ' dragend' : '');
54
+ // if (window.attachEvent && !window.opera) dragEndEvents += ' mouseleave';
55
+
56
+ function startGesture (el) {
57
+ dnd.draggable = el;
58
+ uki.dom.bind(doc, 'mousemove scroll', draggesture);
59
+ uki.dom.bind(doc, dragEndEvents, draggestureend);
60
+ uki.dom.bind(doc, 'selectstart mousedown', uki.dom.preventDefaultHandler);
61
+ }
62
+
63
+ function stopGesture () {
64
+ dnd.draggable = null;
65
+ uki.dom.unbind(doc, 'mousemove scroll', draggesture);
66
+ uki.dom.unbind(doc, dragEndEvents, draggestureend);
67
+ uki.dom.unbind(doc, 'selectstart mousedown', uki.dom.preventDefaultHandler);
68
+ }
69
+
70
+ function draggesturestart (e) {
71
+ e.type = 'draggesturestart';
72
+ uki.dom.handler.apply(this, arguments);
73
+ if (!e.isDefaultPrevented()) {
74
+ startGesture(this);
75
+ dnd.position = new Point(-e.pageX, -e.pageY);
76
+ }
77
+ }
78
+
79
+ function draggesture (e) {
80
+ e.type = 'draggesture';
81
+ e.dragOffset = (new Point(e.pageX, e.pageY)).offset(dnd.position);
82
+ uki.dom.handler.apply(dnd.draggable, arguments);
83
+ if (e.isDefaultPrevented()) stopGesture(dnd.draggable);
84
+ }
85
+
86
+ function draggestureend (e) {
87
+ e.type = 'draggestureend';
88
+ e.dragOffset = (new Point(e.pageX, e.pageY)).offset(dnd.position);
89
+ uki.dom.handler.apply(dnd.draggable, arguments);
90
+ stopGesture(dnd.draggable);
91
+ }
92
+
93
+ })();
@@ -0,0 +1,194 @@
1
+ uki.dom.special = {};
2
+
3
+ uki.dom.Event = function( domEvent ) {
4
+ domEvent = domEvent || {};
5
+ this.domEvent = domEvent.domEvent || domEvent;
6
+
7
+ for ( var i = uki.dom.props.length, prop; i; ){
8
+ prop = uki.dom.props[ --i ];
9
+ this[ prop ] = domEvent[ prop ];
10
+ }
11
+
12
+ // this.dataTransfer = new uki.dom.DataTransfer(domEvent);
13
+ };
14
+
15
+ uki.dom.Event.prototype = new function() {
16
+ function returnTrue () {
17
+ return true;
18
+ }
19
+
20
+ this.preventDefault = function() {
21
+ var domEvent = this.domEvent;
22
+ domEvent.preventDefault && domEvent.preventDefault();
23
+ domEvent.returnValue = false;
24
+
25
+ this.isDefaultPrevented = returnTrue;
26
+ }
27
+
28
+ this.stopPropagation = function() {
29
+ var domEvent = this.domEvent;
30
+ domEvent.stopPropagation && domEvent.stopPropagation();
31
+ domEvent.cancelBubble = true;
32
+
33
+ this.isPropagationStopped = returnTrue;
34
+ }
35
+
36
+ this.isDefaultPrevented = this.isPropagationStopped = uki.F;
37
+ }
38
+
39
+ uki.extend(uki.dom, /** @lends uki.dom */ {
40
+ bound: {},
41
+ handlers: {},
42
+
43
+ props: "type altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which dragOffset dataTransfer".split(" "),
44
+
45
+ events: "blur focus load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error draggesturestart draggestureend draggesture dragstart dragend drag drop dragenter dragleave dragover".split(" "),
46
+
47
+ bind: function(el, types, listener) {
48
+ if ( el.setInterval && el != window )
49
+ el = window;
50
+
51
+ listener.huid = listener.huid || uki.dom.guid++;
52
+
53
+ var id = el[expando] = el[expando] || uki.dom.guid++,
54
+ handler = uki.dom.handlers[id] = uki.dom.handlers[id] || function() {
55
+ uki.dom.handler.apply(arguments.callee.elem, arguments);
56
+ },
57
+ i, type;
58
+
59
+ handler.elem = el;
60
+
61
+ if (!uki.dom.bound[id]) uki.dom.bound[id] = {};
62
+
63
+ types = types.split(' ');
64
+ for (i=0; i < types.length; i++) {
65
+ type = types[i];
66
+ if (!uki.dom.bound[id][type]) {
67
+ uki.dom.bound[id][type] = [];
68
+ if ( !uki.dom.special[type] || uki.dom.special[type].setup.call(el) === false ) {
69
+ el.addEventListener ? el.addEventListener(type, handler, false) : el.attachEvent('on' + type, handler);
70
+ }
71
+ }
72
+ uki.dom.bound[id][type].push(listener);
73
+ };
74
+ listener = handler = el = null;
75
+ },
76
+
77
+ unbind: function(el, types, listener) {
78
+ var id = el[expando],
79
+ huid = listener.huid,
80
+ i, type;
81
+ types = types.split(' ');
82
+ for (i=0; i < types.length; i++) {
83
+ type = types[i];
84
+ if (!huid || !id || !uki.dom.bound[id] || !uki.dom.bound[id][type]) continue;
85
+ uki.dom.bound[id][type] = uki.grep(uki.dom.bound[id][type], function(h) { return h.huid !== huid; });
86
+
87
+ if (uki.dom.bound[id][type].length == 0) {
88
+ var handler = uki.dom.handlers[id];
89
+ if ( !uki.dom.special[type] || uki.dom.special[type].teardown.call(el) === false ) {
90
+ el.removeEventListener ? el.removeEventListener(type, handler, false) : el.detachEvent('on' + type, handler);
91
+ }
92
+ uki.dom.bound[id][type] = null;
93
+ }
94
+ }
95
+ },
96
+
97
+ /** @ignore */
98
+ handler: function( e ) {
99
+ e = e || root.event;
100
+
101
+ var type = e.type,
102
+ id = this[expando],
103
+ handlers = uki.dom.bound[id],
104
+ i;
105
+
106
+ e = new uki.dom.Event(e);
107
+ e = uki.dom.fix( e );
108
+
109
+ if (!id || !handlers || !handlers[type]) return;
110
+
111
+ for (i=0, handlers = handlers[type]; i < handlers.length; i++) {
112
+ handlers[i].call(this, e);
113
+ };
114
+ },
115
+
116
+ /**
117
+ * Taken from jQuery
118
+ * @ignore
119
+ */
120
+ fix: function( event ) {
121
+ // Fix target property, if necessary
122
+ if ( !event.target )
123
+ event.target = event.srcElement || doc;
124
+
125
+ // check if target is a textnode (safari)
126
+ if ( event.target.nodeType == 3 )
127
+ event.target = event.target.parentNode;
128
+
129
+ // Add relatedTarget, if necessary
130
+ if ( !event.relatedTarget && event.fromElement )
131
+ event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
132
+
133
+ // Calculate pageX/Y if missing and clientX/Y available
134
+ if ( event.pageX == null && event.clientX != null ) {
135
+ var de = doc.documentElement, body = doc.body;
136
+ event.pageX = event.clientX + (de && de.scrollLeft || body && body.scrollLeft || 0) - (de.clientLeft || 0);
137
+ event.pageY = event.clientY + (de && de.scrollTop || body && body.scrollTop || 0) - (de.clientTop || 0);
138
+ }
139
+
140
+ // Add which for key events
141
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
142
+ event.which = event.charCode || event.keyCode;
143
+
144
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
145
+ if ( !event.metaKey && event.ctrlKey )
146
+ try { event.metaKey = event.ctrlKey; } catch(e){};
147
+
148
+ // Add which for click: 1 == left; 2 == middle; 3 == right
149
+ // Note: button is not normalized, so don't use it
150
+ if ( !event.which && event.button )
151
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
152
+
153
+ return event;
154
+ },
155
+
156
+ preventDefaultHandler: function(e) {
157
+ e && e.preventDefault();
158
+ return false;
159
+ }
160
+ });
161
+
162
+ uki.each({
163
+ mouseover: 'mouseenter',
164
+ mouseout: 'mouseleave'
165
+ }, function( orig, fix ){
166
+ var handler = function(e) {
167
+ if (!uki.dom.contains(this, e.relatedTarget)) {
168
+ e.type = fix;
169
+ uki.dom.handler.apply(this, arguments);
170
+ }
171
+ };
172
+
173
+ uki.dom.special[ fix ] = {
174
+ setup: function() {
175
+ uki.dom.bind( this, orig, handler );
176
+ },
177
+ teardown: function(){
178
+ uki.dom.unbind( this, orig, handler );
179
+ }
180
+ };
181
+ });
182
+
183
+
184
+ if (root.attachEvent) {
185
+ root.attachEvent('onunload', function() {
186
+ uki.each(uki.dom.bound, function(id, types) {
187
+ uki.each(types, function(type, handlers) {
188
+ try {
189
+ uki.dom.handlers[id].elem.detachEvent('on' + type, uki.dom.handlers[id]);
190
+ } catch (e) {};
191
+ });
192
+ });
193
+ });
194
+ };
@@ -0,0 +1,18 @@
1
+ include('../dom.js');
2
+
3
+ uki.initNativeLayout = function() {
4
+ if (uki.supportNativeLayout === undefined) {
5
+ uki.dom.probe(
6
+ uki.createElement(
7
+ 'div',
8
+ 'position:absolute;width:100px;height:100px;left:-999em;',
9
+ '<div style="position:absolute;left:0;right:0"></div>'
10
+ ),
11
+ function(div) {
12
+ uki.supportNativeLayout = div.childNodes[0].offsetWidth == 100 && !root.opera;
13
+ }
14
+ );
15
+ }
16
+ };
17
+
18
+ // uki.supportNativeLayout = false;