diff options
author | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
commit | 0175cb67e426a27a3ecfb7b81317caa383c8a5a5 (patch) | |
tree | b4fbfcaabaadff508ad5463e8f71fd643995aacb /node_modules/montage/ui/condition.reel/condition.js | |
parent | fe71cb9aa1700199c0089166ad54fc56eb760644 (diff) | |
parent | 9f0c4efe2ed9a00f2c5d85c9d88a8040fedb5d8f (diff) | |
download | ninja-0175cb67e426a27a3ecfb7b81317caa383c8a5a5.tar.gz |
Merge branch 'refs/heads/master' into components
Diffstat (limited to 'node_modules/montage/ui/condition.reel/condition.js')
-rwxr-xr-x | node_modules/montage/ui/condition.reel/condition.js | 68 |
1 files changed, 55 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..053adb16 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 | */ |
@@ -112,15 +162,12 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond | |||
112 | // this keeps us from having to keep track of the range or risk losing | 162 | // this keeps us from having to keep track of the range or risk losing |
113 | // a reference to the elements when they're extracted | 163 | // a reference to the elements when they're extracted |
114 | conditionContentRange.surroundContents(this.content); | 164 | conditionContentRange.surroundContents(this.content); |
165 | conditionContentRange.deleteContents(); //remove the contents that are part of the original structure | ||
115 | } | 166 | } |
116 | 167 | ||
117 | var slotRoot = document.createElement("div"); | 168 | var slotRoot = document.createElement("div"); |
118 | this.element.appendChild(slotRoot); | 169 | this.element.appendChild(slotRoot); |
119 | 170 | ||
120 | this.content.parentNode.removeChild(this.content); | ||
121 | slotRoot.appendChild(this.content); | ||
122 | |||
123 | this._slot = Slot.create(); | ||
124 | this._slot.element = slotRoot; | 171 | this._slot.element = slotRoot; |
125 | } | 172 | } |
126 | }, | 173 | }, |
@@ -133,14 +180,9 @@ exports.Condition = Montage.create(Component, /** @lends module:"montage/ui/cond | |||
133 | value: function() { | 180 | value: function() { |
134 | 181 | ||
135 | if (this.condition) { | 182 | if (this.condition) { |
136 | this._slot.content = this.content; | ||
137 | this.element.classList.remove("montage-invisible"); | 183 | this.element.classList.remove("montage-invisible"); |
138 | } else { | 184 | } else { |
139 | if ("hide" === this.removalStrategy) { | 185 | this.element.classList.add("montage-invisible"); |
140 | this.element.classList.add("montage-invisible"); | ||
141 | } else { | ||
142 | this._slot.content = null; | ||
143 | } | ||
144 | } | 186 | } |
145 | 187 | ||
146 | } | 188 | } |