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
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDA3N2VhZDM4N2JjNjQyMzFiMzM5MWQ5OTc1MDkyZWJmNjU2OWRkMg==
4
+ MzljNWViZTUxOTllNmJmYjllOWU4MmMyMTk4Mzk5YjhiM2MyM2JjYw==
5
5
  data.tar.gz: !binary |-
6
- Y2EzNWNiN2M0NzI2OTYyM2UzN2M4MDQ0ZTMyNzQ2Mzc2Y2U1OTY4Yg==
6
+ OWM0MmI4YmIwMGQ4ZTM2NmFhOTk1NTRmZWQ2ZjFmYzJmZWY3NTk0Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YTRjNzY4ZjRkYjZiYjBiZjU0MjI2NGI4ZmE4ZTYzMzE3MDNiNjJhYzk0OWE0
10
- NzhhN2MxNWQ5NzAwNzU3OTlhOGM1YjFlZTY0ODg2ZTE0ZTI0MTczMWQyZWVh
11
- MThmNjc5MjMxYzBmYzVkZTE5OWZmZjNiMzhkNGZjM2UyZjQ4OWM=
9
+ ZDlkNzk0OWMyZTNjYzk2NjdlZmZmYjdkMmZjNjQ2ZGI4N2NhOWEzZmNhZTg5
10
+ YjA2OTQxMjVjNTc2OWYxOGI2ZWEyN2U1OTIwMmU5NDkwNWMzYWRlMTVkODcx
11
+ ZTgxNzI0MWIxMTU2NmRjYzIwMjJjOTEzMjI2OTMzNjNkNmQ2YzQ=
12
12
  data.tar.gz: !binary |-
13
- MDc1MGQzMWM1YzljMDJhNTcyZGFlMjQwNDQxZDI5ZGMzZjg3M2FmN2UyNzZm
14
- YjZmZGQ4YjA0NjU0OGYxMjZkOGI3ZDZjOGVhZmU5NDFmMjczMzdmOWZmNmNi
15
- MDAwMzQ0NjJjNDEyMGNhYjc5NDhmNDIxYTBmMDhkYTBlZjMzZDE=
13
+ NDQyZGYxMTMxMTQ1YmJjZjZlMGZmZDNjNGQyZDE4MGYyMzhiZWViNWE5Mjdi
14
+ MjhjODE1N2M0ZDE1NTY1NGI4YTc4MTVkNTljMmNmOTIxZTVlMzIwODNkMjYy
15
+ N2Q2M2ZhZTM5ZGNkMTVlMzcyNTc1NGM4NGE2NGI4YzlhMDBiZmI=
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ SproutCore 1.11.0.rc3
2
+ -----------------
3
+
4
+ * Updated the dependency requirements for compass, haml & sass to avoid exceptions running on Ruby 2.
5
+
6
+ SproutCore 1.11.0.rc2
7
+ -----------------
8
+
9
+ * No changes.
10
+
1
11
  SproutCore 1.11.0.rc1
2
12
  -----------------
3
13
 
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 11
4
- :patch: 0.rc2
4
+ :patch: 0.rc3
@@ -1,6 +1,120 @@
1
1
  CHANGE LOG
2
2
  ==========
3
3
 
