Sha256: bb01bf196551cdc7e3997fe76249568f8a247f3a531894e5933e7005ff00247e

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 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

7 entries across 7 versions & 1 rubygems

Version Path
outpost-cms-0.1.4 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.1.3 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.1.2 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.1.1 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.1.0 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.0.5 app/assets/javascripts/outpost/field_manager.js.coffee
outpost-cms-0.0.4 app/assets/javascripts/outpost/field_manager.js.coffee