Skip to content

Commit

Permalink
Add option to minimize sidebar on list view
Browse files Browse the repository at this point in the history
  • Loading branch information
micker committed Sep 11, 2023
1 parent 0e11f3b commit a51fec9
Show file tree
Hide file tree
Showing 13 changed files with 614 additions and 0 deletions.
7 changes: 7 additions & 0 deletions admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,13 @@
<option value="1">FLEXI_IN_SLIDER</option>
</field>

<field name="" type="separator" default="FLEXI_SIDEBAR_MANAGER" icon_class="icon-list" level="tab_open" box_type="1" remove_boxes="2" />
<field name="sidebar_state" type="fcradio" default="open" label="FLEXI_SIDEBAR_STATE" description="FLEXI_SIDEBAR_STATE_DESC" class="btn-group btn-group-yesno">
<option value="closed">FLEXI_ClOSE</option>
<option value="opened">FLEXI_OPEN</option>
</field>


<field name="" type="separator" default="FLEXI_ITEMS_MANAGER" icon_class="icon-list" level="tab_open" box_type="1" remove_boxes="2" />

<field name="original_content_language" type="fclanguage" default="_site_default_" skip_all="true" label="FLEXI_ORIGINAL_CONTENT_LANGUAGE" description="FLEXI_ORIGINAL_CONTENT_LANGUAGE_DESC">
Expand Down
6 changes: 6 additions & 0 deletions admin/language/en-GB/en-GB.com_flexicontent.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,12 @@ FLEXI_FIELD_VALUE_IS_INVALID="Field %s has invalid value."
; items manager configuration
FLEXI_ITEMS_MANAGER="Items Manager"

FLEXI_SIDEBAR_MANAGER="Sidebar manager"
FLEXI_SIDEBAR_STATE="Sidebar behavior"
FLEXI_SIDEBAR_STATE_DESC="Select the default state for the sidebar when loading the list view in the backend. The default setting is 'Open,' similar to the default state in Joomla's backend. However, there is also the option to set it as 'Closed,' which reduces the sidebar size upon loading while still honoring the user's preference. This functionality applies to various lists such as items, categories, tags, and more."
FLEXI_OPEN="Open"
FLEXI_CLOSE="Close"

FLEXI_IS_SUBTYPE="Is subtype"
FLEXI_IS_SUBTYPE_DESC="Items of this type are not meant to viewable itself. Instead they are meant to be displayed inside other items. e.g. this will hide the preview button in items manager"

Expand Down
54 changes: 54 additions & 0 deletions admin/views/categories/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,3 +814,57 @@ class="<?php echo $this->btn_sm_class; ?> fc_assocs_count"

</form>
</div><!-- #flexicontent end -->
<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>
53 changes: 53 additions & 0 deletions admin/views/fields/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,60 @@ function delAllFilters()

</form>
</div><!-- #flexicontent end -->
<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>

<?php
JFactory::getDocument()->addScriptDeclaration('
Expand Down
55 changes: 55 additions & 0 deletions admin/views/filemanager/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,61 @@ function fman_set_cids(el)

</div><!-- #flexicontent end -->

<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>

<?php
JFactory::getDocument()->addScriptDeclaration('
function fc_edit_mmdata_modal_load( container )
Expand Down
55 changes: 55 additions & 0 deletions admin/views/groups/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,58 @@ function delAllFilters()

</form>
</div><!-- #flexicontent end -->

<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>
55 changes: 55 additions & 0 deletions admin/views/import/tmpl/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

$params = $this->cparams;
$document = JFactory::getDocument();
$cparams = JComponentHelper::getParams('com_flexicontent');

if (FLEXI_J40GE) JToolbarHelper::inlinehelp();

Expand Down Expand Up @@ -724,3 +725,57 @@

</form>
</div><!-- #flexicontent end -->
<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>
53 changes: 53 additions & 0 deletions admin/views/items/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,60 @@ class="<?php echo $this->btn_sm_class; ?> fc_assocs_count"

</form>
</div><!-- #flexicontent end -->
<?php
$sidebar_state = $cparams->get('sidebar_state', 'closed');
if(($sidebar_state) == 'closed') : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var sidebar = document.querySelector('#sidebar-wrapper');
var wrapper = document.querySelector('#wrapper');
var menuCollapse = document.querySelector('#menu-collapse');
var menuIcon = document.querySelector('#menu-collapse-icon');
var navLogo = document.querySelector('#header .logo');
// Retrieve sidebar state from localStorage
var sidebarState = localStorage.getItem('sidebar');
console.log(sidebarState);


// Apply initial sidebar state
if (sidebarState === 'closed') {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
} else if (sidebarState === 'open') {
wrapper.classList.remove('closed');
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
navLogo.classList.remove('small');
} else {
wrapper.classList.add('closed');
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
}


// Handle menu click
menuCollapse.addEventListener('click', function() {
// Toggle wrapper class

// Update icon
if (wrapper.classList.contains('closed')) {
menuIcon.classList.remove('icon-toggle-on');
menuIcon.classList.add('icon-toggle-off');
navLogo.classList.add('small');
localStorage.setItem('sidebar', 'closed');
} else {
menuIcon.classList.remove('icon-toggle-off');
menuIcon.classList.add('icon-toggle-on');
localStorage.setItem('sidebar', 'open');
navLogo.classList.remove('small');
}
});
});
</script>
<?php endif; ?>
<?php
Factory::getDocument()->addScriptDeclaration('
function fc_edit_jarticle_modal_load( container )
Expand Down
Loading

0 comments on commit a51fec9

Please sign in to comment.