4
+ Edge
5
+ -----------
6
+
7
+ ### NEW FEATURES
8
+ ### CHANGES & IMPROVEMENTS
9
+ ### DEPRECATIONS & REMOVALS
10
+ ### BUG FIXES
11
+
12
+ 1.11.0.rc3
13
+ -----------
14
+
15
+ ### NEW FEATURES
16
+
17
+ * *SC.NestedStore*
18
+
19
+ `SC.NestedStore` has a new property, `conflictedStoreKeys`, which is an array of all store keys that currently have conflicts with the nested store's parent. A conflict in a nested store can occur when the data in the parent store changes *after* the nested store has accessed and modified it.
20
+
21
+ For instance, in a multi-user system where records can be edited by multiple people at the same time, the client may use polling or websockets to update the records in the main store asynchronously in the background. With such a scenario it would be possible for the current user to be editing a record that someone else has changed in the meantime. If the client attempted to commit the changes from the nested store it would get an exception because of the conflict. Instead, the developer can now check the value of `conflictedStoreKeys` and if it is `null`, then commit the changes and if it is an array of store keys, then they know which records have conflicts and can deal with them directly.
22
+
23
+ * *SC.Binding*
24
+
25
+ There are two new binding transforms, `string` and `integer`, that ensure the value is *always* a `String` or an integer `Number`. Examples include returning an empty `String` for `null` or `undefined` values when using the `string` transform and returning a 0 for these same values when using the `integer` transform. Furthermore, if the `integer` transform is given a String, it will be parsed to an integer `Number` according to the extra argument `radix` (which is 10 by default).
26
+
27
+ There is also a new binding transform, `mix`, that allows for the aggregation of multiple bound properties into a single property through a given function. It is often the case that a single property depends on two or more bound properties in a complex manner that isn't handled by the current `and` and `or` transforms. To handle this situation previously, the developer would need to write the code to bind in the external property values and then make a local computed property dependent on each of these. The `mix` transform does exactly the same thing, but with less typing on the developer's part.
28
+
29
+ For example, to create a mix binding that concatenates two external properties in a non-trivial way, we can now do the following,
30
+
31
+ currentGroupUserLabel: SC.LabelView.extend({
32
+
33
+ // Ex. Returns one of "", "Selected Group", or "Selected Group: Selected User"
34
+ valueBinding: SC.Binding.mix(
35
+ 'MyApp.groupController.name', // The group name (may be null).
36
+ 'MyApp.userController.fullName', // The user full name (may be null).
37
+
38
+ // Aggregate function. The arguments match the bound property values above.
39
+ function (groupName, userFullName) {
40
+ if (SC.none(userFullName)) {
41
+ if (SC.none(groupName)) {
42
+ return ''; // No group and no user. Ex. ""
43
+ } else {
44
+ return groupName; // Just a group. Ex. "Selected Group"
45
+ }
46
+ } else {
47
+ return '%@: %@'.fmt(groupName, userFullName); // Group and user. Ex. "Selected Group: Selected User"
48
+ }
49
+ })
50
+
51
+ })
52
+
53
+ * *Updated Description* Scale is now a first-class layout property, correctly impacting `frame` and `clippingFrame`. If a view is scaled, the width & height of the frame will be correct as the view appears. For example, a view with layout equal to `{ width: 100, height: 100, scale: 2 }` will report a frame of `{ x: 0, y: 0, width: 200, height: 200, scale: 2 }`. The scale also takes a scaling origin into account as well and as part of this change, there are two new layout properties: `transformOriginX` and `transformOriginY`, which define the percentage (between 0.0 and 1.0) on the respective axis about which the scale transform is applied. These properties affect all transform styles and so can be used to also change the origin of a rotate style.
54
+
55
+ ### CHANGES & IMPROVEMENTS
56
+
57
+ * Documentation
58
+
59
+ ** Added lots of documentation to `SC.Request` (examples), `SC.Query` (local vs. remote) and `SC.DateTime` (`adjust` and `advance`).
60
+ ** Cleaned up documentation of all protocols, including a warning not to mix in protocols and fixed some problems that prevented some protocols from being properly generated on docs.sproutcore.com.
61
+ ** Added `SC.ObjectMixinProtocol` with documentation on using mixins with `SC.Object` as well as the methods `initMixin` and `destroyMixin` that are supported.
62
+ ** Added documentation on touch event handling to `SC.ResponderProtocol` (i.e. the protocol that may be implemented by `SC.Responder` subclasses like `SC.View`).
63
+ ** Added/improved documentation on `SC.Gesturable` mixin.
64
+
65
+ * SC.PickerPane
66
+
67
+ This view has been given special behavior when used with SC.View's `transitionIn` plugin support. If the plugin defines `layoutProperties` of either `scale` or `rotate`, then the picker will adjust its transform origin X & Y position to appear to scale or rotate out of the anchor. The result is a very nice effect that picker panes appear to pop out of their anchors.
68
+ To see it in effect, simply set the `transitionIn` property of the pane to one of `SC.View.SCALE_IN` or `SC.View.POP_IN`.
69
+
70
+ * SC.SegmentedView
71
+
72
+ This view was refactored slightly to remove the special overflow view if `shouldHandleOverflow` is `false` (default). Previously the overflow view was always created and appended even if it was not to be used.
73
+
74
+ * The automatically adjusted size component of the layouts of `SC.ListView` and `SC.GridView` have changed to set `height` and `width` instead of `minHeight` and `minWidth` (as it applies). The reason for this change is so that the entire list of items can be GPU accelerated by setting `wantsAcceleratedLayer: true` on the view. GPU accelerated positioning using the `translateX` and `translateY` transforms requires that the view have a fixed position (top & left) and a fixed size (height & width). These views already have a fixed position by default and now by having them adjust their `height` or `width` (depending on the direction), it is possible to accelerate these views by also fixing the other size component (i.e. if the list scrolls vertically, the list will set its height, so the developer needs to set the lists width to a fixed value and then add `wantsAcceleratedLayer: true`).
75
+
76
+ Test Results:
77
+
78
+ With min-height (i.e. can't accelerate): With height (and accelerated):
79
+
80
+ JS Function: ~5.9ms JS Function: ~5.9ms
81
+ Recalc. Style: ~0.3ms Recalc. Style: ~0.3ms
82
+ Layout: ~0.3ms Update Layer Tree: ~0.2ms
83
+ Update Layer Tree: ~0.2ms Composite Layers: ~0.3ms
84
+ Paint: ~2.4ms
85
+ Composite Layers: ~0.3ms
86
+ Update Layer Tree: ~0.1ms
87
+ Paint x 8: ~6.0ms
88
+
89
+ *How does this affect your code?*
90
+ Because lists and grids have an implied layout of `{ top: 0, bottom: 0, left: 0, right: 0 }`, they used to always stretch to fill their parent containing view. This is no longer the case and so a collection with too few items to fill the containing view will only be as tall or as wide as its items warrant. This will affect any background styles that were applied to the collection (such as the Ace theme did), which previously would have covered the whole containing view's background. Unfortunately, those background styles need to be moved to the style of the containing view in order to prevent any styling regressions after updating to this new version.
91
+
92
+ Therefore, to go along with this change the `background: white` style in the Ace theme that was applied to `$theme.collection` has been moved to `$theme.sc-scroll-view`. It has also been changed to `background-color: white`, which is less likely to conflict with other background styles.
93
+
94
+ *How do I check for style regressions?*
95
+ To ensure that any background styles applied to your collections still look correct, you should do a search through your stylesheets for `.collection` and move any custom background styles over to an `.sc-scroll-view` class.
96
+
97
+ * The SC.Binding transforms `and` and `or` have been refactored to use the new `mix` code. This means that you can now pass more than two property paths to these transforms.
98
+
99
+ For example,
100
+
101
+ isEnabledBinding: SC.Binding.and('.hasValue', '.valueIsValid', '.userIsAllowed')
102
+
103
+ ### DEPRECATIONS & REMOVALS
104
+
105
+ * The `isPaneAttached` property of SC.Pane has been deprecated. This property is identical to the existing `isAttached` property of SC.View that SC.Pane extends and so `isPaneAttached` is not needed. Please use `isAttached` instead.
106
+
107
+ Note: This deprecation will show a console warning in debug (i.e. non-production) mode.
108
+
109
+ ### BUG FIXES
110
+
111
+ * Added code to prevent a possible issue that could occur when animating to an implied layout position. For instance, if a view has a layout set to `{ top: 5 }`, the implied layout is actually `{ top: 5, right: 0, bottom: 0, left: 0 }`. The issue that could arise is if the code tried to animate to an implied value (ex. `view.animate('left', 0, { duration: 1 }, callbackFunc)`), the animation wouldn't actually need to run and the callback function would fail to fire.
112
+ * Fixed possible issues that may occur when code altered child views in any of the view state callback functions: `didCreateLayer`, `didAppendToDocument`, `didHideInDocument`, `didShowInDocument`. The issue was that the callback functions were called on the parent before the child was updated to the proper new state. For example, if a developer set the visibility of a child view to false in `didCreateLayer`, at that point the child view would have still been in an unrendered state and optimizations preventing visibility changes to unrendered views would have meant the visibility change would have been lost.
113
+ * Fixed an issue that could occur when using temporary IDs with newly created records. Because the `id` property is a computed property, once it has been read (i.e. `myNewRecord.get('id')`), it will remain cached for any further reads. This can become an issue in situations where the ID of the record changes after being saved to the server. For instance, a new record may be given a temporary ID when it is created and the temporary id may be accessed via `get`. After that record is saved to the server, a call to `store.dataSourceDidComplete(RecordType, newBody, newBody.id)` would properly update the `id` value in the store, but would fail to clear the record instance's cache of `id`. Therefore, a successive call to `get('id')` would return the old value.
114
+ * Fixed an issue with observing the `selection` property of `SC.TextFieldView`. Since the `input` element doesn't update its `selectionStart` and `selectionEnd` values until after the event execution completes, the mouse and keypress event handlers that affect the selection must wait until after the run loop before notifying that the selection property has changed.
115
+ * `SC.RootResponder` mistook two successive mousedown events at the same point as a double click even if the target of the second mousedown was different. The result was that if a view moved suddenly on a first click, a second immediate click at the same point would try to call `doubleClick` on the new target view instead of just `mouseUp`.
116
+ * Fixed a regression in SC.CollectionView that prevented double clicks from triggering the action. Closes #1304 & #1305.
117
+
4
118
  1.11.0.rc2
5
119
  -----------
6
120
 
@@ -75,7 +189,6 @@ These new properties can be used by an `SC.Response` subclass to include allowin
75
189
 
76
190
  ### CHANGES & IMPROVEMENTS
77
191
 
78
- * Scale is now a first-class layout function, correctly impacting frame and clippingFrame. As a result, scaled content within a CollectionView will now correctly calculate which item views should be currently visible.
79
192
  * SC.ScrollView complete refactor:
80
193
  * If `horizontalOverlay` or `verticalOverlay` is true, it will use `SC.OverlayScrollerView` by default. It's no longer necessary to also set `horizontalScrollerView: SC.OverlayScrollerView` in order to get overlaid scrollers.
81
194
  * Use SC.ScrollView's horizontalAlign and verticalAlign properties to align fixed-width or -height content.
@@ -54,13 +54,7 @@ Showcase.ViewsItemView = SC.View.extend({
54
54
  exampleBox: SC.ContainerView.design({
55
55
  classNames: ['example-box'],
56
56
  layoutBinding: SC.Binding.oneWay('.parentView.exampleLayout'),
57
- nowShowingBinding: SC.Binding.oneWay('.parentView.content.exampleView'),
58
- replaceContent: function(newContent) {
59
- // SC.ContainerView needs its awake function to be called to be correctly initialized.
60
- newContent.awake();
61
-
62
- sc_super();
63
- }
57
+ nowShowingBinding: SC.Binding.oneWay('.parentView.content.exampleView')
64
58
  }),
65
59
 
66
60
  supportButton: SC.ButtonView.design({
@@ -14,24 +14,24 @@ Showcase.ViewsListView = SC.ListView.extend({
14
14
 
15
15
  classNames: ['views-list-view'],
16
16
 
17
- customRowHeightIndexes: function() {
17
+ customRowSizeIndexes: function() {
18
18
  var content = this.get('content'),
19
- customRowHeightIndexes = SC.IndexSet.create();
19
+ customRowSizeIndexes = SC.IndexSet.create();
20
20
 
21
21
  for (var i = content.get('length') - 1; i >= 0; i--) {
22
22
  if (content.objectAt(i).get('isShowingSnippet')) {
23
- customRowHeightIndexes.add(i, 1);
23
+ customRowSizeIndexes.add(i, 1);
24
24
  }
25
25
  }
26
26
 
27
- return customRowHeightIndexes;
28
- }.property().idempotent(),
27
+ return customRowSizeIndexes;
28
+ }.property(),
29
29
 
30
30
  exampleHeight: 120,
31
31
 
32
32
  exampleView: Showcase.ViewsItemView,
33
33
 
34
- itemHeight: function() {
34
+ rowSize: function() {
35
35
  var exampleHeight = this.get('exampleHeight');
36
36
 
37
37
  return exampleHeight + 120;
@@ -45,8 +45,8 @@ Showcase.ViewsListView = SC.ListView.extend({
45
45
  return null; // select all
46
46
  },
47
47
 
48
- contentIndexRowHeight: function(view, content, contentIndex) {
49
- return this.get('rowHeight') + 180;
48
+ contentIndexRowSize: function(view, content, contentIndex) {
49
+ return this.get('rowSize') + 180;
50
50
  },
51
51
 
52
52
  createItemView: function(exampleClass, idx, attrs) {
@@ -61,7 +61,7 @@ Showcase.ViewsListView = SC.ListView.extend({
61
61
 
62
62
  var content = this.content;
63
63
  for (var i = content.get('length') - 1; i >= 0; i--) {
64
- content.objectAt(i).addObserver('isShowingSnippet', this, this._sclv_customRowHeightIndexesDidChange);
64
+ content.objectAt(i).addObserver('isShowingSnippet', this, this._sc_customRowSizeIndexesContentDidChange);
65
65
  }
66
66
  }
67
67
 
@@ -10,13 +10,175 @@ sc_require('system/response');
10
10
  /**
11
11
  @class
12
12
 
13
- Implements support for Ajax requests using XHR, XHR 2 and other protocols.
13
+ Implements support for AJAX requests using XHR, XHR2 and other protocols.
14
14
 
15
- SC.Request is much like an inverted version of the request/response objects
16
- you receive when implementing HTTP servers.
15
+ SC.Request is essentially a client version of the request/response objects you receive when
16
+ implementing HTTP servers.
17
17
 
18
- To send a request, you just need to create your request object, configure
19
- your options, and call send() to initiate the request.
18
+ To send a request, you just need to create your request object, configure your options, and call
19
+ `send()` to initiate the request. The request will be added to the pending request queue managed
20
+ by `SC.Request.manager`.
21
+
22
+ For example,
23
+
24
+ // Create a simple XHR request.
25
+ var request = SC.Request.create();
26
+ request.set('address', resourceAddress);
27
+ request.set('type', 'GET');
28
+ request.send();
29
+
30
+ The previous example will create an XHR GET request to `resourceAddress`. Because the `address`
31
+ and `type` of the request must be set on every request, there are helper methods on `SC.Request`
32
+ that you will likely use in every situation.
33
+
34
+ For example, the previous example can be written more concisely as,
35
+
36
+ // Create a simple XHR request.
37
+ var request = SC.Request.getUrl(resourceAddress);
38
+
39
+ There are four other helper methods to cover the other common HTTP method types: `POST`, `DELETE`,
40
+ `PUT` and `PATCH`, which are `postUrl`, `deleteUrl`, `putUrl` and `patchUrl` respectively. Since
41
+ you may also send a body with `POST`, `PUT` and `PATCH` requests, those helper methods also take a
42
+ second argument `body` (which is analogous to calling `request.set('body', body)`).
43
+
44
+ ## Responses
45
+
46
+ ### XHR Requests & Custom Communication Protocols
47
+
48
+ By default, the request will create an instance of `SC.XHRResponse` in order to complete the
49
+ request. As the name implies, the `SC.XHRResponse` class will make an XHR request to the server,
50
+ which is the typical method that the SproutCore client will communicate with remote endpoints.
51
+
52
+ In order to use a custom response type handler, you should extend `SC.Response` and set the
53
+ `responseClass` of the request to your custom response type.
54
+
55
+ For example,
56
+
57
+ var request = SC.Request.getUrl(resourceAddress).set('responseClass', MyApp.CustomProtocolResponse);
58
+
59
+
60
+ ### Handling Responses
61
+
62
+ `SC.Request` supports multiple response handlers based on the status code of the response. This
63
+ system is quite intelligent and allows for specific callbacks to handle specific status codes
64
+ (e.g. 404) or general status codes (e.g. 400) or combinations of both. Callbacks are registered
65
+ using the `notify` method, which accepts a `target` and a `method` which will be called when the
66
+ request completes. The most basic example of registering a general response handler would be like
67
+ so,
68
+
69
+ // The response handler target (typically a state or controller or some such SC.Object instance).
70
+ var targetObject;
71
+
72
+ targetObject = SC.Object.create({
73
+
74
+ handleResponse: function (response) {
75
+ // Handle the various possible status codes.
76
+ var status = response.get('status');
77
+ if (status === 200) { // 200 OK
78
+ // Do something.
79
+ } else if (status < 400) { // i.e. 3xx
80
+ // Do something.
81
+ } else ...
82
+ }
83
+
84
+ });
85
+
86
+
87
+ // Create a simple XHR request.
88
+ var request;
89
+
90
+ request = SC.Request.getUrl(resourceAddress)
91
+ .notify(targetObject, 'handleResponse')
92
+ .send();
93
+
94
+ However, this approach requires that every response handler be able to handle all of the possible
95
+ error codes that we may be able to handle in a more general manner. It's also more code for us
96
+ to write to write all of the multiple condition statements. For this reason, the `notify` method
97
+ accepts an optional status code argument *before* the target and method. You can use a generic
98
+ status code (i.e. 400) or a specific status code (i.e. 404). If you use a generic status code, all
99
+ statuses within that range will result in that callback being used.
100
+
101
+ For example, here is a more specific example,
102
+
103
+ // The response handler target (typically a data source or state or some such SC.Object instance).
104
+ var targetObject;
105
+
106
+ targetObject = SC.Object.create({
107
+
108
+ gotOK: function (response) { // 2xx Successful
109
+ // Do something.
110
+
111
+ return true; // Return true to ensure that any following generic handlers don't run!
112
+ },
113
+
114
+ gotForbidden: function (response) { // 403 Forbidden
115
+ // Do something.
116
+
117
+ return true; // Return true to ensure that any following generic handlers don't run!
118
+ },
119
+
120
+ gotUnknownError: function (response) { // 3xx, 4xx (except 403), 5xx
121
+ // Do something.
122
+ }
123
+
124
+ });
125
+
126
+
127
+ // Create a simple XHR request.
128
+ var request;
129
+
130
+ request = SC.Request.getUrl(resourceAddress)
131
+ .notify(200, targetObject, 'gotOK')
132
+ .notify(403, targetObject, 'gotForbidden')
133
+ .notify(targetObject, 'gotUnknownError')
134
+ .send();
135
+
136
+ Please note that the notifications will fall through in the order they are added if not handled.
137
+ This means that the generic handler `gotUnknownError` will be called for any responses not caught
138
+ by the other handlers. In this example, to ensure that `gotUnknownError` doesn't get called when a
139
+ 2xx or 403 response comes in, those handlers *return `true`*.
140
+
141
+ Please also note that this design allows us to easily re-use handler methods. For example, we may
142
+ choose to have `gotUnknownError` be the standard last resort fallback handler for all requests.
143
+
144
+ For more examples, including handling of XHR2 progress events, please @see SC.Request.prototype.notify.
145
+
146
+ ### Response Bodies & JSON Decoding
147
+
148
+ The body of the response is the `body` property on the response object which is passed to the
149
+ notify target method. For example,
150
+
151
+ gotOK: function (response) { // 2xx Successful
152
+ var body = response.get('body');
153
+
154
+ // Do something.
155
+
156
+ return true; // Return true to ensure that any following generic handlers don't run!
157
+ },
158
+
159
+ The type of the body will depend on what the server returns, but since it will typically be JSON,
160
+ we have a built-in option to have the body be decoded into a JavaScript object automatically by
161
+ setting `isJSON` to true on the request.
162
+
163
+ For example,
164
+
165
+ // Create a simple XHR request.
166
+ var request;
167
+
168
+ request = SC.Request.getUrl(resourceAddress)
169
+ .set('isJSON', true)
170
+ .notify(200, targetObject, 'gotOK')
171
+ .send();
172
+
173
+ There is a helper method to achieve this as well, `json()`,
174
+
175
+ // Create a simple XHR request.
176
+ var request;
177
+
178
+ request = SC.Request.getUrl(resourceAddress)
179
+ .json() // Set `isJSON` to true.
180
+ .notify(200, targetObject, 'gotOK')
181
+ .send();
20
182
 
21
183
  @extends SC.Object
22
184
  @extends SC.Copyable
@@ -6,15 +6,24 @@
6
6
  // ==========================================================================
7
7
  /*global ActiveXObject */
8
8
 
9
- /*
10
- TODO Document SC.Response and SC.XHRResponse
11
- */
12
-
13
9
  /**
14
10
  @class
15
11
 
16
- A response represents a single response from a server request. An instance
17
- of this class is returned whenever you call SC.Request.send().
12
+ A response represents a single response from a server request and handles the communication to
13
+ the server. An instance of this class is returned whenever you call `SC.Request.send()`.
14
+
15
+ SproutCore only defines one concrete subclass of `SC.Response`,`SC.XHRResponse`. In order to
16
+ use `SC.Request` with a non-XHR request type you should create a custom class that extends
17
+ `SC.Response` and set your custom class as the value of `responseClass` on all requests.
18
+
19
+ For example,
20
+
21
+ var request = SC.Request.getUrl(resourceAddress)
22
+ .set('responseClass', MyApp.CustomProtocolResponse)
23
+ .send();
24
+
25
+ To extend `SC.Response`, please look at the property and methods listed below. For more examples,
26
+ please look at the code in `SC.XHRResponse`.
18
27
 
19
28
  @extend SC.Object
20
29
  @since SproutCore 1.0
@@ -168,6 +177,7 @@ SC.Response = SC.Object.extend(
168
177
  */
169
178
  body: function() {
170
179
  // TODO: support XML
180
+ // TODO: why not use the content-type header?
171
181
  var ret = this.get('encodedBody');
172
182
  if (ret && this.get('isJSON')) {
173
183
  try {
@@ -429,8 +439,14 @@ SC.Response = SC.Object.extend(
429
439
  /**
430
440
  @class
431
441
 
432
- Concrete implementation of SC.Response that implements support for using
433
- XHR requests.
442
+ Concrete implementation of `SC.Response` that implements support for using XHR requests. This is
443
+ the default response class that `SC.Request` uses and it is able to create cross-browser
444
+ compatible XHR requests to the address defined on a request and to notify according to the status
445
+ code fallbacks registered on the request.
446
+
447
+ You will not typically deal with this class other than to receive an instance of it when handling
448
+ `SC.Request` responses. For more information on how to create a request and handle an XHR response,
449
+ please @see SC.Request.
434
450
 
435
451
  @extends SC.Response
436
452
  @since SproutCore 1.0