Sha256: 7f7e6dea61affbbc16aa3a2509a79f407b1eae957940929a960a35f1355c1b71

Contents?: true

Size: 1.99 KB

Versions: 137

Compression:

Stored size: 1.99 KB

Contents

BoundControl = Class.extend({
    
  el: false,        // The DOM element to which the object is bound  
  model: false,     // The model to which the control is bound
  attribute: false, // The attribute of the model
  binder: false,    // The model binder
  
  init: function(params) {},  // Constructor  
  view: function() {},        // Sets the control in a view state
  edit: function() {},        // Sets the control in an edit state
  save: function() {},        // Sends the value in the control to the model to be saved
  cancel: function() {},      // Cancels the edit
  error: function(str) {},     // Shows an error

  show_loader: function() {
    var w = $('#'+this.el).outerWidth();
    var h = 40; //$('#'+this.el).outerHeight();
    var this2 = this;
    
    if (!$('#'+this.el+'_check').length)
    {      
      $('#'+this.el+'_container').prepend($('<div/>')
        .attr('id', this.el + '_check')
        .addClass('bound_input_check')
        .css('position', 'absolute')
        .css('top', 0)
        .css('left', w-h-1)
        .css('width', h+2)
        .css('overflow', 'hidden')
        .append($('<a/>')
          .addClass('loading')
          .html('&#10003;')
          .css('width', h)
          .css('margin-left', h)
          .attr('href', '#')
          .click(function(event) { event.preventDefault(); })
        )
      );
    }    
    $('#'+this.el+'_check a')
      .addClass('loading')
      .css('margin-left', h);
    $('#'+this.el+'_check a').animate({ 'margin-left': 0 }, 300); 
  },
  
  hide_loader: function() {
    this.hide_check();
  },
  
  show_check: function(duration) {
    $('#'+this.el+'_check a').removeClass('loading');
    if (duration)
    {
      var this2 = this;
      setTimeout(function() { this2.hide_check(); }, duration);
    }
  },
  
  hide_check: function() {
    var h = $('#'+this.el).outerHeight();
    var this2 = this;
    $('#'+this.el+'_check a').animate({ 'margin-left': h }, 300, function() { 
      $('#'+this2.check).remove(); 
    });
  }
  
});

Version data entries

137 entries across 137 versions & 1 rubygems

Version Path
caboose-cms-0.2.26 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.25 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.24 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.23 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.22 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.21 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.20 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.19 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.18 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.17 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.16 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.15 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.14 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.11 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.8 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.7 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.6 app/assets/javascripts/caboose/model/bound_control.js