sproutcore 1.11.0.rc2 → 1.11.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +10 -0
  3. data/VERSION.yml +1 -1
  4. data/lib/frameworks/sproutcore/CHANGELOG.md +114 -1
  5. data/lib/frameworks/sproutcore/apps/showcase/views/views_item_view.js +1 -7
  6. data/lib/frameworks/sproutcore/apps/showcase/views/views_list_view.js +9 -9
  7. data/lib/frameworks/sproutcore/frameworks/ajax/system/request.js +167 -5
  8. data/lib/frameworks/sproutcore/frameworks/ajax/system/response.js +24 -8
  9. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/stack_layout.js +737 -0
  10. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/layout.js +0 -6
  11. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +11 -7
  12. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane_statechart.js +7 -11
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/child_view_layout_protocol.js +8 -3
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/observable_protocol.js +9 -6
  15. data/lib/frameworks/sproutcore/frameworks/{desktop/protocols/responder.js → core_foundation/protocols/responder_protocol.js} +83 -17
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/{sparse_array_delegate.js → sparse_array_delegate_protocol.js} +11 -7
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/protocols/view_transition_protocol.js +11 -6
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/color.js +2 -2
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +0 -22
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +61 -56
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/main_pane.js +2 -2
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/pane/append_remove.js +3 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/animation.js +63 -39
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/border_frame_test.js +28 -28
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/createLayer.js +10 -4
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layout.js +102 -1
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutDidChange.js +4 -4
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +103 -103
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/replaceAllChildren_test.js +1 -1
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +77 -1
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view_states_test.js +18 -17
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +42 -49
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/animation.js +5 -6
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/enabled.js +16 -5
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +241 -102
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +1 -4
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/manipulation.js +0 -11
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/statechart.js +993 -610
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/theming.js +3 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +6 -11
  41. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +94 -27
  42. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +133 -53
  43. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +30 -35
  44. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +3 -2
  45. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/writeDataHash.js +73 -29
  46. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/conflictedStoreKeys_test.js +156 -0
  47. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +61 -37
  48. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/store/find.js +2 -2
  49. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +68 -39
  50. data/lib/frameworks/sproutcore/frameworks/designer/tests/coders/page.js +1 -2
  51. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +8 -6
  52. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +80 -14
  53. data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +2 -2
  54. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_data_source.js → drag_data_source_protocol.js} +16 -10
  55. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drag_source.js → drag_source_protocol.js} +28 -26
  56. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/{drop_target.js → drop_target_protocol.js} +73 -75
  57. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -4
  58. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/panel/ui.js +39 -23
  59. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +120 -97
  60. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowSizeForContentIndex.js +26 -25
  61. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +3 -3
  62. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +5 -0
  63. data/lib/frameworks/sproutcore/frameworks/desktop/tests/views/split/{dividers.js → dividers_test.js} +38 -38
  64. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +29 -14
  65. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +2 -1
  66. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll_view.js +13 -18
  67. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +41 -35
  68. data/lib/frameworks/sproutcore/frameworks/desktop/views/slider.js +14 -14
  69. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +41 -26
  70. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +2 -12
  71. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +2 -2
  72. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +14 -10
  73. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/gesturable.js +104 -63
  74. data/lib/frameworks/sproutcore/frameworks/foundation/protocols/swap_transition_protocol.js +9 -4
  75. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_mixin_tests.js +1 -2
  76. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/auto_resize_test.js +33 -33
  77. data/lib/frameworks/sproutcore/frameworks/foundation/tests/transitions/view_transitions_test.js +5 -5
  78. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/methods.js +0 -4
  79. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/transition_test.js +0 -4
  80. data/lib/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +0 -2
  81. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +12 -8
  82. data/lib/frameworks/sproutcore/frameworks/media/resources/silence.mp3 +0 -0
  83. data/lib/frameworks/sproutcore/frameworks/media/tests/audio.js +69 -0
  84. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +1 -0
  85. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  86. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +11 -4
  87. data/lib/frameworks/sproutcore/frameworks/runtime/protocols/mixin_protocol.js +150 -0
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +447 -137
  89. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +9 -15
  90. data/lib/frameworks/sproutcore/frameworks/runtime/system/set.js +19 -17
  91. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +188 -16
  92. data/lib/frameworks/sproutcore/frameworks/statechart/system/state.js +1 -1
  93. data/lib/frameworks/sproutcore/frameworks/template_view/panes/template.js +0 -3
  94. data/lib/frameworks/sproutcore/frameworks/template_view/tests/panes/template.js +0 -17
  95. data/lib/frameworks/sproutcore/frameworks/template_view/tests/views/template/collection.js +43 -26
  96. data/lib/frameworks/sproutcore/frameworks/template_view/views/bindable_span.js +9 -2
  97. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list.css +0 -1
  98. data/lib/frameworks/sproutcore/themes/ace/resources/scroll/scroll.css +3 -0
  99. data/sproutcore.gemspec +3 -3
  100. metadata +19 -17
  101. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/horizontal_stack_layout.js +0 -465
  102. data/lib/frameworks/sproutcore/frameworks/core_foundation/child_view_layouts/vertical_stack_layout.js +0 -472
  103. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build.js +0 -87
  104. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/build_children.js +0 -89
