sproutcore 1.10.0 → 1.10.1

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 (50) hide show
  1. checksums.yaml +8 -8
  2. data/VERSION.yml +1 -1
  3. data/bin/sc-phantom +13 -0
  4. data/lib/Buildfile +3 -0
  5. data/lib/buildtasks/manifest.rake +3 -0
  6. data/lib/frameworks/sproutcore/CHANGELOG.md +24 -1
  7. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +1 -0
  8. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +1 -1
  9. data/lib/frameworks/sproutcore/frameworks/designer/views/designer_drop_target.js +1 -2
  10. data/lib/frameworks/sproutcore/frameworks/designer/views/high_light.js +1 -2
  11. data/lib/frameworks/sproutcore/frameworks/designer/views/page_item_view.js +1 -2
  12. data/lib/frameworks/sproutcore/frameworks/designer/views/selection_handles.js +1 -2
  13. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +4 -3
  14. data/lib/frameworks/sproutcore/frameworks/desktop/resources/progress.css +4 -0
  15. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +44 -35
  16. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +167 -91
  17. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/touch.js +215 -0
  18. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/grid/drag_and_drop.js +7 -2
  19. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/drag_and_drop.js +7 -1
  20. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/stacked/ui_comments.js +26 -24
  21. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +9 -18
  22. data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +25 -20
  23. data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +29 -29
  24. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +107 -106
  25. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +120 -134
  26. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +14 -7
  27. data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +2 -1
  28. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +4 -4
  29. data/lib/frameworks/sproutcore/frameworks/foundation/system/module.js +197 -196
  30. data/lib/frameworks/sproutcore/frameworks/foundation/views/inline_text_field.js +7 -0
  31. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +22 -10
  32. data/lib/frameworks/sproutcore/frameworks/routing/tests/system/routes.js +43 -0
  33. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +1 -1
  34. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +2 -3
  35. data/lib/frameworks/sproutcore/frameworks/runtime/system/run_loop.js +14 -14
  36. data/lib/frameworks/sproutcore/frameworks/statechart/system/statechart.js +90 -79
  37. data/lib/frameworks/sproutcore/frameworks/statechart/tests/event_handling/advanced/event_queuing.js +104 -0
  38. data/lib/frameworks/sproutcore/frameworks/table/views/table.js +3 -0
  39. data/lib/frameworks/sproutcore/frameworks/template_view/handlebars.js +2 -1
  40. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/grid.css +17 -0
  41. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.css +1 -0
  42. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu.png +0 -0
  43. data/lib/frameworks/sproutcore/themes/ace/resources/menu/menu@2x.png +0 -0
  44. data/lib/frameworks/sproutcore/themes/ace/resources/panel/panel.css +2 -2
  45. data/lib/frameworks/sproutcore/themes/empty_theme/theme.js +1 -1
  46. data/lib/sproutcore/tools.rb +2 -1
  47. data/lib/sproutcore/tools/phantom.rb +36 -0
  48. data/sproutcore.gemspec +1 -1
  49. data/vendor/chance/lib/chance/instance.rb +5 -2
  50. metadata +11 -4
@@ -140,13 +140,22 @@ SC.GridView = SC.ListView.extend(
140
140
  },
141
141
 
142
142
  /**
143
+ Default view class used to draw an insertion point, which uses CSS
144
+ styling to show a horizontal line.
145
+
146
+ This view's position (top & left) will be automatically adjusted to the
147
+ point of insertion.
148
+
149
+ @field
143
150
  @type SC.View
144
151
  */
145
152
  insertionPointClass: SC.View.extend({
146
- classNames: ['grid-insertion-point'],
153
+ classNames: ['sc-grid-insertion-point'],
154
+
155
+ layout: { width: 2 },
147
156
 
148
157
  render: function (context, firstTime) {
149
- if (firstTime) context.push('<span class="anchor"></span>');
158
+ if (firstTime) context.push('<div class="anchor"></div>');
150
159
  }
151
160
  }),
