]> git.nbdom.net Git - nb.git/commitdiff
responsive
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 16 Feb 2016 22:38:07 +0000 (22:38 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 16 Feb 2016 22:38:07 +0000 (22:38 +0000)
lib/js/nb.js

index 37e17da07f64d227e4cf747a8c4ef47193b2385c..2c42bd14fc829aafb784909d1ba4462e8bf198fb 100644 (file)
@@ -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'));
 
         }
 
-      });
-    }
+      }
+
+    });
 
   }