@@ -225,6 +225,14 @@ SC.PICKER_MENU_POINTER = 'menu-pointer';
225
225
 
226
226
  Positioning: SC.POSITION_BOTTOM (3) > SC.POSITION_RIGHT (0) > SC.POSITION_LEFT (1) > SC.POSITION_TOP (2). Fallback to SC.POSITION_BOTTOM (3).
227
227
 
228
+ ### Transition-In Special Handling
229
+
230
+ This view has special behavior when used with SC.View's `transitionIn` plugin support. If the
231
+ plugin defines `layoutProperties` of either `scale` or `rotate`, then the picker will adjust its
232
+ transform origin X & Y position to appear to scale or rotate out of the anchor. The result is a
233
+ very nice effect that picker panes appear to pop out of their anchors. To see it in effect,
234
+ simply set the `transitionIn` property of the pane to one of `SC.View.SCALE_IN` or `SC.View.POP_IN`.
235
+
228
236
  @extends SC.PalettePane
229
237
  @since SproutCore 1.0
230
238
  */
@@ -538,10 +546,11 @@ SC.PickerPane = SC.PalettePane.extend(
538
546
 
539
547
  /* @private If the pane changes size, reposition as necessary. */
540
548
  viewDidResize: function () {
541
- this.positionPane(true);
542
-
543
549
  // Don't forget to call the superclass method.
544
550
  sc_super();
551
+
552
+ // Re-position.
553
+ this.positionPane(true);
545
554
  },
546
555
 
547
556
  /**
@@ -624,22 +633,79 @@ SC.PickerPane = SC.PalettePane.extend(
624
633
  // frames, add those properties.
625
634
  anchor.halfWidth = parseInt(anchor.width * 0.5, 0);
626
635
  anchor.halfHeight = parseInt(anchor.height * 0.5, 0);
627
- frame.halfWidth = parseInt(frame.originalWidth * 0.5, 0);
628
- frame.halfHeight = parseInt(frame.originalHeight * 0.5, 0);
636
+
637
+ // Don't pollute the borderFrame rect.
638
+ frame = SC.cloneRect(frame);
639
+ frame.halfWidth = parseInt(frame.width * 0.5, 0);
640
+ frame.halfHeight = parseInt(frame.height * 0.5, 0);
629
641
 
630
642
  frame = this.fitPositionToScreen(origin, frame, anchor);
643
+
631
644
  adjustHash = {
632
645
  left: frame.x,
633
- top: frame.y,
634
- width: frame.width,
635
- height: frame.height
646
+ top: frame.y
636
647
  };
637
648
 
649
+ /*
650
+ Special case behavior for transitions that include scale or rotate: notably SC.View.SCALE_IN and SC.View.POP_IN.
651
+
652
+ We make an assumption that the picker should always scale out of the anchor, so we set the
653
+ transform origin accordingly.
654
+ */
655
+ var transitionIn = this.get('transitionIn');
656
+ if (transitionIn && (transitionIn.layoutProperties.indexOf('scale') >= 0 || transitionIn.layoutProperties.indexOf('rotate') >= 0)) {
657
+ var transformOriginX, transformOriginY;
658
+
659
+ switch (preferType) {
660
+ // If the picker uses a pointer, set the origin to the pointer.
661
+ case SC.PICKER_POINTER:
662
+ case SC.PICKER_MENU_POINTER:
663
+ switch (this.get('pointerPos')) {
664
+ case 'perfectTop':
665
+ transformOriginX = (frame.halfWidth + this.get('pointerPosX')) / frame.width;
666
+ transformOriginY = 1;
667
+ break;
668
+ case 'perfectRight':
669
+ transformOriginX = 0;
670
+ transformOriginY = (frame.halfHeight + this.get('pointerPosY')) / frame.height;
671
+ break;
672
+ case 'perfectBottom':
673
+ transformOriginX = (frame.halfWidth + this.get('pointerPosX')) / frame.width;
674
+ transformOriginY = 0;
675
+ break;
676
+ case 'perfectLeft':
677
+ transformOriginX = 1;
678
+ transformOriginY = (frame.halfHeight + this.get('pointerPosY')) / frame.height;
679
+ break;
680
+ }
681
+ break;
682
+
683
+ // If the picker doesn't use a pointer, set the origin to the correct corner.
684
+ case SC.PICKER_MENU:
685
+ case SC.PICKER_FIXED:
686
+ if (frame.x >= anchor.x) {
687
+ transformOriginX = 0;
688
+ } else {
689
+ transformOriginX = 1;
690
+ }
691
+ if (frame.y >= anchor.y) {
692
+ transformOriginY = 0;
693
+ } else {
694
+ transformOriginY = 1;
695
+ }
696
+
697
+ break;
698
+ }
699
+
700
+ adjustHash.transformOriginX = transformOriginX;
701
+ adjustHash.transformOriginY = transformOriginY;
702
+ }
703
+
638
704
  // Adjust.
639
705
  this.adjust(adjustHash);
640
- }
706
+
641
707
  // if no anchor view has been set for some reason, just center.
