uki 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. data/VERSION +1 -1
  2. data/bin/uki +53 -2
  3. data/frameworks/uki/README.rdoc +49 -7
  4. data/frameworks/uki/spec/unit/data/model.spec.js +16 -5
  5. data/frameworks/uki/spec/unit/dom.spec.js +1 -1
  6. data/frameworks/uki/spec/unit/utils.spec.js +1 -1
  7. data/frameworks/uki/src/uki-core/background/sliced9.js +1 -1
  8. data/frameworks/uki/src/uki-core/collection.js +5 -5
  9. data/frameworks/uki/src/uki-core/dom/dnd.js +4 -0
  10. data/frameworks/uki/src/uki-core/dom/event.js +15 -8
  11. data/frameworks/uki/src/uki-core/dom/w3cdnd.js +18 -3
  12. data/frameworks/uki/src/uki-core/dom.js +1 -3
  13. data/frameworks/uki/src/uki-core/uki.js +2 -1
  14. data/frameworks/uki/src/uki-core/utils.js +2 -2
  15. data/frameworks/uki/src/uki-core/view/base.js +4 -3
  16. data/frameworks/uki/src/uki-core/view/focusable.js +61 -41
  17. data/frameworks/uki/src/uki-core/view/observable.js +3 -2
  18. data/frameworks/uki/src/uki-core/view/styleable.js +6 -6
  19. data/frameworks/uki/src/uki-data/model.js +83 -17
  20. data/frameworks/uki/src/uki-data/observable.js +8 -5
  21. data/frameworks/uki/src/uki-more/more/view/treeList/render.js +4 -3
  22. data/frameworks/uki/src/uki-more/more/view/treeList.js +18 -7
  23. data/frameworks/uki/src/uki-view/view/checkbox.js +2 -0
  24. data/frameworks/uki/src/uki-view/view/flow.js +28 -9
  25. data/frameworks/uki/src/uki-view/view/list.js +59 -16
  26. data/frameworks/uki/src/uki-view/view/radio.js +2 -1
  27. data/frameworks/uki/src/uki-view/view/scrollPane.js +5 -6
  28. data/frameworks/uki/src/uki-view/view/slider.js +4 -4
  29. data/frameworks/uki/src/uki-view/view/splitPane.js +26 -29
  30. data/frameworks/uki/src/uki-view/view/table/column.js +6 -5
  31. data/frameworks/uki/src/uki-view/view/table/header.js +28 -18
  32. data/frameworks/uki/src/uki-view/view/table.js +41 -2
  33. data/frameworks/uki/src/uki-view/view/textField.js +2 -3
  34. data/lib/uki/project.rb +55 -15
  35. data/templates/controller.js.erb +5 -0
  36. data/templates/layout.js.erb +5 -0
  37. data/templates/myapp.js.erb +1 -2
  38. data/uki.gemspec +4 -2
  39. metadata +5 -3
@@ -1,7 +1,5 @@
1
1
  uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
