diff options
author | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-03 12:20:10 -0800 |
commit | e6e539f345f5e1ac36a595db5d1a1c3700715e88 (patch) | |
tree | 39846bf1570f9b5a4057b726c54905de9e9e1c02 /node_modules/montage/core/serializer.js | |
parent | 7950424cf704bb221971f4645406b01e6979db18 (diff) | |
parent | c630ead20487c3948fa36448d3e7d5f7b5cba782 (diff) | |
download | ninja-e6e539f345f5e1ac36a595db5d1a1c3700715e88.tar.gz |
Merge branch 'master' into components
Conflicts:
node_modules/montage/ui/bluemoon/progress.reel/progress.html
node_modules/montage/ui/image2.reel/image2.html
node_modules/ninja-components/effect/desaturate-effect.js
node_modules/ninja-components/effect/effect.js
node_modules/ninja-components/effect/invert-effect.js
node_modules/ninja-components/effect/kaliedoscope-effect.js
node_modules/ninja-components/effect/multiply-effect.js
node_modules/ninja-components/effect/sepia-effect.js
node_modules/ninja-components/flow-controller.reel/flow-controller.html
node_modules/ninja-components/flow-controller.reel/flow-controller.js
node_modules/ninja-components/flow-offset.js
node_modules/ninja-components/hottext.reel/hottext.css
node_modules/ninja-components/hottext.reel/hottext.html
node_modules/ninja-components/hottext.reel/hottext.js
node_modules/ninja-components/hottextunit.reel/hottextunit.css
node_modules/ninja-components/hottextunit.reel/hottextunit.html
node_modules/ninja-components/hottextunit.reel/hottextunit.js
node_modules/ninja-components/image2.reel/image2.html
node_modules/ninja-components/image2.reel/image2.js
node_modules/ninja-components/image3d.reel/image3d.html
node_modules/ninja-components/image3d.reel/image3d.js
node_modules/ninja-components/photo-editor.reel/photo-editor.css
node_modules/ninja-components/photo-editor.reel/photo-editor.html
node_modules/ninja-components/photo-editor.reel/photo-editor.js
node_modules/ninja-components/slider-base.js
user-document-templates/montage-application-cloud/appdelegate.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/core/serializer.js')
-rwxr-xr-x | node_modules/montage/core/serializer.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/node_modules/montage/core/serializer.js b/node_modules/montage/core/serializer.js index 129c3e80..449ebf7d 100755 --- a/node_modules/montage/core/serializer.js +++ b/node_modules/montage/core/serializer.js | |||
@@ -12,6 +12,14 @@ | |||
12 | var Montage = require("montage").Montage; | 12 | var Montage = require("montage").Montage; |
13 | var Uuid = require("core/uuid").Uuid; | 13 | var Uuid = require("core/uuid").Uuid; |
14 | var Deserializer = require("core/deserializer").Deserializer; | 14 | var Deserializer = require("core/deserializer").Deserializer; |
15 | var logger = require("core/logger").logger("serializer"); | ||
16 | var Element; | ||
17 | |||
18 | // Shadowing the global with a local allows us to feature-test without typeof | ||
19 | // Element does not exist on the server-side | ||
20 | if (typeof window !== "undefined") { | ||
21 | Element = window.Element; | ||
22 | } | ||
15 | 23 | ||
16 | /** | 24 | /** |
17 | @class module:montage/core/serializer.Serializer | 25 | @class module:montage/core/serializer.Serializer |
@@ -19,6 +27,7 @@ var Deserializer = require("core/deserializer").Deserializer; | |||
19 | @extends module:montage/core/core.Montage | 27 | @extends module:montage/core/core.Montage |
20 | */ | 28 | */ |
21 | var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Serializer# */ { | 29 | var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Serializer# */ { |
30 | _MONTAGE_ID_ATTRIBUTE: {value: "data-montage-id"}, | ||
22 | _serializedObjects: {value: {}}, // uuid -> string | 31 | _serializedObjects: {value: {}}, // uuid -> string |
23 | _serializedReferences: {value: {}}, // uuid -> string | 32 | _serializedReferences: {value: {}}, // uuid -> string |
24 | _externalObjects: {value: null}, // label -> object | 33 | _externalObjects: {value: null}, // label -> object |
@@ -358,7 +367,7 @@ var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Se | |||
358 | if (value instanceof RegExp) { | 367 | if (value instanceof RegExp) { |
359 | return this._serializeRegExp(value); | 368 | return this._serializeRegExp(value); |
360 | } else if (value && (typeof value === "object" || typeof value === "function")) { | 369 | } else if (value && (typeof value === "object" || typeof value === "function")) { |
361 | if (value instanceof Element) { | 370 | if (Element && value instanceof Element) { |
362 | return this._serializeElement(value); | 371 | return this._serializeElement(value); |
363 | } else if (Array.isArray(value)) { | 372 | } else if (Array.isArray(value)) { |
364 | return this._serializeArray(value, indent + 1); | 373 | return this._serializeArray(value, indent + 1); |
@@ -378,11 +387,15 @@ var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Se | |||
378 | @private | 387 | @private |
379 | */ | 388 | */ |
380 | _serializeElement: {value: function(element) { | 389 | _serializeElement: {value: function(element) { |
381 | if (element.id) { | 390 | var attribute = element.getAttribute(this._MONTAGE_ID_ATTRIBUTE), |
391 | // TODO: element.id only here for backwards compatibility | ||
392 | id = attribute || element.id; | ||
393 | |||
394 | if (id) { | ||
382 | this._externalElements.push(element); | 395 | this._externalElements.push(element); |
383 | return '{"#":"' + element.id + '"}'; | 396 | return '{"#":"' + id + '"}'; |
384 | } else { | 397 | } else { |
385 | throw "Error: Not possible to serialize a DOM element with no id assigned: " + element.outerHTML; | 398 | logger.error("Error: Not possible to serialize a DOM element with no id assigned: " + element.outerHTML); |
386 | } | 399 | } |
387 | }}, | 400 | }}, |
388 | 401 | ||