From b30c4434e50c4e3ac128cf04ce4935ca6c660037 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Thu, 7 Aug 2014 16:01:04 -0300 Subject: adds with_feature_toggle mixin --- web-ui/app/js/lib/features.js | 5 +++++ web-ui/app/js/mixins/with_feature_toggle.js | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 web-ui/app/js/lib/features.js create mode 100644 web-ui/app/js/mixins/with_feature_toggle.js diff --git a/web-ui/app/js/lib/features.js b/web-ui/app/js/lib/features.js new file mode 100644 index 00000000..deacc8fe --- /dev/null +++ b/web-ui/app/js/lib/features.js @@ -0,0 +1,5 @@ +define([], function() { + return { + + }; +}); 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; + +}); -- cgit v1.2.3