 { UIRouterMarionette } = require('../index')
 
 
-
+# A helper behavior for linking to states with or without state parameters.
+# Element attributes:
+#   ui-sref="app.state.substate"
+#   ui-sparams='{"client_id": 5}' - optional if state doesn't need params or
+#                                   you're linking to a sibling/child state
+#                                   with the same parameters.
+#                                   The value should be HTML-encoded JSON.
+#                                   A template helper method is helpful here.
+# Behavior options: none
+#
 exports.UISref = class UISref extends Mn.Behavior
   ui:
     sref: '[ui-sref]'

    activeClasses: 'ui-state-active'

  initialize: ->
    router = UIRouterMarionette.getInstance()
    @deregister = router.transitionService.onSuccess {}, => console.warn("state changed!!!")

  onRender: ->
    @deregister()
    router = UIRouterMarionette.getInstance()
    @ui.active.each (i, el) ->
      $el = $(el)
      state = $el.attr('ui-sref-active')

  onStateChange: ->


  onBeforeDestroy: ->
    @deregister()

      e.attr('href', url)



# A behavior to toggle CSS classes on an element when a particular state
# (with or without specific state parameters) is active.
# Targets elements with a ui-sref-active attribute.
# ui-sref-active can optionally have a value selecting the specific state
# you want to watch for. If no value is provided, it will look to the state
# referenced by ui-sref.
# To help with lists that point at the same state with different state params,
# the behavior will also compare the contents of ui-sparams, if present.
# The default class is 'ui-state-active' but this can be customized in the
# behavior options:
# class MyView extends Marionette.ItemView
#   behaviors:
#     UISref: {}
#     UISrefActive: {activeClasses: 'state-is-active'}
#
exports.UISrefActive = class UISrefActive extends Mn.Behavior
  ui:
    active: '[ui-sref-active]'
