sproutcore 0.9.4 → 0.9.5

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 (56) hide show
  1. data/History.txt +70 -2
  2. data/Manifest.txt +3 -15
  3. data/config/hoe.rb +1 -1
  4. data/frameworks/sproutcore/animation/animation.js +411 -0
  5. data/frameworks/sproutcore/controllers/array.js +68 -21
  6. data/frameworks/sproutcore/controllers/object.js +21 -2
  7. data/frameworks/sproutcore/drag/drag.js +13 -4
  8. data/frameworks/sproutcore/drag/drop_target.js +26 -19
  9. data/frameworks/sproutcore/english.lproj/core.css +4 -0
  10. data/frameworks/sproutcore/english.lproj/strings.js +5 -0
  11. data/frameworks/sproutcore/english.lproj/theme.css +5 -0
  12. data/frameworks/sproutcore/foundation/application.js +1 -2
  13. data/frameworks/sproutcore/foundation/set.js +31 -12
  14. data/frameworks/sproutcore/foundation/sorted_set.js +590 -0
  15. data/frameworks/sproutcore/foundation/string.js +43 -9
  16. data/frameworks/sproutcore/globals/window.js +34 -9
  17. data/frameworks/sproutcore/lib/button_views.rb +1 -0
  18. data/frameworks/sproutcore/lib/collection_view.rb +1 -0
  19. data/frameworks/sproutcore/lib/core_views.rb +3 -0
  20. data/frameworks/sproutcore/lib/index.rhtml +1 -1
  21. data/frameworks/sproutcore/mixins/collection_view_delegate.js +201 -0
  22. data/frameworks/sproutcore/mixins/observable.js +2 -7
  23. data/frameworks/sproutcore/models/record.js +1 -1
  24. data/frameworks/sproutcore/models/store.js +81 -28
  25. data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +9 -6
  26. data/frameworks/sproutcore/views/collection/collection.js +649 -211
  27. data/frameworks/sproutcore/views/collection/grid.js +62 -26
  28. data/frameworks/sproutcore/views/collection/list.js +57 -21
  29. data/frameworks/sproutcore/views/collection/source_list.js +61 -13
  30. data/frameworks/sproutcore/views/image.js +7 -0
  31. data/frameworks/sproutcore/views/inline_text_field.js +4 -5
  32. data/frameworks/sproutcore/views/slider.js +2 -0
  33. data/frameworks/sproutcore/views/view.js +2 -2
  34. data/lib/sproutcore/build_tools/html_builder.rb +4 -6
  35. data/lib/sproutcore/build_tools/resource_builder.rb +32 -20
  36. data/lib/sproutcore/bundle.rb +130 -32
  37. data/lib/sproutcore/bundle_manifest.rb +24 -21
  38. data/lib/sproutcore/helpers/static_helper.rb +22 -9
  39. data/lib/sproutcore/merb/bundle_controller.rb +4 -3
  40. data/lib/sproutcore/version.rb +1 -1
  41. metadata +14 -17
  42. data/clients/view_builder/builders/builder.js +0 -339
  43. data/clients/view_builder/builders/button.js +0 -81
  44. data/clients/view_builder/controllers/document.js +0 -21
  45. data/clients/view_builder/core.js +0 -19
  46. data/clients/view_builder/english.lproj/body.css +0 -77
  47. data/clients/view_builder/english.lproj/body.rhtml +0 -39
  48. data/clients/view_builder/english.lproj/controls.css +0 -0
  49. data/clients/view_builder/english.lproj/strings.js +0 -14
  50. data/clients/view_builder/main.js +0 -38
  51. data/clients/view_builder/mixins/design_mode.js +0 -92
  52. data/clients/view_builder/tests/controllers/document.rhtml +0 -20
  53. data/clients/view_builder/tests/views/builder.rhtml +0 -20
  54. data/clients/view_builder/tests/views/palette.rhtml +0 -21
  55. data/clients/view_builder/views/builder.js +0 -26
  56. data/clients/view_builder/views/palette.js +0 -30
@@ -7,12 +7,13 @@ module SproutCore
7
7
 
8
8
  module StaticHelper
9
9
 
10
- # This method will return the HTML to link to all the stylesheets required
11
- # by the named bundle. If you pass no options, the current client will be
12
- # used.
10
+ # This method will return the HTML to link to all the stylesheets
11
+ # required by the named bundle. If you pass no options, the current
12
+ # client will be used.
13
13
  #
14
- # bundle_name = the name of the bundle to render or nil to use the current
15
- # :language => the language to render. defaults to current language
14
+ # bundle_name = the name of the bundle to render or nil to use the
15
+ # current :language => the language to render. defaults to current
16
+ # language
16
17
  #
17
18
  def stylesheets_for_client(bundle_name = nil, opts = {})
18
19
 
@@ -38,11 +39,12 @@ module SproutCore
38
39
  urls.join("\n")
39
40
  end
40
41
 
