Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.75 KB | None | 0 0
  1. /* NOTES: Purpose of .off() jquery native function
  2. is to prevent multiple fired event during orientation change */
  3.  
  4. /* version="9sssssssssss" */
  5. if (ComponentRegistry.GlobalHeaderSettings) {
  6. /* Adjust Header in Preview */
  7. function adjustHeaderForPreview() {
  8. if ($('#scCrossPiece').length > 0 && $('#scFieldValues').length <= 0) {
  9. $('.navbar-fixed-top').css('top', $('#scCrossPiece').height());
  10. }
  11. else { setTimeout(adjustHeaderForPreview, 2500); }
  12. }
  13.  
  14.  
  15. $(window).load(function () {
  16. tertiaryNav.css('display', 'none');
  17. var frameParent = $('#scWebEditRibbon');
  18. if (frameParent.length > 0 && $('#scFieldValues').length <= 0) {
  19. adjustHeaderForPreview();
  20. //add event handler
  21. var siteCoreButton = $("a[data-sc-id='QuickRibbon']", frameParent.contents());
  22. siteCoreButton.on('click dblclick', function () {
  23. setTimeout(adjustHeaderForPreview, 50);
  24. });
  25. }
  26.  
  27. if (isMobile() && !isTablet()) {
  28. if (isLandscape()) {
  29. tertiaryNav.css('margin-top', '-100%');
  30. menuFooter.css('position', 'static');
  31.  
  32. }
  33. else {
  34. tertiaryNav.css('margin-top', '-200%');
  35.  
  36. }
  37.  
  38. }
  39. });
  40.  
  41. /* GLOBAL VARIABLES */
  42. var viewPortWidth, deviceHeight;
  43. var backDropTablet = $(".back-drop-tablet");
  44. var countrySelectorCont = $('.utility-nav .country-form');
  45. var mobileShowToggle = 'show-sub-menu';
  46. var nav = $(".nav-content .nav-submenu");
  47. var navContainer = $('.nav-content');
  48. var navIcon = $('#nav-icon');
  49. var navLabel = $(".nav-content .nav-submenu-label");
  50. var toggleCountryList = 'show-country-list';
  51. var varSearchBody = $('#search-body .search-body-wrapper');
  52. var divContainer = $(".secondary-navs");
  53. var acnLogoContainer = $('.acn-logo-container');
  54. var documentClick = $(document);
  55. var navMenu = $('#navigation-menu');
  56. var menuFooter = $('#menuFooter');
  57. var tertiaryContainer = $('.secondary-item');
  58. var tertiaryClose = $('.nav-submenu-label-L3');
  59. var tertiaryNav = $('#tertiaryNav');
  60. var primaryNav = $('.primary-nav');
  61. var secondContactLink = $('#second-contact-link');
  62. var tertiaryListContainer = $('#tertiaryListContainer')
  63. var subMenuLabel = $('.nav-submenu-label');
  64. $(document).ready(function () {
  65. viewPortWidth = $(document).width();
  66. deviceHeight = $(window).height();
  67. globalHeader.init();
  68.  
  69. });
  70.  
  71. window.addEventListener("orientationchange", function () {
  72. setTimeout(function () {
  73. viewPortWidth = $(document).width();
  74. deviceHeight = $(window).height();
  75. globalHeader.init();
  76. }, 100);
  77.  
  78. if (isLandscape()) {
  79. secondContactLink.css('position', 'static');
  80. }
  81. }, false);
  82.  
  83. /* GLOBAL HEADER CONTROL */
  84. var globalHeader = (function () {
  85. var init = function () {
  86. globalHeaderNavigation();
  87. if ($('.search-icon-container.search-trigger').length == 0) {
  88. globalHeaderSearch();
  89. }
  90. globalCountrySelector();
  91. setNavigationHeightOnChangeOrientation();
  92. }
  93.  
  94. /* NAVIGATION LINKS */
  95. var globalHeaderNavigation = function () {
  96. var prevSubmenu = null;
  97. var countrySelect = $('.country-select-cont');
  98.  
  99.  
  100. if (isTablet() && !isMobile()) {
  101.  
  102. tertiaryNav.css('margin-top', '-304%');
  103. divContainer.removeClass('hidden');
  104. navContainer.addClass('hidden');
  105.  
  106. if (navIcon.hasClass("open")) {
  107. navIcon.removeClass("open");
  108. showHideSecondaryNav.hideBackDrop();
  109.  
  110. navContainer.removeClass('crawl-right');
  111. }
  112. backDropTablet.click(function () {
  113. showHideSecondaryNav.hideBackDropOnClick();
  114. });
  115. } else {
  116. divContainer.addClass('hidden');
  117. navContainer.removeClass('hidden');
  118. }
  119.  
  120. if (isMobile()) {
  121. divContainer.removeClass('hidden');
  122. $(window).on('orientationchange', function (event) {
  123. if (isLandscape()) {
  124. tertiaryNav.css('margin-top', '-100%');
  125. menuFooter.css('position', 'static');
  126.  
  127. }
  128. else {
  129. tertiaryNav.css('margin-top', '-200%');
  130. menuFooter.css('position', 'fixed');
  131.  
  132. }
  133.  
  134. });
  135. }
  136.  
  137.  
  138. navIcon.off('click').click(function () {
  139. $('body').toggleClass('o-hidden');
  140. if (!isTablet()) {
  141. $(this).toggleClass('open');
  142. }
  143. if (isTablet() || isMobile()) {
  144.  
  145. if (isPrimaryOverflow()) {
  146. menuFooter.css('position', 'static');
  147. } else {
  148. menuFooter.css('position', 'fixed');
  149. }
  150. closeL3();
  151. }
  152. if (isTablet() && !isMobile()) {
  153.  
  154. if (hasClass(backDropTablet, 'hidden')) {
  155. showHideSecondaryNav.showBackDrop();
  156. navContainer.removeClass('hidden');
  157. setTimeout(function () {
  158. navIcon.addClass("open");
  159. navContainer.addClass('crawl-right');
  160. }, 100);
  161. } else {
  162.  
  163. showHideSecondaryNav.hideBackDrop();
  164. navContainer.removeClass('crawl-right');
  165. setTimeout(function () {
  166. navIcon.removeClass("open");
  167. navContainer.addClass('hidden');
  168. }, 210);
  169. }
  170. } else {
  171. navContainer.toggleClass('crawl-down');
  172. if (tertiaryNav.css('display') == 'block') {
  173. tertiaryNav.css('display', 'none');
  174. }
  175. }
  176.  
  177. nav.removeClass(mobileShowToggle);
  178.  
  179. if (isMobile()) {
  180. acnLogoContainer.toggleClass('hidden');
  181. countrySelect.toggleClass('absolute-fade');
  182.  
  183. }
  184.  
  185. divContainer.removeClass('in').addClass('collapse');
  186. setNavigationHeightOnChangeOrientation();
  187. countrySelectorControl.closeCountrySelector();
  188. prevSubmenu = null;
  189. });
  190.  
  191. navLabel.click(function (event) {
  192. event.preventDefault();
  193. var $this = $(this);
  194. var newNav = $this.closest('.nav-submenu');
  195. var subMenu = $(this).next();
  196. var newDivContainer = $this.siblings('.secondary-navs');
  197.  
  198. if (isMobile() || isTablet()) {
  199. if (newNav.hasClass(mobileShowToggle)) {
  200. setTimeout(function () {
  201. newNav.removeClass(mobileShowToggle);
  202. }, 10);
  203. } else {
  204. if (newNav.attr('id') != 'tertiary-block') {
  205. nav.delay(1400).removeClass(mobileShowToggle);
  206. }
  207. setTimeout(function () {
  208. newNav.delay(2800).addClass(mobileShowToggle);
  209. }, 10);
  210. }
  211.  
  212. if (isSecondaryOverflow(subMenu) || isPrimaryOverflow()) {
  213. menuFooter.css('position', 'static');
  214. } else {
  215. menuFooter.css('position', 'fixed');
  216. }
  217.  
  218.  
  219. } else {
  220. if (hasClass(newDivContainer, 'hidden')) {
  221. divContainer.addClass('hidden');
  222. setTimeout(function () {
  223. showHideSecondaryNav.showNav(newNav);
  224. }, 100);
  225. } else {
  226. showHideSecondaryNav.clickHideNav(newNav);
  227. }
  228.  
  229. if (!$this.hasClass('active')) {
  230. navLabel.removeClass('active').closest('.nav-submenu').removeClass('border-bottom');
  231. $this.addClass('active').closest('.nav-submenu').addClass('border-bottom');
  232. }
  233. else {
  234. $this.removeClass('active').closest('.nav-submenu').removeClass('border-bottom');
  235. }
  236. }
  237. });
  238.  
  239. if (isMobile() || isTablet()) {
  240.  
  241. if (!hasClass(divContainer, 'collapse')) {
  242. divContainer.addClass('collapse');
  243. navLabel.attr('data-toggle', 'collapse');
  244. }
  245. tertiaryClose.click(function() {
  246. closeL3()
  247. });
  248. //open tertiary menu
  249. tertiaryContainer.click(function L3() {
  250.  
  251. if ($(this).parent().attr('id') != 'no-l3') {
  252. navMenu.children().addClass('hidden');
  253. var tertiary = $(this).data("tertiary");
  254. $('#' + tertiary).removeClass('hidden');
  255. tertiaryNav.css({ 'opacity': '0', 'right': '-530px' });
  256. tertiaryNav.css("display", "block").animate({
  257. opacity: '1',
  258. right: '0px',
  259. }, 100);
  260.  
  261. $('.tertiary-title').html($(this).parents('.secondary-navs').attr('id'));
  262. subMenuLabel.addClass('tertiaryLevel3');
  263. tertiaryListContainer.html($(this).children('ul').clone());
  264. tertiaryListContainer.children('ul').removeClass('hidden-xs hidden-sm');
  265.  
  266. if (isTertiaryOverflow($(this))) {
  267. secondContactLink.css("position", "static");
  268. } else {
  269. $("#second-contact-link").css("position", "fixed");
  270. }
  271. }
  272.  
  273. });
  274.  
  275. } else {
  276. divContainer.removeClass('collapse');
  277. navLabel.removeAttr('data-toggle');
  278. }
  279.  
  280. if (!isMobile() && !isTablet()) {
  281. documentClick.off('click').click(function (event) {
  282. if (!$(event.target).closest(navMenu).length && !navLabel.is(event.target)) {
  283. showHideSecondaryNav.hideSubNav();
  284. }
  285.  
  286. });
  287. }
  288. }
  289.  
  290. /* SEARCH */
  291. var globalHeaderSearch = function () {
  292. var headerId = '#header-topnav';
  293. var searchBody = $('#search-body');
  294. var searchIcon = $(headerId + ' .search-icon-container');
  295. var searchInput = $(headerId + ' .search-textbox');
  296. var clearInput = $(headerId + ' .ion-ios-close');
  297. var countrySelector = $('.utility-nav .country-select-cont');
  298. var showSearchClass = 'show-search';
  299. var signInCont = $('.utility-nav .signin-container');
  300. var textboxSearchIcon = $(headerId + ' .ion-ios-search');
  301.  
  302. searchIcon.off('click').click(function () {
  303. $(this).toggleClass(showSearchClass);
  304. varSearchBody.css('height', deviceHeight + 'px');
  305. $('body').toggleClass('modal-open');
  306. acnLogoContainer.toggleClass('hidden');
  307. navIcon.toggleClass('hidden-xs hidden-sm');
  308. countrySelector.css('visibility','hidden');
  309. searchBody.toggleClass('slide-down');
  310. signInCont.css('visibility', 'hidden');
  311. navLabel.css('visibility', 'hidden');
  312.  
  313. searchInput.val('');
  314. clearInput.addClass('hidden');
  315.  
  316. if (!hasClass($(this), showSearchClass)) {
  317. varSearchBody.css('height', 0);
  318. countrySelector.removeAttr('style');
  319. signInCont.removeAttr('style');
  320. navLabel.removeAttr('style');
  321. }
  322. });
  323.  
  324. searchInput.keyup(function () {
  325. if (viewPortWidth <= 999) {
  326. if ($(this).val() != '') {
  327. clearInput.removeClass('hidden');
  328. } else {
  329. clearInput.addClass('hidden');
  330. }
  331. }
  332. });
  333.  
  334. clearInput.click(function (e) {
  335. e.preventDefault();
  336. searchInput.val('');
  337. clearInput.addClass('hidden');
  338. $('#search-recommendation').removeClass('in')
  339. .addClass('collapse');
  340. });
  341. }
  342.  
  343. /* COUNTRY SELECTOR */
  344. var globalCountrySelector = function () {
  345. var countries = GetCountrySelectorData();
  346. var countryIcon = $('.country-select-cont');
  347. CountrySelectorTemplate(countries);
  348. countryIcon.off('click').click(function () {
  349. countrySelectorCont.toggleClass(toggleCountryList);
  350. })
  351.  
  352. $(document).on("mouseup touchend", function (e) {
  353. if (!e) e = window.event;
  354. var targetElement = e.target || e.srcElement;
  355.  
  356. if ($('.show-country-list').length && $(targetElement).attr('class') !== 'country-select-cont' && $(targetElement).attr('class') !== 'show-country-list'
  357. && !$(targetElement).closest('.country-select-cont').length && !$(targetElement).closest('.show-country-list').length) {
  358. countrySelectorCont.toggleClass(toggleCountryList);
  359. }
  360. });
  361. }
  362.  
  363. var geoGroupStoredData = "";
  364. var ACN_COUNTRY_SELECTOR_CAREERS = "CountryLanguageSelectorData_Careers";
  365. var ACN_COUNTRY_SELECTOR_DOTCOM = "CountryLanguageSelectorData_Dotcom";
  366.  
  367. function GetCountrySelectorData() {
  368. var geoGroupStoredData = CheckCountrySelectorLocalStorage();
  369. var pageLocation = document.location.href.toLowerCase();
  370. var countries = [];
  371. if (geoGroupStoredData != 'null' && geoGroupStoredData != null && typeof geoGroupStoredData != 'undefined' && geoGroupStoredData.length > 0) { //check value condition for different type of browser.
  372. var geoObj = JSON.parse(geoGroupStoredData);
  373.  
  374. //If local Storage is more than 1 day, remove localStorage.
  375. if (geoObj.DateCreated < 86400000) {
  376. if (pageLocation.indexOf("/careers") >= 0) {
  377. localStorage.removeItem(ACN_COUNTRY_SELECTOR_CAREERS);
  378. }
  379. else {
  380. localStorage.removeItem(ACN_COUNTRY_SELECTOR_DOTCOM);
  381. }
  382. }
  383. for (var i = 0; i < geoObj.GeoGroup.length; i++) {
  384. for (var j = 0; j < geoObj.GeoGroup[i].CountryGroup.length; j++) {
  385. for (var k = 0; k < geoObj.GeoGroup[i].CountryGroup[j].CountryList.length; k++) {
  386. countries.push(geoObj.GeoGroup[i].CountryGroup[j].CountryList[k]);
  387. }
  388. }
  389. }
  390. countries.sort(function (a, b) { var a1 = a.CountryName, b1 = b.CountryName; if (a1 == b1) return 0; return a1 > b1 ? 1 : -1; });
  391. return countries;
  392. } else {
  393. var serviceURL = '/api/sitecore/CountrySelectorModule/GetCountrySelectorData';
  394. $.ajax({
  395. type: 'GET',
  396. url: serviceURL,
  397. contentType: "application/json; charset=utf-8",
  398. data: { pageContext: pageContext }, //pulled from the country selector view variable.
  399. dataType: "json",
  400. async: true,
  401. cache: true,
  402. error: function () {
  403. console.error("Error while trying to get Geo Group List.");
  404. },
  405. success: function (data, status) {
  406. if (data.GeoGroup != null && data.GeoGroup != "") {
  407. if (data.GeoGroup.length > 0) {
  408. if (typeof (Storage) !== "undefined") {
  409. var dataObject = { GeoGroup: data.GeoGroup, DateCreated: new Date().getTime() }
  410.  
  411. if (pageLocation.indexOf("/careers") >= 0) {
  412. localStorage.setItem(ACN_COUNTRY_SELECTOR_CAREERS, JSON.stringify(dataObject));
  413. }
  414. else {
  415. localStorage.setItem(ACN_COUNTRY_SELECTOR_DOTCOM, JSON.stringify(dataObject));
  416. }
  417. }
  418.  
  419. for (var i = 0; i < data.GeoGroup.length; i++) {
  420. for (var j = 0; j < data.GeoGroup[i].CountryGroup.length; j++) {
  421. for (var k = 0; k < data.GeoGroup[i].CountryGroup[j].CountryList.length; k++) {
  422. countries.push(data.GeoGroup[i].CountryGroup[j].CountryList[k]);
  423. }
  424. }
  425. }
  426. countries.sort(function (a, b) { var a1 = a.CountryName, b1 = b.CountryName; if (a1 == b1) return 0; return a1 > b1 ? 1 : -1; });
  427. }
  428. } else {
  429. console.error("Page Context is not set.");
  430. }
  431. }
  432. })
  433. return countries;
  434. }
  435. }
  436. function CheckCountrySelectorLocalStorage() {
  437. var pageLocation = document.location.href.toLowerCase();
  438.  
  439. if (typeof (Storage) !== "undefined") {
  440. if (pageLocation.indexOf("/careers") >= 0) {
  441. geoGroupStoredData = localStorage.getItem(ACN_COUNTRY_SELECTOR_CAREERS);
  442. }
  443. else {
  444. geoGroupStoredData = localStorage.getItem(ACN_COUNTRY_SELECTOR_DOTCOM);
  445. }
  446. }
  447. return geoGroupStoredData;
  448. }
  449.  
  450. function CountrySelectorTemplate(countries) {
  451. var locationContainerId = "#location-recommendation";
  452. var locationSelectorMarkup = "";
  453. var countrySite = "/" + window.location.pathname.split("/")[1];
  454. var defaultHeader = "";
  455. var languageContainer = $('.language-container.ucase');
  456.  
  457. //Compare countrysite of the URL to the list of countries displayed in the Language Selector
  458. for (var i = 0; i < countries.length; i++) {
  459. //var countryUrl = countries[i].CountryList[0].CountryDotcomUrl;
  460. //var countryLanguage = RetrieveCountryLanguageName(countries[i].CountryList[0].LanguageName);
  461. // var countryAbbr = countries[i].CountryList[0].LanguageAbbr;
  462. var countryUrl = countries[i].CountryDotcomUrl;
  463. var countryLanguage = countries[i].LanguageTitle;
  464. var countryAbbr = countries[i].LanguageAbbr;
  465.  
  466. //If countrysite is the same as the URL of the country, End the comparison
  467. //Display the corresponding language of the country as Default Language
  468. if (countrySite == countryUrl) {
  469. defaultHeader = '<li class="default">Default (' + countryLanguage + ') </li > ';
  470. languageContainer.text(countryAbbr);
  471. break;
  472. }
  473. //Else, if countrysite is not among the list, set "English" as default
  474. else {
  475. defaultHeader = '<li class="default">Default (English) </li > ';
  476. languageContainer.text('ENG');
  477. }
  478. }
  479.  
  480. var allCountriesHeader = '<li class="dropdown-header ucase">All COUNTRIES &amp; LANGUAGES</li>';
  481.  
  482. locationSelectorMarkup = '<ul type="none" role="menu">';
  483. locationSelectorMarkup += defaultHeader;
  484. locationSelectorMarkup += allCountriesHeader;
  485.  
  486. for (var i = 0; i < countries.length; i++) {
  487. var countryName = countries[i].CountryName;
  488. var countryUrl = countries[i].CountryDotcomUrl;
  489. var countryLanguage = countries[i].LanguageTitle;
  490. locationSelectorMarkup += '<li><a href="' + countryUrl + '" role="list">' + countryName + " (" + countryLanguage + ")" + '</a></li>';
  491. }
  492. locationSelectorMarkup += '</ul>';
  493.  
  494. $(locationContainerId).html(locationSelectorMarkup);
  495. }
  496.  
  497. var setNavigationHeightOnChangeOrientation = function () {
  498. if (isTablet()) {
  499. navContainer.css('height', (deviceHeight - 49) + 'px');
  500. } else {
  501. navContainer.css({ 'height': (deviceHeight - 49) + 'px', 'overflow': 'auto' });
  502. }
  503. }
  504.  
  505. return {
  506. init: init,
  507. setNavigationHeightOnChangeOrientation: setNavigationHeightOnChangeOrientation
  508. }
  509. })();
  510.  
  511. /* HIDE OR SHOW SECONDARY NAVIGATION CONTROL */
  512. var showHideSecondaryNav = {
  513. showNav: function (navlinks) {
  514. var $this = navlinks;
  515. var subMenu = $("#" + $this.data("id"));
  516.  
  517. subMenu.css({ 'opacity': '0', 'top': '-530px' });
  518. subMenu.removeClass("hidden").animate({
  519. opacity: '1',
  520. top: '70px'
  521. }, 400);
  522. },
  523. hideNav: function (navlinks) {
  524. var $this = navlinks;
  525. var subMenu = $("#" + $this.data("id"));
  526.  
  527. subMenu.css({ 'opacity': '1' });
  528. subMenu.animate({ opacity: '0' }, 400);
  529.  
  530. setTimeout(function () {
  531. subMenu.addClass("hidden")
  532. }, 450);
  533. },
  534. hideAllNav: function () {
  535. //var $this = divContainer;
  536. var subMenu = divContainer;
  537.  
  538. subMenu.css({ 'opacity': '1' });
  539. subMenu.animate({ opacity: '0' }, 400);
  540.  
  541. //setTimeout(function () {
  542. subMenu.addClass("hidden")
  543. //}, 450);
  544. },
  545. hideSubNav: function () {
  546. var subMenu = divContainer;
  547. navLabel.removeClass('active');
  548. subMenu.css({ 'top': '0', 'opacity': '1' });
  549. subMenu.animate({
  550. top: '-530px',
  551. opacity: '0'
  552. }, 400);
  553. setTimeout(function () {
  554. subMenu.addClass("hidden")
  555. }, 450);
  556. },
  557. clickHideNav: function (navlinks) {
  558. var $this = navlinks;
  559. var subMenu = $("#" + $this.data("id"));
  560.  
  561. subMenu.css({ 'top': '0', 'opacity': '1' });
  562. subMenu.animate({
  563. top: '-530px',
  564. opacity: '0'
  565. }, 300);
  566. setTimeout(function () {
  567. subMenu.addClass("hidden");
  568. }, 700);
  569. },
  570. showBackDrop: function () {
  571. backDropTablet.css({ 'opacity': '0.6', 'z-index': '-1', 'top': '0' });
  572. backDropTablet.removeClass("hidden").animate({
  573. opacity: '0.6',
  574. zIndex: '1'
  575. }, 300);
  576. },
  577. hideBackDrop: function () {
  578. backDropTablet.css({ 'opacity': '1', 'z-index': '1' });
  579. backDropTablet.animate({
  580. opacity: '0',
  581. zIndex: '0'
  582. }, 300);
  583. setTimeout(function () { backDropTablet.addClass('hidden') }, 1000);
  584. },
  585. hideBackDropOnClick: function () {
  586. var primaryNav = $('.primary-nav');
  587. primaryNav.css({ 'margin-top': '0' });
  588. primaryNav.animate({
  589. marginTop: '-200%'
  590. }, 300);
  591. backDropTablet.css({ 'top': '', 'margin-top': '0%' });
  592. backDropTablet.animate({
  593. maringTop: '-200%',
  594. opacity: '0',
  595. zIndex: '0'
  596. }, 100);
  597. setTimeout(function () {
  598. navIcon.toggleClass('open');
  599. backDropTablet.addClass('hidden');
  600. navContainer.addClass('hidden')
  601. .removeClass('crawl-right');
  602. primaryNav.removeAttr('style');
  603. }, 400);
  604. closeL3();
  605. }
  606. }
  607.  
  608. /* COUNTRY SELECTOR CONTROL */
  609. var countrySelectorControl = {
  610. closeCountrySelector: function () {
  611. if (hasClass(countrySelectorCont, toggleCountryList)) {
  612. countrySelectorCont.removeClass(toggleCountryList);
  613. }
  614. }
  615. }
  616.  
  617. /* GLOBAL FUNCTIONS */
  618. /* Overrides native jquery function isMobile() */
  619. function isMobile() {
  620. if (viewPortWidth < 768) {
  621. return true;
  622. } else {
  623. return false;
  624. }
  625. }
  626.  
  627. function isTablet() {
  628. if (viewPortWidth >= 768 && viewPortWidth < 1000) {
  629. return true;
  630. } else {
  631. return false;
  632. }
  633. }
  634.  
  635. /* Overrides native jquery function hasClass() */
  636. function hasClass($thisElement, $class) {
  637. var classArray = $thisElement.attr('class');
  638. if (classArray) {
  639. classArray = classArray.split(" ");
  640. }
  641.  
  642. if ($.inArray($class, classArray) > 0) {
  643. return true;
  644. } else {
  645. return false;
  646. }
  647. }
  648. /* Landscape && Portrait Functions */
  649. function isLandscape() {
  650. if ($(window).width() > $(window).height()) {
  651. return true;
  652. }
  653. else {
  654. return false;
  655. }
  656. }
  657.  
  658. function isTertiaryOverflow(tertiary) {
  659. //sets footer to fix if overflow is false
  660. var tertiaryBaseHeight = $('#tertiaryListContainer').children('ul').height();
  661.  
  662. if ((tertiaryBaseHeight + secondContactLink.height() + primaryNav.height()) > $(window).height()) {
  663. // scrollbar
  664.  
  665. return true;
  666. }
  667. //sets footer to static if overflow is true
  668. else {
  669.  
  670. return false;
  671. }
  672. }
  673. function isSecondaryOverflow(subMenu) {
  674. //sets footer to fix if overflow is false
  675. var linkCount = subMenu.find('ul.secondaryCounter').first().data('secondarylinkcount');
  676. var linkHeight = subMenu.find('li').outerHeight();
  677. var secondaryLinkHeight = $('.nav-submenu-label').outerHeight();
  678. var secondaryLinkCount = $('.nav-submenu.panel').length;
  679. var menuFooterHeight = $('.nav-contact-link').height();
  680. var headerHeight = $('#header-topnav').height();
  681. var contentHeight = ((secondaryLinkHeight * secondaryLinkCount) + (linkCount * linkHeight));
  682. var contentSpace = ($(window).height() - menuFooterHeight - headerHeight);
  683.  
  684. if (contentHeight > contentSpace) {
  685. return true;
  686. }
  687. else {
  688. return false;
  689. }
  690. }
  691.  
  692. function isPrimaryOverflow() {
  693. var contentHeight = $('.nav-submenu-label.collapsed').length;
  694. var primaryLinkHeight = $('.nav-submenu-label.collapsed').height();
  695. if ((contentHeight * primaryLinkHeight) > (navMenu.outerHeight() - menuFooter.height())) {
  696. return true;
  697. } else {
  698. return false;
  699. }
  700. }
  701.  
  702. function closeL3() {
  703. navMenu.children().removeClass('hidden');
  704. tertiaryNav.css("display", "none");
  705. tertiaryListContainer.html("");
  706. subMenuLabel.removeClass('tertiaryLevel3');
  707. }
  708. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement