sproutcore 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/History.txt +33 -0
  2. data/Manifest.txt +3 -14
  3. data/clients/sc_docs/controllers/docs.js +1 -0
  4. data/clients/sc_docs/core.js +1 -1
  5. data/clients/sc_test_runner/controllers/runner.js +5 -0
  6. data/clients/sc_test_runner/core.js +1 -1
  7. data/frameworks/sproutcore/english.lproj/core.css +41 -0
  8. data/frameworks/sproutcore/english.lproj/theme.css +20 -0
  9. data/frameworks/sproutcore/foundation/animator.js +11 -2
  10. data/frameworks/sproutcore/foundation/date.js +2 -2
  11. data/frameworks/sproutcore/foundation/object.js +2 -2
  12. data/frameworks/sproutcore/foundation/server.js +4 -3
  13. data/frameworks/sproutcore/foundation/set.js +1 -1
  14. data/frameworks/sproutcore/foundation/unittest.js +12 -9
  15. data/frameworks/sproutcore/lib/collection_view.rb +1 -0
  16. data/frameworks/sproutcore/lib/core_views.rb +4 -0
  17. data/frameworks/sproutcore/mixins/editable.js +144 -0
  18. data/frameworks/sproutcore/mixins/inline_editor_delegate.js +72 -0
  19. data/frameworks/sproutcore/mixins/observable.js +45 -16
  20. data/frameworks/sproutcore/mixins/scrollable.js +0 -1
  21. data/frameworks/sproutcore/tests/controllers/controller.rhtml +12 -12
  22. data/frameworks/sproutcore/tests/controllers/object.rhtml +2 -2
  23. data/frameworks/sproutcore/views/collection/collection.js +122 -68
  24. data/frameworks/sproutcore/views/collection/source_list.js +5 -0
  25. data/frameworks/sproutcore/views/field/text_field.js +7 -1
  26. data/frameworks/sproutcore/views/inline_text_field.js +397 -0
  27. data/frameworks/sproutcore/views/label.js +78 -68
  28. data/frameworks/sproutcore/views/list_item.js +184 -31
  29. data/frameworks/sproutcore/views/view.js +41 -9
  30. data/generators/client/templates/core.js +1 -1
  31. data/generators/client/templates/english.lproj/body.css +74 -0
  32. data/generators/framework/templates/core.js +1 -1
  33. data/lib/sproutcore/version.rb +1 -1
  34. metadata +5 -16
  35. data/clients/view_builder/builders/builder.js +0 -339
  36. data/clients/view_builder/builders/button.js +0 -81
  37. data/clients/view_builder/controllers/document.js +0 -21
  38. data/clients/view_builder/core.js +0 -19
  39. data/clients/view_builder/english.lproj/body.css +0 -77
  40. data/clients/view_builder/english.lproj/body.rhtml +0 -41
  41. data/clients/view_builder/english.lproj/controls.css +0 -0
  42. data/clients/view_builder/english.lproj/strings.js +0 -14
  43. data/clients/view_builder/main.js +0 -38
  44. data/clients/view_builder/tests/controllers/document.rhtml +0 -20
  45. data/clients/view_builder/tests/views/builder.rhtml +0 -20
  46. data/clients/view_builder/views/builder.js +0 -23
  47. data/frameworks/sproutcore/english.lproj/inline_text_editor.css +0 -21
  48. data/frameworks/sproutcore/views/inline_text_editor.js +0 -96
@@ -10,7 +10,7 @@
10
10
  //
11
11
  // You will use this most often when running unit tests in dev mode.
12
12
  //
13
- FIXTURES: [],
13
+ FIXTURES: []
14
14
 
15
15
  // Add any global constants or other properties used by the entire
16
16
  // framework:
@@ -2,7 +2,7 @@ module SproutCore #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sproutcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Jolley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-22 00:00:00 -07:00
12
+ date: 2008-04-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -106,18 +106,6 @@ files:
106
106
  - clients/sc_test_runner/models/test.js
107
107
  - clients/sc_test_runner/views/runner_frame.js
108
108
  - clients/sc_test_runner/views/test_label.js
109
- - clients/view_builder/builders/builder.js
110
- - clients/view_builder/builders/button.js
111
- - clients/view_builder/controllers/document.js
112
- - clients/view_builder/core.js
113
- - clients/view_builder/english.lproj/body.css
114
- - clients/view_builder/english.lproj/body.rhtml
115
- - clients/view_builder/english.lproj/controls.css
116
- - clients/view_builder/english.lproj/strings.js
117
- - clients/view_builder/main.js
118
- - clients/view_builder/tests/controllers/document.rhtml
119
- - clients/view_builder/tests/views/builder.rhtml
120
- - clients/view_builder/views/builder.js
121
109
  - config/hoe.rb
122
110
  - config/requirements.rb
123
111
  - frameworks/prototype/prototype.js
@@ -141,7 +129,6 @@ files:
141
129
  - frameworks/sproutcore/english.lproj/images/shared-icons.png
142
130
  - frameworks/sproutcore/english.lproj/images/sproutcore-logo.png
143
131
  - frameworks/sproutcore/english.lproj/images/sticky-note.png
144
- - frameworks/sproutcore/english.lproj/inline_text_editor.css
145
132
  - frameworks/sproutcore/english.lproj/menu.css
146
133
  - frameworks/sproutcore/english.lproj/panels/background-fat.jpg
147
134
  - frameworks/sproutcore/english.lproj/panels/background-thin.jpg
@@ -195,6 +182,8 @@ files:
195
182
  - frameworks/sproutcore/mixins/array.js
196
183
  - frameworks/sproutcore/mixins/control.js
197
184
  - frameworks/sproutcore/mixins/delegate_support.js
185
+ - frameworks/sproutcore/mixins/editable.js
186
+ - frameworks/sproutcore/mixins/inline_editor_delegate.js
198
187
  - frameworks/sproutcore/mixins/observable.js
199
188
  - frameworks/sproutcore/mixins/scrollable.js
200
189
  - frameworks/sproutcore/mixins/selection_support.js
@@ -266,7 +255,7 @@ files:
266
255
  - frameworks/sproutcore/views/filter_button.js
267
256
  - frameworks/sproutcore/views/form.js
268
257
  - frameworks/sproutcore/views/image.js
269
- - frameworks/sproutcore/views/inline_text_editor.js
258
+ - frameworks/sproutcore/views/inline_text_field.js
270
259
  - frameworks/sproutcore/views/label.js
271
260
  - frameworks/sproutcore/views/list_item.js
272
261
  - frameworks/sproutcore/views/menu_item.js
