 
   DEFAULT_EMAIL_INPUT_SELECTOR = 'input[type="email"], input[type="text"]'
 
+  @init: ->
+    instance = new @ unless instance
+
+    instance
+
+  @setToken: (token) ->
+    @init().token = token
+
+  @send: (email) ->
+    @init().send(email)
+
   constructor: ->
-    @token = document.querySelector('script[data-token]').getAttribute('data-token')
-    @debug = document.querySelector('script[data-debug]').getAttribute('data-debug')
-    @installListeners()
+    @token = @getDataAttribute('data-token')
+    @debug = @getDataAttribute('data-debug')
+    @auto  = @getDataAttribute('data-auto')
+
+    if @token and @auto
+      @installListeners()
 
   forms: ->
     document.forms

    if @debug and console
      [].unshift.call(arguments, "[SignupSumo v#{NOTIFIER_VERSION}]")
      console.log.apply(console, arguments)

  installListeners: ->
    @log 'Installing listeners...'

  handleBlur: (field) ->
    cleanEmail = field.value.replace(/^\s+|\s+$/g, '')
    if @validateEmailFormat(cleanEmail)
      @send(cleanEmail)

  send: (email) ->
    if @token
      endpoint = DEFAULT_NOTIFIER_ENDPOINT
      data =
        token: @token
        url: window.location.origin
        email: email

      return superagent
        .post(endpoint)
        .send(data)
    else
      throw 'Token required to send emails. Do `SignupSumo.setToken(TOKEN)` to set it'

  validateEmailFormat: (email) ->
    !!email.match(EMAIL_REGEX)

window.SignupSumo = SignupSumo

loadCompleted = ->
  SignupSumo.init()

if document.addEventListener
  document.addEventListener("DOMContentLoaded", loadCompleted, true)
