Просмотр исходного кода

WIP: apply bootstrap theme

* open/close sidebar
Yuki Takei 8 лет назад
Родитель
Сommit
3de364a65b

+ 3 - 3
lib/views/layout/layout.html

@@ -105,7 +105,7 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
 
 {% block html_body %}
 <body
-  class="crowi main-container {% block html_base_css %}{% endblock %} {% if 'crowi-plus' === layoutType() %}crowi-plus{% endif %}"
+  class="crowi main-container content-wrapper {% block html_base_css %}{% endblock %} {% if 'crowi-plus' === layoutType() %}crowi-plus{% endif %}"
   data-me="{{ user._id.toString() }}"
   data-plugin-enabled="{{ isEnabledPlugins() }}"
  {% block html_base_attr %}{% endblock %}
@@ -140,7 +140,7 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
             <!-- <img src="../plugins/images/agileadmin-text.png" alt="home" class="dark-logo" /> -->
             <!--This is light logo text-->
             <!-- <img src="../plugins/images/agileadmin-text-dark.png" alt="home" class="light-logo" /> -->
-            <span class="light-logo-text">
+            <span class="logo-text light-logo-text">
               <svg xmlns="http://www.w3.org/2000/svg">
                 <text x="0" y="{{22+appTitleFontSize/2}}" font-size="{{appTitleFontSize}}">
                   {% block title %}{{ appTitle }}{% endblock %}
@@ -154,7 +154,7 @@ gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js
       <ul class="nav navbar-top-links navbar-left hidden-xs">
         <li>
           <a class="open-close hidden-xs waves-effect waves-light">
-            <i class="ti-angle-left"></i>
+            <i class="ti-menu"></i>
           </a>
         </li>
         <li>

+ 63 - 46
resource/js/legacy/thirdparty-js/agile-admin.js

@@ -3,6 +3,56 @@ require('jquery-slimscroll');
 
 require('./waves');
 
+let aaSettings = undefined;
+
+function loadSettings() {
+  const settingsStr = sessionStorage.getItem('agile-admin') || '{}';
+  aaSettings = JSON.parse(settingsStr);
+}
+
+function saveSettings() {
+  sessionStorage.setItem('agile-admin', JSON.stringify(aaSettings));
+}
+
+// load settings from sessionStorage
+loadSettings();
+
+//Loads the correct sidebar on window load,
+//collapses the sidebar on window resize.
+// Sets the min-height of #page-wrapper to window size
+$(window).on("load resize", function () {
+    let topOffset = 60;
+    const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
+    if (width < 768) {
+        $('div.navbar-collapse').addClass('collapse');
+        topOffset = 100; // 2-row-menu
+    }
+    else {
+        $('div.navbar-collapse').removeClass('collapse');
+    }
+    let height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
+    height = height - topOffset;
+    if (height < 1) height = 1;
+    if (height > topOffset) {
+        $("#page-wrapper").css("min-height", (height) + "px");
+    }
+});
+// This is for resize window
+$(window).on("load resize", function () {
+    const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
+    if (!aaSettings.isSidebarOpened || width < 1170) {
+        $('body').addClass('content-wrapper');
+        $(".open-close i").addClass('ti-menu');
+        $(".open-close i").removeClass('ti-angle-left');
+        $(".sidebar-nav, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
+    }
+    else {
+        $('body').removeClass('content-wrapper');
+        $(".open-close i").addClass('ti-angle-left');
+        $(".open-close i").removeClass('ti-menu');
+    }
+});
+
 $(document).ready(function () {
   $(function () {
       $(".preloader").fadeOut();
@@ -35,58 +85,21 @@ $(document).ready(function () {
           $('.fxsdr').attr('checked', false);
       }
   });
-  //Loads the correct sidebar on window load,
-  //collapses the sidebar on window resize.
-  // Sets the min-height of #page-wrapper to window size
   $(function () {
-      $(window).bind("load resize", function () {
-          let topOffset = 60;
-          const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
-          if (width < 768) {
-              $('div.navbar-collapse').addClass('collapse');
-              topOffset = 100; // 2-row-menu
-          }
-          else {
-              $('div.navbar-collapse').removeClass('collapse');
-          }
-          let height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
-          height = height - topOffset;
-          if (height < 1) height = 1;
-          if (height > topOffset) {
-              $("#page-wrapper").css("min-height", (height) + "px");
-          }
-      });
-      var url = window.location;
-      var element = $('ul.nav a').filter(function () {
-          return this.href == url || url.href.indexOf(this.href) == 0;
-      }).addClass('active').parent().parent().addClass('in').parent();
-      if (element.is('li')) {
-          element.addClass('active');
-      }
-  });
-  // This is for resize window
-  $(function () {
-      $(window).bind("load resize", function () {
-          const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
-          if (width < 1170) {
-              $('body').addClass('content-wrapper');
-              $(".open-close i").addClass('ti-menu');
-              $(".open-close i").removeClass('ti-angle-left');
-              $(".sidebar-nav, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
-              $(".logo span").hide();
-          }
-          else {
-              $('body').removeClass('content-wrapper');
-              $(".open-close i").addClass('ti-angle-left');
-              $(".open-close i").removeClass('ti-menu');
-              $(".logo span").show();
-          }
-      });
+    var url = window.location;
+    var element = $('ul.nav a').filter(function () {
+        return this.href == url || url.href.indexOf(this.href) == 0;
+    }).addClass('active').parent().parent().addClass('in').parent();
+    if (element.is('li')) {
+        element.addClass('active');
+    }
   });
   // This is for click on open close button
   // Sidebar open close
   $(".open-close").on('click', function () {
       if ($("body").hasClass("content-wrapper")) {
+          aaSettings.isSidebarOpened = true;
+          saveSettings();
           $("body").trigger("resize");
           $(".sidebar-nav, .slimScrollDiv").css("overflow", "hidden").parent().css("overflow", "visible");
           $("body").removeClass("content-wrapper");
@@ -95,6 +108,8 @@ $(document).ready(function () {
           $(".logo span").show();
       }
       else {
+          aaSettings.isSidebarOpened = false;
+          saveSettings();
           $("body").trigger("resize");
           $(".sidebar-nav, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
           $("body").addClass("content-wrapper");
@@ -103,6 +118,7 @@ $(document).ready(function () {
           $(".logo span").hide();
       }
   });
+  /*
   // Collapse Panels
   (function ($, window, document) {
       var panelSelector = '[data-perform="panel-collapse"]';
@@ -148,6 +164,7 @@ $(document).ready(function () {
           }
       });
   }(jQuery, window, document));
+  */
   //tooltip
   $(function () {
           $('[data-toggle="tooltip"]').tooltip()

+ 4 - 1
resource/styles/scss/_override-agileadmin.scss

@@ -2,7 +2,10 @@
  * Sidebar
  */
 .content-wrapper {
-  // hide sidebar by agile-admin completely
+  // hide elements by agile-admin completely
+  .logo .logo-text {
+    display: none;
+  }
   .sidebar {
     display: none;
   }