Sha256: cc1afe2beadf337480127d0eec18abc46640835d139fe312da2e823d98363979

Contents?: true

Size: 1.66 KB

Versions: 17

Compression:

Stored size: 1.66 KB

Contents

// This widget manages the adding and removing of repeating fields.
// There are a lot of assumptions about the structure of the classes and elements.
// These assumptions are reflected in the MultiValueInput class.

(function($){
    var DEFAULTS = {
        /* callback to run after add is called */
        add:    null,
        /* callback to run after remove is called */
        remove: null,

        controlsHtml:      '<span class=\"input-group-btn field-controls\">',
        fieldWrapperClass: '.field-wrapper',
        warningClass:      '.has-warning',
        listClass:         '.listing',
        inputTypeClass:    '.multi_value',

        addHtml:           '<button type=\"button\" class=\"btn btn-link add\"><span class=\"glyphicon glyphicon-plus\"></span><span class="controls-add-text"></span></button>',
        addText:           'Add another',

        removeHtml:        '<button type=\"button\" class=\"btn btn-link remove\"><span class=\"glyphicon glyphicon-remove\"></span><span class="controls-remove-text"></span> <span class=\"sr-only\"> previous <span class="controls-field-name-text">field</span></span></button>',
        removeText:         'Remove',

        labelControls:      true,
    }

    $.fn.manage_fields = function(option) {
        var hydra_editor = require('hydra-editor/field_manager')
        return this.each(function() {
            var $this = $(this);
            var data  = $this.data('manage_fields');
            var options = $.extend({}, DEFAULTS, $this.data(), typeof option == 'object' && option);

            if (!data) $this.data('manage_fields', (data = new hydra_editor.FieldManager(this, options)));
        })
    }
})(jQuery);

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hydra-editor-6.3.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-6.2.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-6.1.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-6.0.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.5 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.4 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.3 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.2 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.1 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-5.0.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-4.0.2 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-4.0.1 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-3.4.0 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-3.4.0.beta app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-3.3.2 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-3.3.1 app/assets/javascripts/hydra-editor/manage_repeating_fields.js
hydra-editor-3.2.1 app/assets/javascripts/hydra-editor/manage_repeating_fields.js