Minecraft Wiki
No edit summary
No edit summary
Line 41: Line 41:
   
 
if (modalTableWidth != null && modalTableWidth > $('body').width()) {
 
if (modalTableWidth != null && modalTableWidth > $('body').width()) {
$('body').css('width', modalTableWidth + 48);
+
$('body').css('width', modalTableWidth + 64);
 
}
 
}
 
});
 
});

Revision as of 22:20, 24 November 2015

$(document).ready(function() {
  function scrollAnchor(id) {
    var scrollTo = $('#' + id).offset().top - 15;
    window.scrollTo(0, scrollTo);
    alert(scrollTo);
  }

  $('table:not(.msgbox):not(.modal-table)').each(function(i, element) {
    var tableType;
    var buttonText = '';

    if ($(element).attr('class') == 'infobox-rows') {
      tableType = 'Info Box';
    } else {
      tableType = 'Table';
    }

    $(element).find('tbody td').each(function(i, element) {
      if ($(element).text().length) {
        buttonText = buttonText + $(element).text() + ', ';
      }
    });

    buttonText = buttonText.substr(0, 62) + '...';

    $(element).before('<button type="button" class="modal-button"><span><strong>View ' +
      tableType +
      ': </strong>' +
      buttonText +
      '</span></button>');
  });

  $('button.modal-button').click(function() {
    var table = this.nextSibling.cloneNode(true);
    table.classList.add('modal-table');
    $(table).attr('style', '');
    console.log(table.outerHTML);
  });

  var modalTableWidth = $('body').find('table.modal-table').width();

  if (modalTableWidth != null && modalTableWidth > $('body').width()) {
    $('body').css('width', modalTableWidth + 64);
  }
});