Parcourir la source

enhanced Layout.js with options for login auto height with interval ability

REJack il y a 5 ans
Parent
commit
b7efadbbca

+ 23 - 9
build/js/Layout.js

@@ -54,7 +54,8 @@ const Layout = (($) => {
 
   const Default = {
     scrollbarTheme : 'os-theme-light',
-    scrollbarAutoHide: 'l'
+    scrollbarAutoHide: 'l',
+    loginRegisterAutoHeight: true,
   }
 
   /**
@@ -113,11 +114,30 @@ const Layout = (($) => {
       }
     }
 
+    fixLoginRegisterHeight() {
+      if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
+        $('body, html').css('height', 'auto')
+      } else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
+        let box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height()
+
+        if ($('body').css('min-height') !== box_height) {
+          $('body').css('min-height', box_height)
+        }
+      }
+    }
+
     // Private
 
     _init() {
       // Activate layout height watcher
       this.fixLayoutHeight()
+
+      if (this._config.loginRegisterAutoHeight === true) {      
+        this.fixLoginRegisterHeight()
+      } else if (Number.isInteger(this._config.loginRegisterAutoHeight)) {      
+        setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight);
+      }
+
       $(Selector.SIDEBAR)
         .on('collapsed.lte.treeview expanded.lte.treeview', () => {
           this.fixLayoutHeight()
@@ -140,14 +160,6 @@ const Layout = (($) => {
         this.fixLayoutHeight()
       })
 
-      if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
-        $('body, html').css('height', 'auto')
-      } else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
-        let box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height()
-
-        $('body').css('min-height', box_height);
-      }
-
       $('body.hold-transition').removeClass('hold-transition')
     }
 
@@ -178,6 +190,8 @@ const Layout = (($) => {
 
         if (config === 'init' || config === '') {
           data['_init']()
+        } else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') {
+          data[config]()
         }
       })
     }

+ 23 - 9
dist/js/adminlte.js

@@ -326,7 +326,8 @@
     };
     var Default = {
       scrollbarTheme: 'os-theme-light',
-      scrollbarAutoHide: 'l'
+      scrollbarAutoHide: 'l',
+      loginRegisterAutoHeight: true
     };
     /**
      * Class Definition
@@ -389,6 +390,18 @@
             });
           }
         }
+      };
+
+      _proto.fixLoginRegisterHeight = function fixLoginRegisterHeight() {
+        if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
+          $('body, html').css('height', 'auto');
+        } else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
+          var box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height();
+
+          if ($('body').css('min-height') !== box_height) {
+            $('body').css('min-height', box_height);
+          }
+        }
       } // Private
       ;
 
@@ -397,6 +410,13 @@
 
         // Activate layout height watcher
         this.fixLayoutHeight();
+
+        if (this._config.loginRegisterAutoHeight === true) {
+          this.fixLoginRegisterHeight();
+        } else if (Number.isInteger(this._config.loginRegisterAutoHeight)) {
+          setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight);
+        }
+
         $(Selector.SIDEBAR).on('collapsed.lte.treeview expanded.lte.treeview', function () {
           _this.fixLayoutHeight();
         });
@@ -411,14 +431,6 @@
         $(window).resize(function () {
           _this.fixLayoutHeight();
         });
-
-        if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
-          $('body, html').css('height', 'auto');
-        } else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
-          var box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height();
-          $('body').css('min-height', box_height);
-        }
-
         $('body.hold-transition').removeClass('hold-transition');
       };
 
@@ -451,6 +463,8 @@
 
           if (config === 'init' || config === '') {
             data['_init']();
+          } else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') {
+            data[config]();
           }
         });
       };

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
dist/js/adminlte.js.map


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
dist/js/adminlte.min.js


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
dist/js/adminlte.min.js.map


+ 2 - 0
docs/javascript/layout.md

@@ -16,6 +16,7 @@ This plugin is activated automatically upon window load.
 |-|-|-|-
 |scrollbarTheme | Boolean | `os-theme-light` | Scrollbar Theme used while SideBar Fixed
 |scrollbarAutoHide | Boolean | `l` | Scrollbar auto-hide trigger
+|loginRegisterAutoHeight | Boolean|Integer | true | Login & Register Height Correction
 |---
 {: .table .table-bordered .bg-light}
 
@@ -33,6 +34,7 @@ This plugin is activated automatically upon window load.
 | Method | Description
 |-|-
 |fixLayoutHeight | Fix the content / control sidebar height and activates OverlayScrollbars for sidebar / control sidebar
+|fixLoginRegisterHeight | Fix the login & register body height
 {: .table .table-bordered .bg-light}
 
 Example: `$('body').Layout('fixLayoutHeight')`

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff