diff options
author | Jose Antonio Marquez | 2012-04-20 10:44:02 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-20 10:44:02 -0700 |
commit | 0b7848540a7ca84b7c67821fedc275cf243eff2f (patch) | |
tree | a26b2986d412a02eb93fc7fa1b0f495cab40e757 /node_modules/montage/core/event/binding.js | |
parent | 154d1a8fdbbe050dbfc97cd13baa8981d8fc1e47 (diff) | |
parent | 8a546291a9d0de3bda1a7765ae9008f2ad052bba (diff) | |
download | ninja-0b7848540a7ca84b7c67821fedc275cf243eff2f.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'node_modules/montage/core/event/binding.js')
-rwxr-xr-x | node_modules/montage/core/event/binding.js | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/node_modules/montage/core/event/binding.js b/node_modules/montage/core/event/binding.js index 21b40609..709a5d85 100755 --- a/node_modules/montage/core/event/binding.js +++ b/node_modules/montage/core/event/binding.js | |||
@@ -18,6 +18,7 @@ var Montage = require("montage").Montage, | |||
18 | ChangeTypes = require("core/event/mutable-event").ChangeTypes, | 18 | ChangeTypes = require("core/event/mutable-event").ChangeTypes, |
19 | Serializer = require("core/serializer").Serializer, | 19 | Serializer = require("core/serializer").Serializer, |
20 | Deserializer = require("core/deserializer").Deserializer, | 20 | Deserializer = require("core/deserializer").Deserializer, |
21 | logger = require("core/logger").logger("binding"); | ||
21 | defaultEventManager = require("core/event/event-manager").defaultEventManager, | 22 | defaultEventManager = require("core/event/event-manager").defaultEventManager, |
22 | AT_TARGET = 2, | 23 | AT_TARGET = 2, |
23 | UNDERSCORE = "_"; | 24 | UNDERSCORE = "_"; |
@@ -1184,11 +1185,14 @@ var BindingDescriptor = exports.BindingDescriptor = Montage.create(Montage, /** | |||
1184 | }, | 1185 | }, |
1185 | 1186 | ||
1186 | serializeSelf: {value: function(serializer) { | 1187 | serializeSelf: {value: function(serializer) { |
1187 | serializer.setReference("boundObject", this.boundObject); | 1188 | var serialization = {}; |
1188 | serializer.set("boundObjectPropertyPath", this.boundObjectPropertyPath); | 1189 | |
1189 | serializer.set("oneway", this.oneway); | 1190 | serializer.addObjectReference(this.boundObject); |
1190 | serializer.set("deferred", this.deferred); | 1191 | serialization[this.oneway ? "<-" : "<<->"] = "@" + serializer.getObjectLabel(this.boundObject) + "." + this.boundObjectPropertyPath; |
1191 | serializer.set("converter", this.converter); | 1192 | serialization.deferred = this.deferred; |
1193 | serialization.converter = this.converter; | ||
1194 | |||
1195 | return serialization; | ||
1192 | }} | 1196 | }} |
1193 | }); | 1197 | }); |
1194 | 1198 | ||
@@ -1200,10 +1204,36 @@ Serializer.defineSerializationUnit("bindings", function(object) { | |||
1200 | } | 1204 | } |
1201 | }); | 1205 | }); |
1202 | 1206 | ||
1203 | Deserializer.defineDeserializationUnit("bindings", function(object, bindings) { | 1207 | Deserializer.defineDeserializationUnit("bindings", function(object, bindings, deserializer) { |
1204 | var sourcePath; | 1208 | for (var sourcePath in bindings) { |
1205 | for (sourcePath in bindings) { | 1209 | var binding = bindings[sourcePath], |
1206 | Object.defineBinding(object, sourcePath, bindings[sourcePath]); | 1210 | dotIndex; |
1211 | |||
1212 | if (!("boundObject" in binding)) { | ||
1213 | var targetPath = binding["<-"] || binding["->"] || binding["<->>"] || binding["<<->"]; | ||
1214 | |||
1215 | if (targetPath[0] !== "@") { | ||
1216 | logger.error("Invalid binding syntax '" + targetPath + "', should be in the form of '@label.path'."); | ||
1217 | throw "Invalid binding syntax '" + targetPath + "'"; | ||
1218 | } | ||
1219 | if ("->" in binding || "<->>" in binding) { | ||
1220 | binding.boundObject = object; | ||
1221 | binding.boundObjectPropertyPath = sourcePath; | ||
1222 | |||
1223 | dotIndex = targetPath.indexOf("."); | ||
1224 | object = deserializer.getObjectByLabel(targetPath.slice(1, dotIndex)); | ||
1225 | sourcePath = targetPath.slice(dotIndex+1); | ||
1226 | } else { | ||
1227 | dotIndex = targetPath.indexOf("."); | ||
1228 | binding.boundObject = deserializer.getObjectByLabel(targetPath.slice(1, dotIndex)); | ||
1229 | binding.boundObjectPropertyPath = targetPath.slice(dotIndex+1); | ||
1230 | } | ||
1231 | |||
1232 | if ("<-" in binding || "->" in binding) { | ||
1233 | binding.oneway = true; | ||
1234 | } | ||
1235 | } | ||
1236 | Object.defineBinding(object, sourcePath, binding); | ||
1207 | } | 1237 | } |
1208 | }); | 1238 | }); |
1209 | 1239 | ||