2
- var proto = this;
3
-
4
- proto._setup = function() {
2
+ this._setup = function() {
5
3
  Base._setup.call(this);
6
4
  this._originalRect = this._rect;
7
5
  uki.extend(this, {
@@ -20,13 +18,13 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
20
18
  /**
21
19
  * @fires event:handleMove
22
20
  */
23
- proto.handlePosition = uki.newProp('_handlePosition', function(val) {
21
+ this.handlePosition = uki.newProp('_handlePosition', function(val) {
24
22
  this._handlePosition = this._normalizePosition(val);
25
23
  this.trigger('handleMove', {source: this, handlePosition: this._handlePosition, dragValue: val });
26
24
  this._resizeChildViews();
27
25
  });
28
26
 
29
- proto.handleWidth = uki.newProp('_handleWidth', function(val) {
27
+ this.handleWidth = uki.newProp('_handleWidth', function(val) {
30
28
  if (this._handleWidth != val) {
31
29
  this._handleWidth = val;
32
30
  var handle = this._createHandle();
@@ -38,7 +36,7 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
38
36
  });
39
37
 
40
38
 
41
- proto._normalizePosition = function(val) {
39
+ this._normalizePosition = function(val) {
42
40
  var prop = this._vertical ? 'height' : 'width';
43
41
  return MAX(
44
42
  this._leftMin,
@@ -49,15 +47,15 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
49
47
  };
50
48
 
51
49
 
52
- uki.addProps(proto, ['leftMin', 'rightMin', 'autogrowLeft', 'autogrowRight']);
53
- proto.topMin = proto.leftMin;
54
- proto.bottomMin = proto.rightMin;
50
+ uki.addProps(this, ['leftMin', 'rightMin', 'autogrowLeft', 'autogrowRight']);
51
+ this.topMin = this.leftMin;
52
+ this.bottomMin = this.rightMin;
55
53
 
56
- proto._removeHandle = function() {
54
+ this._removeHandle = function() {
57
55
  this._dom.removeChild(this._handle);
58
56
  };
59
57
 
60
- proto._createHandle = function() {
58
+ this._createHandle = function() {
61
59
  var handle;
62
60
  if (this._vertical) {
63
61
  handle = uki.theme.dom('splitPane-vertical', {handleWidth: this._handleWidth});
@@ -74,7 +72,7 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
74
72
  return handle;
75
73
  };
76
74
 
77
- proto._createDom = function() {
75
+ this._createDom = function() {
78
76
  this._dom = uki.createElement('div', Base.defaultCss);
79
77
  for (var i=0, paneML; i < 2; i++) {
80
78
  paneML = { view: 'Container' };
@@ -88,7 +86,7 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
88
86
  this._dom.appendChild(this._handle = this._createHandle());
89
87
  };
90
88
 
91
- proto._normalizeRect = function(rect) {
89
+ this._normalizeRect = function(rect) {
92
90
  rect = Base._normalizeRect.call(this, rect);
93
91
  var newRect = rect.clone();
94
92
  if (this._vertical) {
@@ -99,7 +97,7 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
99
97
  return newRect;
100
98
  };
101
99
 
102
- proto._resizeSelf = function(newRect) {
100
+ this._resizeSelf = function(newRect) {
103
101
  var oldRect = this._rect,
104
102
  dx, prop = this._vertical ? 'height' : 'width';
105
103
  if (!Base._resizeSelf.call(this, newRect)) return false;
@@ -119,51 +117,50 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
119
117
  return true;
120
118
  };
121
119
 
122
- proto._draggesturestart = function(e) {
120
+ this._draggesturestart = function(e) {
123
121
  var offset = uki.dom.offset(this.dom());
124
122
  this._posWithinHandle = (e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x']) - this._handlePosition;
125
123
  return true;
126
124
  };
127
125
 
128
- proto._draggesture = function(e) {
126
+ this._draggesture = function(e) {
129
127
  var offset = uki.dom.offset(this.dom());
130
128
  this.handlePosition(e[this._vertical ? 'pageY' : 'pageX'] - offset[this._vertical ? 'y' : 'x'] - this._posWithinHandle);
131
- e.preventDefault();
132
129
  this.layout();
133
130
  };
134
131
 
135
- proto._draggestureend = function(e, offset) {
132
+ this._draggestureend = function(e, offset) {
136
133
  };
137
134
 
138
- proto.topPane = proto.leftPane = function(pane) {
135
+ this.topPane = this.leftPane = function(pane) {
139
136
  return this._paneAt(0, pane);
140
137
  };
141
138
 
142
- proto.bottomPane = proto.rightPane = function(pane) {
139
+ this.bottomPane = this.rightPane = function(pane) {
143
140
  return this._paneAt(1, pane);
144
141
  };
145
142
 
146
- proto.topChildViews = proto.leftChildViews = function(views) {
143
+ this.topChildViews = this.leftChildViews = function(views) {
147
144
  return this._childViewsAt(0, views);
148
145
  };
149
146
 
150
- proto.bottomChildViews = proto.rightChildViews = function(views) {
147
+ this.bottomChildViews = this.rightChildViews = function(views) {
151
148
  return this._childViewsAt(1, views);
152
149
  };
153
150
 
154
- proto._childViewsAt = function(i, views) {
151
+ this._childViewsAt = function(i, views) {
155
152
  if (views === undefined) return this._panes[i].childViews();
156
153
  this._panes[i].childViews(views);
157
154
  return this;
158
155
  };
159
156
 
160
- proto._paneAt = function(i, pane) {
157
+ this._paneAt = function(i, pane) {
161
158
  if (pane === undefined) return this._panes[i];
162
159
  uki.build.copyAttrs(this._panes[i], pane);
163
160
  return this;
164
161
  };
165
162
 
166
- proto._leftRect = function() {
163
+ this._leftRect = function() {
167
164
  if (this._vertical) {
168
165
  return new Rect(this._rect.width, this._handlePosition);
169
166
  } else {
@@ -171,7 +168,7 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
171
168
  }
172
169
  };
173
170
 
174
- proto._rightRect = function() {
171
+ this._rightRect = function() {
175
172
  if (this._vertical) {
176
173
  return new Rect(
177
174
  0, this._handlePosition + this._handleWidth,
@@ -185,17 +182,17 @@ uki.view.declare('uki.view.HSplitPane', uki.view.Container, function(Base) {
185
182
  }
186
183
  };
187
184
 
188
- proto._resizeChildViews = function() {
185
+ this._resizeChildViews = function() {
189
186
  this._panes[0].rect(this._leftRect());
190
187
  this._panes[1].rect(this._rightRect());
191
188
  };
192
189
 
193
- proto._layoutDom = function(rect) {
190
+ this._layoutDom = function(rect) {
194
191
  Base._layoutDom.call(this, rect);
195
192
  this._handle.style[this._vertical ? 'top' : 'left'] = this._handlePosition + 'px';
196
193
  };
197
194
 
198
- proto._bindToDom = function(name) {
195
+ this._bindToDom = function(name) {
199
196
  if (name == 'handleMove') return true;
200
197
  return Base._bindToDom.call(this, name);
201
198
  };
@@ -9,7 +9,7 @@ uki.view.table.Column = uki.newClass(uki.view.Observable, new function() {
9
9
 
10
10
  this.init = function() {};
11
11
 
12
- uki.addProps(this, ['position', 'css', 'formatter', 'label', 'resizable', 'maxWidth', 'minWidth', 'maxWidth']);
12
+ uki.addProps(this, ['position', 'css', 'formatter', 'label', 'resizable', 'maxWidth', 'minWidth', 'maxWidth', 'key']);
13
13
 
14
14
  this.template = function(v) {
15
15
  if (v === undefined) return this._template = this._template || uki.theme.template('table-cell');
@@ -56,7 +56,8 @@ uki.view.table.Column = uki.newClass(uki.view.Observable, new function() {
56
56
 
57
57
  this.render = function(row, rect, i) {
58
58
  this._prerenderedTemplate || this._prerenderTemplate(rect);
59
- this._prerenderedTemplate[1] = this._formatter ? this._formatter(row[this._position], row) : row[this._position];
59
+ var value = this._key ? uki.attr(row, this._key) : row[this._position];
60
+ this._prerenderedTemplate[1] = this._formatter ? this._formatter(value, row) : value;
60
61
  return this._prerenderedTemplate.join('');
61
62
  };
62
63
 
@@ -69,8 +70,8 @@ uki.view.table.Column = uki.newClass(uki.view.Observable, new function() {
69
70
  this.renderHeader = function(height) {
70
71
  this._className || this._initStylesheet();
71
72
  var x = this.headerTemplate().render({
72
- data: '<div style="overflow:hidden;text-overflow:ellipsis;">' + this.label() + '</div>',
73
- style: this._cellStyle(uki.dom.offset.boxModel ? height - 1 : height),
73
+ data: '<div style="overflow:hidden;text-overflow:ellipsis;*width:100%;height:100%;">' + this.label() + '</div>',
74
+ style: '*overflow-y:hidden;' + this._cellStyle(uki.dom.offset.boxModel ? height - 1 : height),
74
75
  className: this._className
75
76
  });
76
77
  return x;
@@ -102,7 +103,7 @@ uki.view.table.Column = uki.newClass(uki.view.Observable, new function() {
102
103
  this._initStylesheet = function() {
103
104
  if (!this._className) {
104
105
  uki.dom.offset.initializeBoxModel();
105
- this._className = 'uki-table-column-' + (++uki.dom.guid);
106
+ this._className = 'uki-table-column-' + (uki.guid++);
106
107
  var css = '.' + this._className + ' {width:' + this._clientWidth() + 'px;}';
107
108
  this._stylesheet = uki.dom.createStylesheet(css);
108
109
  }
@@ -1,23 +1,31 @@
1
1
  include('../label.js');
2
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() {
3
+ uki.view.table.Header = uki.newClass(uki.view.Label, function(Base) {
4
+ this._setup = function() {
8
5
  Base._setup.call(this);
9
6
  this._multiline = true;
7
+ this._resizers = [];
10
8
  };
11
9
 
12
- proto.typeName = function() { return 'uki.view.table.Header'; };
10
+ this.typeName = function() { return 'uki.view.table.Header'; };
13
11
 
14
- proto.columns = uki.newProp('_columns', function(v) {
12
+ this.columns = uki.newProp('_columns', function(v) {
15
13
  this._columns = v;
16
14
  this.html(this._createColumns());
17
15
  this._createResizers();
18
16
  });
19
17
 
20
- proto._createColumns = function() {
18
+ this.redrawColumn = function(col) {
19
+ if (this._resizers[col]) {
20
+ uki.dom.unbind(this._resizers[col]);
21
+ }
22
+ var container = doc.createElement('div');
23
+ container.innerHTML = this._columns[col].renderHeader(this.rect().height);
24
+ this._label.replaceChild(container.firstChild, this._label.childNodes[col]);
25
+ if (this._columns[col].resizable()) this._createResizers(col);
26
+ };
27
+
28
+ this._createColumns = function() {
21
29
  var html = [];
22
30
  for(var i = 0, offset = 0, columns = this._columns, l = columns.length; i < l; i++) {
23
31
  html[html.length] = columns[i].renderHeader(this.rect().height);
@@ -25,17 +33,20 @@ uki.view.table.Header = uki.newClass(uki.view.Label, new function() {
25
33
  return html.join('')
26
34
  };
27
35
 
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
- var resizer = column.appendResizer(this._label.childNodes[i], this.rect().height);
33
- this._bindResizerDrag(resizer, i);
34
- }
35
- };
36
+ this._createResizer = function(i) {
37
+ var column = this._columns[i];
38
+ if (column.resizable()) {
39
+ var resizer = column.appendResizer(this._label.childNodes[i], this.rect().height);
40
+ this._bindResizerDrag(resizer, i);
41
+ this._resizers[i] = resizer;
42
+ }
36
43
  };
37
44
 
38
- proto._bindResizerDrag = function(resizer, columnIndex) {
45
+ this._createResizers = function() {
46
+ uki.each(this._columns, this._createResizer, this);
47
+ };
48
+
49
+ this._bindResizerDrag = function(resizer, columnIndex) {
39
50
  uki.dom.bind(resizer, 'draggesture', uki.proxy(function(e) {
40
51
  var headerOffset = uki.dom.offset(this.dom()),
41
52
  offsetWithinHeader = e.pageX - headerOffset.x,
@@ -46,5 +57,4 @@ uki.view.table.Header = uki.newClass(uki.view.Label, new function() {
46
57
  column.width(offsetWithinHeader - columnOffset);
47
58
  }, this));
48
59
  };
49
-
50
60
  });
@@ -3,7 +3,7 @@ include('list.js');
3
3
  uki.view.table = {};
4
4
 
5
5
  uki.view.declare('uki.view.Table', uki.view.Container, function(Base) {
6
- var propertiesToDelegate = 'rowHeight data packSize visibleRectExt render selectedIndex focusable textSelectable multiselect'.split(' ');
6
+ var propertiesToDelegate = 'rowHeight data packSize visibleRectExt render selectedIndex selectedIndexes selectedRows focus blur hasFocus lastClickIndex focusable textSelectable multiselect'.split(' ');
7
7
 
8
8
  this._rowHeight = 17;
9
9
  this._headerHeight = 17;
@@ -22,6 +22,14 @@ uki.view.declare('uki.view.Table', uki.view.Container, function(Base) {
22
22
  return Base._style.call(this, name, value);
23
23
  };
24
24
 
25
+ this.list = function() {
26
+ return this._list;
27
+ };
28
+
29
+ this.header = function() {
30
+ return this._header;
31
+ };
32
+
25
33
  this.columns = uki.newProp('_columns', function(c) {
26
34
  for (var i = 0; i < this._columns.length; i++) {
27
35
  this._columns[i].unbind();
@@ -39,6 +47,37 @@ uki.view.declare('uki.view.Table', uki.view.Container, function(Base) {
39
47
  this._header.columns(this._columns);
40
48
  });
41
49
 
50
+ this.redrawCell = function(row, col) {
51
+ var item = this._list._itemAt(row);
52
+ if (item) {
53
+ var cell, container = doc.createElement('div');
54
+ container.innerHTML = this.columns()[col].render(
55
+ this.data()[row],
56
+ new Rect(0, row*this.rowHeight(), this.list().width(), this.rowHeight()),
57
+ row
58
+ );
59
+ cell = container.firstChild;
60
+ item.replaceChild(cell, item.childNodes[col]);
61
+ }
62
+ return this;
63
+ };
64
+
65
+ uki.each(['redrawRow', 'addRow', 'removeRow'], function(i, name) {
66
+ this[name] = function() {
67
+ this.list()[name].apply(this.list(), arguments);
68
+ return this;
69
+ };
70
+ }, this)
71
+
72
+ this.redrawColumn = function(col) {
73
+ var from = this._list._packs[0].itemFrom,
74
+ to = this._list._packs[1].itemTo
75
+ for (var i=from; i < to; i++) {
76
+ this.redrawCell(i, col);
77
+ };
78
+ return this;
79
+ };
80
+
42
81
  this._updateTotalWidth = function() {
43
82
  this._totalWidth = 0;
44
83
  for (var i=0; i < this._columns.length; i++) {
@@ -55,7 +94,7 @@ uki.view.declare('uki.view.Table', uki.view.Container, function(Base) {
55
94
  var scrollPaneRect = new Rect(0, this._headerHeight, this.rect().width, this.rect().height - this._headerHeight),
56
95
  listRect = scrollPaneRect.clone().normalize(),
57
96
  headerRect = new Rect(0, 0, this.rect().width, this._headerHeight),
58
- listML = { view: this._listImpl, rect: listRect, anchors: 'left top bottom', render: new uki.view.table.Render(this), className: 'table-list' },
97
+ listML = { view: this._listImpl, rect: listRect, anchors: 'left top bottom right', render: new uki.view.table.Render(this), className: 'table-list' },
59
98
  paneML = { view: 'ScrollPane', rect: scrollPaneRect, anchors: 'left top right bottom', scrollableH: true, childViews: [listML], className: 'table-scroll-pane'},
60
99
  headerML = { view: 'table.Header', rect: headerRect, anchors: 'top left right', className: 'table-header' };
61
100
 
@@ -48,7 +48,7 @@ uki.view.declare('uki.view.TextField', uki.view.Base, uki.view.Focusable, functi
48
48
  this._input.placeholder = v;
49
49
  } else {
50
50
  if (!this._placeholderDom) {
51
- this._placeholderDom = uki.createElement('div', this.defaultCss + 'z-input:103;color:#999;cursor:text', v);
51
+ this._placeholderDom = uki.createElement('div', this.defaultCss + 'z-input:103;color:#999;cursor:text;-moz-user-select:none;', v);
52
52
  this._dom.appendChild(this._placeholderDom);
53
53
  this._updatePlaceholderVis();
54
54
  uki.each(['fontSize', 'fontFamily', 'fontWeight'], function(i, name) {
@@ -83,7 +83,6 @@ uki.view.declare('uki.view.TextField', uki.view.Base, uki.view.Focusable, functi
83
83
  var tagName = this._multiline ? 'textarea' : 'input';
84
84
  this._dom = uki.createElement('div', Base.defaultCss + ';cursor:text;overflow:visible');
85
85
  this._input = uki.createElement(tagName, this.defaultCss + (this._multiline ? '' : ';overflow:hidden;'));
86
- this._inputStyle = this._input.style;
87
86
 
88
87
  this._input.value = this._value;
89
88
  this._dom.appendChild(this._input);
@@ -92,8 +91,8 @@ uki.view.declare('uki.view.TextField', uki.view.Base, uki.view.Focusable, functi
92
91
 
93
92
  this._initFocusable(this._input);
94
93
  this.bind('mousedown', function(e) {
94
+ if (e.target == this._input) return;
95
95
  this.focus();
96
- e.preventDefault();
97
96
  })
98
97
  };
99
98
 
data/lib/uki/project.rb CHANGED
@@ -3,6 +3,8 @@ require 'commander/import'
3
3
  require 'erb'
4
4
  require 'pathname'
5
5
  require 'uki/include_js'
6
+ require 'base64'
7
+ require 'digest/md5'
6
8
 
7
9
  class Uki::Project
8
10
  attr_accessor :dest
@@ -29,8 +31,8 @@ class Uki::Project
29
31
  init_target target
30
32
  containers = find_containers
31
33
  cjs = extract_cjs(containers)
32
- build_containers containers, target, options
33
34
  build_js cjs, target, options
35
+ build_containers containers, target, options
34
36
  build_images target, options
35
37
  end
36
38
 
@@ -40,13 +42,48 @@ class Uki::Project
40
42
  write_class template, path
41
43
  end
42
44
 
45
+ def create_function template, fullName
46
+ path = fullName.split('.')
47
+ create_packages path[0..-2]
48
+ write_function template, path
49
+ end
50
+
51
+ def ie_images target
52
+ contents = File.read(File.join(dest, target))
53
+ place = File.join(dest, 'tmp', 'theme')
54
+ # button-full/normal-v.png
55
+ contents.scan(%r{\[[^"]*"([^"]+)"[^"]+"data:image/png;base64,([^"]+)"[^"\]]*(?:"([^"]+)"[^"\]]*)?\]}) do
56
+ p $1
57
+ file = File.join(place, $1)
58
+ FileUtils.mkdir_p File.dirname(file)
59
+ File.open(file, 'w') do |f|
60
+ f.write Base64.decode64($2)
61
+ end
62
+ `convert #{File.join(place, $1)} #{File.join(place, $3)}` if $3
63
+ end
64
+ place
65
+ end
66
+
43
67
  protected
44
68
  def write_class template, path
45
69
  package_name = path[0..-2].join('.')
46
- class_name = path[-1]
47
- class_name = class_name[0,1].upcase + class_name[1..-1]
48
- file_name = class_name[0,1].downcase + class_name[1..-1]
49
- target = File.join *(path[0..-2] + [file_name])
70
+ class_name = path[-1]
71
+ class_name = class_name[0,1].upcase + class_name[1..-1]
72
+ file_name = class_name[0,1].downcase + class_name[1..-1]
73
+ target = File.join *(path[0..-2] + [file_name])
74
+ target += '.js'
75
+ File.open(File.join(dest, target), 'w') do |f|
76
+ f.write template(template).result(binding)
77
+ end
78
+ add_include(target)
79
+ end
80
+
81
+ def write_function template, path
82
+ package_name = path[0..-2].join('.')
83
+ function_name = path[-1]
84
+ function_name = function_name[0,1].downcase + function_name[1..-1]
85
+ file_name = function_name
86
+ target = File.join *(path[0..-2] + [file_name])
50
87
  target += '.js'
51
88
  File.open(File.join(dest, target), 'w') do |f|
52
89
  f.write template(template).result(binding)
@@ -98,8 +135,9 @@ class Uki::Project
98
135
 
99
136
  def build_containers containers, target, options
100
137
  containers.each do |c|
101
- code = File.read(c).gsub(%r{=\s*["']?([^"' ]+.cjs)}) do |match|
102
- match.sub('.cjs', '.js')
138
+ code = File.read(c).gsub(%r{=\s*["']?(([^"' ]+).cjs)}) do |match|
139
+ md5 = Digest::MD5.file(File.join(target, "#{$2}.js")).hexdigest
140
+ match.sub('.cjs', ".js?#{md5}")
103
141
  end
104
142
  File.open(File.join(target, File.basename(c)), 'w') do |f|
105
143
  f.write code
@@ -128,7 +166,7 @@ class Uki::Project
128
166
 
129
167
  def init_dest
130
168
  FileUtils.mkdir_p File.join(dest, project_name)
131
- ['view', 'model'].each do |name|
169
+ ['view', 'model', 'layout', 'controller'].each do |name|
132
170
  FileUtils.mkdir_p File.join(dest, project_name, name)
133
171
  end
134
172
  end
@@ -140,14 +178,16 @@ class Uki::Project
140
178
  File.open(File.join(dest, "#{project_name}.js"), 'w') do |f|
141
179
  f.write template('myapp.js').result(binding)
142
180
  end
143
- File.open(File.join(dest, project_name, 'view.js'), 'w') do |f|
144
- package_name = "#{project_name}.view"
145
- f.write template('package.js').result(binding)
146
- end
147
- File.open(File.join(dest, project_name, 'model.js'), 'w') do |f|
148
- package_name = "#{project_name}.model"
149
- f.write template('package.js').result(binding)
181
+
182
+ create_function 'layout.js', "#{project_name}.layout.main"
183
+
184
+ ['view', 'model', 'layout', 'controller'].each do |name|
185
+ File.open(File.join(dest, project_name, "#{name}.js"), 'w') do |f|
186
+ package_name = "#{project_name}.#{name}"
187
+ f.write template('package.js').result(binding)
188
+ end
150
189
  end
190
+
151
191
  end
152
192
 
153
193
  def project_name
@@ -0,0 +1,5 @@
1
+ <% if package_name %>include('../<%= package_name.sub(/.*\./, '') %>.js');<% end %>
2
+
3
+ <%= "#{package_name}." if package_name %><%= function_name %> = function() {
4
+
5
+ }
@@ -0,0 +1,5 @@
1
+ <% if package_name %>include('../<%= package_name.sub(/.*\./, '') %>.js');<% end %>
2
+
3
+ <%= "#{package_name}." if package_name %><%= function_name %> = function() {
4
+ return uki({ view: 'Button', rect: '100 20 100 22', anchors: '', text: 'Hello world!' });
5
+ }
@@ -34,8 +34,7 @@ uki.theme.airport.imagePath = 'i/';
34
34
  // skip interface creation if we're testing
35
35
  if (window.TESTING) return;
36
36
 
37
- uki({ view: 'Button', rect: '100 20 100 22', anchors: '', text: 'Hello world!' })
38
- .attachTo(window, '300 62');
37
+ <%= project_name %>.layout.main().attachTo(window, '300 62');
39
38
 
40
39
  uki('Button').click(function() {
41
40
  alert(this.text());
data/uki.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{uki}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vladimir Kolesnikov"]
12
- s.date = %q{2010-03-29}
12
+ s.date = %q{2010-04-05}
13
13
  s.default_executable = %q{uki}
14
14
  s.description = %q{Project creation, dev server, testing, building for uki apps}
15
15
  s.email = %q{voloko@gmail.com}
@@ -245,7 +245,9 @@ Gem::Specification.new do |s|
245
245
  "lib/uki/project.rb",
246
246
  "lib/uki/routes.rb",
247
247
  "lib/uki/server.rb",
248
+ "templates/controller.js.erb",
248
249
  "templates/index.html.erb",
250
+ "templates/layout.js.erb",
249
251
  "templates/model.js.erb",
250
252
  "templates/myapp.js.erb",
251
253
  "templates/package.js.erb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 2
9
+ version: 1.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Vladimir Kolesnikov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-29 00:00:00 +04:00
17
+ date: 2010-04-05 00:00:00 +04:00
18
18
  default_executable: uki
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -293,7 +293,9 @@ files:
293
293
  - lib/uki/project.rb
294
294
  - lib/uki/routes.rb
295
295
  - lib/uki/server.rb
296
+ - templates/controller.js.erb
296
297
  - templates/index.html.erb
298
+ - templates/layout.js.erb
297
299
  - templates/model.js.erb
298
300
  - templates/myapp.js.erb
299
301
  - templates/package.js.erb