From a256f7bf12a4c65cbb7ce4551c7858454976ff3c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 19 Mar 2015 22:32:18 +0100 Subject: Collapsing is remembered during a session --- header.php | 4 ++++ include/ajax-collapse.php | 8 ++++++++ index.php | 3 ++- js/businessadmin.js | 28 +++++++++++++++++++++++----- nav.php | 20 ++++++++++++++------ 5 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 include/ajax-collapse.php diff --git a/header.php b/header.php index 20873b3..ffbbc6d 100644 --- a/header.php +++ b/header.php @@ -58,6 +58,10 @@ + + diff --git a/include/ajax-collapse.php b/include/ajax-collapse.php new file mode 100644 index 0000000..e49c6fd --- /dev/null +++ b/include/ajax-collapse.php @@ -0,0 +1,8 @@ + './include/assignments.php', '/assignments/new' => './include/assignments-new.php', '/assignments/edit' => './include/assignments-edit.php', - '/about' => './include/about.php' + '/about' => './include/about.php', + '/ajax/collapse' => './include/ajax-collapse.php' ); $_page = null; diff --git a/js/businessadmin.js b/js/businessadmin.js index 34b20fb..a82be81 100644 --- a/js/businessadmin.js +++ b/js/businessadmin.js @@ -85,19 +85,37 @@ $(document).ready(function(){ // Collapse menu var collapsed = false; - $('#collapse-menu').click(function(){ + $('#collapse-menu').click(function(e, p){ + var animation = 200; + if (typeof p != 'undefined' && p.load) + animation = 0; + if (!collapsed) - $('.nav-title').hide(); + $('.nav-title').finish().hide(); $('.sidebar').animate({ width: collapsed ? 250 : 50 - }, 200); + }, animation); $('#page-wrapper').animate({ marginLeft: collapsed ? 250 : 50 - }, 200); + }, animation); if (collapsed) - $('.nav-title').delay(200).queue(function(){$(this).show()}); + $('.nav-title').finish().delay(animation).queue(function(){$(this).show()}); $(this).find('i.fa').removeClass('fa-caret-square-o-left fa-caret-square-o-right').addClass('fa-caret-square-o-' + (collapsed ? 'left' : 'right')); collapsed = !collapsed; + + $.ajax({ + url: const_url_external + 'ajax/collapse', + method: 'GET', + crossDomain: true, + cache: false, + xhrFields: { + withCredentials: true + }, + data: { + setting: collapsed + } + }); + return true; }); }); \ No newline at end of file diff --git a/nav.php b/nav.php index bf5b16a..155a95a 100644 --- a/nav.php +++ b/nav.php @@ -93,27 +93,35 @@ -- cgit v1.2.3