1 2window.mr = window.mr || {}; 3 4mr = (function (mr, $, window, document) { 5 "use strict"; 6 7 mr = mr || {}; 8 9 var components = { documentReady: [], documentReadyDeferred: [], windowLoad: [], windowLoadDeferred: [] }; 10 11 mr.status = { documentReadyRan: false, windowLoadPending: false }; 12 13 $(document).ready(documentReady); 14 $(window).on("load", windowLoad); 15 16 function documentReady(context) { 17 18 context = typeof context === typeof undefined ? $ : context; 19 components.documentReady.concat(components.documentReadyDeferred).forEach(function (component) { 20 component(context); 21 }); 22 mr.status.documentReadyRan = true; 23 if (mr.status.windowLoadPending) { 24 windowLoad(mr.setContext()); 25 } 26 } 27 28 function windowLoad(context) { 29 if (mr.status.documentReadyRan) { 30 mr.status.windowLoadPending = false; 31 context = typeof context === "object" ? $ : context; 32 components.windowLoad.concat(components.windowLoadDeferred).forEach(function (component) { 33 component(context); 34 }); 35 } else { 36 mr.status.windowLoadPending = true; 37 } 38 } 39 40 mr.setContext = function (contextSelector) { 41 var context = $; 42 if (typeof contextSelector !== typeof undefined) { 43 return function (selector) { 44 return $(contextSelector).find(selector); 45 }; 46 } 47 return context; 48 }; 49 50 mr.components = components; 51 mr.documentReady = documentReady; 52 mr.windowLoad = windowLoad; 53 54 return mr; 55}(window.mr, jQuery, window, document)); 56 57 58//////////////// Utility Functions 59mr = (function (mr, $, window, document) { 60 "use strict"; 61 mr.util = {}; 62 63 mr.util.requestAnimationFrame = window.requestAnimationFrame || 64 window.mozRequestAnimationFrame || 65 window.webkitRequestAnimationFrame || 66 window.msRequestAnimationFrame; 67 68 mr.util.documentReady = function ($) { 69 var today = new Date(); 70 var year = today.getFullYear(); 71 $('.update-year').text(year); 72 }; 73 74 mr.util.windowLoad = function ($) { 75 $('[data-delay-src]').each(function () { 76 var $el = $(this); 77 $el.attr('src', $el.attr('data-delay-src')); 78 $el.removeAttr('data-delay-src'); 79 }); 80 }; 81 82 mr.util.getURLParameter = function (name) { 83 return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [undefined, ""])[1].replace(/\+/g, '%20')) || null; 84 }; 85 86 87 mr.util.capitaliseFirstLetter = function (string) { 88 return string.charAt(0).toUpperCase() + string.slice(1); 89 }; 90 91 mr.util.slugify = function (text, spacesOnly) { 92 if (typeof spacesOnly !== typeof undefined) { 93 return text.replace(/ +/g, ''); 94 } else { 95 return text 96 .toLowerCase() 97 .replace(/[\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\]\[\}\{\'\"\;\\\:\?\/\>\<\.\,]+/g, '') 98 .replace(/ +/g, '-'); 99 } 100 }; 101 102 mr.util.sortChildrenByText = function (parentElement, reverse) { 103 var $parentElement = $(parentElement); 104 var items = $parentElement.children().get(); 105 var order = -1; 106 var order2 = 1; 107 if (typeof reverse !== typeof undefined) { order = 1; order2 = -1; } 108 109 items.sort(function (a, b) { 110 var keyA = $(a).text(); 111 var keyB = $(b).text(); 112 113 if (keyA < keyB) return order; 114 if (keyA > keyB) return order2; 115 return 0; 116 }); 117 118 // Append back into place 119 $parentElement.empty(); 120 $(items).each(function (i, itm) { 121 $parentElement.append(itm); 122 }); 123 }; 124 125 // Set data-src attribute of element from src to be restored later 126 mr.util.idleSrc = function (context, selector) { 127 128 selector = (typeof selector !== typeof undefined) ? selector : '';
129 var elems = context.is(selector + '[src]') ? context : context.find(selector + '[src]'); 130 131 elems.each(function (index, elem) { 132 elem = $(elem); 133 var currentSrc = elem.attr('src'), 134 dataSrc = elem.attr('data-src'); 135 136 // If there is no data-src, save current source to it 137 if (typeof dataSrc === typeof undefined) { 138 elem.attr('data-src', currentSrc); 139 } 140 141 // Clear the src attribute 142 elem.attr('src', ''); 143 144 }); 145 }; 146 147 // Set src attribute of element from its data-src where it was temporarily stored earlier 148 mr.util.activateIdleSrc = function (context, selector) { 149 150 selector = (typeof selector !== typeof undefined) ? selector : ''; 151 var elems = context.is(selector + '[data-src]') ? context : context.find(selector + '[data-src]'); 152 153 elems.each(function (index, elem) { 154 elem = $(elem); 155 var dataSrc = elem.attr('data-src'); 156 157 // Write the 'src' attribute using the 'data-src' value 158 elem.attr('src', dataSrc); 159 }); 160 }; 161 162 mr.util.pauseVideo = function (context) { 163 var elems = context.is('video') ? context : context.find('video'); 164 165 elems.each(function (index, video) { 166 var playingVideo = $(video).get(0); 167 playingVideo.pause(); 168 }); 169 }; 170 171 // Take a text value in either px (eg. 150px) or vh (eg. 65vh) and return a number in pixels. 172 mr.util.parsePixels = function (text) { 173 var windowHeight = $(window).height(), value; 174 175 // Text text against regular expression for px value. 176 if (/^[1-9]{1}[0-9]*[p][x]$/.test(text)) { 177 return parseInt(text.replace('px', ''), 10); 178 } 179 // Otherwise it is vh value. 180 else if (/^[1-9]{1}[0-9]*[v][h]$/.test(text)) { 181 value = parseInt(text.replace('vh', ''), 10); 182 // Return conversion to percentage of window height. 183 return windowHeight * (value / 100); 184 } else { 185 // If it is not proper text, return -1 to indicate bad value. 186 return -1; 187 } 188 }; 189 190 mr.util.removeHash = function () { 191 // Removes hash from URL bar without reloading and without losing search query 192 history.pushState("", document.title, window.location.pathname + window.location.search); 193 } 194 195 mr.components.documentReady.push(mr.util.documentReady); 196 mr.components.windowLoad.push(mr.util.windowLoad); 197 return mr; 198 199}(mr, jQuery, window, document)); 200 201//////////////// Window Functions 202mr = (function (mr, $, window, document) { 203 "use strict"; 204 205 mr.window = {}; 206 mr.window.height = $(window).height(); 207 mr.window.width = $(window).width(); 208 209 $(window).on('resize', function () { 210 mr.window.height = $(window).height(); 211 mr.window.width = $(window).width(); 212 }); 213 214 return mr; 215}(mr, jQuery, window, document)); 216 217 218//////////////// Scroll Functions 219mr = (function (mr, $, window, document) { 220 "use strict"; 221 222 223 mr.scroll = {}; 224 var raf = window.requestAnimationFrame || 225 window.mozRequestAnimationFrame || 226 window.webkitRequestAnimationFrame || 227 window.msRequestAnimationFrame; 228 mr.scroll.listeners = []; 229 mr.scroll.busy = false; 230 mr.scroll.y = 0; 231 mr.scroll.x = 0; 232 233 var documentReady = function ($) { 234
235 //////////////// Capture Scroll Event and fire scroll function 236 jQuery(window).off('scroll.mr'); 237 jQuery(window).on('scroll.mr', function (evt) { 238 if (mr.scroll.busy === false) { 239 240 mr.scroll.busy = true; 241 raf(function (evt) { 242 mr.scroll.update(evt); 243 }); 244 245 } 246 if (evt.stopPropagation) { 247 evt.stopPropagation(); 248 } 249 }); 250 251 }; 252 253 mr.scroll.update = function (event) { 254 255 // Loop through all mr scroll listeners 256 var parallax = typeof window.mr_parallax !== typeof undefined ? true : false; 257 mr.scroll.y = (parallax ? mr_parallax.mr_getScrollPosition() : window.pageYOffset); 258 mr.scroll.busy = false; 259 if (parallax) { 260 mr_parallax.mr_parallaxBackground(); 261 } 262 263 264 if (mr.scroll.listeners.length > 0) { 265 for (var i = 0, l = mr.scroll.listeners.length; i < l; i++) { 266 mr.scroll.listeners[i](event); 267 } 268 } 269 270 }; 271 272 mr.scroll.documentReady = documentReady; 273 274 mr.components.documentReady.push(documentReady); 275 276 return mr; 277 278}(mr, jQuery, window, document)); 279 280 281//////////////// Scroll Class Modifier 282mr = (function (mr, $, window, document) { 283 "use strict"; 284 285 mr.scroll.classModifiers = {}; 286 // Globally accessible list of elements/rules 287 mr.scroll.classModifiers.rules = []; 288 289 mr.scroll.classModifiers.parseScrollRules = function (element) { 290 var text = element.attr('data-scroll-class'), 291 rules = text.split(";"); 292
293 rules.forEach(function (rule) { 294 var ruleComponents, scrollPoint, ruleObject = {}; 295 ruleComponents = rule.replace(/\s/g, "").split(':'); 296 if (ruleComponents.length === 2) { 297 scrollPoint = mr.util.parsePixels(ruleComponents[0]); 298 if (scrollPoint > -1) { 299 ruleObject.scrollPoint = scrollPoint; 300 if (ruleComponents[1].length) { 301 var toggleClass = ruleComponents[1]; 302 ruleObject.toggleClass = toggleClass; 303 // Set variable in object to indicate that element already has class applied 304 ruleObject.hasClass = element.hasClass(toggleClass); 305 ruleObject.element = element.get(0); 306 mr.scroll.classModifiers.rules.push(ruleObject); 307 } else { 308 // Error: toggleClass component does not exist. 309 //console.log('Error - toggle class not found.'); 310 return false; 311 } 312 } else { 313 // Error: scrollpoint component was malformed 314 //console.log('Error - Scrollpoint not found.'); 315 return false; 316 } 317 } 318 }); 319 320 if (mr.scroll.classModifiers.rules.length) { 321 return true; 322 } else { 323 return false; 324 } 325 }; 326 327 mr.scroll.classModifiers.update = function (event) { 328 var currentScroll = mr.scroll.y, 329 scrollRules = mr.scroll.classModifiers.rules, 330 l = scrollRules.length, 331 currentRule; 332 333 // Given the current scrollPoint, check for necessary changes 334 while (l--) { 335 336 currentRule = scrollRules[l]; 337 338 if (currentScroll > currentRule.scrollPoint && !currentRule.hasClass) { 339 // Set local copy and glogal copy at the same time; 340 currentRule.element.classList.add(currentRule.toggleClass); 341 currentRule.hasClass = mr.scroll.classModifiers.rules[l].hasClass = true; 342 } 343 if (currentScroll < currentRule.scrollPoint && currentRule.hasClass) { 344 // Set local copy and glogal copy at the same time; 345 currentRule.element.classList.remove(currentRule.toggleClass); 346 currentRule.hasClass = mr.scroll.classModifiers.rules[l].hasClass = false; 347 } 348 } 349 }; 350 351 var fixedElementSizes = function () { 352 $('.main-container [data-scroll-class*="pos-fixed"]').each(function () { 353 var element = $(this); 354 element.css('max-width', element.parent().outerWidth()); 355 element.parent().css('min-height', element.outerHeight()); 356 }); 357 }; 358 359 var documentReady = function ($) { 360 // Collect info on all elements that require class modification at load time 361 // Each element has data-scroll-class with a formatted value to represent class to add/remove at a particular scroll point. 362 $('[data-scroll-class]').each(function () { 363 var element = $(this); 364 365 // Test the rules to be added to an array of rules. 366 if (!mr.scroll.classModifiers.parseScrollRules(element)) { 367 console.log('Error parsing scroll rules on: ' + element); 368 } 369 }); 370 371 // For 'position fixed' elements, give them a max-width for correct fixing behaviour 372 fixedElementSizes(); 373 $(window).on('resize', fixedElementSizes); 374 375 // If there are valid scroll rules add classModifiers update function to the scroll event processing queue. 376 if (mr.scroll.classModifiers.rules.length) { 377 mr.scroll.listeners.push(mr.scroll.classModifiers.update); 378 } 379 }; 380 381 mr.components.documentReady.push(documentReady); 382 mr.scroll.classModifiers.documentReady = documentReady; 383 384 385 386 return mr; 387 388}(mr, jQuery, window, document)); 389 390 391//////////////// Accordions 392mr = (function (mr, $, window, document) { 393 "use strict"; 394 395 mr.accordions = mr.accordions || {}; 396 397 mr.accordions.documentReady = function ($) { 398 $('.accordion__title').on('click', function () { 399 mr.accordions.activatePanel($(this)); 400 }); 401 402 $('.accordion').each(function () { 403 var accordion = $(this); 404 var minHeight = accordion.outerHeight(true); 405 accordion.css('min-height', minHeight); 406 }); 407 408 if (window.location.hash !== '' && window.location.hash !== '#') { 409 if ($('.accordion li' + $(this).attr('href')).length) { 410 mr.accordions.activatePanelById(window.location.hash, true); 411 } 412 } 413 414 jQuery(document).on('click', 'a[href^="#"]:not(a[href="#"])', function () { 415 416 if ($('.accordion > li > .accordion__title' + $(this).attr('href')).length) { 417 mr.accordions.activatePanelById($(this).attr('href'), true); 418 } 419 }); 420 }; 421 422 423 424 mr.accordions.activatePanel = function (panel, forceOpen) { 425 426 var $panel = $(panel), 427 accordion = $panel.closest('.accordion'), 428 li = $panel.closest('li'), 429 openEvent = document.createEvent('Event'), 430 closeEvent = document.createEvent('Event'); 431 432 openEvent.initEvent('panelOpened.accordions.mr', true, true); 433 closeEvent.initEvent('panelClosed.accordions.mr', true, true); 434 435 436 437 if (li.hasClass('active')) { 438 439 if (forceOpen !== true) { 440 441 li.removeClass('active'); 442 $panel.trigger('panelClosed.accordions.mr').get(0).dispatchEvent(closeEvent); 443 } 444 } else { 445 446 if (accordion.hasClass('accordion--oneopen')) { 447 448 var wasActive = accordion.find('li.active'); 449 if (wasActive.length) { 450 wasActive.removeClass('active'); 451 wasActive.trigger('panelClosed.accordions.mr').get(0).dispatchEvent(closeEvent); 452 } 453 li.addClass('active'); 454 li.trigger('panelOpened.accordions.mr').get(0).dispatchEvent(openEvent); 455 456 } else { 457 458 if (!li.is('.active')) { 459 li.trigger('panelOpened.accordions.mr').get(0).dispatchEvent(openEvent); 460 } 461 li.addClass('active'); 462 } 463 } 464 }; 465 466 mr.accordions.activatePanelById = function (id, forceOpen) { 467 var panel; 468 469 if (id !== '' && id !== '#') { 470 panel = $('.accordion > li > .accordion__title#' + id.replace('#', '')); 471 if (panel.length) { 472 $('html, body').stop(true).animate({ 473 scrollTop: (panel.offset().top - 50) 474 }, 1200); 475 476 mr.accordions.activatePanel(panel, forceOpen); 477 } 478 } 479 }; 480 481 mr.components.documentReady.push(mr.accordions.documentReady); 482 return mr; 483 484}(mr, jQuery, window, document)); 485 486 487//////////////// Alerts 488mr = (function (mr, $, window, document) { 489 "use strict"; 490 491 mr.alerts = mr.alerts || {}; 492 493 mr.alerts.documentReady = function ($) { 494 $('.alert__close').on('click touchstart', function () { 495 jQuery(this).closest('.alert').addClass('alert--dismissed'); 496 }); 497 }; 498 499 mr.components.documentReady.push(mr.alerts.documentReady); 500 return mr; 501 502}(mr, jQuery, window, document)); 503 504
505//////////////// Backgrounds 506mr = (function (mr, $, window, document) { 507 "use strict"; 508 509 mr.backgrounds = mr.backgrounds || {}; 510 511 mr.backgrounds.documentReady = function ($) { 512 513 //////////////// Append .background-image-holder <img>'s as CSS backgrounds 514 515 $('.background-image-holder').each(function () { 516 var imgSrc = $(this).children('img').attr('src'); 517 $(this).css('background', 'url("' + imgSrc + '")').css('background-position', 'initial').css('opacity', '1'); 518 }); 519 }; 520 521 mr.components.documentReady.push(mr.backgrounds.documentReady); 522 return mr; 523 524}(mr, jQuery, window, document)); 525 526//////////////// Bars 527mr = (function (mr, $, window, document) { 528 "use strict"; 529 530 mr.bars = mr.bars || {}; 531 532 mr.bars.documentReady = function ($) { 533 $('.nav-container .bar[data-scroll-class*="fixed"]:not(.bar--absolute)').each(function () { 534 var bar = $(this), 535 barHeight = bar.outerHeight(true); 536 bar.closest('.nav-container').css('min-height', barHeight); 537 }); 538 }; 539 540 mr.components.documentReady.push(mr.bars.documentReady); 541 return mr; 542 543}(mr, jQuery, window, document)); 544 545//////////////// Cookies 546mr = (function (mr, $, window, document) { 547 "use strict"; 548 549 mr.cookies = { 550 551 getItem: function (sKey) { 552 if (!sKey) { return null; } 553 return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; 554 }, 555 setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) { 556 if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } 557 var sExpires = ""; 558 if (vEnd) { 559 switch (vEnd.constructor) { 560 case Number: 561 sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd; 562 break; 563 case String: 564 sExpires = "; expires=" + vEnd; 565 break; 566 case Date: 567 sExpires = "; expires=" + vEnd.toUTCString(); 568 break; 569 } 570 } 571 document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); 572 return true; 573 }, 574 removeItem: function (sKey, sPath, sDomain) { 575 if (!this.hasItem(sKey)) { return false; } 576 document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : ""); 577 return true; 578 }, 579 hasItem: function (sKey) { 580 if (!sKey) { return false; } 581 return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); 582 }, 583 keys: function () { 584 var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/); 585 for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); } 586 return aKeys; 587 } 588 }; 589 590 return mr; 591 592}(mr, jQuery, window, document)); 593 594//////////////// Countdown 595mr = (function (mr, $, window, document) { 596 "use strict"; 597 598 mr.countdown = mr.countdown || {}; 599 mr.countdown.options = mr.countdown.options || {}; 600 601 mr.countdown.documentReady = function ($) { 602 603 $('.countdown[data-date]').each(function () { 604 var element = $(this), 605 date = element.attr('data-date'), 606 daysText = typeof element.attr('data-days-text') !== typeof undefined ? '%D ' + element.attr('data-days-text') + ' %H:%M:%S' : '%D days %H:%M:%S', 607 daysText = typeof mr.countdown.options.format !== typeof undefined ? mr.countdown.options.format : daysText, 608 dateFormat = typeof element.attr('data-date-format') !== typeof undefined ? element.attr('data-date-format') : daysText, 609 610 fallback; 611 612 if (typeof element.attr('data-date-fallback') !== typeof undefined) { 613 fallback = element.attr('data-date-fallback') || "Timer Done"; 614 } 615 616 element.countdown(date, function (event) { 617 if (event.elapsed) { 618 element.text(fallback); 619 } else { 620 element.text( 621 event.strftime(dateFormat) 622 ); 623 } 624 }); 625 }); 626 627 }; 628 629 mr.components.documentReadyDeferred.push(mr.countdown.documentReady); 630 return mr; 631 632}(mr, jQuery, window, document)); 633
634//////////////// Datepicker 635mr = (function (mr, $, window, document) { 636 "use strict"; 637 638 mr.datepicker = mr.datepicker || {}; 639 640 var options = mr.datepicker.options || {}; 641 642 mr.datepicker.documentReady = function ($) { 643 if ($('.datepicker').length) { 644 $('.datepicker').pickadate(options); 645 } 646 }; 647 648 mr.components.documentReadyDeferred.push(mr.datepicker.documentReady); 649 return mr; 650 651}(mr, jQuery, window, document)); 652 653//////////////// Dropdowns 654mr = (function (mr, $, window, document) { 655 "use strict"; 656 657 mr.dropdowns = mr.dropdowns || {}; 658 659 mr.dropdowns.done = false; 660 661 mr.dropdowns.documentReady = function ($) { 662 663 var rtl = false; 664 665 if ($('html[dir="rtl"]').length) { 666 rtl = true; 667 } 668 669 if (!mr.dropdowns.done) { 670 jQuery(document).on('click', 'body:not(.dropdowns--hover) .dropdown:not(.dropdown--hover), body.dropdowns--hover .dropdown.dropdown--click', function (event) { 671 var dropdown = jQuery(this); 672 if (jQuery(event.target).is('.dropdown--active > .dropdown__trigger')) { 673 dropdown.siblings().removeClass('dropdown--active').find('.dropdown').removeClass('dropdown--active'); 674 dropdown.toggleClass('dropdown--active'); 675 } else { 676 console.log("oculta"); 677 $('.dropdown--active').removeClass('dropdown--active'); 678 } 679 }); 680 jQuery(document).on('click touchstart', 'body:not(.dropdowns--hover)', function (event) { 681 if (!jQuery(event.target).is('[class*="dropdown"], [class*="dropdown"] *')) { 682 $('.dropdown--active').removeClass('dropdown--active'); 683 } 684 }); 685 686 jQuery('body.dropdowns--hover .dropdown').on('click', function (event) { 687 event.stopPropagation(); 688 var hoverDropdown = jQuery(this); 689 hoverDropdown.toggleClass('dropdown--active'); 690 }); 691 692 // Append a container to the body for measuring purposes 693 jQuery('body').append('<div class="container containerMeasure" style="opacity:0;pointer-events:none;"></div>'); 694 695 // Menu dropdown positioning 696 if (rtl === false) { 697 mr.dropdowns.repositionDropdowns($); 698 jQuery(window).on('resize', function () { mr.dropdowns.repositionDropdowns($); }); 699 } else { 700 mr.dropdowns.repositionDropdownsRtl($); 701 jQuery(window).on('resize', function () { mr.dropdowns.repositionDropdownsRtl($); }); 702 } 703 704 mr.dropdowns.done = true; 705 } 706 }; 707 708 mr.dropdowns.repositionDropdowns = function ($) { 709 $('.dropdown__container').each(function () { 710 var container, containerOffset, masterOffset, menuItem, content; 711 712 jQuery(this).css('left', ''); 713 714 container = jQuery(this); 715 containerOffset = container.offset().left; 716 masterOffset = jQuery('.containerMeasure').offset().left; 717 menuItem = container.closest('.dropdown').offset().left; 718 content = null; 719 720 container.css('left', ((-containerOffset) + (masterOffset))); 721 722 if (container.find('.dropdown__content:not([class*="md-12"])').length) { 723 content = container.find('.dropdown__content'); 724 content.css('left', ((menuItem) - (masterOffset))); 725 } 726 727 }); 728 $('.dropdown__content').each(function () { 729 var dropdown, offset, width, offsetRight, winWidth, leftCorrect; 730 731 dropdown = jQuery(this); 732 offset = dropdown.offset().left; 733 width = dropdown.outerWidth(true); 734 offsetRight = offset + width; 735 winWidth = jQuery(window).outerWidth(true); 736 leftCorrect = jQuery('.containerMeasure').outerWidth() - width; 737 738 if (offsetRight > winWidth) { 739 dropdown.css('left', leftCorrect); 740 } 741 742 }); 743 }; 744 745 mr.dropdowns.repositionDropdownsRtl = function ($) { 746 747 var windowWidth = jQuery(window).width(); 748 749 $('.dropdown__container').each(function () { 750 var container, containerOffset, masterOffset, menuItem, content; 751 752 jQuery(this).css('left', ''); 753 754 container = jQuery(this); 755 containerOffset = windowWidth - (container.offset().left + container.outerWidth(true)); 756 masterOffset = jQuery('.containerMeasure').offset().left; 757 menuItem = windowWidth - (container.closest('.dropdown').offset().left + container.closest('.dropdown').outerWidth(true)); 758 content = null; 759 760 container.css('right', ((-containerOffset) + (masterOffset))); 761 762 if (container.find('.dropdown__content:not([class*="md-12"])').length) { 763 content = container.find('.dropdown__content'); 764 content.css('right', ((menuItem) - (masterOffset))); 765 } 766 }); 767 $('.dropdown__content').each(function () { 768 var dropdown, offset, width, offsetRight, winWidth, rightCorrect; 769 770 dropdown = jQuery(this); 771 offset = windowWidth - (dropdown.offset().left + dropdown.outerWidth(true)); 772 width = dropdown.outerWidth(true); 773 offsetRight = offset + width; 774 winWidth = jQuery(window).outerWidth(true); 775 rightCorrect = jQuery('.containerMeasure').outerWidth() - width; 776 777 if (offsetRight > winWidth) { 778 dropdown.css('right', rightCorrect); 779 } 780 781 }); 782 }; 783 784 785 mr.components.documentReady.push(mr.dropdowns.documentReady); 786 return mr; 787 788}(mr, jQuery, window, document)); 789
790//////////////// Forms 791 792mr = (function (mr, $, window, document) { 793 "use strict"; 794 795 mr.forms = mr.forms || {}; 796 mr.forms.captcha = {}; 797 mr.forms.captcha.widgets = []; 798 mr.forms.captcha.done = false; 799 800 mr.forms.documentReady = function ($) { 801 802 mr.forms.captcha.widgets = []; 803 804 /// Checkbox & Radio Inputs 805 806 $('.input-checkbox input[type="checkbox"], .input-radio input[type="radio"]').each(function (index) { 807 var input = $(this), 808 label = input.siblings('label'), 809 id = "input-assigned-" + index; 810 if (typeof input.attr('id') === typeof undefined || input.attr('id') === "") { 811 input.attr('id', id); 812 label.attr('for', id); 813 } else { 814 id = input.attr('id'); 815 label.attr('for', id); 816 } 817 }); 818 819 //////////////// Number Inputs 820 821 $('.input-number__controls > span').off('click.mr').on('click.mr', function () { 822 var control = jQuery(this), 823 parent = control.closest('.input-number'), 824 input = parent.find('input[type="number"]'), 825 max = input.attr('max'), 826 min = input.attr('min'), 827 step = 1, 828 current = parseInt(input.val(), 10); 829 830 if (parent.is('[data-step]')) { 831 step = parseInt(parent.attr('data-step'), 10); 832 } 833 834 if (control.hasClass('input-number__increase')) { 835 if ((current + step) <= max) { 836 input.val(current + step); 837 } 838 } else { 839 if ((current - step) >= min) { 840 input.val(current - step); 841 } 842 } 843 }); 844 845
846 //////////////// File Uploads 847 848 $('.input-file .btn').off('click.mr').on('click.mr', function () { 849 $(this).siblings('input').trigger('click'); 850 return false; 851 }); 852 853 //////////////// Handle Form Submit 854 855 $('form.form-email, form[action*="list-manage.com"], form[action*="createsend.com"]').attr('novalidate', true).off('submit').on('submit', mr.forms.submit); 856 857 //////////////// Handle Form Submit 858 $(document).on('change, input, paste, keyup', '.attempted-submit .field-error', function () { 859 $(this).removeClass('field-error'); 860 }); 861 862 //////////////// Check forms for Google reCaptcha site keys 863 864 $('form[data-recaptcha-sitekey]:not([data-recaptcha-sitekey=""])').each(function () { 865 var $thisForm = jQuery(this), 866 $captchaDiv = $thisForm.find('div.recaptcha'), 867 $insertBefore, $column, widgetObject, $script, scriptSrc, widgetColourTheme, widgetSize; 868 869 widgetColourTheme = $thisForm.attr('data-recaptcha-theme'); 870 widgetColourTheme = typeof widgetColourTheme !== typeof undefined ? widgetColourTheme : ''; 871 872 widgetSize = $thisForm.attr('data-recaptcha-size'); 873 widgetSize = typeof widgetSize !== typeof undefined ? widgetSize : ''; 874 875 // Store the site key for later use 876 mr.forms.captcha.sitekey = $thisForm.attr('data-recaptcha-sitekey'); 877 878 if ($captchaDiv.length) { 879 // If a div.recaptcha was already present on this form, do nothing at this stage, 880 // It will be populated with a captcha widget later. 881 } else { 882 // Create a captcha div and insert it before the submit button. 883 $insertBefore = $thisForm.find('button[type=submit]').closest('[class*="col-"]'); 884 $captchaDiv = jQuery('<div>').addClass('recaptcha'); 885 $column = jQuery('<div>').addClass('col-xs-12').append($captchaDiv); 886 $column.insertBefore($insertBefore); 887 } 888 889 890 // Add the widget div to the widgets array 891 widgetObject = { 892 element: $captchaDiv.get(0), 893 parentForm: $thisForm, 894 theme: widgetColourTheme, 895 size: widgetSize, 896 }; 897 898 899 900 mr.forms.captcha.widgets.push(widgetObject); 901 902 // mr.forms.captcha.done indicates whether the api script has been appended yet. 903 if (mr.forms.captcha.done === false) { 904 if (!jQuery('script[src*="recaptcha/api.js"]').length) { 905 $script = jQuery('<script async defer>'); 906 scriptSrc = 'https://www.google.com/recaptcha/api.js?onload=mrFormsCaptchaInit&render=explicit'; 907 $script.attr('src', scriptSrc); 908 jQuery('body').append($script); 909 mr.forms.captcha.done = true; 910 } 911 } else { 912 if (typeof grecaptcha !== typeof undefined) { 913 mr.forms.captcha.renderWidgets(); 914 } 915 } 916 917 }); 918 919 920 }; 921 922 mr.forms.submit = function (e) { 923 // return false so form submits through jQuery rather than reloading page. 924 if (e.preventDefault) e.preventDefault(); 925 else e.returnValue = false; 926 927 var body = $('body'), 928 thisForm = $(e.target).closest('form'), 929 formAction = typeof thisForm.attr('action') !== typeof undefined ? thisForm.attr('action') : "", 930 submitButton = thisForm.find('button[type="submit"], input[type="submit"]'), 931 error = 0, 932 originalError = thisForm.attr('original-error'), 933 captchaUsed = thisForm.find('div.recaptcha').length ? true : false, 934 successRedirect, formError, formSuccess, errorText, successText; 935 936 body.find('.form-error, .form-success').remove(); 937 submitButton.attr('data-text', submitButton.text()); 938 errorText = thisForm.attr('data-error') ? thisForm.attr('data-error') : "Please fill all fields correctly"; 939 successText = thisForm.attr('data-success') ? thisForm.attr('data-success') : "Thanks, we'll be in touch shortly"; 940 body.append('<div class="form-error" style="display: none;">' + errorText + '</div>'); 941 body.append('<div class="form-success" style="display: none;">
941' + successText + '</div>'); 942 formError = body.find('.form-error'); 943 formSuccess = body.find('.form-success'); 944 thisForm.addClass('attempted-submit'); 945 946 // Do this if the form is intended to be submitted to MailChimp or Campaign Monitor 947 if (formAction.indexOf('createsend.com') !== -1 || formAction.indexOf('list-manage.com') !== -1) { 948 949 console.log('Mail list form signup detected.'); 950 if (typeof originalError !== typeof undefined && originalError !== false) { 951 formError.html(originalError); 952 } 953 954 // validateFields returns 1 on error; 955 if (mr.forms.validateFields(thisForm) !== 1) { 956 957 thisForm.removeClass('attempted-submit'); 958 959 // Hide the error if one was shown 960 formError.fadeOut(200); 961 // Create a new loading spinner in the submit button. 962 submitButton.addClass('btn--loading'); 963 964 try { 965 $.ajax({
966 url: thisForm.attr('action'), 967 crossDomain: true, 968 data: thisForm.serialize(), 969 method: "GET", 970 cache: false, 971 dataType: 'json', 972 contentType: 'application/json; charset=utf-8', 973 success: function (data) { 974 // Request was a success, what was the response? 975 976 if (data.result !== "success" && data.Status !== 200) { 977 978 // Got an error from Mail Chimp or Campaign Monitor 979 980 // Keep the current error text in a data attribute on the form 981 formError.attr('original-error', formError.text()); 982 // Show the error with the returned error text. 983 formError.html(data.msg).stop(true).fadeIn(1000); 984 formSuccess.stop(true).fadeOut(1000); 985 986 submitButton.removeClass('btn--loading'); 987 } else { 988 989 // Got success from Mail Chimp or Campaign Monitor 990 991 submitButton.removeClass('btn--loading'); 992 993 successRedirect = thisForm.attr('data-success-redirect'); 994 // For some browsers, if empty `successRedirect` is undefined; for others, 995 // `successRedirect` is false. Check for both. 996 if (typeof successRedirect !== typeof undefined && successRedirect !== false && successRedirect !== "") { 997 window.location = successRedirect; 998 } else { 999 mr.forms.resetForm(thisForm); 1000 mr.forms.showFormSuccess(formSuccess, formError, 1000, 5000, 500); 1001 } 1002 } 1003 } 1004 }); 1005 } catch (err) { 1006 // Keep the current error text in a data attribute on the form 1007 formError.attr('original-error', formError.text()); 1008 // Show the error with the returned error text. 1009 formError.html(err.message); 1010 mr.forms.showFormError(formSuccess, formError, 1000, 5000, 500); 1011 1012 submitButton.removeClass('btn--loading'); 1013 } 1014 1015 1016 1017 } else { 1018 // There was a validation error - show the default form error message 1019 mr.forms.showFormError(formSuccess, formError, 1000, 5000, 500); 1020 } 1021 } else { 1022 // If no MailChimp or Campaign Monitor form was detected then this is treated as an email form instead. 1023 if (typeof originalError !== typeof undefined && originalError !== false) { 1024 formError.text(originalError); 1025 } 1026 1027 error = mr.forms.validateFields(thisForm); 1028 1029 if (error === 1) { 1030 mr.forms.showFormError(formSuccess, formError, 1000, 5000, 500); 1031 } else { 1032 1033 thisForm.removeClass('attempted-submit'); 1034 1035 // Hide the error if one was shown 1036 formError.fadeOut(200); 1037 1038 // Create a new loading spinner in the submit button. 1039 submitButton.addClass('btn--loading'); 1040 1041 jQuery.ajax({ 1042 type: "POST", 1043 url: (formAction !== "" ? formAction : "mail/mail.php"), 1044 data: thisForm.serialize() + "&url=" + window.location.href + "&captcha=" + captchaUsed, 1045 success: function (response) { 1046 // Swiftmailer always sends back a number representing number of emails sent. 1047 // If this is numeric (not Swift Mailer error text) AND greater than 0 then show success message. 1048 1049 submitButton.removeClass('btn--loading'); 1050 1051 if ($.isNumeric(response)) { 1052 if (parseInt(response, 10) > 0) { 1053 // For some browsers, if empty 'successRedirect' is undefined; for others, 1054 // 'successRedirect' is false. Check for both. 1055 successRedirect = thisForm.attr('data-success-redirect'); 1056 if (typeof successRedirect !== typeof undefined && successRedirect !== false && successRedirect !== "") { 1057 window.location = successRedirect; 1058 } 1059 1060 mr.forms.resetForm(thisForm); 1061 mr.forms.showFormSuccess(formSuccess, formError, 1000, 5000, 500); 1062 mr.forms.captcha.resetWidgets(); 1063 } 1064 } 1065 // If error text was returned, put the text in the .form-error div and show it. 1066 else { 1067 // Keep the current error text in a data attribute on the form 1068 formError.attr('original-error', formError.text()); 1069 // Show the error with the returned error text. 1070 formError.text(response).stop(true).fadeIn(1000); 1071 formSuccess.stop(true).fadeOut(1000); 1072 } 1073 }, 1074 error: function (errorObject, errorText, errorHTTP) { 1075 // Keep the current error text in a data attribute on the form 1076 formError.attr('original-error', formError.text()); 1077 // Show the error with the returned error text. 1078 formError.text(errorHTTP).stop(true).fadeIn(1000); 1079 formSuccess.stop(true).fadeOut(1000); 1080 submitButton.removeClass('btn--loading'); 1081 } 1082 }); 1083 } 1084 } 1085 return false; 1086 }; 1087 1088 mr.forms.validateFields = function (form) { 1089 var body = $(body), 1090 error = false, 1091 originalErrorMessage, 1092 name, 1093 thisElement; 1094 1095 form = $(form); 1096 1097 1098 1099 1100 form.find('.validate-required[type="checkbox"]').each(function () { 1101 var checkbox = $(this); 1102 if (!$('[name="' + $(this).attr('name') + '"]:checked').length) { 1103 error = 1; 1104 name = $(this).attr('data-name') || 'check'; 1105 checkbox.parent().addClass('field-error'); 1106 //body.find('.form-error').text('Please tick at least one ' + name + ' box.'); 1107 } 1108 }); 1109 1110 form.find('.validate-required, .required, [required]').not('input[type="checkbox"]').each(function () { 1111 if ($(this).val() === '') { 1112 $(this).addClass('field-error'); 1113 error = 1; 1114 } else { 1115 $(this).removeClass('field-error'); 1116 } 1117 }); 1118 1119 form.find('.validate-email, .email, [name*="cm-"][type="email"]').each(function () { 1120 if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) { 1121 $(this).addClass('field-error'); 1122 error = 1; 1123 } else { 1124 $(this).removeClass('field-error'); 1125 } 1126 }); 1127 1128 form.find('.validate-number-dash').each(function () { 1129 if (!(/^[0-9][0-9-]+[0-9]$/.test($(this).val()))) { 1130 $(this).addClass('field-error'); 1131 error = 1; 1132 } else { 1133 $(this).removeClass('field-error'); 1134 } 1135 }); 1136 1137 // Validate recaptcha 1138 if (form.find('div.recaptcha').length && typeof form.attr('data-recaptcha-sitekey') !== typeof undefined) { 1139 thisElement = $(form.find('div.recaptcha')); 1140 1141 if (grecaptcha.getResponse(form.data('recaptchaWidgetID')) !== "") { 1142 thisElement.removeClass('field-error'); 1143 } else { 1144 thisElement.addClass('field-error'); 1145 error = 1; 1146 } 1147 } 1148 1149 if (!form.find('.field-error').length) { 1150 body.find('.form-error').fadeOut(1000); 1151 } else { 1152 1153 var firstError = $(form).find('.field-error:first'); 1154 1155 if (firstError.length) { 1156 $('html, body').stop(true).animate({ 1157 scrollTop: (firstError.offset().top - 100) 1158 }, 1200, function () { firstError.focus(); }); 1159 } 1160 } 1161 1162 1163 1164 return error; 1165 }; 1166 1167 mr.forms.showFormSuccess = function (formSuccess, formError, fadeOutError, wait, fadeOutSuccess) { 1168 1169 formSuccess.stop(true).fadeIn(fadeOutError); 1170 1171 formError.stop(true).fadeOut(fadeOutError); 1172 setTimeout(function () { 1173 formSuccess.stop(true).fadeOut(fadeOutSuccess); 1174 }, wait); 1175 }; 1176 1177 mr.forms.showFormError = function (formSuccess, formError, fadeOutSuccess, wait, fadeOutError) { 1178 1179 formError.stop(true).fadeIn(fadeOutSuccess); 1180 1181 formSuccess.stop(true).fadeOut(fadeOutSuccess); 1182 setTimeout(function () { 1183 formError.stop(true).fadeOut(fadeOutError); 1184 }, wait); 1185 }; 1186 1187 // Reset form to empty/default state. 1188 mr.forms.resetForm = function (form) { 1189 form = $(form); 1190 form.get(0).reset(); 1191 form.find('.input-radio, .input-checkbox').removeClass('checked'); 1192 form.find('[data-default-value]').filter('[type="text"],[type="number"],[type="email"],[type="url"],[type="search"],[type="tel"]').each(function () { 1193 var elem = jQuery(this); 1194 elem.val(elem.attr('data-default-value')); 1195 }); 1196 1197 }; 1198 1199 // Defined on the window scope as the recaptcha js api seems not to be able to call function in mr scope 1200 window.mrFormsCaptchaInit = function () { 1201 mr.forms.captcha.renderWidgets(); 1202 }; 1203 1204 mr.forms.captcha.renderWidgets = function () {
1205 mr.forms.captcha.widgets.forEach(function (widget) { 1206 if (widget.element.innerHTML === '') { 1207 widget.id = grecaptcha.render(widget.element, { 1208 'sitekey': mr.forms.captcha.sitekey, 1209 'theme': widget.theme, 1210 'size': widget.size, 1211 'callback': mr.forms.captcha.setHuman 1212 }); 1213 widget.parentForm.data('recaptchaWidgetID', widget.id); 1214 } 1215 }); 1216 }; 1217 1218 mr.forms.captcha.resetWidgets = function () { 1219 mr.forms.captcha.widgets.forEach(function (widget) { 1220 grecaptcha.reset(widget.id); 1221 }); 1222 }; 1223 1224 mr.forms.captcha.setHuman = function () { 1225 jQuery('div.recaptcha.field-error').removeClass('field-error'); 1226 }; 1227 1228 mr.components.documentReadyDeferred.push(mr.forms.documentReady); 1229 return mr; 1230 1231}(mr, jQuery, window, document)); 1232 1233//////////////// Granim 1234mr = (function (mr, $, window, document) { 1235 "use strict"; 1236 1237 mr.granim = mr.granim || {}; 1238 1239 mr.granim.documentReady = function ($) { 1240 $('[data-gradient-bg]').each(function (index, element) { 1241 var granimParent = $(this), 1242 granimID = 'granim-' + index + '', 1243 colours = granimParent.attr('data-gradient-bg'), 1244 pairs = [], 1245 tempPair = [], 1246 ao = {}, 1247 count, 1248 passes, 1249 i, 1250 themeDefaults, 1251 1252 options; 1253 1254 // Canvas element forms the gradient background 1255 granimParent.prepend('<canvas id="' + granimID + '"></canvas>'); 1256 1257 // Regular expression to match comma separated list of hex colour values 1258 passes = /^(#[0-9|a-f|A-F]{6}){1}([ ]*,[ ]*#[0-9|a-f|A-F]{6})*$/.test(colours); 1259 1260 if (passes === true) { 1261 colours = colours.replace(' ', ''); 1262 colours = colours.split(','); 1263 count = colours.length; 1264 // If number of colours is odd - duplicate last colour to make even array 1265 if (count % 2 !== 0) { 1266 colours.push(colours[count - 1]); 1267 } 1268 for (i = 0; i < (count / 2); i++) { 1269 tempPair = []; 1270 tempPair.push(colours.shift()); 1271 tempPair.push(colours.shift()); 1272 pairs.push(tempPair); 1273 } 1274 1275 // attribute overrides - allows per-gradient override of global options. 1276 ao.states = { 1277 "default-state": { 1278 gradients: pairs 1279 } 1280 } 1281 } 1282 1283 themeDefaults = { 1284 element: '#' + granimID, 1285 name: 'basic-gradient', 1286 direction: 'left-right', 1287 opacity: [1, 1], 1288 isPausedWhenNotInView: true, 1289 states: { 1290 "default-state": { 1291 gradients: pairs 1292 } 1293 } 1294 }; 1295 1296 options = jQuery.extend({}, themeDefaults, mr.granim.options, ao); 1297 $(this).data('gradientOptions', options); 1298 var granimElement = $(this); 1299 var granimInstance = new Granim(options); 1300 }); 1301 }; 1302 1303 mr.components.documentReadyDeferred.push(mr.granim.documentReady); 1304 return mr; 1305 1306}(mr, jQuery, window, document)); 1307 1308//////////////// Instagram 1309mr = (function (mr, $, window, document) { 1310 "use strict"; 1311 1312 mr.instagram = mr.instagram || {}; 1313 1314 mr.instagram.documentReady = function ($) { 1315 1316 var themeDefaults, options, ao = {}; 1317 1318 if ($('.instafeed').length) { 1319 1320 // Replace with your own Access Token and Client ID 1321 var token = '4079540202.b9b1d8a.1d13c245c68d4a17bfbff87919aaeb14', 1322 client = 'b9b1d8ae049d4153b24a6332f0088686', 1323 elementToken, elementClient; 1324 1325 if ($('.instafeed[data-access-token][data-client-id]').length) { 1326 elementToken = $('.instafeed[data-access-token][data-client-id]').first().attr('data-access-token'); 1327 elementClient = $('.instafeed[data-access-token][data-client-id]').first().attr('data-client-id'); 1328 1329 if (elementToken !== "") { token = elementToken; } 1330 if (elementClient !== "") { client = elementClient; } 1331 } 1332 1333 jQuery.fn.spectragram.accessData = { 1334 accessToken: token, 1335 clientID: client 1336 }; 1337 } 1338 1339 $('.instafeed').each(function () { 1340 var feed = $(this), 1341 feedID = feed.attr('data-user-name'), 1342 fetchNumber = 12; 1343 1344 themeDefaults = { 1345 query: 'mediumrarethemes', 1346 max: 12 1347 }; 1348 1349 // Attribute Overrides taken from data attributes allow for per-feed customization 1350 ao.max = feed.attr('data-amount') 1351 ao.query = feed.attr('data-user-name'); 1352 1353 options = jQuery.extend({}, themeDefaults, mr.instagram.options, ao); 1354 1355 feed.append('<ul></ul>'); 1356 feed.children('ul').spectragram('getUserFeed', options); 1357 }); 1358 }; 1359 1360 mr.components.documentReadyDeferred.push(mr.instagram.documentReady); 1361 return mr; 1362 1363}(mr, jQuery, window, document)); 1364
1365//////////////// Maps 1366mr = (function (mr, $, window, document) { 1367 "use strict"; 1368 1369 mr.maps = mr.maps || {}; 1370 mr.maps.options = mr.maps.options || {}; 1371 1372 mr.maps.documentReady = function ($) { 1373 // Interact with Map once the user has clicked (to prevent scrolling the page = zooming the map 1374 1375 $('.map-holder').on('click', function () { 1376 $(this).addClass('interact'); 1377 }).removeClass('interact'); 1378 1379 var mapsOnPage = $('.map-container[data-maps-api-key]'); 1380 if (mapsOnPage.length) { 1381 mapsOnPage.addClass('gmaps-active'); 1382 mr.maps.initAPI($); 1383 mr.maps.init(); 1384 } 1385 1386 }; 1387 1388 mr.maps.initAPI = function ($) { 1389 // Load Google MAP API JS with callback to initialise when fully loaded 1390 if (document.querySelector('[data-maps-api-key]') && !document.querySelector('.gMapsAPI')) { 1391 if ($('[data-maps-api-key]').length) { 1392 var script = document.createElement('script'); 1393 var apiKey = $('[data-maps-api-key]:first').attr('data-maps-api-key'); 1394 apiKey = typeof apiKey !== typeof undefined ? apiKey : ''; 1395 if (apiKey !== '') { 1396 script.type = 'text/javascript'; 1397 script.src = 'https://maps.googleapis.com/maps/api/js?key=' + apiKey + '&callback=mr.maps.init'; 1398 script.className = 'gMapsAPI'; 1399 document.body.appendChild(script); 1400 } 1401 } 1402 } 1403 }; 1404 1405 mr.maps.init = function () { 1406 if (typeof window.google !== "undefined") { 1407 if (typeof window.google.maps !== "undefined") { 1408 1409 mr.maps.instances = []; 1410 1411 1412 jQuery('.gmaps-active').each(function () { 1413 var mapElement = this, 1414 mapInstance = jQuery(this), 1415 isDraggable = jQuery(document).width() > 766 ? true : false, 1416 showZoomControl = typeof mapInstance.attr('data-zoom-controls') !== typeof undefined ? true : false, 1417 zoomControlPos = typeof mapInstance.attr('data-zoom-controls') !== typeof undefined ? mapInstance.attr('data-zoom-controls') : false, 1418 latlong = typeof mapInstance.attr('data-latlong') !== typeof undefined ? mapInstance.attr('data-latlong') : false, 1419 latitude = latlong ? 1 * latlong.substr(0, latlong.indexOf(',')) : false, 1420 longitude = latlong ? 1 * latlong.substr(latlong.indexOf(",") + 1) : false, 1421 geocoder = new google.maps.Geocoder(), 1422 address = typeof mapInstance.attr('data-address') !== typeof undefined ? mapInstance.attr('data-address').split(';') : [""], 1423 map, marker, markerDefaults, mapDefaults, mapOptions, markerOptions, mapAo = {}, markerAo = {}, mapCreatedEvent; 1424 1425 mapCreatedEvent = document.createEvent('Event'); 1426 mapCreatedEvent.initEvent('mapCreated.maps.mr', true, true); 1427 1428 1429 1430 1431 mapDefaults = { 1432 disableDefaultUI: true, 1433 draggable: isDraggable, 1434 scrollwheel: false, 1435 styles: [{ "featureType": "landscape", "stylers": [{ "saturation": -100 }, { "lightness": 65 }, { "visibility": "on" }] }, { "featureType": "poi", "stylers": [{ "saturation": -100 }, { "lightness": 51 }, { "visibility": "simplified" }] }, { "featureType": "road.highway", "stylers": [{ "saturation": -100 }, { "visibility": "simplified" }] }, { "featureType": "road.arterial", "stylers": [{ "saturation": -100 }, { "lightness": 30 }, { "visibility": "on" }] }, { "featureType": "road.local", "stylers": [{ "saturation": -100 }, { "lightness": 40 }, { "visibility": "on" }] }, { "featureType": "transit", "stylers": [{ "saturation": -100 }, { "visibility": "simplified" }] }, { "featureType": "administrative.province", "stylers": [{ "visibility": "off" }] }, { "featureType": "water", "elementType": "labels", "stylers": [{ "visibility": "on" }, { "lightness": -25 }, { "saturation": -100 }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "hue": "#ffff00" }, { "lightness": -25 }, { "saturation": -97 }] }], 1436 zoom: 17, 1437 zoomControl: false, 1438 }; 1439 1440 // Attribute overrides - allows data attributes on the map to override global options 1441 mapAo.styles = typeof mapInstance.attr('data-map-style') !== typeof undefined ? JSON.parse(mapInstance.attr('data-map-style')) : undefined; 1442 mapAo.zoom = mapInstance.attr('data-map-zoom'); 1443 mapAo.zoomControlOptions = zoomControlPos !== false ? { position: google.maps.ControlPosition[zoomControlPos] } : undefined, 1444 1445 markerDefaults = { 1446 icon: { url: (typeof mr_variant !== typeof undefined ? '../' : '') + 'img/mapmarker.png', scaledSize: new google.maps.Size(50, 50) }, 1447 title: 'We Are Here',
1448 optimised: false 1449 }; 1450 1451 markerAo.icon = typeof mapInstance.attr('data-marker-image') !== typeof undefined ? mapInstance.attr('data-marker-image') : undefined, 1452 markerAo.title = mapInstance.attr('data-marker-title'); 1453 1454 mapOptions = jQuery.extend({}, mapDefaults, mr.maps.options.map, mapAo); 1455 markerOptions = jQuery.extend({}, markerDefaults, mr.maps.options.marker, markerAo); 1456 1457 1458 if (address !== undefined && address[0] !== "") { 1459 geocoder.geocode({ 'address': address[0].replace('[nomarker]', '') }, function (results, status) { 1460 if (status === google.maps.GeocoderStatus.OK) { 1461 map = new google.maps.Map(mapElement, mapOptions); 1462 1463 1464 mr.maps.instances.push(map); 1465 jQuery(mapElement).trigger('mapCreated.maps.mr').get(0).dispatchEvent(mapCreatedEvent); 1466 map.setCenter(results[0].geometry.location); 1467 1468 address.forEach(function (address) { 1469 var markerGeoCoder; 1470 1471 if (/(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)/.test(address)) { 1472 var latlong = address.split(','), 1473 marker = new google.maps.Marker(jQuery.extend({}, markerOptions, { 1474 position: { lat: 1 * latlong[0], lng: 1 * latlong[1] }, 1475 map: map, 1476 })); 1477 } 1478 else if (address.indexOf('[n
1478omarker]') < 0) { 1479 markerGeoCoder = new google.maps.Geocoder(); 1480 markerGeoCoder.geocode({ 'address': address.replace('[nomarker]', '') }, function (results, status) { 1481 if (status === google.maps.GeocoderStatus.OK) { 1482 marker = new google.maps.Marker(jQuery.extend({}, markerOptions, { 1483 map: map, 1484 position: results[0].geometry.location, 1485 })); 1486 } 1487 else { 1488 console.log('Map marker error: ' + status); 1489 } 1490 }); 1491 } 1492 1493 }); 1494 } else { 1495 console.log('There was a problem geocoding the address.'); 1496 } 1497 }); 1498 } 1499 else if (typeof latitude !== typeof undefined && latitude !== "" && latitude !== false && typeof longitude !== typeof undefined && longitude !== "" && longitude !== false) { 1500 1501 mapOptions.center = { lat: latitude, lng: longitude }; 1502 map = new google.maps.Map(mapElement, mapOptions); 1503 marker = new google.maps.Marker(jQuery.extend({}, markerOptions, { 1504 position: { lat: latitude, lng: longitude }, 1505 map: map 1506 })); 1507 mr.maps.instances.push(map); 1508 jQuery(mapElement).trigger('mapCreated.maps.mr').get(0).dispatchEvent(mapCreatedEvent); 1509 1510 1511 } 1512 1513 1514 1515 }); 1516 } 1517 } 1518 }; 1519 1520 mr.components.documentReady.push(mr.maps.documentReady); 1521 return mr; 1522 1523}(mr, jQuery, window, document)); 1524 1525 1526//////////////// Masonry 1527mr = (function (mr, $, window, document) { 1528 "use strict"; 1529 1530 mr.masonry = mr.masonry || {}; 1531 1532 mr.masonry.documentReady = function ($) { 1533 1534 mr.masonry.updateFilters(); 1535 1536 $(document).on('click touchstart', '.masonry__filters li:not(.js-no-action)', function () { 1537 var masonryFilter = $(this); 1538 var masonryContainer = masonryFilter.closest('.masonry').find('.masonry__container'); 1539 var filterValue = '*'; 1540 if (masonryFilter.attr('data-masonry-filter') !== '*') { 1541 filterValue = '.filter-' + masonryFilter.attr('data-masonry-filter'); 1542 } 1543 masonryFilter.siblings('li').removeClass('active'); 1544 masonryFilter.addClass('active'); 1545 masonryContainer.removeClass('masonry--animate'); 1546 masonryContainer.on('layoutComplete', function () { 1547 $(this).addClass('masonry--active'); 1548 if (typeof mr_parallax !== typeof undefined) { 1549 setTimeout(function () { mr_parallax.profileParallaxElements(); }, 100); 1550 } 1551 }); 1552 masonryContainer.isotope({ filter: filterValue }); 1553 1554 }); 1555 1556 }; 1557 1558 mr.masonry.windowLoad = function () { 1559 1560 $('.masonry').each(function () { 1561 var masonry = $(this).find('.masonry__container'), 1562 masonryParent = $(this), 1563 defaultFilter = '*', 1564 themeDefaults, ao = {}; 1565 1566 themeDefaults = { 1567 itemSelector: '.masonry__item', 1568 filter: '*', 1569 masonry: { 1570 columnWidth: '.masonry__item' 1571 } 1572 }; 1573 1574 // Check for a default filter attribute 1575 if (masonryParent.is('[data-default-filter]')) { 1576 defaultFilter = masonryParent.attr('data-default-filter').toLowerCase(); 1577 defaultFilter = '.filter-' + defaultFilter; 1578 masonryParent.find('li[data-masonry-filter]').removeClass('active'); 1579 masonryParent.find('li[data-masonry-filter="' + masonryParent.attr("data-default-filter").toLowerCase() + '"]').addClass('active'); 1580 } 1581 1582 // Use data attributes to override the default settings and provide a per-masonry customisation where necessary. 1583 ao.filter = defaultFilter !== '*' ? defaultFilter : undefined; 1584 1585 masonry.on('layoutComplete', function () { 1586 masonry.addClass('masonry--active'); 1587 if (typeof mr_parallax !== typeof undefined) { 1588 setTimeout(function () { mr_parallax.profileParallaxElements(); }, 100); 1589 } 1590 }); 1591 1592 1593 masonry.isotope(jQuery.extend({}, themeDefaults, mr.masonry.options, ao)); 1594 1595 }); 1596 }; 1597 1598 mr.masonry.updateFilters = function (masonry) { 1599 1600 // If no argument is supplied, just apply the update to all masonry sets on the page. 1601 masonry = typeof masonry !== typeof undefined ? masonry : '.masonry'; 1602 1603 var $masonry = $(masonry); 1604 1605 $masonry.each(function () { 1606 var $masonry = $(this), 1607 masonryContainer = $masonry.find('.masonry__container'), 1608 filters = $masonry.find('.masonry__filters'), 1609 // data-filter-all-text can be used to set the word for "all" 1610 filterAllText = typeof filters.attr('data-filter-all-text') !== typeof undefined ? filters.attr('data-filter-all-text') : "All", 1611 filtersList; 1612 1613 // Ensure we are working with a .masonry element 1614 if ($masonry.is('.masonry')) { 1615 // If a filterable masonry item exists 1616 if (masonryContainer.find('.masonry__item[data-masonry-filter]').length) { 1617 1618 // Create empty ul for filters 1619 filtersList = filters.find('> ul'); 1620 1621 if (!filtersList.length) { 1622 filtersList = filters.append('<ul></ul>').find('> ul'); 1623 } 1624 1625 // To avoid cases where user leave filter attribute blank 1626 // only take items that have filter attribute 1627 masonryContainer.find('.masonry__item[data-masonry-filter]').each(function () { 1628 var masonryItem = $(this), 1629 filterString = masonryItem.attr('data-masonry-filter'), 1630 filtersArray = []; 1631 1632 // If not undefined or empty 1633 if (typeof filterString !== typeof undefined && filterString !== "") { 1634 // Split tags from string into array 1635 filtersArray = filterString.split(','); 1636 } 1637 jQuery(filtersArray).each(function (index, tag) { 1638 1639 // Slugify the tag 1640 1641 var slug = mr.util.slugify(tag); 1642 1643 // Add the filter class to the masonry item 1644 1645 masonryItem.addClass('filter-' + slug); 1646 1647 // If this tag does not appear in the list already, add it 1648 if (!filtersList.find('[data-masonry-filter="' + slug + '"]').length) { 1649 filtersList.append('<li data-masonry-filter="' + slug + '">' + tag + '</li>'); 1650 1651 } 1652 }); 1653 }); 1654 1655 mr.util.sortChildrenByText($(this).find('.masonry__filters ul')); 1656 // Add a filter "all" option 1657 if (!filtersList.find('[data-masonry-filter="*"]').length) { 1658 filtersList.prepend('<li class="active" data-masonry-filter="*">' + filterAllText + '</li>'); 1659 } 1660 1661 } 1662 //End of "if filterable masonry item exists" 1663 } 1664 //End of "if $masonry is .masonry" 1665 }); 1666 1667 }; 1668 1669 mr.masonry.updateLayout = function (masonry) { 1670 1671 // If no argument is supplied, just apply the update to all masonry sets on the page. 1672 masonry = typeof masonry !== typeof undefined ? masonry : '.masonry'; 1673 1674 var $masonry = $(masonry); 1675 1676 1677 $masonry.each(function () { 1678 var collection = $(this), 1679 newItems = collection.find('.masonry__item:not([style])'), 1680 masonryContainer = collection.find('.masonry__container'); 1681 1682 if (collection.is('.masonry')) { 1683 if (newItems.length) { 1684 masonryContainer.isotope('appended', newItems).isotope('layout'); 1685 } 1686 1687 masonryContainer.isotope('layout'); 1688 } 1689 }); 1690 }; 1691 1692 mr.components.documentReady.push(mr.masonry.documentReady); 1693 mr.components.windowLoad.push(mr.masonry.windowLoad); 1694 return mr; 1695 1696}(mr, jQuery, window, document)); 1697 1698 1699//////////////// Modals 1700mr = (function (mr, $, window, document) { 1701 "use strict"; 1702 1703 mr.modals = mr.modals || {}; 1704 1705 mr.modals.documentReady = function ($) { 1706 var allPageModals = "<div class=\"all-page-modals\"></div>", 1707 mainContainer = $('div.main-container'); 1708 1709 if (mainContainer.length) { 1710 jQuery(allPageModals).insertAfter(mainContainer); 1711 mr.modals.allModalsContainer = $('div.all-page-modals'); 1712 } 1713 else { 1714 jQuery('body').append(allPageModals); 1715 mr.modals.allModalsContainer = jQuery('body div.all-page-modals'); 1716 } 1717 1718 $('.modal-container').each(function () { 1719 1720 // Add modal close if none exists 1721 1722 var modal = $(this), 1723 $window = $(window),
1724 modalContent = modal.find('.modal-content'); 1725 1726 1727 if (!modal.find('.modal-close').length) { 1728 modal.find('.modal-content').append('<div class="modal-close modal-close-cross"></div>'); 1729 } 1730 1731 // Set modal height 1732 1733 if (modalContent.attr('data-width') !== undefined) { 1734 var modalWidth = modalContent.attr('data-width').substr(0, modalContent.attr('data-width').indexOf('%')) * 1; 1735 modalContent.css('width', modalWidth + '%'); 1736 } 1737 if (modalContent.attr('data-height') !== undefined) { 1738 var modalHeight = modalContent.attr('data-height').substr(0, modalContent.attr('data-height').indexOf('%')) * 1; 1739 modalContent.css('height', modalHeight + '%'); 1740 } 1741 1742 // Set iframe's src to data-src to stop autoplaying iframes 1743 mr.util.idleSrc(modal, 'iframe'); 1744 1745 }); 1746 1747 1748 $('.modal-instance').each(function (index) { 1749 var modalInstance = $(this); 1750 var modal = modalInstance.find('.modal-container'); 1751 var modalContent = modalInstance.find('.modal-content'); 1752 var trigger = modalInstance.find('.modal-trigger'); 1753 1754 // Link modal with modal-id attribute 1755 1756 trigger.attr('data-modal-index', index); 1757 modal.attr('data-modal-index', index); 1758 // Set unique id for multiple triggers 1759 1760 if (typeof modal.attr('data-modal-id') !== typeof undefined) { 1761 trigger.attr('data-modal-id', modal.attr('data-modal-id')); 1762 } 1763 1764 1765 // Attach the modal to the body 1766 modal = modal.detach(); 1767 mr.modals.allModalsContainer.append(modal); 1768 }); 1769 1770 $(document).on('click', 'a.modal-trigger', function (e) { 1771 1772 console.log("e", e); 1773 1774 var modalTrigger = $(this); 1775 var uniqueID, targetModal; 1776 // Determine if the modal id is set by user or is set programatically 1777 1778 if (typeof modalTrigger.attr('data-modal-id') !== typeof undefined) { 1779 uniqueID = modalTrigger.attr('data-modal-id'); 1780 targetModal = mr.modals.allModalsContainer.find('.modal-container[data-modal-id="' + uniqueID + '"]'); 1781 } else { 1782 uniqueID = $(this).attr('data-modal-index'); 1783 targetModal = mr.modals.allModalsContainer.find('.modal-container[data-modal-index="' + uniqueID + '"]'); 1784 } 1785 1786 mr.util.activateIdleSrc(targetModal, 'iframe'); 1787 mr.modals.autoplayVideo(targetModal); 1788 1789 mr.modals.showModal(targetModal); 1790 1791 return false; 1792 }); 1793 1794 jQuery(document).on('click', '.modal-close', mr.modals.closeActiveModal); 1795 1796 jQuery(document).keyup(function (e) { 1797 if (e.keyCode === 27) { // escape key maps to keycode `27` 1798 mr.modals.closeActiveModal(); 1799 } 1800 }); 1801 1802 $('.modal-container').on('click', function (e) { 1803 if (e.target !== this) return; 1804 mr.modals.closeActiveModal(); 1805 }); 1806 1807 // Trigger autoshow modals 1808 $('.modal-container[data-autoshow]').each(function () { 1809 var modal = $(this); 1810 var millisecondsDelay = modal.attr('data-autoshow') * 1; 1811 1812 mr.util.activateIdleSrc(modal); 1813 mr.modals.autoplayVideo(modal); 1814 1815 // If this modal has a cookie attribute, check to see if a cookie is set, and if so, don't show it. 1816 if (typeof modal.attr('data-cookie') !== typeof undefined) { 1817 if (!mr.cookies.hasItem(modal.attr('data-cookie'))) { 1818 mr.modals.showModal(modal, millisecondsDelay); 1819 } 1820 } else { 1821 mr.modals.showModal(modal, millisecondsDelay); 1822 } 1823 }); 1824 1825 // Exit modals 1826 $('.modal-container[data-show-on-exit]').each(function () { 1827 var modal = jQuery(this), 1828 exitSelector = modal.attr('data-show-on-exit'),
1829 delay = 0; 1830 1831 if (modal.attr('data-delay')) { 1832 delay = parseInt(modal.attr('data-delay'), 10) || 0; 1833 } 1834 1835 // If a valid selector is found, attach leave event to show modal. 1836 if ($(exitSelector).length) { 1837 modal.prepend($('<i class="ti-close close-modal">')); 1838 jQuery(document).on('mouseleave', exitSelector, function () { 1839 if (!$('.modal-active').length) { 1840 if (typeof modal.attr('data-cookie') !== typeof undefined) { 1841 if (!mr.cookies.hasItem(modal.attr('data-cookie'))) { 1842 mr.modals.showModal(modal, delay); 1843 } 1844 } else { 1845 mr.modals.showModal(modal, delay); 1846 } 1847 } 1848 }); 1849 } 1850 }); 1851 1852 1853 // Autoshow modal by ID from location href 1854 if (window.location.href.split('#').length === 2) { 1855 var modalID = window.location.href.split('#').pop(); 1856 if ($('[data-modal-id="' + modalID + '"]').length) { 1857 mr.modals.closeActiveModal(); 1858 mr.modals.showModal($('[data-modal-id="' + modalID + '"]')); 1859 } 1860 } 1861 1862 jQuery(document).on('click', 'a[href^="#"]', function () { 1863 var modalID = $(this).attr('href').replace('#', ''); 1864 mr.modals.closeActiveModal(); 1865 setTimeout(mr.modals.showModal, 500, '[data-modal-id="' + modalID + '"]', 0); 1866 }); 1867 1868 // Make modal scrollable 1869 jQuery(document).on('wheel mousewheel scroll', '.modal-content, .modal-content .scrollable', function (evt) { 1870 if (evt.preventDefault) { evt.preventDefault(); } 1871 if (evt.stopPropagation) { evt.stopPropagation(); } 1872 this.scrollTop += (evt.originalEvent.deltaY); 1873 }); 1874 }; 1875 //////////////// 1876 //////////////// End documentReady 1877 //////////////// 1878 1879 mr.modals.showModal = function (modal, millisecondsDelay) { 1880 1881 var delay = (typeof millisecondsDelay !== typeof undefined) ? (1 * millisecondsDelay) : 0, $modal = $(modal); 1882 1883 if ($modal.length) { 1884 setTimeout(function () { 1885 var openEvent = document.createEvent('Event'); 1886 openEvent.initEvent('modalOpened.modals.mr', true, true); 1887 $(modal).addClass('modal-active').trigger('modalOpened.modals.mr').get(0).dispatchEvent(openEvent); 1888 1889 }, delay); 1890 } 1891 }; 1892 1893 mr.modals.closeActiveModal = function () { 1894 var modal = jQuery('body div.modal-active'), 1895 closeEvent = document.createEvent('Event'); 1896 1897 mr.util.idleSrc(modal, 'iframe'); 1898 mr.util.pauseVideo(modal); 1899 1900 // If this modal requires to be closed permanently using a cookie, set the cookie now. 1901 if (typeof modal.attr('data-cookie') !== typeof undefined) { 1902 mr.cookies.setItem(modal.attr('data-cookie'), "true", Infinity, '/'); 1903 } 1904 1905 if (modal.length) { 1906 // Remove hash from URL bar if this modal was opened via url bar ID 1907 if (modal.is('[data-modal-id]') && window.location.hash === '#' + modal.attr('data-modal-id')) { 1908 mr.util.removeHash(); 1909 } 1910 closeEvent.initEvent('modalClosed.modals.mr', true, true); 1911 modal.removeClass('modal-active').trigger('modalClosed.modals.mr').get(0).dispatchEvent(closeEvent); 1912 } 1913 }; 1914 1915 mr.modals.autoplayVideo = function (modal) { 1916 // If modal contains HTML5 video with autoplay, play the video 1917 if (modal.find('video[autoplay]').length) { 1918 var video = modal.find('video').get(0); 1919 video.play(); 1920 } 1921 }; 1922 1923 mr.components.documentReady.push(mr.modals.documentReady); 1924 return mr; 1925 1926}(mr, jQuery, window, document)); 1927 1928//////////////// Newsletter Providers 1929mr = (function (mr, $, window, document) { 1930 "use strict"; 1931 1932 mr.newsletters = mr.newsletters || {}; 1933 1934 mr.newsletters.documentReady = function ($) { 1935 1936 var form, checkbox, label, id, parent, radio; 1937 1938 // Treat Campaign Monitor forms 1939 $('form[action*="createsend.com"]').each(function () { 1940 form = $(this); 1941 1942 // Override browser validation and allow us to use our own 1943 form.attr('novalidate', 'novalidate'); 1944 1945 // Give each text input a placeholder value 1946 1947 if (!form.is('.form--no-placeholders')) {
1948 form.find('input:not([checkbox]):not([radio])').each(function () { 1949 var $input = $(this); 1950 if (typeof $input.attr('placeholder') !== typeof undefined) { 1951 if ($input.attr('placeholder') === "") { 1952 if ($input.siblings('label').length) { 1953 $input.attr('placeholder', $input.siblings('label').first().text()); 1954 if (form.is('.form--no-labels')) { 1955 $input.siblings('label').first().remove(); 1956 } 1957 } 1958 } 1959 } else if ($input.siblings('label').length) { 1960 $input.attr('placeholder', $input.siblings('label').first().text()); 1961 if (form.is('.form--no-labels')) { 1962 $input.siblings('label').first().remove(); 1963 } 1964 } 1965 if ($input.parent().is('p')) { 1966 $input.unwrap(); 1967 } 1968 }); 1969 } else { 1970 form.find('input[placeholder]').removeAttr('placeholder'); 1971 } 1972 1973 1974 // Wrap select elements in template code 1975 1976 form.find('select').wrap('<div class="input-select"></div>'); 1977 1978 // Wrap radios elements in template code 1979 1980 form.find('input[type="radio"]').wrap('<div class="input-radio"></div>'); 1981 1982 // Wrap checkbox elements in template code 1983 1984 form.find('input[type="checkbox"]').each(function () { 1985 checkbox = $(this); 1986 id = checkbox.attr('id'); 1987 label = form.find('label[for=' + id + ']'); 1988 if (!label.length) { 1989 label = $('<label for="' + id + '"></label>'); 1990 } 1991 1992 checkbox.before('<div class="input-checkbox" data-id="' + id + '"></div>'); 1993 $('.input-checkbox[data-id="' + id + '"]').prepend(checkbox); 1994 $('.input-checkbox[data-id="' + id + '"]').prepend(label); 1995 }); 1996 1997 form.find('button[type="submit"]').each(function () { 1998 var button = $(this); 1999 button.addClass('btn'); 2000 if (button.parent().is('p')) { 2001 button.unwrap(); 2002 } 2003 }); 2004 2005 form.find('[required]').attr('required', 'required').addClass('validate-required'); 2006 2007 form.addClass('form--active'); 2008 2009 mr.newsletters.prepareAjaxAction(form); 2010 2011 2012 }); 2013 2014 // Treat MailChimp forms 2015 $('form[action*="list-manage.com"]').each(function () { 2016 form = $(this); 2017 2018 // Override browser validation and allow us to use our own 2019 form.attr('novalidate', 'novalidate'); 2020 2021 // Give each text input a placeholder value 2022 if (!form.is('.form--no-placeholders')) { 2023 form.find('input:not([checkbox]):not([radio])').each(function () { 2024 var $input = $(this); 2025 if (typeof $input.attr('placeholder') !== typeof undefined) { 2026 if ($input.attr('placeholder') === "") { 2027 if ($input.siblings('label').length) { 2028 $input.attr('placeholder', $input.siblings('label').first().text()); 2029 if (form.is('.form--no-labels')) { 2030 $input.siblings('label').first().remove(); 2031 } 2032 } 2033 } 2034 } else if ($input.siblings('label').length) { 2035 $input.attr('placeholder', $input.siblings('label').first().text()); 2036 if (form.is('.form--no-labels')) { 2037 $input.siblings('label').first().remove(); 2038 } 2039 } 2040 }); 2041 } else { 2042 form.find('input[placeholder]').removeAttr('placeholder'); 2043 } 2044 2045 if (form.is('.form--no-labels')) {
2046 form.find('input:not([checkbox]):not([radio])').each(function () { 2047 var $input = $(this); 2048 if ($input.siblings('label').length) { 2049 $input.siblings('label').first().remove(); 2050 } 2051 }); 2052 } 2053 2054 // Wrap select elements in template code 2055 2056 form.find('select').wrap('<div class="input-select"></div>'); 2057 2058 // Wrap checboxes elements in template code 2059 2060 form.find('input[type="checkbox"]').each(function () { 2061 checkbox = jQuery(this); 2062 parent = checkbox.parent(); 2063 label = parent.find('label'); 2064 if (!label.length) { 2065 label = jQuery('<label>'); 2066 } 2067 checkbox.before('<div class="input-checkbox"></div>'); 2068 parent.find('.input-checkbox').append(checkbox); 2069 parent.find('.input-checkbox').append(label); 2070 }); 2071 2072 // Wrap radio elements in template code 2073 2074 form.find('input[type="radio"]').each(function () { 2075 radio = jQuery(this); 2076 parent = radio.closest('li'); 2077 label = parent.find('label'); 2078 if (!label.length) { 2079 label = jQuery('<label>'); 2080 } 2081 radio.before('<div class="input-radio"></div>'); 2082 parent.find('.input-radio').prepend(radio); 2083 parent.find('.input-radio').prepend(label); 2084 }); 2085 2086 // Convert MailChimp input[type="submit"] to div.button 2087 2088 form.find('input[type="submit"]').each(function () { 2089 var submit = $(this); 2090 2091 var newButton = jQuery('<button/>').attr('type', 'submit').attr('class', submit.attr('class')).addClass('btn').text(submit.attr('value')); 2092 2093 if (submit.parent().is('div.clear')) { 2094 submit.unwrap(); 2095 } 2096 2097 newButton.insertBefore(submit); 2098 submit.remove(); 2099 }); 2100 2101 form.find('input').each(function () { 2102 var input = $(this); 2103 if (input.hasClass('required')) { 2104 input.removeClass('required').addClass('validate-required'); 2105 } 2106 }); 2107 2108 form.find('input[type="email"]').removeClass('email').addClass('validate-email'); 2109 2110 form.find('#mce-responses').remove(); 2111 2112 form.find('.mc-field-group').each(function () { 2113 $(this).children().first().unwrap(); 2114 }); 2115 2116 form.find('[required]').attr('required', 'required').addClass('validate-required'); 2117 2118 form.addClass('form--active'); 2119 2120 mr.newsletters.prepareAjaxAction(form); 2121 2122 }); 2123 2124 // Reinitialize the forms so interactions work as they should 2125 2126 mr.forms.documentReady(mr.setContext('form.form--active')); 2127 2128 }; 2129 2130 mr.newsletters.prepareAjaxAction = function (form) { 2131 var action = $(form).attr('action'); 2132 2133 // Alter action for a Mail Chimp-compatible ajax request url. 2134 if (/list-manage\.com/.test(action)) { 2135 action = action.replace('/post?', '/post-json?') + "&c=?"; 2136 if (action.substr(0, 2) === "//") { 2137 action = 'http:' + action; 2138 } 2139 } 2140 2141 // Alter action for a Campaign Monitor-compatible ajax request url. 2142 if (/createsend\.com/.test(action)) { 2143 action = action + '?callback=?'; 2144 } 2145 2146 // Set action on the form 2147 $(form).attr('action', action); 2148 2149 }; 2150 2151 2152 2153 mr.components.documentReady.push(mr.newsletters.documentReady); 2154 return mr; 2155 2156}(mr, jQuery, window, document)); 2157 2158//////////////// Notifications 2159mr = (function (mr, $, window, document) { 2160 "use strict"; 2161 2162 mr.notifications = mr.notifications || {}; 2163 2164 mr.notifications.documentReady = function ($) { 2165 2166 $('.notification').each(function () { 2167 var notification = $(this); 2168 if (!notification.find('.notification-close').length) { 2169 notification.append('<div class="notification-close-cross notification-close"></div>'); 2170 } 2171 }); 2172 2173 2174 $('.notification[data-autoshow]').each(function () { 2175 var notification = $(this); 2176 var millisecondsDelay = parseInt(notification.attr('data-autoshow'), 10); 2177 2178 // If this notification has a cookie attribute, check to see if a cookie is set, and if so, don't show it. 2179 if (typeof notification.attr('data-cookie') !== typeof undefined) { 2180 if (!mr.cookies.hasItem(notification.attr('data-cookie'))) { 2181 mr.notifications.showNotification(notification, millisecondsDelay); 2182 } 2183 } else { 2184 mr.notifications.showNotification(notification, millisecondsDelay); 2185 } 2186 }); 2187 2188 $('[data-notification-link]:not(.notification)').on('click', function () { 2189 var notificationID = jQuery(this).attr('data-notification-link'); 2190 var notification = $('.notification[data-notification-link="' + notificationID + '"]'); 2191 jQuery('.notification--reveal').addClass('notification--dismissed'); 2192 notification.removeClass('notification--dismissed'); 2193 mr.notifications.showNotification(notification, 0); 2194 return false; 2195 }); 2196 2197 $('.notification-close').on('click', function () { 2198 var closeButton = jQuery(this); 2199 // Pass the closeNotification function a reference to the close button 2200 mr.notifications.closeNotification(closeButton); 2201 2202 if (closeButton.attr('href') === '#') { 2203 return false; 2204 } 2205 }); 2206 2207 $('.notification .inner-link').on('click', function () { 2208 var notificationLink = jQuery(this).closest('.notification').attr('data-notification-link'); 2209 mr.notifications.closeNotification(notificationLink); 2210 }); 2211 2212 }; 2213 2214 2215 mr.notifications.showNotification = function (notification, millisecondsDelay) { 2216 var $notification = jQuery(notification),
2217 delay = (typeof millisecondsDelay !== typeof undefined) ? (1 * millisecondsDelay) : 0, 2218 openEvent = document.createEvent('Event'); 2219 2220 setTimeout(function () { 2221 openEvent.initEvent('notificationOpened.notifications.mr', true, true); 2222 $notification.addClass('notification--reveal').trigger('notificationOpened.notifications.mr').get(0).dispatchEvent(openEvent); 2223 $notification.closest('nav').addClass('notification--reveal'); 2224 if ($notification.find('input').length) { 2225 $notification.find('input').first().focus(); 2226 } 2227 2228 2229 2230 }, delay); 2231 // If notification has autohide attribute, set a timeout 2232 // for the autohide time plus the original delay time in case notification was called 2233 // on page load 2234 if (notification.is('[data-autohide]')) { 2235 var hideDelay = parseInt(notification.attr('data-autohide'), 10); 2236 setTimeout(function () { 2237 mr.notifications.closeNotification(notification); 2238 }, hideDelay + delay); 2239 } 2240 }; 2241 2242 mr.notifications.closeNotification = function (notification) { 2243 var $notification = jQuery(notification), 2244 closeEvent = document.createEvent('Event'); 2245 notification = $notification.is('.notification') ? 2246 $notification : 2247 $notification.is('.notification-close') ? 2248 $notification.closest('.notification') : 2249 $('.notification[data-notification-link="' + notification + '"]'); 2250 2251 closeEvent.initEvent('notificationClosed.notifications.mr', true, true); 2252 notification.addClass('notification--dismissed').trigger('notificationClosed.notifications.mr').get(0).dispatchEvent(closeEvent); 2253 notification.closest('nav').removeClass('notification--reveal'); 2254 2255 // If this notification requires to be closed permanently using a cookie, set the cookie now. 2256 if (typeof notification.attr('data-cookie') !== typeof undefined) { 2257 mr.cookies.setItem(notification.attr('data-cookie'), "true", Infinity, '/'); 2258 } 2259 }; 2260 2261 mr.components.documentReady.push(mr.notifications.documentReady); 2262 return mr; 2263 2264}(mr, jQuery, window, document)); 2265 2266//////////////// Parallax 2267mr = (function (mr, $, window, document) { 2268 "use strict"; 2269 2270 mr.parallax = mr.parallax || {}; 2271 2272 mr.parallax.documentReady = function ($) { 2273 2274 var $window = $(window); 2275 var windowWidth = $window.width(); 2276 var windowHeight = $window.height(); 2277 var navHeight = $('nav').outerHeight(true); 2278 2279 if (windowWidth > 768) { 2280 var parallaxHero = $('.parallax:nth-of-type(1)'), 2281 parallaxHeroImage = $('.parallax:nth-of-type(1) .background-image-holder'); 2282 2283 parallaxHeroImage.css('top', -(navHeight)); 2284 if (parallaxHero.outerHeight(true) === windowHeight) { 2285 parallaxHeroImage.css('height', windowHeight + navHeight); 2286 } 2287 } 2288 }; 2289 2290 mr.parallax.update = function () { 2291 if (typeof mr_parallax !== typeof undefined) { 2292 mr_parallax.profileParallaxElements(); 2293 mr_parallax.mr_parallaxBackground(); 2294 } 2295 }; 2296 2297 mr.components.documentReady.push(mr.parallax.documentReady); 2298 return mr; 2299 2300}(mr, jQuery, window, document)); 2301 2302//////////////// Progress Horizontal (bars) 2303mr = (function (mr, $, window, document) { 2304 "use strict"; 2305 2306 mr.progressHorizontal = mr.progressHorizontal || {}; 2307 2308 mr.progressHorizontal.documentReady = function ($) { 2309 2310 var progressBars = []; 2311 2312 $('.progress-horizontal').each(function () { 2313 var bar = jQuery(this).find('.progress-horizontal__bar'), 2314 barObject = {}, 2315 progress = jQuery('<div class="progress-horizontal__progress"></div>'); 2316 2317 bar.prepend(progress); 2318 2319 barObject.element = bar; 2320 barObject.progress = progress; 2321 barObject.value = parseInt(bar.attr('data-value'), 10) + "%"; 2322 barObject.offsetTop = bar.offset().top; 2323 barObject.animate = false; 2324 2325 if (jQuery(this).hasClass('progress-horizontal--animate')) { 2326 barObject.animate = true; 2327 } else { 2328 progress.css('width', barObject.value); 2329 } 2330 progressBars.push(barObject); 2331 }); 2332 }; 2333 2334 mr.components.documentReady.push(mr.progressHorizontal.documentReady); 2335 return mr; 2336 2337}(mr, jQuery, window, document)); 2338
2339//////////////// EasyPiecharts 2340mr = (function (mr, $, window, document) { 2341 "use strict"; 2342 2343 mr.easypiecharts = mr.easypiecharts || {}; 2344 mr.easypiecharts.pies = []; 2345 mr.easypiecharts.options = mr.easypiecharts.options || {}; 2346 2347 mr.easypiecharts.documentReady = function ($) { 2348 2349 $('.radial').each(function () { 2350 var chart = jQuery(this), 2351 value = 0, 2352 color = '#000000', 2353 time = 2000, 2354 pieSize = 110, 2355 barWidth = 3, 2356 defaults = {}, 2357 attributeOverrides = {}, 2358 options; 2359 2360 defaults = { 2361 animate: ({ duration: time, enabled: true }), 2362 barColor: color, 2363 scaleColor: false, 2364 size: pieSize, 2365 lineWidth: barWidth 2366 }; 2367 2368 if (typeof mr.easypiecharts.options.size !== typeof undefined) { 2369 pieSize = mr.easypiecharts.options.size; 2370 } 2371 if (typeof chart.attr('data-timing') !== typeof undefined) { 2372 attributeOverrides.animate = { duration: parseInt(chart.attr('data-timing'), 10), enabled: true }; 2373 } 2374 if (typeof chart.attr('data-color') !== typeof undefined) { 2375 attributeOverrides.barColor = chart.attr('data-color'); 2376 } 2377 if (typeof chart.attr('data-size') !== typeof undefined) { 2378 pieSize = attributeOverrides.size = parseInt(chart.attr('data-size'), 10); 2379 } 2380 if (typeof chart.attr('data-bar-width') !== typeof undefined) { 2381 attributeOverrides.lineWidth = parseInt(chart.attr('data-bar-width'), 10); 2382 } 2383 2384 chart.css('height', pieSize).css('width', pieSize); 2385 2386 2387 2388 if (typeof mr.easypiecharts.options === 'object') { 2389 options = jQuery.extend({}, defaults, mr.easypiecharts.options, attributeOverrides); 2390 } 2391 2392 chart.easyPieChart(options); 2393 chart.data('easyPieChart').update(0); 2394 }); 2395 2396 if ($('.radial').length) { 2397 mr.easypiecharts.init(); 2398 mr.easypiecharts.activate(); 2399 mr.scroll.listeners.push(mr.easypiecharts.activate); 2400 } 2401 2402 }; 2403 2404 mr.easypiecharts.init = function () { 2405 2406 mr.easypiecharts.pies = []; 2407 2408 $('.radial').each(function () { 2409 var pieObject = {}, 2410 currentPie = jQuery(this); 2411 2412 pieObject.element = currentPie; 2413 pieObject.value = parseInt(currentPie.attr('data-value'), 10); 2414 pieObject.top = currentPie.offset().top; 2415 pieObject.height = currentPie.height() / 2; 2416 pieObject.active = false; 2417 mr.easypiecharts.pies.push(pieObject); 2418 }); 2419 }; 2420 2421 mr.easypiecharts.activate = function () { 2422 mr.easypiecharts.pies.forEach(function (pie) { 2423 if (Math.round((mr.scroll.y + mr.window.height)) >= Math.round(pie.top + pie.height)) { 2424 if (pie.active === false) { 2425 2426 pie.element.data('easyPieChart').enableAnimation(); 2427 pie.element.data('easyPieChart').update(pie.value); 2428 pie.element.addClass('radial--active'); 2429 pie.active = true; 2430 } 2431 } 2432 }); 2433 }; 2434 2435 mr.components.documentReadyDeferred.push(mr.easypiecharts.documentReady); 2436 return mr; 2437 2438}(mr, jQuery, window, document)); 2439 2440//////////////// Flickity 2441mr = (function (mr, $, window, document) { 2442 "use strict"; 2443 2444 mr.sliders = mr.sliders || {}; 2445 2446 mr.sliders.documentReady = function ($) { 2447 2448 $('.slider').each(function (index) { 2449 2450 var slider = $(this); 2451 var sliderInitializer = slider.find('ul.slides'); 2452 sliderInitializer.find('>li').addClass('slide'); 2453 var childnum = sliderInitializer.find('li').length; 2454 2455 var themeDefaults = { 2456 cellSelector: '.slide', 2457 cellAlign: 'left', 2458 wrapAround: true, 2459 pageDots: false,
2460 prevNextButtons: false, 2461 autoPlay: true, 2462 draggable: (childnum < 2 ? false : true), 2463 imagesLoaded: true, 2464 accessibility: true, 2465 rightToLeft: false, 2466 initialIndex: 0, 2467 freeScroll: false 2468 }; 2469 2470 // Attribute Overrides - options that are overridden by data attributes on the slider element 2471 var ao = {}; 2472 ao.pageDots = (slider.attr('data-paging') === 'true' && sliderInitializer.find('li').length > 1) ? true : undefined; 2473 ao.prevNextButtons = slider.attr('data-arrows') === 'true' ? true : undefined; 2474 ao.draggable = slider.attr('data-draggable') === 'false' ? false : undefined; 2475 ao.autoPlay = slider.attr('data-autoplay') === 'false' ? false : (slider.attr('data-timing') ? parseInt(slider.attr('data-timing'), 10) : undefined); 2476 ao.accessibility = slider.attr('data-accessibility') === 'false' ? false : undefined; 2477 ao.rightToLeft = slider.attr('data-rtl') === 'true' ? true : undefined; 2478 ao.initialIndex = slider.attr('data-initial') ? parseInt(slider.attr('data-initial'), 10) : undefined; 2479 ao.freeScroll = slider.attr('data-freescroll') === "true" ? true : undefined; 2480 2481 // Set data attribute to inidicate the number of children in the slider 2482 slider.attr('data-children', childnum); 2483 2484 2485 $(this).data('sliderOptions', jQuery.extend({}, themeDefaults, mr.sliders.options, ao)); 2486 2487 $(sliderInitializer).flickity($(this).data('sliderOptions')); 2488 2489 $(sliderInitializer).on('scroll.flickity', function (event, progress) { 2490 if (slider.find('.is-selected').hasClass('controls--dark')) { 2491 slider.addClass('controls--dark'); 2492 } else { 2493 slider.removeClass('controls--dark'); 2494 } 2495 }); 2496 }); 2497 2498 if (mr.parallax.update) { mr.parallax.update(); } 2499 2500 }; 2501 2502 mr.components.documentReadyDeferred.push(mr.sliders.documentReady); 2503 return mr; 2504 2505}(mr, jQuery, window, document)); 2506 2507//////////////// Smoothscroll 2508mr = (function (mr, $, window, document) { 2509 "use strict"; 2510 2511 mr.smoothscroll = mr.smoothscroll || {}; 2512 mr.smoothscroll.sections = []; 2513 2514 mr.smoothscroll.init = function () { 2515 mr.smoothscroll.sections = []; 2516 2517 2518 2519 $('a.inner-link').each(function () { 2520 var sectionObject = {}, 2521 link = $(this), 2522 href = link.attr('href'), 2523 validLink = new RegExp('^#[^\r\n\t\f\v\#\.]+$', 'gm'); 2524 2525 if (validLink.test(href)) { 2526 2527 if ($('section' + href).length) { 2528 2529 sectionObject.id = href; 2530 sectionObject.top = Math.round($(href).offset().top); 2531 sectionObject.height = Math.round($(href).outerHeight()); 2532 sectionObject.link = link.get(0); 2533 sectionObject.active = false; 2534 2535 mr.smoothscroll.sections.push(sectionObject); 2536 } 2537 } 2538 }); 2539 2540 mr.smoothscroll.highlight(); 2541 }; 2542 2543 mr.smoothscroll.highlight = function () { 2544 mr.smoothscroll.sections.forEach(function (section) { 2545 if (mr.scroll.y >= section.top && mr.scroll.y < (section.top + section.height)) { 2546 if (section.active === false) { 2547 section.link.classList.add("inner-link--active"); 2548 section.active = true; 2549 } 2550 } else { 2551 section.link.classList.remove("inner-link--active"); 2552 section.active = false; 2553 } 2554 }); 2555 }; 2556 2557 mr.scroll.listeners.push(mr.smoothscroll.highlight); 2558 2559 mr.smoothscroll.documentReady = function ($) { 2560 // Smooth scroll to inner links 2561 var innerLinks = $('a.inner-link'), offset, themeDefaults, ao = {}; 2562 2563 themeDefaults = { 2564 selector: '.inner-link', 2565 selectorHeader: null, 2566 speed: 750, 2567 easing: 'easeInOutCubic', 2568 offset: 0 2569 }; 2570 2571 if (innerLinks.length) { 2572 innerLinks.each(function (index) { 2573 var link = $(this), 2574 href = link.attr('href'); 2575 if (href.charAt(0) !== "#") { 2576 link.removeClass('inner-link'); 2577 } 2578 }); 2579 2580 mr.smoothscroll.init(); 2581 $(window).on('resize', mr.smoothscroll.init); 2582 2583 offset = 0; 2584 if ($('body[data-smooth-scroll-offset]').length) { 2585 offset = $('body').attr('data-smooth-scroll-offset'); 2586 offset = offset * 1; 2587 } 2588 2589 ao.offset = offset !== 0 ? offset : undefined; 2590 2591 smoothScroll.init(jQuery.extend({}, themeDefaults, mr.smoothscroll.options, ao)); 2592 } 2593 }; 2594 2595 mr.components.documentReady.push(mr.smoothscroll.documentReady); 2596 mr.components.windowLoad.push(mr.smoothscroll.init); 2597 return mr; 2598 2599}(mr, jQuery, window, document)); 2600
2601//////////////// Tabs 2602mr = (function (mr, $, window, document) { 2603 "use strict"; 2604 2605 mr.tabs = mr.tabs || {}; 2606 2607 mr.tabs.documentReady = function ($) { 2608 2609 var target = $(document); 2610 mr.tabs.setTab(target); 2611 console.log("target", target); 2612 }; 2613 2614 mr.tabs.setTab = function (target) { 2615 // TODO: poner una clase de control 2616 target.find('.tabs').not('.ms-tabs-assigned').each(function () { 2617 var tabs = $(this); 2618 //$(this).css('background-color', 'red'); 2619 $(this).addClass('ms-tabs-assigned'); 2620 tabs.after('<ul class="tabs-content">'); // TODO: revisar por qué esto 2621 tabs.find('li').each(function () { 2622 var currentTab = $(this), 2623 tabContent = currentTab.find('.tab__content').eq(0).wrap('<li></li>').parent(), 2624 tabContentClone = tabContent.clone(true, true); 2625 tabContent.remove(); 2626 currentTab.closest('.tabs-container').find('.tabs-content').append(tabContentClone); 2627 }); 2628 }); 2629 2630 target.find('.tabs > li').off('click').on('click', function () { 2631 var clickedTab = $(this), hash; 2632 var tabContainer = clickedTab.closest('.tabs-container'), 2633 activeIndex = (clickedTab.index() * 1) + (1), 2634 activeContent = tabContainer.find('.tabs-content').eq(0).children('li:nth-of-type(' + activeIndex + ')'); 2635 mr.tabs.activateTab(clickedTab); 2636 mr.tabs.setTab(activeContent); 2637 2638 // Update the URL bar if the currently clicked tab has an ID 2639 if (clickedTab.is('[id]')) { 2640 2641 // Create the hash from the tab's ID 2642 hash = '#' + clickedTab.attr('id'); 2643 // Check we are in a newish browser with the history API 2644 if (history.pushState) { 2645 history.pushState(null, null, hash); 2646 } 2647 else { 2648 location.hash = hash; 2649 } 2650 } 2651 2652 activeContent.find('div.czContainer.insideTab').czMore(); 2653 //activeContent.find('table.dataTable').DataTable(); 2654 2655 var dtTarget = activeContent.find('table.dataTable'); 2656 if (dtTarget.length) { 2657 2658 2659 if ($(dtTarget[0]).data('init')) { 2660 2661 2662 //$.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust().draw(); 2663 2664 $(`#${dtTarget[0].id}`).DataTable($(dtTarget[0]).data('init')); 2665 2666 //$($.fn.dataTable.tables({ visible: true, api: true })).destroy() 2667 //$(`#${dtTarget[0].id}`).DataTable().destroy(); 2668 2669 2670 //var table = $(dtTarget[0].id).DataTable($(dtTarget[0]).data('init')); 2671 2672 2673 // $(dtTarget[0].id).DataTable($(dtTarget[0]).data('init')); 2674 // $($.fn.dataTable.tables({ visible: true, api: true })).DataTable().destroy(); 2675 // $.fn.dataTable.tables( {visible: true, api: true} ).draw(); 2676 } 2677 } 2678 }); 2679 2680 target.find('.tabs li.active').each(function () { 2681 mr.tabs.activateTab(this); 2682 }); 2683 2684 if (window.location.hash !== '') { 2685 mr.tabs.activateTabById(window.location.hash); 2686 } 2687 2688 $('a[href^="#"]').off('click').on('click', function () { 2689 mr.tabs.activateTabById($(this).attr('href')); 2690 }); 2691 2692 //patch para activar por defecto la primera pestaña 2693 try { 2694 target.find('.tabs > li').eq(0).click(); 2695 } catch (ex) { 2696 2697 } 2698 } 2699 2700 mr.tabs.activateTab = function (tab) { 2701 2702 var clickedTab = $(tab), 2703 tabContainer = clickedTab.closest('.tabs-container'), 2704 activeIndex = (clickedTab.index() * 1) + (1), 2705 activeContent = tabContainer.find('.tabs-content').eq(0).children('li:nth-of-type(' + activeIndex + ')'), 2706 openEvent = document.createEvent('Event'), 2707 iframe, radial; 2708 2709 openEvent.initEvent('tabOpened.tabs.mr', true, true); 2710 2711 tabContainer.find('.tabs').eq(0).children('li').removeClass('active'); 2712 tabContainer.find('.tabs-content').eq(0).children('li').removeClass('active'); 2713 2714 clickedTab.addClass('active').trigger('tabOpened.tabs.mr').get(0).dispatchEvent(openEvent); 2715 activeContent.addClass('active'); 2716 2717 // If there is an <iframe> element in the tab, reload its content when the tab is made active. 2718 iframe = activeContent.find('iframe'); 2719 if (iframe.length) { 2720 iframe.attr('src', iframe.attr('src')); 2721 } 2722 }; 2723 2724 mr.tabs.activateTabById = function (id) { 2725 if (id !== '' && id !== '#') { 2726 $('.tabs > li#' + id.replace('#', '')).click(); 2727 } 2728 }; 2729 2730 mr.components.documentReady.push(mr.tabs.documentReady); 2731 return mr; 2732 2733}(mr, jQuery, window, document)); 2734
2735//////////////// Toggle Class 2736mr = (function (mr, $, window, document) { 2737 "use strict"; 2738 2739 mr.toggleClass = mr.toggleClass || {}; 2740 2741 mr.toggleClass.documentReady = function ($) { 2742 $('[data-toggle-class]').each(function () { 2743 var element = $(this), 2744 data = element.attr('data-toggle-class').split("|"); 2745 2746 2747 $(data).each(function () { 2748 var candidate = element, 2749 dataArray = [], 2750 toggleClass = '', 2751 toggleElement = '', 2752 dataArray = this.split(";"); 2753 2754 if (dataArray.length === 2) { 2755 toggleElement = dataArray[0]; 2756 toggleClass = dataArray[1]; 2757 $(candidate).on('click', function () { 2758 if (!candidate.hasClass('toggled-class')) { 2759 candidate.toggleClass('toggled-class'); 2760 } else { 2761 candidate.removeClass('toggled-class'); 2762 } 2763 $(toggleElement).toggleClass(toggleClass); 2764 return false; 2765 }); 2766 } else { 2767 console.log('Error in [data-toggle-class] attribute. This attribute accepts an element, or comma separated elements terminated witha ";" followed by a class name to toggle'); 2768 } 2769 }); 2770 }); 2771 }; 2772 2773 mr.components.documentReady.push(mr.toggleClass.documentReady); 2774 return mr; 2775 2776}(mr, jQuery, window, document)); 2777 2778//////////////// Typed Headline Effect 2779mr = (function (mr, $, window, document) { 2780 "use strict"; 2781 2782 mr.typed = mr.typed || {}; 2783 2784 2785 mr.typed.documentReady = function ($) { 2786 $('.typed-text').each(function () { 2787 var text = $(this); 2788 var strings = text.attr("data-typed-strings") ? text.attr("data-typed-strings").split(",") : [], 2789 themeDefaults = { 2790 strings: [], 2791 typeSpeed: 100, 2792 loop: true, 2793 showCursor: false 2794 }, ao = {}; 2795 2796 ao.strings = text.attr("data-typed-strings") ? text.attr("data-typed-strings").split(",") : undefined; 2797 2798 $(text).typed(jQuery.extend({}, themeDefaults, mr.typed.options, ao)); 2799 2800 }); 2801 }; 2802 2803 mr.components.documentReady.push(mr.typed.documentReady); 2804 return mr; 2805 2806}(mr, jQuery, window, document)); 2807 2808//////////////// Twitter Feeds 2809mr = (function (mr, $, window, document) { 2810 "use strict"; 2811 2812 mr.twitter = mr.twitter || {}; 2813 mr.twitter.options = mr.twitter.options || {}; 2814 2815 mr.twitter.documentReady = function ($) { 2816 $('.tweets-feed').each(function (index) { 2817 $(this).attr('id', 'tweets-' + index); 2818 }).each(function (index) { 2819 var element = $('#tweets-' + index); 2820 2821 var TweetConfig = { 2822 "domId": '', 2823 "maxTweets": 6, 2824 "enableLinks": true, 2825 "showUser": true, 2826 "showTime": true, 2827 "dateFunction": '', 2828 "showRetweet": false, 2829 "customCallback": handleTweets 2830 }; 2831 2832 TweetConfig = jQuery.extend(TweetConfig, mr.twitter.options); 2833 2834 2835 2836 if (typeof element.attr('data-widget-id') !== typeof undefined) { 2837 TweetConfig.id = element.attr('data-widget-id'); 2838 } else if (typeof element.attr('data-feed-name') !== typeof undefined && element.attr('data-feed-name') !== "") { 2839 TweetConfig.profile = { "screenName": element.attr('data-feed-name').replace('@', '') }; 2840 } else if (typeof mr.twitter.options.profile !== typeof undefined) { 2841 TweetConfig.profile = { "screenName": mr.twitter.options.profile.replace('@', '') }; 2842 } else { 2843 TweetConfig.profile = { "screenName": 'twitter' }; 2844 } 2845 2846 TweetConfig.maxTweets = element.attr('data-amount') ? element.attr('data-amount') : TweetConfig.maxTweets; 2847 2848 if (element.closest('.twitter-feed--slider').length) { 2849 element.addClass('slider'); 2850 } 2851 2852 function handleTweets(tweets) { 2853 var x = tweets.length; 2854 var n = 0; 2855 var html = '<ul class="slides">'; 2856 while (n < x) { 2857 html += '<li>' + tweets[n] + '</li>'; 2858 n++; 2859 } 2860 html += '</ul>'; 2861 element.html(html); 2862 2863 // Initialize twitter feed slider 2864 if (element.closest('.slider').length) { 2865 mr.sliders.documentReady(mr.setContext()); 2866 2867 return html; 2868 } 2869 } 2870 twitterFetcher.fetch(TweetConfig); 2871 }); 2872 }; 2873 2874 mr.components.documentReady.push(mr.twitter.documentReady); 2875 return mr; 2876 2877}(mr, jQuery, window, document)); 2878
2879//////////////// Video 2880mr = (function (mr, $, window, document) { 2881 "use strict"; 2882 2883 mr.video = mr.video || {}; 2884 mr.video.options = mr.video.options || {}; 2885 mr.video.options.ytplayer = mr.video.options.ytplayer || {}; 2886 2887 mr.video.documentReady = function ($) { 2888 2889 //////////////// Youtube Background 2890 2891 if ($('.youtube-background').length) { 2892 $('.youtube-background').each(function () { 2893 2894 2895 var player = $(this), 2896 2897 themeDefaults = { 2898 containment: "self", 2899 autoPlay: true, 2900 mute: true, 2901 opacity: 1 2902 }, ao = {}; 2903 2904 // Attribute overrides - provides overrides to the global options on a per-video basis 2905 ao.videoURL = $(this).attr('data-video-url'); 2906 ao.startAt = $(this).attr('data-start-at') ? parseInt($(this).attr('data-start-at'), 10) : undefined; 2907 2908 2909 player.closest('.videobg').append('<div class="loading-indicator"></div>'); 2910 player.YTPlayer(jQuery.extend({}, themeDefaults, mr.video.options.ytplayer, ao)); 2911 player.on("YTPStart", function () { 2912 player.closest('.videobg').addClass('video-active'); 2913 }); 2914 2915 }); 2916 } 2917 2918 if ($('.videobg').find('video').length) { 2919 $('.videobg').find('video').closest('.videobg').addClass('video-active'); 2920 } 2921
2922 //////////////// Video Cover Play Icons 2923 2924 $('.video-cover').each(function () { 2925 var videoCover = $(this); 2926 if (videoCover.find('iframe[src]').length) { 2927 videoCover.find('iframe').attr('data-src', videoCover.find('iframe').attr('src')); 2928 videoCover.find('iframe').attr('src', ''); 2929 } 2930 }); 2931 2932 $('.video-cover .video-play-icon').on("click", function () { 2933 var playIcon = $(this); 2934 var videoCover = playIcon.closest('.video-cover'); 2935 if (videoCover.find('video').length) { 2936 var video = videoCover.find('video').get(0); 2937 videoCover.addClass('reveal-video'); 2938 video.play(); 2939 return false; 2940 } else if (videoCover.find('iframe').length) { 2941 var iframe = videoCover.find('iframe'); 2942 iframe.attr('src', iframe.attr('data-src')); 2943 videoCover.addClass('reveal-video'); 2944 return false; 2945 } 2946 }); 2947 }; 2948 2949 mr.components.documentReady.push(mr.video.documentReady); 2950 return mr; 2951 2952}(mr, jQuery, window, document)); 2953 2954//////////////// Wizard 2955mr = (function (mr, $, window, document) { 2956 "use strict"; 2957 2958 mr.wizard = mr.wizard || {}; 2959 2960 mr.wizard.documentReady = function ($) { 2961 2962 $('.wizard').each(function () { 2963 var wizard = jQuery(this), themeDefaults = {}; 2964 2965 themeDefaults = { 2966 headerTag: "h5", 2967 bodyTag: "section", 2968 transitionEffect: "slideLeft", 2969 autoFocus: true 2970 } 2971 2972 2973 if (!wizard.is('[role="application"][id^="steps-uid"]')) { 2974 wizard.steps(jQuery.extend({}, themeDefaults, mr.wizard.options)); 2975 2976 wizard.addClass('active'); 2977 } 2978 2979 }); 2980 }; 2981 2982 mr.components.documentReady.push(mr.wizard.documentReady); 2983 return mr; 2984 2985}(mr, jQuery, window, document)); 2986 2987 2988/*** HAY QUE AÃADIR AQUÃ LOS CAMBIOS EN AUTONÃMICAS PARA NUEVAS ALTAS ***/ 2989 2990 2991$("input[name='irobot']").click(function(){ 2992 console.log("Clk button PRIMARY"); 2993 $(".nClss").html("<span id='ChkNoRobotIsOK'></span>"); 2994});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.