Sha256: 63cbc008a19cb6f2719bab483c9e4b82f7899d27a8d7c3cceeb95320dc225e33

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

##
# FieldManager
#
# A simple class that listens for certain events
# and does things to forms
#
class outpost.FieldManager
    constructor: ->
        
        $("fieldset.form-block legend").on
            click: (event) ->
                target = $(@)
                target.siblings(".fields").toggle()
                target.siblings(".notification").toggle()

        # Add fields
        $(".js-add-fields").on
            click: (event) ->
                event.preventDefault()

                target = $(@)
                time   = new Date().getTime()
                regexp = new RegExp(target.data('id'), 'g')
                fields = $(target.data('fields').trim().replace(regexp, time))
                
                if buildTarget = target.data('build-target')
                    $(buildTarget).append fields
                else
                    target.before(fields)
                    
                # Build any special fields.
                # TODO: Can we accomplish this with triggers?
                outpost.DateTimeInput.buildDateTimeInputs(fields)
                outpost.DateTimeInput.buildDateInputs(fields)
                $("select", fields).select2
                    placeholder: " "
                    allowClear: true

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 app/assets/javascripts/outpost/field_manager.js.coffee