41
- # This method will return the HTML to link to all the javascripts required
42
- # by the client. If you pass no options, the current client will be used.
42
+ # This method will return the HTML to link to all the javascripts
43
+ # required by the client. If you pass no options, the current client
44
+ # will be used.
43
45
  #
44
- # client_name = the name of the client to render or nil to use the current
45
- # :language => the language to render. defaults to @language.
46
+ # client_name = the name of the client to render or nil to use the
47
+ # current :language => the language to render. defaults to @language.
46
48
  #
47
49
  def javascripts_for_client(bundle_name = nil, opts = {})
48
50
 
@@ -65,6 +67,10 @@ module SproutCore
65
67
  urls = urls.map do |url|
66
68
  %( <script type="text/javascript" src="#{url}"></script>)
67
69
  end
70
+
71
+ # Add preferred language definition...
72
+ urls << %(<script type="text/javascript">String.preferredLanguage = "#{language}";</script>)
73
+
68
74
  urls.join("\n")
69
75
  end
70
76
 
@@ -74,6 +80,13 @@ module SproutCore
74
80
  entry = bundle.find_resource_entry(resource_name, opts)
75
81
  entry.nil? ? '' : entry.url
76
82
  end
83
+
84
+ # Localizes the passed string, using the optional passed options.
85
+ def loc(string, opts = {})
86
+ opts[:language] ||= language
87
+ bundle.strings_hash(opts)[string] || string
88
+ end
89
+
77
90
  end
78
91
 
79
92
  end
@@ -70,13 +70,14 @@ module SproutCore
70
70
 
71
71
  # Get the entry for the resource.
72
72
  entry = current_bundle.entry_for_url(url, :hidden => :include)
73
- raise(NotFound, "No matching entry in #{current_bundle.bundle_name}") if entry.nil?
73
+ raise(NotFound, "No matching entry in #{current_bundle.bundle_name} for #{url}") if entry.nil?
74
74
 
75
75
 
76
76
  build_path = entry.build_path
77
77
 
78
- # Found an entry, build the resource. If the resource has already been built, this
79
- # will not do much. If this the resource is an index.html file, force the build.
78
+ # Found an entry, build the resource. If the resource has already
79
+ # been built, this will not do much. If this the resource is an
80
+ # index.html file, force the build.
80
81
  is_index = /\/index\.html$/ =~ url
81
82
 
82
83
  current_bundle.build_entry(entry, :force => is_index, :hidden => :include)
@@ -2,7 +2,7 @@ module SproutCore #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 4
5
+ TINY = 5
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.4
4
+ version: 0.9.5
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-05-05 00:00:00 -07:00
12
+ date: 2008-05-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,6 +48,15 @@ dependencies:
48
48
  - !ruby/object:Gem::Version
49
49
  version: "0"
50
50
  version:
51
+ - !ruby/object:Gem::Dependency
52
+ name: mongrel
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
51
60
  description: SproutCore - JavaScript Application Framework + Build Tools
52
61
  email:
53
62
  - charles@sproutit.com
@@ -106,24 +115,10 @@ files:
106
115
  - clients/sc_test_runner/models/test.js
107
116
  - clients/sc_test_runner/views/runner_frame.js
108
117
  - 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/mixins/design_mode.js
119
- - clients/view_builder/tests/controllers/document.rhtml
120
- - clients/view_builder/tests/views/builder.rhtml
121
- - clients/view_builder/tests/views/palette.rhtml
122
- - clients/view_builder/views/builder.js
123
- - clients/view_builder/views/palette.js
124
118
  - config/hoe.rb
125
119
  - config/requirements.rb
126
120
  - frameworks/prototype/prototype.js
121
+ - frameworks/sproutcore/animation/animation.js
127
122
  - frameworks/sproutcore/controllers/array.js
128
123
  - frameworks/sproutcore/controllers/collection.js
129
124
  - frameworks/sproutcore/controllers/controller.js
@@ -179,6 +174,7 @@ files:
179
174
  - frameworks/sproutcore/foundation/run_loop.js
180
175
  - frameworks/sproutcore/foundation/server.js
181
176
  - frameworks/sproutcore/foundation/set.js
177
+ - frameworks/sproutcore/foundation/sorted_set.js
182
178
  - frameworks/sproutcore/foundation/string.js
183
179
  - frameworks/sproutcore/foundation/timer.js
184
180
  - frameworks/sproutcore/foundation/undo_manager.js
@@ -194,6 +190,7 @@ files:
194
190
  - frameworks/sproutcore/lib/index.rhtml
195
191
  - frameworks/sproutcore/lib/menu_views.rb
196
192
  - frameworks/sproutcore/mixins/array.js
193
+ - frameworks/sproutcore/mixins/collection_view_delegate.js
197
194
  - frameworks/sproutcore/mixins/control.js
198
195
  - frameworks/sproutcore/mixins/delegate_support.js
199
196
  - frameworks/sproutcore/mixins/editable.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
- } ;