Sha256: f500d0d38389dca5752e403cab099663e3d479d7382bedf326032acb3d91e0f3

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 KB

Contents

var PickyAddination = function(view, results) {
  
  // Calculate the addination range.
  // 
  var calculateRange = function(data, correction) {
    var correction      = correction || 0;
    var numberOfResults = 20; // Make parametrizable.
    var offset  = data.offset + numberOfResults + correction;
    var end     = offset + numberOfResults;
    var total   = data.total;
    if (total < end) { end = total; }
    return { offset:offset, start:(offset+1), end:end };
  };
  
  // Remove the addination.
  //
  var remove = function() {
    results.find('.addination').remove();
  };
  this.remove = remove;
  
  // Renders the addination;
  //
  var render = function(data) {
    var total = data.total;
    var range = calculateRange(data);
    if (range.offset < total) {
      var result = $("<div class='addination current'>" + t('results.addination.more') + "<div class='tothetop'><a href='javascript:$.scrollTo(0,{ duration: 500});'>&uarr;</a></div></div>");
      result.bind('click', { offset: range.offset }, view.addinationClicked);
      return result;
    } else {
      return '';
    }
  };
  this.render = render;
};

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
picky-client-1.1.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-1.0.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.12.3 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.12.2 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.12.1 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.12.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.11.2 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.11.1 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.11.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.10.5 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.10.4 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.10.2 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.10.1 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.10.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.9.4 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.9.3 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.9.2 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.9.1 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.9.0 sinatra_prototype/javascripts/picky.addination.js
picky-client-0.3.0 sinatra_prototype/javascripts/picky.addination.js