Skip to content
Snippets Groups Projects
Commit e946b940 authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

Issue #2228139: Refactor responsive tables JS.

- Always apply responsive tables to narrow tables that take the full
  width on API.Drupal.org.
parent 45630149
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,6 @@ stylesheets[all][] = css/styles.css ...@@ -25,7 +25,6 @@ stylesheets[all][] = css/styles.css
; -------- Javascript --------------- ; -------- Javascript ---------------
scripts[] = js/bluecheese.js scripts[] = js/bluecheese.js
scripts[] = js/plugins/responsive_tables.js
; -------- Theme based custom Vote Up Down Widgets --------------- ; -------- Theme based custom Vote Up Down Widgets ---------------
......
(function ($) { (function ($) {
$(document).ready(function() { $(document).ready(function() {
$("table").not("#forum table").not(".page-user-track table").not("#project-usage-project-releases").responsivetable(); var windowsize = $(window).width();
$('table').not('#forum table').not('.page-user-track table').not('#project-usage-project-releases').each(function() {
// If the table is wider than the width of the window.
if ($(this).width() > windowsize) {
$(this).addClass('mobile-table');
}
});
// Use mobile tables for narrow tables.
$('.drupalorg-site-api table.views-table').each(function() {
var $this = $(this);
if ($this.width() < 500 && $this.width() === $this.parent().width()) {
$this.addClass('mobile-table');
}
});
}); });
})(jQuery); })(jQuery);
(function($) {
$.fn.responsivetable = function() {
var $window = $(window);
var windowsize = $window.width();
var tables = this;
for (var i = tables.length - 1; i >= 0; i--) {
var tablesize = $(tables[i]).width();
if (windowsize <= tablesize) {
$(tables[i]).addClass("mobile-table");
}
};
return this;
};
})(jQuery);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment