sproutcore 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/History.txt +19 -0
  2. data/Manifest.txt +103 -26
  3. data/app_generators/sproutcore/templates/README +1 -1
  4. data/bin/sc-build +1 -1
  5. data/bin/sc-gen +0 -0
  6. data/bin/sc-ide +278 -0
  7. data/bin/sc-init +38 -0
  8. data/bin/sc-install +96 -0
  9. data/bin/sc-remove +94 -0
  10. data/bin/sc-server +4 -0
  11. data/bin/sc-update +94 -0
  12. data/bin/sproutcore +3 -14
  13. data/clients/sc_docs/controllers/docs.js +1 -1
  14. data/clients/sc_docs/models/doc.js +6 -0
  15. data/clients/sc_docs/views/doc_frame.js +1 -1
  16. data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
  17. data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
  18. data/frameworks/sproutcore/HISTORY +34 -2
  19. data/frameworks/sproutcore/controllers/array.js +1 -1
  20. data/frameworks/sproutcore/controllers/controller.js +1 -1
  21. data/frameworks/sproutcore/controllers/object.js +9 -6
  22. data/frameworks/sproutcore/core.js +19 -4
  23. data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
  24. data/frameworks/sproutcore/english.lproj/core.css +1 -0
  25. data/frameworks/sproutcore/english.lproj/menu.css +1 -0
  26. data/frameworks/sproutcore/foundation/application.js +3 -3
  27. data/frameworks/sproutcore/foundation/benchmark.js +1 -1
  28. data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
  29. data/frameworks/sproutcore/foundation/page.js +3 -2
  30. data/frameworks/sproutcore/foundation/path_module.js +33 -16
  31. data/frameworks/sproutcore/foundation/run_loop.js +1 -1
  32. data/frameworks/sproutcore/foundation/server.js +68 -18
  33. data/frameworks/sproutcore/foundation/string.js +1 -1
  34. data/frameworks/sproutcore/globals/window.js +62 -15
  35. data/frameworks/sproutcore/lib/core_views.rb +1 -0
  36. data/frameworks/sproutcore/lib/index.rhtml +4 -3
  37. data/frameworks/sproutcore/lib/menu_views.rb +2 -2
  38. data/frameworks/sproutcore/models/collection.js +122 -107
  39. data/frameworks/sproutcore/models/record.js +2 -2
  40. data/frameworks/sproutcore/panes/manager.js +1 -1
  41. data/frameworks/sproutcore/panes/overlay.js +3 -3
  42. data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
  43. data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
  44. data/frameworks/sproutcore/views/button/disclosure.js +1 -1
  45. data/frameworks/sproutcore/views/collection/collection.js +19 -15
  46. data/frameworks/sproutcore/views/collection/source_list.js +1 -1
  47. data/frameworks/sproutcore/views/collection/table.js +2 -2
  48. data/frameworks/sproutcore/views/error_explanation.js +1 -1
  49. data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
  50. data/frameworks/sproutcore/views/field/field.js +1 -1
  51. data/frameworks/sproutcore/views/field/radio_field.js +1 -1
  52. data/frameworks/sproutcore/views/field/select_field.js +1 -1
  53. data/frameworks/sproutcore/views/form.js +1 -1
  54. data/frameworks/sproutcore/views/image.js +1 -1
  55. data/frameworks/sproutcore/views/menu_item.js +1 -1
  56. data/frameworks/sproutcore/views/popup_button.js +1 -1
  57. data/frameworks/sproutcore/views/popup_menu.js +1 -1
  58. data/frameworks/sproutcore/views/progress.js +4 -2
  59. data/frameworks/sproutcore/views/radio_group.js +1 -1
  60. data/frameworks/sproutcore/views/scroll.js +1 -1
  61. data/frameworks/sproutcore/views/source_list_group.js +1 -1
  62. data/frameworks/sproutcore/views/split.js +1 -1
  63. data/frameworks/sproutcore/views/tab.js +3 -1
  64. data/frameworks/sproutcore/views/view.js +19 -3
  65. data/jsdoc/README.txt +89 -57
  66. data/jsdoc/app/frame/Chain.js +102 -0
  67. data/jsdoc/app/frame/Dumper.js +144 -0
  68. data/jsdoc/app/frame/Hash.js +47 -0
  69. data/jsdoc/app/frame/Link.js +142 -0
  70. data/jsdoc/app/frame/Namespace.js +10 -0
  71. data/jsdoc/app/frame/Opt.js +134 -0
  72. data/jsdoc/app/frame/Reflection.js +26 -0
  73. data/jsdoc/app/frame/String.js +93 -0
  74. data/jsdoc/app/frame/Testrun.js +129 -0
  75. data/jsdoc/app/frame.js +33 -0
  76. data/jsdoc/app/handlers/FOODOC.js +26 -0
  77. data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  78. data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  79. data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  80. data/jsdoc/app/handlers/XMLDOC.js +26 -0
  81. data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
  82. data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  83. data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
  84. data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
  85. data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  86. data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
  87. data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  88. data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
  89. data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
  90. data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  91. data/jsdoc/app/lib/JSDOC/Token.js +18 -0
  92. data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
  93. data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  94. data/jsdoc/app/lib/JSDOC/Util.js +32 -0
  95. data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
  96. data/jsdoc/app/lib/JSDOC.js +97 -0
  97. data/jsdoc/app/main.js +74 -0
  98. data/jsdoc/app/plugins/commentSrcJson.js +19 -0
  99. data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  100. data/jsdoc/app/plugins/functionCall.js +10 -0
  101. data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  102. data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
  103. data/jsdoc/app/plugins/symbolLink.js +9 -0
  104. data/jsdoc/app/plugins/tagParamConfig.js +31 -0
  105. data/jsdoc/app/plugins/tagSynonyms.js +43 -0
  106. data/jsdoc/app/run.js +339 -137
  107. data/jsdoc/changes.txt +47 -0
  108. data/jsdoc/conf/sample.conf +31 -0
  109. data/jsdoc/java/build.xml +36 -0
  110. data/jsdoc/java/build_1.4.xml +36 -0
  111. data/jsdoc/java/classes/js.jar +0 -0
  112. data/jsdoc/java/src/JsDebugRun.java +21 -0
  113. data/jsdoc/java/src/JsRun.java +21 -0
  114. data/jsdoc/jsdebug.jar +0 -0
  115. data/jsdoc/jsrun.jar +0 -0
  116. data/jsdoc/t/TestDoc.js +144 -0
  117. data/jsdoc/t/runner.js +13 -0
  118. data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
  119. data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
  120. data/jsdoc/templates/sproutcore/class.tmpl +408 -326
  121. data/jsdoc/templates/sproutcore/index.tmpl +30 -31
  122. data/jsdoc/templates/sproutcore/publish.js +173 -81
  123. data/jsdoc/templates/sproutcore/static/default.css +191 -0
  124. data/jsdoc/templates/sproutcore/static/header.html +2 -0
  125. data/jsdoc/templates/sproutcore/static/index.html +19 -0
  126. data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
  127. data/jsdoc/test/addon.js +24 -0
  128. data/jsdoc/test/anon_inner.js +14 -0
  129. data/jsdoc/test/augments.js +31 -0
  130. data/jsdoc/test/augments2.js +26 -0
  131. data/jsdoc/test/borrows.js +41 -0
  132. data/jsdoc/test/borrows2.js +23 -0
  133. data/jsdoc/test/config.js +22 -0
  134. data/jsdoc/test/constructs.js +18 -0
  135. data/jsdoc/test/encoding.js +10 -0
  136. data/jsdoc/test/encoding_other.js +12 -0
  137. data/jsdoc/test/functions_anon.js +39 -0
  138. data/jsdoc/test/functions_nested.js +33 -0
  139. data/jsdoc/test/global.js +13 -0
  140. data/jsdoc/test/globals.js +25 -0
  141. data/jsdoc/test/ignore.js +10 -0
  142. data/jsdoc/test/inner.js +16 -0
  143. data/jsdoc/test/jsdoc_test.js +477 -0
  144. data/jsdoc/test/lend.js +33 -0
  145. data/jsdoc/test/memberof.js +20 -0
  146. data/jsdoc/test/memberof_constructor.js +15 -0
  147. data/jsdoc/test/name.js +19 -0
  148. data/jsdoc/test/namespace_nested.js +23 -0
  149. data/jsdoc/test/nocode.js +13 -0
  150. data/jsdoc/test/oblit_anon.js +20 -0
  151. data/jsdoc/test/overview.js +20 -0
  152. data/jsdoc/test/param_inline.js +37 -0
  153. data/jsdoc/test/params_optional.js +8 -0
  154. data/jsdoc/test/prototype.js +17 -0
  155. data/jsdoc/test/prototype_nested.js +9 -0
  156. data/jsdoc/test/prototype_oblit.js +13 -0
  157. data/jsdoc/test/prototype_oblit_constructor.js +24 -0
  158. data/jsdoc/test/public.js +10 -0
  159. data/jsdoc/test/shared.js +42 -0
  160. data/jsdoc/test/shared2.js +2 -0
  161. data/jsdoc/test/shortcuts.js +22 -0
  162. data/jsdoc/test/static_this.js +13 -0
  163. data/jsdoc/test/synonyms.js +23 -0
  164. data/jsdoc/test/tosource.js +23 -0
  165. data/jsdoc/test/variable_redefine.js +14 -0
  166. data/jsdoc/test.js +304 -0
  167. data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
  168. data/lib/sproutcore/bundle_installer.rb +268 -0
  169. data/lib/sproutcore/jsdoc.rb +7 -6
  170. data/lib/sproutcore/library.rb +38 -0
  171. data/lib/sproutcore/merb/bundle_controller.rb +8 -4
  172. data/lib/sproutcore/version.rb +1 -1
  173. data/lib/sproutcore.rb +1 -1
  174. data/script/destroy +0 -0
  175. data/script/generate +0 -0
  176. data/script/txt2html +0 -0
  177. metadata +117 -29
  178. data/clients/view_builder/core.js +0 -19
  179. data/clients/view_builder/english.lproj/body.css +0 -149
  180. data/clients/view_builder/english.lproj/body.rhtml +0 -18
  181. data/clients/view_builder/english.lproj/strings.js +0 -14
  182. data/clients/view_builder/main.js +0 -37
  183. data/jsdoc/app/DocFile.js +0 -137
  184. data/jsdoc/app/DocTag.js +0 -110
  185. data/jsdoc/app/Doclet.js +0 -63
  186. data/jsdoc/app/Dumper.js +0 -143
  187. data/jsdoc/app/JsDoc.js +0 -103
  188. data/jsdoc/app/JsHilite.js +0 -45
  189. data/jsdoc/app/JsIO.js +0 -163
  190. data/jsdoc/app/JsParse.js +0 -385
  191. data/jsdoc/app/JsPlate.js +0 -130
  192. data/jsdoc/app/JsTestrun.js +0 -129
  193. data/jsdoc/app/JsToke.js +0 -564
  194. data/jsdoc/app/Symbol.js +0 -298
  195. data/jsdoc/app/Transformer.js +0 -14
  196. data/jsdoc/app/Util.js +0 -97
  197. data/jsdoc/app/js.jar +0 -0
  198. data/jsdoc/plugins/min.js +0 -316
  199. data/jsdoc/plugins/strip.js +0 -20
  200. data/jsdoc/templates/sproutcore/default.css +0 -191
  201. data/jsdoc/templates/sproutcore/index.html +0 -13
  202. data/jsdoc/templates/sproutcore/prototype.js +0 -4186
  203. data/jsdoc/templates/sproutcore/splash.html +0 -7
