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,139 @@
|
|
1
|
+
(function() {
|
2
|
+
var scrollWidth, widthIncludesScrollBar;
|
3
|
+
|
4
|
+
function initScrollWidth () {
|
5
|
+
if (!scrollWidth) {
|
6
|
+
uki.dom.probe(
|
7
|
+
uki.createElement(
|
8
|
+
'div',
|
9
|
+
'position:absolute;left:-99em;width:100px;height:100px;overflow:scroll;',
|
10
|
+
'<div style="position:absolute;left:0;width:100%;"></div>'
|
11
|
+
),
|
12
|
+
function( probe ) {
|
13
|
+
scrollWidth = probe.offsetWidth - probe.clientWidth;
|
14
|
+
widthIncludesScrollBar = probe.firstChild.offsetWidth == 100;
|
15
|
+
}
|
16
|
+
);
|
17
|
+
}
|
18
|
+
return scrollWidth;
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Scroll pane. Pane with scrollbars with content overflowing the borders.
|
23
|
+
* Works consistently across all supported browsers.
|
24
|
+
*/
|
25
|
+
uki.view.declare('uki.view.ScrollPane', uki.view.Container, function(Base) {
|
26
|
+
this.typeName = function() {
|
27
|
+
return 'uki.view.ScrollPane';
|
28
|
+
};
|
29
|
+
|
30
|
+
this._setup = function() {
|
31
|
+
Base._setup.call(this);
|
32
|
+
|
33
|
+
uki.extend(this, {
|
34
|
+
_clientRect: this.rect().clone(), // rect with scroll bars excluded
|
35
|
+
_rectForChild: this.rect().clone(),
|
36
|
+
_scrollableV: true,
|
37
|
+
_scrollableH: false,
|
38
|
+
_scrollV: false,
|
39
|
+
_scrollH: false
|
40
|
+
});
|
41
|
+
};
|
42
|
+
|
43
|
+
uki.addProps(this, ['scrollableV', 'scrollableH']);
|
44
|
+
|
45
|
+
this.rectForChild = function() { return this._rectForChild; };
|
46
|
+
this.clientRect = function() { return this._clientRect; };
|
47
|
+
|
48
|
+
this.scroll = function(dx, dy) {
|
49
|
+
if (dx) this.scrollTop(this.scrollLeft() + dy);
|
50
|
+
if (dy) this.scrollTop(this.scrollTop() + dy);
|
51
|
+
};
|
52
|
+
|
53
|
+
uki.each(['appendChild', 'removeChild', 'insertBefore'], function(i, name) {
|
54
|
+
this[name] = function(arg1, arg2) {
|
55
|
+
return Base[name].call(this, arg1, arg2);
|
56
|
+
};
|
57
|
+
}, this);
|
58
|
+
|
59
|
+
uki.delegateProp(this, 'scrollTop', '_dom');
|
60
|
+
uki.delegateProp(this, 'scrollLeft', '_dom');
|
61
|
+
|
62
|
+
this.visibleRect = function() {
|
63
|
+
var tmpRect = this._clientRect.clone();
|
64
|
+
tmpRect.x = this.rect().x + this.scrollLeft();
|
65
|
+
tmpRect.y = this.rect().y + this.scrollTop();
|
66
|
+
return tmpRect;
|
67
|
+
};
|
68
|
+
|
69
|
+
this.rect = function(newRect) {
|
70
|
+
if (newRect === undefined) return this._rect;
|
71
|
+
|
72
|
+
newRect = Rect.create(newRect);
|
73
|
+
var oldRect = this._rect;
|
74
|
+
this._parentRect = newRect;
|
75
|
+
if (!this._resizeSelf(newRect)) return this;
|
76
|
+
this._updateClientRects();
|
77
|
+
this._needsLayout = true;
|
78
|
+
this.trigger('resize', {oldRect: oldRect, newRect: this._rect, source: this});
|
79
|
+
return this;
|
80
|
+
};
|
81
|
+
|
82
|
+
this._recalcClientRects = function() {
|
83
|
+
initScrollWidth();
|
84
|
+
|
85
|
+
var cw = this.contentsWidth(),
|
86
|
+
ch = this.contentsHeight(),
|
87
|
+
sh = this._scrollableH ? cw > this._rect.width : false,
|
88
|
+
sv = this._scrollableV ? ch > this._rect.height : false;
|
89
|
+
|
90
|
+
this._scrollH = sh;
|
91
|
+
this._scrollV = sv;
|
92
|
+
this._clientRect = new Rect( this._rect.width + (sv ? -1 : 0) * scrollWidth,
|
93
|
+
this._rect.height + (sh ? -1 : 0) * scrollWidth );
|
94
|
+
this._rectForChild = new Rect( this._rect.width + (sv && !widthIncludesScrollBar ? -1 : 0) * scrollWidth,
|
95
|
+
this._rect.height + (sh && !widthIncludesScrollBar ? -1 : 0) * scrollWidth );
|
96
|
+
};
|
97
|
+
|
98
|
+
this._updateClientRects = function() {
|
99
|
+
var oldClientRect = this._clientRect;
|
100
|
+
this._recalcClientRects();
|
101
|
+
|
102
|
+
if (oldClientRect.width != this._clientRect.width || oldClientRect.height != this._clientRect.height) {
|
103
|
+
this._resizeChildViews(oldClientRect);
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
this._resizeChildViews = function(oldClientRect) {
|
108
|
+
for (var i=0, childViews = this.childViews(); i < childViews.length; i++) {
|
109
|
+
childViews[i].parentResized(oldClientRect, this._clientRect);
|
110
|
+
};
|
111
|
+
};
|
112
|
+
|
113
|
+
this._layoutChildViews = function() {
|
114
|
+
for (var i=0, childViews = this.childViews(); i < childViews.length; i++) {
|
115
|
+
if (childViews[i]._needsLayout && childViews[i].visible()) {
|
116
|
+
childViews[i].layout();
|
117
|
+
}
|
118
|
+
};
|
119
|
+
};
|
120
|
+
|
121
|
+
this._layoutDom = function(rect) {
|
122
|
+
this._updateClientRects();
|
123
|
+
|
124
|
+
if (this._layoutScrollH !== this._scrollH) {
|
125
|
+
this._dom.style.overflowX = this._scrollH ? 'scroll' : 'hidden';
|
126
|
+
this._layoutScrollH = this._scrollH;
|
127
|
+
}
|
128
|
+
|
129
|
+
if (this._layoutScrollV !== this._scrollV) {
|
130
|
+
this._dom.style.overflowY = this._scrollV ? 'scroll' : 'hidden';
|
131
|
+
this._layoutScrollV = this._scrollV;
|
132
|
+
}
|
133
|
+
|
134
|
+
Base._layoutDom.call(this, rect);
|
135
|
+
};
|
136
|
+
});
|
137
|
+
|
138
|
+
uki.view.ScrollPane.initScrollWidth = initScrollWidth;
|
139
|
+
})();
|
@@ -0,0 +1,154 @@
|
|
1
|
+
uki.view.declare('uki.view.Slider', uki.view.Base, uki.view.Focusable, function(Base, Focusable) {
|
2
|
+
|
3
|
+
this._setup = function() {
|
4
|
+
Base._setup.call(this);
|
5
|
+
uki.extend(this, {
|
6
|
+
_min: 0,
|
7
|
+
_max: 1,
|
8
|
+
_value: 0,
|
9
|
+
_values: null,
|
10
|
+
_keyStep: 0.01
|
11
|
+
});
|
12
|
+
};
|
13
|
+
|
14
|
+
uki.addProps(this, ['min', 'max', 'values', 'keyStep']);
|
15
|
+
|
16
|
+
this.values = uki.newProp('_values', function(val) {
|
17
|
+
this._values = val;
|
18
|
+
this._min = val[0];
|
19
|
+
this._max = val[val.length - 1];
|
20
|
+
});
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @fires event:change
|
24
|
+
*/
|
25
|
+
this.value = uki.newProp('_value', function(val) {
|
26
|
+
this._value = MAX(this._min, MIN(this._max, val));
|
27
|
+
this._position = this._val2pos(this._value);
|
28
|
+
this._moveHandle();
|
29
|
+
this.trigger('change', {source: this, value: this._value});
|
30
|
+
});
|
31
|
+
|
32
|
+
this._pos2val = function(pos, cacheIndex) {
|
33
|
+
if (this._values) {
|
34
|
+
var index = Math.round(1.0 * pos / this._rect.width * (this._values.length - 1));
|
35
|
+
if (cacheIndex) this._cachedIndex = index;
|
36
|
+
return this._values[index];
|
37
|
+
}
|
38
|
+
return pos / this._rect.width * (this._max - this._min);
|
39
|
+
};
|
40
|
+
|
41
|
+
this._val2pos = function(val) {
|
42
|
+
if (this._values) {
|
43
|
+
var index = this._cachedIndex !== undefined ? this._cachedIndex : uki.binarySearch(val, this._values);
|
44
|
+
return index / (this._values.length - 1) * this._rect.width;
|
45
|
+
}
|
46
|
+
return val / (this._max - this._min) * this._rect.width;
|
47
|
+
};
|
48
|
+
|
49
|
+
this._createDom = function() {
|
50
|
+
this._dom = uki.createElement('div', Base.defaultCss + 'height:18px;-moz-user-select:none;-webkit-user-select:none;overflow:visible;');
|
51
|
+
this._handle = uki.createElement('div', Base.defaultCss + 'overflow:hidden;cursor:default;background:url(' + uki.theme.image('x').src + ')');
|
52
|
+
this._bg = uki.theme.image('slider-handle');
|
53
|
+
this._focusBg = uki.theme.image('slider-focus');
|
54
|
+
this._focusBg.style.cssText += this._bg.style.cssText += Base.defaultCss + 'top:0;left:0;z-index:-1;position:absolute;';
|
55
|
+
this._handle.appendChild(this._bg);
|
56
|
+
|
57
|
+
|
58
|
+
uki.theme.background('slider-bar').attachTo(this);
|
59
|
+
this._initFocusable();
|
60
|
+
|
61
|
+
uki.image.load([this._bg, this._focusBg], uki.proxy(this._afterHandleLoad, this) );
|
62
|
+
};
|
63
|
+
|
64
|
+
this._afterHandleLoad = function() {
|
65
|
+
this._focusBg.style.cssText += ';z-index:10;margin-left:-' + (this._focusBg.width) / 2 + 'px;margin-top:-' + (this._focusBg.height-(this._bg.height/2)+1)/2 + 'px;';
|
66
|
+
this._handle.style.cssText += ';margin-left:-' + (this._bg.width / 2) + 'px;width:' +this._bg.width + 'px;height:' + (this._bg.height / 2) + 'px;';
|
67
|
+
this._dom.appendChild(this._handle);
|
68
|
+
|
69
|
+
uki.each(['mouseenter', 'mouseleave', 'draggesturestart', 'draggesture', 'draggestureend'], function(i, name) {
|
70
|
+
uki.dom.bind(this._handle, name, uki.proxy(this['_' + name], this));
|
71
|
+
}, this);
|
72
|
+
|
73
|
+
this.bind('click', this._click);
|
74
|
+
this.bind('keydown', this._keydown);
|
75
|
+
};
|
76
|
+
|
77
|
+
this._mouseenter = function() {
|
78
|
+
this._over = true;
|
79
|
+
this._bg.style.top = - this._bg.height / 2 + 'px';
|
80
|
+
};
|
81
|
+
|
82
|
+
this._mouseleave = function() {
|
83
|
+
this._over = false;
|
84
|
+
this._bg.style.top = this._dragging ? (- this._bg.height / 2 + 'px') : 0;
|
85
|
+
};
|
86
|
+
|
87
|
+
this._click = function(e) {
|
88
|
+
var x = e.pageX - uki.dom.offset(this._dom).x;
|
89
|
+
this.value(this._pos2val(x, true));
|
90
|
+
this._cachedIndex = undefined;
|
91
|
+
};
|
92
|
+
|
93
|
+
this._keydown = function(e) {
|
94
|
+
if (e.which == 39) {
|
95
|
+
this.value(this.value() + this._keyStep * (this._max - this._min));
|
96
|
+
} else if (e.which == 37) {
|
97
|
+
this.value(this.value() - this._keyStep * (this._max - this._min));
|
98
|
+
}
|
99
|
+
};
|
100
|
+
|
101
|
+
this._moveHandle = function() {
|
102
|
+
// this._focusBg.style.left = this._handle.style.left = 100.0*this._position/this._rect.width + '%';
|
103
|
+
this._focusBg.style.left = this._handle.style.left = this._position + 'px';
|
104
|
+
};
|
105
|
+
|
106
|
+
this._draggesturestart = function(e) {
|
107
|
+
this._dragging = true;
|
108
|
+
this._initialPosition = new Point(parseInt(this._handle.style.left, 10), parseInt(this._handle.style.top, 10));
|
109
|
+
return true;
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* @fires event:change
|
114
|
+
*/
|
115
|
+
this._draggesture = function(e) {
|
116
|
+
var position = MAX(0, MIN(this._rect.width, this._initialPosition.x + e.dragOffset.x));
|
117
|
+
this.value(this._pos2val(position, true));
|
118
|
+
this._cachedIndex = undefined;
|
119
|
+
};
|
120
|
+
|
121
|
+
this._draggestureend = function(e) {
|
122
|
+
this._dragging = false;
|
123
|
+
this._initialPosition = null;
|
124
|
+
if (!this._over) this._bg.style.top = 0;
|
125
|
+
this.value(this._pos2val(this._position, true));
|
126
|
+
this._cachedIndex = undefined;
|
127
|
+
};
|
128
|
+
|
129
|
+
this._focus = function(e) {
|
130
|
+
this._dom.appendChild(this._focusBg);
|
131
|
+
this._focusBg.style.left = this._handle.style.left;
|
132
|
+
Focusable._focus.call(this, e);
|
133
|
+
};
|
134
|
+
|
135
|
+
this._blur = function(e) {
|
136
|
+
this._dom.removeChild(this._focusBg);
|
137
|
+
Focusable._blur.call(this, e);
|
138
|
+
};
|
139
|
+
|
140
|
+
this._layoutDom = function(rect) {
|
141
|
+
var fixedRect = rect.clone();
|
142
|
+
fixedRect.height = 18;
|
143
|
+
Base._layoutDom.call(this, fixedRect);
|
144
|
+
this._position = this._val2pos(this._value);
|
145
|
+
this._moveHandle();
|
146
|
+
return true;
|
147
|
+
};
|
148
|
+
|
149
|
+
this._bindToDom = function(name) {
|
150
|
+
if (name == 'change') return true;
|
151
|
+
return uki.view.Focusable._bindToDom.call(this, name) || Base._bindToDom.call(this, name);
|
152
|
+
};
|
153
|
+
|
154
|
+
});
|
@@ -0,0 +1,213 @@
|
|
1
|
+
uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
|
2
|
+
var proto = this;
|
3
|
+
|
4
|
+
proto._setup = function() {
|
5
|
+
Base._setup.call(this);
|
6
|
+
this._originalRect = this._rect;
|
7
|
+
uki.extend(this, {
|
8
|
+
_vertical: false,
|
9
|
+
_handlePosition: 200,
|
10
|
+
_autogrowLeft: false,
|
11
|
+
_autogrowRight: true,
|
12
|
+
_handleWidth: 7,
|
13
|
+
_leftMin: 100,
|
14
|
+
_rightMin: 100,
|
15
|
+
|
16
|
+
_panes: []
|
17
|
+
});
|
18
|
+
};
|
19
|
+
|
20
|
+
/**
|
21
|
+
* @fires event:handleMove
|
22
|
+
*/
|
23
|
+
proto.handlePosition = uki.newProp('_handlePosition', function(val) {
|
24
|
+
this._handlePosition = this._normalizePosition(val);
|
25
|
+
this.trigger('handleMove', {source: this, handlePosition: this._handlePosition, dragValue: val });
|
26
|
+
this._resizeChildViews();
|
27
|
+
});
|
28
|
+
|
29
|
+
proto.handleWidth = uki.newProp('_handleWidth', function(val) {
|
30
|
+
if (this._handleWidth != val) {
|
31
|
+
this._handleWidth = val;
|
32
|
+
var handle = this._createHandle();
|
33
|
+
this._dom.insertBefore(handle, this._handle);
|
34
|
+
this._removeHandle();
|
35
|
+
this._handle = handle;
|
36
|
+
this._resizeChildViews();
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
|
41
|
+
proto._normalizePosition = function(val) {
|
42
|
+
var prop = this._vertical ? 'height' : 'width';
|
43
|
+
return MAX(
|
44
|
+
this._leftMin,
|
45
|
+
MIN(
|
46
|
+
this._rect[prop] - this._rightMin - this._handleWidth,
|
47
|
+
MAX(0, MIN(this._rect ? this._rect[prop] : 1000, val * 1))
|
48
|
+
));
|
49
|
+
};
|
50
|
+
|
51
|
+
|
52
|
+
uki.addProps(proto, ['leftMin', 'rightMin', 'autogrowLeft', 'autogrowRight']);
|
53
|
+
proto.topMin = proto.leftMin;
|
54
|
+
proto.bottomMin = proto.rightMin;
|
55
|
+
|
56
|
+
proto._removeHandle = function() {
|
57
|
+
this._dom.removeChild(this._handle);
|
58
|
+
};
|
59
|
+
|
60
|
+
proto._createHandle = function() {
|
61
|
+
var handle;
|
62
|
+
if (this._vertical) {
|
63
|
+
handle = uki.theme.dom('splitPane-vertical', {handleWidth: this._handleWidth});
|
64
|
+
handle.style.top = this._handlePosition + PX;
|
65
|
+
} else {
|
66
|
+
handle = uki.theme.dom('splitPane-horizontal', {handleWidth: this._handleWidth});
|
67
|
+
handle.style.left = this._handlePosition + PX;
|
68
|
+
}
|
69
|
+
|
70
|
+
uki.each(['draggesturestart', 'draggesture', 'draggestureend'], function(i, name) {
|
71
|
+
uki.dom.bind(handle, name, uki.proxy(this['_' + name], this));
|
72
|
+
}, this);
|
73
|
+
|
74
|
+
return handle;
|
75
|
+
};
|
76
|
+
|
77
|
+
proto._createDom = function() {
|
78
|
+
this._dom = uki.createElement('div', Base.defaultCss);
|
79
|
+
for (var i=0, paneML; i < 2; i++) {
|
80
|
+
paneML = { view: 'Container' };
|
81
|
+
paneML.anchors = i == 1 ? 'left top bottom right' :
|
82
|
+
this._vertical ? 'left top right' :
|
83
|
+
'left top bottom';
|
84
|
+
paneML.rect = i == 0 ? this._leftRect() : this._rightRect();
|
85
|
+
this._panes[i] = uki.build(paneML)[0];
|
86
|
+
this.appendChild(this._panes[i]);
|
87
|
+
};
|
88
|
+
this._dom.appendChild(this._handle = this._createHandle());
|
89
|
+
};
|
90
|
+
|
91
|
+
proto._normalizeRect = function(rect) {
|
92
|
+
rect = Base._normalizeRect.call(this, rect);
|
93
|
+
var newRect = rect.clone();
|
94
|
+
if (this._vertical) {
|
95
|
+
newRect.height = MAX(newRect.height, this._leftMin + this._rightMin); // force min width
|
96
|
+
} else {
|
97
|
+
newRect.width = MAX(newRect.width, this._leftMin + this._rightMin); // force min width
|
98
|
+
}
|
99
|
+
return newRect;
|
100
|
+
};
|
101
|
+
|
102
|
+
proto._resizeSelf = function(newRect) {
|
103
|
+
var oldRect = this._rect,
|
104
|
+
dx, prop = this._vertical ? 'height' : 'width';
|
105
|
+
if (!Base._resizeSelf.call(this, newRect)) return false;
|
106
|
+
if (this._autogrowLeft) {
|
107
|
+
dx = newRect[prop] - oldRect[prop];
|
108
|
+
this._handlePosition = this._normalizePosition(this._handlePosition + (this._autogrowRight ? dx / 2 : dx));
|
109
|
+
}
|
110
|
+
if (this._vertical) {
|
111
|
+
if (newRect.height - this._handlePosition < this._rightMin) {
|
112
|
+
this._handlePosition = MAX(this._leftMin, newRect.height - this._rightMin);
|
113
|
+
}
|
114
|
+
} else {
|
115
|
+
if (newRect.width - this._handlePosition < this._rightMin) {
|
116
|
+
this._handlePosition = MAX(this._leftMin, newRect.width - this._rightMin);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return true;
|
120
|
+
};
|
121
|
+
|
122
|
+
proto._draggesturestart = function(e) {
|
123
|
+
var offset = uki.dom.offset(this.dom());
|
124
|
+
this._posWithinHandle = (e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x']) - this._handlePosition;
|
125
|
+
return true;
|
126
|
+
};
|
127
|
+
|
128
|
+
proto._draggesture = function(e) {
|
129
|
+
var offset = uki.dom.offset(this.dom());
|
130
|
+
this.handlePosition(e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x'] - this._posWithinHandle);
|
131
|
+
e.preventDefault();
|
132
|
+
this.layout();
|
133
|
+
};
|
134
|
+
|
135
|
+
proto._draggestureend = function(e, offset) {
|
136
|
+
};
|
137
|
+
|
138
|
+
proto.topPane = proto.leftPane = function(pane) {
|
139
|
+
return this._paneAt(0, pane);
|
140
|
+
};
|
141
|
+
|
142
|
+
proto.bottomPane = proto.rightPane = function(pane) {
|
143
|
+
return this._paneAt(1, pane);
|
144
|
+
};
|
145
|
+
|
146
|
+
proto.topChildViews = proto.leftChildViews = function(views) {
|
147
|
+
return this._childViewsAt(0, views);
|
148
|
+
};
|
149
|
+
|
150
|
+
proto.bottomChildViews = proto.rightChildViews = function(views) {
|
151
|
+
return this._childViewsAt(1, views);
|
152
|
+
};
|
153
|
+
|
154
|
+
proto._childViewsAt = function(i, views) {
|
155
|
+
if (views === undefined) return this._panes[i].childViews();
|
156
|
+
this._panes[i].childViews(views);
|
157
|
+
return this;
|
158
|
+
};
|
159
|
+
|
160
|
+
proto._paneAt = function(i, pane) {
|
161
|
+
if (pane === undefined) return this._panes[i];
|
162
|
+
uki.build.copyAttrs(this._panes[i], pane);
|
163
|
+
return this;
|
164
|
+
};
|
165
|
+
|
166
|
+
proto._leftRect = function() {
|
167
|
+
if (this._vertical) {
|
168
|
+
return new Rect(this._rect.width, this._handlePosition);
|
169
|
+
} else {
|
170
|
+
return new Rect(this._handlePosition, this._rect.height);
|
171
|
+
}
|
172
|
+
};
|
173
|
+
|
174
|
+
proto._rightRect = function() {
|
175
|
+
if (this._vertical) {
|
176
|
+
return new Rect(
|
177
|
+
0, this._handlePosition + this._handleWidth,
|
178
|
+
this._rect.width, this._rect.height - this._handleWidth - this._handlePosition
|
179
|
+
);
|
180
|
+
} else {
|
181
|
+
return new Rect(
|
182
|
+
this._handlePosition + this._handleWidth, 0,
|
183
|
+
this._rect.width - this._handleWidth - this._handlePosition, this._rect.height
|
184
|
+
);
|
185
|
+
}
|
186
|
+
};
|
187
|
+
|
188
|
+
proto._resizeChildViews = function() {
|
189
|
+
this._panes[0].rect(this._leftRect());
|
190
|
+
this._panes[1].rect(this._rightRect());
|
191
|
+
};
|
192
|
+
|
193
|
+
proto._layoutDom = function(rect) {
|
194
|
+
Base._layoutDom.call(this, rect);
|
195
|
+
this._handle.style[this._vertical ? 'top' : 'left'] = this._handlePosition + 'px';
|
196
|
+
};
|
197
|
+
|
198
|
+
proto._bindToDom = function(name) {
|
199
|
+
if (name == 'handleMove') return true;
|
200
|
+
return Base._bindToDom.call(this, name);
|
201
|
+
};
|
202
|
+
|
203
|
+
});
|
204
|
+
|
205
|
+
uki.view.declare('uki.view.VSplitPane', uki.view.HSplitPane, function(Base) {
|
206
|
+
this._setup = function() {
|
207
|
+
Base._setup.call(this);
|
208
|
+
this._vertical = true;
|
209
|
+
};
|
210
|
+
});
|
211
|
+
|
212
|
+
|
213
|
+
uki.Collection.addAttrs(['handlePosition']);
|
@@ -0,0 +1,96 @@
|
|
1
|
+
uki.view.table.Column = uki.newClass(uki.view.Observable, new function() {
|
2
|
+
var proto = this;
|
3
|
+
|
4
|
+
proto._width = 100;
|
5
|
+
proto._offset = 0;
|
6
|
+
proto._position = 0;
|
7
|
+
proto._minWidth = 40;
|
8
|
+
proto._css = 'overflow:hidden;float:left;font-size:11px;line-height:11px;white-space:nowrap;text-overflow:ellipsis;';
|
9
|
+
proto._inset = new Inset(3, 5);
|
10
|
+
|
11
|
+
proto.init = function() {};
|
12
|
+
|
13
|
+
uki.addProps(proto, ['position', 'css', 'formatter', 'label', 'resizable', 'maxWidth', 'minWidth']);
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @fires event:beforeResize
|
17
|
+
* @fires event:resize
|
18
|
+
*/
|
19
|
+
proto.width = uki.newProp('_width', function(w) {
|
20
|
+
this._width = this._normailizeWidth(w);
|
21
|
+
this.trigger('beforeResize', {source: this});
|
22
|
+
if (this._stylesheet) {
|
23
|
+
var rules = this._stylesheet.styleSheet ? this._stylesheet.styleSheet.rules : this._stylesheet.sheet.cssRules;
|
24
|
+
rules[0].style.width = this._clientWidth() + PX;
|
25
|
+
}
|
26
|
+
this.trigger('resize', {source: this});
|
27
|
+
});
|
28
|
+
|
29
|
+
proto._bindToDom = uki.F;
|
30
|
+
|
31
|
+
proto._normailizeWidth = function(w) {
|
32
|
+
if (this._maxWidth) w = MIN(this._maxWidth, w);
|
33
|
+
if (this._minWidth) w = MAX(this._minWidth, w);
|
34
|
+
return w;
|
35
|
+
};
|
36
|
+
|
37
|
+
proto.inset = uki.newProp('_inset', function(i) {
|
38
|
+
this._inset = Inset.create(i);
|
39
|
+
});
|
40
|
+
|
41
|
+
proto.render = function(row, rect, i) {
|
42
|
+
if (!this._template) this._template = this._buildTemplate(rect);
|
43
|
+
this._template[1] = this._formatter ? this._formatter(row[this._position], row) : row[this._position];
|
44
|
+
return this._template.join('')
|
45
|
+
};
|
46
|
+
|
47
|
+
proto.renderHeader = function(height) {
|
48
|
+
if (!this._headerTemplate) this._headerTemplate = this._buildHeaderTemplate(height);
|
49
|
+
var template = this._headerTemplate;
|
50
|
+
template[1] = this.label();
|
51
|
+
return template.join('');
|
52
|
+
};
|
53
|
+
|
54
|
+
proto._clientWidth = function() {
|
55
|
+
return this._width - (uki.dom.offset.boxModel ? this._inset.width() + 1 : 0);
|
56
|
+
};
|
57
|
+
|
58
|
+
proto._initStylesheet = function() {
|
59
|
+
uki.dom.offset.initializeBoxModel();
|
60
|
+
if (!this._className) {
|
61
|
+
this._className = 'uki-table-column-' + (++uki.dom.guid);
|
62
|
+
var css = '.' + this._className + ' {width:' + this._clientWidth() + 'px;}';
|
63
|
+
this._stylesheet = uki.dom.createStylesheet(css);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
proto._buildHeaderTemplate = function(headerHeight) {
|
68
|
+
this._initStylesheet();
|
69
|
+
var border = 'border:1px solid #CCC;border-top: none;border-left:none;',
|
70
|
+
inset = this._inset,
|
71
|
+
padding = ['padding:', inset.top, 'px ', inset.right, 'px ', inset.bottom, 'px ', inset.left, 'px;'].join(''),
|
72
|
+
height = 'height:' + (headerHeight - (uki.dom.offset.boxModel ? inset.height() + 1 : 0)) + 'px;',
|
73
|
+
tagOpening = ['<div style="position:relative;', border, padding, height, this._css, '" class="',this._className,'">'].join('');
|
74
|
+
|
75
|
+
return [tagOpening, '', '</div>'];
|
76
|
+
};
|
77
|
+
|
78
|
+
proto._buildTemplate = function(rect) {
|
79
|
+
this._initStylesheet();
|
80
|
+
var inset = this._inset,
|
81
|
+
border = 'border-right:1px solid #CCC;',
|
82
|
+
padding = ['padding:', inset.top, 'px ', inset.right, 'px ', inset.bottom, 'px ', inset.left, 'px;'].join(''),
|
83
|
+
height = 'height:' + (rect.height - (uki.dom.offset.boxModel ? inset.height() : 0)) + 'px;',
|
84
|
+
tagOpening = ['<div style="', border, padding, height, this._css, '" class="',this._className,'">'].join('');
|
85
|
+
return [tagOpening, '', '</div>'];
|
86
|
+
};
|
87
|
+
});
|
88
|
+
|
89
|
+
uki.view.table.NumberColumn = uki.newClass(uki.view.table.Column, new function() {
|
90
|
+
var Base = uki.view.table.Column.prototype,
|
91
|
+
proto = this;
|
92
|
+
|
93
|
+
proto._css = Base._css + 'text-align:right;';
|
94
|
+
});
|
95
|
+
|
96
|
+
uki.view.table.CustomColumn = uki.view.table.Column;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
include('../label.js');
|
2
|
+
|
3
|
+
uki.view.table.Header = uki.newClass(uki.view.Label, new function() {
|
4
|
+
var Base = uki.view.Label.prototype,
|
5
|
+
proto = this;
|
6
|
+
|
7
|
+
proto._setup = function() {
|
8
|
+
Base._setup.call(this);
|
9
|
+
this._multiline = true;
|
10
|
+
};
|
11
|
+
|
12
|
+
proto.typeName = function() { return 'uki.view.table.Header'; };
|
13
|
+
|
14
|
+
proto.columns = uki.newProp('_columns', function(v) {
|
15
|
+
this._columns = v;
|
16
|
+
this.html(this._createColumns());
|
17
|
+
this._createResizers();
|
18
|
+
});
|
19
|
+
|
20
|
+
proto._createColumns = function() {
|
21
|
+
var html = [];
|
22
|
+
for(var i = 0, offset = 0, columns = this._columns, l = columns.length; i < l; i++) {
|
23
|
+
html[html.length] = columns[i].renderHeader(this.rect().height);
|
24
|
+
}
|
25
|
+
return html.join('')
|
26
|
+
};
|
27
|
+
|
28
|
+
proto._createResizers = function() {
|
29
|
+
for (var i=0, column, resizer, offset = 0; i < this._columns.length; i++) {
|
30
|
+
column = this._columns[i];
|
31
|
+
if (column.resizable()) {
|
32
|
+
resizer = uki.theme.dom('resizer', {height: this.rect().height});
|
33
|
+
resizer.style.right = -2 + PX;
|
34
|
+
// resizer.style.background = 'red';
|
35
|
+
this._label.childNodes[i].appendChild(resizer);
|
36
|
+
this._bindResizerDrag(resizer, i);
|
37
|
+
}
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
proto._bindResizerDrag = function(resizer, columnIndex) {
|
42
|
+
uki.dom.bind(resizer, 'draggesture', uki.proxy(function(e) {
|
43
|
+
var headerOffset = uki.dom.offset(this.dom()),
|
44
|
+
offsetWithinHeader = e.pageX - headerOffset.x,
|
45
|
+
columnOffset = 0, i, column = this._columns[columnIndex];
|
46
|
+
for (i=0; i < columnIndex; i++) {
|
47
|
+
columnOffset += this._columns[i].width();
|
48
|
+
};
|
49
|
+
column.width(offsetWithinHeader - columnOffset);
|
50
|
+
}, this));
|
51
|
+
};
|
52
|
+
|
53
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
include('../list/render.js');
|
2
|
+
|
3
|
+
uki.view.table.Render = uki.newClass(uki.view.list.Render, new function() {
|
4
|
+
|
5
|
+
var proto = this;
|
6
|
+
|
7
|
+
proto.init = function(table) {
|
8
|
+
this._table = table;
|
9
|
+
};
|
10
|
+
|
11
|
+
proto.render = function(row, rect, i) {
|
12
|
+
if (!this._template) this._template = this._buildTemplate(rect);
|
13
|
+
var table = this._table,
|
14
|
+
columns = table.columns();
|
15
|
+
this._template[1] = uki.map(columns, function(val, j) {
|
16
|
+
return columns[j].render(row, rect, i);
|
17
|
+
}).join('');
|
18
|
+
return this._template.join('');
|
19
|
+
};
|
20
|
+
|
21
|
+
proto._buildTemplate = function(rect) {
|
22
|
+
var tagOpening = ['<div style="position:relwidth:100%;height:', rect.height, 'px">'].join(',');
|
23
|
+
return ['', '', '']
|
24
|
+
};
|
25
|
+
});
|