     i = randInt(options.length)
     @set_option(test_name, options[i])
 
-window.CircleABTestVM = new ABTestViewModel
+CircleABTestVM = new ABTestViewModel
+
+# Global variable
+exports.AB = CircleABTestVM.ab_tests()
 
 ko.bindingHandlers.ab_test =
   init: (el, valueAccessor) =>

    option = valueAccessor().option

    try
      ab_tests = window.CircleABTestVM.ab_tests()

      display_p = ab_tests[test] is option


# Make sure _ab_test_definitions is defined. Either define it in this file,
# or define it window._ab_test_definitions. Format is 'test-name': [options...]
#
# Example test defs:
# _ab_test_definitions =
#   'daniel-test': [true, false]
#   'daniel-test-2': ['option1', 'option2', 'option3']
#
# Caveats:
#   Don't set null as an option.
#   You can't change the options once they're set, you need to define a new test
#   You shouldn't have another global variable named AB
#
# Example usage in view:
#   %p{href: "#", data-bind: "ab_test: {test: 'Show beta text', option: true}"}
#     This is the paragraph that will show up if option is set to true
#   %p{href: "#", data-bind: "ab_test: {test: 'Show beta text', option: false}"}
#     This is the paragraph that will show up if option is set to false
#
#   Or, if you prefer not to use built-in knockout bindings:
#     %p{href: "#", data-bind: "if: AB.daniel_test == true"}
#       This is the text that will show up if option is set to true
#     %p{href: "#", data-bind: "if: AB.daniel_test == false"}
#       This is the text that will show up if option is set to false
#
# Note that the ab_test binding adds display:none to non-matching test options
# This may be desirable or undesirable depending on your use case

exports = this

## Define your A/B tests here
_ab_test_definitions =
  day_vs_week: ['day', 'week']

cookie_prefix = "ab_test_"
$.cookie.json = true
