| 1 |
(function ($) { |
| 2 |
("use strict"); |
| 3 |
/************************************* |
| 4 |
Menu Block |
| 5 |
*************************************/ |
| 6 |
setTimeout(() => { |
| 7 |
handleMegaMenuWidth("setTimeout"); |
| 8 |
}, 10); |
| 9 |
handleMegaMenuWidth("normal"); |
| 10 |
|
| 11 |
function handleMegaMenuWidth(t) { |
| 12 |
if ($(".editor-styles-wrapper")?.length) { |
| 13 |
return; |
| 14 |
} |
| 15 |
const hasMegaMenu = $( |
| 16 |
".wp-block-ultimate-post-menu-item.hasMegaMenuChild > .ultp-menu-item-wrapper > .ultp-menu-item-content" |
| 17 |
); |
| 18 |
if (hasMegaMenu.length > 0) { |
| 19 |
hasMegaMenu.each(function () { |
| 20 |
if ($(this).hasClass("ultpMegaWindowWidth")) { |
| 21 |
const bodyWrapperWidth = $("body")?.width() || 1200; |
| 22 |
const bodyWrapperLeft = $("body")?.offset()?.left || 0; |
| 23 |
const contentLeft = $(this)?.offset()?.left || 0; |
| 24 |
$(this) |
| 25 |
.find( |
| 26 |
" > .wp-block-ultimate-post-mega-menu > .ultp-mega-menu-wrapper" |
| 27 |
) |
| 28 |
.css({ |
| 29 |
maxWidth: `${bodyWrapperWidth}px`, |
| 30 |
boxSizing: "border-box", |
| 31 |
}); |
| 32 |
// $(this).css({ "left" : `${bodyWrapperLeft - contentLeft}px`}); |
| 33 |
|
| 34 |
const siblingLeft = |
| 35 |
$(this).siblings(".ultp-menu-item-label-container")?.offset() |
| 36 |
?.left || 0; |
| 37 |
$(this).css({ left: `${bodyWrapperLeft - siblingLeft}px` }); |
| 38 |
|
| 39 |
//do not remove $('.wp-block-ultimate-post-menu-item.hasMegaMenuChild > .ultp-menu-item-wrapper > .ultp-menu-item-content.ultpMegaWindowWidth > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block > .wp-block-ultimate-post-mega-menu > .ultp-mega-menu-wrapper').css({ "maxWidth" : `${editorMainWrapperWidth}px`, "boxSizing": "border-box"}); |
| 40 |
//do not remove $('.wp-block-ultimate-post-menu-item.hasMegaMenuChild > .ultp-menu-item-wrapper > .ultp-menu-item-content.ultpMegaWindowWidth > .block-editor-inner-blocks').css({ "left" : `-${contentLeft - editorMainWrapperLeft}px`}); |
| 41 |
} else if ($(this).hasClass("ultpMegaMenuWidth")) { |
| 42 |
const closetMenuWidth = |
| 43 |
$(this).closest(".wp-block-ultimate-post-menu")?.width() || 800; |
| 44 |
const closetMenuLeft = |
| 45 |
$(this).closest(".wp-block-ultimate-post-menu")?.offset()?.left || |
| 46 |
0; |
| 47 |
const contentLeft = $(this)?.offset()?.left || 0; |
| 48 |
$(this) |
| 49 |
.find( |
| 50 |
" > .wp-block-ultimate-post-mega-menu > .ultp-mega-menu-wrapper" |
| 51 |
) |
| 52 |
.css({ maxWidth: `${closetMenuWidth}px`, boxSizing: "border-box" }); |
| 53 |
$(this).css({ left: `${closetMenuLeft - contentLeft}px` }); |
| 54 |
const siblingLeft = |
| 55 |
$(this).siblings(".ultp-menu-item-label-container")?.offset() |
| 56 |
?.left || 0; |
| 57 |
$(this).css({ left: `${closetMenuLeft - siblingLeft}px` }); |
| 58 |
} else { |
| 59 |
$(this) |
| 60 |
.find( |
| 61 |
" > .wp-block-ultimate-post-mega-menu > .ultp-mega-menu-wrapper" |
| 62 |
) |
| 63 |
.css({ maxWidth: ``, boxSizing: "" }); |
| 64 |
$(this).css({ left: `` }); |
| 65 |
} |
| 66 |
}); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
/* |
| 71 |
Menu responsive |
| 72 |
*/ |
| 73 |
const isFront = $("body.postx-admin-page").length == 0; |
| 74 |
if (isFront) { |
| 75 |
$(window).on("resize", function () { |
| 76 |
handleMegaMenuWidth("resize"); |
| 77 |
}); |
| 78 |
} |
| 79 |
let currentStack = ""; |
| 80 |
let prevStack = []; |
| 81 |
let toAppend; |
| 82 |
let toAppendBack; |
| 83 |
let rawMenu; |
| 84 |
let mv_rcsstype; |
| 85 |
let mv_rstr; |
| 86 |
let mv_naviIcon; |
| 87 |
let mv_naviExpandIcon; |
| 88 |
let mv_animationDuration; |
| 89 |
let mv_HeadText; |
| 90 |
let mv_dropIconArray = []; |
| 91 |
if (isFront) { |
| 92 |
$(".wp-block-ultimate-post-menu").each(function () { |
| 93 |
const that = $(this); |
| 94 |
if (that.data("hasrootmenu") != "hasRootMenu") { |
| 95 |
that |
| 96 |
.find( |
| 97 |
`.ultp-menu-item-wrapper[data-parentbid=".ultp-block-${that?.data( |
| 98 |
"bid" |
| 99 |
)}"] > .ultp-menu-item-label-container a` |
| 100 |
) |
| 101 |
.each(function () { |
| 102 |
const theA = $(this); |
| 103 |
const currentUrl = window.location.href; |
| 104 |
let isActive = false; |
| 105 |
const targetUrl = theA[0].href; |
| 106 |
if (currentUrl.endsWith("/") && !targetUrl.endsWith("/")) { |
| 107 |
const normalizedTargetUrl = targetUrl + "/"; |
| 108 |
if ( |
| 109 |
currentUrl.replace("https:", "http:") == |
| 110 |
normalizedTargetUrl.replace("https:", "http:") |
| 111 |
) { |
| 112 |
isActive = true; |
| 113 |
} |
| 114 |
} |
| 115 |
if ( |
| 116 |
currentUrl.replace("https:", "http:") == |
| 117 |
targetUrl.replace("https:", "http:") || |
| 118 |
isActive |
| 119 |
) { |
| 120 |
theA |
| 121 |
.closest( |
| 122 |
`.ultp-menu-item-wrapper[data-parentbid=".ultp-block-${that?.data( |
| 123 |
"bid" |
| 124 |
)}"]` |
| 125 |
) |
| 126 |
.addClass("ultp-current-link"); |
| 127 |
} |
| 128 |
}); |
| 129 |
} |
| 130 |
}); |
| 131 |
$(document).on( |
| 132 |
"click", |
| 133 |
'.wp-block-ultimate-post-menu[data-mv="enable"] > .ultp-mv-ham-icon.ultp-active', |
| 134 |
function (e) { |
| 135 |
enableDisableMolibeView(e, "ham"); |
| 136 |
} |
| 137 |
); |
| 138 |
$(document).on( |
| 139 |
"click", |
| 140 |
".ultp-mobile-view-container .ultp-mv-back, .ultp-mobile-view-container .ultp-mv-back-label-con", |
| 141 |
function (e) { |
| 142 |
if (mv_rstr == "mv_dissolve" || mv_rstr == "mv_slide") { |
| 143 |
handleResponsiveMenuHtml(e, "back"); |
| 144 |
} else { |
| 145 |
handleMenuDropDownStyle(e, "back"); |
| 146 |
} |
| 147 |
} |
| 148 |
); |
| 149 |
$(document).on( |
| 150 |
"click", |
| 151 |
".ultp-mobile-view-container .ultp-mv-close", |
| 152 |
function (e) { |
| 153 |
enableDisableMolibeView(e, "close"); |
| 154 |
} |
| 155 |
); |
| 156 |
$(document).on("click", ".ultp-mobile-view-container", function (e) { |
| 157 |
if ($(e.target).hasClass("ultp-mobile-view-container")) { |
| 158 |
enableDisableMolibeView(e, "close"); |
| 159 |
} |
| 160 |
}); |
| 161 |
$(document).on( |
| 162 |
"click", |
| 163 |
".ultp-mobile-view-container .ultp-menu-item-label-container", |
| 164 |
function (e) { |
| 165 |
if ( |
| 166 |
$(e.target).is(".ultp-menu-item-label") || |
| 167 |
$(e.target).parent().is(".ultp-menu-item-label") || |
| 168 |
($(e.target).is(".ultp-menu-item-label-container") && |
| 169 |
$(e.target).siblings(".ultp-menu-item-content").find("> *") |
| 170 |
.length == 0) |
| 171 |
) { |
| 172 |
return; |
| 173 |
} |
| 174 |
e.preventDefault(); |
| 175 |
if (mv_rstr == "mv_dissolve" || mv_rstr == "mv_slide") { |
| 176 |
handleResponsiveMenuHtml(e, "next"); |
| 177 |
} else { |
| 178 |
handleMenuDropDownStyle(e, "next"); |
| 179 |
} |
| 180 |
} |
| 181 |
); |
| 182 |
} |
| 183 |
|
| 184 |
function enableDisableMolibeView(e, type = "") { |
| 185 |
// ham close |
| 186 |
if (type == "close") { |
| 187 |
$(rawMenu) |
| 188 |
.find("> .ultp-mobile-view-container > .ultp-mobile-view-wrapper") |
| 189 |
.css({ |
| 190 |
transform: "translateX(-100%)", |
| 191 |
visibility: "hidden", |
| 192 |
opacity: "0", |
| 193 |
}); |
| 194 |
setTimeout(() => { |
| 195 |
if ($(rawMenu).hasClass("ultpMenu__Css")) { |
| 196 |
$(rawMenu).addClass("ultpMenuCss"); |
| 197 |
$(rawMenu).removeClass("ultpMenu__Css"); |
| 198 |
} |
| 199 |
$(rawMenu).removeClass("ultp-mobile-menu"); |
| 200 |
$(rawMenu) |
| 201 |
.find("> .ultp-mobile-view-container") |
| 202 |
.removeClass("ultp-mv-active"); |
| 203 |
$(rawMenu) |
| 204 |
.find("> .ultp-mobile-view-container > .ultp-mobile-view-wrapper") |
| 205 |
.css({ |
| 206 |
transform: "", |
| 207 |
visibility: "", |
| 208 |
opacity: "", |
| 209 |
"transition-property": "", |
| 210 |
"transition-timing-function": "", |
| 211 |
"transition-duration": "", |
| 212 |
}); |
| 213 |
toAppend?.html(""); |
| 214 |
currentStack = ""; |
| 215 |
prevStack = []; |
| 216 |
toAppend = ""; |
| 217 |
toAppendBack = ""; |
| 218 |
rawMenu = ""; |
| 219 |
mv_rcsstype = ""; |
| 220 |
mv_rstr = ""; |
| 221 |
mv_animationDuration = 0; |
| 222 |
mv_HeadText = ""; |
| 223 |
mv_dropIconArray = []; |
| 224 |
}, mv_animationDuration); |
| 225 |
} else { |
| 226 |
// ham |
| 227 |
const that = $(e.target); |
| 228 |
mv_animationDuration = $(that).hasClass("ultp-mv-ham-icon") |
| 229 |
? $(that).data("animationduration") |
| 230 |
: that.closest(".ultp-mv-ham-icon").data("animationduration"); |
| 231 |
mv_animationDuration = mv_animationDuration || 100; |
| 232 |
mv_HeadText = $(that).hasClass("ultp-mv-ham-icon") |
| 233 |
? $(that).data("headtext") |
| 234 |
: that.closest(".ultp-mv-ham-icon").data("headtext"); |
| 235 |
mv_naviIcon = that |
| 236 |
.closest(".wp-block-ultimate-post-menu") |
| 237 |
.find( |
| 238 |
"> .ultp-mobile-view-container > .ultp-mv-icons > .ultp-mv-label-icon svg" |
| 239 |
) |
| 240 |
.prop("outerHTML"); |
| 241 |
mv_naviExpandIcon = that |
| 242 |
.closest(".wp-block-ultimate-post-menu") |
| 243 |
.find( |
| 244 |
"> .ultp-mobile-view-container > .ultp-mv-icons > .ultp-mv-label-icon-expand svg" |
| 245 |
) |
| 246 |
.prop("outerHTML"); |
| 247 |
|
| 248 |
rawMenu = that.closest(".wp-block-ultimate-post-menu"); |
| 249 |
const menuObj = $(rawMenu); |
| 250 |
if ($(rawMenu).hasClass("ultpMenuCss")) { |
| 251 |
$(rawMenu).removeClass("ultpMenuCss"); |
| 252 |
$(rawMenu).addClass("ultpMenu__Css"); |
| 253 |
} |
| 254 |
currentStack = "ultp-block-" + menuObj.data("bid"); |
| 255 |
menuObj.addClass("ultp-mobile-menu"); |
| 256 |
menuObj.find("> .ultp-mobile-view-container").addClass("ultp-mv-active"); |
| 257 |
handleResponsiveMenuHtml("", "hamIcon"); |
| 258 |
|
| 259 |
menuObj |
| 260 |
.find("> .ultp-mobile-view-container > .ultp-mobile-view-wrapper") |
| 261 |
.css({ |
| 262 |
"transition-property": "opacity, visibility, transform", |
| 263 |
"transition-timing-function": "ease-in", |
| 264 |
"transition-duration": mv_animationDuration |
| 265 |
? mv_animationDuration / 1000 + "s" |
| 266 |
: ".25s", |
| 267 |
}); |
| 268 |
} |
| 269 |
} |
| 270 |
function handleDropIcon(data) { |
| 271 |
const _replace = data?._replace || mv_naviIcon; |
| 272 |
let _string = data?._string; |
| 273 |
if (_string && mv_dropIconArray.length) { |
| 274 |
mv_dropIconArray.forEach((el) => { |
| 275 |
if (el && _replace) { |
| 276 |
_string = _string.replace(el, _replace); |
| 277 |
} |
| 278 |
}); |
| 279 |
} |
| 280 |
return _string; |
| 281 |
} |
| 282 |
function handleResponsiveMenuHtml(e, src) { |
| 283 |
// hamIcon next back |
| 284 |
if (src == "hamIcon") { |
| 285 |
mv_rcsstype = rawMenu.data("rcsstype"); |
| 286 |
mv_rstr = rawMenu.data("rstr"); |
| 287 |
toAppend = $(rawMenu).find( |
| 288 |
"> .ultp-mobile-view-container .ultp-mobile-view-body" |
| 289 |
); |
| 290 |
toAppendBack = $(rawMenu).find( |
| 291 |
"> .ultp-mobile-view-container .ultp-mv-back-label" |
| 292 |
); |
| 293 |
let theHtml = $(rawMenu) |
| 294 |
.find("> .ultp-menu-wrapper > .ultp-menu-content") |
| 295 |
.html(); |
| 296 |
|
| 297 |
$(rawMenu) |
| 298 |
.find(".ultp-menu-item-dropdown") |
| 299 |
.toArray() |
| 300 |
.forEach((element) => { |
| 301 |
if ($(element).html()) { |
| 302 |
mv_dropIconArray.push($(element).html()); |
| 303 |
} |
| 304 |
}); |
| 305 |
if (theHtml) { |
| 306 |
let tempHtml = $("<div>").html(theHtml); |
| 307 |
tempHtml |
| 308 |
.find(".wp-block-ultimate-post-menu") |
| 309 |
.addClass("ultp-mobile-menu"); |
| 310 |
theHtml = tempHtml.html(); |
| 311 |
|
| 312 |
theHtml = handleDropIcon({ type: "hamicon", _string: theHtml }); |
| 313 |
toAppend.html( |
| 314 |
mv_rcsstype == "custom" |
| 315 |
? theHtml.replaceAll("ultpMenuCss", "ultpMenu__Css") |
| 316 |
: theHtml |
| 317 |
); |
| 318 |
toAppendBack.html(mv_HeadText); |
| 319 |
} |
| 320 |
} else if (src == "next") { |
| 321 |
const that = $(e.target); |
| 322 |
const parentItem = that.closest(".wp-block-ultimate-post-menu-item"); |
| 323 |
const bid = parentItem.data("bid"); |
| 324 |
if (!prevStack.includes("ultp-block-" + bid)) { |
| 325 |
let theHtml = ""; |
| 326 |
let d_none = ""; |
| 327 |
if (parentItem.hasClass("hasListMenuChild")) { |
| 328 |
d_none = parentItem |
| 329 |
.find( |
| 330 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content > .wp-block-ultimate-post-list-menu" |
| 331 |
) |
| 332 |
.css("display"); |
| 333 |
theHtml = parentItem |
| 334 |
.find( |
| 335 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content > .wp-block-ultimate-post-list-menu > .ultp-list-menu-wrapper > .ultp-list-menu-content" |
| 336 |
) |
| 337 |
.html(); |
| 338 |
} else { |
| 339 |
d_none = parentItem |
| 340 |
.find( |
| 341 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content > .wp-block-ultimate-post-mega-menu" |
| 342 |
) |
| 343 |
.css("display"); |
| 344 |
theHtml = parentItem |
| 345 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 346 |
.html(); |
| 347 |
} |
| 348 |
if (d_none == "none") { |
| 349 |
return; |
| 350 |
} |
| 351 |
if (theHtml) { |
| 352 |
$(rawMenu) |
| 353 |
.find(".ultp-mv-back-label-con") |
| 354 |
.removeClass("ultpmenu-dnone"); |
| 355 |
let tempHtml = $("<div>").html(theHtml); |
| 356 |
tempHtml |
| 357 |
.find(".wp-block-ultimate-post-menu") |
| 358 |
.addClass("ultp-mobile-menu"); |
| 359 |
theHtml = tempHtml.html(); |
| 360 |
|
| 361 |
prevStack.push(currentStack); |
| 362 |
currentStack = "ultp-block-" + bid; |
| 363 |
toAppendBack.html( |
| 364 |
parentItem |
| 365 |
.find( |
| 366 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-label-container .ultp-menu-item-label-text" |
| 367 |
) |
| 368 |
.html() |
| 369 |
); |
| 370 |
|
| 371 |
if (mv_rstr == "mv_dissolve") { |
| 372 |
toAppend.find("> *").animate( |
| 373 |
{ |
| 374 |
opacity: 0.2, |
| 375 |
}, |
| 376 |
mv_animationDuration, |
| 377 |
function () { |
| 378 |
toAppend.html( |
| 379 |
mv_rcsstype == "custom" |
| 380 |
? theHtml.replaceAll("ultpMenuCss", "ultpMenu__Css") |
| 381 |
: theHtml |
| 382 |
); |
| 383 |
|
| 384 |
toAppend.find("> *").css("opacity", ".1"); |
| 385 |
toAppend.find("> *").animate( |
| 386 |
{ |
| 387 |
opacity: 1, |
| 388 |
}, |
| 389 |
mv_animationDuration |
| 390 |
); |
| 391 |
} |
| 392 |
); |
| 393 |
} else { |
| 394 |
// Slide View |
| 395 |
toAppend.html( |
| 396 |
mv_rcsstype == "custom" |
| 397 |
? theHtml.replaceAll("ultpMenuCss", "ultpMenu__Css") |
| 398 |
: theHtml |
| 399 |
); |
| 400 |
toAppend.find("> *").css({ |
| 401 |
opacity: ".1", |
| 402 |
transform: "translateX(100%)", |
| 403 |
transition: `transform ${mv_animationDuration / 1000 + "s"} ease`, |
| 404 |
}); |
| 405 |
toAppend.find("> *").animate( |
| 406 |
{ |
| 407 |
opacity: 0.3, |
| 408 |
}, |
| 409 |
10, |
| 410 |
function () { |
| 411 |
toAppend |
| 412 |
.find("> *") |
| 413 |
.css({ opacity: "1", transform: "translateX(0px)" }); |
| 414 |
} |
| 415 |
); |
| 416 |
} |
| 417 |
} |
| 418 |
} |
| 419 |
} else if (src == "back") { |
| 420 |
if (prevStack.length == 0) { |
| 421 |
return; |
| 422 |
} |
| 423 |
currentStack = prevStack.pop() || ""; |
| 424 |
let backHtml = ""; |
| 425 |
if (prevStack.length == 0) { |
| 426 |
backHtml = $(rawMenu) |
| 427 |
.find("> .ultp-menu-wrapper > .ultp-menu-content") |
| 428 |
.html(); |
| 429 |
toAppendBack.html(mv_HeadText); |
| 430 |
$(rawMenu).find(".ultp-mv-back-label-con").addClass("ultpmenu-dnone"); |
| 431 |
} else { |
| 432 |
if ( |
| 433 |
$("." + currentStack).hasClass("wp-block-ultimate-post-menu-item") |
| 434 |
) { |
| 435 |
if ($("." + currentStack).hasClass("hasListMenuChild")) { |
| 436 |
backHtml = $(rawMenu) |
| 437 |
.find("." + currentStack) |
| 438 |
.find( |
| 439 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content > .wp-block-ultimate-post-list-menu > .ultp-list-menu-wrapper > .ultp-list-menu-content" |
| 440 |
) |
| 441 |
.html(); |
| 442 |
} else { |
| 443 |
backHtml = $(rawMenu) |
| 444 |
.find("." + currentStack) |
| 445 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 446 |
.html(); |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
if (backHtml) { |
| 451 |
let tempHtml = $("<div>").html(backHtml); |
| 452 |
tempHtml |
| 453 |
.find(".wp-block-ultimate-post-menu") |
| 454 |
.addClass("ultp-mobile-menu"); |
| 455 |
backHtml = tempHtml.html(); |
| 456 |
backHtml = handleDropIcon({ type: "back", _string: backHtml }); |
| 457 |
toAppendBack.html( |
| 458 |
$(rawMenu) |
| 459 |
.find("." + currentStack) |
| 460 |
.find( |
| 461 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-label-container .ultp-menu-item-label-text" |
| 462 |
) |
| 463 |
.html() |
| 464 |
); |
| 465 |
|
| 466 |
if (mv_rstr == "mv_dissolve") { |
| 467 |
toAppend.find("> *").animate( |
| 468 |
{ |
| 469 |
opacity: 0.2, |
| 470 |
}, |
| 471 |
mv_animationDuration, |
| 472 |
function () { |
| 473 |
toAppend.html( |
| 474 |
mv_rcsstype == "custom" |
| 475 |
? backHtml.replaceAll("ultpMenuCss", "ultpMenu__Css") |
| 476 |
: backHtml |
| 477 |
); |
| 478 |
} |
| 479 |
); |
| 480 |
toAppend.find("> *").animate( |
| 481 |
{ |
| 482 |
opacity: 1, |
| 483 |
}, |
| 484 |
mv_animationDuration |
| 485 |
); |
| 486 |
} else { |
| 487 |
// Slide View |
| 488 |
toAppend.html( |
| 489 |
mv_rcsstype == "custom" |
| 490 |
? backHtml.replaceAll("ultpMenuCss", "ultpMenu__Css") |
| 491 |
: backHtml |
| 492 |
); |
| 493 |
toAppend.find("> *").css({ |
| 494 |
opacity: ".1", |
| 495 |
transform: "translateX(-100%)", |
| 496 |
transition: `transform ${mv_animationDuration / 1000 + "s"} ease`, |
| 497 |
}); |
| 498 |
toAppend.find("> *").animate( |
| 499 |
{ |
| 500 |
opacity: 0.3, |
| 501 |
}, |
| 502 |
10, |
| 503 |
function () { |
| 504 |
toAppend |
| 505 |
.find("> *") |
| 506 |
.css({ opacity: "1", transform: "translateX(0px)" }); |
| 507 |
} |
| 508 |
); |
| 509 |
} |
| 510 |
} |
| 511 |
} |
| 512 |
// console.log(prevStack, currentStack); |
| 513 |
} |
| 514 |
|
| 515 |
function handleMenuDropDownStyle(e, type) { |
| 516 |
const that = $(e.target); |
| 517 |
const parentItem = that.closest(".wp-block-ultimate-post-menu-item"); |
| 518 |
let c_type = "next"; |
| 519 |
if (parentItem.hasClass("ultp-menu-res-css")) { |
| 520 |
c_type = "back"; |
| 521 |
} else { |
| 522 |
parentItem.addClass("ultp-menu-res-css"); |
| 523 |
} |
| 524 |
let target; |
| 525 |
let theHeight; |
| 526 |
if (c_type == "next") { |
| 527 |
parentItem.addClass("ultp-hammenu-accordian-active"); |
| 528 |
if (mv_naviExpandIcon) { |
| 529 |
parentItem |
| 530 |
.find( |
| 531 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-label-container .ultp-menu-item-dropdown" |
| 532 |
) |
| 533 |
.html(mv_naviExpandIcon); |
| 534 |
} |
| 535 |
|
| 536 |
if (parentItem.hasClass("hasListMenuChild")) { |
| 537 |
target = parentItem.find( |
| 538 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content > .wp-block-ultimate-post-list-menu > .ultp-list-menu-wrapper > .ultp-list-menu-content" |
| 539 |
); |
| 540 |
} else { |
| 541 |
target = parentItem.find( |
| 542 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content" |
| 543 |
); |
| 544 |
} |
| 545 |
if (!target.length) { |
| 546 |
target = parentItem.find( |
| 547 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content" |
| 548 |
); |
| 549 |
} |
| 550 |
theHeight = target.outerHeight(); |
| 551 |
const paddingObj = parentItem.find( |
| 552 |
"> .ultp-menu-item-wrapper > .ultp-menu-item-content" |
| 553 |
); |
| 554 |
const paddingTop = paddingObj.css("padding-top"); |
| 555 |
const paddingBottom = paddingObj.css("padding-bottom"); |
| 556 |
|
| 557 |
parentItem |
| 558 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 559 |
.html(target.html()); |
| 560 |
parentItem |
| 561 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 562 |
.css({ height: "0px", "padding-top": "0", "padding-bottom": "0" }); |
| 563 |
parentItem |
| 564 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 565 |
.animate( |
| 566 |
{ |
| 567 |
height: theHeight + "px", |
| 568 |
"padding-top": paddingTop, |
| 569 |
"padding-bottom": paddingBottom, |
| 570 |
}, |
| 571 |
mv_animationDuration, |
| 572 |
function () { |
| 573 |
$(this).css({ |
| 574 |
height: "", |
| 575 |
"padding-top": "", |
| 576 |
"padding-bottom": "", |
| 577 |
}); |
| 578 |
} |
| 579 |
); |
| 580 |
} else if (c_type == "back") { |
| 581 |
parentItem.removeClass("ultp-hammenu-accordian-active"); |
| 582 |
parentItem |
| 583 |
.find(".wp-block-ultimate-post-menu-item") |
| 584 |
.removeClass("ultp-hammenu-accordian-active"); |
| 585 |
parentItem |
| 586 |
.find("> .ultp-menu-item-wrapper > .ultp-menu-item-content") |
| 587 |
.animate( |
| 588 |
{ |
| 589 |
height: "0", |
| 590 |
paddingTop: "0", |
| 591 |
paddingBottom: "0", |
| 592 |
}, |
| 593 |
mv_animationDuration, |
| 594 |
function () { |
| 595 |
$(this).css({ |
| 596 |
height: "", |
| 597 |
paddingTop: "", |
| 598 |
paddingBottom: "", |
| 599 |
}); |
| 600 |
if (mv_naviIcon) { |
| 601 |
parentItem |
| 602 |
.find( |
| 603 |
".ultp-menu-item-wrapper .ultp-menu-item-label-container .ultp-menu-item-dropdown" |
| 604 |
) |
| 605 |
.each(function () { |
| 606 |
if ($(this).html()) { |
| 607 |
$(this).html(mv_naviIcon); |
| 608 |
} |
| 609 |
}); |
| 610 |
} |
| 611 |
parentItem.removeClass("ultp-menu-res-css"); |
| 612 |
parentItem |
| 613 |
.find(".wp-block-ultimate-post-menu-item") |
| 614 |
.removeClass("ultp-menu-res-css"); |
| 615 |
} |
| 616 |
); |
| 617 |
} |
| 618 |
} |
| 619 |
})(jQuery); |
| 620 |
|