Sha256: e5e561b98613a98f6d06daf03e02570ada7b95a0f40bce2e4a4bd1b056c4042c

Contents?: true

Size: 1.92 KB

Versions: 184

Compression:

Stored size: 1.92 KB

Contents

var Attribute = function(params) {
  for (var thing in params)
    this[thing] = params[thing];
  if (!this.text)
    this.text = this.value;
  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,
  download_text: false,
  upload_text: false,
  image_refresh_delay: false,
  minute_increment: 15,
  hour_increment: 1,
  show_check_all: true,
  show_empty_option: false,
  empty_option_text: false,
  quick_add_url: false,
  quick_add_text: 'Add New',  
  
  update_url: false,
  options_url: false,
  options: false,
  s3: false,
  
  save: function(after) {                  
    var this2 = this;
    //if (this.before_update) this.before_update(this2);
    $.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(this2);				
			},
			error: function() { 
			  if (after) after(false);
			}
		});
  },
  
  populate_options: function(after, refresh) {
    if (!this.options_url)
      return;        
    if (this.options && !refresh)
    {
      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

184 entries across 184 versions & 1 rubygems

Version Path
caboose-cms-0.9.102 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.101 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.100 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.99 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.98 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.97 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.96 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.95 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.94 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.93 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.92 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.91 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.90 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.89 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.88 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.87 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.86 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.85 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.84 app/assets/javascripts/caboose/model/attribute.js
caboose-cms-0.9.83 app/assets/javascripts/caboose/model/attribute.js