 
 # ## Initialization
 
-# ### rendered()
+# ##### rendered()
 #   * When the component is first rendered datatables is initialized
 #   * The `this` context for all of the component methods is `templateInstance.__component__`
-
 Template.dataTable.rendered = ->
   templateInstance = @
   instantiatedComponent = templateInstance.__component__
   instantiatedComponent.log "rendered", @
   instantiatedComponent.initialize()
 
-# ### destroyed()
+# ##### destroyed()
 #   * Currently nothing is done when the component is destroyed
 #   * This may change
-
 Template.dataTable.destroyed = ->
   @log "destroyed"
 
-# ### initialize()
+# ##### initialize()
 #   * Set the initial table properties from the component declaration
 #   * Initialize the jQuery DataTables object
 #   * Initialize other third parties if they exist ( plugins, select2, etc. )
-
 Template.dataTable.initialize = ->
   @prepareQuery()
   @prepareCollection()

#   * The reactive cursor responsible for keeping the client in sync
#   * identical to the server cursor publishing the data, except it does not skip

Template.dataTable.setCursor = ( cursor ) ->
  Match.test cursor, Object
  @setData 'cursor', cursor
  @log "cursor:set", cursor

Template.dataTable.prepareCursor = ->
  return

Template.dataTable.getCursor = ->
  return @getData().cursor or false

# ### DataTable Instance

Template.dataTable.getDataTable = ->
  return @getTemplateInstance().dataTable or false

Template.dataTable.setDataTable = ( dataTable ) ->
  Match.test dataTable, Object
  @getTemplateInstance().dataTable = dataTable
  @log "dataTable:set", dataTable.fnSettings()

Template.dataTable.prepareDataTable = ->
  @setDataTable $(".#{ @getSelector() } table").dataTable( @getOptions() )

Template.dataTable.prepareFilters = ->
  @prepareFilterPlaceholder()
  @prepareFooterFilter()

Template.dataTable.prepareFilterPlaceholder = ->
  $(".#{ @getSelector() } .dataTables_filter input[type=text]").attr "placeholder", "Type to filter..."

Template.dataTable.prepareFooterFilter = ->
  selector = @getSelector()
  if selector is 'datatable-add-row' and $.keyup


# ##### Default Table Template
#   * The default table template is defined in datatables.html
Template.dataTable.defaultTemplate = 'default_table_template'

# ##### chooseTemplate Helper
