From: Nicolas Boisselier Date: Tue, 16 Feb 2016 22:38:07 +0000 (+0000) Subject: responsive X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=86f002349ceddf8a7b49fa1e41fc3eba06bcf253;p=nb.git responsive --- diff --git a/lib/js/nb.js b/lib/js/nb.js index 37e17da0..2c42bd14 100644 --- a/lib/js/nb.js +++ b/lib/js/nb.js @@ -26,48 +26,61 @@ function NB() { } this.resize = function() { + + // table to div + if ($('#_responsive').css('content') != 'none') { + that.table2div('table.rows'); + return true; + } else { + $('table.rows').addClass('t2d'); + $('.t2d-th').each(function(){ + $(this).remove(); + }); + } + // Max width for blocks var block = $("table, div"); - if (block) { - var width = $(window).width(); - var set_width = width - 20; - block.each(function(){ - - var first_width = $(this).attr('nb.resize'); - var cur_width = $(this).width(); - if (cur_width > width) { - if (!first_width) { - $(this).attr('nb.resize',cur_width); - } - if (this.tagName == 'TABLE') $(this).css({ - 'display': 'block', - 'overflow': 'scroll', - }); - $(this).width(set_width); - //console.log(this.tagName+' : '+$(this).width()+' / '+width); + if (!block) return false; - } else { + var width = $(window).width(); + var set_width = width - 20; + block.each(function(){ - if (first_width) { + var first_width = $(this).attr('nb-resize'); + var cur_width = $(this).width(); - if (this.tagName == 'TABLE') { - $(this).css({ - 'display': 'table', - 'overflow': 'visible', - }); + if (cur_width > width) { + if (!first_width) { + $(this).attr('nb-resize',cur_width); + } + if (this.tagName == 'TABLE') $(this).css({ + 'display': 'block', + 'overflow': 'scroll', + }); + $(this).width(set_width); + //console.log(this.tagName+' : '+$(this).width()+' / '+width); - } else { - $(this).width((set_width < first_width) ? set_width : first_width); + } else { - } - //console.log(this.tagName+' : '+$(this).attr('nb.resize')); + if (first_width) { + + if (this.tagName == 'TABLE') { + $(this).css({ + 'display': 'table', + 'overflow': 'visible', + }); + + } else { + $(this).width((set_width < first_width) ? set_width : first_width); } + //console.log(this.tagName+' : '+$(this).attr('nb-resize')); } - }); - } + } + + }); }