Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Add helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mnoack committed Sep 3, 2013
1 parent b1edae0 commit 4479100
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 0 deletions.
@@ -0,0 +1 @@
%input{name: @field, value: @model.get(@field), type: 'hidden'}
@@ -0,0 +1,2 @@
%label{for: @field}= @label
%input{name: @field, value: @model.get(@field), type: 'password'}
@@ -0,0 +1,2 @@
%label{for: @field}= @label
%input{name: @field, value: @model.get(@field), type: 'radio'}
@@ -0,0 +1 @@
%input{type: 'submit', class: 'btn btn-primary', value: 'Save'}
2 changes: 2 additions & 0 deletions lib/assets/javascripts/templates/text_area_template.jst.hamlc
@@ -0,0 +1,2 @@
%label{for: @field}= @label
%textarea{name: @field}= @model.get(@field)
15 changes: 15 additions & 0 deletions lib/assets/javascripts/views/form_helpers.coffee
Expand Up @@ -13,6 +13,21 @@ Backtastic.Views.FormHelpers =

checkBoxField: (options) ->
@fieldView(Backtastic.Views.CheckBoxView, options)

hiddenField: (options) ->
@fieldView(Backtastic.Views.HiddenFieldView, options)

passwordField: (options) ->
@fieldView(Backtastic.Views.PasswordFieldView, options)

textArea: (options) ->
@fieldView(Backtastic.Views.TextAreaView, options)

radioButton: (options) ->
@fieldView(Backtastic.Views.RadioButtonView, options)

submit: (options) ->
@fieldView(Backtastic.Views.SubmitButtonView, options)

selectField: (options) ->
@fieldView(Backtastic.Views.SelectFieldView, options)
8 changes: 8 additions & 0 deletions lib/assets/javascripts/views/hidden_field_view.coffee
@@ -0,0 +1,8 @@
class Backtastic.Views.HiddenFieldView extends Backtastic.Views.FormFieldView
tagName: 'span'

template: JST["templates/hidden_field_template"]

render: ->
@$el.html @template(@)

4 changes: 4 additions & 0 deletions lib/assets/javascripts/views/password_field_view.coffee
@@ -0,0 +1,4 @@
class Backtastic.Views.PasswordFieldView extends Backtastic.Views.FormFieldView

template: JST["templates/password_field_template"]

4 changes: 4 additions & 0 deletions lib/assets/javascripts/views/radio_button_view.coffee
@@ -0,0 +1,4 @@
class Backtastic.Views.RadioButtonView extends Backtastic.Views.FormFieldView

template: JST["templates/radio_button_template"]

4 changes: 4 additions & 0 deletions lib/assets/javascripts/views/submit_button_view.coffee
@@ -0,0 +1,4 @@
class Backtastic.Views.SubmitButtonView extends Backtastic.Views.FormFieldView

template: JST["templates/submit_button_template"]

4 changes: 4 additions & 0 deletions lib/assets/javascripts/views/text_area_view.coffee
@@ -0,0 +1,4 @@
class Backtastic.Views.TextAreaView extends Backtastic.Views.FormFieldView

template: JST["templates/text_area_template"]

0 comments on commit 4479100

Please sign in to comment.