sproutcore 1.6.0.1 → 1.7.1.beta

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 (143) hide show
  1. data/CHANGELOG +21 -0
  2. data/Gemfile +5 -0
  3. data/Rakefile +26 -13
  4. data/VERSION.yml +2 -2
  5. data/lib/Buildfile +43 -4
  6. data/lib/buildtasks/build.rake +10 -0
  7. data/lib/buildtasks/helpers/file_rule.rb +22 -0
  8. data/lib/buildtasks/helpers/file_rule_list.rb +137 -0
  9. data/lib/buildtasks/manifest.rake +133 -122
  10. data/lib/frameworks/sproutcore/CHANGELOG.md +69 -2
  11. data/lib/frameworks/sproutcore/apps/tests/english.lproj/strings.js +1 -0
  12. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -22
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -5
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +1 -1
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js +18 -13
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +5 -3
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +2 -0
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +80 -0
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +84 -116
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +8 -5
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +157 -157
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +5 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +6 -6
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +10 -7
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +106 -0
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +18 -0
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +71 -1
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/attribute_bindings_test.js +38 -0
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +47 -0
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +18 -18
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +42 -10
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +26 -1
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +14 -8
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +158 -1
  35. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +15 -2
  36. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +108 -108
  37. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -4
  39. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +2 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +26 -0
  41. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +7 -0
  42. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +1 -1
  43. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +4 -1
  44. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +6 -0
  45. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +26 -5
  46. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +97 -96
  47. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -3
  48. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +17 -4
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +7 -7
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +7 -5
  51. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +12 -3
  52. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +23 -14
  53. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +5 -1
  54. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +28 -0
  55. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +235 -0
  56. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +363 -0
  57. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +250 -0
  58. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +92 -0
  59. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +25 -0
  60. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +33 -0
  61. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +76 -0
  62. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +50 -0
  63. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +143 -0
  64. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +258 -0
  65. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +1164 -0
  66. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +332 -0
  67. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +236 -0
  68. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +347 -0
  69. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +15 -0
  70. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +10 -0
  71. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +804 -0
  72. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +133 -0
  73. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +3 -3
  74. data/lib/frameworks/sproutcore/frameworks/foundation/validators/number.js +3 -1
  75. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +3 -3
  76. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +2 -1
  77. data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +2 -1
  78. data/lib/frameworks/sproutcore/frameworks/media/views/media_slider.js +2 -4
  79. data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +2 -4
  80. data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +2 -4
  81. data/lib/frameworks/sproutcore/frameworks/media/views/video.js +2 -2
  82. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +29 -3
  83. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  84. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +1 -1
  85. data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +2 -1
  86. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
  87. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -2
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +1 -1
  89. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
  90. data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/segmented.css +1 -1
  91. data/lib/gen/app/templates/apps/@target_name@/Buildfile +3 -5
  92. data/lib/gen/app/templates/apps/@target_name@/resources/_theme.css +18 -0
  93. data/lib/gen/project/templates/@filename@/Buildfile +2 -2
  94. data/lib/sproutcore/builders/chance_file.rb +9 -16
  95. data/lib/sproutcore/builders/html.rb +2 -1
  96. data/lib/sproutcore/builders/minify.rb +4 -35
  97. data/lib/sproutcore/builders/module.rb +38 -1
  98. data/lib/sproutcore/builders/split.rb +63 -0
  99. data/lib/sproutcore/builders/strings.rb +7 -1
  100. data/lib/sproutcore/builders.rb +1 -0
  101. data/lib/sproutcore/helpers/css_split.rb +190 -0
  102. data/lib/sproutcore/helpers/entry_sorter.rb +2 -0
  103. data/lib/sproutcore/helpers/minifier.rb +40 -16
  104. data/lib/sproutcore/helpers/static_helper.rb +35 -17
  105. data/lib/sproutcore/helpers.rb +1 -1
  106. data/lib/sproutcore/models/manifest.rb +26 -0
  107. data/lib/sproutcore/models/target.rb +12 -1
  108. data/lib/sproutcore/rack/proxy.rb +244 -225
  109. data/lib/sproutcore/rack/restrict_ip.rb +67 -0
  110. data/lib/sproutcore/rack/service.rb +8 -2
  111. data/lib/sproutcore/rack.rb +1 -0
  112. data/lib/sproutcore/tools/build.rb +91 -43
  113. data/lib/sproutcore/tools/gen.rb +2 -3
  114. data/lib/sproutcore/tools/manifest.rb +22 -16
  115. data/lib/sproutcore/tools/server.rb +21 -0
  116. data/lib/sproutcore/tools.rb +102 -46
  117. data/lib/sproutcore.rb +30 -5
  118. data/spec/buildtasks/helpers/accept_list +22 -0
  119. data/spec/buildtasks/helpers/accept_list.rb +128 -0
  120. data/spec/buildtasks/helpers/list.json +11 -0
  121. data/spec/buildtasks/manifest/prepare_build_tasks/chance_2x_spec.rb +1 -39
  122. data/spec/buildtasks/manifest/prepare_build_tasks/chance_spec.rb +0 -38
  123. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +4 -4
  124. data/spec/buildtasks/manifest/prepare_build_tasks/module_spec.rb +2 -2
  125. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_indirect_spec.rb +7 -16
  126. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_spec.rb +7 -17
  127. data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +11 -6
  128. data/spec/fixtures/builder_tests/Buildfile +2 -1
  129. data/spec/fixtures/builder_tests/apps/module_test/modules/required_module/core.js +0 -0
  130. data/spec/lib/builders/module_spec.rb +1 -1
  131. data/spec/spec_helper.rb +1 -0
  132. data/sproutcore.gemspec +4 -9
  133. data/vendor/chance/lib/chance/factory.rb +45 -0
  134. data/vendor/chance/lib/chance/instance/data_url.rb +0 -29
  135. data/vendor/chance/lib/chance/instance/slicing.rb +57 -4
  136. data/vendor/chance/lib/chance/instance/spriting.rb +112 -21
  137. data/vendor/chance/lib/chance/instance.rb +173 -28
  138. data/vendor/chance/lib/chance/parser.rb +80 -52
  139. data/vendor/chance/lib/chance.rb +25 -6
  140. data/vendor/sproutcore/SCCompiler.jar +0 -0
  141. data/vendor/sproutcore/lib/args4j-2.0.12.jar +0 -0
  142. data/vendor/sproutcore/lib/yuicompressor-2.4.2.jar +0 -0
  143. metadata +97 -38
