aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/condition.reel/condition.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/condition.reel/condition.js')
-rwxr-xr-xnode_modules/montage/ui/condition.reel/condition.js79
1 files changed, 10 insertions, 69 deletions
diff --git a/node_modules/montage/ui/condition.reel/condition.js b/node_modules/montage/ui/condition.reel/condition.js
index bcb0e957..7553c14f 100755
--- a/node_modules/montage/ui/condition.reel/condition.js
+++ b/node_modules/montage/ui/condition.reel/condition.js
@@ -12,7 +12,6 @@
12*/ 12*/
13var Montage = require("montage").Montage, 13var Montage = require("montage").Montage,
14 Component = require("ui/component").Component, 14 Component = require("ui/component").Component,
15 Slot = require("ui/slot.reel").Slot,
16 logger = require("core/logger").logger("condition"); 15 logger = require("core/logger").logger("condition");
17/** 16/**
18 @class module:"montage/ui/condition.reel".Condition 17 @class module:"montage/ui/condition.reel".Condition
@@ -53,11 +52,12 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
53 52
54 this._condition = value; 53 this._condition = value;
55 this.needsDraw = true; 54 this.needsDraw = true;
56 if (this.removalStrategy === "remove") { 55 // If it is being deserialized originalContent has not been populated yet
56 if (this.removalStrategy === "remove" && !this.isDeserializing) {
57 if (value) { 57 if (value) {
58 this._slot.content = this.content; 58 this.domContent = this.originalContent;
59 } else { 59 } else {
60 this._slot.content = null; 60 this.domContent = null;
61 } 61 }
62 } 62 }
63 }, 63 },
@@ -65,42 +65,6 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
65 return this._condition; 65 return this._condition;
66 } 66 }
67 }, 67 },
68/**
69 Description TODO
70 @private
71*/
72 _content: {
73 enumerable: false,
74 value: null
75 },
76/**
77 Description TODO
78 @type {Function}
79 @default null
80 */
81 content: {
82 enumerable: false,
83 get: function() {
84 return this._content;
85 },
86 set: function(value) {
87 if (this._content === value) {
88 return;
89 }
90
91 this._content = value;
92 this.needsDraw = true;
93
94 if (this.removalStrategy === "remove") {
95 if (this.condition) {
96 this._slot.content = value;
97 }
98 } else {
99 this._slot.content = value;
100 }
101
102 }
103 },
104 68
105 /** 69 /**
106 @private 70 @private
@@ -120,45 +84,22 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
120 if (this._removalStrategy === value) { 84 if (this._removalStrategy === value) {
121 return; 85 return;
122 } 86 }
123 if (value === "hide" || this.condition) { 87 if (value === "hide" && !this.isDeserializing) {
124 // was remove OR was hide 88 this.domContent = this.originalContent;
125 this._slot.content = this.content;
126 } 89 }
127 this._removalStrategy = value; 90 this._removalStrategy = value;
91 this.needsDraw = true;
128 } 92 }
129 }, 93 },
130 94
131
132 didCreate:{
133 value:function () {
134 this._slot = Slot.create();
135 }
136 },
137
138
139 /**
140 Description TODO
141 @function
142 */
143 prepareForDraw: { 95 prepareForDraw: {
144 enumerable: false,
145 value: function() { 96 value: function() {
146 var i, childList, childElement; 97 if (this.removalStrategy === "remove" && !this.condition) {
147 if (!this.content) { 98 this.domContent = null;
148 this.content = document.createElement("div");
149 childList = Array.prototype.slice.call(this._element.childNodes, 0);
150 for (i = 0; (childElement = childList[i]); i++) {
151 childElement.parentNode.removeChild(childElement);
152 this.content.appendChild(childElement);
153 }
154 } 99 }
155
156 var slotRoot = document.createElement("div");
157 this.element.appendChild(slotRoot);
158
159 this._slot.element = slotRoot;
160 } 100 }
161 }, 101 },
102
162 /** 103 /**
163 Description TODO 104 Description TODO
164 @function 105 @function