Skip to content

Commit

Permalink
docs(all generators): document methods and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cueedee committed Apr 13, 2015
1 parent 077b755 commit 6aa0d3c
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 67 deletions.
18 changes: 18 additions & 0 deletions generators/app/templates/demo/models/example.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,29 @@

class ExampleModel extends Backbone.Model

###*
# Defaults to initialize missing attributes with when instantiating a new `ExampleModel`.
#
# @property defaults
#
# @type Object
# @protected
# @static
# @final
###

defaults:
propertyOne: 'this should be a string'
propertyTwo: true


###*
# @method exampleAsyncFunction
#
# @param {Function} callback A callback function to call after one second.
#
###

exampleAsyncFunction: ( callback ) ->

setTimeout( () ->
Expand Down
42 changes: 36 additions & 6 deletions generators/app/templates/demo/views/buildscript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,49 @@

class BuildscriptView extends Backbone.View

# We need to expose our name to the router
###*
# Expose this view's name to the router.
#
viewName: 'buildscript'
className: 'buildscript-view'
# @property viewName
#
# @default 'buildscript'
# @type String
# @static
# @final
###

viewName: 'buildscript'


###*
# CSS class(es) to set on this view's root DOM element.
#
# @property className
#
# @default 'buildscript-view'
# @type String
# @static
# @final
###

className: 'buildscript-view'


###*
# @method render
#
# @chainable
#
###

render: () ->

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )

# By convention always return this so people can chain functions
# for example grab the .el after rendering ;-)
#
## This method is chainable.
##
return @

)
42 changes: 33 additions & 9 deletions generators/app/templates/demo/views/documentation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,49 @@

class DocumentationView extends Backbone.View

# We need to expose our name to the router
###*
# Expose this view's name to the router.
#
# @property viewName
#
viewName: 'documentation'
className: 'documentation-view'
# @default 'documentation'
# @type String
# @static
# @final
###

viewName: 'documentation'


###*
# Function renders the view
# CSS class(es) to set on this view's root DOM element.
#
# @method render
# @return viewInstance
# @property className
#
# @default 'documentation-view'
# @type String
# @static
# @final
###

className: 'documentation-view'


###*
# @method render
#
# @chainable
#
###

render: () ->

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )

# By convention always return this so people can chain functions
# for example grab the .el after rendering ;-)
#
## This method is chainable.
##
return @

)
70 changes: 54 additions & 16 deletions generators/app/templates/demo/views/i18n.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,85 @@

class I18nView extends Backbone.View

# We need to expose our name to the router
###*
# Expose this view's name to the router.
#
# @property viewName
#
# @default 'i18n'
# @type String
# @static
# @final
###

viewName: 'i18n'


###*
# CSS class(es) to set on this view's root DOM element.
#
# @property className
#
viewName: 'i18n'
className: 'i18n-view'
# @default 'i18n-view'
# @type String
# @static
# @final
###

className: 'i18n-view'


###*
# Setup UI event handler definitions.
#
# @property events
#
# @type Object
# @protected
# @static
# @final
###

events:
'change select[name="language"]': '_changeLanguage'


###*
# Function renders the view
# @method render
#
# @chainable
#
# @method render
# @return viewInstance
###

render: () ->

# Set the template to el
#
## Expand the handlebars template into this view's container element.
##
@$el.html( template(
date: new Date()
money: 100000
number: 1090870987
))

# Set the current locale as selected option
#
## Set the current locale as selected option.
##
@$el.find( "select[name='language'] option[value='#{ localeManager.getLocaleName() }']" ).attr( 'selected', true )

# By convention always return this so people can chain functions
# for example grab the .el after rendering ;-)
#
## This method is chainable.
##
return @


###*
# Private function called when the lanaguage select changes
# Handles changes to the selected language.
#
# @method _changeLanguage
# @protected
#
# @method render
# @private
###

_changeLanguage: () ->

$select = @$el.find( 'select[name="language"]' )

localeManager.setLocale( $select.val() ).then(
Expand Down
43 changes: 34 additions & 9 deletions generators/app/templates/demo/views/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,49 @@

class IndexView extends Backbone.View

# We need to expose our name to the router
###*
# Expose this view's name to the router.
#
# @property viewName
#
# @default 'index'
# @type String
# @static
# @final
###

viewName: 'index'


###*
# CSS class(es) to set on this view's root DOM element.
#
# @property className
#
viewName: 'index'
className: 'index-view'
# @default 'index-view'
# @type String
# @static
# @final
###

className: 'index-view'


###*
# Function renders the view
# @method render
#
# @chainable
#
# @method render
# @return viewInstance
###

render: () ->

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )

# By convention always return this so people can chain functions
# for example grab the .el after rendering ;-)
#
## This method is chainable.
##
return @

)
39 changes: 27 additions & 12 deletions generators/app/templates/demo/views/navigation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,53 @@

class NavigationView extends Backbone.View

# We need to expose our name to the router
###*
# CSS class(es) to set on this view's root DOM element.
#
# @property className
#
viewName: 'navigation'
className: 'navigation-view'
# @default 'navigation-view'
# @type String
# @static
# @final
###

className: 'navigation-view'


###*
# Function renders the view
# @method render
#
# @chainable
#
# @method render
# @return viewInstance
###

render: () ->

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )

# Set reference to the navbar
#
@$navBar = @$el.find( '.navbar-nav' )

# By convention always return this so people can chain functions
# for example grab the .el after rendering ;-)
#
## This method is chainable.
##
return @


###*
# Function to set the activeMenuItem based on the url passed
# Set the activeMenuItem based on the url passed.
#
# @method setActiveMenuItem
#
# @param {String} url Url excluding the hash belonging to the menuitem
#
# @method setActiveMenuItem
# @param url {string} Url excluding the hash belonging to the menuitem
###

setActiveMenuItem: ( url ) ->

@$navBar.find( '.active' ).removeClass( 'active' )
@$navBar.find( "a[href='##{url}']" ).closest( 'li' ).addClass( 'active' )

Expand Down
Loading

0 comments on commit 6aa0d3c

Please sign in to comment.