 #
 # The `options` object will contains all the options passed to the `widgets`
 # method except the `on`, `if`, `unless` and `media` ones.
-widgets.define = (name, block) -> __widgets__[name] = block
+agt.widgets.define = (name, block) -> __widgets__[name] = block
 
 # A shorthand method to register a jQuery widget.
-widgets.$define = (name, baseOptions={}, block) ->
+agt.widgets.$define = (name, baseOptions={}, block) ->
   [baseOptions, block] = [{}, baseOptions] if typeof baseOptions is 'function'
   throw new Error "#{name} jquery widget isn't defined" unless $.fn[name]
   __widgets__[name] = (element, options={}) ->

# of the given `name` from the page.
# It's the widget responsibility to clean up its dependencies during
# the `dispose` call.
widgets.release = (names...) ->
  names = Object.keys(__instances__) if names.length is 0
  for name in names
    __instances__[name].each (value) -> value.dispose()

# Activates all the widgets instances of type `name`.
widgets.activate = (names...) ->
  names = Object.keys(__instances__) if names.length is 0
  for name in names
    __instances__[name].each (value) -> value.activate()

# Deactivates all the widgets instances of type `name`.
widgets.deactivate = (names...) ->
  names = Object.keys(__instances__) if names.length is 0
  for name in names
    __instances__[name].each (value) -> value.deactivate()


# The `widgets` function is both the main module and the function
# used to register the widgets to apply on a page.
agt.widgets = (name, selector, options={}, block) ->
  unless __widgets__[name]?
    throw new Error "Unable to find widget '#{name}'"

