summaryrefslogtreecommitdiffstatshomepage
path: root/core/misc/tableresponsive.js
diff options
context:
space:
mode:
authorAlex Pott <alex.a.pott@googlemail.com>2020-01-30 09:08:38 +0000
committerAlex Pott <alex.a.pott@googlemail.com>2020-01-30 09:08:38 +0000
commit4577772da05ddb0c2b67c1fc739f38707e430e06 (patch)
treee244921105b95bb5b6de3d3cc89175b7ef92ec3c /core/misc/tableresponsive.js
parent01793fbc8e7cb6a1a63f2ce45096ef35423bf965 (diff)
downloaddrupal-4577772da05ddb0c2b67c1fc739f38707e430e06.tar.gz
drupal-4577772da05ddb0c2b67c1fc739f38707e430e06.zip
Issue #3101543 by lauriii, bnjmnm, ravi.shankar, alexpott: Update core JavaScript dependencies listed in package.json
Diffstat (limited to 'core/misc/tableresponsive.js')
-rw-r--r--core/misc/tableresponsive.js18
1 files changed, 5 insertions, 13 deletions
diff --git a/core/misc/tableresponsive.js b/core/misc/tableresponsive.js
index 0de5eee23cd..ffcb0a11a8e 100644
--- a/core/misc/tableresponsive.js
+++ b/core/misc/tableresponsive.js
@@ -11,32 +11,28 @@
this.$table = $(table);
this.showText = Drupal.t('Show all columns');
this.hideText = Drupal.t('Hide lower priority columns');
-
this.$headers = this.$table.find('th');
-
this.$link = $('<button type="button" class="link tableresponsive-toggle"></button>').attr('title', Drupal.t('Show table cells that were hidden to make the table fit within a small screen.')).on('click', $.proxy(this, 'eventhandlerToggleColumns'));
-
this.$table.before($('<div class="tableresponsive-toggle-columns"></div>').append(this.$link));
-
$(window).on('resize.tableresponsive', $.proxy(this, 'eventhandlerEvaluateColumnVisibility')).trigger('resize.tableresponsive');
}
Drupal.behaviors.tableResponsive = {
attach: function attach(context, settings) {
var $tables = $(context).find('table.responsive-enabled').once('tableresponsive');
+
if ($tables.length) {
var il = $tables.length;
+
for (var i = 0; i < il; i++) {
TableResponsive.tables.push(new TableResponsive($tables[i]));
}
}
}
};
-
$.extend(TableResponsive, {
tables: []
});
-
$.extend(TableResponsive.prototype, {
eventhandlerEvaluateColumnVisibility: function eventhandlerEvaluateColumnVisibility(e) {
var pegged = parseInt(this.$link.data('pegged'), 10);
@@ -63,42 +59,38 @@
self.$table.find('tbody tr').each(function () {
var $cells = $(this).find('td').eq(position);
$cells.show();
-
self.$revealedCells = $().add(self.$revealedCells).add($cells);
});
$header.show();
-
self.$revealedCells = $().add(self.$revealedCells).add($header);
});
this.$link.text(this.hideText).data('pegged', 1);
} else {
this.$revealedCells.hide();
-
this.$revealedCells.each(function (index, element) {
var $cell = $(this);
var properties = $cell.attr('style').split(';');
var newProps = [];
-
var match = /^display\s*:\s*none$/;
+
for (var i = 0; i < properties.length; i++) {
var prop = properties[i];
prop.trim();
-
var isDisplayNone = match.exec(prop);
+
if (isDisplayNone) {
continue;
}
+
newProps.push(prop);
}
$cell.attr('style', newProps.join(';'));
});
this.$link.text(this.showText).data('pegged', 0);
-
$(window).trigger('resize.tableresponsive');
}
}
});
-
Drupal.TableResponsive = TableResponsive;
})(jQuery, Drupal, window); \ No newline at end of file