sproutcore 0.9.1 → 0.9.2
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.
- data/History.txt +233 -0
- data/Manifest.txt +67 -34
- data/bin/sc-build +12 -1
- data/bin/sc-gen +1 -1
- data/bin/sproutcore +14 -0
- data/clients/sc_docs/controllers/docs.js +38 -8
- data/clients/sc_docs/english.lproj/body.css +80 -127
- data/clients/sc_docs/english.lproj/body.rhtml +43 -23
- data/clients/sc_docs/english.lproj/no_docs.rhtml +2 -1
- data/clients/sc_docs/english.lproj/tabs.rhtml +16 -0
- data/clients/sc_docs/main.js +14 -9
- data/clients/sc_docs/models/doc.js +1 -1
- data/clients/sc_docs/tests/controllers/docs.rhtml +1 -2
- data/clients/sc_docs/tests/models/doc.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_frame.rhtml +1 -2
- data/clients/sc_docs/tests/views/doc_label_view.rhtml +1 -2
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/controllers/runner.js +31 -8
- data/clients/sc_test_runner/english.lproj/body.css +62 -122
- data/clients/sc_test_runner/english.lproj/body.rhtml +62 -26
- data/clients/sc_test_runner/main.js +1 -6
- data/clients/sc_test_runner/models/test.js +14 -1
- data/clients/sc_test_runner/views/runner_frame.js +4 -2
- data/clients/view_builder/builders/builder.js +339 -0
- data/clients/view_builder/builders/button.js +81 -0
- data/clients/view_builder/controllers/document.js +21 -0
- data/clients/view_builder/core.js +19 -0
- data/clients/view_builder/english.lproj/body.css +77 -0
- data/clients/view_builder/english.lproj/body.rhtml +41 -0
- data/clients/{sc_docs → view_builder}/english.lproj/controls.css +0 -0
- data/clients/view_builder/english.lproj/strings.js +14 -0
- data/clients/view_builder/main.js +38 -0
- data/clients/view_builder/tests/controllers/document.rhtml +20 -0
- data/clients/view_builder/tests/views/builder.rhtml +20 -0
- data/clients/view_builder/views/builder.js +23 -0
- data/frameworks/prototype/prototype.js +1 -1
- data/frameworks/sproutcore/Core.js +32 -7
- data/frameworks/sproutcore/README +1 -1
- data/frameworks/sproutcore/animation/animation.js +411 -0
- data/frameworks/sproutcore/controllers/array.js +17 -9
- data/frameworks/sproutcore/controllers/collection.js +9 -110
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +2 -1
- data/frameworks/sproutcore/drag/drag.js +267 -56
- data/frameworks/sproutcore/drag/drag_data_source.js +24 -16
- data/frameworks/sproutcore/drag/drag_source.js +53 -42
- data/frameworks/sproutcore/drag/drop_target.js +2 -2
- data/frameworks/sproutcore/english.lproj/buttons.css +337 -236
- data/frameworks/sproutcore/english.lproj/core.css +115 -0
- data/frameworks/sproutcore/english.lproj/icons.css +227 -0
- data/{clients/sc_docs → frameworks/sproutcore}/english.lproj/images/indicator.gif +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-sprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/sc-theme-ysprite.png +0 -0
- data/frameworks/sproutcore/english.lproj/images/shared-icons.png +0 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -1
- data/frameworks/sproutcore/english.lproj/strings.js +1 -1
- data/frameworks/sproutcore/english.lproj/theme.css +405 -31
- data/frameworks/sproutcore/foundation/application.js +15 -11
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/binding.js +2 -2
- data/frameworks/sproutcore/foundation/date.js +1 -1
- data/frameworks/sproutcore/foundation/error.js +1 -1
- data/frameworks/sproutcore/foundation/input_manager.js +32 -21
- data/frameworks/sproutcore/foundation/mock.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +9 -6
- data/frameworks/sproutcore/foundation/object.js +249 -177
- data/frameworks/sproutcore/foundation/page.js +5 -2
- data/frameworks/sproutcore/foundation/path_module.js +11 -10
- data/frameworks/sproutcore/foundation/responder.js +5 -2
- data/frameworks/sproutcore/foundation/routes.js +17 -13
- data/frameworks/sproutcore/foundation/run_loop.js +249 -11
- data/frameworks/sproutcore/foundation/server.js +1 -1
- data/frameworks/sproutcore/foundation/set.js +3 -3
- data/frameworks/sproutcore/foundation/string.js +5 -3
- data/frameworks/sproutcore/foundation/timer.js +371 -0
- data/frameworks/sproutcore/foundation/undo_manager.js +1 -1
- data/frameworks/sproutcore/foundation/unittest.js +3 -3
- data/frameworks/sproutcore/foundation/utils.js +161 -2
- data/frameworks/sproutcore/globals/panels.js +1 -1
- data/frameworks/sproutcore/globals/popups.js +4 -3
- data/frameworks/sproutcore/globals/window.js +44 -4
- data/frameworks/sproutcore/lib/button_views.rb +328 -0
- data/frameworks/sproutcore/lib/collection_view.rb +80 -0
- data/frameworks/sproutcore/lib/core_views.rb +281 -0
- data/frameworks/sproutcore/lib/form_views.rb +253 -0
- data/frameworks/sproutcore/lib/index.rhtml +2 -0
- data/frameworks/sproutcore/lib/menu_views.rb +88 -0
- data/frameworks/sproutcore/{foundation → mixins}/array.js +60 -29
- data/frameworks/sproutcore/mixins/control.js +265 -0
- data/frameworks/sproutcore/mixins/delegate_support.js +66 -0
- data/frameworks/sproutcore/{foundation → mixins}/observable.js +176 -6
- data/frameworks/sproutcore/mixins/scrollable.js +245 -0
- data/frameworks/sproutcore/mixins/selection_support.js +148 -0
- data/frameworks/sproutcore/mixins/validatable.js +152 -0
- data/frameworks/sproutcore/models/collection.js +5 -5
- data/frameworks/sproutcore/models/record.js +1 -1
- data/frameworks/sproutcore/models/store.js +1 -1
- data/frameworks/sproutcore/panes/dialog.js +1 -1
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/menu.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +2 -2
- data/frameworks/sproutcore/panes/panel.js +1 -1
- data/frameworks/sproutcore/panes/picker.js +1 -1
- data/frameworks/sproutcore/tests/controllers/array.rhtml +44 -4
- data/frameworks/sproutcore/tests/foundation/timer/invalidate.rhtml +33 -0
- data/frameworks/sproutcore/tests/foundation/timer/invokeLater.rhtml +145 -0
- data/frameworks/sproutcore/tests/foundation/timer/isPaused.rhtml +70 -0
- data/frameworks/sproutcore/tests/foundation/timer/schedule.rhtml +145 -0
- data/frameworks/sproutcore/tests/views/{scroll.rhtml → checkbox.rhtml} +3 -3
- data/frameworks/sproutcore/tests/views/{collection.rhtml → collection/base.rhtml} +33 -32
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +260 -0
- data/frameworks/sproutcore/tests/views/image_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/label_item.rhtml +2 -4
- data/frameworks/sproutcore/tests/views/list.rhtml +2 -3
- data/frameworks/sproutcore/tests/views/list_item.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/slider.rhtml +20 -0
- data/frameworks/sproutcore/tests/views/text_cell.rhtml +19 -0
- data/frameworks/sproutcore/tests/views/view/clippingFrame.rhtml +395 -0
- data/frameworks/sproutcore/tests/views/view/frame.rhtml +353 -0
- data/frameworks/sproutcore/tests/views/view/innerFrame.rhtml +347 -0
- data/frameworks/sproutcore/tests/views/view/isVisibleInWindow.rhtml +148 -0
- data/frameworks/sproutcore/tests/views/view/scrollFrame.rhtml +468 -0
- data/frameworks/sproutcore/validators/credit_card.js +33 -13
- data/frameworks/sproutcore/validators/date.js +26 -6
- data/frameworks/sproutcore/validators/email.js +21 -3
- data/frameworks/sproutcore/validators/not_empty.js +11 -1
- data/frameworks/sproutcore/validators/number.js +18 -4
- data/frameworks/sproutcore/validators/password.js +12 -1
- data/frameworks/sproutcore/validators/validator.js +204 -194
- data/frameworks/sproutcore/views/{button.js → button/button.js} +96 -94
- data/frameworks/sproutcore/views/button/checkbox.js +29 -0
- data/frameworks/sproutcore/views/button/disclosure.js +42 -0
- data/frameworks/sproutcore/views/button/radio.js +29 -0
- data/frameworks/sproutcore/views/{collection.js → collection/collection.js} +1373 -1024
- data/frameworks/sproutcore/views/collection/grid.js +124 -46
- data/frameworks/sproutcore/views/collection/image_cell.js +17 -46
- data/frameworks/sproutcore/views/collection/list.js +45 -35
- data/frameworks/sproutcore/views/collection/source_list.js +386 -0
- data/frameworks/sproutcore/views/collection/table.js +118 -0
- data/frameworks/sproutcore/views/container.js +7 -2
- data/frameworks/sproutcore/views/error_explanation.js +23 -10
- data/frameworks/sproutcore/views/{checkbox_field.js → field/checkbox_field.js} +16 -6
- data/frameworks/sproutcore/views/field/field.js +219 -0
- data/frameworks/sproutcore/views/{radio_field.js → field/radio_field.js} +27 -12
- data/frameworks/sproutcore/views/{select_field.js → field/select_field.js} +116 -90
- data/frameworks/sproutcore/views/{text_field.js → field/text_field.js} +57 -8
- data/frameworks/sproutcore/views/{textarea_field.js → field/textarea_field.js} +13 -3
- data/frameworks/sproutcore/views/filter_button.js +2 -2
- data/frameworks/sproutcore/views/form.js +3 -3
- data/frameworks/sproutcore/views/image.js +128 -21
- data/frameworks/sproutcore/views/inline_text_editor.js +1 -1
- data/frameworks/sproutcore/views/label.js +149 -92
- data/frameworks/sproutcore/views/list_item.js +225 -0
- data/frameworks/sproutcore/views/menu_item.js +10 -4
- data/frameworks/sproutcore/views/pagination.js +11 -4
- data/frameworks/sproutcore/views/popup_button.js +25 -21
- data/frameworks/sproutcore/views/popup_menu.js +10 -4
- data/frameworks/sproutcore/views/progress.js +29 -16
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +60 -20
- data/frameworks/sproutcore/views/segmented.js +1 -1
- data/frameworks/sproutcore/views/slider.js +132 -0
- data/frameworks/sproutcore/views/source_list_group.js +130 -0
- data/frameworks/sproutcore/views/spinner.js +1 -1
- data/frameworks/sproutcore/views/split.js +292 -0
- data/frameworks/sproutcore/views/split_divider.js +109 -0
- data/frameworks/sproutcore/views/tab.js +1 -1
- data/frameworks/sproutcore/views/toolbar.js +1 -1
- data/frameworks/sproutcore/views/view.js +1272 -591
- data/generators/client/templates/english.lproj/body.css +1 -1
- data/generators/controller/controller_generator.rb +1 -1
- data/generators/controller/templates/test.rhtml +2 -1
- data/generators/model/templates/test.rhtml +1 -1
- data/generators/test/templates/test.rhtml +1 -1
- data/generators/view/templates/test.rhtml +1 -1
- data/jsdoc/templates/sproutcore/class.tmpl +241 -338
- data/jsdoc/templates/sproutcore/default.css +105 -155
- data/jsdoc/templates/sproutcore/index.tmpl +43 -8
- data/jsdoc/templates/sproutcore/publish.js +9 -4
- data/lib/sproutcore/build_tools/html_builder.rb +29 -13
- data/lib/sproutcore/build_tools/resource_builder.rb +1 -1
- data/lib/sproutcore/bundle.rb +86 -25
- data/lib/sproutcore/jsdoc.rb +2 -0
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore/view_helpers.rb +36 -3
- data/tasks/deployment.rake +1 -1
- metadata +69 -36
- data/clients/sc_docs/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_docs/english.lproj/icons/small/reset.png +0 -0
- data/clients/sc_docs/english.lproj/images/gradients.png +0 -0
- data/clients/sc_docs/english.lproj/images/toolbar.png +0 -0
- data/clients/sc_docs/english.lproj/warning.rhtml +0 -6
- data/clients/sc_test_runner/english.lproj/warning.rhtml +0 -6
- data/frameworks/sproutcore/english.lproj/buttons.png +0 -0
- data/frameworks/sproutcore/english.lproj/collections.css +0 -82
- data/frameworks/sproutcore/english.lproj/images/buttons-sprite.png +0 -0
- data/frameworks/sproutcore/views/collection/collection_item.js +0 -36
- data/frameworks/sproutcore/views/collection/text_cell.js +0 -128
- data/frameworks/sproutcore/views/field.js +0 -214
- data/frameworks/sproutcore/views/workspace.js +0 -170
- data/generators/client/templates/english.lproj/controls.css +0 -0
- data/generators/framework/templates/english.lproj/body.css +0 -0
- data/generators/framework/templates/english.lproj/body.rhtml +0 -3
- data/generators/framework/templates/english.lproj/controls.css +0 -0
- data/lib/sproutcore/view_helpers/button_views.rb +0 -302
- data/lib/sproutcore/view_helpers/core_views.rb +0 -292
- data/lib/sproutcore/view_helpers/form_views.rb +0 -258
- data/lib/sproutcore/view_helpers/menu_views.rb +0 -94
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
require('Core');
|
|
2
2
|
require('foundation/responder');
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
/**
|
|
5
|
+
|
|
6
|
+
@class
|
|
7
|
+
|
|
8
|
+
The SC.Application object manages a SproutCore application. A single
|
|
9
|
+
instance is created and placed in a global variable named SC.app. All events
|
|
10
|
+
and actions are routed through this object.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@extends SC.Responder
|
|
14
|
+
@author Skip Baney
|
|
15
|
+
@copyright 2006-2008, Sprout Systems, Inc. and contributors.
|
|
16
|
+
@version 0.1
|
|
14
17
|
*/
|
|
15
|
-
SC.Application = SC.Responder.extend(
|
|
18
|
+
SC.Application = SC.Responder.extend(
|
|
19
|
+
/** @scope SC.Application.prototype */ {
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* The pane that is currently receiving key events.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('Core') ;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('foundation/object') ;
|
|
@@ -216,7 +216,7 @@ SC.Binding.mixin({
|
|
|
216
216
|
// of properties. The second param is a set of properties. Both are opt.
|
|
217
217
|
SC.Binding.From = function(from,opts) {
|
|
218
218
|
if (!opts) opts = {} ;
|
|
219
|
-
if ((
|
|
219
|
+
if (($type(from) == T_STRING) || ($type(from) == T_ARRAY)) {
|
|
220
220
|
opts.from = from ;
|
|
221
221
|
} else Object.extend(opts,from) ;
|
|
222
222
|
var ret = SC.Binding.extend(opts) ;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
// Extensions to the Date object. Comes from JavaScript Toolbox at:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('foundation/object');
|
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('Core') ;
|
|
7
7
|
require('foundation/object') ;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
/** @class
|
|
10
|
+
|
|
11
|
+
An InputManager knows how to convert incoming keyboard events and convert
|
|
12
|
+
them into actions on a responder. The default version should provide the
|
|
13
|
+
correct behavior for most people. However, if you want some special
|
|
14
|
+
behavior, you can always write your own.
|
|
15
|
+
|
|
16
|
+
An instance of this input manager is created as a property of
|
|
17
|
+
SC.Responder. To overide the inputManager used for all responders, replace
|
|
18
|
+
this property with your own instance. To override the inputManager used
|
|
19
|
+
only for one responder, set the inputManager property on your specific
|
|
20
|
+
instance.
|
|
21
|
+
|
|
22
|
+
Note that generally you do not want to write your own inputManager. They
|
|
23
|
+
are tricky to get right. Instead, you should implement the various handler
|
|
24
|
+
methods on the responder.
|
|
25
|
+
|
|
26
|
+
@extends SC.Object
|
|
27
|
+
@author Charles Jolley
|
|
28
|
+
*/
|
|
29
|
+
SC.InputManager = SC.Object.extend(
|
|
30
|
+
/** @scope SC.InputManager.prototype */ {
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
The is the primary entry point for the inputManager. If you override
|
|
34
|
+
the input manager, have this method process the key event and invoke
|
|
35
|
+
methods on the responder.
|
|
36
|
+
*/
|
|
28
37
|
interpretKeyEvents: function(event, responder)
|
|
29
38
|
{
|
|
30
39
|
var codes = this.codesForEvent(event) ;
|
|
@@ -50,8 +59,10 @@ SC.InputManager = SC.Object.extend({
|
|
|
50
59
|
return false ; //nothing to do.
|
|
51
60
|
},
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
/**
|
|
63
|
+
this will get a standardized command code for the event. It returns
|
|
64
|
+
null if the event is plain text, not a command code.
|
|
65
|
+
*/
|
|
55
66
|
codesForEvent: function(e) {
|
|
56
67
|
var code = e.keyCode ;
|
|
57
68
|
var ret = null ; var key = null ;
|
|
@@ -4,7 +4,7 @@ require('foundation/object');
|
|
|
4
4
|
/**
|
|
5
5
|
@namespace Mocks for unit testing
|
|
6
6
|
@author Skip Baney
|
|
7
|
-
@copyright 2006-
|
|
7
|
+
@copyright 2006-2008, Sprout Systems, Inc. and contributors.
|
|
8
8
|
@version 0.1
|
|
9
9
|
|
|
10
10
|
Mock objects provide basic support for unit testing. Look for subclasses.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('Core') ;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/**
|
|
9
|
+
This object can generate HTML DOM elements from a hash-based description of
|
|
10
|
+
the nodes. See the NodeDescriptor wiki page for complete docs.
|
|
11
|
+
|
|
12
|
+
See https://wiki.sproutit.com/engineering/show/NodeDescriptor
|
|
13
|
+
|
|
14
|
+
@deprecated
|
|
15
|
+
*/
|
|
13
16
|
SC.NodeDescriptor = {
|
|
14
17
|
create: function(descriptor, opts) {
|
|
15
18
|
if (!opts) opts = {} ;
|
|
@@ -1,31 +1,52 @@
|
|
|
1
1
|
// ========================================================================
|
|
2
2
|
// SproutCore
|
|
3
|
-
// copyright 2006-
|
|
3
|
+
// copyright 2006-2008 Sprout Systems, Inc.
|
|
4
4
|
// ========================================================================
|
|
5
5
|
|
|
6
6
|
require('Core') ;
|
|
7
7
|
require('foundation/benchmark') ;
|
|
8
|
-
require('
|
|
8
|
+
require('mixins/observable') ;
|
|
9
|
+
require('mixins/array') ;
|
|
9
10
|
|
|
10
11
|
SC.BENCHMARK_OBJECTS = NO;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
@class
|
|
14
|
+
@class
|
|
15
|
+
|
|
16
|
+
Root Object for the SproutCore Framework
|
|
17
|
+
|
|
18
|
+
h2. Class at a Glance
|
|
19
|
+
|
|
20
|
+
Add a one or two paragraph description of the class here.
|
|
14
21
|
|
|
15
22
|
This is the root object of the SproutCore framework. All other objects
|
|
16
23
|
inherit from you. SC.Object among other things implements support for
|
|
17
24
|
class inheritance, observers, and bindings. You should use SC.Object to
|
|
18
25
|
create your own subclasses as well.
|
|
26
|
+
|
|
27
|
+
h2. Overview
|
|
19
28
|
|
|
29
|
+
Some overview information about the class should go here.
|
|
20
30
|
Please see online documentation for more information about this.
|
|
31
|
+
|
|
32
|
+
h2. Subclassing Notes
|
|
21
33
|
|
|
22
34
|
I should be able to put a long list of things here I suppose.
|
|
23
35
|
|
|
24
|
-
Do bullet
|
|
25
|
-
points
|
|
26
|
-
work?
|
|
36
|
+
- Do bullet
|
|
37
|
+
- points
|
|
38
|
+
- work?
|
|
39
|
+
|
|
40
|
+
{{{
|
|
41
|
+
// Also some sample
|
|
42
|
+
code.goesHere() ;
|
|
43
|
+
}}}
|
|
27
44
|
|
|
28
45
|
@extends SC.Observable
|
|
46
|
+
@author Charles Jolley
|
|
47
|
+
@version 1.0
|
|
48
|
+
@since Version 1.0
|
|
49
|
+
|
|
29
50
|
*/
|
|
30
51
|
SC.Object = function(noinit) {
|
|
31
52
|
if (noinit == SC.Object._noinit_) return ;
|
|
@@ -33,12 +54,18 @@ SC.Object = function(noinit) {
|
|
|
33
54
|
return ret ;
|
|
34
55
|
};
|
|
35
56
|
|
|
36
|
-
Object.extend(SC.Object,
|
|
57
|
+
Object.extend(SC.Object,
|
|
58
|
+
/** @scope SC.Object */ {
|
|
37
59
|
|
|
38
60
|
_noinit_: '__noinit__',
|
|
39
61
|
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
/**
|
|
63
|
+
Add properties to a object's class definition.
|
|
64
|
+
|
|
65
|
+
@params {Hash} props the properties you want to add
|
|
66
|
+
@returns {void}
|
|
67
|
+
*/
|
|
68
|
+
mixin: function(props) {
|
|
42
69
|
var ext = $A(arguments) ;
|
|
43
70
|
for(var loc=0;loc<ext.length;loc++) {
|
|
44
71
|
Object.extend(this,ext[loc]);
|
|
@@ -46,9 +73,14 @@ Object.extend(SC.Object, {
|
|
|
46
73
|
return this ;
|
|
47
74
|
},
|
|
48
75
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
/**
|
|
77
|
+
Creates a new subclass, add to the receiver any passed properties
|
|
78
|
+
or methods.
|
|
79
|
+
|
|
80
|
+
@params {Hash} props the methods of properties you want to add
|
|
81
|
+
@returns {Class} A new object class
|
|
82
|
+
*/
|
|
83
|
+
extend: function(props) {
|
|
52
84
|
|
|
53
85
|
if (SC.BENCHMARK_OBJECTS) SC.Benchmark.start('SC.Object.extend') ;
|
|
54
86
|
|
|
@@ -78,20 +110,51 @@ Object.extend(SC.Object, {
|
|
|
78
110
|
|
|
79
111
|
return ret ;
|
|
80
112
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
Creates a new instance of the class.
|
|
116
|
+
|
|
117
|
+
Unlike most frameworks, you do not pass paramters into the init funciton
|
|
118
|
+
for an object. Instead, you pass a hash of additonal properties you want
|
|
119
|
+
to have assigned to the object when it is first created. This is
|
|
120
|
+
functionally like creating a anonymous subclass of the receiver and then
|
|
121
|
+
instantiating it, but more efficient.
|
|
122
|
+
|
|
123
|
+
You can use create() like you would a normal constructor in a class-based
|
|
124
|
+
system, or you can use it to create highly customized singleton objects
|
|
125
|
+
such as controllers or app-level objects. This is often more efficient
|
|
126
|
+
than creating subclasses and than instantiating them.
|
|
127
|
+
|
|
128
|
+
@param {Hash} props optional hash of method or properties to add to the instance.
|
|
129
|
+
@returns {SC.Object} new instance of the receiver class.
|
|
130
|
+
*/
|
|
131
|
+
create: function(props) {
|
|
84
132
|
var ret = new this($A(arguments),this) ;
|
|
85
133
|
return ret ;
|
|
86
134
|
},
|
|
87
135
|
|
|
88
|
-
|
|
136
|
+
/**
|
|
137
|
+
Takes an array of hashes and returns newly created instances.
|
|
138
|
+
|
|
139
|
+
This convenience method will take an array of properties and simply
|
|
140
|
+
instantiates objects from them.
|
|
141
|
+
|
|
142
|
+
@params {Array} array Array of hashes with properties to assigned to each object.
|
|
143
|
+
@returns {Array} array of instantiated objects.
|
|
144
|
+
*/
|
|
89
145
|
createArray: function(array) {
|
|
90
146
|
var obj = this ;
|
|
91
147
|
return array.map(function(props) { return obj.create(props); }) ;
|
|
92
148
|
},
|
|
93
149
|
|
|
94
|
-
|
|
150
|
+
/**
|
|
151
|
+
Adding this function to the end of a view declaration will define the
|
|
152
|
+
class as an outlet that can be constructed using the outlet() method
|
|
153
|
+
(instead of get()).
|
|
154
|
+
|
|
155
|
+
@returns {Outlet} a specially constructed function that will be used to
|
|
156
|
+
build the outlet later.
|
|
157
|
+
*/
|
|
95
158
|
outlet: function() {
|
|
96
159
|
var obj = this ;
|
|
97
160
|
return function() {
|
|
@@ -99,7 +162,74 @@ Object.extend(SC.Object, {
|
|
|
99
162
|
} ;
|
|
100
163
|
},
|
|
101
164
|
|
|
102
|
-
|
|
165
|
+
/**
|
|
166
|
+
Alway YES since this is a class.
|
|
167
|
+
*/
|
|
168
|
+
isClass: YES,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
Returns the name of this class. If the name is not known, triggers
|
|
172
|
+
a search. This can be expensive the first time it is called.
|
|
173
|
+
*/
|
|
174
|
+
objectClassName: function() {
|
|
175
|
+
if (!this._objectClassName) this._findObjectClassNames() ;
|
|
176
|
+
if (this._objectClassName) return this._objectClassName ;
|
|
177
|
+
var ret = this ;
|
|
178
|
+
while(ret && !ret._objectClassName) ret = ret._type;
|
|
179
|
+
return (ret._objectClassName) ? ret._objectClassName : 'Anonymous' ;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/** @private
|
|
183
|
+
This is a way of performing brute-force introspection. This searches
|
|
184
|
+
through all the top-level properties looking for classes. When it finds
|
|
185
|
+
one, it saves the class path name.
|
|
186
|
+
*/
|
|
187
|
+
_findObjectClassNames: function() {
|
|
188
|
+
|
|
189
|
+
if (SC._foundObjectClassNames) return ;
|
|
190
|
+
SC._foundObjectClassNames = true ;
|
|
191
|
+
|
|
192
|
+
var seen = [] ;
|
|
193
|
+
var searchObject = function(root, object, levels) {
|
|
194
|
+
levels-- ;
|
|
195
|
+
|
|
196
|
+
// not the fastest, but safe
|
|
197
|
+
if (seen.indexOf(object) >= 0) return ;
|
|
198
|
+
seen.push(object) ;
|
|
199
|
+
|
|
200
|
+
for(var key in object) {
|
|
201
|
+
if (key == '__scope__') continue ;
|
|
202
|
+
if (key == '_type') continue ;
|
|
203
|
+
if (!key.match(/^[A-Z0-9]/)) continue ;
|
|
204
|
+
|
|
205
|
+
var path = (root) ? [root,key].join('.') : key ;
|
|
206
|
+
var value = object[key] ;
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
switch($type(value)) {
|
|
210
|
+
case T_CLASS:
|
|
211
|
+
if (!value._objectClassName) value._objectClassName = path;
|
|
212
|
+
if (levels>=0) searchObject(path, value, levels) ;
|
|
213
|
+
break ;
|
|
214
|
+
|
|
215
|
+
case T_OBJECT:
|
|
216
|
+
if (levels>=0) searchObject(path, value, levels) ;
|
|
217
|
+
break ;
|
|
218
|
+
|
|
219
|
+
case T_HASH:
|
|
220
|
+
if (((root != null) || (path=='SC')) && (levels>=0)) searchObject(path, value, levels) ;
|
|
221
|
+
break ;
|
|
222
|
+
|
|
223
|
+
default:
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} ;
|
|
228
|
+
|
|
229
|
+
searchObject(null, window, 2) ;
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
toString: function() { return this.objectClassName(); },
|
|
103
233
|
|
|
104
234
|
// ..........................................
|
|
105
235
|
// PROPERTY SUPPORT METHODS
|
|
@@ -162,7 +292,7 @@ Object.extend(SC.Object, {
|
|
|
162
292
|
var concats = {} ;
|
|
163
293
|
if (cprops) for(var cloc=0;cloc<cprops.length;cloc++) {
|
|
164
294
|
var p = cprops[cloc]; var p1 = base[p]; var p2 = ext[p] ;
|
|
165
|
-
p1 = (p1 && p2) ? p1.concat(p2) : (p1 || p2) ;
|
|
295
|
+
p1 = (p1 && p2) ? Array.from(p1).concat(p2) : (p1 || p2) ;
|
|
166
296
|
concats[p] = p1 ;
|
|
167
297
|
}
|
|
168
298
|
|
|
@@ -213,8 +343,6 @@ Object.extend(SC.Object, {
|
|
|
213
343
|
return base ;
|
|
214
344
|
},
|
|
215
345
|
|
|
216
|
-
toString: function() { return 'Object('+ SC.getGUID(this) +')'; },
|
|
217
|
-
|
|
218
346
|
// Returns true if the receiver is a subclass of the named class. If the
|
|
219
347
|
// receiver is the class passed, this will return false. See kindOf().
|
|
220
348
|
subclassOf: function(scClass) {
|
|
@@ -262,16 +390,33 @@ SC.report = function() {
|
|
|
262
390
|
//
|
|
263
391
|
SC.Object.prototype = {
|
|
264
392
|
|
|
393
|
+
/**
|
|
394
|
+
Always YES since this is an object and not a class.
|
|
395
|
+
*/
|
|
265
396
|
isObject: true,
|
|
266
397
|
|
|
267
|
-
|
|
398
|
+
/**
|
|
399
|
+
Returns YES if the named value is an executable function.
|
|
400
|
+
|
|
401
|
+
@param methodName {String} the property name to check
|
|
402
|
+
@returns {Boolean}
|
|
403
|
+
*/
|
|
404
|
+
respondsTo: function( methodName )
|
|
268
405
|
{
|
|
269
|
-
return !!(
|
|
406
|
+
return !!(methodName && this[methodName] && ($type(this[methodName]) == T_FUNCTION));
|
|
270
407
|
},
|
|
271
408
|
|
|
272
|
-
|
|
409
|
+
/**
|
|
410
|
+
If the passed property is a method, then it will be executed with the
|
|
411
|
+
passed arguments. Otherwise, returns NO.
|
|
412
|
+
|
|
413
|
+
@param methodName {String} the method name to try to perform.
|
|
414
|
+
@param args {*arguments} arbitrary arguments to pass along to the method.
|
|
415
|
+
@returns {Object} NO if method could not be performed or method result.
|
|
416
|
+
*/
|
|
417
|
+
tryToPerform: function( methodName, args )
|
|
273
418
|
{
|
|
274
|
-
if ( !
|
|
419
|
+
if ( !methodName ) return false;
|
|
275
420
|
|
|
276
421
|
var args = $A(arguments);
|
|
277
422
|
var name = args.shift();
|
|
@@ -376,12 +521,25 @@ SC.Object.prototype = {
|
|
|
376
521
|
}
|
|
377
522
|
}
|
|
378
523
|
|
|
524
|
+
// Call 'initMixin' methods to automatically setup modules.
|
|
525
|
+
if (this.initMixin) {
|
|
526
|
+
var inc = Array.from(this.initMixin) ;
|
|
527
|
+
for(var idx=0; idx < inc.length; idx++) inc[idx].call(this);
|
|
528
|
+
}
|
|
529
|
+
|
|
379
530
|
if (r) { SC.idt.t += ((new Date().getTime()) - idtStart); }
|
|
380
531
|
},
|
|
381
532
|
|
|
382
533
|
/**
|
|
383
|
-
EXPERIMENTAL: You can use this to call super in any method.
|
|
384
|
-
|
|
534
|
+
EXPERIMENTAL: You can use this to call super in any method.
|
|
535
|
+
|
|
536
|
+
This currently does not work in some versions of Safari. Instead you
|
|
537
|
+
should use:
|
|
538
|
+
|
|
539
|
+
argments.callee.base.apply(this, arguments); to call super.
|
|
540
|
+
|
|
541
|
+
@params args {*args} any arguments you want to pass along.
|
|
542
|
+
@returns {void}
|
|
385
543
|
*/
|
|
386
544
|
$super: function(args) {
|
|
387
545
|
var caller = SC.Object.prototype.$super.caller;
|
|
@@ -390,7 +548,10 @@ SC.Object.prototype = {
|
|
|
390
548
|
},
|
|
391
549
|
|
|
392
550
|
/**
|
|
393
|
-
|
|
551
|
+
Add passed properties to the object's class.
|
|
552
|
+
|
|
553
|
+
@param props {Hash} properties to append.
|
|
554
|
+
@returns {void}
|
|
394
555
|
*/
|
|
395
556
|
mixin: function() { return SC.Object.mixin.apply(this,arguments) ; },
|
|
396
557
|
|
|
@@ -409,6 +570,9 @@ SC.Object.prototype = {
|
|
|
409
570
|
/**
|
|
410
571
|
returns true if the receiver is an instance of the named class. See also
|
|
411
572
|
kindOf().
|
|
573
|
+
|
|
574
|
+
@param {Class} scClass the class
|
|
575
|
+
@returns {Boolean}
|
|
412
576
|
*/
|
|
413
577
|
instanceOf: function(scClass) {
|
|
414
578
|
return this._type == scClass ;
|
|
@@ -417,6 +581,9 @@ SC.Object.prototype = {
|
|
|
417
581
|
/**
|
|
418
582
|
Returns true if the receiver is an instance of the named class or any
|
|
419
583
|
subclass of the named class. See also instanceOf().
|
|
584
|
+
|
|
585
|
+
@param scClass {Class} the class
|
|
586
|
+
@returns {Boolean}
|
|
420
587
|
*/
|
|
421
588
|
kindOf: function(scClass) {
|
|
422
589
|
var t = this._type ;
|
|
@@ -428,34 +595,26 @@ SC.Object.prototype = {
|
|
|
428
595
|
},
|
|
429
596
|
|
|
430
597
|
/** @private */
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
nextObject: function() {
|
|
437
|
-
var loc = this.loc ;
|
|
438
|
-
return (loc>=0) ? this.obj.objectAtIndex(--loc) : null ;
|
|
439
|
-
},
|
|
440
|
-
loc: this.get('length') || 0,
|
|
441
|
-
obj: this
|
|
442
|
-
} ;
|
|
443
|
-
|
|
444
|
-
// or just return one that does nothing.
|
|
445
|
-
} else {
|
|
446
|
-
ret = { nextObject: function() { return null; } } ;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return ret ;
|
|
598
|
+
toString: function() {
|
|
599
|
+
if (!this.__toString) {
|
|
600
|
+
this.__toString = "%@:%@".fmt(this._type.objectClassName(), this._guid);
|
|
601
|
+
}
|
|
602
|
+
return this.__toString ;
|
|
450
603
|
},
|
|
451
|
-
|
|
604
|
+
|
|
452
605
|
// ..........................................
|
|
453
606
|
// OUTLETS
|
|
454
607
|
//
|
|
455
608
|
|
|
456
609
|
/**
|
|
610
|
+
Activates any outlet connections in the the object. This is called
|
|
611
|
+
automatically for views typically.
|
|
612
|
+
|
|
457
613
|
A view may contain outlets. Outlets are a way to find and connect to
|
|
458
614
|
elements within the view.
|
|
615
|
+
|
|
616
|
+
@param key {String} optional single key to awake.
|
|
617
|
+
@returns {void}
|
|
459
618
|
*/
|
|
460
619
|
awake: function(key) {
|
|
461
620
|
// if a key is passed, convert that from an outlet and awake it. otherwise
|
|
@@ -504,17 +663,27 @@ SC.Object.prototype = {
|
|
|
504
663
|
},
|
|
505
664
|
|
|
506
665
|
/**
|
|
507
|
-
|
|
508
|
-
|
|
666
|
+
Array of outlets to awake automatically.
|
|
667
|
+
|
|
668
|
+
If you have outlets defined on a class, add this array with their
|
|
669
|
+
property names to have them awake automatically. This array is merged
|
|
670
|
+
with the parent class outlet's array automatically when you call extend().
|
|
671
|
+
|
|
672
|
+
@type {Array}
|
|
673
|
+
@field
|
|
509
674
|
*/
|
|
510
675
|
outlets: [],
|
|
511
676
|
|
|
512
677
|
/**
|
|
678
|
+
Just like get() except it will also create an outlet-packaged view if that
|
|
679
|
+
is the value of the property.
|
|
680
|
+
|
|
513
681
|
This method works just like get() except if the value of the property
|
|
514
682
|
is an outlet-packaged View, the view will be created first. You can use
|
|
515
|
-
this to create lazy outlets.
|
|
683
|
+
this to create lazy outlets.
|
|
516
684
|
|
|
517
685
|
@param {String} key The key to read as an outlet.
|
|
686
|
+
@returns {Object} the value of the key, possibly an awakened outlet.
|
|
518
687
|
*/
|
|
519
688
|
outlet: function(key) {
|
|
520
689
|
var value = this[key] ; // get the current value.
|
|
@@ -524,6 +693,7 @@ SC.Object.prototype = {
|
|
|
524
693
|
if (!this._originalOutlets) this._originalOutlets = {} ;
|
|
525
694
|
this._originalOutlets[key] = value ;
|
|
526
695
|
|
|
696
|
+
// create the outlet by calling the outlet function. this should be the owner view.
|
|
527
697
|
value = value.call(this) ;
|
|
528
698
|
this.set(key, value) ;
|
|
529
699
|
} else if (typeof(value) == "string") {
|
|
@@ -537,16 +707,38 @@ SC.Object.prototype = {
|
|
|
537
707
|
|
|
538
708
|
return value ;
|
|
539
709
|
},
|
|
540
|
-
|
|
710
|
+
|
|
541
711
|
/**
|
|
542
|
-
|
|
712
|
+
Invokes the named method after the specified period of time.
|
|
713
|
+
|
|
714
|
+
This is a convenience method that will create a single run timer to
|
|
715
|
+
invoke a method after a period of time. The method should have the
|
|
716
|
+
signature:
|
|
717
|
+
|
|
718
|
+
{{{
|
|
719
|
+
methodName: function(timer)
|
|
720
|
+
}}}
|
|
721
|
+
|
|
722
|
+
If you would prefer to pass your own parameters instead, you can instead
|
|
723
|
+
call invokeLater() directly on the function object itself.
|
|
724
|
+
|
|
725
|
+
@param interval {Number} period from current time to schedule.
|
|
726
|
+
@param methodName {String} method name to perform.
|
|
727
|
+
@returns {SC.Timer} scheduled timer.
|
|
543
728
|
*/
|
|
544
|
-
invokeLater: function(
|
|
545
|
-
|
|
546
|
-
|
|
729
|
+
invokeLater: function(methodName, interval) {
|
|
730
|
+
if (interval === undefined) interval = 1 ;
|
|
731
|
+
var f = methodName ;
|
|
732
|
+
if (arguments.length > 2) {
|
|
733
|
+
var args =$A(arguments).slice(2,arguments.length);
|
|
734
|
+
args.unshift(this);
|
|
735
|
+
if ($type(f) === T_STRING) f = this[methodName] ;
|
|
736
|
+
f = f.bind.apply(f, args) ;
|
|
737
|
+
}
|
|
738
|
+
return SC.Timer.schedule({ target: this, action: f, interval: interval });
|
|
547
739
|
},
|
|
548
740
|
|
|
549
|
-
_cprops: ['_cprops','outlets','_bindings','_observers','_properties']
|
|
741
|
+
_cprops: ['_cprops','outlets','_bindings','_observers','_properties', 'initMixin']
|
|
550
742
|
|
|
551
743
|
} ;
|
|
552
744
|
|
|
@@ -557,126 +749,6 @@ function logChange(target,key,value) {
|
|
|
557
749
|
console.log("CHANGE: " + target + "["+key+"]=" + value) ;
|
|
558
750
|
}
|
|
559
751
|
|
|
560
|
-
// ........................................................................
|
|
561
|
-
// FUNCTION ENHANCEMENTS
|
|
562
|
-
//
|
|
563
|
-
// Enhance function.
|
|
564
|
-
Object.extend(Function.prototype,{
|
|
565
|
-
|
|
566
|
-
// Declare a function as a property. This makes it something that can be
|
|
567
|
-
// accessed via get/set.
|
|
568
|
-
property: function() {
|
|
569
|
-
this.dependentKeys = $A(arguments) ;
|
|
570
|
-
this.isProperty = true; return this;
|
|
571
|
-
},
|
|
572
|
-
|
|
573
|
-
// Declare that a function should observe an object at the named path. Note
|
|
574
|
-
// that the path is used only to construct the observation one time.
|
|
575
|
-
observes: function(propertyPaths) {
|
|
576
|
-
this.propertyPaths = $A(arguments);
|
|
577
|
-
return this;
|
|
578
|
-
},
|
|
579
|
-
|
|
580
|
-
typeConverter: function() {
|
|
581
|
-
this.isTypeConverter = true; return this ;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
}) ;
|
|
585
|
-
|
|
586
|
-
// ........................................................................
|
|
587
|
-
// OBSERVER QUEUE
|
|
588
|
-
//
|
|
589
|
-
// This queue is used to hold observers when the object you tried to observe
|
|
590
|
-
// does not exist yet. This queue is flushed just before any property
|
|
591
|
-
// notification is sent.
|
|
592
|
-
SC.Observers = {
|
|
593
|
-
queue: {},
|
|
594
|
-
|
|
595
|
-
addObserver: function(propertyPath, func) {
|
|
596
|
-
// try to get the tuple for this.
|
|
597
|
-
if (typeof(propertyPath) == "string") {
|
|
598
|
-
var tuple = SC.Object.tupleForPropertyPath(propertyPath) ;
|
|
599
|
-
} else {
|
|
600
|
-
var tuple = propertyPath;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if (tuple) {
|
|
604
|
-
tuple[0].addObserver(tuple[1],func) ;
|
|
605
|
-
} else {
|
|
606
|
-
var ary = this.queue[propertyPath] || [] ;
|
|
607
|
-
ary.push(func) ;
|
|
608
|
-
this.queue[propertyPath] = ary ;
|
|
609
|
-
}
|
|
610
|
-
},
|
|
611
|
-
|
|
612
|
-
removeObserver: function(propertyPath, func) {
|
|
613
|
-
var tuple = SC.Object.tupleForPropertyPath(propertyPath) ;
|
|
614
|
-
if (tuple) {
|
|
615
|
-
tuple[0].removeObserver(tuple[1],func) ;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
var ary = this.queue[propertyPath] ;
|
|
619
|
-
if (ary) {
|
|
620
|
-
ary = ary.without(func) ;
|
|
621
|
-
this.queue[propertyPath] = ary ;
|
|
622
|
-
}
|
|
623
|
-
},
|
|
624
|
-
|
|
625
|
-
flush: function() {
|
|
626
|
-
var newQueue = {} ;
|
|
627
|
-
for(var path in this.queue) {
|
|
628
|
-
var funcs = this.queue[path] ;
|
|
629
|
-
var tuple = SC.Object.tupleForPropertyPath(path) ;
|
|
630
|
-
if (tuple) {
|
|
631
|
-
var loc = funcs.length ;
|
|
632
|
-
while(--loc >= 0) {
|
|
633
|
-
var func = funcs[loc] ;
|
|
634
|
-
tuple[0].addObserver(tuple[1],func) ;
|
|
635
|
-
}
|
|
636
|
-
} else newQueue[path] = funcs ;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// set queue to remaining items
|
|
640
|
-
this.queue = newQueue ;
|
|
641
|
-
}
|
|
642
|
-
} ;
|
|
643
|
-
|
|
644
|
-
// ........................................................................
|
|
645
|
-
// NOTIFCATION QUEUE
|
|
646
|
-
//
|
|
647
|
-
// Property notifications are placed into this queue first and then processed
|
|
648
|
-
// to keep the stack size down.
|
|
649
|
-
SC.NotificationQueue = {
|
|
650
|
-
queue: [],
|
|
651
|
-
maxFlush: 5000, // max time you can spend flushing before we reschedule.
|
|
652
|
-
_flushing: false,
|
|
653
|
-
add: function(target, func, args) { this.queue.push([target, func, args]);},
|
|
654
|
-
flush: function() {
|
|
655
|
-
if (this._flushing) return ;
|
|
656
|
-
this._flushing = true ;
|
|
657
|
-
|
|
658
|
-
var start = new Date().getTime() ;
|
|
659
|
-
var now = start ;
|
|
660
|
-
var n = null ;
|
|
661
|
-
while(((now - start) < this.maxFlush) && (n = this.queue.pop())) {
|
|
662
|
-
try {
|
|
663
|
-
var t = n[0] || n[1] ;
|
|
664
|
-
n[1].apply(t,n[2]) ;
|
|
665
|
-
}
|
|
666
|
-
catch(e) {
|
|
667
|
-
console.log("Exception while notify("+n[1]+"): " + e) ;
|
|
668
|
-
} // catch
|
|
669
|
-
now = Date.now() ;
|
|
670
|
-
}
|
|
671
|
-
this._flushing = false ;
|
|
672
|
-
|
|
673
|
-
if (this.queue.length > 0) {
|
|
674
|
-
setTimeout(this._reflush,1);
|
|
675
|
-
}
|
|
676
|
-
},
|
|
677
|
-
|
|
678
|
-
_reflush: function() { SC.NotificationQueue.flush(); }
|
|
679
|
-
} ;
|
|
680
752
|
|
|
681
753
|
// ........................................................................
|
|
682
754
|
// CHAIN OBSERVER
|