summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mixins
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-07 16:01:04 -0300
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-08 13:44:43 -0300
commitb30c4434e50c4e3ac128cf04ce4935ca6c660037 (patch)
tree694c57df36e002e6fff6091812aeafae298e7a35 /web-ui/app/js/mixins
parent77b12bda3df10710daf7c441512146170523f003 (diff)
adds with_feature_toggle mixin
Diffstat (limited to 'web-ui/app/js/mixins')
-rw-r--r--web-ui/app/js/mixins/with_feature_toggle.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/web-ui/app/js/mixins/with_feature_toggle.js b/web-ui/app/js/mixins/with_feature_toggle.js
new file mode 100644
index 00000000..3a484388
--- /dev/null
+++ b/web-ui/app/js/mixins/with_feature_toggle.js
@@ -0,0 +1,20 @@
+define(['lib/features'],
+ function(features) {
+
+ function withFeatureToggle(componentName) {
+ return function() {
+
+ var defaultToggle = {enabled: true};
+
+ this.around('initialize', function(basicInitialize) {
+ var featureToggle = features[componentName] || defaultToggle;
+ if(featureToggle.enabled) {
+ basicInitialize(arguments[1], arguments[2]);
+ }
+ });
+ };
+ }
+
+ return withFeatureToggle;
+
+});