aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/adm/style/admin.js
diff options
context:
space:
mode:
authorVjacheslav Trushkin <cyberalien@gmail.com>2013-10-26 00:46:20 +0300
committerVjacheslav Trushkin <cyberalien@gmail.com>2013-10-26 22:00:23 +0300
commitb80f213995df6456cf35897a7a35d7943baa5ebb (patch)
tree3a51ef927a698aaa01a4cc72d0f64f14b2e3c7a0 /phpBB/adm/style/admin.js
parent5f39fd470c7c2742e852e8b24de88de02a544250 (diff)
downloadforums-b80f213995df6456cf35897a7a35d7943baa5ebb.tar
forums-b80f213995df6456cf35897a7a35d7943baa5ebb.tar.gz
forums-b80f213995df6456cf35897a7a35d7943baa5ebb.tar.bz2
forums-b80f213995df6456cf35897a7a35d7943baa5ebb.tar.xz
forums-b80f213995df6456cf35897a7a35d7943baa5ebb.zip
[ticket/11957] Responsive ACP tables
PHPBB3-11957
Diffstat (limited to 'phpBB/adm/style/admin.js')
-rw-r--r--phpBB/adm/style/admin.js97
1 files changed, 97 insertions, 0 deletions
diff --git a/phpBB/adm/style/admin.js b/phpBB/adm/style/admin.js
index a9e00ab9d7..385e49dc87 100644
--- a/phpBB/adm/style/admin.js
+++ b/phpBB/adm/style/admin.js
@@ -36,6 +36,103 @@ function parse_document(container)
blocks.filter(':first').addClass('active');
}
});
+
+ /**
+ * Responsive tables
+ */
+ container.find('table').not('.not-responsive').each(function() {
+ var $this = $(this),
+ th = $this.find('thead > tr > th'),
+ columns = th.length,
+ headers = [],
+ totalHeaders = 0,
+ i, headersLength;
+
+ // Find columns
+ $this.find('colgroup:first').children().each(function(i) {
+ var column = $(this);
+ if (column.hasClass('col1')) {
+ $this.find('td:nth-child(' + (i + 1) + ')').addClass('col1');
+ }
+ if (column.hasClass('col2')) {
+ $this.find('td:nth-child(' + (i + 1) + ')').addClass('col2');
+ }
+ });
+
+ // Find each header
+ if (!$this.data('no-responsive-header'))
+ {
+ th.each(function(column) {
+ var cell = $(this),
+ colspan = parseInt(cell.attr('colspan')),
+ dfn = cell.attr('data-dfn'),
+ text = dfn ? dfn : cell.text();
+
+ colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
+
+ for (i=0; i<colspan; i++) {
+ headers.push(text);
+ }
+ totalHeaders ++;
+
+ if (dfn && !column) {
+ $this.addClass('show-header');
+ }
+ });
+ }
+
+ headersLength = headers.length;
+
+ // Add header text to each cell as <dfn>
+ $this.addClass('responsive');
+
+ if (totalHeaders < 2) {
+ $this.addClass('show-header');
+ return;
+ }
+
+ $this.find('tbody > tr').each(function() {
+ var row = $(this),
+ cells = row.children('td'),
+ column = 0;
+
+ if (cells.length == 1) {
+ row.addClass('big-column');
+ return;
+ }
+
+ cells.each(function() {
+ var cell = $(this),
+ colspan = parseInt(cell.attr('colspan')),
+ text = cell.text().trim();
+
+ if (headersLength <= column) {
+ return;
+ }
+
+ if (text.length && text !== '-') {
+ cell.prepend('<dfn style="display: none;">' + headers[column] + '</dfn>');
+ }
+ else {
+ cell.addClass('empty');
+ }
+
+ colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
+ column += colspan;
+ });
+ });
+ });
+
+ /**
+ * Hide empty responsive tables
+ */
+ container.find('table.responsive > tbody').each(function() {
+ var items = $(this).children('tr');
+ if (items.length == 0)
+ {
+ $(this).parent('table:first').addClass('responsive-hide');
+ }
+ });
}
/**