Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sidebar collapse regression #1409

Merged
merged 3 commits into from Nov 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/layout_api.php
Expand Up @@ -946,7 +946,7 @@ function layout_sidebar_end() {

$t_collapse_block = is_collapsed( 'sidebar' );

echo '<div class="sidebar-toggle sidebar-collapse">';
echo '<div id="sidebar-btn" class="sidebar-toggle sidebar-collapse">';
if( layout_is_rtl() ) {
$t_block_icon = $t_collapse_block ? 'fa-angle-double-left' : 'fa-angle-double-right';
echo '<i data-icon2="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-right"
Expand Down
34 changes: 19 additions & 15 deletions js/common.js
Expand Up @@ -80,21 +80,25 @@ $(document).ready( function() {
SetCookie( "collapse_settings", t_cookie );
});

$('#sidebar.sidebar-toggle').on('click', function (event) {
var t_id = $(this).attr('id');
var t_cookie = GetCookie("collapse_settings");
if (1 == g_collapse_clear) {
t_cookie = "";
g_collapse_clear = 0;
}
if( $(this).parent().hasClass( "menu-min" ) ) {
t_cookie = t_cookie.replace("|" + t_id + ":1", '');
t_cookie = t_cookie + "|" + t_id + ":0";
} else {
t_cookie = t_cookie.replace("|" + t_id + ":0", '');
t_cookie = t_cookie + "|" + t_id + ":1";
}
SetCookie("collapse_settings", t_cookie);
$('#sidebar-btn.sidebar-toggle').on('click', function (event) {
var t_cookie;
var t_sidebar = $(this).closest('.sidebar');
var t_id = t_sidebar.attr('id');

if (1 == g_collapse_clear) {
t_cookie = "";
g_collapse_clear = 0;
} else {
// Get collapse state and remove the old value
t_cookie = GetCookie("collapse_settings");
t_cookie = t_cookie.replace(new RegExp('\\|' + t_id + ':.'), '');
}

// Save the new collapse state
var t_value = !t_sidebar.hasClass("menu-min") | 0;
t_cookie += '|' + t_id + ':' + t_value;

SetCookie("collapse_settings", t_cookie);
});

$('input[type=text].typeahead').each(function() {
Expand Down