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,90 @@
|
|
1
|
+
include('uki.js');
|
2
|
+
include('dom.js');
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Creates image element from url
|
6
|
+
*
|
7
|
+
* @param {string} url Image url
|
8
|
+
* @param {string=} dataUrl Data url representation of image, used if supported
|
9
|
+
* @param {string=} alphaUrl Gif image url for IE6
|
10
|
+
*
|
11
|
+
* @namespace
|
12
|
+
* @function
|
13
|
+
*
|
14
|
+
* @returns {Element}
|
15
|
+
*/
|
16
|
+
uki.image = function(url, dataUrl, alphaUrl) {
|
17
|
+
var result = new Image();
|
18
|
+
result.src = uki.imageSrc(url, dataUrl, alphaUrl);
|
19
|
+
return result;
|
20
|
+
};
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Selects image src depending on browser
|
24
|
+
*
|
25
|
+
* @param {string} url Image url
|
26
|
+
* @param {string=} dataUrl Data url representation of image, used if supported
|
27
|
+
* @param {string=} alphaUrl Gif image url for IE6
|
28
|
+
*
|
29
|
+
* @returns {string}
|
30
|
+
*/
|
31
|
+
uki.imageSrc = function(url, dataUrl, alphaUrl) {
|
32
|
+
if (uki.image.dataUrlSupported && dataUrl) return dataUrl;
|
33
|
+
if (alphaUrl && uki.image.needAlphaFix) return alphaUrl;
|
34
|
+
return url;
|
35
|
+
};
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Image html representation: '<img src="">'
|
39
|
+
*
|
40
|
+
* @param {string} url Image url
|
41
|
+
* @param {string=} dataUrl Data url representation of image, used if supported
|
42
|
+
* @param {boolean=} alphaUrl Gif image url for IE6
|
43
|
+
* @param {string=} html Additional html
|
44
|
+
*
|
45
|
+
* @returns {string} html
|
46
|
+
*/
|
47
|
+
uki.imageHTML = function(url, dataUrl, alphaUrl, html) {
|
48
|
+
if (uki.image.needAlphaFix && alphaUrl) {
|
49
|
+
url = alphaUrl;
|
50
|
+
} else if (uki.image.dataUrlSupported) {
|
51
|
+
url = dataUrl;
|
52
|
+
}
|
53
|
+
return '<img' + (html || '') + ' src="' + url + '" />';
|
54
|
+
};
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Loads given images, callbacks after all of them loads
|
58
|
+
*
|
59
|
+
* @param {Array.<Element>} images Images to load
|
60
|
+
* @param {function()} callback
|
61
|
+
*/
|
62
|
+
uki.image.load = function(images, callback) {
|
63
|
+
var imagesToLoad = images.length;
|
64
|
+
|
65
|
+
uki.each(images, function(i, img) {
|
66
|
+
if (!img || img.width) {
|
67
|
+
if (!--imagesToLoad) callback();
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
|
71
|
+
var handler = function() {
|
72
|
+
img.onload = img.onerror = img.onabort = null; // prevent memory leaks
|
73
|
+
if (!--imagesToLoad) callback();
|
74
|
+
};
|
75
|
+
img.onload = handler;
|
76
|
+
img.onerror = handler;
|
77
|
+
img.onabort = handler;
|
78
|
+
});
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* @type boolean
|
83
|
+
*/
|
84
|
+
uki.image.dataUrlSupported = doc.createElement('canvas').toDataURL || (/MSIE (8)/).test(ua);
|
85
|
+
|
86
|
+
/**
|
87
|
+
* @type boolean
|
88
|
+
*/
|
89
|
+
uki.image.needAlphaFix = /MSIE 6/.test(ua);
|
90
|
+
if(uki.image.needAlphaFix) doc.execCommand("BackgroundImageCache", false, true);
|
@@ -0,0 +1,201 @@
|
|
1
|
+
include('uki.js');
|
2
|
+
include('collection.js');
|
3
|
+
|
4
|
+
/* Ideas and code parts borrowed from Sizzle (http://sizzlejs.com/) */
|
5
|
+
(function() {
|
6
|
+
/**#@+ @ignore */
|
7
|
+
var self,
|
8
|
+
attr = uki.attr,
|
9
|
+
chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
10
|
+
regexps = [ // enforce order
|
11
|
+
{ name: 'ID', regexp: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/ },
|
12
|
+
{ name: 'ATTR', regexp: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/ },
|
13
|
+
{ name: 'TYPE', regexp: /^((?:[\w\u00c0-\uFFFF\*_\.-]|\\.)+)/ },
|
14
|
+
{ name: 'POS', regexp: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/ }
|
15
|
+
],
|
16
|
+
posRegexp = regexps.POS,
|
17
|
+
posFilters = {
|
18
|
+
first: function(i){
|
19
|
+
return i === 0;
|
20
|
+
},
|
21
|
+
last: function(i, match, array){
|
22
|
+
return i === array.length - 1;
|
23
|
+
},
|
24
|
+
even: function(i){
|
25
|
+
return i % 2 === 0;
|
26
|
+
},
|
27
|
+
odd: function(i){
|
28
|
+
return i % 2 === 1;
|
29
|
+
},
|
30
|
+
lt: function(i, match){
|
31
|
+
return i < match[2] - 0;
|
32
|
+
},
|
33
|
+
gt: function(i, match){
|
34
|
+
return i > match[2] - 0;
|
35
|
+
},
|
36
|
+
nth: function(i, match){
|
37
|
+
return match[2] - 0 == i;
|
38
|
+
},
|
39
|
+
eq: function(i, match){
|
40
|
+
return match[2] - 0 == i;
|
41
|
+
}
|
42
|
+
},
|
43
|
+
reducers = {
|
44
|
+
TYPE: function(comp, match) {
|
45
|
+
var expected = match[1];
|
46
|
+
if (expected == '*') return true;
|
47
|
+
var typeName = attr(comp, 'typeName');
|
48
|
+
return typeName && typeName.length >= expected.length &&
|
49
|
+
('.' + typeName).indexOf('.' + expected) == (typeName.length - expected.length);
|
50
|
+
},
|
51
|
+
|
52
|
+
ATTR: function(comp, match) {
|
53
|
+
var result = attr(comp, match[1]),
|
54
|
+
value = result + '',
|
55
|
+
type = match[2],
|
56
|
+
check = match[4];
|
57
|
+
|
58
|
+
return result == null ? type === "!=" :
|
59
|
+
type === "=" ? value === check :
|
60
|
+
type === "*=" ? value.indexOf(check) >= 0 :
|
61
|
+
type === "~=" ? (" " + value + " ").indexOf(check) >= 0 :
|
62
|
+
!check ? value && result !== false :
|
63
|
+
type === "!=" ? value != check :
|
64
|
+
type === "^=" ? value.indexOf(check) === 0 :
|
65
|
+
type === "$=" ? value.substr(value.length - check.length) === check :
|
66
|
+
false;
|
67
|
+
},
|
68
|
+
|
69
|
+
ID: function(comp, match) {
|
70
|
+
return reducers.ATTR(comp, ['', 'id', '=', '', match[1]]);
|
71
|
+
},
|
72
|
+
|
73
|
+
POS: function(comp, match, i, array) {
|
74
|
+
var filter = posFilters[match[1]];
|
75
|
+
return filter ? filter( i, match, array ) : false;
|
76
|
+
}
|
77
|
+
},
|
78
|
+
mappers = {
|
79
|
+
"+": function(context){
|
80
|
+
return uki.unique( uki.map(context, 'nextView') );
|
81
|
+
},
|
82
|
+
|
83
|
+
">": function(context){
|
84
|
+
return uki.unique( flatten(uki.map(context, 'childViews')) );
|
85
|
+
},
|
86
|
+
|
87
|
+
"": function(context) {
|
88
|
+
return uki.unique( recChildren(flatten(uki.map(context, 'childViews'))) );
|
89
|
+
},
|
90
|
+
|
91
|
+
"~": function(context){
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
function recChildren (comps) {
|
96
|
+
return flatten(uki.map(comps, function(comp) {
|
97
|
+
return [comp].concat( recChildren(attr(comp, 'childViews')) );
|
98
|
+
}));
|
99
|
+
}
|
100
|
+
|
101
|
+
function flatten (array) {
|
102
|
+
return uki.reduce( [], array, reduceFlatten );
|
103
|
+
}
|
104
|
+
|
105
|
+
function reduceFlatten (x, e) {
|
106
|
+
return x.concat(e);
|
107
|
+
}
|
108
|
+
/**#@-*/
|
109
|
+
|
110
|
+
self =
|
111
|
+
/**
|
112
|
+
* @namespace
|
113
|
+
*/
|
114
|
+
uki.Selector = {
|
115
|
+
/**
|
116
|
+
* Finds views by CSS3 selectors in view tree.
|
117
|
+
* <p>Can be called as uki(selector) instead of uki.Selector.find(selector)</p>
|
118
|
+
*
|
119
|
+
* @example
|
120
|
+
* uki('Label') find all labels on page
|
121
|
+
* uki('Box[name=main] > Label') find all immediate descendant Labels in a box with name = "main"
|
122
|
+
* uki('> Slider', context) find all direct descendant Sliders within given context
|
123
|
+
* uki('Slider,Checkbox') find all Sliders and Checkboxes
|
124
|
+
* uki('Slider:eq(3)') find 3-d slider
|
125
|
+
*
|
126
|
+
* @param {string} selector
|
127
|
+
* @param {Array.<uki.view.Base>} context to search in
|
128
|
+
*
|
129
|
+
* @return {uki.Collection} found views
|
130
|
+
*/
|
131
|
+
find: function(selector, context, skipFiltering) {
|
132
|
+
context = context || uki.top();
|
133
|
+
if (context.length === undefined) context = [context];
|
134
|
+
|
135
|
+
var tokens = self.tokenize(selector),
|
136
|
+
expr = tokens[0],
|
137
|
+
extra = tokens[1],
|
138
|
+
result = context,
|
139
|
+
mapper;
|
140
|
+
|
141
|
+
while (expr.length > 0) {
|
142
|
+
mapper = mappers[expr[0]] ? mappers[expr.shift()] : mappers[''];
|
143
|
+
result = mapper(result);
|
144
|
+
if (expr.length == 0) break;
|
145
|
+
result = self.reduce(expr.shift(), result);
|
146
|
+
}
|
147
|
+
|
148
|
+
if (extra) {
|
149
|
+
result = result.concat(self.find(extra, context, true));
|
150
|
+
}
|
151
|
+
|
152
|
+
return skipFiltering ? result : new uki.Collection(uki.unique(result));
|
153
|
+
},
|
154
|
+
|
155
|
+
/** @ignore */
|
156
|
+
reduce: function(exprItem, context) {
|
157
|
+
if (!context || !context.length) return [];
|
158
|
+
|
159
|
+
var match, found;
|
160
|
+
|
161
|
+
while (exprItem != '') {
|
162
|
+
found = false;
|
163
|
+
uki.each(regexps, function(index, row) {
|
164
|
+
|
165
|
+
/*jsl:ignore*/
|
166
|
+
if (match = exprItem.match(row.regexp)) {
|
167
|
+
/*jsl:end*/
|
168
|
+
found = true;
|
169
|
+
context = uki.grep(context, function(comp, index) {
|
170
|
+
return reducers[row.name](comp, match, index, context);
|
171
|
+
});
|
172
|
+
exprItem = exprItem.replace(row.regexp, '');
|
173
|
+
return false;
|
174
|
+
}
|
175
|
+
});
|
176
|
+
if (!found) break;
|
177
|
+
}
|
178
|
+
return context;
|
179
|
+
},
|
180
|
+
|
181
|
+
/** @ignore */
|
182
|
+
tokenize: function(expr) {
|
183
|
+
var parts = [], match, extra;
|
184
|
+
|
185
|
+
chunker.lastIndex = 0;
|
186
|
+
|
187
|
+
while ( (match = chunker.exec(expr)) !== null ) {
|
188
|
+
parts.push( match[1] );
|
189
|
+
|
190
|
+
if ( match[2] ) {
|
191
|
+
extra = RegExp.rightContext;
|
192
|
+
break;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
return [parts, extra];
|
197
|
+
}
|
198
|
+
};
|
199
|
+
|
200
|
+
uki.find = self.find;
|
201
|
+
})();
|
@@ -0,0 +1,39 @@
|
|
1
|
+
include('../theme.js');
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @class
|
5
|
+
*/
|
6
|
+
uki.theme.Base = {
|
7
|
+
images: [],
|
8
|
+
imageSrcs: [],
|
9
|
+
backgrounds: [],
|
10
|
+
doms: [],
|
11
|
+
styles: [],
|
12
|
+
templates: [],
|
13
|
+
|
14
|
+
background: function(name, params) {
|
15
|
+
return this.backgrounds[name] && this.backgrounds[name](params);
|
16
|
+
},
|
17
|
+
|
18
|
+
image: function(name, params) {
|
19
|
+
if (this.images[name]) return this.images[name](params);
|
20
|
+
return this.imageSrcs[name] && uki.image.apply(uki, this.imageSrcs[name](params));
|
21
|
+
},
|
22
|
+
|
23
|
+
imageSrc: function(name, params) {
|
24
|
+
if (this.imageSrcs[name]) return uki.imageSrc.apply(uki, this.imageSrcs[name](params));
|
25
|
+
return this.images[name] && this.images[name](params).src;
|
26
|
+
},
|
27
|
+
|
28
|
+
dom: function(name, params) {
|
29
|
+
return this.doms[name] && this.doms[name](params);
|
30
|
+
},
|
31
|
+
|
32
|
+
style: function(name, params) {
|
33
|
+
return this.styles[name] && this.styles[name](params);
|
34
|
+
},
|
35
|
+
|
36
|
+
template: function(name, params) {
|
37
|
+
return this.templates[name] && this.templates[name](params);
|
38
|
+
}
|
39
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
include('../theme.js');
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Simple and fast (2x–15x faster than regexp) html template
|
5
|
+
* @example
|
6
|
+
* var t = new uki.theme.Template('<p class="${className}">${value}</p>')
|
7
|
+
* t.render({className: 'myClass', value: 'some html'})
|
8
|
+
*/
|
9
|
+
uki.theme.Template = function(code) {
|
10
|
+
var parts = code.split('${'), i, l, tmp;
|
11
|
+
this.parts = [parts[0]];
|
12
|
+
this.names = [];
|
13
|
+
for (i=1, l = parts.length; i < l; i++) {
|
14
|
+
tmp = parts[i].split('}');
|
15
|
+
this.names.push(tmp.shift());
|
16
|
+
this.parts.push('');
|
17
|
+
this.parts.push(tmp.join('}'));
|
18
|
+
};
|
19
|
+
};
|
20
|
+
|
21
|
+
uki.theme.Template.prototype.render = function(values) {
|
22
|
+
for (var i=0, names = this.names, l = names.length; i < l; i++) {
|
23
|
+
this.parts[i*2+1] = values[names[i]] || '';
|
24
|
+
};
|
25
|
+
return this.parts.join('');
|
26
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
include('uki.js');
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @namespace
|
5
|
+
*/
|
6
|
+
uki.theme = {
|
7
|
+
themes: [],
|
8
|
+
|
9
|
+
register: function(theme) {
|
10
|
+
uki.theme.themes.push(theme);
|
11
|
+
},
|
12
|
+
|
13
|
+
background: function(name, params) {
|
14
|
+
return uki.theme._namedResource(name, 'background', params) || new uki.background.Null();
|
15
|
+
},
|
16
|
+
|
17
|
+
image: function(name, params) {
|
18
|
+
return uki.theme._namedResource(name, 'image', params) || new Image();
|
19
|
+
},
|
20
|
+
|
21
|
+
imageSrc: function(name, params) {
|
22
|
+
return uki.theme._namedResource(name, 'imageSrc', params) || '';
|
23
|
+
},
|
24
|
+
|
25
|
+
style: function(name, params) {
|
26
|
+
return uki.theme._namedResource(name, 'style', params) || '';
|
27
|
+
},
|
28
|
+
|
29
|
+
dom: function(name, params) {
|
30
|
+
return uki.theme._namedResource(name, 'dom', params) || uki.createElement('div');
|
31
|
+
},
|
32
|
+
|
33
|
+
template: function(name, params) {
|
34
|
+
return uki.theme._namedResource(name, 'template', params) || '';
|
35
|
+
},
|
36
|
+
|
37
|
+
_namedResource: function(name, type, params) {
|
38
|
+
for (var i = uki.theme.themes.length - 1; i >= 0; i--){
|
39
|
+
var result = uki.theme.themes[i][type](name, params);
|
40
|
+
if (result) return result;
|
41
|
+
};
|
42
|
+
return null;
|
43
|
+
|
44
|
+
}
|
45
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* Shortcut access to uki.build, uki.Selector.find and uki.Collection constructor
|
3
|
+
* uki('#id') is also a shortcut for search by id
|
4
|
+
*
|
5
|
+
* @param {String|uki.view.Base|Object|Array.<uki.view.Base>} val
|
6
|
+
* @param {Array.<uki.view.Base>=} optional context for selector
|
7
|
+
* @class
|
8
|
+
* @namespace
|
9
|
+
* @name uki
|
10
|
+
* @return {uki.Collection}
|
11
|
+
*/
|
12
|
+
root.uki = function(val, context) {
|
13
|
+
if (typeof val == 'string') {
|
14
|
+
var m = val.match(/^#((?:[\w\u00c0-\uFFFF_-]|\\.)+)$/),
|
15
|
+
e = m && uki._ids[m[1]];
|
16
|
+
if (m && !context) {
|
17
|
+
return new uki.Collection( e ? [e] : [] );
|
18
|
+
}
|
19
|
+
return uki.find(val, context);
|
20
|
+
}
|
21
|
+
if (val.length === undefined) val = [val];
|
22
|
+
if (val.length > 0 && uki.isFunction(val[0].typeName)) return new uki.Collection(val);
|
23
|
+
return uki.build(val);
|
24
|
+
};
|
25
|
+
|
26
|
+
/**
|
27
|
+
* @type string
|
28
|
+
* @field
|
29
|
+
*/
|
30
|
+
uki.version = '0.1.0.1';
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Empty function
|
34
|
+
* @type function():boolean
|
35
|
+
*/
|
36
|
+
uki.F = function() { return false; };
|
37
|
+
uki._ids = {};
|
38
|
+
|
39
|
+
uki.registerId = function(comp) {
|
40
|
+
uki._ids[uki.attr(comp, 'id')] = comp;
|
41
|
+
};
|
42
|
+
uki.unregisterId = function(comp) {
|
43
|
+
uki._ids[uki.attr(comp, 'id')] = undefined;
|
44
|
+
};
|
45
|
+
|