642
- else {
708
+ } else {
643
709
  this.adjust({
644
710
  centerX: 0,
645
711
  centerY: 0
@@ -886,10 +952,10 @@ SC.PickerPane = SC.PalettePane.extend(
886
952
  [anchorFrame.x + anchorFrame.width + offset[0], anchorFrame.y + anchorFrame.halfHeight - frame.halfHeight],
887
953
 
888
954
  // Top left [x, y] if positioned evenly to the left of the anchor
889
- [anchorFrame.x - frame.originalWidth + offset[1], anchorFrame.y + anchorFrame.halfHeight - frame.halfHeight],
955
+ [anchorFrame.x - frame.width + offset[1], anchorFrame.y + anchorFrame.halfHeight - frame.halfHeight],
890
956
 
891
957
  // Top left [x, y] if positioned evenly above the anchor
892
- [anchorFrame.x + anchorFrame.halfWidth - frame.halfWidth, anchorFrame.y - frame.originalHeight + offset[2]],
958
+ [anchorFrame.x + anchorFrame.halfWidth - frame.halfWidth, anchorFrame.y - frame.height + offset[2]],
893
959
 
894
960
  // Top left [x, y] if positioned evenly below the anchor
895
961
  [anchorFrame.x + anchorFrame.halfWidth - frame.halfWidth, anchorFrame.y + anchorFrame.height + offset[3]]
@@ -1038,8 +1104,7 @@ SC.PickerPane = SC.PalettePane.extend(
1038
1104
 
1039
1105
  }
1040
1106
 
1041
- // If no arrangement was found to fit, then use the fall back preferred
1042
- // type.
1107
+ // If no arrangement was found to fit, then use the fall back preferred type.
1043
1108
  if (i === pointerLen) {
1044
1109
  if (matrix[4] === -1) {
1045
1110
  frame.x = anchorFrame.x + anchorFrame.halfWidth;
@@ -1216,7 +1281,7 @@ SC.PickerPane = SC.PalettePane.extend(
1216
1281
  },
1217
1282
 
1218
1283
  remove: function () {
1219
- if (this.get('isVisibleInWindow') && this.get('isPaneAttached')) {
1284
+ if (this.get('isVisibleInWindow')) {
1220
1285
  this._withdrawOverflowRequest();
1221
1286
  }
1222
1287
  this._removeScrollObservers();
@@ -1334,6 +1399,7 @@ SC.PickerPane = SC.PalettePane.extend(
1334
1399
  this._anchorHTMLElement = null;
1335
1400
  return sc_super();
1336
1401
  }
1402
+
1337
1403
  });
1338
1404
 
1339
1405
 
@@ -36,8 +36,8 @@ SC.SheetPane = SC.PanelPane.extend(
36
36
 
37
37
  /**
38
38
  @type {Array}
39
- @default {['sc-sheet']}
40
- @see {SC.View#classNames}
39
+ @default ['sc-sheet']
40
+ @see SC.View#classNames
41
41
  */
42
42
  classNames: ['sc-sheet'],
43
43
 
@@ -5,16 +5,22 @@
5
5
  // License: Licensed under MIT license (see license.js)
6
6
  // ==========================================================================
7
7
 
8
- sc_require('system/drag') ;
8
+ sc_require('system/drag');
9
9
 
10
- /**
11
- @namespace
10
+ /** @namespace
11
+ The `SC.DragDataSourceProtocol` protocol defines the properties and methods that you may implement
12
+ in your drag source objects in order to access additional functionality of SproutCore's drag
13
+ support.
12
14
 
13
- This protocol implements a dynamic data source for a drag operation. You can
14
- return a set of allowed data types and then the method will be used to
15
- actually get data in that format when requested.
15
+ This protocol implements a dynamic data source for a drag operation. You should use it to return a
16
+ set of allowed data types and then the method will be used to actually get data in that format
17
+ when requested.
18
+
19
+ *Note: Do not mix `SC.DragDataSourceProtocol` into your classes. As a protocol, it exists only for
20
+ reference sake. You only need define any of the properties or methods listed below in order to use
21
+ this protocol.*
16
22
  */
17
- SC.DragDataSource = {
23
+ SC.DragDataSourceProtocol = {
18
24
 
19
25
  /**
20
26
  Implement this property as an array of data types you want to support
@@ -28,11 +34,11 @@ SC.DragDataSource = {
28
34
  /**
29
35
  Implement this method to return the data in the format passed. Return
30
36
  null if the requested data type cannot be generated.
31
-
37
+
32
38
  @param {SC.Drag} drag The Drag instance managing this drag.
33
- @param {Object} dataType The proposed dataType to return. This will
39
+ @param {Object} dataType The proposed dataType to return. This will
34
40
  always be one of the data types declared in dragDataTypes.
35
-
41
+
36
42
  @returns The data object for the specified type
37
43
  */
38
44
  dragDataForType: function(drag, dataType) {
@@ -7,62 +7,64 @@
7
7
 
8
8
  sc_require('system/drag') ;
9
9
 
10
- /**
11
- @namespace
10
+ /** @namespace
11
+ The `SC.DragSourceProtocol` protocol defines the properties and methods that you may implement in
12
+ your drag source objects in order to access additional functionality of SproutCore's drag support.
12
13
 
13
- If you implement the SC.DragSource protocol on your drag's source, it will
14
- receive a series of callbacks throughout the course of the drag, and be consulted
15
- about what operations to allow on a particular candidate drop target. All methods
16
- are optional.
14
+ If you implement the `SC.DragSourceProtocol` protocol on your drag's source, it will receive a
15
+ series of callbacks throughout the course of the drag, and be consulted about what operations to
16
+ allow on a particular candidate drop target. Note that when you initiate a drag you must also
17
+ provide an object implementing `SC.DragDataSourceProtocol`, which includes some *required*
18
+ methods. A single object may serve as both the drag's source and its data source.
17
19
 
18
- (Note that when you initiate a drag you must also provide an object implementing
19
- SC.DragDataSource, which includes some required methods. A single object may
20
- serve as both the drag's source and its data source.)
20
+ *Note: Do not mix `SC.DragSourceProtocol` into your classes. As a protocol, it exists only for
21
+ reference sake. You only need define any of the properties or methods listed below in order to use
22
+ this protocol.*
21
23
  */
22
- SC.DragSource = {
24
+ SC.DragSourceProtocol = {
23
25
 
24
26
  /**
25
27
  Return a bitwise OR'd mask of the drag operations allowed on the
26
28
  specified target. If you don't care about the target, just return a
27
29
  constant value. If a drag's source does not implement this method,
28
30
  it will assume that any drag operation (SC.DRAG_ANY) is allowed.
29
-
31
+
30
32
  @param {SC.Drag} drag The SC.Drag instance managing this drag.
31
33
  @param {SC.View} dropTarget The proposed target of the drop.
32
34
  */
33
35
  dragSourceOperationMaskFor: function(drag, dropTarget) {
34
36
  return SC.DRAG_ANY;
35
37
  },
36
-
38
+
37
39
  /**
38
40
  If this property is set to `NO` or is not implemented, then the user may
39
- modify the drag operation by changing the modifier keys they have
41
+ modify the drag operation by changing the modifier keys they have
40
42
  pressed.
41
-
43
+
42
44
  @type Boolean
43
45
  @default NO
44
46
  */
45
47
  ignoreModifierKeysWhileDragging: NO,
46
-
48
+
47
49
  /**
48
50
  This method is called when the drag begins. You can use this to do any
49
- visual highlighting to indicate that the receiver is the source of the
51
+ visual highlighting to indicate that the receiver is the source of the
50
52
  drag.
51
-
53
+
52
54
  @param {SC.Drag} drag The Drag instance managing this drag.
53
- @param {Point} loc The point in *window* coordinates where the drag
54
- began. You can use convertOffsetFromView() to convert this to local
55
+ @param {Point} loc The point in *window* coordinates where the drag
56
+ began. You can use convertOffsetFromView() to convert this to local
55
57
  coordinates.
56
58
  */
57
59
  dragDidBegin: function(drag, loc) {},
58
-
60
+
59
61
  /**
60
62
  This method is called whenever the drag image is moved. This is
61
63
  similar to the `dragUpdated()` method called on drop targets.
62
-
64
+
63
65
  @param {SC.Drag} drag The Drag instance managing this drag.
64
- @param {Point} loc The point in *window* coordinates where the drag
65
- mouse is. You can use convertOffsetFromView() to convert this to local
66
+ @param {Point} loc The point in *window* coordinates where the drag
67
+ mouse is. You can use convertOffsetFromView() to convert this to local
66
68
  coordinates.
67
69
  */
68
70
  dragDidMove: function(drag, loc) {},
@@ -90,11 +92,11 @@ SC.DragSource = {
90
92
  @param {DragOp} op Provided for consistency. Always SC.DRAG_NONE.
91
93
  */
92
94
  dragDidCancel: function(drag, loc, op) {},
93
-
95
+
94
96
  /**
95
97
  This method is called when the drag ended, regardless of whether it succeeded
96
98
  or not. You can use this to do any cleanup.
97
-
99
+
98
100
  @param {SC.Drag} drag The drag instance managing the drag.
99
101
  @param {Point} loc The point in WINDOW coordinates where the drag
100
102
  ended.
@@ -108,7 +110,7 @@ SC.DragSource = {
108
110
  to YES, then the drag's ghost view will slide back to its initial location.
109
111
  dragDidEnd is called immediately upon mouseUp; dragSlideBackDidEnd is called
110
112
  after the slide-back animation completes.
111
-
113
+
112
114
  @param {SC.Drag} drag The drag instance managing the drag.
113
115
  */
114
116
  dragSlideBackDidEnd: function(drag) {}
@@ -7,17 +7,12 @@
7
7
 
8
8
  sc_require('system/drag');
9
9
 
10
- /**
11
- @namespace
12
-
13
- Implement the DropTarget protocol in your view to be able to accept drop events. You
14
- should define the methods below as needed to handle accepting of events.
15
-
16
- See the method descriptions for more information on what you need to implement.
17
-
18
- The general call sequence for all drop targets is (in pseudo-Ragel, regex
19
- format):
20
-
10
+ /** @namespace
11
+ The `SC.DropTargetProtocol` protocol defines the properties and methods that you may implement
12
+ in your views in order to act as a drop target for a drag.
13
+
14
+ The general call sequence for all drop targets is (in pseudo-Ragel, regex format):
15
+
21
16
  dragStarted
22
17
  (
23
18
  computeDragOperations+
@@ -30,159 +25,162 @@ sc_require('system/drag');
30
25
  )*
31
26
  )*
32
27
  dragEnded
33
-
34
- Thus, every drop target will have its dragStarted and dragEnded methods called
35
- once during every drag session. computeDragOperations, if called at all, may be
36
- called more than once before the dragEntered method is called. Once dragEntered
37
- is called, you are at guaranteed that both dragUpdated and dragExited will be
38
- called at some point, followed by either dragEnded or additional
39
- computeDragOperation calls.
28
+
29
+ Thus, every drop target will have its `dragStarted` and `dragEnded` methods called once during
30
+ every drag session. `computeDragOperations`, if called at all, may be called more than once before
31
+ the `dragEntered` method is called. Once `dragEntered` is called, you are guaranteed that both
32
+ `dragUpdated` and `dragExited` will be called at some point, followed by either `dragEnded` or
33
+ additional `computeDragOperation` calls.
34
+
35
+ *Note: Do not mix `SC.DropTargetProtocol` into your classes. As a protocol, it exists only for
36
+ reference sake. You only need define any of the properties or methods listed below in order to use
37
+ this protocol.*
40
38
  */
41
- SC.DropTarget = {
42
-
39
+ SC.DropTargetProtocol = {
40
+
43
41
  /**
44
42
  Must be true when your view is instantiated.
45
-
43
+
46
44
  Drop targets must be specially registered in order to receive drop
47
45
  events. SproutCore knows to register your view when this property
48
46
  is true on view creation.
49
-
47
+
50
48
  @type Boolean
51
49
  @default YES
52
50
  @constant
53
- */
51
+ */
54
52
  isDropTarget: YES,
55
53
 
56
54
  /**
57
55
  Called when the drag is started, regardless of where or not your drop
58
56
  target is current. You can use this to highlight your drop target
59
57
  as "eligible".
60
-
58
+
61
59
  The default implementation does nothing.
62
-
60
+
63
61
  @param {SC.Drag} drag The current drag object.
64
- @param {SC.Event} evt The most recent mouse move event. Use to get location
62
+ @param {SC.Event} evt The most recent mouse move event. Use to get location
65
63
  */
66
64
  dragStarted: function(drag, evt) {},
67
-
65
+
68
66
  /**
69
67
  Called when the drag first enters the droppable area, if it returns a
70
68
  drag operations other than `SC.DRAG_NONE`.
71
-
69
+
72
70
  The default implementation does nothing.
73
-
71
+
74
72
  @param drag {SC.Drag} The current drag object.
75
73
  @param evt {SC.Event} The most recent mouse move event. Use to get location
76
74
  */
77
75
  dragEntered: function(drag, evt) {},
78
-
76
+
79
77
  /**
80
78
  Called periodically when a drag is over your droppable area.
81
-
82
- Override this method this to update various elements of the drag state,
83
- including the location of ghost view. You should use this method to
79
+
80
+ Override this method this to update various elements of the drag state,
81
+ including the location of ghost view. You should use this method to
84
82
  implement snapping.
85
-
83
+
86
84
  This method will be called periodically, even if the user is not moving
87
85
  the drag. If you perform expensive operations, be sure to check the
88
86
  mouseLocation property of the drag to determine if you actually need to
89
87
  update anything before doing your expensive work.
90
-
88
+
91
89
  The default implementation does nothing.
92
-
90
+
93
91
  @param {SC.Drag} drag The current drag object.
94
92
  @param {SC.Event} evt The most recent mouse move event. Use to get location
95
93
  */
96
94
  dragUpdated: function(drag, evt) {},
97
-
95
+
98
96
  /**
99
97
  Called when the user exits your droppable area or the drag ends
100
98
  and you were the last targeted droppable area.
101
-
102
- Override this method to perform any clean up on your UI such as hiding
99
+
100
+ Override this method to perform any clean up on your UI such as hiding
103
101
  a special highlight state or removing insertion points.
104
-
102
+
105
103
  The default implementation does nothing.
106
-
104
+
107
105
  @param {SC.Drag} drag The current drag object
108
106
  @param {SC.Event} evt The most recent mouse move event. Use to get location.
109
107
  */
110
108
  dragExited: function(drag, evt) {},
111
-
109
+
112
110
  /**
113
- Called on all drop targets when the drag ends.
114
-
115
- For example, the user might have dragged the view off the screen and let
116
- go or they might have hit escape. Override this method to perform any
111
+ Called on all drop targets when the drag ends.
112
+
113
+ For example, the user might have dragged the view off the screen and let
114
+ go or they might have hit escape. Override this method to perform any
117
115
  final cleanup. This will be called instead of dragExited.
118
-
116
+
119
117
  The default implementation does nothing.
120
-
118
+
121
119
  @param {SC.Drag} drag The current drag object
122
120
  @param {SC.Event} evt The most recent mouse move event. Use to get location.
123
121
  */
124
122
  dragEnded: function(drag, evt) {},
125
-
123
+
126
124
  /**
127
125
  Called when the drag needs to determine which drag operations are
128
126
  valid in a given area.
129
-
130
- Override this method to return an OR'd mask of the allowed drag
131
- operations. If the user drags over a droppable area within another
132
- droppable area, the drag will latch onto the deepest view that returns one
127
+
128
+ Override this method to return an OR'd mask of the allowed drag
129
+ operations. If the user drags over a droppable area within another
130
+ droppable area, the drag will latch onto the deepest view that returns one
133
131
  or more available operations.
134
-
132
+
135
133
  The default implementation returns `SC.DRAG_NONE`
136
-
134
+
137
135
  @param {SC.Drag} drag The current drag object
138
- @param {SC.Event} evt The most recent mouse move event. Use to get
139
- location
136
+ @param {SC.Event} evt The most recent mouse move event. Use to get
137
+ location
140
138
  @param {DragOp} op The proposed drag operation. A drag constant
141
-
142
- @returns {DragOps} A mask of all the drag operations allowed or
139
+
140
+ @returns {DragOps} A mask of all the drag operations allowed or
143
141
  SC.DRAG_NONE
144
142
  */
145
143
  computeDragOperations: function(drag, evt, op) {
146
144
  return SC.DRAG_NONE;
147
145
  },
148
-
146
+
149
147
  /**
150
148
  Called when the user releases the mouse.
151
-
152
- This method gives your drop target one last opportunity to choose to
149
+
150
+ This method gives your drop target one last opportunity to choose to
153
151
  accept the proposed drop operation. You might use this method to
154
152
  perform fine-grained checks on the drop location, for example.
155
153
  Return true to accept the drop operation.
156
-
154
+
157
155
  The default implementation returns `YES`.
158
-
156
+
159
157
  @param {SC.Drag} drag The drag instance managing this drag
160
158
  @param {DragOp} op The proposed drag operation. A drag constant
161
-
159
+
162
160
  @return {Boolean} YES if operation is OK, NO to cancel.
163
- */
161
+ */
164
162
  acceptDragOperation: function(drag, op) {
165
163
  return YES;
166
164
  },
167
-
165
+
168
166
  /**
169
167
  Called to actually perform the drag operation.
170
-
168
+
171
169
  Override this method to actually perform the drag operation. This method
172
- is only called if you returned `YES` in `acceptDragOperation()`.
173
-
174
- Return the operation that was actually performed or `SC.DRAG_NONE` if the
170
+ is only called if you returned `YES` in `acceptDragOperation()`.
171
+
172
+ Return the operation that was actually performed or `SC.DRAG_NONE` if the
175
173
  operation was aborted.
176
-
174
+
177
175
  The default implementation returns `SC.DRAG_NONE`
178
-
176
+
179
177
  @param {SC.Drag} drag The drag instance managing this drag
180
178
  @param {DragOp} op The proposed drag operation. A drag constant.
181
-
179
+
182
180
  @return {DragOp} Drag Operation actually performed
183
181
  */
184
182
  performDragOperation: function(drag, op) {
185
183
  return SC.DRAG_NONE;
186
184
  }
187
-
185
+
188
186
  };