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.js67
1 files changed, 54 insertions, 13 deletions
diff --git a/node_modules/montage/ui/condition.reel/condition.js b/node_modules/montage/ui/condition.reel/condition.js
index 298edb13..e88d96a1 100755
--- a/node_modules/montage/ui/condition.reel/condition.js
+++ b/node_modules/montage/ui/condition.reel/condition.js
@@ -53,6 +53,13 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
53 53
54 this._condition = value; 54 this._condition = value;
55 this.needsDraw = true; 55 this.needsDraw = true;
56 if (this.removalStrategy === "remove") {
57 if (value) {
58 this._slot.content = this.content;
59 } else {
60 this._slot.content = null;
61 }
62 }
56 }, 63 },
57 get: function() { 64 get: function() {
58 return this._condition; 65 return this._condition;
@@ -83,17 +90,60 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
83 90
84 this._content = value; 91 this._content = value;
85 this.needsDraw = true; 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
86 } 102 }
87 }, 103 },
88 104
105 /**
106 @private
107 */
108 _removalStrategy:{
109 value: "remove",
110 enumerable:false
111 },
112
113 /**
114
115 */
89 // TODO should this strategy be part of another class? 116 // TODO should this strategy be part of another class?
90 // TODO expose the options as an exported enum 117 // TODO expose the options as an exported enum
91 removalStrategy: { 118 removalStrategy:{
92 enumerable: false, 119 get:function () {
93 value: "remove" 120 return this._removalStrategy;
121 },
122 set:function (value) {
123 if (this._removalStrategy === value) {
124 return;
125 }
126 if (value === "hide" || this.condition) {
127 // was remove OR was hide
128 this._slot.content = this.content;
129 }
130 this._removalStrategy = value;
131 }
94 }, 132 },
95 133
96 /** 134 /**
135
136 @param
137 @returns
138 */
139 didCreate:{
140 value:function () {
141 this._slot = Slot.create();
142 }
143 },
144
145
146 /**
97 Description TODO 147 Description TODO
98 @function 148 @function
99 */ 149 */
@@ -117,10 +167,6 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
117 var slotRoot = document.createElement("div"); 167 var slotRoot = document.createElement("div");
118 this.element.appendChild(slotRoot); 168 this.element.appendChild(slotRoot);
119 169
120 this.content.parentNode.removeChild(this.content);
121 slotRoot.appendChild(this.content);
122
123 this._slot = Slot.create();
124 this._slot.element = slotRoot; 170 this._slot.element = slotRoot;
125 } 171 }
126 }, 172 },
@@ -133,14 +179,9 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond
133 value: function() { 179 value: function() {
134 180
135 if (this.condition) { 181 if (this.condition) {
136 this._slot.content = this.content;
137 this.element.classList.remove("montage-invisible"); 182 this.element.classList.remove("montage-invisible");
138 } else { 183 } else {
139 if ("hide" === this.removalStrategy) { 184 this.element.classList.add("montage-invisible");
140 this.element.classList.add("montage-invisible");
141 } else {
142 this._slot.content = null;
143 }
144 } 185 }
145 186
146 } 187 }