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.82 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.81 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.80 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.79 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.78 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.71 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.70 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.68 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.67 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.66 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.65 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.64 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.62 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.57 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.55 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.54 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.52 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.50 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.49 app/assets/javascripts/caboose/model/bound_control.js
caboose-cms-0.2.48 app/assets/javascripts/caboose/model/bound_control.js