Sha256: 08fd927098c459d597c564f5aae492864bc6b198c92cf4625c5f78964a78b1f7

Contents?: true

Size: 1.67 KB

Versions: 8

Compression:

Stored size: 1.67 KB

Contents

(function() {
  
  var InputModel = function(){

    this.id = 0;
    this.name = '';
    this.type = '';
    this.label = '';
    this.description = '';
    this.field_order = '';
    this.default_value = '';
    this.tag_attributes = '';

    this.setValue = function(prop_name, value){
      if(this[prop_name] != undefined) {

        this[prop_name] = value;
      }
    };

    this.getBaseObj = function(){
      return {
        id: this.id,
        name: this.name,
        type: this.type,
        label: this.label,
        description: this.description,
        field_order: this.field_order,
        default_value: this.default_value,
        tag_attributes: this.tag_attributes
      }
    };

    this.getFromFieldset = function(fieldset){
      var self = this;
      fieldset.serializeArray().forEach(function(el){
        var name = el.name.replace(/inputs\[\](group_inputs\[\])?/i, '');
        self[name] = el.value;
      });
    };

    this.getTagAttr = function(){
      try{
        return JSON.parse(this.tag_attributes);
      }catch(e){
        return {};
      }
    };

    this.setTagAttr = function(name, data){
      var obj = this.getTagAttr();
      obj[name] = data;
      this.tag_attributes = JSON.stringify(obj);
    };

    this.delTagAttr = function(attr){
      var obj = this.getTagAttr();
      delete(obj[attr]);
      this.tag_attributes = JSON.stringify(obj);
    };

    this.clear = function(){
      this.id = 0;
      this.name = '';
      this.type = '';
      this.label = '';
      this.description = '';
      this.field_order = '';
      this.default_value = '';
      this.tag_attributes = '';
    };

  };

  window.InputModel = new InputModel();
})();

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
formily-0.0.5.6.5 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.6.4 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.6.3 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.6.2 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.6.1 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.6.0 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.5.9 app/assets/javascripts/formily/editor/input_model.js
formily-0.0.5.5.7 app/assets/javascripts/formily/editor/input_model.js