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,79 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
uki.view.declare('uki.more.view.SplitTable', uki.view.Table, function(base) {
|
4
|
+
var Rect = uki.geometry.Rect;
|
5
|
+
|
6
|
+
|
7
|
+
this._defaultHandlePosition = 200;
|
8
|
+
|
9
|
+
this._createDom = function() {
|
10
|
+
Base._createDom.call(this);
|
11
|
+
var scrollWidth = uki.view.ScrollPane.initScrollWidth(),
|
12
|
+
bodyHeight = this.rect().height - this._headerHeight - scrollWidth,
|
13
|
+
contents = uki(
|
14
|
+
[
|
15
|
+
{
|
16
|
+
view: 'table.Header',
|
17
|
+
rect: new Rect(0, 0, this.rect().width, this._headerHeight),
|
18
|
+
anchors: 'top left right',
|
19
|
+
className: 'table-header'
|
20
|
+
},
|
21
|
+
{
|
22
|
+
view: 'ScrollPane',
|
23
|
+
rect: new Rect(0, this._headerHeight, this.rect().width, bodyHeight),
|
24
|
+
anchors: 'left top right bottom',
|
25
|
+
className: 'table-v-scroll',
|
26
|
+
childViews: [
|
27
|
+
{
|
28
|
+
view: 'SplitPane',
|
29
|
+
rect: new Rect(this.rect().width, bodyHeight),
|
30
|
+
anchors: 'left top',
|
31
|
+
handlePosition: this._defaultHandlePosition,
|
32
|
+
handleWidth: 1,
|
33
|
+
leftChildViews: [
|
34
|
+
{
|
35
|
+
view: 'List',
|
36
|
+
rect: new Rect(this._defaultHandlePosition, bodyHeight),
|
37
|
+
anchors: 'left top right bottom',
|
38
|
+
className: 'table-list-left'
|
39
|
+
}
|
40
|
+
],
|
41
|
+
rightChildViews: [
|
42
|
+
{
|
43
|
+
view: 'ScrollPane',
|
44
|
+
rect: new Rect(this.rect().width - this._defaultHandlePosition - 1, bodyHeight + scrollWidth),
|
45
|
+
scrollableV: false,
|
46
|
+
scrollableH: true,
|
47
|
+
anchors: 'left top right bottom',
|
48
|
+
className: 'table-h-scroll',
|
49
|
+
childViews: [
|
50
|
+
{
|
51
|
+
view: 'List',
|
52
|
+
rect: new Rect(this.rect().width - this._defaultHandlePosition - 1, bodyHeight + scrollWidth),
|
53
|
+
anchors: 'left top rect bottom'
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
},
|
61
|
+
{
|
62
|
+
view: 'ScrollPane',
|
63
|
+
rect: new Rect(this._defaultHandlePosition + 1, bodyHeight + this._headerHeight, this.rect().width - this._defaultHandlePosition - 1, scrollWidth),
|
64
|
+
anchors: 'left bottom right',
|
65
|
+
scrollableH: true,
|
66
|
+
scrollableV: false,
|
67
|
+
scrollH: true,
|
68
|
+
className: 'table-h-scroll-bar'
|
69
|
+
}
|
70
|
+
]).appendTo(this);
|
71
|
+
|
72
|
+
this._verticalScroll = uki('ScrollPane[className=table-v-scroll]', this)[0];
|
73
|
+
this._horizontalScroll = uki('ScrollPane[className=table-h-scroll]', this)[0];
|
74
|
+
this._horizontalScrollBar = uki('ScrollPane[className=table-h-scroll-bar]', this)[0];
|
75
|
+
this._leftList = uki('List:eq(0)', this)[0];
|
76
|
+
this._rightList = uki('List:eq(1)', this)[0];
|
77
|
+
this._splitPane = uki('SplitPane', this)[0];
|
78
|
+
};
|
79
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
uki.view.declare('uki.more.view.ToggleButton', uki.view.Button, function(Base) {
|
2
|
+
|
3
|
+
this._setup = function() {
|
4
|
+
Base._setup.call(this);
|
5
|
+
this._focusable = false;
|
6
|
+
};
|
7
|
+
|
8
|
+
this.value = this.checked = uki.newProp('_checked', function(state) {
|
9
|
+
this._checked = !!state;
|
10
|
+
this._updateBg();
|
11
|
+
});
|
12
|
+
|
13
|
+
this._updateBg = function() {
|
14
|
+
var name = this._disabled ? 'disabled' : this._down || this._checked ? 'down' : this._over ? 'hover' : 'normal';
|
15
|
+
this._backgroundByName(name);
|
16
|
+
};
|
17
|
+
|
18
|
+
this._mouseup = function(e) {
|
19
|
+
if (!this._down) return;
|
20
|
+
this._down = false;
|
21
|
+
if (!this._disabled) this.checked(!this.checked())
|
22
|
+
};
|
23
|
+
|
24
|
+
});
|
@@ -0,0 +1,53 @@
|
|
1
|
+
// tree list render
|
2
|
+
uki.more.view.treeList.Render = uki.newClass(uki.view.list.Render, new function() {
|
3
|
+
this._parentTemplate = new uki.theme.Template(
|
4
|
+
'<div class="${classPrefix}-row ${classPrefix}-${opened}" style="margin-left:${indent}px">' +
|
5
|
+
'<div class="${classPrefix}-toggle"><i class="toggle-tree"></i></div>${text}' +
|
6
|
+
'</div>'
|
7
|
+
);
|
8
|
+
|
9
|
+
this._leafTemplate = new uki.theme.Template(
|
10
|
+
'<div class="${classPrefix}-row" style="margin-left:${indent}px">${text}</div>'
|
11
|
+
);
|
12
|
+
|
13
|
+
this.initStyles = function() {
|
14
|
+
uki.more.view.treeList.Render.prototype.classPrefix = 'treeList-' + uki.dom.guid++;
|
15
|
+
var style = new uki.theme.Template(
|
16
|
+
'.${classPrefix}-row { color: #333; position:relative; padding-top:3px; } ' +
|
17
|
+
'.${classPrefix}-toggle { overflow: hidden; position:absolute; left:-15px; top:5px; width: 10px; height:9px; } ' +
|
18
|
+
'.${classPrefix}-toggle i { display: block; position:absolute; left: 0; top: 0; width:20px; height:18px; background: url(${imageSrc});} ' +
|
19
|
+
'.${classPrefix}-selected { background: #3875D7; } ' +
|
20
|
+
'.${classPrefix}-selected .${classPrefix}-row { color: #FFF; } ' +
|
21
|
+
'.${classPrefix}-selected i { left: -10px; } ' +
|
22
|
+
'.${classPrefix}-selected-blured { background: #CCCCCC; } ' +
|
23
|
+
'.${classPrefix}-opened i { top: -9px; }'
|
24
|
+
).render({
|
25
|
+
classPrefix: this.classPrefix,
|
26
|
+
imageSrc: 'i/arrows.png' // should call uki.image here
|
27
|
+
});
|
28
|
+
uki.dom.createStylesheet(style);
|
29
|
+
};
|
30
|
+
|
31
|
+
this.render = function(row, rect, i) {
|
32
|
+
this.classPrefix || this.initStyles();
|
33
|
+
var text = row.data;
|
34
|
+
if (row.children && row.children.length) {
|
35
|
+
return this._parentTemplate.render({
|
36
|
+
text: text,
|
37
|
+
indent: row.__indent*18 + 22,
|
38
|
+
classPrefix: this.classPrefix,
|
39
|
+
opened: row.__opened ? 'opened' : ''
|
40
|
+
});
|
41
|
+
} else {
|
42
|
+
return this._leafTemplate.render({
|
43
|
+
text: text,
|
44
|
+
indent: row.__indent*18 + 22,
|
45
|
+
classPrefix: this.classPrefix
|
46
|
+
});
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
this.setSelected = function(container, data, state, focus) {
|
51
|
+
container.className = !state ? '' : focus ? this.classPrefix + '-selected' : this.classPrefix + '-selected-blured';
|
52
|
+
};
|
53
|
+
});
|
@@ -0,0 +1,110 @@
|
|
1
|
+
include('../view.js');
|
2
|
+
|
3
|
+
// really basic tree list implementation
|
4
|
+
uki.more.view.treeList = {};
|
5
|
+
|
6
|
+
uki.more.view.TreeList = uki.newClass(uki.view.List, new function() {
|
7
|
+
var Base = uki.view.List.prototype,
|
8
|
+
proto = this;
|
9
|
+
|
10
|
+
proto.typeName = function() { return 'uki.more.view.TreeList'; };
|
11
|
+
|
12
|
+
proto._setup = function() {
|
13
|
+
Base._setup.call(this);
|
14
|
+
this._render = new uki.more.view.treeList.Render();
|
15
|
+
};
|
16
|
+
|
17
|
+
proto.listData = Base.data;
|
18
|
+
|
19
|
+
proto.data = uki.newProp('_treeData', function(v) {
|
20
|
+
this._treeData = v;
|
21
|
+
this.listData(this._treeNodeToListData(v));
|
22
|
+
});
|
23
|
+
|
24
|
+
proto._treeNodeToListData = function(node, indent) {
|
25
|
+
indent = indent || 0;
|
26
|
+
return uki.map(node, function(row) {
|
27
|
+
row.__indent = indent;
|
28
|
+
return row;
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
proto.toggle = function(index) {
|
33
|
+
this._data[index].__opened ? this.close(index) : this.open(index);
|
34
|
+
};
|
35
|
+
|
36
|
+
function recursiveLength (item) {
|
37
|
+
var children = item.children,
|
38
|
+
length = children.length;
|
39
|
+
|
40
|
+
for (var i=0; i < children.length; i++) {
|
41
|
+
if (children[i].__opened) length += recursiveLength(children[i]);
|
42
|
+
};
|
43
|
+
return length;
|
44
|
+
}
|
45
|
+
|
46
|
+
proto.open = function(index, _skipUpdate) {
|
47
|
+
var selectedIndex = this._selectedIndex,
|
48
|
+
item = this._data[index],
|
49
|
+
children = item.children;
|
50
|
+
|
51
|
+
if (!children || !children.length || (item.__opened && !_skipUpdate)) return 0;
|
52
|
+
var length = children.length;
|
53
|
+
|
54
|
+
item.__opened = true;
|
55
|
+
this._data.splice.apply(this._data, [index+1, 0].concat( this._treeNodeToListData(children, item.__indent + 1) ));
|
56
|
+
|
57
|
+
for (var i=children.length - 1; i >= 0 ; i--) {
|
58
|
+
if (this._data[index+1+i].__opened) {
|
59
|
+
length += this.open(index+1+i, true);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
if (!_skipUpdate) {
|
63
|
+
this.listData(this._data);
|
64
|
+
this.selectedIndex(selectedIndex <= index ? selectedIndex : selectedIndex + length);
|
65
|
+
}
|
66
|
+
return length;
|
67
|
+
};
|
68
|
+
|
69
|
+
proto.close = function(index) {
|
70
|
+
var selectedIndex = this._selectedIndex,
|
71
|
+
item = this._data[index],
|
72
|
+
children = item.children;
|
73
|
+
|
74
|
+
if (!children || !children.length || !item.__opened) return;
|
75
|
+
var length = recursiveLength(item);
|
76
|
+
|
77
|
+
item.__opened = false;
|
78
|
+
this._data.splice(index+1, length);
|
79
|
+
this.listData(this._data);
|
80
|
+
this.selectedIndex(
|
81
|
+
selectedIndex <= index ? selectedIndex :
|
82
|
+
selectedIndex >= index + length ? index - length :
|
83
|
+
index
|
84
|
+
);
|
85
|
+
};
|
86
|
+
|
87
|
+
proto._mousedown = function(e) {
|
88
|
+
if (e.domEvent.target.className.indexOf('toggle-tree') > -1) {
|
89
|
+
var o = uki.dom.offset(this._dom),
|
90
|
+
y = e.domEvent.pageY - o.y,
|
91
|
+
p = y / this._rowHeight << 0;
|
92
|
+
this.toggle(p);
|
93
|
+
} else {
|
94
|
+
Base._mousedown.call(this, e);
|
95
|
+
}
|
96
|
+
};
|
97
|
+
|
98
|
+
proto._keypress = function(e) {
|
99
|
+
Base._keypress.call(this, e);
|
100
|
+
e = e.domEvent;
|
101
|
+
if (e.which == 39 || e.keyCode == 39) { // RIGHT
|
102
|
+
this.open(this._selectedIndex);
|
103
|
+
} else if (e.which == 37 || e.keyCode == 37) { // LEFT
|
104
|
+
this.close(this._selectedIndex);
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
});
|
109
|
+
|
110
|
+
include('treeList/render.js');
|
@@ -0,0 +1 @@
|
|
1
|
+
uki.more = {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*!
|
2
|
+
* uki JavaScript Library
|
3
|
+
* Licensed under the MIT license http://ukijs.org/LICENSE
|
4
|
+
*
|
5
|
+
* Copyright (c) 2010 Vladimir Kolesnikov
|
6
|
+
*
|
7
|
+
* Parts of code derived from jQuery JavaScript Library
|
8
|
+
* Copyright (c) 2009 John Resig
|
9
|
+
*/
|
10
|
+
(function() {
|
11
|
+
|
12
|
+
include('uki-core.js');
|
13
|
+
include('uki-view.js');
|
14
|
+
|
15
|
+
}());
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|