/** * Side Navigation extension for Zendesk themes v2.8.0 * https://www.lotusthemes.com * * Released on 2020-07-14 * Copyright (c) 2014-2020 Lotus Themes */ !function a(o,c,l){function r(i,t){if(!c[i]){if(!o[i]){var e="function"==typeof require&&require;if(!t&&e)return e(i,!0);if(d)return d(i,!0);var n=new Error("Cannot find module '"+i+"'");throw n.code="MODULE_NOT_FOUND",n}var s=c[i]={exports:{}};o[i][0].call(s.exports,function(t){return r(o[i][1][t]||t)},s,s.exports,a,o,c,l)}return c[i].exports}for(var d="function"==typeof require&&require,t=0;t')),this.$box=$('
')),this.initialStates(),"slide"===this.options.animation?(this.$box.addClass(a.CSS_PREFIX+"_slide"),this.initVisibleSlideBlocks()):this.$box.addClass(a.CSS_PREFIX+"_accordion"),this.$element.html(this.$wrapper.html(this.$box[0])[0]),this.options.showMobile&&(this.$button=$('")),this.$overlay=$('')),this.$element.append(this.$overlay[0]),this.$element.append(this.$button[0])),this.renderMenuItems(),this.initVisibleAccordionBlocks()}},{key:"renderMenuItems",value:function(){var t=this.ifRenderCategories?this.getCategoriesTemplate(ApiData.toCategoriesTree(ApiData.sortBy(this.data,"position"))):this.ifRenderSections?this.getSectionsTemplate(ApiData.toSectionsTree(ApiData.sortBy(this.data,"position"))):this.getArticlesTemplate(this.data.articles);this.$box.append(t),this.handleToggleMobileView(),this.options.disableClickHandlers||("slide"===this.options.animation?(this.autoHeightAnimation(),this.changeBoxHeight(),this.$box.find(".".concat(a.CSS_PREFIX,"__category-name")).on("click",this.handleCategoryClick.bind(this)),this.$box.find(".".concat(a.CSS_PREFIX,"__section-name")).on("click",this.handleSectionClick.bind(this)),this.$box.find("[data-".concat(a.CSS_PREFIX,"-back-to-categories]")).on("click",this.handleBackToCategoriesClick.bind(this)),this.$box.find("[data-".concat(a.CSS_PREFIX,"-back-to-sections]")).on("click",this.handleBackToSectionsClick.bind(this)),this.$box.find("[data-".concat(a.CSS_PREFIX,"-back-to-prev-sections]")).on("click",this.handleBackToPrevSections.bind(this))):(this.$box.find(".".concat(a.CSS_PREFIX,"__category-name")).on("click",this.handleCategorySlideToggleClick.bind(this)),this.$box.find(".".concat(a.CSS_PREFIX,"__section-name")).on("click",this.handleSectionSlideToggleClick.bind(this)))),this.options.showMobile&&(this.$button.on("click",this.handleToggleMobileMenu.bind(this)),this.$overlay.on("click",this.handleHideMobileMenu.bind(this))),$(window).on("resize",this.handleToggleMobileView.bind(this))}},{key:"initialStates",value:function(){if(-1!==window.location.pathname.indexOf("/categories/"))this.state={currentPage:"category",activeCategoryId:parseInt(window.location.pathname.replace(a.REG_CATEGORY_ID,"$1"))};else if(-1!==window.location.pathname.indexOf("/sections/"))this.state={currentPage:"section",activeSectionId:[parseInt(window.location.pathname.replace(a.REG_SECTION_ID,"$1"))]},this.ifRenderCategories&&(this.state.activeCategoryId=ApiData.filterBySectionId(this.data,this.state.activeSectionId[0]).categories[0].id);else if(-1!==window.location.pathname.indexOf("/articles/")){this.state={currentPage:"article",activeArticleId:parseInt(window.location.pathname.replace(a.REG_ARTICLE_ID,"$1"))};var t=ApiData.filterByArticleId(this.data,this.state.activeArticleId);this.ifRenderCategories&&(this.state.activeCategoryId=t.categories[0].id),this.ifRenderSections&&(this.state.activeSectionId=[t.sections[0].id])}this.pushActiveSections()}},{key:"pushActiveSections",value:function(t){if(this.state.activeSectionId&&this.state.activeSectionId.length){var i=t||ApiData.filterBySectionId(this.data,this.state.activeSectionId[0]).sections[0];if(i&&i.parent_section_id){var e=ApiData.filterBySectionId(this.data,i.parent_section_id).sections[0];e&&(this.state.activeSectionId.push(e.id),this.pushActiveSections(e))}}}},{key:"initVisibleSlideBlocks",value:function(){"category"===this.state.currentPage?this.isExist("category")&&this.$box.addClass(a.CSS_PREFIX+"_sections-is-active"):"section"===this.state.currentPage?this.isExist("section")&&this.isExist("category")?this.$box.addClass(a.CSS_PREFIX+"_articles-is-active"):this.isExist("category")&&this.$box.addClass(a.CSS_PREFIX+"_sections-is-active"):"article"===this.state.currentPage&&(this.isExist("article")&&this.isExist("section")&&this.isExist("category")||this.isExist("section")&&this.isExist("category")?this.$box.addClass(a.CSS_PREFIX+"_articles-is-active"):this.isExist("category")&&this.$box.addClass(a.CSS_PREFIX+"_sections-is-active"))}},{key:"initVisibleAccordionBlocks",value:function(){"accordion"===this.options.animation&&this.$box.find(".sidenav__category.is-active > .sidenav__sections-list, .sidenav__section.is-active > .sidenav__articles-list").css("display","block")}},{key:"isExist",value:function(t){var i="category"===t?this.state.activeCategoryId:"section"===t?this.state.activeSectionId:this.state.activeArticleId;if("section"!==t)return"article"===t?(0,n.isExist)(this.options.includeArticles,this.options.excludeArticles,i):"category"===t&&(0,n.isExist)(this.options.includeCategories,this.options.excludeCategories,i);for(var e=0;e\n ').concat(this.options.homeTitle?'\n
  • \n ').concat(this.options.homeTitle,"\n
  • \n "):"","\n ").concat(t.map(this.getCategoryTemplate.bind(this)).join(""),"\n \n ")}},{key:"getCategoryTemplate",value:function(t){return this.options.includeCategories&&-1===this.options.includeCategories.indexOf(t.id)||this.options.excludeCategories&&-1!==this.options.excludeCategories.indexOf(t.id)?"":'\n
  • \n ').concat(this.ifRenderSections?'').concat(t.name,"\n ").concat(this.getSectionsTemplate(t.sections,t)):this.ifRenderArticles?'').concat(t.name,"\n ").concat(this.getArticlesTemplate(ApiData.filterByCategoryId(this.data,t.id).articles,null,t)):'').concat(t.name,""),"\n
  • ")}},{key:"getSectionsTemplate",value:function(t,i){return'\n \n ")}},{key:"getSectionTemplate",value:function(t){return this.options.includeSections&&-1===this.options.includeSections.indexOf(t.id)||this.options.excludeSections&&-1!==this.options.excludeSections.indexOf(t.id)?"":'\n
  • \n ').concat(t.name," ").concat(this.getArticlesTemplate(t.articles,t),"\n
  • \n ")}},{key:"getArticlesTemplate",value:function(t,i,e){var n="";return i&&this.state.activeSectionId&&(n=i.id===this.state.activeSectionId[0]?a.VISIBLE_CLASS+" "+a.ACTIVE_CLASS:""),this.ifRenderArticles&&t.length||i.sections.length?'\n \n "):""}},{key:"getArticleTemplate",value:function(t){return this.options.includeArticles&&-1===this.options.includeArticles.indexOf(t.id)||this.options.excludeArticles&&-1!==this.options.excludeArticles.indexOf(t.id)?"":'\n
  • \n ').concat(t.title,"\n
  • \n ")}},{key:"getHomeLinkTemplate",value:function(){return this.options.homeTitle?'\n
  • \n ').concat(this.options.homeTitle,"\n
  • \n "):""}},{key:"categoriesIsActive",value:function(){this.addActiveClass(),this.$box.removeClass("sidenav_articles-is-active sidenav_sections-is-active").addClass("sidenav_categories-is-active")}},{key:"sectionsIsActive",value:function(t){this.addActiveClass(t?"[data-".concat(a.CSS_PREFIX,'-parent-category="').concat(t,'"]'):null),this.$box.removeClass("sidenav_categories-is-active sidenav_articles-is-active").addClass("sidenav_sections-is-active")}},{key:"articlesIsActive",value:function(t){this.addActiveClass("[data-".concat(a.CSS_PREFIX,'-parent-section="').concat(t,'"]')),this.$box.removeClass("sidenav_categories-is-active sidenav_sections-is-active").addClass("sidenav_articles-is-active")}},{key:"addActiveClass",value:function(t){var i=this;t&&this.$box.find(t).addClass(a.ACTIVE_CLASS).addClass(a.VISIBLE_CLASS),"slide"===this.options.animation?(this.changeBoxHeight(t),this.removeActiveClass(t,!0),setTimeout(function(){return i.removeActiveClass(t)},this.options.animationDuration)):this.removeActiveClass(t)}},{key:"removeActiveClass",value:function(t,i){var e=i?a.VISIBLE_CLASS:a.ACTIVE_CLASS;t?this.$box.find("ul."+e).not(t).removeClass(e):this.$box.find("ul."+e).removeClass(e),this.$box.hasClass("".concat(a.CSS_PREFIX,"_init"))&&this.$box.removeClass("".concat(a.CSS_PREFIX,"_init"))}},{key:"autoHeightAnimation",value:function(){this.options.autoHeightAnimation&&this.$box.css("transition-duration",this.options.animationDuration+"ms")}},{key:"changeBoxHeight",value:function(t){var i=this,e=t?this.$box.find(t).outerHeight():this.$box.find("."+a.ACTIVE_CLASS).length&&this.$box.hasClass(a.CSS_PREFIX+"_init")?this.$box.find("."+a.ACTIVE_CLASS).last().children("ul").outerHeight()||this.$box.find("."+a.ACTIVE_CLASS).last().closest("ul").outerHeight():this.$box.children("ul").outerHeight();this.options.autoHeightAnimation||!this.height?this.$box.height(e):(this.autoHeightDelay&&clearTimeout(this.autoHeightDelay),this.$box.height(e>this.height?e:this.height),this.autoHeightDelay=setTimeout(function(){i.$box.height(e)},this.options.animationDuration)),this.height=e}},{key:"handleCategoryClick",value:function(t){t.preventDefault();var i=$(t.currentTarget).closest("[data-".concat(a.CSS_PREFIX,"-category-id]")).attr("data-".concat(a.CSS_PREFIX,"-category-id"));this.sectionsIsActive(i)}},{key:"handleSectionClick",value:function(t){t.preventDefault();var i=$(t.currentTarget).closest("[data-".concat(a.CSS_PREFIX,"-section-id]")).attr("data-".concat(a.CSS_PREFIX,"-section-id"));this.articlesIsActive(i)}},{key:"handleBackToCategoriesClick",value:function(t){t.preventDefault(),this.categoriesIsActive()}},{key:"handleBackToSectionsClick",value:function(t){t.preventDefault(),this.ifRenderCategories?this.handleCategoryClick(t):this.sectionsIsActive()}},{key:"handleBackToPrevSections",value:function(t){t.preventDefault();var i=$(t.currentTarget).parents("[data-".concat(a.CSS_PREFIX,"-section-id]")).eq(1).attr("data-".concat(a.CSS_PREFIX,"-section-id"));this.articlesIsActive(i)}},{key:"slideToggle",value:function(t){t.siblings("ul").slideToggle(this.options.animationDuration)}},{key:"handleCategorySlideToggleClick",value:function(t){t.preventDefault();var i=$(t.currentTarget);this.slideToggle(i),i.closest(".".concat(a.CSS_PREFIX,"__category")).toggleClass(a.ACTIVE_CLASS)}},{key:"handleSectionSlideToggleClick",value:function(t){var i=$(t.currentTarget),e=i.siblings("ul");e&&e.length&&(t.preventDefault(),this.slideToggle(i),i.closest(".".concat(a.CSS_PREFIX,"__section")).toggleClass(a.ACTIVE_CLASS))}},{key:"handleToggleMobileView",value:function(){window.innerWidth<=this.options.mobileBreakpoint&&"desktop"===this.view&&(this.view="mobile",this.options.showMobile?(this.$button.show(0),this.$overlay.show(0),this.$wrapper.addClass("".concat(a.CSS_PREFIX,"-mobile"))):this.$wrapper.hide(0)),window.innerWidth>this.options.mobileBreakpoint&&"mobile"===this.view&&(this.view="desktop",this.options.showMobile?(this.$button.hide(0),this.$overlay.hide(0),this.$wrapper.removeClass("".concat(a.CSS_PREFIX,"-mobile"))):this.$wrapper.show(0)),"slide"===this.options.animation&&this.changeBoxHeight()}},{key:"handleToggleMobileMenu",value:function(t){t.preventDefault(),this.$overlay.toggleClass("is-active"),this.$wrapper.toggleClass("is-active")}},{key:"handleHideMobileMenu",value:function(t){t.preventDefault(),this.$overlay.removeClass("is-active"),this.$wrapper.removeClass("is-active")}},{key:"openCategory",value:function(t,i){var e=this;if("slide"===this.options.animation)this.sectionsIsActive("number"==typeof t?t:t[0]);else{var n=i?0:this.options.animationDuration;"number"==typeof t?(this.$element.find("[data-".concat(a.CSS_PREFIX,'-parent-category="').concat(t,'"]')).slideDown(n),this.$element.find("[data-".concat(a.CSS_PREFIX,'-category-id="').concat(t,'"]')).addClass(a.ACTIVE_CLASS)):t.forEach(function(t){e.$element.find("[data-".concat(a.CSS_PREFIX,'-parent-category="').concat(t,'"]')).slideDown(n),e.$element.find("[data-".concat(a.CSS_PREFIX,'-category-id="').concat(t,'"]')).addClass(a.ACTIVE_CLASS)})}}},{key:"openSection",value:function(t,i){var e=this;if("slide"===this.options.animation)this.articlesIsActive("number"==typeof t?t:t[0]);else{var n=i?0:this.options.animationDuration;"number"==typeof t?(this.$element.find("[data-".concat(a.CSS_PREFIX,'-parent-section="').concat(t,'"]')).slideDown(n),this.$element.find("[data-".concat(a.CSS_PREFIX,'-section-id="').concat(t,'"]')).addClass(a.ACTIVE_CLASS)):t.forEach(function(t){e.$element.find("[data-".concat(a.CSS_PREFIX,'-parent-section="').concat(t,'"]')).slideDown(n),e.$element.find("[data-".concat(a.CSS_PREFIX,'-section-id="').concat(t,'"]')).addClass(a.ACTIVE_CLASS)})}}},{key:"openAllCategories",value:function(t){var i="slide"===this.options.animation?this.data.categories[0].id:this.data.categories.map(function(t){return t.id});this.openCategory(i,t)}},{key:"openAllSections",value:function(t){var i="slide"===this.options.animation?this.data.sections[0].id:this.data.sections.map(function(t){return t.id});this.openSection(i,t)}}])&&o(t.prototype,i),e&&o(t,e),s}();e.default=s},{"./constants":3,"./utils":5}],3:[function(t,i,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.REG_ARTICLE_ID=e.REG_SECTION_ID=e.REG_CATEGORY_ID=e.VISIBLE_CLASS=e.ACTIVE_CLASS=e.CSS_PREFIX=void 0;e.CSS_PREFIX="sidenav";e.ACTIVE_CLASS="is-active";e.VISIBLE_CLASS="is-visible";e.REG_CATEGORY_ID=/\/hc(?:\/[A-Za-z_-]+)?\/categories\/([0-9]+)[\S]*$/i;e.REG_SECTION_ID=/\/hc(?:\/[A-Za-z_-]+)?\/sections\/([0-9]+)[\S]*$/i;e.REG_ARTICLE_ID=/\/hc(?:\/[A-Za-z_-]+)?\/articles\/([0-9]+)[\S]*$/i},{}],4:[function(t,i,e){"use strict";var n,o=(n=t("./SideNav"))&&n.__esModule?n:{default:n},s=t("../package");$(window).on("apiDataFetched",function(t,a){$(function(){$("[data-sidenav]").each(function(t,i){var e=$(i),n=e.data("sidenav")||{};t||$("html").addClass("sidenav-enabled");var s=new o.default(t,e,n,a);$(window).trigger("sidenavRendered",s),$(window).trigger("resize")})})}),window.SideNav={version:s.version}},{"../package":1,"./SideNav":2}],5:[function(t,i,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isExist=void 0;e.isExist=function(t,i,e){return t?-1!==t.indexOf(e):!i||-1===i.indexOf(e)}},{}]},{},[4]);