uki 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.gitmodules +3 -0
- data/LICENSE +20 -0
- data/Rakefile +23 -0
- data/Readme.rdoc +9 -0
- data/VERSION +1 -0
- data/bin/uki +102 -0
- data/frameworks/jspec/lib/images/bg.png +0 -0
- data/frameworks/jspec/lib/images/hr.png +0 -0
- data/frameworks/jspec/lib/images/loading.gif +0 -0
- data/frameworks/jspec/lib/images/sprites.bg.png +0 -0
- data/frameworks/jspec/lib/images/sprites.png +0 -0
- data/frameworks/jspec/lib/images/vr.png +0 -0
- data/frameworks/jspec/lib/jspec.css +149 -0
- data/frameworks/jspec/lib/jspec.growl.js +115 -0
- data/frameworks/jspec/lib/jspec.jquery.js +72 -0
- data/frameworks/jspec/lib/jspec.js +1756 -0
- data/frameworks/jspec/lib/jspec.shell.js +39 -0
- data/frameworks/jspec/lib/jspec.timers.js +90 -0
- data/frameworks/jspec/lib/jspec.xhr.js +195 -0
- data/frameworks/uki/README.rdoc +179 -0
- data/frameworks/uki/compiler.jar +0 -0
- data/frameworks/uki/run.rb +2 -0
- data/frameworks/uki/spec/commands/example_command.rb +19 -0
- data/frameworks/uki/spec/dom.html +39 -0
- data/frameworks/uki/spec/support/images/bg.png +0 -0
- data/frameworks/uki/spec/support/images/hr.png +0 -0
- data/frameworks/uki/spec/support/images/loading.gif +0 -0
- data/frameworks/uki/spec/support/images/sprites.bg.png +0 -0
- data/frameworks/uki/spec/support/images/sprites.png +0 -0
- data/frameworks/uki/spec/support/images/vr.png +0 -0
- data/frameworks/uki/spec/support/jspec.css +149 -0
- data/frameworks/uki/spec/support/jspec.js +1773 -0
- data/frameworks/uki/spec/support/jspec.xhr.js +193 -0
- data/frameworks/uki/spec/support/spec.helper.js +1 -0
- data/frameworks/uki/spec/unit/background.spec.js +29 -0
- data/frameworks/uki/spec/unit/builder.spec.js +51 -0
- data/frameworks/uki/spec/unit/data/model.spec.js +29 -0
- data/frameworks/uki/spec/unit/dom/dnd.spec.js +71 -0
- data/frameworks/uki/spec/unit/dom/event.spec.js +78 -0
- data/frameworks/uki/spec/unit/dom.spec.js +28 -0
- data/frameworks/uki/spec/unit/geometry.spec.js +79 -0
- data/frameworks/uki/spec/unit/selector.spec.js +140 -0
- data/frameworks/uki/spec/unit/theme/template.spec.js +31 -0
- data/frameworks/uki/spec/unit/utils.spec.js +176 -0
- data/frameworks/uki/spec/unit/view/base.spec.js +86 -0
- data/frameworks/uki/spec/unit/view/container.spec.js +73 -0
- data/frameworks/uki/spec/unit/view.spec.js +13 -0
- data/frameworks/uki/src/airport.js +1 -0
- data/frameworks/uki/src/uki-core/attachment.js +175 -0
- data/frameworks/uki/src/uki-core/background/css.js +37 -0
- data/frameworks/uki/src/uki-core/background/cssBox.js +73 -0
- data/frameworks/uki/src/uki-core/background/multi.js +20 -0
- data/frameworks/uki/src/uki-core/background/null.js +10 -0
- data/frameworks/uki/src/uki-core/background/rows.js +77 -0
- data/frameworks/uki/src/uki-core/background/sliced9.js +206 -0
- data/frameworks/uki/src/uki-core/background.js +35 -0
- data/frameworks/uki/src/uki-core/builder.js +68 -0
- data/frameworks/uki/src/uki-core/collection.js +278 -0
- data/frameworks/uki/src/uki-core/const.js +17 -0
- data/frameworks/uki/src/uki-core/dom/dnd.js +93 -0
- data/frameworks/uki/src/uki-core/dom/event.js +194 -0
- data/frameworks/uki/src/uki-core/dom/nativeLayout.js +18 -0
- data/frameworks/uki/src/uki-core/dom/offset.js +130 -0
- data/frameworks/uki/src/uki-core/dom/w3cdnd.js +333 -0
- data/frameworks/uki/src/uki-core/dom.js +109 -0
- data/frameworks/uki/src/uki-core/geometry.js +658 -0
- data/frameworks/uki/src/uki-core/image.js +90 -0
- data/frameworks/uki/src/uki-core/selector.js +201 -0
- data/frameworks/uki/src/uki-core/theme/base.js +39 -0
- data/frameworks/uki/src/uki-core/theme/template.js +26 -0
- data/frameworks/uki/src/uki-core/theme.js +45 -0
- data/frameworks/uki/src/uki-core/uki.js +45 -0
- data/frameworks/uki/src/uki-core/utils.js +399 -0
- data/frameworks/uki/src/uki-core/view/base.js +480 -0
- data/frameworks/uki/src/uki-core/view/container.js +155 -0
- data/frameworks/uki/src/uki-core/view/focusable.js +93 -0
- data/frameworks/uki/src/uki-core/view/observable.js +66 -0
- data/frameworks/uki/src/uki-core/view/styleable.js +70 -0
- data/frameworks/uki/src/uki-core/view/utils.js +66 -0
- data/frameworks/uki/src/uki-core/view.js +21 -0
- data/frameworks/uki/src/uki-core.js +36 -0
- data/frameworks/uki/src/uki-data/data.js +1 -0
- data/frameworks/uki/src/uki-data/model.js +28 -0
- data/frameworks/uki/src/uki-data/observable.js +34 -0
- data/frameworks/uki/src/uki-data.js +1 -0
- data/frameworks/uki/src/uki-more/more/utils.js +20 -0
- data/frameworks/uki/src/uki-more/more/view/listContainer.js +4 -0
- data/frameworks/uki/src/uki-more/more/view/multiselectList.js +196 -0
- data/frameworks/uki/src/uki-more/more/view/radioButton.js +27 -0
- data/frameworks/uki/src/uki-more/more/view/splitTable.js +79 -0
- data/frameworks/uki/src/uki-more/more/view/toggleButton.js +24 -0
- data/frameworks/uki/src/uki-more/more/view/treeList/render.js +53 -0
- data/frameworks/uki/src/uki-more/more/view/treeList.js +110 -0
- data/frameworks/uki/src/uki-more/more/view.js +2 -0
- data/frameworks/uki/src/uki-more/more.js +1 -0
- data/frameworks/uki/src/uki-more.js +4 -0
- data/frameworks/uki/src/uki-theamless.js +15 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/down-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/focusRing.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/hover.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/button/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/checkbox.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/checkbox/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/panel/dark.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/popup/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/radio/radio.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-c.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-h.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/shadow/large.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-m.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar-v.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/bar.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/slider/handle.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/horizontal.png +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/splitPane/vertical.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport/i/x.gif +0 -0
- data/frameworks/uki/src/uki-theme/airport.js +322 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/down.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/focusRing.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/button/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/checkbox/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/panel/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/popup/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/focus.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/radio/normal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-c.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-h.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/shadow/large.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-m.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar-v.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/bar.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/slider/handle.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/horizontal.png +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/splitPane/vertical.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo/i/x.gif +0 -0
- data/frameworks/uki/src/uki-theme/aristo.js +217 -0
- data/frameworks/uki/src/uki-view/view/box.js +1 -0
- data/frameworks/uki/src/uki-view/view/button.js +126 -0
- data/frameworks/uki/src/uki-view/view/checkbox.js +36 -0
- data/frameworks/uki/src/uki-view/view/flow.js +48 -0
- data/frameworks/uki/src/uki-view/view/image.js +9 -0
- data/frameworks/uki/src/uki-view/view/label.js +123 -0
- data/frameworks/uki/src/uki-view/view/list/render.js +23 -0
- data/frameworks/uki/src/uki-view/view/list.js +442 -0
- data/frameworks/uki/src/uki-view/view/popup.js +113 -0
- data/frameworks/uki/src/uki-view/view/radio.js +57 -0
- data/frameworks/uki/src/uki-view/view/scrollPane.js +139 -0
- data/frameworks/uki/src/uki-view/view/slider.js +154 -0
- data/frameworks/uki/src/uki-view/view/splitPane.js +213 -0
- data/frameworks/uki/src/uki-view/view/table/column.js +96 -0
- data/frameworks/uki/src/uki-view/view/table/header.js +53 -0
- data/frameworks/uki/src/uki-view/view/table/render.js +25 -0
- data/frameworks/uki/src/uki-view/view/table.js +71 -0
- data/frameworks/uki/src/uki-view/view/textField.js +145 -0
- data/frameworks/uki/src/uki-view/view/toolbar.js +93 -0
- data/frameworks/uki/src/uki-view.js +15 -0
- data/frameworks/uki/src/uki.js +2 -0
- data/frameworks/uki/thin.yaml +11 -0
- data/frameworks/uki/uki.rb +38 -0
- data/frameworks/uki/uki.ru +2 -0
- data/lib/uki/include_js.rb +50 -0
- data/lib/uki/project.rb +207 -0
- data/lib/uki/routes.rb +20 -0
- data/lib/uki/server.rb +42 -0
- data/lib/uki.rb +9 -0
- data/templates/index.html.erb +10 -0
- data/templates/model.js.erb +5 -0
- data/templates/myapp.js.erb +44 -0
- data/templates/package.js.erb +3 -0
- data/templates/spec.html.erb +23 -0
- data/templates/spec.js.erb +6 -0
- data/templates/view.js.erb +10 -0
- data/uki.gemspec +281 -0
- 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;
|