@@ -5,6 +5,9 @@
5
5
 
6
6
  require('core') ;
7
7
 
8
+ SC.URL_ENCODED_FORMAT = 'url-encoded' ;
9
+ SC.JSON_FORMAT = 'json';
10
+
8
11
  // The Server object knows how to send requests to the server and how to
9
12
  // get things back from the server. It automatically handles situations
10
13
  // such as 304 caching and queuing requests to send to the server later if
@@ -37,6 +40,12 @@ SC.Server = SC.Object.extend({
37
40
  // Set this string to the format to be used to set your resource and verb.
38
41
  urlFormat: '/%@/%@',
39
42
 
43
+ // Set this string to either rails or json to set the post transport protocol
44
+ postFormat: SC.URL_ENCODED_FORMAT,
45
+
46
+ // Set this string to true when escaping the JSON string is necessary
47
+ escapeJSON: true,
48
+
40
49
  // call this in your main to preload any data sent from the server with the
41
50
  // initial page load.
42
51
  preload: function(clientData) {
@@ -189,7 +198,6 @@ SC.Server = SC.Object.extend({
189
198
  var recData = server._decamelizeData(rec.getPropertyData()) ;
190
199
  recData._guid = rec._guid ;
191
200
  context[rec._guid] = rec ;
192
- rec.set('newRecord',false) ;
193
201
  return recData ;
194
202
  }) ;
195
203
 
@@ -218,6 +226,7 @@ SC.Server = SC.Object.extend({
218
226
  var pk = rec.get('primaryKey') ;
219
227
  var dataKey = (pk == 'guid') ? 'id' : pk.decamelize().toLowerCase().replace(/\-/g,'_') ;
220
228
  rec.set(pk,data[dataKey]) ;
229
+ rec.set('newRecord',false) ;
221
230
  }
222
231
  }) ;
223
232
 
@@ -288,20 +297,53 @@ SC.Server = SC.Object.extend({
288
297
 
289
298
  // collect data for records
290
299
  var server = this ;
291
- var data = curRecords.map(function(rec) {
292
- return server._decamelizeData(rec.getPropertyData()) ;
293
- }) ;
294
300
 
295
- // issue request
296
- this.request(resource,'update',null,{
297
- requestContext: records,
298
- onSuccess: this._commitSuccess.bind(this),
299
- onFailure: this._commitFailure.bind(this),
300
- records: data
301
- },'post') ;
301
+ // start format differences
302
+ switch(this.get('postFormat')){
303
+ case SC.URL_ENCODED_FORMAT:
304
+ var data = curRecords.map(function(rec) {
305
+ return server._decamelizeData(rec.getPropertyData()) ;
306
+ }) ;
307
+
308
+ // issue request
309
+ this.request(resource,'update',null,{
310
+ requestContext: records,
311
+ onSuccess: this._commitSuccess.bind(this),
312
+ onFailure: this._commitFailure.bind(this),
313
+ records: data
314
+ },'post') ;
315
+ break;
316
+
317
+ case SC.JSON_FORMAT:
318
+ // get all records and put them into an array
319
+ var objects = [];
320
+ for(rec in curRecords){
321
+ if (!curRecords.hasOwnProperty(rec)) continue ;
322
+ objects.push(curRecords[rec].get('attributes'));
323
+ }
324
+
325
+ // convert to JSON and escape if this.escapeJSON is true
326
+ if(this.get('escapeJSON')){
327
+ var data = escape(objects.toJSONString());
328
+ } else {
329
+ var data = objects.toJSONString();
330
+ }
331
+
332
+ // issue request
333
+ this.request(resource,'update',null,{
334
+ requestContext: records,
335
+ onSuccess: this._commitSuccess.bind(this),
336
+ onFailure: this._commitFailure.bind(this),
337
+ records: data
338
+ },'post') ;
339
+ break;
340
+ default:
341
+ break;
342
+ }
343
+ // end format differences
302
344
  }
303
345
  },
304
-
346
+
305
347
  // This method is called when a refresh is successful. It expects an array
306
348
  // of hashes, which it will convert to records.
307
349
  _commitSuccess: function(status, transport, cacheCode, context) {
@@ -369,6 +411,7 @@ SC.Server = SC.Object.extend({
369
411
  // their data.
370
412
  refreshRecordsWithData: function(dataAry,recordType,cacheCode,loaded) {
371
413
  var server = this ;
414
+
372
415
  // first, prepare each data item in the Ary.
373
416
  dataAry = dataAry.map(function(data) {
374
417
 
@@ -381,16 +424,23 @@ SC.Server = SC.Object.extend({
381
424
  // find the recordType
382
425
  if (data.type) {
383
426
  var recordName = data.type.capitalize() ;
384
- if (server.prefix) for(var prefixLoc=0;prefixLoc < server.prefix.length; prefixLoc++) {
385
- var namespace = window[server.prefix[prefixLoc]] ;
386
- if (namespace) data.recordType = namespace[recordName] ;
387
- if (data.recordType) break ;
427
+ if (server.prefix) {
428
+ for (var prefixLoc = 0; prefixLoc < server.prefix.length; prefixLoc++) {
429
+ var prefixParts = server.prefix[prefixLoc].split('.');
430
+ var namespace = window;
431
+ for (var prefixPartsLoc = 0; prefixPartsLoc < prefixParts.length; prefixPartsLoc++) {
432
+ var namespace = namespace[prefixParts[prefixPartsLoc]] ;
433
+ }
434
+ if (namespace != window) data.recordType = namespace[recordName] ;
435
+ if (data.recordType) break ;
436
+ }
388
437
  } else data.recordType = window[recordName] ;
438
+
389
439
  if (!data.recordType) console.log('skipping undefined recordType:'+recordName) ;
390
440
  } else data.recordType = recordType ;
441
+
391
442
  if (!data.recordType) return null; // could not process.
392
-
393
- return data ;
443
+ else return data ;
394
444
  }).compact() ;
395
445
 
396
446
  // now update.
@@ -150,7 +150,6 @@ Object.extend(String,
150
150
  that are defined and use those instead.
151
151
  */
152
152
  currentLanguage: function () {
153
-
154
153
  var ret = (this.useAutodetectedLanguage) ? (this.browserLanguage || this.preferredLanguage || 'en') : (this.preferredLanguage || this.browserLanguage || 'en') ;
155
154
 
156
155
  // then try a couple of normalized forms...
@@ -182,6 +181,7 @@ Object.extend(String,
182
181
  break;
183
182
 
184
183
  default:
184
+ ret = "English";
185
185
  break ;
186
186
  }
187
187
  return ret;
@@ -21,7 +21,7 @@ SC.window = SC.PaneView.extend({
21
21
  while(el && (el != document) && (!el._configured)) el = el.parentNode ;
22
22
  if (el) el = SC.View.findViewForElement(el) ;
23
23
  if (el == this) el = null ;
24
- return el ;
24
+ return el ;
25
25
  },
26
26
 
27
27
  // ........................................................................
@@ -223,6 +223,12 @@ SC.window = SC.PaneView.extend({
223
223
  {
224
224
  Event.stop(evt);
225
225
  ret = false ;
226
+ if(this._mouseDownView.mouseDragged && $type(this._mouseDownView.mouseDragged) == T_FUNCTION) {
227
+ //IE7: if the mouseDownView handles the mouseDragged event, set mouseCanDrag
228
+ //to true. TODO: make an optional "allowBrowserSelect" property that
229
+ // would do the same thing; for now let's just prevent it in this case
230
+ this._mouseCanDrag = true;
231
+ }
226
232
  }
227
233
 
228
234
  SC.runLoop.endRunLoop();
@@ -263,10 +269,18 @@ SC.window = SC.PaneView.extend({
263
269
  evt._type = 'click';
264
270
  handler = SC.app.sendEvent(evt, this._mouseDownView);
265
271
  }
266
-
272
+ this._mouseCanDrag = false;
267
273
  this._mouseDownView = null;
268
274
  SC.runLoop.endRunLoop() ;
269
275
  },
276
+
277
+ _ondblclick: function(evt){
278
+ if(SC.isIE())
279
+ {
280
+ this._clickCount = 2;
281
+ this._onmouseup(evt);
282
+ }
283
+ },
270
284
 
271
285
  _lastHovered: null,
272
286
 
@@ -285,6 +299,7 @@ SC.window = SC.PaneView.extend({
285
299
  // make sure the view gets focus no matter what. FF is inconsistant
286
300
  // about this.
287
301
  this._onfocus();
302
+
288
303
 
289
304
  var lh = this._lastHovered || [] ;
290
305
  var nh = [] ;
@@ -349,38 +364,70 @@ SC.window = SC.PaneView.extend({
349
364
  }
350
365
  },
351
366
 
367
+ /** @private */
368
+ // these methods are used to prevent unnecessary text-selection in IE,
369
+ // there could be some more work to improve this behavior and make it
370
+ // a bit more useful; right now it's just to prevent bugs when dragging
371
+ // and dropping.
372
+
373
+ _mouseCanDrag: true,
374
+
375
+ _onselectstart: function() {
376
+ if(this._mouseCanDrag) {
377
+ return false;
378
+ } else {
379
+ return true;
380
+ }
381
+ },
382
+
383
+ _ondrag: function() {
384
+ return false;
385
+ },
386
+
352
387
  _hasFocus: NO,
353
388
 
354
- _EVTS: ['mousedown', 'mouseup', 'click', 'dblclick', 'keydown', 'keyup', 'keypress', 'mouseover', 'mouseout', 'mousemove', 'resize', 'unload', 'focus', 'blur'],
389
+ _EVTS: ['mousedown', 'mouseup', 'click', 'dblclick', 'keydown', 'keyup', 'keypress', 'mouseover', 'mouseout', 'mousemove', 'resize', 'unload', 'focus', 'blur','drag','selectstart'],
355
390
 
356
391
  _listenerCache: [],
357
392
 
358
- setup: function() {
359
-
393
+ setup: function()
394
+ {
360
395
  // setup event listeners for window.
361
396
  var win = this ;
362
- win._EVTS.each(function(e) {
397
+ win._EVTS.each(function(e)
398
+ {
363
399
  var func = win['_on' + e] ;
364
400
  var target = (e != 'resize') ? document : window ;
365
- if (func) {
401
+ if (func)
402
+ {
366
403
  var f = func.bindAsEventListener(win) ;
367
-
368
- if (e === 'keypress' && SC.CAPTURE_BACKSPACE_KEY && SC.Platform.Firefox > 0) {
404
+ if (e === 'keypress' && SC.CAPTURE_BACKSPACE_KEY && SC.Platform.Firefox > 0)
405
+ {
369
406
  document.onkeypress = f ;
370
- } else {
407
+ }
408
+ else if (e === 'selectstart' && SC.Platform.IE > 0)
409
+ {
410
+ //capture onselectstart events in IE (proprietary)
411
+ document.body.onselectstart = f;
412
+ }
413
+ else if (e === 'drag' && SC.Platform.IE > 0)
414
+ {
415
+ document.body.ondrag = f;
416
+ }
417
+ else
418
+ {
371
419
  Event.observe(target, e, f) ;
372
420
  }
373
-
374
421
  win._listenerCache.push([target, e, f]) ;
375
422
  }
376
423
  });
377
-
378
- this.get('size') ; // fetch the size from the window and save it.
424
+ this.get('size') ;
425
+ // fetch the size from the window and save it.
379
426
  this.set('isVisibleInWindow', true) ;
380
427
  this._onfocus() ;
381
-
382
428
  }
383
- }).viewFor($tag('body')) ;
429
+ }).viewFor($tag('body')) ;
430
+
384
431
 
385
432
  // events:
386
433
  // window.onfocus --
@@ -132,6 +132,7 @@ view_helper :label_view do
132
132
 
133
133
  var :label, nil
134
134
  var :value, nil
135
+ var :tag, 'span'
135
136
  view 'SC.LabelView'
136
137
 
137
138
  css_class_names << 'sc-label-view'
@@ -8,7 +8,8 @@
8
8
  # See the comments in this file for more information on what you can
9
9
  # change.
10
10
  -%>
11
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
11
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
12
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
12
13
  <html>
13
14
  <head>
14
15
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
@@ -26,8 +27,8 @@
26
27
  <%= @content_for_page_styles %>
27
28
  </head>
28
29
  <body class="<%= @theme || 'sc-theme' %> focus">
29
- <script>
30
- if (window.SC && SC.setupBodyClassNames) SC.setupBodyClassNames() ;
30
+ <script type="text/javascript">
31
+ if (SC.setupBodyClassNames) SC.setupBodyClassNames() ;
31
32
  </script>
32
33
 
33
34
  <% #
@@ -80,12 +80,12 @@ view_helper :menu_item_view, :extends => :button_view do
80
80
  @href = nil
81
81
  @inner_html = [
82
82
  %(<a href="#{@my_href}">),
83
- '<span class="sel">&#x2713;</span>',
84
- '<span class="mixed">-</span>',
85
83
  '<span class="inner">',
86
84
  @image,
87
85
  %(<span class="label">#{@label}</span>),
88
86
  '</span>',
87
+ '<span class="sel">&#x2713;</span>',
88
+ '<span class="mixed">-</span>',
89
89
  %(<span class="shortcut">#{@shortcut}</span>),
90
90
  '</a>'
91
91
  ] * ''
@@ -6,46 +6,99 @@
6
6
  require('models/record') ;
7
7
  require('models/store') ;
8
8
 
9
- // A collection holds a set of records matching the specified conditions. You
10
- // can set the data source used to find the objects matching the conditions
11
- // to create collections pulled from the local set of objects or pulled
12
- // from the server.
13
- //
14
- // Collection's automatically update their contents based on the conditions
15
- // settings you provide as the state of loaded records change.
16
- //
17
- SC.Collection = SC.Object.extend({
9
+ /**
10
+ @class
11
+ @extends SC.Object
12
+ @since 0.9.14
13
+
14
+ @author Charles Jolley
15
+
16
+ _IMPORTANT: SC.Collection currently has several known performance issues. It
17
+ is suitable for use in existing code, but it is possible that the API will
18
+ change before SproutCore 1.0
19
+
20
+ A collection holds a set of records matching the specified conditions. You
21
+ can set the data source used to find the objects matching the conditions
22
+ to create collections pulled from the local set of objects or pulled
23
+ from the server.
24
+
25
+ Collection's automatically update their contents based on the conditions
26
+ settings you provide as the state of loaded records change.
27
+ */
28
+ SC.Collection = SC.Object.extend(
29
+ /** @scope SC.Collection.prototype */ {
18
30
 
19
31
  // ........................................
20
32
  // CONFIGURABLE PROPERTIES
21
33
  //
22
34
  // Set these properties to control the records that will be in this list.
23
35
 
24
- // indicates the keys to use to order the records. If you want the records
25
- // ordered by descending order, use a string like 'guid DESC'.
36
+ /**
37
+ Indicates the keys to use to order the records. If you want the records
38
+ ordered by descending order, use a string like 'guid DESC'.
39
+
40
+ @type {Array}
41
+ */
26
42
  orderBy: ['guid'],
27
43
 
28
- // set this to the range of records you are interested in seeing or null if
29
- // you want to see all records. Note that collection actually retrieves
30
- // a list of records slightly larger than what you pass here to allow for
31
- // members to be added and removed.
32
- offset: 0, limit: 0,
44
+ /**
45
+ Set this to the range of records you are interested in seeing or null if
46
+ you want to see all records. Note that collection actually retrieves
47
+ a list of records slightly larger than what you pass here to allow for
48
+ members to be added and removed.
49
+
50
+ @see SC.Collection.offset
51
+
52
+ @type {Number}
53
+ */
54
+ limit: 0,
33
55
 
34
- // set this to a hash with conditions options. e.g. { active: true }. If you
35
- // don't set this property, then all records of the given type will be
36
- // used.
56
+ /**
57
+ Set this to the offset within the range of records you want to retrieve
58
+ this.get('limit') records from.
59
+
60
+ @see SC.Collection.limit
61
+
62
+ @type {Number}
63
+ */
64
+ offset: 0,
65
+
66
+ /**
67
+ Set this to a hash with conditions options. e.g. { active: true }. If you
68
+ don't set this property, then all records of the given type will be
69
+ used.
70
+
71
+ Note also that if you are matching a property that contains an array, the
72
+ condition will match if the key you specify is found in the array. For
73
+ example { groups: someGroup } would match any record where someGroup is
74
+ included in the groups array.
75
+
76
+ @type {Object}
77
+ */
37
78
  conditions: {},
38
79
 
39
- // this is the actual array of records in the current collection. This
40
- // property will change anytime the record members change (but not when
41
- // the member record properties change)
80
+ /**
81
+ @property
82
+
83
+ This is the actual array of records in the current collection. This
84
+ property will change anytime the record members change (but not when
85
+ the member record properties change).
86
+
87
+ @type {Array}
88
+ */
42
89
  records: function() {
43
90
  if (this._changedRecords) this._flushChangedRecords() ;
44
91
  return this._records ;
45
92
  }.property(),
46
93
 
47
- // the total count of records matching the conditions settings. The contents
48
- // of the records array will be clipped to the range value.
94
+ /**
95
+ @property
96
+
97
+ The total count of records matching the conditions settings. The contents
98
+ of the records array will be clipped to the range value.
99
+
100
+ @type {Number}
101
+ */
49
102
  count: function(key, value) {
50
103
  if (value !== undefined) {
51
104
  this._count = value ;
@@ -53,31 +106,56 @@ SC.Collection = SC.Object.extend({
53
106
  return this._count || 0 ;
54
107
  }.property(),
55
108
 
56
- // set to true when the collection is destroyed
109
+ /**
110
+ Set to true when the collection is destroyed
111
+
112
+ @type {Boolean}
113
+ */
57
114
  isDeleted: false, // RO
58
115
 
59
- // set this to the data source you want to use to get the records. Use
60
- // either SC.Store or SC.Server. If you use SC.Server, your recordType
61
- // must have a resourceURL property. // NC
62
- dataSource: SC.Store,
116
+ /**
117
+ Set this to the data source you want to use to get the records. Use
118
+ either SC.Store or SC.Server. If you use SC.Server, your recordType
119
+ must have a resourceURL property.
120
+
121
+ This should be set when the collection is created and not changed later.
122
+
123
+ @type {SC.Store or SC.Server}
124
+ */
125
+ dataSource: SC.Store, // NC
63
126
 
64
- // set this to the type of record you want in the collection. This should
65
- // be set when the collection is created and not changed later.
127
+ /**
128
+ Set this to the type of record you want in the collection.
129
+
130
+ This should be set when the collection is created and not changed later.
131
+
132
+ @type {SC.Record}
133
+ */
66
134
  recordType: SC.Record, // NC
67
135
 
68
- // set to true while a refresh is in progress.
136
+ /**
137
+ Set to true while a refresh is in progress.
138
+
139
+ @type {Boolean}
140
+ */
69
141
  isLoading: false, // RO
70
142
 
71
- // set to true if records have changed in a way that might leave the records out
72
- // of date.
143
+ /**
144
+ Set to true if records have changed in a way that might leave the records out
145
+ of date.
146
+
147
+ @type {Boolean}
148
+ */
73
149
  isDirty: false, // RO
74
150
 
75
151
  // ........................................
76
152
  // ACTIONS
77
153
  //
78
154
 
79
- // call this to force the list to refresh. The refresh may not happen
80
- // right away, depending on the dataSource.
155
+ /**
156
+ Call this to force the list to refresh. The refresh may not happen
157
+ right away, depending on the dataSource.
158
+ */
81
159
  refresh: function() {
82
160
  var recordType = this.get('recordType') || SC.Record ;
83
161
  var offset = (this._limit > 0) ? this._offset : 0 ;
@@ -107,11 +185,16 @@ SC.Collection = SC.Object.extend({
107
185
  return this;
108
186
  },
109
187
 
110
- // call this method when you are done with a collection. This will remove
111
- // it as an observer to changes in the SC.Store so that it can be reclaimed.
112
- // isDeleted will also be set to true.
188
+ /**
189
+ Call this method when you are done with a collection. This will remove
190
+ it as an observer to changes in the SC.Store so that it can be reclaimed.
191
+ isDeleted will also be set to true.
192
+ */
113
193
  destroy: function() { SC.Store.removeCollection(this); return this; },
114
194
 
195
+ /**
196
+ TODO: Needs documentation.
197
+ */
115
198
  newRecord: function(settings) {
116
199
  if (!settings) settings = {} ;
117
200
  settings.newRecord = true ;
@@ -258,74 +341,6 @@ SC.Collection = SC.Object.extend({
258
341
  this._reslice() ;
259
342
  },
260
343
 
261
- /// SAVED FOR POSTERITY
262
- _oldRecordsDidChange: function() {
263
- var state = ((!rec.isDeleted) && rec.matchConditions(this.get('conditions'))) ? 'in' : 'out';
264
- var records = this._records ;
265
-
266
- // see if this comes before or after
267
- if ((this._limit > 0) && (state == "in") && records && (records.length > 0)) {
268
- var order = this.get('orderBy') ;
269
- if (rec.compareTo(records[0],order) < 0) {
270
- state = "before" ;
271
- } else if (rec.compareTo(records[records.length-1],order) > 0) {
272
- state = "after" ;
273
- }
274
- }
275
-
276
- // does this currently belong to the collection.
277
- var belongs = records.include(rec) ;
278
- var reslice = false ; var refresh = false ;
279
-
280
- // now adjust appropriately
281
- switch(state) {
282
- case 'before':
283
- // note: this is technically incorrect. If the record comes before
284
- // that might actually shift everything forward. But there is no
285
- // way to really tell if the rec is just now being added or not.
286
- //
287
- // We let this go since this will only be temporarily wrong as the
288
- // list will get refreshed.
289
- //
290
- if (belongs) { records = records.without(rec) ; reslice = true; }
291
- refresh = true ;
292
- break ;
293
-
294
- case 'after':
295
- case 'out':
296
- if (belongs) {
297
- records = records.without(rec) ;
298
- reslice = refresh = true ;
299
- }
300
- break ;
301
-
302
- case 'in':
303
- // resort records
304
- if (!belongs) {
305
- records = records.slice();
306
- records.push(rec) ;
307
- }
308
- records = records.sort(function(a,b){ return a.compareTo(b,order); });
309
- if (!records.isEqual(this._records)) reslice = refresh = true ;
310
- break;
311
- }
312
-
313
- if (reslice) {
314
- this._records = records ;
315
- if (this._limit > 0) {
316
- var start = this.get('offset') - this._offset ;
317
- var end = start + this.get('limit') ;
318
- records = records.slice(start,end) ;
319
- }
320
- this.set('records',records) ;
321
- }
322
-
323
- //if (refresh && !this._refreshing) {
324
- // this._refreshing = true ;
325
- // this.invokeLater(this.refresh, 1) ;
326
- //}
327
- },
328
-
329
344
  // Anytime the properties used to filter the collection change, reslice if possible
330
345
  // then refresh from the data source.
331
346
  propertyObserver: function(observing,target,key,value) {
@@ -114,7 +114,7 @@ SC.Record = SC.Object.extend(
114
114
 
115
115
  init: function()
116
116
  {
117
- arguments.callee.base.apply(this, arguments);
117
+ sc_super();
118
118
 
119
119
  var primaryKeyName = this.get('primaryKey');
120
120
  if (!this.get(primaryKeyName))
@@ -462,7 +462,7 @@ SC.Record = SC.Object.extend(
462
462
  if (recValue && recValue.primaryKey) recValue = recValue.get(recValue.primaryKey) ;
463
463
  var stringify = (value instanceof RegExp);
464
464
  if (stringify) {
465
- return recValue.toString().match(value)
465
+ return recValue.toString().match(value) ;
466
466
  } else {
467
467
  return recValue==value ;
468
468
  }
@@ -137,7 +137,7 @@ SC.PaneManager = SC.View.extend({
137
137
 
138
138
  // on init, add to main HTML page if not already added.
139
139
  init: function() {
140
- arguments.callee.base.apply(this,arguments) ;
140
+ sc_super() ;
141
141
  var el = this.rootElement ;
142
142
  if (!this.parentNode) {
143
143
  $tag('body').insertBefore(el, null) ;
@@ -115,7 +115,7 @@ SC.OverlayPaneView = SC.PaneView.extend({
115
115
 
116
116
  keyDown: function(evt) {
117
117
  if (!this.interpretKeyEvents(evt)) {
118
- return arguments.callee.base.apply(this,arguments);
118
+ return sc_super();
119
119
  }
120
120
  },
121
121
 
@@ -206,7 +206,7 @@ SC.OverlayPaneView = SC.PaneView.extend({
206
206
  }.observes('content'),
207
207
 
208
208
  init: function() {
209
- arguments.callee.base.apply(this,arguments) ;
209
+ sc_super() ;
210
210
 
211
211
  // only Safari does well enough with animations to handle this dainty
212
212
  // guy.
@@ -228,7 +228,7 @@ SC.OverlayPaneView = SC.PaneView.extend({
228
228
  // view to match its content
229
229
  show: function() {
230
230
  this.containerView._fixWidth();
231
- arguments.callee.base.apply(this,arguments);
231
+ sc_super();
232
232
  //this.focusFirstKeyView() ;
233
233
  }
234
234