Sha256: c4518375b93ac58199f089af5170453ce9d09d3eca9c4c2c733278feaf461bd1

Contents?: true

Size: 1.48 KB

Versions: 40

Compression:

Stored size: 1.48 KB

Contents

var Attribute = function(params) {
  for (var thing in params)
    this[thing] = params[thing];
  this.value_clean = this.value;  
};

Attribute.prototype = {
  name: false,
  nice_name: false,
  type: false,
  value: false,
  value_clean: false,
  text: false,
  empty_text: 'empty',
  fixed_placeholder: true,
  align: 'left',
  before_update: false,
  after_update: false,
  debug: false,
  
  update_url: false,
  options_url: false,
  options: false,
  
  save: function(after) {
    if (this.before_update) this.before_update();    
    var this2 = this;
    $.ajax({
      url: this.update_url,
      type: 'put',
      data: this.name + '=' + encodeURIComponent(this.value),
			success: function(resp) {			  
				if (resp.success)
				{
				  if (resp.attributes && resp.attributes[this2.name])
				    for (var thing in resp.attributes[this2.name])
				      this2[thing] = resp.attributes[this2.name][thing];				  
				  this2.value_clean = this2.value;
				}
				if (after) after(resp);
				if (this2.after_update) this2.after_update();
			},
			error: function() { 
			  if (after) after(false);
			}
		});
  },
  
  populate_options: function(after) {
    if (!this.options_url)
      return;
    if (this.options)
    {
      if (after) after();
      return;
    }
    var this2 = this;
    $.ajax({
      url: this.options_url,
      type: 'get',
			success: function(resp) {
        this2.options = resp;
				if (after) after();
			},
			error: function() { 
			  if (after) after();
			}
		});
  }
};

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
caboose-cms-0.3.3 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.2 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.1 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.104 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.103 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.102 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.100 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.99 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.98 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.97 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.96 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.95 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.94 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.93 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.92 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.91 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.90 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.89 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.88 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.2.87 app/assets/javascripts/caboose/model/attribute.js