Skip to content

Commit

Permalink
Merge pull request #4068 from IgorA100/patch-141
Browse files Browse the repository at this point in the history
Changed the flip panel control "data-flip-control-object" (skin.js)
  • Loading branch information
connortechnology authored Jun 19, 2024
2 parents ba83300 + b1a35c3 commit 48dc523
Showing 1 changed file with 51 additions and 34 deletions.
85 changes: 51 additions & 34 deletions web/skins/classic/js/skin.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,22 +313,7 @@ if ( currentView != 'none' && currentView != 'login' ) {
const objIconButton = _this_.find("i");
const obj = $j(_this_.attr('data-flip-сontrol-object'));

if ( obj.is(":visible") && !obj.hasClass("hidden-shift")) {
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
objIconButton.html(objIconButton.attr('data-icon-hidden'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
objIconButton.removeClass(objIconButton.attr('data-icon-visible')).addClass(objIconButton.attr('data-icon-hidden'));
}
setCookie('zmFilterBarFlip'+_this_.attr('data-flip-сontrol-object'), 'hidden');
} else { //hidden
obj.removeClass('hidden-shift').addClass('hidden'); //It is necessary to make the block invisible both for JS and for humans
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
objIconButton.html(objIconButton.attr('data-icon-visible'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
objIconButton.removeClass(objIconButton.attr('data-icon-hidden')).addClass(objIconButton.attr('data-icon-visible'));
}
setCookie('zmFilterBarFlip'+_this_.attr('data-flip-сontrol-object'), 'visible');
}
changeButtonIcon(_this_, objIconButton);

const nameFuncBefore = _this_.attr('data-flip-сontrol-run-before-func') ? _this_.attr('data-flip-сontrol-run-before-func') : null;
const nameFuncAfter = _this_.attr('data-flip-сontrol-run-after-func') ? _this_.attr('data-flip-сontrol-run-after-func') : null;
Expand All @@ -339,13 +324,15 @@ if ( currentView != 'none' && currentView != 'login' ) {
if (typeof safeFunc[nameFunc] === 'function') safeFunc[nameFunc]();
});
}
obj.slideToggle("fast", function() {
if (nameFuncAfterComplet) {
$j.each(nameFuncAfterComplet.split(' '), function(i, nameFunc) {
if (typeof safeFunc[nameFunc] === 'function') safeFunc[nameFunc]();
});
}
});
if (!_this_.attr('data-on-click-true')) {
obj.slideToggle("fast", function() {
if (nameFuncAfterComplet) {
$j.each(nameFuncAfterComplet.split(' '), function(i, nameFunc) {
if (typeof safeFunc[nameFunc] === 'function') safeFunc[nameFunc]();
});
}
});
}
if (nameFuncAfter) {
$j.each(nameFuncAfter.split(' '), function(i, nameFunc) {
if (typeof safeFunc[nameFunc] === 'function') safeFunc[nameFunc]();
Expand All @@ -354,30 +341,35 @@ if ( currentView != 'none' && currentView != 'login' ) {
});

// Manage visible filter bar & control button (after document ready)
$j("[data-flip-сontrol-object]").each(function() { //let's go through all objects and set icons
$j("[data-flip-сontrol-object]").each(function() { //let's go through all objects (buttons) and set icons
const _this_ = $j(this);
const сookie = getCookie('zmFilterBarFlip'+_this_.attr('data-flip-сontrol-object'));
const initialStateIcon = _this_.attr('data-initial-state-icon'); //"visible"=Opened block , "hidden"=Closed block or "undefined"=use cookie
const objIconButton = _this_.find("i");
const obj = $j(_this_.attr('data-flip-сontrol-object'));

if (obj.parent().css('display') != 'block') {
obj.wrap('<div style="display: block"></div>');
}

if (сookie == 'hidden') {
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
// initialStateIcon takes priority. If there is no cookie, we assume that it is 'visible'
const stateIcon = (initialStateIcon) ? initialStateIcon : ((сookie == 'hidden') ? 'hidden' : 'visible');
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
if (stateIcon == 'hidden') {
objIconButton.html(objIconButton.attr('data-icon-hidden'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
objIconButton.addClass(objIconButton.attr('data-icon-hidden'));
}
obj.addClass('hidden-shift'); //To prevent jerking when running the "Chosen" script, it is necessary to make the block visible to JS, but invisible to humans!
} else { //no cookies or opened.
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
obj.addClass('hidden-shift'); //To prevent jerking when running the "Chosen" script, it is necessary to make the block visible to JS, but invisible to humans!
} else {
objIconButton.html(objIconButton.attr('data-icon-visible'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
obj.removeClass('hidden-shift');
}
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
if (stateIcon == 'hidden') {
objIconButton.addClass(objIconButton.attr('data-icon-hidden'));
obj.addClass('hidden-shift'); //To prevent jerking when running the "Chosen" script, it is necessary to make the block visible to JS, but invisible to humans!
} else {
objIconButton.addClass(objIconButton.attr('data-icon-visible'));
obj.removeClass('hidden-shift');
}
obj.removeClass('hidden-shift');
}
});

Expand Down Expand Up @@ -417,6 +409,31 @@ if ( currentView != 'none' && currentView != 'login' ) {
applyChosen();
});

/*
* params{visibility: null "visible" or "hidden"} - state of the panel before pressing button
*/
function changeButtonIcon(pressedBtn, target, params) {
const visibility = (!params) ? null : params.visibility;
const objIconButton = pressedBtn.find("i");
const obj = $j(pressedBtn.attr('data-flip-сontrol-object'));
if ((visibility == "visible") || (obj.is(":visible") && !obj.hasClass("hidden-shift"))) {
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
objIconButton.html(objIconButton.attr('data-icon-hidden'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
objIconButton.removeClass(objIconButton.attr('data-icon-visible')).addClass(objIconButton.attr('data-icon-hidden'));
}
setCookie('zmFilterBarFlip'+pressedBtn.attr('data-flip-сontrol-object'), 'hidden');
} else { //hidden
obj.removeClass('hidden-shift').addClass('hidden'); //It is necessary to make the block invisible both for JS and for humans
if (objIconButton.is('[class~="material-icons"]')) { // use material-icons
objIconButton.html(objIconButton.attr('data-icon-visible'));
} else if (objIconButton.is('[class*="fa-"]')) { //use Font Awesome
objIconButton.removeClass(objIconButton.attr('data-icon-hidden')).addClass(objIconButton.attr('data-icon-visible'));
}
setCookie('zmFilterBarFlip'+pressedBtn.attr('data-flip-сontrol-object'), 'visible');
}
}

// After retieving modal html via Ajax, this will insert it into the DOM
function insertModalHtml(name, html) {
let modal = $j('#' + name);
Expand Down

0 comments on commit 48dc523

Please sign in to comment.