diff options
author | Jose Antonio Marquez | 2012-05-16 15:42:37 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-16 15:42:37 -0700 |
commit | 857aafee732b6a85fa155ff4a05d1b8fde48f09d (patch) | |
tree | e06d330caee280aa05aec46391979e9abdcf974c /node_modules/montage | |
parent | 5cc5d29736d8bf253e3a168cdd6443e839ffb23c (diff) | |
parent | fd54dabad7cbc27a0efb0957155c00d578912909 (diff) | |
download | ninja-857aafee732b6a85fa155ff4a05d1b8fde48f09d.tar.gz |
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'node_modules/montage')
66 files changed, 7578 insertions, 3685 deletions
diff --git a/node_modules/montage/core/change-notification.js b/node_modules/montage/core/change-notification.js new file mode 100644 index 00000000..bfe5ff2d --- /dev/null +++ b/node_modules/montage/core/change-notification.js | |||
@@ -0,0 +1,1418 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /** | ||
8 | @module montage/core/event/change-notification | ||
9 | */ | ||
10 | |||
11 | var Montage = require("montage").Montage, | ||
12 | logger = require("core/logger").logger("change-notification"), | ||
13 | UNDERSCORE = "_"; | ||
14 | |||
15 | // key: <path>, <target uuid>, <listener uuid> | ||
16 | var _descriptorsDirectory = Object.create(null); | ||
17 | |||
18 | // key: <target uuid>, <path> | ||
19 | var _willChangeDescriptorsDirectory = Object.create(null); | ||
20 | var _willChangeDescriptorsIndexesDirectory = Object.create(null); | ||
21 | var _changeDescriptorsDirectory = Object.create(null); | ||
22 | var _changeDescriptorsIndexesDirectory = Object.create(null); | ||
23 | |||
24 | exports.__reset__ = function() { | ||
25 | _descriptorsDirectory = Object.create(null); | ||
26 | _willChangeDescriptorsDirectory = Object.create(null); | ||
27 | _willChangeDescriptorsIndexesDirectory = Object.create(null); | ||
28 | _changeDescriptorsDirectory = Object.create(null); | ||
29 | _changeDescriptorsIndexesDirectory = Object.create(null); | ||
30 | // also need to remove all installed setters | ||
31 | }; | ||
32 | |||
33 | exports.__debug__ = function() { | ||
34 | console.log("_descriptorsDirectory", _descriptorsDirectory); | ||
35 | console.log("_willChangeDescriptorsDirectory", _willChangeDescriptorsDirectory, _willChangeDescriptorsIndexesDirectory); | ||
36 | console.log("_changeDescriptorsDirectory", _changeDescriptorsDirectory, _changeDescriptorsIndexesDirectory); | ||
37 | }; | ||
38 | |||
39 | var ChangeNotification = exports.ChangeNotification = Object.create(Montage, { | ||
40 | // (object) => <object>.uuid | ||
41 | // | ||
42 | // (target_n): { | ||
43 | // <propertyPath_n>: { | ||
44 | // target, | ||
45 | // propertyPath, | ||
46 | // willChangeListeners: { | ||
47 | // (listener_n): { | ||
48 | // listenerTarget, | ||
49 | // listenerFunction, | ||
50 | // listensToMutation | ||
51 | // } | ||
52 | // }, | ||
53 | // changeListeners: same as willChangeListeners, | ||
54 | // willChangeListenersCount: Object.keys(willChangeListeners).length, | ||
55 | // changeListenersCount: Object.keys(changeListeners).length, | ||
56 | // handleWillChange: function() | ||
57 | // handleChange: function() | ||
58 | // } | ||
59 | // } | ||
60 | _descriptorsRegistry: { | ||
61 | writable: true, | ||
62 | value: Object.create(null) | ||
63 | }, | ||
64 | |||
65 | _createFunctionDescriptor: { | ||
66 | value: function(target, listener, beforeChange, mutation) { | ||
67 | var identifier, | ||
68 | functionName, | ||
69 | functionDescriptor = Object.create(ChangeNotificationFunctionDescriptor); | ||
70 | |||
71 | if (typeof listener === "function") { | ||
72 | functionDescriptor.listenerFunction = listener; | ||
73 | functionDescriptor.listenerTarget = target; | ||
74 | } else { | ||
75 | identifier = target.identifier; | ||
76 | |||
77 | if (identifier) { | ||
78 | identifier = identifier.toCapitalized(); | ||
79 | |||
80 | functionName = "handle" + identifier + (beforeChange ? "WillChange" : "Change"); | ||
81 | if (typeof listener[functionName] === "function") { | ||
82 | functionDescriptor.listenerFunctionName = functionName; | ||
83 | functionDescriptor.listenerFunction = listener[functionName]; | ||
84 | functionDescriptor.listenerTarget = listener; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | if (!functionDescriptor.listenerFunction) { | ||
89 | functionName = "handle" + (beforeChange ? "WillChange" : "Change"); | ||
90 | if (typeof listener[functionName] === "function") { | ||
91 | functionDescriptor.listenerFunctionName = functionName; | ||
92 | functionDescriptor.listenerFunction = listener[functionName]; | ||
93 | functionDescriptor.listenerTarget = listener; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | if (!functionDescriptor.listenerFunction) { | ||
99 | console.log("Could not find valid listener when installing", target, listener); | ||
100 | throw "Could not find valid listener when installing"; | ||
101 | } | ||
102 | |||
103 | functionDescriptor.listensToMutation = mutation; | ||