Sha256: bece3807ff1a1cace3c30f7983e2b5ec60083e80078dcfe9503417eab0b3f27c

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 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,
  before_cancel: false,
  after_cancel: 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

17 entries across 17 versions & 1 rubygems

Version Path
caboose-cms-0.3.23 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.22 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.20 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.19 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.17 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.16 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.15 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.14 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.13 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.12 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.11 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.9 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.8 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.7 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.6 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.5 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.3.4 app/assets/javascripts/caboose/model/attribute.js