152
161
 
@@ -169,7 +178,6 @@ SC.GridView = SC.ListView.extend(
169
178
  }
170
179
 
171
180
  } else {
172
-
173
181
  if (this._lastDropOnView) {
174
182
  // If there was an item that was the target of the drop previously, be
175
183
  // sure to clear it.
@@ -177,27 +185,24 @@ SC.GridView = SC.ListView.extend(
177
185
  this._lastDropOnView = null;
178
186
  }
179
187
 
180
- if (!this._insertionPointView) {
181
- this._insertionPointView = this.insertionPointClass.create();
182
- }
188
+ var insertionPoint = this._insertionPointView,
189
+ layout = itemView.get('layout'),
190
+ top, left;
183
191
 
184
- var insertionPoint = this._insertionPointView;
185
- var itemViewFrame = itemView.get('frame');
186
- var f = { height: itemViewFrame.height - 6,
187
- x: itemViewFrame.x,
188
- y: itemViewFrame.y + 6,
189
- width: 0
190
- };
191
-
192
- if (!SC.rectsEqual(insertionPoint.get('frame'), f)) {
193
- insertionPoint.set('frame', f);
192
+ if (!insertionPoint) {
193
+ insertionPoint = this._insertionPointView = this.insertionPointClass.create();
194
194
  }
195
195
 
196
- if (insertionPoint.parentNode !== itemView.parentNode) {
197
- itemView.parentNode.appendChild(insertionPoint);
198
- }
199
- }
196
+ // Adjust the position of the insertion point.
197
+ top = layout.top;
198
+ left = layout.left;
199
+ if (dropOperation & SC.DROP_AFTER) left += layout.width;
200
+ height = layout.height;
200
201
 
202
+ // Adjust the position of the insertion point.
203
+ insertionPoint.adjust({ top: top, left: left, height: height });
204
+ this.appendChild(insertionPoint);
205
+ }
201
206
  },
202
207
 
203
208
  /** @see SC.CollectionView#hideInsertionPoint */
@@ -438,10 +438,11 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
438
438
  //
439
439
 
440
440
  /**
441
- Default view class used to draw an insertion point. The default
442
- view will show a vertical line. Any view you create
443
- should expect an outlineLevel property set, which should impact your left
444
- offset.
441
+ Default view class used to draw an insertion point, which uses CSS
442
+ styling to show a horizontal line.
443
+
444
+ This view's position (top & left) will be automatically adjusted to the
445
+ point of insertion.
445
446
 
446
447
  @field
447
448
  @type SC.View
@@ -449,6 +450,8 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
449
450
  insertionPointView: SC.View.extend({
450
451
  classNames: 'sc-list-insertion-point',
451
452
 
453
+ layout: { height: 2 },
454
+
452
455
  /** @private */
