Sha256: 4b728740f75d353bbf6223f7a2fd051c94d11f7ef124a0a1986b9e63c3730ea1

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

var contentWidth, previousPosition;

function getRecord(div, index, which) {
  var data = {index: index};
  if (typeof(which) != "object") {
    data['which'] = which;
  }
  div.load(detailsUrl, data, groupFetched);
}

function startCallback(e, ui) {
  previousPosition = ui.position;
}

function dragCallback(e, ui) {
  var handle = $(this);
  var column = handle.parent();
  var originalWidth = column.width();
  var container = column.parent();
  var diff = ui.position.left - previousPosition.left;
  var newWidth = originalWidth + diff;

  if (newWidth < 15) {
    // don't allow the column to be smaller than 15
    return false;
  }

  var newTotalWidth = container.width() + container.siblings('.result-group').width() + diff;
  if (newTotalWidth > contentWidth) {
    // TODO: make the column to the right smaller
    return false;
  }

  var selector = column.hasClass('column-name') ? '.column-name' : '.column-value';
  container.find(selector).width(newWidth);

  previousPosition = ui.position;
}

function groupFetched(responseText, textStatus, xhr) {
  var div = $(this);
  div.find('.resize-handle').draggable({
    axis: 'x',
    start: startCallback,
    drag: dragCallback,
  });
  div.find('.record-nav').click(function() {
    var button = $(this);
    var klass = button.attr('class')
    var which = klass.match(/which-(\d)/);
    var num = klass.match(/record-(\d+)/);
    if (num) {
      getRecord(div, num[1], which ? which[1] : null);
    }
  });
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
coupler-0.0.9-java webroot/public/js/results.js
coupler-0.0.8-java webroot/public/js/results.js
coupler-0.0.7-java webroot/public/js/results.js
coupler-0.0.6-java webroot/public/js/results.js
coupler-0.0.4-java webroot/public/js/results.js
coupler-0.0.3-java webroot/public/js/results.js
coupler-0.0.2-java webroot/public/js/results.js
coupler-0.0.1-java webroot/public/js/results.js