robertgauld/OSMExtender

View on GitHub
app/assets/javascripts/osm_flexi_records/show.js

Summary

Maintainability
D
1 day
Test Coverage
function setTextSize(to) {
  $('.field_head').css('font-size', to);
  $('.field_data').css('font-size', to);
  $('.field_total').css('font-size', to);
  $('.field_count').css('font-size', to);
  $('.label').css('font-size', to);
}
function setRowHeight(to) {
  $('.row_head').css('height', to);
  $('.row_data').css('height', to);
  $('.row_total').css('height', to);
  $('.row_count').css('height', to);
}

function saveCustomSizes(csrfToken) {
  $.ajax({
    url: '/my_preferences/save_custom_sizes',
    type: 'post',
    dataType: 'json',
    headers: {'X-CSRF-Token': csrfToken},
    data: 'text_size=' + parseInt($('.field_head').css('font-size')) + '&row_height=' + parseInt($('.row_head').css('height')),
    async: false,
    success: function(data, status, jqXHR) {
      if (data['saved']) {
        $().toastmessage('showSuccessToast', "Your preferences were saved");
      } else {
        $().toastmessage('showErrorToast', "Your preferences were not saved");
      }
    },
    error: function(jqXHR, textStatus, errorThrown) {
      $().toastmessage('showErrorToast', textStatus);
    }
  })
}


function changeTextSize(by) {
  setTextSize(parseInt($('.field_head').css('font-size')) + by);
}
function changeRowHeight(by) {
  setRowHeight(parseInt($('.row_head').css('height')) + by);
}
function changeColumnWidth(field, by) {
  $('.field_' + field).css('width', parseInt($('.field_' + field).css('width')) + by);
  $('#table').css('width', parseInt($('#table').css('width')) + by);
}