453
456
  render: function(context, firstTime) {
454
457
  if (firstTime) context.push('<div class="anchor"></div>');
@@ -459,25 +462,17 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
459
462
  Default implementation will show an insertion point
460
463
  @see SC.CollectionView#showInsertionPoint
461
464
  */
462
- showInsertionPoint: function(itemView, dropOperation) {
463
- var view = this._insertionPointView;
464
- if (!view) {
465
- view = this._insertionPointView
466
- = this.get('insertionPointView').create();
467
- }
468
-
465
+ showInsertionPoint: function (itemView, dropOperation) {
469
466
  var index = itemView.get('contentIndex'),
470
- len = this.get('length'),
471
- layout = SC.clone(itemView.get('layout')),
472
- level = itemView.get('outlineLevel'),
473
- indent = itemView.get('outlineIndent') || 0,
474
- group;
467
+ len = this.get('length'),
468
+ level = itemView.get('outlineLevel'),
469
+ indent = itemView.get('outlineIndent') || 0;
475
470
 
476
471
  // show item indented if we are inserting at the end and the last item
477
472
  // is a group item. This is a special case that should really be
478
473
  // converted into a more general protocol.
479
474
  if ((index >= len) && index>0) {
480
- group = this.itemViewForContentIndex(len-1);
475
+ var group = this.itemViewForContentIndex(len - 1);
481
476
  if (group.get('isGroupView')) {
482
477
  level = 1;
483
478
  indent = group.get('outlineIndent');
@@ -499,7 +494,6 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
499
494
  this._lastDropOnView = itemView;
500
495
  }
501
496
  } else {
502
-
503
497
  if (this._lastDropOnView) {
504
498
  // If there was an item that was the target of the drop previously, be
505
499
  // sure to clear it.
@@ -507,15 +501,21 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
507
501
  this._lastDropOnView = null;
508
502
  }
509
503
 
510
- if (dropOperation & SC.DROP_AFTER) layout.top += layout.height;
504
+ var insertionPoint = this._insertionPointView,
505
+ layout = itemView.get('layout'),
506
+ top, left;
507
+
508
+ if (!insertionPoint) {
509
+ insertionPoint = this._insertionPointView = this.get('insertionPointView').create();
510
+ }
511
511
 
512
- layout.height = 2;
513
- layout.right = 0;
514
- layout.left = ((level+1) * indent) + 12;
515
- delete layout.width;
512
+ // Adjust the position of the insertion point.
513
+ top = layout.top;
514
+ if (dropOperation & SC.DROP_AFTER) top += layout.height;
515
+ left = ((level + 1) * indent) + 12;
516
516
 
517
- view.set('layout', layout);
518
- this.appendChild(view);
517
+ insertionPoint.adjust({ top: top, left: left });
518
+ this.appendChild(insertionPoint);
519
519
  }
520
520
  },
521
521
 
@@ -558,8 +558,8 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
558
558
  // if there are no indexes in the rect, then we need to either insert
559
559
  // before the top item or after the last item. Figure that out by
560
560
  // computing both.
561
- if (SC.none(index) || index<0) {
562
- if ((len===0) || (loc.y <= this.rowOffsetForContentIndex(0))) index = 0;
561
+ if (SC.none(index) || index < 0) {
562
+ if ((len === 0) || (loc.y <= this.rowOffsetForContentIndex(0))) index = 0;
563
563
  else if (loc.y >= this.rowOffsetForContentIndex(len)) index = len;
564
564
  }
565
565
 
@@ -571,11 +571,11 @@ SC.ListView = SC.CollectionView.extend(SC.CollectionRowDelegate,
571
571
  // if we can drop on or not.
572
572
  if (dropOperation == SC.DROP_ON) {
573
573
  // editable size - reduce height by a bit to handle dropping
574
- if (this.get('isEditable')) diff=Math.min(Math.floor((max-min)*0.2),5);
574
+ if (this.get('isEditable')) diff = Math.min(Math.floor((max - min) * 0.2), 5);
575
575
  else diff = 0;
576
576
 
577
577
  // if we're inside the range, then DROP_ON
578
- if (loc.y >= (min+diff) || loc.y <= (max+diff)) {
578
+ if (loc.y >= (min + diff) || loc.y <= (max + diff)) {
579
579
  return [index, SC.DROP_ON];
580
580
  }
581
581
  }
@@ -5,8 +5,8 @@
5
5
  // License: Licensed under MIT license (see license.js)
6
6
  // ==========================================================================
7
7
 
8
- sc_require('views/button') ;
9
- sc_require('views/separator') ;
8
+ sc_require('views/button');
9
+ sc_require('views/separator');
10
10
 
11
11
  /**
12
12
  @class
@@ -89,7 +89,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
89
89
  @type Boolean
90
90
  @observes content
91
91
  */
92
- isSeparator: function() {
92
+ isSeparator: function () {
93
93
  return this.getContentProperty('itemSeparatorKey') === YES;
94
94
  }.property('content').cacheable(),
95
95
 
@@ -98,7 +98,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
98
98
  @type Boolean
99
99
  @observes content.isEnabled
100
100
  */
101
- isEnabled: function() {
101
+ isEnabled: function () {
102
102
  return this.getContentProperty('itemIsEnabledKey') !== NO &&
103
103
  this.getContentProperty('itemSeparatorKey') !== YES;
104
104
  }.property('content.isEnabled').cacheable(),
@@ -109,7 +109,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
109
109
  @type Boolean
110
110
  @property
111
111
  */
112
- isChecked: function() {
112
+ isChecked: function () {
113
113
  return this.getContentProperty('itemCheckboxKey');
114
114
  }.property(),
115
115
 
@@ -120,13 +120,13 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
120
120
  @type SC.MenuView
121
121
  @observes content
122
122
  */
123
- subMenu: function() {
123
+ subMenu: function () {
124
124
  var content = this.get('content'), menuItems, parentMenu;
125
125
 
126
126
  if (!content) return null;
127
127
 
128
128
  parentMenu = this.get('parentMenu');
129
- menuItems = content.get(parentMenu.itemSubMenuKey );
129
+ menuItems = content.get(parentMenu.itemSubMenuKey);
130
130
  if (menuItems) {
131
131
  if (SC.kindOf(menuItems, SC.MenuPane)) {
132
132
  menuItems.set('isModal', NO);
@@ -154,12 +154,12 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
154
154
  @default NO
155
155
  @observes subMenu
156
156
  */
157
- hasSubMenu: function() {
157
+ hasSubMenu: function () {
158
158
  return !!this.get('subMenu');
159
159
  }.property('subMenu').cacheable(),
160
160
 
161
161
  /** @private */
162
- init: function() {
162
+ init: function () {
163
163
  sc_super();
164
164
  this.contentDidChange();
165
165
  },
@@ -177,14 +177,15 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
177
177
  @param {Boolean} firstTime
178
178
  @returns {void}
179
179
  */
180
- render: function(context, firstTime) {
180
+ render: function (context) {
181
181
  var content = this.get('content'),
182
- key, val,
182
+ val,
183
183
  menu = this.get('parentMenu'),
184
184
  itemWidth = this.get('itemWidth') || menu.layout.width,
185
- itemHeight = this.get('itemHeight') || SC.DEFAULT_MENU_ITEM_HEIGHT ;
186
- this.set('itemWidth',itemWidth);
187
- this.set('itemHeight',itemHeight);
185
+ itemHeight = this.get('itemHeight') || SC.DEFAULT_MENU_ITEM_HEIGHT;
186
+
187
+ this.set('itemWidth', itemWidth);
188
+ this.set('itemHeight', itemHeight);
188
189
 
189
190
  //addressing accessibility
190
191
  if (this.get('isSeparator')) {
@@ -237,19 +238,19 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
237
238
  @param {String} the source path of the image
238
239
  @returns {void}
239
240
  */
240
- renderImage: function(context, image) {
241
+ renderImage: function (context, image) {
241
242
  // get a class name and url to include if relevant
242
243
 
243
- var url, className ;
244
+ var url, className;
244
245
  if (image && SC.ImageView.valueIsUrl(image)) {
245
- url = image ;
246
- className = '' ;
246
+ url = image;
247
+ className = '';
247
248
  } else {
248
- className = image ;
249
+ className = image;
249
250
  url = SC.BLANK_IMAGE_URL;
250
251
  }
251
252
  // generate the img element...
252
- context.begin('img').addClass('image').addClass(className).setAttr('src', url).end() ;
253
+ context.begin('img').addClass('image').addClass(className).setAttr('src', url).end();
253
254
  },
254
255
 
255
256
  /** @private
@@ -261,11 +262,11 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
261
262
  @returns {void}
262
263
  */
263
264
 
264
- renderLabel: function(context, label) {
265
+ renderLabel: function (context, label) {
265
266
  if (this.get('escapeHTML')) {
266
- label = SC.RenderContext.escapeHTML(label) ;
267
+ label = SC.RenderContext.escapeHTML(label);
267
268
  }
268
- context.push("<span class='value ellipsis'>"+label+"</span>") ;
269
+ context.push("<span class='value ellipsis'>" + label + "</span>");
269
270
  },
270
271
 
271
272
  /** @private
@@ -275,8 +276,8 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
275
276
  @param {SC.RenderContext} context the render context
276
277
  @returns {void}
277
278
  */
278
- renderBranch: function(context) {
279
- context.push('<span class="has-branch"></span>') ;
279
+ renderBranch: function (context) {
280
+ context.push('<span class="has-branch"></span>');
280
281
  },
281
282
 
282
283
  /** @private
@@ -287,19 +288,19 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
287
288
  @param {String} the shortcut key string to be displayed with menu item name
288
289
  @returns {void}
289
290
  */
290
- renderShortcut: function(context, shortcut) {
291
- context.push('<span class = "shortcut">' + shortcut + '</span>') ;
291
+ renderShortcut: function (context, shortcut) {
292
+ context.push('<span class = "shortcut">' + shortcut + '</span>');
292
293
  },
293
294
 
294
295
  /**
295
296
  This method will check whether the current Menu Item is still
296
297
  selected and then create a submenu accordingly.
297
298
  */
298
- showSubMenu: function() {
299
- var subMenu = this.get('subMenu') ;
300
- if(subMenu) {
299
+ showSubMenu: function () {
300
+ var subMenu = this.get('subMenu');
301
+ if (subMenu) {
301
302
  subMenu.set('mouseHasEntered', NO);
302
- subMenu.popup(this,[0,0,0]) ;
303
+ subMenu.popup(this, [0, 0, 0]);
303
304
  }
304
305
 
305
306
  this._subMenuTimer = null;
@@ -312,17 +313,17 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
312
313
  @type String
313
314
  @observes content.title
314
315
  */
315
- title: function() {
316
+ title: function () {
316
317
  var ret = this.getContentProperty('itemTitleKey'),
317
318
  localize = this.getPath('parentMenu.localize');
318
319
 
319
320
  if (localize && ret) ret = SC.String.loc(ret);
320
321
 
321
- return ret||'';
322
+ return ret || '';
322
323
  }.property('content.title').cacheable(),
323
324
 
324
325
  /** @private */
325
- getContentProperty: function(property) {
326
+ getContentProperty: function (property) {
326
327
  var content = this.get('content'),
327
328
  menu = this.get('parentMenu');
328
329
 
@@ -337,7 +338,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
337
338
  //
338
339
 
339
340
  /** @private */
340
- mouseUp: function(evt) {
341
+ mouseUp: function (evt) {
341
342
  // SproutCore's event system will deliver the mouseUp event to the view
342
343
  // that got the mouseDown event, but for menus we want to track the mouse,
343
344
  // so we'll do our own dispatching.
@@ -346,7 +347,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
346
347
  targetMenuItem = this.getPath('parentMenu.rootMenu.targetMenuItem');
347
348
 
348
349
  if (targetMenuItem) targetMenuItem.performAction();
349
- return YES ;
350
+ return YES;
350
351
  },
351
352
 
352
353
  /** @private
@@ -358,7 +359,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
358
359
 
359
360
  @returns {Boolean}
360
361
  */
361
- performAction: function() {
362
+ performAction: function () {
362
363
  // Clicking on a disabled menu item should close the menu.
363
364
  if (!this.get('isEnabled')) {
364
365
  this.getPath('parentMenu.rootMenu').remove();
@@ -395,7 +396,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
395
396
  /** @private
396
397
  Actually sends the action of the menu item to the target.
397
398
  */
398
- sendAction: function() {
399
+ sendAction: function () {
399
400
  var action = this.getContentProperty('itemActionKey'),
400
401
  target = this.getContentProperty('itemTargetKey'),
401
402
  rootMenu = this.getPath('parentMenu.rootMenu'),
@@ -415,7 +416,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
415
416
  // Legacy support for actions that are functions
416
417
  if (SC.typeOf(action) === SC.T_FUNCTION) {
417
418
  action.apply(target, [rootMenu]);
418
- //@if(debug)
419
+ //@if (debug)
419
420
  SC.Logger.warn('Support for menu item action functions has been deprecated. Please use target and action.');
420
421
  //@endif
421
422
  } else {
@@ -437,7 +438,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
437
438
  track of how many flashes have occurred, and calls itself until a maximum
438
439
  has been reached.
439
440
  */
440
- flashHighlight: function() {
441
+ flashHighlight: function () {
441
442
  var flashCounter = this._flashCounter, layer = this.$();
442
443
  if (flashCounter % 2 === 0) {
443
444
  layer.addClass('focus');
@@ -452,12 +453,12 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
452
453
  },
453
454
 
454
455
  /** @private*/
455
- mouseDown: function(evt) {
456
- return YES ;
456
+ mouseDown: function (evt) {
457
+ return YES;
457
458
  },
458
459
 
459
460
  /** @private */
460
- mouseEntered: function(evt) {
461
+ mouseEntered: function (evt) {
461
462
  var menu = this.get('parentMenu'),
462
463
  rootMenu = menu.get('rootMenu');
463
464
 
@@ -474,17 +475,17 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
474
475
  this.becomeFirstResponder();
475
476
  }
476
477
 
477
- if(this.get('hasSubMenu')) {
478
- this._subMenuTimer = this.invokeLater(this.showSubMenu, 100) ;
478
+ if (this.get('hasSubMenu')) {
479
+ this._subMenuTimer = this.invokeLater(this.showSubMenu, 100);
479
480
  }
480
481
 
481
- return YES;
482
+ return YES;
482
483
  },
483
484
 
484
485
  /** @private
485
486
  Set the focus based on whether the current menu item is selected or not.
486
487
  */
487
- mouseExited: function(evt) {
488
+ mouseExited: function (evt) {
488
489
  var parentMenu, timer;
489
490
 
490
491
  // If we have a submenu, we need to give the user's mouse time to get
@@ -506,32 +507,32 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
506
507
  }
507
508
  }
508
509
 
509
- return YES ;
510
+ return YES;
510
511
  },
511
512
 
512
513
  /** @private */
513
- touchStart: function(evt){
514
+ touchStart: function (evt) {
514
515
  this.mouseEntered(evt);
515
516
  return YES;
516
517
  },
517
518
 
518
519
  /** @private */
519
- touchEnd: function(evt){
520
+ touchEnd: function (evt) {
520
521
  return this.mouseUp(evt);
521
522
  },
522
523
 
523
524
  /** @private */
524
- touchEntered: function(evt){
525
+ touchEntered: function (evt) {
525
526
  return this.mouseEntered(evt);
526
527
  },
527
528
 
528
529
  /** @private */
529
- touchExited: function(evt){
530
+ touchExited: function (evt) {
530
531
  return this.mouseExited(evt);
531
532
  },
532
533
 
533
534
  /** @private */
534
- checkMouseLocation: function() {
535
+ checkMouseLocation: function () {
535
536
  var subMenu = this.get('subMenu'), parentMenu = this.get('parentMenu'),
536
537
  currentMenuItem, previousMenuItem;
537
538
 
@@ -552,30 +553,30 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
552
553
  /** @private
553
554
  Call the moveUp function on the parent Menu
554
555
  */
555
- moveUp: function(sender,evt) {
556
- var menu = this.get('parentMenu') ;
557
- if(menu) {
558
- menu.moveUp(this) ;
556
+ moveUp: function (sender, evt) {
557
+ var menu = this.get('parentMenu');
558
+ if (menu) {
559
+ menu.moveUp(this);
559
560
  }
560
- return YES ;
561
+ return YES;
561
562
  },
562
563
 
563
564
  /** @private
564
565
  Call the moveDown function on the parent Menu
565
566
  */
566
- moveDown: function(sender,evt) {
567
- var menu = this.get('parentMenu') ;
568
- if(menu) {
569
- menu.moveDown(this) ;
567
+ moveDown: function (sender, evt) {
568
+ var menu = this.get('parentMenu');
569
+ if (menu) {
570
+ menu.moveDown(this);
570
571
  }
571
- return YES ;
572
+ return YES;
572
573
  },
573
574
 
574
575
  /** @private
575
576
  Call the function to create a branch
576
577
  */
577
- moveRight: function(sender,evt) {
578
- this.showSubMenu() ;
578
+ moveRight: function (sender, evt) {
579
+ this.showSubMenu();
579
580
  return YES;
580
581
  },
581
582
 
@@ -583,7 +584,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
583
584
  Proxies insertText events to the parent menu so items can be selected
584
585
  by typing their titles.
585
586
  */
586
- insertText: function(chr, evt) {
587
+ insertText: function (chr, evt) {
587
588
  var menu = this.get('parentMenu');
588
589
  if (menu) {
589
590
  menu.insertText(chr, evt);
@@ -591,60 +592,60 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
591
592
  },
592
593
 
593
594
  /** @private*/
594
- keyDown: function(evt) {
595
- return this.interpretKeyEvents(evt) ;
595
+ keyDown: function (evt) {
596
+ return this.interpretKeyEvents(evt);
596
597
  },
597
598
 
598
599
  /** @private*/
599
- keyUp: function(evt) {
600
- return YES ;
600
+ keyUp: function (evt) {
601
+ return YES;
601
602
  },
602
603
 
603
604
  /** @private*/
604
- cancel: function(evt) {
605
+ cancel: function (evt) {
605
606
  this.getPath('parentMenu.rootMenu').remove();
606
- return YES ;
607
+ return YES;
607
608
  },
608
609
 
609
610
  /** @private*/
610
- didBecomeFirstResponder: function(responder) {
611
+ didBecomeFirstResponder: function (responder) {
611
612
  if (responder !== this) return;
612
- var parentMenu = this.get('parentMenu') ;
613
- if(parentMenu) {
614
- parentMenu.set('currentSelectedMenuItem', this) ;
613
+ var parentMenu = this.get('parentMenu');
614
+ if (parentMenu) {
615
+ parentMenu.set('currentSelectedMenuItem', this);
615
616
  }
616
617
  },
617
618
 
618
619
  /** @private*/
619
- willLoseFirstResponder: function(responder) {
620
+ willLoseFirstResponder: function (responder) {
620
621
  if (responder !== this) return;
621
- var parentMenu = this.get('parentMenu') ;
622
- if(parentMenu) {
623
- parentMenu.set('currentSelectedMenuItem', null) ;
624
- parentMenu.set('previousSelectedMenuItem', this) ;
622
+ var parentMenu = this.get('parentMenu');
623
+ if (parentMenu) {
624
+ parentMenu.set('currentSelectedMenuItem', null);
625
+ parentMenu.set('previousSelectedMenuItem', this);
625
626
  }
626
627
  },
627
628
 
628
629
  /** @private*/
629
- insertNewline: function(sender, evt) {
630
- this.mouseUp(evt) ;
630
+ insertNewline: function (sender, evt) {
631
+ this.mouseUp(evt);
631
632
  },
632
633
 
633
634
  /**
634
635
  Close the parent Menu and remove the focus of the current Selected
635
636
  Menu Item
636
637
  */
637
- closeParent: function() {
638
- this.$().removeClass('focus') ;
639
- var menu = this.get('parentMenu') ;
640
- if(menu) {
641
- menu.remove() ;
638
+ closeParent: function () {
639
+ this.$().removeClass('focus');
640
+ var menu = this.get('parentMenu');
641
+ if (menu) {
642
+ menu.remove();
642
643
  }
643
644
  },
644
645
 
645
646
  /** @private*/
646
- clickInside: function(frame, evt) {
647
- return SC.pointInRect({ x: evt.pageX, y: evt.pageY }, frame) ;
647
+ clickInside: function (frame, evt) {
648
+ return SC.pointInRect({ x: evt.pageX, y: evt.pageY }, frame);
648
649
  },
649
650
 
650
651
 
@@ -656,19 +657,19 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
656
657
  Add an observer to ensure that we invalidate our cached properties
657
658
  whenever the content object’s associated property changes.
658
659
  */
659
- contentDidChange: function() {
660
+ contentDidChange: function () {
660
661
  var content = this.get('content'),
661
662
  oldContent = this._content;
662
663
 
663
- if (content === oldContent) return ;
664
+ if (content === oldContent) return;
664
665
 
665
666
  var f = this.contentPropertyDidChange;
666
667
  // remove an observer from the old content if necessary
667
- if (oldContent && oldContent.removeObserver) oldContent.removeObserver('*', this, f) ;
668
+ if (oldContent && oldContent.removeObserver) oldContent.removeObserver('*', this, f);
668
669
 
669
670
  // add observer to new content if necessary.
670
- this._content = content ;
671
- if (content && content.addObserver) content.addObserver('*', this, f) ;
671
+ this._content = content;
672
+ if (content && content.addObserver) content.addObserver('*', this, f);
672
673
 
673
674
  // notify that value did change.
674
675
  this.contentPropertyDidChange(content, '*') ;
@@ -679,31 +680,31 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
679
680
  Invalidate our cached property whenever the content object’s associated
680
681
  property changes.
681
682
  */
682
- contentPropertyDidChange: function(target, key) {
683
+ contentPropertyDidChange: function (target, key) {
683
684
  // If the key that changed in the content is one of the fields for which
684
685
  // we (potentially) cache a value, update our cache.
685
- var menu = this.get('parentMenu') ;
686
- if (!menu) return ;
686
+ var menu = this.get('parentMenu');
687
+ if (!menu) return;
687
688
 
688
689
  var mapping = SC.MenuItemView._contentPropertyToMenuItemPropertyMapping,
689
690
  contentProperties = SC.keys(mapping),
690
- i, len, contentProperty, menuItemProperty ;
691
+ i, len, contentProperty, menuItemProperty;
691
692
 
692
693
 
693
694
  // Are we invalidating all keys?
694
695
  if (key === '*') {
695
696
  for (i = 0, len = contentProperties.length; i < len; ++i) {
696
- contentProperty = contentProperties[i] ;
697
- menuItemProperty = mapping[contentProperty] ;
698
- this.notifyPropertyChange(menuItemProperty) ;
697
+ contentProperty = contentProperties[i];
698
+ menuItemProperty = mapping[contentProperty];
699
+ this.notifyPropertyChange(menuItemProperty);
699
700
  }
700
701
  }
701
702
  else {
702
703
  for (i = 0, len = contentProperties.length; i < len; ++i) {
703
- contentProperty = contentProperties[i] ;
704
+ contentProperty = contentProperties[i];
704
705
  if (menu.get(contentProperty) === key) {
705
- menuItemProperty = mapping[contentProperty] ;
706
- this.notifyPropertyChange(menuItemProperty) ;
706
+ menuItemProperty = mapping[contentProperty];
707
+ this.notifyPropertyChange(menuItemProperty);
707
708
 
708
709
  // Note: We won't break here in case the menu is set up to map
709
710
  // multiple properties to the same content key.
@@ -712,7 +713,7 @@ SC.MenuItemView = SC.View.extend(SC.ContentDisplay,
712
713
  }
713
714
  }
714
715
 
715
- }) ;
716
+ });
716
717
 
717
718
 
718
719
  // ..........................................................