@@ -1,339 +0,0 @@
1
- // ==========================================================================
2
- // Basic View Builder
3
- // ==========================================================================
4
-
5
- /**
6
- A Builder can generate HTML, JavaScript and CSS based on a set of input
7
- attributes. It expects to have the following attributes defined:
8
-
9
- - targetClass: The name of the output class for JavaScript purposes.
10
- - name: the human readable name
11
- - guid: an internally unique id used to identify the resource.
12
-
13
- - htmlTemplate: the html template to render.
14
- - tagName: the tag name
15
- - htmlId: ID used for tag
16
- - cssClassNames: class names to add to tag.
17
- - attributes: { src: "item" } -- HTML attrs to include.
18
-
19
- - targetClass: name of output class.
20
- - key: name of object when added to parent.
21
- - properties: properties to place on JS object.
22
- - bind: named bindings. each binding is like:
23
- { to: path, kind: 'SC.Binding.Kind', isEnabled: YES }
24
-
25
- - children: Array of child view builder records, in order. If any.
26
- - parent: parent builder or null if top level.
27
- - inPage: YES if should be added to SC.page.
28
-
29
- You can add any other properties as well. Use them when your callbacks are
30
- invoked to enhance these properties before they are generated.
31
- */
32
- SC.Builder = SC.Record.extend({
33
-
34
- _targetClass: 'SC.Object',
35
-
36
- /**
37
- Defined by subclasses. If this is true, then the content of the view
38
- is the HTML generated by children.
39
- */
40
- isContainer: NO,
41
-
42
- /**
43
- Defined by subclasses. If true, then views will be generated with an
44
- outletFor() attached to them.
45
- */
46
- isOutletView: YES,
47
-
48
- childrenType: 'SC.Builder',
49
-
50
- parentType: 'SC.Builder',
51
-
52
- /**
53
- The default profile. New records will inherit a cloned set of these
54
- attributes.
55
- */
56
- defaultAttributes: {
57
- propertySettings: {},
58
- bindSettings: {},
59
- attributeSettings: {},
60
- htmlTemplate: '<{%TagName%}{%Attributes%}>{%Content%}</{%TagName%}>',
61
- cssClassNames: [],
62
- innerHtml: '',
63
- lazyOutlet: NO
64
- },
65
-
66
- init: function() {
67
- arguments.callee.base.apply(this) ;
68
- if (this.get('newRecord')) {
69
- var attrs = this._deepClone(this.get('defaultAttributes'));
70
- attrs.name = attrs.targetClass = this._targetClass ;
71
- attrs.guid = attrs.htmlId = 'id%@'.fmt(Date.now().toString());
72
- this.updateAttributes(attrs, YES, YES);
73
- }
74
- },
75
-
76
- /**
77
- Invoked just before the attributes are written out. You can add anything
78
- you want here.
79
- */
80
- prepareAttributes: function(attrs) {
81
- return attrs ;
82
- },
83
-
84
- /**
85
- Invoked just before the class name is set. Add anything you want here.
86
- */
87
- prepareClassNames: function(classNames) {
88
- return classNames ;
89
- },
90
-
91
- /**
92
- Invoked just before outlets are added and the final JS is generated. Add
93
- anything here you might pull from specialized preferences.
94
- */
95
- prepareProperties: function(props) { return props; },
96
-
97
- /**
98
- Invoked just before bindings are blended into properties. Add your own.
99
- */
100
- prepareBindings: function(binds) { return binds; },
101
-
102
- // ..........................................
103
- // HTML RENDERING
104
- //
105
-
106
- /**
107
- Computes the HTML for this builder. HTML is built by interpolating the
108
- htmlTemplate. Any variables must match a corresponding property on the
109
- record with 'html' added to the beginning.
110
- */
111
- htmlPart: function() {
112
- var template = this.get('htmlTemplate') ;
113
- if (!template) return null ;
114
-
115
- var that = this;
116
- return template.replace(/{%(.+?)%}/g,function(m,p) {
117
- return (p[0] == '%') ? p.slice(1,p.length) : that.get('html' + p) ;
118
- }) ;
119
- }.property('htmlTemplate', 'htmlContent', 'htmlTagName', 'htmlAttributes'),
120
-
121
- /**
122
- The tag name for the HTML. Usually specified by tagName in the
123
- attributes.
124
- */
125
- htmlTagName: function() {
126
- return this.get('tagName') || 'div';
127
- }.property('tagName'),
128
-
129
- /**
130
- The attributes for the HTML. Combines attributes hash, css classes,
131
- and id. It then calls prepareAttributes() so you can do any extra
132
- processing you need.
133
- */
134
- htmlAttributes: function() {
135
- // start with attributeSettings.
136
- var attrs = this._deepClone(this.get('attributeSettings')) || {} ;
137
-
138
- // add id
139
- attrs.id = this.get('htmlId') ;
140
-
141
- // merge in CSS class names
142
- var cssClassNames = this.get('cssClassNames') || [] ;
143
- if ($type(cssClassNames) === T_STRING) {
144
- cssClassNames = cssClassNames.split(' ') ;
145
- }
146
-
147
- var cur = attrs['class'] || [] ;
148
- if ($type(cur) === T_STRING) {
149
- cur = cur.split(' ') ;
150
- }
151
-
152
- cur = cur.concat(cssClassNames).uniq().compact().sort() ;
153
- cur.push(attrs.id) ;
154
- cur = this.prepareClassNames(cur) || cur;
155
- if (cur.length > 0) {
156
- attrs['class'] = cur.join(' ') ;
157
- } else delete attrs['class'] ;
158
-
159
- attrs = this.prepareAttributes(attrs) || attrs ;
160
-
161
- // now convert to a string.
162
- var ret = [''];
163
- for(var key in attrs) {
164
- if (!attrs.hasOwnProperty(key)) continue ;
165
- ret.push('%@="%@"'.fmt(key, attrs[key])) ;
166
- }
167
-
168
- return (ret.length > 1) ? ret.join(' ') : '';
169
- }.property('cssClassNames', 'attributeSettings', 'htmlId'),
170
-
171
- /**
172
- The inner content for the HTML. If isContainer is true, then we get
173
- the children for this view and use their HTML, otherwise get the
174
- innerHtml property.
175
- */
176
- htmlContent: function() {
177
- if (this.get('isContainer')) {
178
- var children = this.get('children') || [] ;
179
- var ret = [];
180
- for(var idx=0;idx<children.length;idx++) {
181
- var child = children.objectAt(idx) ;
182
- ret.push(child.get('htmlPart')) ;
183
- }
184
-
185
- return ret.join('') ;
186
- } else return this.get('innerHtml') ;
187
- }.property('innerHtml', 'isContainer', 'children'),
188
-
189
- // ..........................................
190
- // JAVASCRIPT RENDERING
191
- //
192
-
193
- /**
194
- Generates the JavaScript for this part.
195
-
196
- This works by merging the propertySettings and bindSettings. Then it
197
- calls your prepareProperties and finally merges in any outlets. With the
198
- properties combined, it then generates the code to build a view.
199
- */
200
- javascriptPart: function() {
201
- var props = this.get('javascriptProperties') ;
202
-
203
- var outlets = this.get('javascriptOutlets') ;
204
- for(var key in outlets) {
205
- if (!outlets.hasOwnProperty(key)) continue ;
206
- props[key] = outlets[key] ;
207
- }
208
-
209
- var outletDeclaration = '' ;
210
- var verb = 'create' ;
211
- if (this.get('isOutletView')) {
212
- verb = 'extend' ;
213
- outletDeclaration = '.outletFor(".%@?")'.fmt(this.get('htmlId'));
214
- }
215
-
216
- return '%@.%@(%@)%@'.fmt(this.get('targetClass'), verb, this._stringify(props), outletDeclaration) ;
217
- }.property(),
218
-
219
- /**
220
- Generates the properties for the JavaScript sans any outlets.
221
- */
222
- javascriptProperties: function() {
223
- var props = this._deepClone(this.get('propertySettings')) ;
224
- props = this.prepareProperties(props) || props ;
225
-
226
- var binds = this._deepClone(this.get('bindSettings')) ;
227
- binds = this.prepareBindings(binds) || binds ;
228
- for(var key in binds) {
229
- if (!binds.hasOwnProperty(key)) continue ;
230
-
231
- var bind = binds[key] ;
232
- if (!bind.isEnabled) continue ;
233
- bind = (bind.kind) ? "%@('%@')".fmt(bind.kind, bind.to) : "'%@'".fmt(bind.to) ;
234
- props[key + 'Binding'] = bind ;
235
- }
236
-
237
- return props ;
238
- }.property(),
239
-
240
- /**
241
- Generates the outlet properties for the JavaScript.
242
- */
243
- javascriptOutlets: function() {
244
- var ret = {} ;
245
- var outlets = [] ;
246
-
247
- // loop through children.
248
- var children = this.get('children') || [];
249
- var idx = children.length ;
250
- if (idx <= 0) return {} ;
251
- while(--idx >= 0) {
252
- var child = children.objectAt(idx) ;
253
- var outletName = child.get('outletName') ;
254
- var js = child.get('javascriptPart') ;
255
- ret[outletName] = js ;
256
- if (!child.get('lazyOutlet')) outlets.push(outletName) ;
257
- }
258
-
259
- ret.outlets = outletName ;
260
- return ret ;
261
- }.property(),
262
-
263
- outletName: function(key, value) {
264
- if (value !== undefined) this.writeAttribute('outletName', value) ;
265
- return this.readAttribute('outletName') || this.get('htmlId') ;
266
- }.property(),
267
-
268
- // ..........................................
269
- // INTERNAL METHODS
270
- //
271
-
272
- // deep clones a hash of properties. expects only Hash, Array or
273
- // primitives.
274
- _deepClone: function(obj) {
275
- var ret = obj ;
276
-
277
- switch($type(obj)) {
278
- case T_HASH:
279
- ret = {} ;
280
- for(var key in obj) {
281
- if (!obj.hasOwnProperty(key)) continue ;
282
- ret[key] = this._deepClone(obj[key]) ;
283
- }
284
- break ;
285
- case T_ARRAY:
286
- ret = [] ;
287
- for(var idx=0;idx < obj.length; idx++) {
288
- ret.push(this._deepClone(obj[idx])) ;
289
- }
290
- break ;
291
- }
292
- return ret ;
293
- },
294
-
295
- // converts the input object into a eval-able string
296
- _stringify: function(obj) {
297
- var ret = obj ;
298
- switch($type(obj)) {
299
- case T_HASH:
300
- ret = [] ;
301
- for(var key in obj) {
302
- if (!obj.hasOwnProperty(key)) continue ;
303
- ret.push([key, this._stringify(obj[key])].join(': ')) ;
304
- }
305
- ret = "{ %@ }".fmt(ret.join(",\n ")) ;
306
- break ;
307
-
308
- case T_ARRAY:
309
- ret = [] ;
310
- for(var idx=0; idx < obj.length; idx++) {
311
- ret.push(this._stringify(obj[idx])) ;
312
- }
313
- ret = '[%@]'.fmt(ret.join(', ')) ;
314
- break ;
315
-
316
- case T_NULL:
317
- ret = 'null' ;
318
- break ;
319
-
320
- // Strings can be either property paths or quoted strings. They are
321
- // quoted strings if they are in "quotes". If they are strings they
322
- // should be already quoted, etc.
323
- case T_STRING:
324
- ret = obj ;
325
- break ;
326
-
327
- default:
328
- ret = (obj.toString) ? obj.toString() : obj ;
329
- }
330
- return ret ;
331
- }
332
-
333
- }) ;
334
-
335
- SC.Builder.newBuilder = function(attrs) {
336
- if (!attrs) attrs = {} ;
337
- attrs.newRecord = YES ;
338
- return this.create(attrs) ;
339
- } ;
@@ -1,81 +0,0 @@
1
- // ==========================================================================
2
- // Button View Builder
3
- // ==========================================================================
4
-
5
- require('builders/builder') ;
6
-
7
- /**
8
- */
9
- SC.ButtonView.Builder = SC.Builder.extend({
10
-
11
- _targetClass: 'SC.ButtonView',
12
-
13
- /**
14
- Defined by subclasses. If this is true, then the content of the view
15
- is the HTML generated by children.
16
- */
17
- isContainer: NO,
18
-
19
- /**
20
- Defined by subclasses. If true, then views will be generated with an
21
- outletFor() attached to them.
22
- */
23
- isOutletView: YES,
24
-
25
- /**
26
- The default profile. New records will inherit a cloned set of these
27
- attributes.
28
- */
29
- defaultAttributes: {
30
- propertySettings: {},
31
- bindSettings: {},
32
- attributeSettings: {},
33
- htmlTemplate: '<{%TagName%}{%Attributes%}><span class="button-inner"><span class="label">{%Content%}</span></span></{%TagName%}>',
34
- cssClassNames: ['sc-button-view', 'regular', 'normal'],
35
- lazyOutlet: NO,
36
- tagName: 'a',
37
-
38
- title: 'Hello!'
39
- },
40
-
41
- init: function() {
42
- arguments.callee.base.apply(this) ;
43
- if (this.get('newRecord')) {
44
- var attrs = this._deepClone(this.get('defaultAttributes'));
45
- attrs.name = attrs.targetClass = this._targetClass ;
46
- attrs.guid = attrs.htmlId = 'id%@'.fmt(Date.now().toString());
47
- this.updateAttributes(attrs, YES, YES);
48
- }
49
- },
50
-
51
- /**
52
- Invoked just before the attributes are written out. You can add anything
53
- you want here.
54
- */
55
- prepareAttributes: function(attrs) {
56
- return attrs ;
57
- },
58
-
59
- /**
60
- Invoked just before the class name is set. Add anything you want here.
61
- */
62
- prepareClassNames: function(classNames) {
63
- return classNames ;
64
- },
65
-
66
- /**
67
- Invoked just before outlets are added and the final JS is generated. Add
68
- anything here you might pull from specialized preferences.
69
- */
70
- prepareProperties: function(props) { return props; },
71
-
72
- /**
73
- Invoked just before bindings are blended into properties. Add your own.
74
- */
75
- prepareBindings: function(binds) { return binds; },
76
-
77
- innerHtml: function() {
78
- return this.get('title') ;
79
- }.property('title')
80
-
81
- }) ;