@@ -0,0 +1,347 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // Portions ©2008-2011 Apple Inc. All rights reserved.
5
+ // License: Licensed under MIT license (see license.js)
6
+ // ==========================================================================
7
+
8
+ sc_require('views/core_scroller');
9
+
10
+ /** @class
11
+ Implements a custom desktop-like scroller view that handles
12
+ your basic scrollbar events:
13
+
14
+ - Arrow buttons for incremental scrolling in either direction.
15
+ - Clicking in the track to incrementally jump to a location.
16
+ - CTL+Click to jump immediately to a location.
17
+ - A draggable scroll thumb.
18
+
19
+ @extends SC.CoreScrollerView
20
+ @since SproutCore 1.6
21
+ */
22
+ SC.DesktopScrollerView = SC.CoreScrollerView.extend(
23
+ /** @scope SC.DesktopScrollerView.prototype */{
24
+
25
+ /**
26
+ @type String
27
+ @default 'desktopScrollerRenderDelegate'
28
+ */
29
+ renderDelegateName: 'desktopScrollerRenderDelegate',
30
+
31
+ // ..........................................................
32
+ // MOUSE EVENTS
33
+ //
34
+
35
+ /** @private
36
+ Returns the value for a position within the scroller's frame.
37
+ */
38
+ valueForPosition: function (pos) {
39
+ return ((pos - (this.get('capLength') - this.get('capOverlap'))) /
40
+ (this.get('trackLength') - this.get('thumbLength'))) * this.get('maximum');
41
+ },
42
+
43
+ /** @private
44
+ Handles mouse down events and adjusts the value property depending where
45
+ the user clicked.
46
+
47
+ If the control is disabled, we ignore all mouse input.
48
+
49
+ If the user clicks the thumb, we note the position of the mouse event but
50
+ do not take further action until they begin to drag.
51
+
52
+ If the user clicks the track, we adjust the value a page at a time, unless
53
+ alt is pressed, in which case we scroll to that position.
54
+
55
+ If the user clicks the buttons, we adjust the value by a fixed amount, unless
56
+ alt is pressed, in which case we adjust by a page.
57
+
58
+ If the user clicks and holds on either the track or buttons, those actions
59
+ are repeated until they release the mouse button.
60
+
61
+ @param evt {SC.Event} the mousedown event
62
+ */
63
+ mouseDown: function (evt) {
64
+ if (!this.get('isEnabled')) return NO;
65
+
66
+ var target = evt.target,
67
+ thumbPosition = this.get('thumbPosition'),
68
+ value, clickLocation, clickOffset,
69
+ scrollerLength = this.get('scrollerLength');
70
+
71
+ // Determine the subcontrol that was clicked
72
+ if (target.className.indexOf('thumb') >= 0) {
73
+ // Convert the mouseDown coordinates to the view's coordinates
74
+ clickLocation = this.convertFrameFromView({ x: evt.pageX,
75
+ y: evt.pageY });
76
+
77
+ clickLocation.x -= thumbPosition;
78
+ clickLocation.y -= thumbPosition;
79
+
80
+ // Store the starting state so we know how much to adjust the
81
+ // thumb when the user drags
82
+ this._thumbDragging = YES;
83
+ this._thumbOffset = clickLocation;
84
+ this._mouseDownLocation = { x: evt.pageX,
85
+ y: evt.pageY };
86
+ this._thumbPositionAtDragStart = this.get('thumbPosition');
87
+ this._valueAtDragStart = this.get("value");
88
+
89
+ // User clicked the up/left button; decrement the value by a fixed amount or page size
90
+ } else if (target.className.indexOf('button-top') >= 0) {
91
+ this.decrementProperty('value', 30);
92
+ this.makeButtonActive('.button-top');
93
+
94
+ // start a timer that will continue to fire until mouseUp is called
95
+ this.startMouseDownTimer('scrollUp');
96
+ this._isScrollingUp = YES;
97
+
98
+ // User clicked the down/right button; increment the value by a fixed amount
99
+ } else if (target.className.indexOf('button-bottom') >= 0) {
100
+ this.incrementProperty('value', 30);
101
+ this.makeButtonActive('.button-bottom');
102
+
103
+ // start a timer that will continue to fire until mouseUp is called
104
+ this.startMouseDownTimer('scrollDown');
105
+ this._isScrollingDown = YES;
106
+
107
+ // User clicked in the track
108
+ } else {
109
+ var scrollToClick = this.get("shouldScrollToClick"),
110
+ trackLength = this.get('trackLength'),
111
+ thumbLength = this.get('thumbLength'),
112
+ frame = this.convertFrameFromView({ x: evt.pageX, y: evt.pageY }),
113
+ mousePosition;
114
+
115
+ if (evt.altKey) scrollToClick = !scrollToClick;
116
+
117
+ switch (this.get('layoutDirection')) {
118
+ case SC.LAYOUT_VERTICAL:
119
+ this._mouseDownLocation = mousePosition = frame.y;
120
+ break;
121
+ case SC.LAYOUT_HORIZONTAL:
122
+ this._mouseDownLocation = mousePosition = frame.x;
123
+ break;
124
+ }
125
+
126
+ if (scrollToClick) {
127
+ this.set('value', this.valueForPosition(mousePosition - (thumbLength / 2)));
128
+
129
+ // and start a normal mouse down
130
+ thumbPosition = this.get('thumbPosition');
131
+
132
+ this._thumbDragging = YES;
133
+ this._thumbOffset = { x: frame.x - thumbPosition,
134
+ y: frame.y - thumbPosition };
135
+ this._mouseDownLocation = { x: evt.pageX,
136
+ y: evt.pageY };
137
+ this._thumbPositionAtDragStart = thumbPosition;
138
+ this._valueAtDragStart = this.get("value");
139
+
140
+ // Move the thumb up or down a page depending on whether the click
141
+ // was above or below the thumb
142
+ } else if (mousePosition < thumbPosition) {
143
+ this.decrementProperty('value', scrollerLength);
144
+ this.startMouseDownTimer('page');
145
+
146
+ } else {
147
+ this.incrementProperty('value', scrollerLength);
148
+ this.startMouseDownTimer('page');
149
+ }
150
+ }
151
+
152
+ return YES;
153
+ },
154
+
155
+ /** @private
156
+ When the user releases the mouse button, remove any active
157
+ state from the button controls, and cancel any outstanding
158
+ timers.
159
+
160
+ @param evt {SC.Event} the mousedown event
161
+ */
162
+ mouseUp: function (evt) {
163
+ var active = this._scs_buttonActive,
164
+ ret = NO, timer;
165
+
166
+ // If we have an element that was set as active in mouseDown,
167
+ // remove its active state
168
+ if (active) {
169
+ active.removeClass('active');
170
+ ret = YES;
171
+ }
172
+
173
+ // Stop firing repeating events after mouseup
174
+ timer = this._mouseDownTimer;
175
+ if (timer) {
176
+ timer.invalidate();
177
+ this._mouseDownTimer = null;
178
+ }
179
+
180
+ this._thumbDragging = NO;
181
+ this._isScrollingDown = NO;
182
+ this._isScrollingUp = NO;
183
+
184
+ return ret;
185
+ },
186
+
187
+ /** @private
188
+ If the user began the drag on the thumb, we calculate the difference
189
+ between the mouse position at click and where it is now. We then
190
+ offset the thumb by that amount, within the bounds of the track.
191
+
192
+ If the user began scrolling up/down using the buttons, this will track
193
+ what component they are currently over, changing the scroll direction.
194
+
195
+ @param evt {SC.Event} the mousedragged event
196
+ */
197
+ mouseDragged: function (evt) {
198
+ var value, length, delta, thumbPosition,
199
+ target = evt.target,
200
+ thumbPositionAtDragStart = this._thumbPositionAtDragStart,
201
+ isScrollingUp = this._isScrollingUp,
202
+ isScrollingDown = this._isScrollingDown,
203
+ active = this._scs_buttonActive,
204
+ timer;
205
+
206
+ // Only move the thumb if the user clicked on the thumb during mouseDown
207
+ if (this._thumbDragging) {
208
+ switch (this.get('layoutDirection')) {
209
+ case SC.LAYOUT_VERTICAL:
210
+ delta = (evt.pageY - this._mouseDownLocation.y);
211
+ break;
212
+ case SC.LAYOUT_HORIZONTAL:
213
+ delta = (evt.pageX - this._mouseDownLocation.x);
214
+ break;
215
+ }
216
+
217
+ thumbPosition = thumbPositionAtDragStart + delta;
218
+ length = this.get('trackLength') - this.get('thumbLength');
219
+ this.set('value', Math.round( (thumbPosition/length) * this.get('maximum')));
220
+
221
+ } else if (isScrollingUp || isScrollingDown) {
222
+ var nowScrollingUp = NO, nowScrollingDown = NO;
223
+
224
+ var topButtonRect = this.$('.button-top')[0].getBoundingClientRect();
225
+ var bottomButtonRect = this.$('.button-bottom')[0].getBoundingClientRect();
226
+
227
+ switch (this.get('layoutDirection')) {
228
+ case SC.LAYOUT_VERTICAL:
229
+ nowScrollingUp = (evt.clientY < topButtonRect.bottom);
230
+ break;
231
+ case SC.LAYOUT_HORIZONTAL:
232
+ nowScrollingUp = (evt.clientX < topButtonRect.right);
233
+ break;
234
+ }
235
+ nowScrollingDown = !nowScrollingUp;
236
+
237
+ if ((nowScrollingUp || nowScrollingDown) && nowScrollingUp !== isScrollingUp) {
238
+ // If we have an element that was set as active in mouseDown,
239
+ // remove its active state
240
+ if (active) active.removeClass('active');
241
+
242
+ // Stop firing repeating events after mouseup
243
+ this._mouseDownTimerAction = nowScrollingUp ? "scrollUp" : "scrollDown";
244
+
245
+ if (nowScrollingUp) {
246
+ this.makeButtonActive('.button-top');
247
+ } else if (nowScrollingDown) {
248
+ this.makeButtonActive('.button-bottom');
249
+ }
250
+
251
+ this._isScrollingUp = nowScrollingUp;
252
+ this._isScrollingDown = nowScrollingDown;
253
+ }
254
+ }
255
+
256
+ return YES;
257
+ },
258
+
259
+ mouseWheel: function (evt) {
260
+ var el = this.getPath('parentView.containerView.layer'),
261
+ rawEvent = evt.originalEvent;
262
+
263
+ if (el && rawEvent) {
264
+ try {
265
+ if (SC.typeOf(el.fireEvent) === SC.T_FUNCTION) { // IE
266
+ el.fireEvent(rawEvent.type, rawEvent);
267
+ } else { // W3C
268
+ el.dispatchEvent(rawEvent);
269
+ }
270
+ } catch (x) {
271
+ // Can't dispatch the event; give up.
272
+ }
273
+ }
274
+ },
275
+
276
+ /** @private
277
+ Starts a timer that fires after 300ms. This is called when the user
278
+ clicks a button or inside the track to move a page at a time. If they
279
+ continue holding the mouse button down, we want to repeat that action
280
+ after a small delay. This timer will be invalidated in mouseUp.
281
+
282
+ Specify "immediate" as YES if it should not wait.
283
+ */
284
+ startMouseDownTimer: function (action, immediate) {
285
+ this._mouseDownTimerAction = action;
286
+ this._mouseDownTimer = SC.Timer.schedule({
287
+ target: this,
288
+ action: this.mouseDownTimerDidFire,
289
+ interval: immediate ? 0 : 300
290
+ });
291
+ },
292
+
293
+ /** @private
294
+ Called by the mousedown timer. This method determines the initial
295
+ user action and repeats it until the timer is invalidated in mouseUp.
296
+ */
297
+ mouseDownTimerDidFire: function () {
298
+ var scrollerLength = this.get('scrollerLength'),
299
+ mouseLocation = SC.device.get('mouseLocation'),
300
+ thumbPosition = this.get('thumbPosition'),
301
+ thumbLength = this.get('thumbLength'),
302
+ timerInterval = 50;
303
+
304
+ switch (this.get('layoutDirection')) {
305
+ case SC.LAYOUT_VERTICAL:
306
+ mouseLocation = this.convertFrameFromView(mouseLocation).y;
307
+ break;
308
+ case SC.LAYOUT_HORIZONTAL:
309
+ mouseLocation = this.convertFrameFromView(mouseLocation).x;
310
+ break;
311
+ }
312
+
313
+ switch (this._mouseDownTimerAction) {
314
+ case 'scrollDown':
315
+ this.incrementProperty('value', 30);
316
+ break;
317
+ case 'scrollUp':
318
+ this.decrementProperty('value', 30);
319
+ break;
320
+ case 'page':
321
+ timerInterval = 150;
322
+ if (mouseLocation < thumbPosition) {
323
+ this.decrementProperty('value', scrollerLength);
324
+ } else if (mouseLocation > thumbPosition+thumbLength) {
325
+ this.incrementProperty('value', scrollerLength);
326
+ }
327
+ }
328
+
329
+ this._mouseDownTimer = SC.Timer.schedule({
330
+ target: this,
331
+ action: this.mouseDownTimerDidFire,
332
+ interval: timerInterval
333
+ });
334
+ },
335
+
336
+ /** @private
337
+ Given a selector, finds the corresponding DOM element and adds
338
+ the 'active' class name. Also stores the returned element so that
339
+ the 'active' class name can be removed during mouseup.
340
+
341
+ @param {String} the selector to find
342
+ */
343
+ makeButtonActive: function (selector) {
344
+ this._scs_buttonActive = this.$(selector).addClass('active');
345
+ }
346
+
347
+ });
@@ -0,0 +1,15 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+
7
+ sc_require('views/desktop/scroll');
8
+ sc_require('views/touch/scroll');
9
+
10
+ SC.ScrollView = SC.platform.touch ? SC.TouchScrollView : SC.DesktopScrollView;
11
+
12
+ // Spoofed browsers should use TouchScrollView.
13
+ if (SC.browser && SC.platform && SC.browser.mobileSafari && !SC.platform.touch) {
14
+ SC.ScrollView = SC.TouchScrollView;
15
+ }
@@ -0,0 +1,10 @@
1
+ // ==========================================================================
2
+ // Project: SproutCore - JavaScript Application Framework
3
+ // Copyright: ©2006-2011 Strobe Inc. and contributors.
4
+ // License: Licensed under MIT license (see license.js)
5
+ // ==========================================================================
6
+
7
+ sc_require('views/desktop/scroller');
8
+
9
+ // Legacy ScrollerView === DesktopScrollerView
10
+ SC.ScrollerView = SC.DesktopScrollerView;