1(function($) {// v5 namespace 2var MK = { 3 api : {}, 4 ui : {}, 5 component : {}, 6}; 7 8// Global 9window.MK = MK; 10// http://alistapart.com/article/container-queries-once-more-unto-the-breach 11 var elementQuery = (function() { 12 13 // implementations for testing actual element query properties 14 var queryMatchers = { 15 "min-width": function(element, value, units) { 16 var el = element; 17 var px = convertToPx(el, value, units); 18 return value && el && el.offsetWidth >= px; 19 }, 20 "max-width": function(element, value, units) { 21 var el = element; 22 var px = convertToPx(el, value, units); 23 return value && el && el.offsetWidth < px; 24 } 25 }; 26 27 // convert an element query into a css class name we can replace it with 28 var classNameForRules = function(rules) { 29 var name = "query"; 30 for (var i = 0, len = rules.length; i < len; i++) { 31 name += "_" + rules[i].property + "_" + rules[i].value + rules[i].units; 32 } 33 return name; 34 }; 35 36 // determine the px value for a measurement (e.g. "5em") on a given element 37 var convertToPx = function(element, value, units) { 38 switch (units) { 39 case "px": return value; 40 case "em": return value * getEmSize(element); 41 case "rem": return value * getEmSize(); 42 // Viewport units! 43 // According to http://quirksmode.org/mobile/tableViewport.html 44 // documentElement.clientWidth/Height gets us the most reliable info 45 case "vw": return value * document.documentElement.clientWidth / 100; 46 case "vh": return value * document.documentElement.clientHeight / 100; 47 case "vmin": 48 case "vmax": 49 var vw = document.documentElement.clientWidth / 100; 50 var vh = document.documentElement.clientHeight / 100; 51 var chooser = Math[units === "vmin" ? "min" : "max"]; 52 return value * chooser(vw, vh); 53 default: return value; 54 // for now, not supporting physical units (since they are just a set number of px) 55 // or ex/ch (getting accurate measurements is hard) 56 } 57 }; 58 59 // determine the size of an em in a given element 60 var getEmSize = function(element) { 61 if (!element) { 62 element = document.documentElement; 63 } 64 if (window.getComputedStyle) { 65 return parseFloat(getComputedStyle(element).fontSize) || 16; 66 } 67 // TODO: support IE? 68 return 16; 69 }; 70 71 // test whether an element matches a set of query rules 72 var elementMatchesRules = function(element, rules) { 73 for (var i = rules.length - 1; i > -1; i--) { 74 var rule = rules[i]; 75 var matcher = queryMatchers[rule.property]; 76 if (matcher && !matcher(element, rule.value, rule.units)) { 77 return false; 78 } 79 } 80 return true; 81 }; 82 83 var loader = { 84 // parse an array of CSSStyleSheet objects for element queries 85 loadStyleSheets: function(sheets, callback) { 86 var completed = 0; 87 for (var i = 0, len = sheets.length; i < len; i++) { 88 89 // if( (sheets[i].href && sheets[i].href.indexOf('media.min.css') != -1) || (sheets[i].href && sheets[i].href.indexOf('media.css') != -1) ) { 90 this.loadStyleSheet(sheets[i], function() { 91 completed += 1; 92 if (completed === len) { 93 callback && callback(); 94 } 95 }); 96 // } 97 } 98 }, 99 100 // parse a single CSSStyleSheet object for element queries 101 loadStyleSheet: function(sheet, callback) { 102 // if (sheet.ownerNode.nodeName === "STYLE") { 103 // if(sheet.ownerNode.id !== 'js-media-query') return; 104 // var result = elementQuery.parser.parseStyleText(sheet.ownerNode.innerHTML); 105 // sheet.ownerNode.innerHTML += result.newCss; 106 // elementQuery.queries = elementQuery.queries.concat(result.queries); 107 // callback && callback(); 108 // } 109 // else if (sheet.href) { 110 if (sheet.href && sheet.ownerNode.id === 'js-media-query-css') { 111 console.log('element query css parsed'); 112 var xhr = new XMLHttpRequest(); 113 xhr.open("GET", sheet.href, true); 114 xhr.onreadystatechange = function() { 115 if (xhr.readyState === 4) { 116 if (xhr.status === 200) { 117 var result = elementQuery.parser.parseStyleText(xhr.responseText); 118 elementQuery.queries = elementQuery.queries.concat(result.queries); 119 var style = document.createElement("style"); 120 style.innerHTML = result.newCss; 121 document.body.appendChild(style); 122 } 123 else if (window.console) { 124 console.log("Could not load stylesheet at " + sheet.href); 125 } 126 callback && callback(); 127 } 128 } 129 xhr.send(null); 130 } 131 }, 132 }; 133 134 // public API 135 var elementQuery = { 136 autoInit: true, 137 138 init: function() { 139 var evaluated = false;
140 this.loader.loadStyleSheets(document.styleSheets, function() { 141 evaluated = true; 142 elementQuery.evaluateQueries(); 143 }); 144 145 // if we are still waiting for some asynchronous ones, go ahead and evaluate 146 // any found queries now for minimum latency 147 if (!evaluated) { 148 elementQuery.evaluateQueries(); 149 } 150 }, 151 152 // update the styling for all the elements that have queries 153 evaluateQueries: function(context) { 154 context = context || document; 155 var queries = this.queries; 156 for (var i = 0, len = queries.length; i < len; i++) { 157 var elements = context.querySelectorAll(queries[i].selector); 158 for (var j = 0; j < elements.length; j++) { 159 var element = elements[j]; 160 if (elementMatchesRules(element, queries[i].rules)) { 161 element.classList.add(queries[i].className); 162 } 163 else { 164 element.classList.remove(queries[i].className); 165 } 166 } 167 } 168 }, 169 170 queryMatchers: queryMatchers, 171 queries: [], 172 classNameForRules: classNameForRules, 173 loader: loader 174 }; 175 176 // re-run all queries on resize 177 window.addEventListener("resize", function() { 178 elementQuery.evaluateQueries(); 179 }, false); 180 181 // automatically look for things on window load 182 window.addEventListener("load", function() { 183 if (elementQuery.autoInit) { 184 elementQuery.init(); 185 setTimeout(function() { 186 elementQuery.evaluateQueries(); 187 console.log('Element Queries evaluated'); 188 }, 1000); 189 } 190 }); 191 192 // TODO: re-run all queries... on an interval? 193 // override setTimeout, addEventListener, etc to hit every possible JS entry 194 // point? Not really an ideal solution to this. 195 // Repaint events in Mozilla? 196 197 return elementQuery; 198 199 }()); 200 201 (function(elementQuery) { 202 203 // Identifies comments in CSS 204 var COMMENT_PATTERN = /(\/\*)[\s\S]*?(\*\/)/g; 205 // $1 is the end of a block ("}") 206 // $2 is all of a simple @rule ("@something ...;") 207 // $3 is the start of a rule with a block, excluding the opening { 208 // this could be an @media rule or a simple style rule. 209 var STATEMENT_END_OR_START_PATTERN = /\s*(?:(\})|(@\S+\s+[^;{]+;)|(?:([^{}]+)\{))/g; 210 // element queries look like: 211 // `:media(property: value)` or `:media((property: value) and (property: value))` 212 var QUERY_PATTERN = /:media\s*\(([^)]*)\)/g; 213 var QUERY_RULES_PATTERN = /\(?([^\s:]+):\s*(\d+(?:\.\d+)?)(px|em|rem|vw|vh|vmin|vmax)\)?/g; 214 var WHITESPACE_PATTERN = /^\s*$/; 215 216 // Parse CSS content for element queries 217 elementQuery.parser = { 218 /** 219 * This the main entry point for parsing some CSS. Pass it a string of 220 * CSS content and you'll get back an object like: 221 * { 222 * queries: [array of query objects] 223 * newCss: [string of new CSS] 224 * } 225 * The `newCss` property contains new CSS rules to use in place of the 226 * rules that have element queries -- they replace the queries in selectors 227 * with classes you can turn on and off on the relevant elements. You'll 228 * want to insert the new CSS content into a <style> element on your page. 229 * 230 * @param {String} styleText The text of a style sheet 231 * @return {Object} 232 */ 233 parseStyleText: function(styleText) { 234 var newText = ""; 235 var queries = []; 236 237 this.parseText(styleText, { 238 // TODO: don't write a media query to newText if it has no element 239 // queries. Unfortunately that means tracking nesting level :\ 240 mediaQuery: function(selector) { 241 newText += "\n" + selector + "{"; 242 }, 243 244 endMediaQuery: function() { 245 newText += "\n}"; 246 }, 247 248 rule: function(selector, properties) { 249 // a selector is an array of selectors, which are arrays in the form: 250 // [text, elementQuery, text, elementQuery, etc., optional text] 251 // TODO: maybe have a callback for each? May simplify the logic here. 252 for (var i = 0, len = selector.length; i < len; i++) { 253 var single = selector[i]; 254 255 // we're going to build up a new selector in `selectorSoFar`, 256 // replacing the element queries with classes. 257 var selectorSoFar = ""; 258 259 // jump by two since we are dealing with [text, query] pairs 260 for (var j = 0, lenj = single.length; j < lenj; j += 2) { 261 // add text content to the selector 262 selectorSoFar += single[j]; 263 var rules = single[j + 1]; 264 // we may have trailing text at the end, in which case there will 265 // be no associated query rules. 266 if (rules) { 267 var queryClass = elementQuery.classNameForRules(rules); 268 // create and add a query object for this element query 269 queries.push({ 270 selector: selectorSoFar, 271 rules: rules, 272 className: queryClass 273 }); 274 // replace the query in the selector with a class 275 selectorSoFar += "." + queryClass; 276 } 277 } 278 279 // Add this selector to our new CSS 280 newText += selectorSoFar + (i < len - 1 ? "," : ""); 281 } 282 283 // Add the actual style rule content 284 newText += " {" + properties + "}"; 285 } 286 }); 287 288 return { 289 queries: queries, 290 newCss: newText 291 }; 292 }, 293 294 /** 295 * Parse the text of a stylesheet. Usually, you'll want to use 296 * parseStyleText() instead;
296 this is slightly lower-level. You should 297 * provide an object with callbacks for the parsing events you are 298 * interested in: 299 * { 300 * mediaQuery: 301 * The start of a media rule was encountered. Receives everything 302 * from the "@" to the "{" as the first argument. 303 * endMediaQuery: 304 * The end of a media rule was encountered. No arguments. 305 * rule: 306 * A normal style rule was encountered. Receives the parsed selector 307 * as the first argument and the string of properties and values the 308 * rule would apply to matched elements as the second argument. 309 * } 310 * 311 * There is no return value for this function. 312 * 313 * @param {String} styleText The text of a stylesheet to parse. 314 * @param {Object} callbacks An object containing callbacks for the parsing 315 * events you are interested in. 316 */ 317 parseText: function(styleText, callbacks) { 318 callbacks = callbacks || {}; 319 320 // remove comments 321 var text = styleText.replace(COMMENT_PATTERN, ""); 322 323 // iterate through all the CSS rules 324 while (match = STATEMENT_END_OR_START_PATTERN.exec(text)) { 325 // we found the end of a block 326 if (match[1]) { 327 callbacks.endMediaQuery && callbacks.endMediaQuery(); 328 continue; 329 } 330 331 // if we hit a plain-jane @rule (i.e. match[2]), we don't care 332 var selector = match[3]; 333 if (selector) { 334 // Note @media rules specially, since they can contain other rules 335 if (selector.slice(0, 6) === "@media") { 336 callbacks.mediaQuery && callbacks.mediaQuery(selector); 337 } 338 // otherwise just parse the rule 339 else { 340 var closingIndex = text.indexOf("}", match.index); 341 // don't parse other @rules with blocks, e.g. @font-face 342 if (selector[0] !== "@") { 343 var content = text.slice(match.index + match[0].length, closingIndex); 344 this.parseRule(selector, content, callbacks.rule); 345 } 346 STATEMENT_END_OR_START_PATTERN.lastIndex = closingIndex + 1; 347 } 348 } 349 } 350 }, 351 352 /** 353 * Parse a style rule. This just manages the parsing of a selector and the 354 * callback for a rule. 355 * @private 356 * 357 * @param {String} selector The selector for the rule 358 * @param {String} content The properties and values of the rule. 359 * @param {Function} callback The callback for a parsed rule. 360 */ 361 parseRule: function(selector, content, callback) { 362 var parsedSelector = this.parseSelector(selector); 363 if (parsedSelector) { 364 callback && callback(parsedSelector, content); 365 } 366 }, 367 368 /** 369 * Parse a selector string and return an array of parsed selectors (one for 370 * each comma-separated sub-selector). 371 * Individual sub-selectors are parsed as arrays of alternating text and 372 * element queries, so this selector: 373 * body:media(...) div:media(...) a, body:media(...), a 374 * returns: 375 * [["body", [rules], " div", [rules], " a"], 376 * ["body", [rules], " a"]] 377 * @private 378 * 379 * @param {String} selector The selector to parse. 380 * @return {Array} 381 */ 382 parseSelector: function(selector) { 383 var parsed = []; 384 var parts = selector.split(","); 385 for (var i = 0, len = parts.length; i < len; i++) { 386 var result = this.parseSingleSelector(parts[i]); 387 if (result.length > 1) { 388 parsed.push(result); 389 } 390 } 391 // return null if no selectors had element queries 392 return parsed.length ? parsed : null; 393 }, 394 395 /** 396 * Parses a single sub-selector. This is used by parseSelector(). 397 * @private 398 * @param {String} selector The sub-selector to parse 399 * @return {Array} The parsed selector 400 */ 401 parseSingleSelector: function(selector) { 402 var parsed = []; 403 var lastIndex = 0; 404 while (queryMatch = QUERY_PATTERN.exec(selector)) { 405 // get everything up to the element query 406 var selectorChunk = selector.slice(lastIndex, queryMatch.index); 407 lastIndex = QUERY_PATTERN.lastIndex;
408 var queryData = this.parseQuery(queryMatch[1]); 409 parsed.push(selectorChunk); 410 parsed.push(queryData); 411 } 412 // get any remaining text in the selector 413 var remaining = selector.slice(lastIndex); 414 if (!WHITESPACE_PATTERN.test(remaining)) { 415 parsed.push(remaining); 416 } 417 418 // reset QUERY_PATTERN 419 QUERY_PATTERN.lastIndex = 0; 420 421 return parsed; 422 }, 423 424 /** 425 * Parse an element query. Returns an array of objects like: 426 * { 427 * property: the property being queries, e.g. "max-available-width" 428 * value: the actual value to test for as a number 429 * units: the units the value is expressed in 430 * } 431 * 432 * @param {String} queryString The text of the element query. 433 * @return {Array} 434 */ 435 parseQuery: function(queryString) { 436 var rules = []; 437 var ruleMatch; 438 while (ruleMatch = QUERY_RULES_PATTERN.exec(queryString)) { 439 rules.push({ 440 property: ruleMatch[1], 441 value: parseFloat(ruleMatch[2]), 442 units: ruleMatch[3] 443 }); 444 } 445 return rules; 446 } 447 }; 448 449 }(elementQuery)); 450(function($) { 451 'use strict'; 452 453 $.exists = function(selector) { 454 return ($(selector).length > 0); 455 }; 456 457 /** 458 * Helper to enable caching async scripts 459 * https://api.jquery.com/jquery.getscript/ 460 * http://www.vrdmn.com/2013/07/overriding-jquerygetscript-to-include.html 461 * 462 * @param {String} script url 463 * @param {Function} callback 464 */ 465 $.getCachedScript = function( url ) { 466 var options = { 467 dataType: "script", 468 cache: true, 469 url: url 470 }; 471 472 // Use $.ajax() since it is more flexible than $.getScript 473 // Return the jqXHR object so we can chain callbacks 474 return $.ajax( options ); 475 }; 476 477 478 479 // Fn to allow an event to fire after all images are loaded 480 // usage: 481 // $.ajax({ 482 // cache: false, 483 // url: 'ajax/content.php', 484 // success: function(data) { 485 // $('#divajax').html(data).imagesLoaded().then(function(){ 486 // // do stuff after images are loaded here 487 // }); 488 // } 489 // }); 490 $.fn.imagesLoaded = function () { 491 492 // Edit: in strict mode, the var keyword is needed 493 var $imgs = this.find('img[src!=""]'); 494 // if there's no images, just return an already resolved promise 495 if (!$imgs.length) {return $.Deferred().resolve().promise();} 496 497 // for each image, add a deferred object to the array which resolves when the image is loaded (or if loading fails) 498 var dfds = []; 499 $imgs.each(function(){ 500 var dfd = $.Deferred(); 501 dfds.push(dfd); 502 var img = new Image(); 503 img.onload = function(){dfd.resolve();}; 504 img.onerror = function(){dfd.resolve();}; 505 img.src = this.src; 506 }); 507 508 // return a master promise object which will resolve when all the deferred objects have resolved 509 // IE - when all the images are loaded 510 return $.when.apply($,dfds); 511 512 }; 513 514}(jQuery)); 515/** 516* Detect Element Resize 517* 518* https://github.com/sdecima/javascript-detect-element-resize 519* Sebastian Decima 520* 521* version: 0.5.3 522**/ 523 524(function () { 525 var attachEvent = document.attachEvent, 526 stylesCreated = false; 527 528 if (!attachEvent) { 529 var requestFrame = (function(){ 530 var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || 531 function(fn){ return window.setTimeout(fn, 20); }; 532 return function(fn){ return raf(fn); }; 533 })(); 534 535 var cancelFrame = (function(){ 536 var cancel = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || 537 window.clearTimeout; 538 return function(id){ return cancel(id); }; 539 })(); 540 541 function resetTriggers(element){ 542 var triggers = element.__resizeTriggers__, 543 expand = triggers.firstElementChild, 544 contract = triggers.lastElementChild, 545 expandChild = expand.firstElementChild; 546 contract.scrollLeft = contract.scrollWidth; 547 contract.scrollTop = contract.scrollHeight; 548 expandChild.style.width = expand.offsetWidth + 1 + 'px'; 549 expandChild.style.height = expand.offsetHeight + 1 + 'px'; 550 expand.scrollLeft = expand.scrollWidth; 551 expand.scrollTop = expand.scrollHeight; 552 }; 553 554 function checkTriggers(element){ 555 return element.offsetWidth != element.__resizeLast__.width || 556 element.offsetHeight != element.__resizeLast__.height; 557 } 558 559 function scrollListener(e){ 560 var element = this; 561 resetTriggers(this); 562 if (this.__resizeRAF__) cancelFrame(this.__resizeRAF__); 563 this.__resizeRAF__ = requestFrame(function(){ 564 if (checkTriggers(element)) { 565 element.__resizeLast__.width = element.offsetWidth; 566 element.__resizeLast__.height = element.offsetHeight; 567 element.__resizeListeners__.forEach(function(fn){ 568 fn.call(element, e); 569 }); 570 } 571 }); 572 }; 573
574 /* Detect CSS Animations support to detect element display/re-attach */ 575 var animation = false, 576 animationstring = 'animation', 577 keyframeprefix = '', 578 animationstartevent = 'animationstart', 579 domPrefixes = 'Webkit Moz O ms'.split(' '), 580 startEvents = 'webkitAnimationStart animationstart oAnimationStart MSAnimationStart'.split(' '), 581 pfx = ''; 582 { 583 var elm = document.createElement('fakeelement'); 584 if( elm.style.animationName !== undefined ) { animation = true; } 585 586 if( animation === false ) { 587 for( var i = 0; i < domPrefixes.length; i++ ) { 588 if( elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) { 589 pfx = domPrefixes[ i ]; 590 animationstring = pfx + 'Animation'; 591 keyframeprefix = '-' + pfx.toLowerCase() + '-'; 592 animationstartevent = startEvents[ i ]; 593 animation = true; 594 break; 595 } 596 } 597 } 598 } 599 600 var animationName = 'resizeanim'; 601 var animationKeyframes = '@' + keyframeprefix + 'keyframes ' + animationName + ' { from { opacity: 0; } to { opacity: 0; } } '; 602 var animationStyle = keyframeprefix + 'animation: 1ms ' + animationName + '; '; 603 } 604 605 function createStyles() { 606 if (!stylesCreated) { 607 //opacity:0 works around a chrome bug https://code.google.com/p/chromium/issues/detail?id=286360 608 var css = (animationKeyframes ? animationKeyframes : '') + 609 '.resize-triggers { ' + (animationStyle ? animationStyle : '') + 'visibility: hidden; opacity: 0; } ' + 610 '.resize-triggers, .resize-triggers > div, .contract-trigger:before { content: \" \"; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', 611 head = document.head || document.getElementsByTagName('head')[0], 612 style = document.createElement('style'); 613 614 style.type = 'text/css'; 615 if (style.styleSheet) { 616 style.styleSheet.cssText = css; 617 } else { 618 style.appendChild(document.createTextNode(css)); 619 } 620 621 head.appendChild(style); 622 stylesCreated = true; 623 } 624 } 625 626 window.addResizeListener = function(element, fn){ 627 if (attachEvent) element.attachEvent('onresize', fn); 628 else { 629 if (!element.__resizeTriggers__) { 630 if (getComputedStyle(element).position == 'static') element.style.position = 'relative'; 631 createStyles(); 632 element.__resizeLast__ = {}; 633 element.__resizeListeners__ = []; 634 (element.__resizeTriggers__ = document.createElement('div')).className = 'resize-triggers'; 635 element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div>' + 636 '<div class="contract-trigger"></div>'; 637 element.appendChild(element.__resizeTriggers__); 638 resetTriggers(element); 639 element.addEventListener('scroll', scrollListener, true); 640 641 /* Listen for a css animation to detect element display/re-attach */ 642 animationstartevent && element.__resizeTriggers__.addEventListener(animationstartevent, function(e) { 643 if(e.animationName == animationName) 644 resetTriggers(element); 645 }); 646 } 647 element.__resizeListeners__.push(fn); 648 } 649 }; 650 651 window.removeResizeListener = function(element, fn){ 652 if (attachEvent) element.detachEvent('onresize', fn); 653 else { 654 element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1); 655 if (!element.__resizeListeners__.length) { 656 element.removeEventListener('scroll', scrollListener); 657 element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__); 658 } 659 } 660 } 661})(); 662/** 663* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 664*/ 665;(function(window, document) { 666/*jshint evil:true */ 667 /** version */ 668 var version = '3.7.3'; 669 670 /** Preset options */ 671 var options = window.html5 || {}; 672 673 /** Used to skip problem elements */ 674 var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; 675 676 /** Not all elements can be cloned in IE **/ 677 var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; 678 679 /** Detect whether the browser supports default html5 styles */ 680 var supportsHtml5Styles; 681 682 /** Name of the expando, to work with multiple documents or to re-shiv one document */ 683 var expando = '_html5shiv'; 684 685 /** The id for the the documents expando */ 686 var expanID = 0; 687 688 /** Cached data for each document */ 689 var expandoData = {}; 690 691 /** Detect whether the browser supports unknown elements */ 692 var supportsUnknownElements; 693 694 (function() { 695 try { 696 var a = document.createElement('a'); 697 a.innerHTML = '<xyz></xyz>'; 698 //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles 699 supportsHtml5Styles = ('hidden' in a); 700 701 supportsUnknownElements = a.childNodes.length == 1 || (function() { 702 // assign a false positive if unable to shiv 703 (document.createElement)('a'); 704 var frag = document.createDocumentFragment(); 705 return ( 706 typeof frag.cloneNode == 'undefined' || 707 typeof frag.createDocumentFragment == 'undefined' || 708 typeof frag.createElement == 'undefined' 709 ); 710 }()); 711 } catch(e) { 712 // assign a false positive if detection fails => unable to shiv 713 supportsHtml5Styles = true; 714 supportsUnknownElements = true; 715 } 716 717 }()); 718 719 /*--------------------------------------------------------------------------*/ 720 721 /** 722 * Creates a style sheet with the given CSS text and adds it to the document. 723 * @private 724 * @param {Document} ownerDocument The document. 725 * @param {String} cssText The CSS text. 726 * @returns {StyleSheet} The style element. 727 */ 728 function addStyleSheet(ownerDocument, cssText) { 729 var p = ownerDocument.createElement('p'), 730 parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; 731 732 p.innerHTML = 'x<style>' + cssText + '</style>'; 733 return parent.insertBefore(p.lastChild, parent.firstChild); 734 } 735 736 /** 737 * Returns the value of `html5.elements` as an array.
vendor: 1,418 bytes, lines 738-785
738 * @private 739 * @returns {Array} An array of shived element node names. 740 */ 741 function getElements() { 742 var elements = html5.elements; 743 return typeof elements == 'string' ? elements.split(' ') : elements; 744 } 745 746 /** 747 * Extends the built-in list of html5 elements 748 * @memberOf html5 749 * @param {String|Array} newElements whitespace separated list or array of new element names to shiv 750 * @param {Document} ownerDocument The context document. 751 */ 752 function addElements(newElements, ownerDocument) { 753 var elements = html5.elements; 754 if(typeof elements != 'string'){ 755 elements = elements.join(' '); 756 } 757 if(typeof newElements != 'string'){ 758 newElements = newElements.join(' '); 759 } 760 html5.elements = elements +' '+ newElements; 761 shivDocument(ownerDocument); 762 } 763 764 /** 765 * Returns the data associated to the given document 766 * @private 767 * @param {Document} ownerDocument The document. 768 * @returns {Object} An object of data. 769 */ 770 function getExpandoData(ownerDocument) { 771 var data = expandoData[ownerDocument[expando]]; 772 if (!data) { 773 data = {}; 774 expanID++; 775 ownerDocument[expando] = expanID; 776 expandoData[expanID] = data; 777 } 778 return data; 779 } 780 781 /** 782 * returns a shived element for the given nodeName and document 783 * @memberOf html5 784 * @param {String} nodeName name of the element 785 * @param {Document|DocumentFrag
vendor: 6,335 bytes, lines 785-987
785ment} ownerDocument The context document. 786 * @returns {Object} The shived element. 787 */ 788 function createElement(nodeName, ownerDocument, data){ 789 if (!ownerDocument) { 790 ownerDocument = document; 791 } 792 if(supportsUnknownElements){ 793 return ownerDocument.createElement(nodeName); 794 } 795 if (!data) { 796 data = getExpandoData(ownerDocument); 797 } 798 var node; 799 800 if (data.cache[nodeName]) { 801 node = data.cache[nodeName].cloneNode(); 802 } else if (saveClones.test(nodeName)) { 803 node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); 804 } else { 805 node = data.createElem(nodeName); 806 } 807 808 // Avoid adding some elements to fragments in IE < 9 because 809 // * Attributes like `name` or `type` cannot be set/changed once an element 810 // is inserted into a document/fragment 811 // * Link elements with `src` attributes that are inaccessible, as with 812 // a 403 response, will cause the tab/window to crash 813 // * Script elements appended to fragments will execute when their `src` 814 // or `text` property is set 815 return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; 816 } 817 818 /** 819 * returns a shived DocumentFragment for the given document 820 * @memberOf html5 821 * @param {Document} ownerDocument The context document. 822 * @returns {Object} The shived DocumentFragment. 823 */ 824 function createDocumentFragment(ownerDocument, data){ 825 if (!ownerDocument) { 826 ownerDocument = document; 827 } 828 if(supportsUnknownElements){ 829 return ownerDocument.createDocumentFragment(); 830 } 831 data = data || getExpandoData(ownerDocument); 832 var clone = data.frag.cloneNode(), 833 i = 0, 834 elems = getElements(), 835 l = elems.length; 836 for(;i<l;i++){ 837 clone.createElement(elems[i]); 838 } 839 return clone; 840 } 841 842 /** 843 * Shivs the `createElement` and `createDocumentFragment` methods of the document. 844 * @private 845 * @param {Document|DocumentFragment} ownerDocument The document. 846 * @param {Object} data of the document. 847 */ 848 function shivMethods(ownerDocument, data) { 849 if (!data.cache) { 850 data.cache = {}; 851 data.createElem = ownerDocument.createElement; 852 data.createFrag = ownerDocument.createDocumentFragment; 853 data.frag = data.createFrag(); 854 } 855 856 857 ownerDocument.createElement = function(nodeName) { 858 //abort shiv 859 if (!html5.shivMethods) { 860 return data.createElem(nodeName); 861 } 862 return createElement(nodeName, ownerDocument, data); 863 }; 864 865 ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' + 866 'var n=f.cloneNode(),c=n.createElement;' + 867 'h.shivMethods&&(' + 868 // unroll the `createElement` calls 869 getElements().join().replace(/[\w\-:]+/g, function(nodeName) { 870 data.createElem(nodeName); 871 data.frag.createElement(nodeName); 872 return 'c("' + nodeName + '")'; 873 }) + 874 ');return n}' 875 )(html5, data.frag); 876 } 877 878 /*--------------------------------------------------------------------------*/ 879 880 /** 881 * Shivs the given document. 882 * @memberOf html5 883 * @param {Document} ownerDocument The document to shiv. 884 * @returns {Document} The shived document. 885 */ 886 function shivDocument(ownerDocument) { 887 if (!ownerDocument) { 888 ownerDocument = document; 889 } 890 var data = getExpandoData(ownerDocument); 891 892 if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) { 893 data.hasCSS = !!addStyleSheet(ownerDocument, 894 // corrects block display not defined in IE6/7/8/9 895 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' + 896 // adds styling not present in IE6/7/8/9 897 'mark{background:#FF0;color:#000}' + 898 // hides non-rendered elements 899 'template{display:none}' 900 ); 901 } 902 if (!supportsUnknownElements) { 903 shivMethods(ownerDocument, data); 904 } 905 return ownerDocument; 906 } 907 908 /*--------------------------------------------------------------------------*/ 909 910 /** 911 * The `html5` object is exposed so that more elements can be shived and 912 * existing shiving can be detected on iframes. 913 * @type Object 914 * @example 915 * 916 * // options can be changed before the script is included 917 * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false }; 918 */ 919 var html5 = { 920 921 /** 922 * An array or space separated string of node names of the elements to shiv. 923 * @memberOf html5 924 * @type Array|String 925 */ 926 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video', 927 928 /** 929 * current version of html5shiv 930 */ 931 'version': version, 932 933 /** 934 * A flag to indicate that the HTML5 style sheet should be inserted. 935 * @memberOf html5 936 * @type Boolean 937 */ 938 'shivCSS': (options.shivCSS !== false), 939 940 /** 941 * Is equal to true if a browser supports creating unknown/HTML5 elements 942 * @memberOf html5 943 * @type boolean 944 */ 945 'supportsUnknownElements': supportsUnknownElements, 946 947 /** 948 * A flag to indicate that the document's `createElement` and `createDocumentFragment` 949 * methods should be overwritten. 950 * @memberOf html5 951 * @type Boolean 952 */ 953 'shivMethods': (options.shivMethods !== false), 954 955 /** 956 * A string to describe the type of `html5` object ("default" or "default print"). 957 * @memberOf html5 958 * @type String 959 */ 960 'type': 'default', 961 962 // shivs the document according to the specified `html5` object options 963 'shivDocument': shivDocument, 964 965 //creates a shived element 966 createElement: createElement, 967 968 //creates a shived documentFragment 969 createDocumentFragment: createDocumentFragment, 970 971 //extends list of elements 972 addElements: addElements 973 }; 974 975 /*--------------------------------------------------------------------------*/ 976 977 // expose html5 978 window.html5 = html5; 979 980 // shiv the document 981 shivDocument(document); 982 983 if(typeof module == 'object' && module.exports){ 984 module.exports = html5; 985 } 986 987}(typeof window !== "undefined" ? window : this, document));
988/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ 989 990window.matchMedia || (window.matchMedia = function() { 991 "use strict"; 992 993 // For browsers that support matchMedium api such as IE 9 and webkit 994 var styleMedia = (window.styleMedia || window.media); 995 996 // For those that don't support matchMedium 997 if (!styleMedia) { 998 var style = document.createElement('style'), 999 script = document.getElementsByTagName('script')[0], 1000 info = null; 1001 1002 style.type = 'text/css'; 1003 style.id = 'matchmediajs-test'; 1004 1005 script.parentNode.insertBefore(style, script); 1006 1007 // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers 1008 info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle; 1009 1010 styleMedia = { 1011 matchMedium: function(media) { 1012 var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }'; 1013 1014 // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers 1015 if (style.styleSheet) { 1016 style.styleSheet.cssText = text; 1017 } else { 1018 style.textContent = text; 1019 } 1020 1021 // Test if media query is true or false 1022 return info.width === '1px'; 1023 } 1024 }; 1025 } 1026 1027 return function(media) { 1028 return { 1029 matches: styleMedia.matchMedium(media || 'all'), 1030 media: media || 'all' 1031 }; 1032 }; 1033}()); 1034 1035/*! 1036 * The MIT License 1037 * 1038 * Copyright (c) 2012 James Allardice 1039 * 1040 * Permission is hereby granted, free of charge, to any person obtaining a copy 1041 * of this software and associated documentation files (the "Software"), to 1042 * deal in the Software without restriction, including without limitation the 1043 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 1044 * sell copies of the Software, and to permit persons to whom the Software is 1045 * furnished to do so, subject to the following conditions: 1046 * 1047 * The above copyright notice and this permission notice shall be included in 1048 * all copies or substantial portions of the Software. 1049 * 1050 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1051 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1052 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1053 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1054 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 1055 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 1056 * IN THE SOFTWARE. 1057 */ 1058 1059( function ( global ) { 1060 1061 'use strict'; 1062 1063 // 1064 // Test for support. We do this as early as possible to optimise for browsers 1065 // that have native support for the attribute. 1066 // 1067 1068 var test = document.createElement('input'); 1069 var nativeSupport = test.placeholder !== void 0; 1070 1071 global.Placeholders = { 1072 nativeSupport: nativeSupport, 1073 disable: nativeSupport ? noop : disablePlaceholders, 1074 enable: nativeSupport ? noop : enablePlaceholders 1075 }; 1076 1077 if ( nativeSupport ) { 1078 return; 1079 } 1080 1081 // 1082 // If we reach this point then the browser does not have native support for 1083 // the attribute. 1084 // 1085 1086 // The list of input element types that support the placeholder attribute.
1087 var validTypes = [ 1088 'text', 1089 'search', 1090 'url', 1091 'tel', 1092 'email', 1093 'password', 1094 'number', 1095 'textarea' 1096 ]; 1097 1098 // The list of keycodes that are not allowed when the polyfill is configured 1099 // to hide-on-input. 1100 var badKeys = [ 1101 1102 // The following keys all cause the caret to jump to the end of the input 1103 // value. 1104 1105 27, // Escape 1106 33, // Page up 1107 34, // Page down 1108 35, // End 1109 36, // Home 1110 1111 // Arrow keys allow you to move the caret manually, which should be 1112 // prevented when the placeholder is visible. 1113 1114 37, // Left 1115 38, // Up 1116 39, // Right 1117 40, // Down 1118 1119 // The following keys allow you to modify the placeholder text by removing 1120 // characters, which should be prevented when the placeholder is visible. 1121 1122 8, // Backspace 1123 46 // Delete 1124 ]; 1125 1126 // Styling variables. 1127 var placeholderStyleColor = '#ccc'; 1128 var placeholderClassName = 'placeholdersjs'; 1129 var classNameRegExp = new RegExp('(?:^|\\s)' + placeholderClassName + '(?!\\S)'); 1130 1131 // The various data-* attributes used by the polyfill. 1132 var ATTR_CURRENT_VAL = 'data-placeholder-value'; 1133 var ATTR_ACTIVE = 'data-placeholder-active'; 1134 var ATTR_INPUT_TYPE = 'data-placeholder-type'; 1135 var ATTR_FORM_HANDLED = 'data-placeholder-submit'; 1136 var ATTR_EVENTS_BOUND = 'data-placeholder-bound'; 1137 var ATTR_OPTION_FOCUS = 'data-placeholder-focus'; 1138 var ATTR_OPTION_LIVE = 'data-placeholder-live'; 1139 var ATTR_MAXLENGTH = 'data-placeholder-maxlength'; 1140 1141 // Various other variables used throughout the rest of the script. 1142 var UPDATE_INTERVAL = 100; 1143 var head = document.getElementsByTagName('head')[ 0 ]; 1144 var root = document.documentElement; 1145 var Placeholders = global.Placeholders; 1146 var keydownVal; 1147 1148 // Get references to all the input and textarea elements currently in the DOM 1149 // (live NodeList objects to we only need to do this once). 1150 var inputs = document.getElementsByTagName('input'); 1151 var textareas = document.getElementsByTagName('textarea'); 1152 1153 // Get any settings declared as data-* attributes on the root element. 1154 // Currently the only options are whether to hide the placeholder on focus 1155 // or input and whether to auto-update. 1156 var hideOnInput = root.getAttribute(ATTR_OPTION_FOCUS) === 'false'; 1157 var liveUpdates = root.getAttribute(ATTR_OPTION_LIVE) !== 'false'; 1158 1159 // Create style element for placeholder styles (instead of directly setting 1160 // style properties on elements - allows for better flexibility alongside 1161 // user-defined styles). 1162 var styleElem = document.createElement('style'); 1163 styleElem.type = 'text/css'; 1164 1165 // Create style rules as text node. 1166 var styleRules = document.createTextNode( 1167 '.' + placeholderClassName + ' {' + 1168 'color:' + placeholderStyleColor + ';' + 1169 '}' 1170 ); 1171 1172 // Append style rules to newly created stylesheet. 1173 if ( styleElem.styleSheet ) { 1174 styleElem.styleSheet.cssText = styleRules.nodeValue; 1175 } else { 1176 styleElem.appendChild(styleRules); 1177 } 1178 1179 // Prepend new style element to the head (before any existing stylesheets, 1180 // so user-defined rules take precedence). 1181 head.insertBefore(styleElem, head.firstChild); 1182 1183 // Set up the placeholders. 1184 var placeholder; 1185 var elem; 1186 1187 for ( var i = 0, len = inputs.length + textareas.length; i < len; i++ ) { 1188 1189 // Find the next element. If we've already done all the inputs we move on 1190 // to the textareas. 1191 elem = i < inputs.length ? inputs[ i ] : textareas[ i - inputs.length ]; 1192 1193 // Get the value of the placeholder attribute, if any. IE10 emulating IE7 1194 // fails with getAttribute, hence the use of the attributes node. 1195 placeholder = elem.attributes.placeholder; 1196 1197 // If the element has a placeholder attribute we need to modify it. 1198 if ( placeholder ) { 1199 1200 // IE returns an empty object instead of undefined if the attribute is 1201 // not present. 1202 placeholder = placeholder.nodeValue; 1203 1204 // Only apply the polyfill if this element is of a type that supports 1205 // placeholders and has a placeholder attribute with a non-empty value. 1206 if ( placeholder && inArray(validTypes, elem.type) ) { 1207 newElement(elem); 1208 } 1209 } 1210 } 1211 1212 // If enabled, the polyfill will repeatedly check for changed/added elements 1213 // and apply to those as well. 1214 var timer = setInterval(function () {
1215 for ( var i = 0, len = inputs.length + textareas.length; i < len; i++ ) { 1216 elem = i < inputs.length ? inputs[ i ] : textareas[ i - inputs.length ]; 1217 1218 // Only apply the polyfill if this element is of a type that supports 1219 // placeholders, and has a placeholder attribute with a non-empty value. 1220 placeholder = elem.attributes.placeholder; 1221 1222 if ( placeholder ) { 1223 1224 placeholder = placeholder.nodeValue; 1225 1226 if ( placeholder && inArray(validTypes, elem.type) ) { 1227 1228 // If the element hasn't had event handlers bound to it then add 1229 // them. 1230 if ( !elem.getAttribute(ATTR_EVENTS_BOUND) ) { 1231 newElement(elem); 1232 } 1233 1234 // If the placeholder value has changed or not been initialised yet 1235 // we need to update the display. 1236 if ( 1237 placeholder !== elem.getAttribute(ATTR_CURRENT_VAL) || 1238 ( elem.type === 'password' && !elem.getAttribute(ATTR_INPUT_TYPE) ) 1239 ) { 1240 1241 // Attempt to change the type of password inputs (fails in IE < 9). 1242 if ( 1243 elem.type === 'password' && 1244 !elem.getAttribute(ATTR_INPUT_TYPE) && 1245 changeType(elem, 'text') 1246 ) { 1247 elem.setAttribute(ATTR_INPUT_TYPE, 'password'); 1248 } 1249 1250 // If the placeholder value has changed and the placeholder is 1251 // currently on display we need to change it. 1252 if ( elem.value === elem.getAttribute(ATTR_CURRENT_VAL) ) { 1253 elem.value = placeholder; 1254 } 1255 1256 // Keep a reference to the current placeholder value in case it 1257 // changes via another script. 1258 elem.setAttribute(ATTR_CURRENT_VAL, placeholder); 1259 } 1260 } 1261 } else if ( elem.getAttribute(ATTR_ACTIVE) ) { 1262 hidePlaceholder(elem); 1263 elem.removeAttribute(ATTR_CURRENT_VAL); 1264 } 1265 } 1266 1267 // If live updates are not enabled cancel the timer. 1268 if ( !liveUpdates ) { 1269 clearInterval(timer); 1270 } 1271 }, UPDATE_INTERVAL); 1272 1273 // Disabling placeholders before unloading the page prevents flash of 1274 // unstyled placeholders on load if the page was refreshed. 1275 addEventListener(global, 'beforeunload', function () { 1276 Placeholders.disable(); 1277 }); 1278 1279 // 1280 // Utility functions 1281 // 1282 1283 // No-op (used in place of public methods when native support is detected). 1284 function noop() {} 1285 1286 // Avoid IE9 activeElement of death when an iframe is used. 1287 // 1288 // More info: 1289 // - http://bugs.jquery.com/ticket/13393 1290 // - https://github.com/jquery/jquery/commit/85fc5878b3c6af73f42d61eedf73013e7faae408 1291 function safeActiveElement() { 1292 try { 1293 return document.activeElement; 1294 } catch ( err ) {} 1295 } 1296 1297 // Check whether an item is in an array. We don't use Array.prototype.indexOf 1298 // so we don't clobber any existing polyfills. This is a really simple 1299 // alternative. 1300 function inArray( arr, item ) { 1301 for ( var i = 0, len = arr.length; i < len; i++ ) { 1302 if ( arr[ i ] === item ) { 1303 return true; 1304 } 1305 } 1306 return false; 1307 } 1308 1309 // Cross-browser DOM event binding 1310 function addEventListener( elem, event, fn ) { 1311 if ( elem.addEventListener ) { 1312 return elem.addEventListener(event, fn, false); 1313 } 1314 if ( elem.attachEvent ) { 1315 return elem.attachEvent('on' + event, fn); 1316 } 1317 } 1318 1319 // Move the caret to the index position specified. Assumes that the element 1320 // has focus. 1321 function moveCaret( elem, index ) { 1322 var range; 1323 if ( elem.createTextRange ) { 1324 range = elem.createTextRange(); 1325 range.move('character', index); 1326 range.select(); 1327 } else if ( elem.selectionStart ) { 1328 elem.focus(); 1329 elem.setSelectionRange(index, index); 1330 } 1331 } 1332 1333 // Attempt to change the type property of an input element. 1334 function changeType( elem, type ) { 1335 try { 1336 elem.type = type; 1337 return true; 1338 } catch ( e ) { 1339 // You can't change input type in IE8 and below. 1340 return false; 1341 } 1342 } 1343 1344 function handleElem( node, callback ) { 1345 1346 // Check if the passed in node is an input/textarea (in which case it can't 1347 // have any affected descendants). 1348 if ( node && node.getAttribute(ATTR_CURRENT_VAL) ) { 1349 callback(node); 1350 } else { 1351 1352 // If an element was passed in, get all affected descendants. Otherwise, 1353 // get all affected elements in document. 1354 var handleInputs = node ? node.getElementsByTagName('input') : input
1354s; 1355 var handleTextareas = node ? node.getElementsByTagName('textarea') : textareas; 1356 1357 var handleInputsLength = handleInputs ? handleInputs.length : 0; 1358 var handleTextareasLength = handleTextareas ? handleTextareas.length : 0; 1359 1360 // Run the callback for each element. 1361 var len = handleInputsLength + handleTextareasLength; 1362 var elem; 1363 for ( var i = 0; i < len; i++ ) { 1364 1365 elem = i < handleInputsLength ? 1366 handleInputs[ i ] : 1367 handleTextareas[ i - handleInputsLength ]; 1368 1369 callback(elem); 1370 } 1371 } 1372 } 1373 1374 // Return all affected elements to their normal state (remove placeholder 1375 // value if present). 1376 function disablePlaceholders( node ) { 1377 handleElem(node, hidePlaceholder); 1378 } 1379 1380 // Show the placeholder value on all appropriate elements. 1381 function enablePlaceholders( node ) { 1382 handleElem(node, showPlaceholder); 1383 } 1384 1385 // Hide the placeholder value on a single element. Returns true if the 1386 // placeholder was hidden and false if it was not (because it wasn't visible 1387 // in the first place). 1388 function hidePlaceholder( elem, keydownValue ) { 1389 1390 var valueChanged = !!keydownValue && elem.value !== keydownValue; 1391 var isPlaceholderValue = elem.value === elem.getAttribute(ATTR_CURRENT_VAL); 1392 1393 if ( 1394 ( valueChanged || isPlaceholderValue ) && 1395 elem.getAttribute(ATTR_ACTIVE) === 'true' 1396 ) { 1397 1398 elem.removeAttribute(ATTR_ACTIVE); 1399 elem.value = elem.value.replace(elem.getAttribute(ATTR_CURRENT_VAL), ''); 1400 elem.className = elem.className.replace(classNameRegExp, ''); 1401 1402 // Restore the maxlength value. Old FF returns -1 if attribute not set. 1403 // See GH-56. 1404 var maxLength = elem.getAttribute(ATTR_MAXLENGTH); 1405 if ( parseInt(maxLength, 10) >= 0 ) { 1406 elem.setAttribute('maxLength', maxLength); 1407 elem.removeAttribute(ATTR_MAXLENGTH); 1408 } 1409 1410 // If the polyfill has changed the type of the element we need to change 1411 // it back. 1412 var type = elem.getAttribute(ATTR_INPUT_TYPE); 1413 if ( type ) { 1414 elem.type = type; 1415 } 1416 1417 return true; 1418 } 1419 1420 return false; 1421 } 1422 1423 // Show the placeholder value on a single element. Returns true if the 1424 // placeholder was shown and false if it was not (because it was already 1425 // visible). 1426 function showPlaceholder( elem ) { 1427 1428 var val = elem.getAttribute(ATTR_CURRENT_VAL); 1429 1430 if ( elem.value === '' && val ) { 1431 1432 elem.setAttribute(ATTR_ACTIVE, 'true'); 1433 elem.value = val; 1434 elem.className += ' ' + placeholderClassName; 1435 1436 // Store and remove the maxlength value. 1437 var maxLength = elem.getAttribute(ATTR_MAXLENGTH); 1438 if ( !maxLength ) { 1439 elem.setAttribute(ATTR_MAXLENGTH, elem.maxLength); 1440 elem.removeAttribute('maxLength'); 1441 } 1442 1443 // If the type of element needs to change, change it (e.g. password 1444 // inputs). 1445 var type = elem.getAttribute(ATTR_INPUT_TYPE); 1446 if ( type ) { 1447 elem.type = 'text'; 1448 } else if ( elem.type === 'password' && changeType(elem, 'text') ) { 1449 elem.setAttribute(ATTR_INPUT_TYPE, 'password'); 1450 } 1451 1452 return true; 1453 } 1454 1455 return false; 1456 } 1457 1458 // Returns a function that is used as a focus event handler. 1459 function makeFocusHandler( elem ) { 1460 return function () { 1461 1462 // Only hide the placeholder value if the (default) hide-on-focus 1463 // behaviour is enabled. 1464 if ( 1465 hideOnInput && 1466 elem.value === elem.getAttribute(ATTR_CURRENT_VAL) && 1467 elem.getAttribute(ATTR_ACTIVE) === 'true' 1468 ) { 1469 1470 // Move the caret to the start of the input (this mimics the behaviour 1471 // of all browsers that do not hide the placeholder on focus). 1472 moveCaret(elem, 0); 1473 } else { 1474 1475 // Remove the placeholder. 1476 hidePlaceholder(elem); 1477 } 1478 }; 1479 } 1480 1481 // Returns a function that is used as a blur event handler. 1482 function makeBlurHandler( elem ) { 1483 return function () { 1484 showPlaceholder(elem); 1485 }; 1486 } 1487 1488 // Returns a function that is used as a submit event handler on form elements 1489 // that have children affected by this polyfill. 1490 function makeSubmitHandler( form ) { 1491 return function () { 1492 1493 // Turn off placeholders on all appropriate descendant elements. 1494 disablePlaceholders(form); 1495 }; 1496 } 1497 1498 // Functions that are used as a event handlers when the hide-on-input 1499 // behaviour has been activated - very basic implementation of the 'input' 1500 // event. 1501 function makeKeydownHandler( elem ) { 1502 return function ( e ) { 1503 keydownVal = elem.value; 1504 1505 // Prevent the use of the arrow keys (try to keep the cursor before the 1506 // placeholder). 1507 if ( 1508 elem.getAttribute(ATTR_ACTIVE) === 'true' && 1509 keydownVal === elem.getAttribute(ATTR_CURRENT_VAL) && 1510 inArray(badKeys, e.keyCode) 1511 ) { 1512 if ( e.preventDefault ) { 1513 e.preventDefault(); 1514 } 1515 return false;
1516 } 1517 }; 1518 } 1519 1520 function makeKeyupHandler(elem) { 1521 return function () { 1522 hidePlaceholder(elem, keydownVal); 1523 1524 // If the element is now empty we need to show the placeholder 1525 if ( elem.value === '' ) { 1526 elem.blur(); 1527 moveCaret(elem, 0); 1528 } 1529 }; 1530 } 1531 1532 function makeClickHandler(elem) { 1533 return function () { 1534 if ( 1535 elem === safeActiveElement() && 1536 elem.value === elem.getAttribute(ATTR_CURRENT_VAL) && 1537 elem.getAttribute(ATTR_ACTIVE) === 'true' 1538 ) { 1539 moveCaret(elem, 0); 1540 } 1541 }; 1542 } 1543 1544 // Bind event handlers to an element that we need to affect with the 1545 // polyfill. 1546 function newElement( elem ) { 1547 1548 // If the element is part of a form, make sure the placeholder string is 1549 // not submitted as a value. 1550 var form = elem.form; 1551 if ( form && typeof form === 'string' ) { 1552 1553 // Get the real form. 1554 form = document.getElementById(form); 1555 1556 // Set a flag on the form so we know it's been handled (forms can contain 1557 // multiple inputs). 1558 if ( !form.getAttribute(ATTR_FORM_HANDLED) ) { 1559 addEventListener(form, 'submit', makeSubmitHandler(form)); 1560 form.setAttribute(ATTR_FORM_HANDLED, 'true'); 1561 } 1562 } 1563 1564 // Bind event handlers to the element so we can hide/show the placeholder 1565 // as appropriate. 1566 addEventListener(elem, 'focus', makeFocusHandler(elem)); 1567 addEventListener(elem, 'blur', makeBlurHandler(elem)); 1568 1569 // If the placeholder should hide on input rather than on focus we need 1570 // additional event handlers 1571 if (hideOnInput) { 1572 addEventListener(elem, 'keydown', makeKeydownHandler(elem)); 1573 addEventListener(elem, 'keyup', makeKeyupHandler(elem)); 1574 addEventListener(elem, 'click', makeClickHandler(elem)); 1575 } 1576 1577 // Remember that we've bound event handlers to this element. 1578 elem.setAttribute(ATTR_EVENTS_BOUND, 'true'); 1579 elem.setAttribute(ATTR_CURRENT_VAL, placeholder); 1580 1581 // If the element doesn't have a value and is not focussed, set it to the 1582 // placeholder string. 1583 if ( hideOnInput || elem !== safeActiveElement() ) { 1584 showPlaceholder(elem); 1585 } 1586 } 1587 1588}(this) ); 1589// IE spupport comes in IE10 1590(function rAFPolyfill() { 1591 var lastTime, vendors, x; 1592 lastTime = 0; 1593 vendors = ["webkit", "moz"]; 1594 x = 0; 1595 while (x < vendors.length && !window.requestAnimationFrame) { 1596 window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"]; 1597 window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"]; 1598 ++x; 1599 } 1600 if (!window.requestAnimationFrame) { 1601 window.requestAnimationFrame = function(callback, element) { 1602 var currTime, id, timeToCall; 1603 currTime = new Date().getTime(); 1604 timeToCall = Math.max(0, 16 - (currTime - lastTime)); 1605 id = window.setTimeout(function() { 1606 callback(currTime + timeToCall); 1607 }, timeToCall); 1608 lastTime = currTime + timeToCall; 1609 return id; 1610 }; 1611 } 1612 if (!window.cancelAnimationFrame) { 1613 window.cancelAnimationFrame = function(id) { 1614 clearTimeout(id); 1615 }; 1616 } 1617})(); 1618 1619 1620 1621(function($) { 1622 'use strict'; 1623 1624 var MK = window.MK || {}; 1625 1626 /** 1627 * MK.core holds most important methods that bootstraps whole application 1628 * 1629 * @type {Object} 1630 */ 1631 MK.core = {}; 1632 1633 1634 1635 /** 1636 * State for referance of already loaded script files 1637 * @type {Array} 1638 */ 1639 var _loadedDependencies = []; 1640 1641 /** 1642 * State of queue represented as pairs of script ref => callback 1643 * @type {Object} 1644 */ 1645 var _inQueue = {}; 1646 1647 /** 1648 * Initializes all components in given scope (object or DOM reference) based on data attribute and 'pointer' css class '.js-el'. 1649 * DOM work is reduced by single traversing for pointer class and later filtering through cached object. It expects init() method 1650 * on every component. Component itself should be defined in MK.component namespace and assign to DOM element via data-mk-component. 1651 * Use it once on DOM ready with document as a scope. For partial initialization after aja
1651x operations pass as a scope element 1652 * where new DOM was inserted. 1653 * 1654 * @param {string|object} 1655 */ 1656 MK.core.initAll = function( scope ) { 1657 var $el = $( scope ).find( '.js-el' ), // single traversing 1658 $components = $el.filter( '[data-mk-component]' ), 1659 component = null; 1660 1661 1662 // initialize component 1663 var init = function init(name, el) { 1664 var $el = $(el); 1665 1666 if( $el.data('init-' + name) ) return; // do not initialize the same module twice 1667 1668 if( typeof MK.component[ name ] !== 'function' ) console.log('Component init error: ', name); 1669 1670 component = new MK.component[ name ]( el ); 1671 component.init(); 1672 $el.data('init-' + name, true); // mark as initialised 1673 1674 // TODO add name 1675 MK.utils.eventManager.publish('component-inited'); 1676 }; 1677 1678 $components.each( function() { 1679 var self = this, 1680 $this = $( this ), 1681 names = $this.data( 'mk-component' ); 1682 1683 if( typeof names === 'string' ) { 1684 var name = names; // containes only single name. Keep it transparent. 1685 init(name, self); 1686 } else { 1687 names.forEach( function( name ) { 1688 init(name, self); 1689 }); 1690 } 1691 }); 1692 }; 1693 1694 /** 1695 * Async loader for 3rd party plugins available from within theme or external CDNs / APIs. 1696 * Take one argument as callback which is run when loading is finished. Also keeps track of already loaded scripts 1697 * and prevent duplication. Holds in queue multiple callbacks that where defined in different places but depend on the 1698 * same plugin. 1699 * 1700 * TODO: heavy test for multiple dependencies and crosssharing one dependency and different one dependency in queue, 1701 * bulletproof with single dependency 1702 * 1703 * @example MK.core.loadDependencies([MK.core.path.plugins + 'plugin.js'], function() { 1704 * // do something when plugin is loaded 1705 * }) 1706 * 1707 * @param {array} 1708 * @param {function} 1709 */ 1710 MK.core.loadDependencies = function( dependencies, callback ) { 1711 var _callback = callback || function() {}; 1712 1713 if( !dependencies ) { 1714 // If no dependencies defined then run _callback imidietelly 1715 _callback(); 1716 return; 1717 } 1718 1719 // Check for new dependencies 1720 var newDeps = dependencies.map( function( dep ) { 1721 if( _loadedDependencies.indexOf( dep ) === -1 ) { 1722 if( typeof _inQueue[ dep ] === 'undefined' ) { 1723 // console.log( dep ); 1724 return dep; 1725 } else { 1726 _inQueue[ dep ].push( _callback ); 1727 return true; 1728 } 1729 } else { 1730 return false; 1731 } 1732 }); 1733 1734 // The dependency is not new but it's not resolved yet 1735 // Callback is added to queue that will be run after the script is loaded 1736 // Don't run callback just yet. 1737 if( newDeps[0] === true ) {
1738 // console.log('Waiting for ' + dependencies[0]); 1739 return; 1740 } 1741 1742 // Dependency was loaded previously. We can run callback safely 1743 if( newDeps[0] === false ) { 1744 _callback(); 1745 return; 1746 } 1747 1748 // Create queue and relationship script -> callback array to track 1749 // all callbacks that waits for ths script 1750 var queue = newDeps.map( function( script ) { 1751 // console.log( script ); 1752 _inQueue[ script ] = [ _callback ]; 1753 return $.getCachedScript( script ); 1754 }); 1755 1756 // Callbacks invoking 1757 var onLoad = function onLoad() { 1758 var index; 1759 newDeps.map( function( loaded ) { 1760 _inQueue[ loaded ].forEach( function( callback ) { 1761 callback(); 1762 }); 1763 delete _inQueue[ loaded ]; 1764 _loadedDependencies.push( loaded ); 1765 }); 1766 }; 1767 1768 // Run callbacks when promise is resolved 1769 $.when.apply( null, queue ).done( onLoad ); 1770 }; 1771 1772 /** 1773 * Single namespace for all paths recuired in application. 1774 * @type {Object} 1775 */ 1776 MK.core.path = { 1777 plugins: mk_theme_js_path + '/plugins/async/min/', 1778 ajaxUrl: window.PHP.ajax 1779 }; 1780 1781 1782})(jQuery); 1783(function($) { 1784 'use strict'; 1785 1786 var MK = window.MK || {}; 1787 MK.utils = window.MK.utils || {}; 1788 1789 /** 1790 * Enables to evaluate common methods through DOM JSON references by invoking from object with bracket notation MK.utils[var][var] 1791 * @type {Object} 1792 */ 1793 MK.utils.actions = {}; 1794 1795 MK.utils.actions.activate = function (el) { 1796 $(el).addClass('is-active'); 1797 }; 1798 1799 MK.utils.actions.deactivate = function (el) { 1800 $(el).removeClass('is-active'); 1801 }; 1802 1803}(jQuery)); 1804(function($) { 1805 'use strict'; 1806 1807 var MK = window.MK || {}; 1808 MK.utils = window.MK.utils || {}; 1809 1810 /** 1811 * Gets user browser and its version 1812 * @return {Object} => {name, version} 1813 */ 1814 MK.utils.browser = (function() { 1815 var dataBrowser = [ 1816 {string: navigator.userAgent, subString: "Edge", identity: "Edge"}, 1817 {string: navigator.userAgent, subString: "Chrome", identity: "Chrome"}, 1818 {string: navigator.userAgent, subString: "MSIE", identity: "IE"}, 1819 {string: navigator.userAgent, subString: "Trident", identity: "IE"}, 1820 {string: navigator.userAgent, subString: "Firefox", identity: "Firefox"}, 1821 {string: navigator.userAgent, subString: "Safari", identity: "Safari"}, 1822 {string: navigator.userAgent, subString: "Opera", identity: "Opera"} 1823 ]; 1824 1825 var versionSearchString = null; 1826 var searchString = function (data) { 1827 for (var i = 0; i < data.length; i++) { 1828 var dataString = data[i].string; 1829 versionSearchString = data[i].subString; 1830 1831 if (dataString.indexOf(data[i].subString) !== -1) { 1832 return data[i].identity; 1833 } 1834 } 1835 }; 1836 1837 var searchVersion = function (dataString) { 1838 var index = dataString.indexOf(versionSearchString); 1839 if (index === -1) { 1840 return; 1841 } 1842 1843 var rv = dataString.indexOf("rv:"); 1844 if (versionSearchString === "Trident" && rv !== -1) { 1845 return parseFloat(dataString.substring(rv + 3)); 1846 } else { 1847 return parseFloat(dataString.substring(index + versionSearchString.length + 1)); 1848 } 1849 }; 1850 1851 var name = searchString(dataBrowser) || "Other"; 1852 var version = searchVersion(navigator.userAgent) || searchVersion(navigator.appVersion) || "Unknown"; 1853 1854 // Expose for css 1855 $('html').addClass(name).addClass(name + version); 1856 1857 1858 return { 1859 name : name, 1860 version : version 1861 }; 1862 1863 })(); 1864 1865 /** 1866 * Gets user operating system 1867 * @return {String} 1868 */ 1869 MK.utils.OS = (function() { 1870 if (navigator.appVersion.indexOf("Win")!=-1) return "Windows"; 1871 if (navigator.appVersion.indexOf("Mac")!=-1) return "OSX"; 1872 if (navigator.appVersion.indexOf("X11")!=-1) return "UNIX"; 1873 if (navigator.appVersion.indexOf("Linux")!=-1) return "Linux"; 1874 })(); 1875 1876 /** 1877 * Check if mobile device. 1878 * @return {Boolean} 1879 */ 1880 MK.utils.isMobile = function() { 1881 // Problems with bigger tablets as users raport differences with behaviour. Switch to navigator sniffing 1882 // return ('ontouchstart' in document.documentElement) && matchMedia( '(max-width: 1024px)' ).matches; 1883 1884 // http://www.abeautifulsite.net/detecting-mobile-devices-with-javascript/ 1885 // if it still brings problem try to move to more sophisticated solution like 1886 // apachemobilefilter.org 1887 // detectright.com 1888 // web.wurfl.io 1889 // 1890 // Seems as best solution here: 1891 // hgoebl.github.io/mobile-detect.js 1892 1893 function android() { 1894 return navigator.userAgent.match(/Android/i); 1895 } 1896 1897 function blackBerry() { 1898 return navigator.userAgent.match(/BlackBerry/i); 1899 } 1900 1901 function iOS() { 1902 return navigator.userAgent.match(/iPhone|iPad|iPod/i); 1903 } 1904 1905 function opera() { 1906 return navigator.userAgent.match(/Opera Mini/i); 1907 } 1908 1909 function windows() { 1910 return navigator.userAgent.match(/IEMobile/i); 1911 } 1912 1913 return (android() || blackBerry() || iOS() || opera() || windows() || matchMedia( '(max-width: 1024px)' ).matches); 1914 1915 }; 1916 1917 /** 1918 * Check if menu is switched to responsive state based on user width settings 1919 * @return {Boolean} 1920 */ 1921 MK.utils.isResponsiveMenuState = function() { 1922 return window.matchMedia( '(max-width: '+ mk_responsive_nav_width +'px)').matches; 1923 }; 1924 1925 1926 1927 MK.utils.getUrlParameter = function getUrlParameter(sParam) { 1928 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 1929 sURLVariables = sPageURL.split('&'), 1930 sParameterName, 1931 i; 1932 1933 for (i = 0; i < sURLVariables.length; i++) { 1934 sParameterName = sURLVariables[i].split('='); 1935 1936 if (sParameterName[0] === sParam) { 1937 return sParameterName[1] === undefined ? true : sParameterName[1]; 1938 } 1939 } 1940 }; 1941 1942 1943 MK.utils.isSmoothScroll = (function() { 1944 var isSafari = (MK.utils.browser.name === "Safari"); 1945 var isUserChoice = (mk_smooth_scroll === 'true'); 1946 1947 // We notify our app about smooth scroll option when user choose it from admin panel and current browser is not safari. 1948 // Safari has waterfall of events that will block our event loop and make page unresponsive. 1949 // It's better to strip it from effects rather than keep it not usable 1950 return isUserChoice && !isSafari; 1951 }()); 1952 1953}(jQuery)); 1954(function($) { 1955 'use strict'; 1956 1957 var MK = window.MK || {}; 1958 MK.utils = window.MK.utils || {}; 1959 1960 /** 1961 * Basic implementation of pub / sub pattern to avoid tight coupling with direct module communication 1962 * @type {Object} 1963 */ 1964 MK.utils.eventManager = {}; 1965 1966 /** 1967 * Subscribe to custom event and run callbacks 1968 * @param {String} 1969 * @param {Function} 1970 * 1971 * @usage MK.utils.eventManager.subscribe('event', function(e, params) {} ) 1972 */ 1973 MK.utils.eventManager.subscribe = function(evt, func) { 1974 $(this).on(evt, func); 1975 }; 1976 1977 /** 1978 * Unsubscribe from custom event 1979 * @param {String} 1980 * @param {Function} 1981 */ 1982 MK.utils.eventManager.unsubscribe = function(evt, func) { 1983 $(this).off(evt, func); 1984 }; 1985 1986 /** 1987 * Publish custom event to notify appliaction about state change 1988 * @param {String} 1989 * 1990 * @usage MK.utils.eventManager.publish('event', { 1991 * param: val 1992 * }) 1993 */ 1994 MK.utils.eventManager.publish = function(evt, params) { 1995 $(this).trigger(evt, [params]); 1996 }; 1997 1998}(jQuery)); 1999(function($) { 2000 'use strict'; 2001 2002 var MK = window.MK || {}; 2003 MK.utils = window.MK.utils || {}; 2004 2005 /** 2006 * Control browser fullscreen mode 2007 * @type {Object} 2008 */ 2009 MK.utils.fullscreen = {}; 2010 2011 // TODO: move to namespace 2012 MK.utils.launchIntoFullscreen = function ( element ) { 2013 if(element.requestFullscreen) { 2014 element.requestFullscreen(); 2015 } else if(element.mozRequestFullScreen) { 2016 element.mozRequestFullScreen(); 2017 } else if(element.webkitRequestFullscreen) { 2018 element.webkitRequestFullscreen(); 2019 } else if(element.msRequestFullscreen) { 2020 element.msRequestFullscreen(); 2021 } 2022 }; 2023 2024 MK.utils.exitFullscreen = function () { 2025 if(document.exitFullscreen) { 2026 document.exitFullscreen(); 2027 } else if(document.mozCancelFullScreen) { 2028 document.mozCancelFullScreen(); 2029 } else if(document.webkitExitFullscreen) { 2030 document.webkitExitFullscreen(); 2031 } 2032 }; 2033 2034}(jQuery)); 2035(function($) { 2036 'use strict'; 2037 2038 var MK = window.MK || {}; 2039 MK.utils = window.MK.utils || {}; 2040 2041 MK.utils.misc = {}; 2042 // TODO: move to namespace 2043 2044 /** 2045 * Get all top offsets from jQuery collection 2046 * 2047 * @param {$Objects} 2048 * @return {Aray} 2049 */ 2050 MK.utils.offsets = function( $els ) { 2051 return $.map( $els, function( el ) { 2052 return $( el ).offset().top; 2053 }); 2054 }; 2055 2056 /** 2057 * Retrive from array of numbers first number that is higher than given parameter 2058 * 2059 * @param {Number} 2060 * @param {Array} 2061 * @return {Number} 2062 */ 2063 MK.utils.nextHigherVal = function( val, arr ) { 2064 var i = 0, 2065 higher = null; 2066 2067 var check = function() { 2068 if( val > arr[ i ]) { 2069 i += 1; 2070 check(); 2071 } else { 2072 higher = arr[ i ]; 2073 } 2074 }; 2075 check(); 2076 2077 return higher; 2078 }; 2079 2080 2081 MK.utils.throttle = function( delay, fn ) { 2082 var last; 2083 var deferTimer; 2084 2085 return function() { 2086 var context = this; 2087 var args = arguments; 2088 var now = +new Date; 2089 if( last && now < last + delay ) { 2090 clearTimeout( deferTimer ); 2091 deferTimer = setTimeout( function() { 2092 last = now; fn.apply( context, args ); 2093 }, delay ); 2094 } else { 2095 last = now; 2096 fn.apply( context, args ); 2097 } 2098 }; 2099 }; 2100 2101})(jQuery); 2102(function($) { 2103 'use strict'; 2104 2105 var MK = window.MK || {}; 2106 MK.utils = window.MK.utils || {}; 2107 2108 /** 2109 * Scrolls page to static pixel offset 2110 * @param {Number} 2111 */ 2112 MK.utils.scrollTo = function( offset ) { 2113 $('html, body').stop().animate({ 2114 scrollTop: offset 2115 }, { 2116 duration: 1200, 2117 easing: "easeInOutExpo" 2118 }); 2119 }; 2120 2121 /** 2122 * Scrolls to element passed in as object or DOM reference 2123 * @param {String|Object} 2124 */ 2125 MK.utils.scrollToAnchor = function( hash ) { 2126 var $target = $( hash ); 2127 // console.log( hash ); 2128 2129 if( ! $target.length ) return; 2130 2131 var offset = $target.offset().top; 2132 offset = offset - MK.val.offsetHeaderHeight( offset ); 2133 2134 if( hash === '#top-of-page' ) window.history.replaceState( undefined, undefined, ' ' ); 2135 else window.history.replaceState( undefined, undefined, hash ); 2136 2137 MK.utils.scrollTo( offset ); 2138 }; 2139 2140 /** 2141 * Controls native scroll behaviour 2142 * @return {Object} => {disable, enable} 2143 */ 2144 MK.utils.scroll = (function() { 2145 // 37 - left arror, 38 - up arrow, 39 right arrow, 40 down arrow 2146 var keys = [38, 40]; 2147 2148 function preventDefault(e) { 2149 e = e || window.event; 2150 e.preventDefault(); 2151 e.returnValue = false; 2152 } 2153 2154 function wheel(e) { 2155 preventDefault(e); 2156 } 2157 2158 function keydown(e) { 2159 for (var i = keys.length; i--;) { 2160 if (e.keyCode === keys[i]) { 2161 preventDefault(e); 2162 return; 2163 } 2164 } 2165 } 2166 2167 function disableScroll() { 2168 if (window.addEventListener) { 2169 window.addEventListener('DOMMouseScroll', wheel, false); 2170 } 2171 window.onmousewheel = document.onmousewheel = wheel; 2172 document.onkeydown = keydown; 2173 } 2174 2175 function enableScroll() { 2176 if (window.removeEventListener) { 2177 window.removeEventListener('DOMMouseScroll', wheel, false); 2178 } 2179 window.onmousewheel = document.onmousewheel = document.onkeydown = null; 2180 } 2181 2182 return { 2183 disable : disableScroll, 2184 enable : enableScroll 2185 }; 2186 2187 })(); 2188 2189 /** 2190 * Checks if passed link element has anchor inside current page. Returns string like '#anchor' if so or false 2191 * @param {String|Object} 2192 * @return {String|Boolean} 2193 */ 2194 MK.utils.detectAnchor = function( el ) { 2195 var $this = $( el ), 2196 loc = window.location, 2197 currentPage = loc.origin + loc.pathname, 2198 href = $this.attr( 'href' ), 2199 linkSplit = (href) ? href.split( '#' ) : '', 2200 hrefPage = linkSplit[0] ? linkSplit[0] : '', 2201 hrefHash = linkSplit[1] ? linkSplit[1] : ''; 2202 2203 if( (hrefPage === currentPage || hrefPage === '') && typeof hrefHash !== 'undefined' && hrefHash !== '' ) { 2204 return '#' + hrefHash; 2205 } else { 2206 return false;
2207 } 2208 }; 2209 2210 /** 2211 * This should be invoked only on page load. 2212 * Scrolls to anchor from address bar 2213 */ 2214 MK.utils.scrollToURLHash = function() { 2215 var loc = window.location, 2216 hash = loc.hash; 2217 2218 if ( hash.length && hash.substring(1).length ) { 2219 // !loading is added early after DOM is ready to prevent native jump to anchor 2220 hash = hash.replace( '!loading', '' ); 2221 2222 // Wait for one second before animating 2223 // Most of UI animations should be done by then and async operations complited 2224 setTimeout( function() { 2225 MK.utils.scrollToAnchor( hash ); 2226 }, 1000 ); 2227 2228 // Right after reset back address bar 2229 setTimeout( function() { 2230 window.history.replaceState(undefined, undefined, hash); 2231 }, 1001); 2232 } 2233 }; 2234 2235 /** 2236 * Scroll Spy implementation. Spy dynamic offsets of elements or static pixel offset 2237 * @param {Number|Element} 2238 * @param {Object} => callback object {before, active, after} 2239 */ 2240 MK.utils.scrollSpy = function( toSpy, config ) { 2241 var $window = $( window ), 2242 container = document.getElementById( 'mk-theme-container' ), 2243 isObj = ( typeof toSpy === 'object' ), 2244 offset = (isObj) ? MK.val.dynamicOffset( toSpy, config.position, config.threshold ) : function() { return toSpy; }, 2245 height = (isObj) ? MK.val.dynamicHeight( toSpy ) : function() { return 0; }, 2246 cacheVals = {}, 2247 _p = 'before'; // current position 2248 2249 var checkPosition = function() { 2250 var s = MK.val.scroll(), 2251 o = offset(), 2252 h = height(); 2253 2254 if( s < o && _p !== 'before' ) { 2255 // console.log( toSpy, 'before' ); 2256 if( config.before ) config.before(); 2257 _p = 'before'; 2258 } 2259 else if( s >= o && s <= o + h && _p !== 'active' ) { 2260 // console.log( toSpy, 'active' ); 2261 if( config.active ) config.active( o ); 2262 _p = 'active'; 2263 } 2264 else if( s > o + h && _p !== 'after' ) { 2265 // console.log( toSpy, 'after' ); 2266 if( config.after) config.after( o + h ); 2267 _p = 'after'; 2268 } 2269 }; 2270 2271 var rAF = function() { 2272 window.requestAnimationFrame( checkPosition ); 2273 }; 2274 2275 var exportVals = function() { 2276 return cacheVals; 2277 }; 2278 2279 var updateCache = function() { 2280 var o = offset(), 2281 h = height(); 2282 2283 cacheVals = { 2284 before : o - $window.height(), 2285 active : o, 2286 after : o + h 2287 }; 2288 }; 2289 2290 if( config.cache ) { 2291 config.cache( exportVals ); 2292 } 2293 2294 checkPosition(); 2295 $window.on( 'load', checkPosition ); 2296 $window.on( 'resize', checkPosition ); 2297 $window.on( 'mouseup', checkPosition ); 2298 window.addResizeListener( container, checkPosition ); 2299 2300 $window.on( 'scroll', rAF ); 2301 2302 updateCache(); 2303 $window.on( 'load', updateCache ); 2304 $window.on( 'resize', updateCache ); 2305 window.addResizeListener( container, updateCache ); 2306 }; 2307 2308}(jQuery)); 2309(function($) { 2310 'use strict'; 2311 2312 // Create delagation event handler to behave as "live" listener. We may provide new elements with ajax etc later 2313 // Just add js-taphover class whatever element you'd like to immidietely bring hover on touch devices 2314 $("body").on("touchstart", '.js-taphover', function (e) { 2315 var $link = $(e.currentTarget); // grab target 2316 2317 // Rather than ":hover" state we operate on ".hover" class which gives us more control and chance to emulate it on touchstart 2318 // yet it is easy to reason about in our CSS 2319 if ($link.hasClass('hover')) { 2320 return true; 2321 } else { 2322 $link.addClass('hover'); 2323 $('.js-taphover').not(e.currentTarget).removeClass('hover'); // remove it from previous element 2324 e.stopPropagation(); // do not leak to document root if expected element was touched 2325 return false; //extra, and to make sure the function has consistent return points 2326 } 2327 }); 2328 2329 // Whenever touchstart leaks to the root romve all hover classes 2330 $(document).on("touchstart", function(e) { 2331 $('.js-taphover').removeClass('hover'); 2332 }); 2333 2334}(jQuery)); 2335// (function() { 2336// 'use strict'; 2337 2338// // Make sure the video behaves like background-size: cover 2339// window.videoCover = function( holderSelector, videoSelector ) { 2340// var videos = document.querySelectorAll( videoSelector ), 2341// holder = document.querySelectorAll( holderSelector )[0]; 2342 2343// [].forEach.call(videos, function(video) { 2344 2345// var videoAspectRatio; 2346
2347// resizeBackground(); 2348 2349// video.onloadedmetadata = function() { 2350// // get images aspect ratio 2351// videoAspectRatio = this.height / this.width; 2352// // attach resize event and fire it once 2353// window.onresize = resizeBackground; 2354// resizeBackground(); 2355// }; 2356 2357// function resizeBackground() { 2358// // get window size and aspect ratio 2359// var holderWidth = holder.innerWidth, 2360// holderHeight = holder.innerHeight, 2361// holderAspectRatio = holderHeight / holderWidth; 2362 2363// //compare holder ratio to image ratio so you know which way the image should fill 2364// if ( holderAspectRatio < videoAspectRatio ) { 2365// // we are fill width 2366// video.style.width = holderWidth + "px"; 2367// // and applying the correct aspect to the height now 2368// video.style.height = (holderWidth * videoAspectRatio) + "px"; // this can be margin if your element is not positioned relatively, absolutely or fixed 2369// // make sure image is always centered 2370// video.style.left = "0px";
2371// video.style.top = (holderHeight - (holderWidth * videoAspectRatio)) / 2 + "px"; 2372// } else { // same thing as above but filling height instead 2373// video.style.height = holderHeight + "px"; 2374// video.style.width = (holderHeight / videoAspectRatio) + "px"; 2375// video.style.left = (holderWidth - (holderHeight / videoAspectRatio)) / 2 + "px"; 2376// video.style.top = "0px"; 2377// } 2378// } 2379 2380// }); 2381// }; 2382 2383// }()); 2384// 2385// 2386// 2387// TODO it is temp only. make it as a plugin 2388 2389(function($) { 2390 'use strict'; 2391 2392 var $videoHolder = $('.mk-center-video'), 2393 $wrapper = $videoHolder.parent(), 2394 baseAspectRatio = 56.25; 2395 2396 var wrapperHeight, 2397 wrapperWidth, 2398 wrapperAspectRatio; 2399 2400 function calc() { 2401 wrapperHeight = $wrapper.height(); 2402 wrapperWidth = $wrapper.width(); 2403 wrapperAspectRatio = (wrapperHeight / wrapperWidth) * 100; 2404 } 2405 2406 function apply() { 2407 var width = (wrapperAspectRatio / baseAspectRatio) * 100, 2408 widthOverflow = (width - 100); 2409 2410 $videoHolder.css({ 2411 'padding-top': wrapperAspectRatio + '%', 2412 'width': width + '%', 2413 'left': -(widthOverflow / 2) + '%' 2414 }); 2415 } 2416 2417 function reset() { 2418 $videoHolder.css({ 2419 'padding-top': baseAspectRatio + '%', 2420 'width': 100 + '%', 2421 'left': 0 2422 }); 2423 } 2424 2425 function setCover() { 2426 reset(); 2427 calc(); 2428 if(wrapperAspectRatio > baseAspectRatio) apply(); 2429 } 2430 2431 $(window).on('load', setCover); 2432 $(window).on('resize', setCover); 2433 2434 2435}(jQuery)); 2436(function($) { 2437 'use strict'; 2438 2439 var MK = window.MK || {}; 2440 2441 /** 2442 * MK.val is collection of Lambdas responsible for returning up to date values of method type like scrollY or el offset. 2443 * The Lambda is responsible for keeping track of value of a particular property, usually takes as argument an object 2444 * (or DOM reference) and internally creates and updates data that is returned as primitive value - through variable reference. 2445 * 2446 * Benefits of this approach: 2447 * - reduced DOM reads 2448 * - auto-updating values without need for additional logic where methods are called 2449 * - updating values when needed to be updated not read 2450 * 2451 * Downsides: 2452 * - Memory overhead with closures and keeping state in memory ( still beter than read state from DOM, but use wisely - 2453 * do not use it when you really need static value on runtime ) 2454 */ 2455 MK.val = {}; 2456 2457 /** 2458 * Current window offsetY position 2459 * 2460 * @uses MK.val.scroll() 2461 * @return {number} 2462 */ 2463 MK.val.scroll = (function() { 2464 var offset = 0, 2465 $window = $( window ), 2466 hasPageYOffset = ( window.pageYOffset !== undefined ), 2467 body = ( document.documentElement || document.body.parentNode || document.body ); // cross browser handling 2468 2469 var update = function() { 2470 offset = hasPageYOffset ? window.pageYOffset : body.scrollTop; 2471 }; 2472 2473 var rAF = function() { 2474 window.requestAnimationFrame( update ); 2475 }; 2476 2477 update(); 2478 $window.on( 'load', update ); 2479 $window.on( 'resize', update ); 2480 $window.on( 'scroll', rAF ); 2481 2482 return function() { 2483 return offset; 2484 }; 2485 })(); 2486 2487 2488 /** 2489 * Changes number of percent to pixels based on viewport height 2490 * 2491 * @uses MK.val.viewportPercentHeight({percent val}) 2492 * @param {number} 2493 * @return {number} 2494 */ 2495 MK.val.viewportPercentHeight = function( percent ) { 2496 return $( window ).height() * ( percent / 100 ); 2497 }; 2498 2499 2500 /** 2501 * Wordpress adminbar height based on wp media queries 2502 * @return {Number} 2503 */ 2504 MK.val.adminbarHeight = function() { 2505 if( php.hasAdminbar ) { 2506 // apply WP native media-query and sizes 2507 return ( window.matchMedia( '( max-width: 782px )' ).matches ) ? 46 : 32; 2508 } else { 2509 return 0; 2510 } 2511 }; 2512 2513 2514 /** 2515 * Offset when header becomes sticky. Evaluates viewport % and header height to pixels for according options 2516 * @return {Number} 2517 */ 2518 MK.val.stickyOffset = (function() { 2519 var $header = $('.mk-header').not('.js-header-shortcode').first(); 2520 2521 // We need to have returning function even when header is disabled 2522 if(!$header.length) { 2523 return function() { 2524 return 0; 2525 }; 2526 } 2527 2528 var $toolbar = $header.find( '.mk-header-toolbar' ), 2529 config = $header.data(), 2530 hasToolbar = $toolbar.length, 2531 toolbarHeight = (hasToolbar) ? $toolbar.height() : 0, 2532 isVertical = (config.headerStyle === 4), 2533 headerHeight = (isVertical) ? 0 : config.height; 2534 2535 var type = ((typeof config.stickyOffset === 'number') ? 'number' : false) || 2536 ((config.stickyOffset === 'header') ? 'header' : false) || 2537 'percent'; 2538 2539 var stickyOffset = 0; 2540 var setOffset = function() { 2541 if( type === 'number' ) { 2542 stickyOffset = config.stickyOffset; 2543 } 2544 else if( type === 'header' ) { 2545 stickyOffset = headerHeight + toolbarHeight + MK.val.adminbarHeight(); // add all header components here, make them 0 if needed 2546 } 2547 else if( type === 'percent' ) { 2548 stickyOffset = MK.val.viewportPercentHeight( parseInt(config.stickyOffset) ); 2549 } 2550 }; 2551 2552 setOffset(); 2553 $(window).on('resize', setOffset); 2554 2555 return function() { 2556 return stickyOffset; 2557 }; 2558 }()); 2559 2560 2561 2562 /** 2563 * Gets header height on particular offsetY position. Use to determine logic for fullHeight, smooth scroll etc. 2564 * Takes one parameter which is offset position we're interested in. 2565 * 2566 * @uses MK.val.offsetHeaderHeight({offset val}) 2567 * @param {number} 2568 * @return {number} 2569 */ 2570 MK.val.offsetHeaderHeight = (function() { // Closure avoids multiple DOM reads. We need to fetch header config only once. 2571 var $header = $('.mk-header').not('.js-header-shortcode').first(); 2572 2573 // We need to have returning function even when header is disabled 2574 if(!$header.length) { 2575 return function() { 2576 return 0; 2577 }; 2578 } 2579 2580 var $toolbar = $header.find( '.mk-header-toolbar' ), 2581 config = $header.data(), 2582 stickyHeight = config.stickyHeight, 2583 desktopHeight = config.height, 2584 mobileHeight = config.responsiveHeight, 2585 isTransparent = $header.hasClass( 'transparent-header' ), 2586 isSticky = config.stickyStyle.length, 2587 isStickyLazy = config.stickyStyle === 'lazy', 2588 isVertical = config.headerStyle === 4, 2589 hasToolbar = $toolbar.length, 2590 toolbarHeight = hasToolbar ? $toolbar.height() : 0, 2591 bufor = 5; 2592 2593 var headerHeight = function( offset ) { 2594 var stickyOffset = MK.val.stickyOffset(); 2595 2596 if( MK.utils.isResponsiveMenuState() ) { // Header avaible only on top for mobile 2597 var totalHeight = mobileHeight + MK.val.adminbarHeight(); 2598 if( offset <= totalHeight ) return totalHeight; 2599 else return MK.val.adminbarHeight(); 2600 } else { 2601 if( offset <= stickyOffset ) { 2602 if( isVertical ) { 2603 if( hasToolbar ) { return toolbarHeight + MK.val.adminbarHeight(); } 2604 else { return MK.val.adminbarHeight(); } 2605 } 2606 else if( isTransparent ) { return MK.val.adminbarHeight(); } 2607 else { return desktopHeight + MK.val.adminbarHeight(); } // For any other return regular desktop height 2608 } 2609 else if( offset > stickyOffset) { 2610 if( isVertical ) { return MK.val.adminbarHeight(); } 2611 else if( ! isSticky ) { return MK.val.adminbarHeight(); } 2612 else if( isStickyLazy ) { return MK.val.adminbarHeight(); } 2613 else if( isSticky ) { return stickyHeight + MK.val.adminbarHeight(); } 2614 } 2615 } 2616 // default to 0 to prevent errors ( need to return number ) 2617 // Anyway make sure all scenarios are covered in IFs 2618 return 0; 2619 }; 2620 2621 return function( offset ) { 2622 return headerHeight( offset - MK.val.adminbarHeight()); 2623 }; 2624 })(); 2625 2626 2627 /** 2628 * Gets current offset of given element (passed as object or DOM reference) from top or bottom (default to top) 2629 * of screen with possible threshold (default to 0) 2630 * 2631 * @uses MK.val.dynamicOffset({obj reference}, {'top'|'bottom'}, {threshold val}) 2632 * @param {string|object} 2633 * @param {string} 2634 * @param {number} 2635 * @return {number} 2636 */ 2637 MK.val.dynamicOffset = function( el, position, threshold ) { 2638 var $window = $( window ), 2639 $el = $( el ), 2640 pos = position || 'top', 2641 thr = threshold || 0, 2642 container = document.getElementById( 'mk-theme-container' ), 2643 currentPos = 0; 2644 2645 var offset = 0, 2646 winH = 0, 2647 rect = 0, 2648 x = 0; 2649 2650 var update = function() { 2651 winH = $window.height(); 2652 rect = $el[ 0 ].getBoundingClientRect(); 2653 offset = (rect.top + MK.val.scroll()); 2654 x = (pos === 'top') ? MK.val.offsetHeaderHeight( offset ) : winH + ( rect.height - thr ); 2655 currentPos = offset - x - 1; 2656 }; 2657 2658 update(); 2659 $window.on( 'load', update ); 2660 $window.on( 'resize', update ); 2661 window.addResizeListener( container, update ); 2662 2663 return function() { 2664 return currentPos; 2665 }; 2666 }; 2667 2668 /** 2669 * Gets current height of given element (passed as object or DOM reference) 2670 * 2671 * @uses MK.val.dynamicHeight({obj reference}) 2672 * @param {string|object} 2673 * @return {number} 2674 */ 2675 MK.val.dynamicHeight = function( el ) { 2676 var $window = $( window ), 2677 $el = $( el ), 2678 container = document.getElementById( 'mk-theme-container' ), 2679 currentHeight = 0; 2680 2681 var update = function() { 2682 currentHeight = $el.outerHeight(); 2683 }; 2684 2685 update(); 2686 $window.on( 'load', update ); 2687 $window.on( 'resize', update ); 2688 window.addResizeListener( container, update ); 2689 2690 return function() { 2691 return currentHeight; 2692 }; 2693 }; 2694 2695})(jQuery); 2696/* 2697 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 2698 * 2699 */ 2700jQuery.easing["jswing"] = jQuery.easing["swing"]; 2701jQuery.extend(jQuery.easing, { 2702 def: "easeOutQuad", 2703 swing: function (a, b, c, d, e) { 2704 return jQuery.easing[jQuery.easing.def](a, b, c, d, e) 2705 }, 2706 easeInQuad: function (a, b, c, d, e) { 2707 return d * (b /= e) * b + c 2708 }, 2709 easeOutQuad: function (a, b, c, d, e) { 2710 return -d * (b /= e) * (b - 2) + c 2711 }, 2712 easeInOutQuad: function (a, b, c, d, e) { 2713 if ((b /= e / 2) < 1) return d / 2 * b * b + c; 2714 return -d / 2 * (--b * (b - 2) - 1) + c 2715 }, 2716 easeInCubic: function (a, b, c, d, e) { 2717 return d * (b /= e) * b * b + c 2718 }, 2719 easeOutCubic: function (a, b, c, d, e) { 2720 return d * ((b = b / e - 1) * b * b + 1) + c 2721 }, 2722 easeInOutCubic: function (a, b, c, d, e) { 2723 if ((b /= e / 2) < 1) return d / 2 * b * b * b + c; 2724 return d / 2 * ((b -= 2) * b * b + 2) + c 2725 }, 2726 easeInQuart: function (a, b, c, d, e) { 2727 return d * (b /= e) * b * b * b + c 2728 }, 2729 easeOutQuart: function (a, b, c, d, e) { 2730 return -d * ((b = b / e - 1) * b * b * b - 1) + c 2731 }, 2732 easeInOutQuart: function (a, b, c, d, e) { 2733 if ((b /= e / 2) < 1) return d / 2 * b * b * b * b + c; 2734 return -d / 2 * ((b -= 2) * b * b * b - 2) + c 2735 }, 2736 easeInQuint: function (a, b, c, d, e) { 2737 return d * (b /= e) * b * b * b * b + c 2738 }, 2739 easeOutQuint: function (a, b, c, d, e) { 2740 return d * ((b = b / e - 1) * b * b * b * b + 1) + c 2741 }, 2742 easeInOutQuint: function (a, b, c, d, e) { 2743 if ((b /= e / 2) < 1) return d / 2 * b * b * b * b * b + c; 2744 return d / 2 * ((b -= 2) * b * b * b * b + 2) + c 2745 }, 2746 easeInSine: function (a, b, c, d, e) {
2747 return -d * Math.cos(b / e * (Math.PI / 2)) + d + c 2748 }, 2749 easeOutSine: function (a, b, c, d, e) { 2750 return d * Math.sin(b / e * (Math.PI / 2)) + c 2751 }, 2752 easeInOutSine: function (a, b, c, d, e) { 2753 return -d / 2 * (Math.cos(Math.PI * b / e) - 1) + c 2754 }, 2755 easeInExpo: function (a, b, c, d, e) { 2756 return b == 0 ? c : d * Math.pow(2, 10 * (b / e - 1)) + c 2757 }, 2758 easeOutExpo: function (a, b, c, d, e) { 2759 return b == e ? c + d : d * (-Math.pow(2, -10 * b / e) + 1) + c 2760 }, 2761 easeInOutExpo: function (a, b, c, d, e) { 2762 if (b == 0) return c; 2763 if (b == e) return c + d; 2764 if ((b /= e / 2) < 1) return d / 2 * Math.pow(2, 10 * (b - 1)) + c; 2765 return d / 2 * (-Math.pow(2, -10 * --b) + 2) + c 2766 }, 2767 easeInCirc: function (a, b, c, d, e) { 2768 return -d * (Math.sqrt(1 - (b /= e) * b) - 1) + c 2769 }, 2770 easeOutCirc: function (a, b, c, d, e) { 2771 return d * Math.sqrt(1 - (b = b / e - 1) * b) + c 2772 }, 2773 easeInOutCirc: function (a, b, c, d, e) { 2774 if ((b /= e / 2) < 1) return -d / 2 * (Math.sqrt(1 - b * b) - 1) + c; 2775 return d / 2 * (Math.sqrt(1 - (b -= 2) * b) + 1) + c 2776 }, 2777 easeInElastic: function (a, b, c, d, e) { 2778 var f = 1.70158; 2779 var g = 0; 2780 var h = d; 2781 if (b == 0) return c; 2782 if ((b /= e) == 1) return c + d; 2783 if (!g) g = e * .3; 2784 if (h < Math.abs(d)) { 2785 h = d; 2786 var f = g / 4 2787 } else var f = g / (2 * Math.PI) * Math.asin(d / h); 2788 return -(h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g)) + c 2789 }, 2790 easeOutElastic: function (a, b, c, d, e) { 2791 var f = 1.70158; 2792 var g = 0; 2793 var h = d; 2794 if (b == 0) return c; 2795 if ((b /= e) == 1) return c + d; 2796 if (!g) g = e * .3; 2797 if (h < Math.abs(d)) { 2798 h = d; 2799 var f = g / 4 2800 } else var f = g / (2 * Math.PI) * Math.asin(d / h); 2801 return h * Math.pow(2, -10 * b) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c 2802 }, 2803 easeInOutElastic: function (a, b, c, d, e) { 2804 var f = 1.70158; 2805 var g = 0; 2806 var h = d; 2807 if (b == 0) return c; 2808 if ((b /= e / 2) == 2) return c + d; 2809 if (!g) g = e * .3 * 1.5; 2810 if (h < Math.abs(d)) { 2811 h = d; 2812 var f = g / 4 2813 } else var f = g / (2 * Math.PI) * Math.asin(d / h); 2814 if (b < 1) return -.5 * h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) + c; 2815 return h * Math.pow(2, -10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) * .5 + d + c 2816 }, 2817 easeInBack: function (a, b, c, d, e, f) { 2818 if (f == undefined) f = 1.70158; 2819 return d * (b /= e) * b * ((f + 1) * b - f) + c 2820 }, 2821 easeOutBack: function (a, b, c, d, e, f) { 2822 if (f == undefined) f = 1.70158; 2823 return d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c 2824 }, 2825 easeInOutBack: function (a, b, c, d, e, f) { 2826 if (f == undefined) f = 1.70158; 2827 if ((b /= e / 2) < 1) return d / 2 * b * b * (((f *= 1.525) + 1) * b - f) + c; 2828 return d / 2 * ((b -= 2) * b * (((f *= 1.525) + 1) * b + f) + 2) + c 2829 }, 2830 easeInBounce: function (a, b, c, d, e) { 2831 return d - jQuery.easing.easeOutBounce(a, e - b, 0, d, e) + c 2832 }, 2833 easeOutBounce: function (a, b, c, d, e) { 2834 if ((b /= e) < 1 / 2.75) { 2835 return d * 7.5625 * b * b + c 2836 } else if (b < 2 / 2.75) { 2837 return d * (7.5625 * (b -= 1.5 / 2.75) * b + .75) + c 2838 } else if (b < 2.5 / 2.75) { 2839 return d * (7.5625 * (b -= 2.25 / 2.75) * b + .9375) + c 2840 } else { 2841 return d * (7.5625 * (b -= 2.625 / 2.75) * b + .984375) + c 2842 } 2843 }, 2844 easeInOutBounce: function (a, b, c, d, e) { 2845 if (b < e / 2) return jQuery.easing.easeInBounce(a, b * 2, 0, d, e) * .5 + c; 2846 return jQuery.easing.easeOutBounce(a, b * 2 - e, 0, d, e) * .5 + d * .5 + c 2847 } 2848}); 2849 2850/*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */ 2851(function(s, H, f, w) { 2852 var K = f("html"), 2853 q = f(s), 2854 p = f(H), 2855 b = f.fancybox = function() { 2856 b.open.apply(this, arguments) 2857 }, 2858 J = navigator.userAgent.match(/msie/i), 2859 C = null, 2860 t = H.createTouch !== w, 2861 u = function(a) { 2862 return a && a.hasOwnProperty && a instanceof f 2863 }, 2864 r = function(a) { 2865 return a && "string" === f.type(a) 2866 }, 2867 F = function(a) { 2868 return r(a) && 0 < a.indexOf("%") 2869 }, 2870 m = function(a, d) { 2871 var e = parseInt(a, 10) || 0; 2872 d && F(a) && (e *= b.getViewport()[d] / 100); 2873 return Math.ceil(e) 2874 }, 2875 x = function(a, b) { 2876 return m(a, b) + "px" 2877 }; 2878 f.extend(b, { 2879 version: "2.1.5", 2880 defaults: { 2881 padding: 15, 2882 margin: 20, 2883 width: 800, 2884 height: 600, 2885 minWidth: 100, 2886 minHeight: 100, 2887 maxWidth: 9999, 2888 maxHeight: 9999, 2889 pixelRatio: 1, 2890 autoSize: !0, 2891 autoHeight: !1, 2892 autoWidth: !1, 2893 autoResize: !0, 2894 autoCenter: !t, 2895 fitToView: !0, 2896 aspectRatio: !1, 2897 topRatio: 0.5, 2898 leftRatio: 0.5, 2899 scrolling: "auto", 2900 wrapCSS: "", 2901 arrows: !0, 2902 closeBtn: !0, 2903 closeClick: !1, 2904 nextClick: !1, 2905 mouseWheel: !0, 2906 autoPlay: !1, 2907 playSpeed: 3E3, 2908 preload: 3, 2909 modal: !1, 2910 loop: !0, 2911 ajax: { 2912 dataType: "html", 2913 headers: { 2914 "X-fancyBox": !0 2915 } 2916 }, 2917 iframe: { 2918 scrolling: "auto", 2919 preload: !0 2920 }, 2921 swf: { 2922 wmode: "transparent", 2923 allowfullscreen: "true", 2924 allowscriptaccess: "always" 2925 }, 2926 keys: { 2927 next: { 2928 13: "left", 2929 34: "up", 2930 39: "left", 2931 40: "up" 2932 }, 2933 prev: { 2934 8: "right", 2935 33: "down", 2936 37: "right", 2937 38: "down" 2938 }, 2939 close: [27], 2940 play: [32], 2941 toggle: [70] 2942 }, 2943 direction: { 2944 next: "left", 2945 prev: "right" 2946 }, 2947 scrollOutside: !0, 2948 index: 0, 2949 type: null, 2950 href: null, 2951 content: null, 2952 title: null, 2953 tpl: { 2954 wrap: '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>', 2955 image: '<img class="fancybox-image" src="{href}" alt="" />', 2956 iframe: '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + 2957 (J ? ' allowtransparency="true"' : "") + "></iframe>", 2958 error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>', 2959 closeBtn: '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>', 2960 next: '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>', 2961 prev: '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>' 2962 }, 2963 openEffect: "fade", 2964 openSpeed: 250, 2965 openEasing: "swing", 2966 openOpacity: !0, 2967 openMethod: "zoomIn", 2968 closeEffect: "fade", 2969 closeSpeed: 250, 2970 closeEasing: "swing", 2971 closeOpacity: !0, 2972 closeMethod: "zoomOut", 2973 nextEffect: "elastic", 2974 nextSpeed: 250, 2975 nextEasing: "swing", 2976 nextMethod: "changeIn", 2977 prevEffect: "elastic", 2978 prevSpeed: 250, 2979 prevEasing: "swing", 2980 prevMethod: "changeOut", 2981 helpers: { 2982 overlay: !0, 2983 title: !0 2984 }, 2985 onCancel: f.noop, 2986 beforeLoad: f.noop, 2987 afterLoad: f.noop, 2988 beforeShow: f.noop, 2989 afterShow: f.noop, 2990 beforeChange: f.noop, 2991 beforeClose: f.noop, 2992 afterClose: f.noop 2993 }, 2994 group: {}, 2995 opts: {}, 2996 previous: null, 2997 coming: null, 2998 current: null, 2999 isActive: !1, 3000 isOpen: !1, 3001 isOpened: !1, 3002 wrap: null, 3003 skin: null, 3004 outer: null, 3005 inner: null, 3006 player: { 3007 timer: null, 3008 isActive: !1 3009 }, 3010 ajaxLoad: null, 3011 imgPreload: null, 3012 transitions: {}, 3013 helpers: {}, 3014 open: function(a, d) { 3015 if (a && (f.isPlainObject(d) || (d = {}), !1 !== b.close(!0))) return f.isArray(a) || (a = u(a) ? f(a).get() : [a]), f.each(a, function(e,
vendor: 34,462 bytes, lines 3015-3765
3015c) { 3016 var l = {}, 3017 g, h, k, n, m; 3018 "object" === f.type(c) && (c.nodeType && (c = f(c)), u(c) ? (l = { 3019 href: c.data("fancybox-href") || c.attr("href"), 3020 title: f("<div/>").text(c.data("fancybox-title") || c.attr("title")).html(), 3021 isDom: !0, 3022 element: c 3023 }, 3024 f.metadata && f.extend(!0, l, c.metadata())) : l = c); 3025 g = d.href || l.href || (r(c) ? c : null); 3026 h = d.title !== w ? d.title : l.title || ""; 3027 n = (k = d.content || l.content) ? "html" : d.type || l.type; 3028 !n && l.isDom && (n = c.data("fancybox-type"), n || (n = (n = c.prop("class").match(/fancybox\.(\w+)/)) ? n[1] : null)); 3029 r(g) && (n || (b.isImage(g) ? n = "image" : b.isSWF(g) ? n = "swf" : "#" === g.charAt(0) ? n = "inline" : r(c) && (n = "html", k = c)), "ajax" === n && (m = g.split(/\s+/, 2), g = m.shift(), m = m.shift())); 3030 k || ("inline" === n ? g ? k = f(r(g) ? g.replace(/.*(?=#[^\s]+$)/, "") : g) : l.isDom && (k = c) : 3031 "html" === n ? k = g : n || g || !l.isDom || (n = "inline", k = c)); 3032 f.extend(l, { 3033 href: g, 3034 type: n, 3035 content: k, 3036 title: h, 3037 selector: m 3038 }); 3039 a[e] = l 3040 }), b.opts = f.extend(!0, {}, b.defaults, d), d.keys !== w && (b.opts.keys = d.keys ? f.extend({}, b.defaults.keys, d.keys) : !1), b.group = a, b._start(b.opts.index) 3041 }, 3042 cancel: function() { 3043 var a = b.coming; 3044 a && !1 === b.trigger("onCancel") || (b.hideLoading(), a && (b.ajaxLoad && b.ajaxLoad.abort(), b.ajaxLoad = null, b.imgPreload && (b.imgPreload.onload = b.imgPreload.onerror = null), a.wrap && a.wrap.stop(!0, !0).trigger("onReset").remove(), 3045 b.coming = null, b.current || b._afterZoomOut(a))) 3046 }, 3047 close: function(a) { 3048 b.cancel(); 3049 !1 !== b.trigger("beforeClose") && (b.unbindEvents(), b.isActive && (b.isOpen && !0 !== a ? (b.isOpen = b.isOpened = !1, b.isClosing = !0, f(".fancybox-item, .fancybox-nav").remove(), b.wrap.stop(!0, !0).removeClass("fancybox-opened"), b.transitions[b.current.closeMethod]()) : (f(".fancybox-wrap").stop(!0).trigger("onReset").remove(), b._afterZoomOut()))) 3050 }, 3051 play: function(a) { 3052 var d = function() { 3053 clearTimeout(b.player.timer) 3054 }, 3055 e = function() { 3056 d(); 3057 b.current && b.player.isActive && 3058 (b.player.timer = setTimeout(b.next, b.current.playSpeed)) 3059 }, 3060 c = function() { 3061 d(); 3062 p.unbind(".player"); 3063 b.player.isActive = !1; 3064 b.trigger("onPlayEnd") 3065 }; 3066 !0 === a || !b.player.isActive && !1 !== a ? b.current && (b.current.loop || b.current.index < b.group.length - 1) && (b.player.isActive = !0, p.bind({ 3067 "onCancel.player beforeClose.player": c, 3068 "onUpdate.player": e, 3069 "beforeLoad.player": d 3070 }), e(), b.trigger("onPlayStart")) : c() 3071 }, 3072 next: function(a) { 3073 var d = b.current; 3074 d && (r(a) || (a = d.direction.next), b.jumpto(d.index + 1, a, "next")) 3075 }, 3076 prev: function(a) { 3077 var d = 3078 b.current; 3079 d && (r(a) || (a = d.direction.prev), b.jumpto(d.index - 1, a, "prev")) 3080 }, 3081 jumpto: function(a, d, e) { 3082 var c = b.current; 3083 c && (a = m(a), b.direction = d || c.direction[a >= c.index ? "next" : "prev"], b.router = e || "jumpto", c.loop && (0 > a && (a = c.group.length + a % c.group.length), a %= c.group.length), c.group[a] !== w && (b.cancel(), b._start(a))) 3084 }, 3085 reposition: function(a, d) { 3086 var e = b.current, 3087 c = e ? e.wrap : null, 3088 l; 3089 c && (l = b._getPosition(d), a && "scroll" === a.type ? (delete l.position, c.stop(!0, !0).animate(l, 200)) : (c.css(l), e.pos = f.extend({}, e.dim, l))) 3090 }, 3091 update: function(a) { 3092 var d = a && a.originalEvent && a.originalEvent.type, 3093 e = !d || "orientationchange" === d; 3094 e && (clearTimeout(C), C = null); 3095 b.isOpen && !C && (C = setTimeout(function() { 3096 var c = b.current; 3097 c && !b.isClosing && (b.wrap.removeClass("fancybox-tmp"), (e || "load" === d || "resize" === d && c.autoResize) && b._setDimension(), "scroll" === d && c.canShrink || b.reposition(a), b.trigger("onUpdate"), C = null) 3098 }, e && !t ? 0 : 300)) 3099 }, 3100 toggle: function(a) { 3101 b.isOpen && (b.current.fitToView = "boolean" === f.type(a) ? a : !b.current.fitToView, t && (b.wrap.removeAttr("style").addClass("fancybox-tmp"), 3102 b.trigger("onUpdate")), b.update()) 3103 }, 3104 hideLoading: function() { 3105 p.unbind(".loading"); 3106 f("#fancybox-loading").remove() 3107 }, 3108 showLoading: function() { 3109 var a, d; 3110 b.hideLoading(); 3111 a = f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body"); 3112 p.bind("keydown.loading", function(a) { 3113 27 === (a.which || a.keyCode) && (a.preventDefault(), b.cancel()) 3114 }); 3115 b.defaults.fixed || (d = b.getViewport(), a.css({ 3116 position: "absolute", 3117 top: 0.5 * d.h + d.y, 3118 left: 0.5 * d.w + d.x 3119 })); 3120 b.trigger("onLoading") 3121 }, 3122 getViewport: function() { 3123 var a = b.current && 3124 b.current.locked || !1, 3125 d = { 3126 x: q.scrollLeft(), 3127 y: q.scrollTop() 3128 }; 3129 a && a.length ? (d.w = a[0].clientWidth, d.h = a[0].clientHeight) : (d.w = t && s.innerWidth ? s.innerWidth : q.width(), d.h = t && s.innerHeight ? s.innerHeight : q.height()); 3130 return d 3131 }, 3132 unbindEvents: function() { 3133 b.wrap && u(b.wrap) && b.wrap.unbind(".fb"); 3134 p.unbind(".fb"); 3135 q.unbind(".fb") 3136 }, 3137 bindEvents: function() { 3138 var a = b.current, 3139 d; 3140 a && (q.bind("orientationchange.fb" + (t ? "" : " resize.fb") + (a.autoCenter && !a.locked ? " scroll.fb" : ""), b.update), (d = a.keys) && p.bind("keydown.fb", function(e) { 3141 var c = 3142 e.which || e.keyCode, 3143 l = e.target || e.srcElement; 3144 if (27 === c && b.coming) return !1; 3145 e.ctrlKey || e.altKey || e.shiftKey || e.metaKey || l && (l.type || f(l).is("[contenteditable]")) || f.each(d, function(d, l) { 3146 if (1 < a.group.length && l[c] !== w) return b[d](l[c]), e.preventDefault(), !1; 3147 if (-1 < f.inArray(c, l)) return b[d](), e.preventDefault(), !1 3148 }) 3149 }), f.fn.mousewheel && a.mouseWheel && b.wrap.bind("mousewheel.fb", function(d, c, l, g) { 3150 for (var h = f(d.target || null), k = !1; h.length && !(k || h.is(".fancybox-skin") || h.is(".fancybox-wrap"));) k = h[0] && !(h[0].style.overflow && 3151 "hidden" === h[0].style.overflow) && (h[0].clientWidth && h[0].scrollWidth > h[0].clientWidth || h[0].clientHeight && h[0].scrollHeight > h[0].clientHeight), h = f(h).parent(); 3152 0 !== c && !k && 1 < b.group.length && !a.canShrink && (0 < g || 0 < l ? b.prev(0 < g ? "down" : "left") : (0 > g || 0 > l) && b.next(0 > g ? "up" : "right"), d.preventDefault()) 3153 })) 3154 }, 3155 trigger: function(a, d) { 3156 var e, c = d || b.coming || b.current; 3157 if (c) { 3158 f.isFunction(c[a]) && (e = c[a].apply(c, Array.prototype.slice.call(arguments, 1))); 3159 if (!1 === e) return !1; 3160 c.helpers && f.each(c.helpers, function(d, e) { 3161 if (e && 3162 b.helpers[d] && f.isFunction(b.helpers[d][a])) b.helpers[d][a](f.extend(!0, {}, b.helpers[d].defaults, e), c) 3163 }) 3164 } 3165 p.trigger(a) 3166 }, 3167 isImage: function(a) { 3168 return r(a) && a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i) 3169 }, 3170 isSWF: function(a) { 3171 return r(a) && a.match(/\.(swf)((\?|#).*)?$/i) 3172 }, 3173 _start: function(a) { 3174 var d = {}, 3175 e, c; 3176 a = m(a); 3177 e = b.group[a] || null; 3178 if (!e) return !1; 3179 d = f.extend(!0, {}, b.opts, e); 3180 e = d.margin; 3181 c = d.padding; 3182 "number" === f.type(e) && (d.margin = [e, e, e, e]); 3183 "number" === f.type(c) && (d.padding = [c, c, 3184 c, c 3185 ]); 3186 d.modal && f.extend(!0, d, { 3187 closeBtn: !1, 3188 closeClick: !1, 3189 nextClick: !1, 3190 arrows: !1, 3191 mouseWheel: !1, 3192 keys: null, 3193 helpers: { 3194 overlay: { 3195 closeClick: !1 3196 } 3197 } 3198 }); 3199 d.autoSize && (d.autoWidth = d.autoHeight = !0); 3200 "auto" === d.width && (d.autoWidth = !0); 3201 "auto" === d.height && (d.autoHeight = !0); 3202 d.group = b.group; 3203 d.index = a; 3204 b.coming = d; 3205 if (!1 === b.trigger("beforeLoad")) b.coming = null; 3206 else { 3207 c = d.type; 3208 e = d.href; 3209 if (!c) return b.coming = null, b.current && b.router && "jumpto" !== b.router ? (b.current.index = a, b[b.router](b.direction)) : !1; 3210 b.isActive = !0; 3211 if ("image" === 3212 c || "swf" === c) d.autoHeight = d.autoWidth = !1, d.scrolling = "visible"; 3213 "image" === c && (d.aspectRatio = !0); 3214 "iframe" === c && t && (d.scrolling = "scroll"); 3215 d.wrap = f(d.tpl.wrap).addClass("fancybox-" + (t ? "mobile" : "desktop") + " fancybox-type-" + c + " fancybox-tmp " + d.wrapCSS).appendTo(d.parent || "body"); 3216 f.extend(d, { 3217 skin: f(".fancybox-skin", d.wrap), 3218 outer: f(".fancybox-outer", d.wrap), 3219 inner: f(".fancybox-inner", d.wrap) 3220 }); 3221 f.each(["Top", "Right", "Bottom", "Left"], function(a, b) { 3222 d.skin.css("padding" + b, x(d.padding[a])) 3223 }); 3224 b.trigger("onReady"); 3225 if ("inline" === c || "html" === c) { 3226 if (!d.content || !d.content.length) return b._error("content") 3227 } else if (!e) return b._error("href"); 3228 "image" === c ? b._loadImage() : "ajax" === c ? b._loadAjax() : "iframe" === c ? b._loadIframe() : b._afterLoad() 3229 } 3230 }, 3231 _error: function(a) { 3232 f.extend(b.coming, { 3233 type: "html", 3234 autoWidth: !0, 3235 autoHeight: !0, 3236 minWidth: 0, 3237 minHeight: 0, 3238 scrolling: "no", 3239 hasError: a, 3240 content: b.coming.tpl.error 3241 }); 3242 b._afterLoad() 3243 }, 3244 _loadImage: function() { 3245 var a = b.imgPreload = new Image; 3246 a.onload = function() { 3247 this.onload = this.onerror = null; 3248 b.coming.width = 3249 this.width / b.opts.pixelRatio; 3250 b.coming.height = this.height / b.opts.pixelRatio; 3251 b._afterLoad() 3252 }; 3253 a.onerror = function() { 3254 this.onload = this.onerror = null; 3255 b._error("image") 3256 }; 3257 a.src = b.coming.href; 3258 !0 !== a.complete && b.showLoading() 3259 }, 3260 _loadAjax: function() { 3261 var a = b.coming; 3262 b.showLoading(); 3263 b.ajaxLoad = f.ajax(f.extend({}, a.ajax, { 3264 url: a.href, 3265 error: function(a, e) { 3266 b.coming && "abort" !== e ? b._error("ajax", a) : b.hideLoading() 3267 }, 3268 success: function(d, e) { 3269 "success" === e && (a.content = d, b._afterLoad()) 3270 } 3271 })) 3272 }, 3273 _loadIframe: function() { 3274 var a = b.coming, 3275 d = f(a.tpl.iframe.replace(/\{rnd\}/g, (new Date).getTime())).attr("scrolling", t ? "auto" : a.iframe.scrolling).attr("src", a.href); 3276 f(a.wrap).bind("onReset", function() { 3277 try { 3278 f(this).find("iframe").hide().attr("src", "//about:blank").end().empty() 3279 } catch (a) {} 3280 }); 3281 a.iframe.preload && (b.showLoading(), d.one("load", function() { 3282 f(this).data("ready", 1); 3283 t || f(this).bind("load.fb", b.update); 3284 f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show(); 3285 b._afterLoad() 3286 })); 3287 a.content = d.appendTo(a.inner); 3288 a.iframe.preload || 3289 b._afterLoad() 3290 }, 3291 _preloadImages: function() { 3292 var a = b.group, 3293 d = b.current, 3294 e = a.length, 3295 c = d.preload ? Math.min(d.preload, e - 1) : 0, 3296 f, g; 3297 for (g = 1; g <= c; g += 1) f = a[(d.index + g) % e], "image" === f.type && f.href && ((new Image).src = f.href) 3298 }, 3299 _afterLoad: function() { 3300 var a = b.coming, 3301 d = b.current, 3302 e, c, l, g, h; 3303 b.hideLoading(); 3304 if (a && !1 !== b.isActive) 3305 if (!1 === b.trigger("afterLoad", a, d)) a.wrap.stop(!0).trigger("onReset").remove(), b.coming = null; 3306 else { 3307 d && (b.trigger("beforeChange", d), d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove()); 3308 b.unbindEvents(); 3309 e = a.content; 3310 c = a.type; 3311 l = a.scrolling; 3312 f.extend(b, { 3313 wrap: a.wrap, 3314 skin: a.skin, 3315 outer: a.outer, 3316 inner: a.inner, 3317 current: a, 3318 previous: d 3319 }); 3320 g = a.href; 3321 switch (c) { 3322 case "inline": 3323 case "ajax": 3324 case "html": 3325 a.selector ? e = f("<div>").html(e).find(a.selector) : u(e) && (e.data("fancybox-placeholder") || e.data("fancybox-placeholder", f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()), e = e.show().detach(), a.wrap.bind("onReset", function() { 3326 f(this).find(e).length && e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder", !1) 3327 })); 3328 break; 3329 case "image": 3330 e = a.tpl.image.replace(/\{href\}/g, g); 3331 break; 3332 case "swf": 3333 e = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + g + '"></param>', h = "", f.each(a.swf, function(a, b) { 3334 e += '<param name="' + a + '" value="' + b + '"></param>'; 3335 h += " " + a + '="' + b + '"' 3336 }), e += '<embed src="' + g + '" type="application/x-shockwave-flash" width="100%" height="100%"' + h + "></embed></object>" 3337 } 3338 u(e) && e.parent().is(a.inner) || a.inner.append(e); 3339 b.trigger("beforeShow"); 3340 a.inner.css("overflow", "yes" === l ? "scroll" : "no" === l ? "hidden" : l); 3341 b._setDimension(); 3342 b.reposition(); 3343 b.isOpen = !1; 3344 b.coming = null; 3345 b.bindEvents(); 3346 if (!b.isOpened) f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove(); 3347 else if (d.prevMethod) b.transitions[d.prevMethod](); 3348 b.transitions[b.isOpened ? a.nextMethod : a.openMethod](); 3349 b._preloadImages() 3350 } 3351 }, 3352 _setDimension: function() { 3353 var a = b.getViewport(), 3354 d = 0, 3355 e = !1, 3356 c = !1, 3357 e = b.wrap, 3358 l = b.skin, 3359 g = b.inner, 3360 h = b.current, 3361 c = h.width, 3362 k = h.height, 3363 n = h.minWidth, 3364 v = h.minHeight, 3365 p = h.maxWidth, 3366 q = h.maxHeight, 3367 t = h.scrolling, 3368 r = h.scrollOutside ? h.scrollbarWidth : 0, 3369 y = h.margin, 3370 z = m(y[1] + y[3]), 3371 s = m(y[0] + y[2]), 3372 w, A, u, D, B, G, C, E, I; 3373 e.add(l).add(g).width("auto").height("auto").removeClass("fancybox-tmp"); 3374 y = m(l.outerWidth(!0) - l.width()); 3375 w = m(l.outerHeight(!0) - l.height()); 3376 A = z + y; 3377 u = s + w; 3378 D = F(c) ? (a.w - A) * m(c) / 100 : c; 3379 B = F(k) ? (a.h - u) * m(k) / 100 : k; 3380 if ("iframe" === h.type) { 3381 if (I = h.content, h.autoHeight && 1 === I.data("ready")) try { 3382 I[0].contentWindow.document.location && (g.width(D).height(9999), G = I.contents().find("body"), r && G.css("overflow-x", 3383 "hidden"), B = G.outerHeight(!0)) 3384 } catch (H) {} 3385 } else if (h.autoWidth || h.autoHeight) g.addClass("fancybox-tmp"), h.autoWidth || g.width(D), h.autoHeight || g.height(B), h.autoWidth && (D = g.width()), h.autoHeight && (B = g.height()), g.removeClass("fancybox-tmp"); 3386 c = m(D); 3387 k = m(B); 3388 E = D / B; 3389 n = m(F(n) ? m(n, "w") - A : n); 3390 p = m(F(p) ? m(p, "w") - A : p); 3391 v = m(F(v) ? m(v, "h") - u : v); 3392 q = m(F(q) ? m(q, "h") - u : q); 3393 G = p; 3394 C = q; 3395 h.fitToView && (p = Math.min(a.w - A, p), q = Math.min(a.h - u, q)); 3396 A = a.w - z; 3397 s = a.h - s; 3398 h.aspectRatio ? (c > p && (c = p, k = m(c / E)), k > q && (k = q, c = m(k * E)), c < n && (c = n, k = m(c / 3399 E)), k < v && (k = v, c = m(k * E))) : (c = Math.max(n, Math.min(c, p)), h.autoHeight && "iframe" !== h.type && (g.width(c), k = g.height()), k = Math.max(v, Math.min(k, q))); 3400 if (h.fitToView) 3401 if (g.width(c).height(k), e.width(c + y), a = e.width(), z = e.height(), h.aspectRatio) 3402 for (; 3403 (a > A || z > s) && c > n && k > v && !(19 < d++);) k = Math.max(v, Math.min(q, k - 10)), c = m(k * E), c < n && (c = n, k = m(c / E)), c > p && (c = p, k = m(c / E)), g.width(c).height(k), e.width(c + y), a = e.width(), z = e.height(); 3404 else c = Math.max(n, Math.min(c, c - (a - A))), k = Math.max(v, Math.min(k, k - (z - s))); 3405 r && "auto" === t && k < B && 3406 c + y + r < A && (c += r); 3407 g.width(c).height(k); 3408 e.width(c + y); 3409 a = e.width(); 3410 z = e.height(); 3411 e = (a > A || z > s) && c > n && k > v; 3412 c = h.aspectRatio ? c < G && k < C && c < D && k < B : (c < G || k < C) && (c < D || k < B); 3413 f.extend(h, { 3414 dim: { 3415 width: x(a), 3416 height: x(z) 3417 }, 3418 origWidth: D, 3419 origHeight: B, 3420 canShrink: e, 3421 canExpand: c, 3422 wPadding: y, 3423 hPadding: w, 3424 wrapSpace: z - l.outerHeight(!0), 3425 skinSpace: l.height() - k 3426 }); 3427 !I && h.autoHeight && k > v && k < q && !c && g.height("auto") 3428 }, 3429 _getPosition: function(a) { 3430 var d = b.current, 3431 e = b.getViewport(), 3432 c = d.margin, 3433 f = b.wrap.width() + c[1] + c[3], 3434 g = b.wrap.height() + c[0] + c[2], 3435 c = { 3436 position: "absolute", 3437 top: c[0], 3438 left: c[3] 3439 }; 3440 d.autoCenter && d.fixed && !a && g <= e.h && f <= e.w ? c.position = "fixed" : d.locked || (c.top += e.y, c.left += e.x); 3441 c.top = x(Math.max(c.top, c.top + (e.h - g) * d.topRatio)); 3442 c.left = x(Math.max(c.left, c.left + (e.w - f) * d.leftRatio)); 3443 return c 3444 }, 3445 _afterZoomIn: function() { 3446 var a = b.current; 3447 a && ((b.isOpen = b.isOpened = !0, b.wrap.css("overflow", "visible").addClass("fancybox-opened"), b.update(), (a.closeClick || a.nextClick && 1 < b.group.length) && b.inner.css("cursor", "pointer").bind("click.fb", function(d) { 3448 f(d.target).is("a") || f(d.target).parent().is("a") || 3449 (d.preventDefault(), b[a.closeClick ? "close" : "next"]()) 3450 }), a.closeBtn && f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb", function(a) { 3451 a.preventDefault(); 3452 b.close() 3453 }), a.arrows && 1 < b.group.length && ((a.loop || 0 < a.index) && f(a.tpl.prev).appendTo(b.outer).bind("click.fb", b.prev), (a.loop || a.index < b.group.length - 1) && f(a.tpl.next).appendTo(b.outer).bind("click.fb", b.next)), b.trigger("afterShow"), a.loop || a.index !== a.group.length - 1) ? b.opts.autoPlay && !b.player.isActive && (b.opts.autoPlay = !1, b.play(!0)) : b.play(!1)) 3454 }, 3455 _afterZoomOut: function(a) { 3456 a = a || b.current; 3457 f(".fancybox-wrap").trigger("onReset").remove(); 3458 f.extend(b, { 3459 group: {}, 3460 opts: {}, 3461 router: !1, 3462 current: null, 3463 isActive: !1, 3464 isOpened: !1, 3465 isOpen: !1, 3466 isClosing: !1, 3467 wrap: null, 3468 skin: null, 3469 outer: null, 3470 inner: null 3471 }); 3472 b.trigger("afterClose", a) 3473 } 3474 }); 3475 b.transitions = { 3476 getOrigPosition: function() { 3477 var a = b.current, 3478 d = a.element, 3479 e = a.orig, 3480 c = {}, 3481 f = 50, 3482 g = 50, 3483 h = a.hPadding, 3484 k = a.wPadding, 3485 n = b.getViewport(); 3486 !e && a.isDom && d.is(":visible") && (e = d.find("img:first"), e.length || (e = d)); 3487 u(e) ? (c = e.offset(), e.is("img") && 3488 (f = e.outerWidth(), g = e.outerHeight())) : (c.top = n.y + (n.h - g) * a.topRatio, c.left = n.x + (n.w - f) * a.leftRatio); 3489 if ("fixed" === b.wrap.css("position") || a.locked) c.top -= n.y, c.left -= n.x; 3490 return c = { 3491 top: x(c.top - h * a.topRatio), 3492 left: x(c.left - k * a.leftRatio), 3493 width: x(f + k), 3494 height: x(g + h) 3495 } 3496 }, 3497 step: function(a, d) { 3498 var e, c, f = d.prop; 3499 c = b.current; 3500 var g = c.wrapSpace, 3501 h = c.skinSpace; 3502 if ("width" === f || "height" === f) e = d.end === d.start ? 1 : (a - d.start) / (d.end - d.start), b.isClosing && (e = 1 - e), c = "width" === f ? c.wPadding : c.hPadding, c = a - c, b.skin[f](m("width" === 3503 f ? c : c - g * e)), b.inner[f](m("width" === f ? c : c - g * e - h * e)) 3504 }, 3505 zoomIn: function() { 3506 var a = b.current, 3507 d = a.pos, 3508 e = a.openEffect, 3509 c = "elastic" === e, 3510 l = f.extend({ 3511 opacity: 1 3512 }, d); 3513 delete l.position; 3514 c ? (d = this.getOrigPosition(), a.openOpacity && (d.opacity = 0.1)) : "fade" === e && (d.opacity = 0.1); 3515 b.wrap.css(d).animate(l, { 3516 duration: "none" === e ? 0 : a.openSpeed, 3517 easing: a.openEasing, 3518 step: c ? this.step : null, 3519 complete: b._afterZoomIn 3520 }) 3521 }, 3522 zoomOut: function() { 3523 var a = b.current, 3524 d = a.closeEffect, 3525 e = "elastic" === d, 3526 c = { 3527 opacity: 0.1 3528 }; 3529 e && (c = this.getOrigPosition(), a.closeOpacity && 3530 (c.opacity = 0.1)); 3531 b.wrap.animate(c, { 3532 duration: "none" === d ? 0 : a.closeSpeed, 3533 easing: a.closeEasing, 3534 step: e ? this.step : null, 3535 complete: b._afterZoomOut 3536 }) 3537 }, 3538 changeIn: function() { 3539 var a = b.current, 3540 d = a.nextEffect, 3541 e = a.pos, 3542 c = { 3543 opacity: 1 3544 }, 3545 f = b.direction, 3546 g; 3547 e.opacity = 0.1; 3548 "elastic" === d && (g = "down" === f || "up" === f ? "top" : "left", "down" === f || "right" === f ? (e[g] = x(m(e[g]) - 200), c[g] = "+=200px") : (e[g] = x(m(e[g]) + 200), c[g] = "-=200px")); 3549 "none" === d ? b._afterZoomIn() : b.wrap.css(e).animate(c, { 3550 duration: a.nextSpeed, 3551 easing: a.nextEasing, 3552 complete: b._afterZoomIn 3553 }) 3554 }, 3555 changeOut: function() { 3556 var a = b.previous, 3557 d = a.prevEffect, 3558 e = { 3559 opacity: 0.1 3560 }, 3561 c = b.direction; 3562 "elastic" === d && (e["down" === c || "up" === c ? "top" : "left"] = ("up" === c || "left" === c ? "-" : "+") + "=200px"); 3563 a.wrap.animate(e, { 3564 duration: "none" === d ? 0 : a.prevSpeed, 3565 easing: a.prevEasing, 3566 complete: function() { 3567 f(this).trigger("onReset").remove() 3568 } 3569 }) 3570 } 3571 }; 3572 b.helpers.overlay = { 3573 defaults: { 3574 closeClick: !0, 3575 speedOut: 200, 3576 showEarly: !0, 3577 css: {}, 3578 locked: !t, 3579 fixed: !0 3580 }, 3581 overlay: null, 3582 fixed: !1, 3583 el: f("html"), 3584 create: function(a) { 3585 var d; 3586 a = f.extend({}, this.defaults, a); 3587 this.overlay && 3588 this.close(); 3589 d = b.coming ? b.coming.parent : a.parent; 3590 this.overlay = f('<div class="fancybox-overlay"></div>').appendTo(d && d.lenth ? d : "body"); 3591 this.fixed = !1; 3592 a.fixed && b.defaults.fixed && (this.overlay.addClass("fancybox-overlay-fixed"), this.fixed = !0) 3593 }, 3594 open: function(a) { 3595 var d = this; 3596 a = f.extend({}, this.defaults, a); 3597 this.overlay ? this.overlay.unbind(".overlay").width("auto").height("auto") : this.create(a); 3598 this.fixed || (q.bind("resize.overlay", f.proxy(this.update, this)), this.update()); 3599 a.closeClick && this.overlay.bind("click.overlay", 3600 function(a) { 3601 if (f(a.target).hasClass("fancybox-overlay")) return b.isActive ? b.close() : d.close(), !1 3602 }); 3603 this.overlay.css(a.css).show() 3604 }, 3605 close: function() { 3606 q.unbind("resize.overlay"); 3607 this.el.hasClass("fancybox-lock") && (f(".fancybox-margin").removeClass("fancybox-margin"), this.el.removeClass("fancybox-lock"), q.scrollTop(this.scrollV).scrollLeft(this.scrollH)); 3608 f(".fancybox-overlay").remove().hide(); 3609 f.extend(this, { 3610 overlay: null, 3611 fixed: !1 3612 }) 3613 }, 3614 update: function() { 3615 var a = "100%", 3616 b; 3617 this.overlay.width(a).height("100%"); 3618 J ? (b = Math.max(H.documentElement.offsetWidth, H.body.offsetWidth), p.width() > b && (a = p.width())) : p.width() > q.width() && (a = p.width()); 3619 this.overlay.width(a).height(p.height()) 3620 }, 3621 onReady: function(a, b) { 3622 var e = this.overlay; 3623 f(".fancybox-overlay").stop(!0, !0); 3624 e || this.create(a); 3625 a.locked && this.fixed && b.fixed && (b.locked = this.overlay.append(b.wrap), b.fixed = !1); 3626 !0 === a.showEarly && this.beforeShow.apply(this, arguments) 3627 }, 3628 beforeShow: function(a, b) { 3629 b.locked && !this.el.hasClass("fancybox-lock") && (!1 !== this.fixPosition && f("*").filter(function() { 3630 return "fixed" === 3631 f(this).css("position") && !f(this).hasClass("fancybox-overlay") && !f(this).hasClass("fancybox-wrap") 3632 }).addClass("fancybox-margin"), this.el.addClass("fancybox-margin"), this.scrollV = q.scrollTop(), this.scrollH = q.scrollLeft(), this.el.addClass("fancybox-lock"), q.scrollTop(this.scrollV).scrollLeft(this.scrollH)); 3633 this.open(a) 3634 }, 3635 onUpdate: function() { 3636 this.fixed || this.update() 3637 }, 3638 afterClose: function(a) { 3639 this.overlay && !b.coming && this.overlay.fadeOut(a.speedOut, f.proxy(this.close, this)) 3640 } 3641 }; 3642 b.helpers.title = { 3643 defaults: { 3644 type: "float", 3645 position: "bottom" 3646 }, 3647 beforeShow: function(a) { 3648 var d = b.current, 3649 e = d.title, 3650 c = a.type; 3651 f.isFunction(e) && (e = e.call(d.element, d)); 3652 if (r(e) && "" !== f.trim(e)) { 3653 d = f('<div class="fancybox-title fancybox-title-' + c + '-wrap">' + e + "</div>"); 3654 switch (c) { 3655 case "inside": 3656 c = b.skin; 3657 break; 3658 case "outside": 3659 c = b.wrap; 3660 break; 3661 case "over": 3662 c = b.inner; 3663 break; 3664 default: 3665 c = b.skin, d.appendTo("body"), J && d.width(d.width()), d.wrapInner('<span class="child"></span>'), b.current.margin[2] += Math.abs(m(d.css("margin-bottom"))) 3666 } 3667 d["top" === a.position ? "prependTo" : 3668 "appendTo"](c) 3669 } 3670 } 3671 }; 3672 f.fn.fancybox = function(a) { 3673 var d, e = f(this), 3674 c = this.selector || "", 3675 l = function(g) { 3676 var h = f(this).blur(), 3677 k = d, 3678 l, m; 3679 g.ctrlKey || g.altKey || g.shiftKey || g.metaKey || h.is(".fancybox-wrap") || (l = a.groupAttr || "data-fancybox-group", m = h.attr(l), m || (l = "rel", m = h.get(0)[l]), m && "" !== m && "nofollow" !== m && (h = c.length ? f(c) : e, h = h.filter("[" + l + '="' + m + '"]'), k = h.index(this)), a.index = k, !1 !== b.open(h, a) && g.preventDefault()) 3680 }; 3681 a = a || {}; 3682 d = a.index || 0; 3683 c && !1 !== a.live ? p.undelegate(c, "click.fb-start").delegate(c + ":not('.fancybox-item, .fancybox-nav')", 3684 "click.fb-start", l) : e.unbind("click.fb-start").bind("click.fb-start", l); 3685 this.filter("[data-fancybox-start=1]").trigger("click"); 3686 return this 3687 }; 3688 p.ready(function() { 3689 var a, d; 3690 f.scrollbarWidth === w && (f.scrollbarWidth = function() { 3691 var a = f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"), 3692 b = a.children(), 3693 b = b.innerWidth() - b.height(99).innerWidth(); 3694 a.remove(); 3695 return b 3696 }); 3697 f.support.fixedPosition === w && (f.support.fixedPosition = function() { 3698 var a = f('<div style="position:fixed;top:20px;"></div>').appendTo("body"), 3699 b = 20 === a[0].offsetTop || 15 === a[0].offsetTop; 3700 a.remove(); 3701 return b 3702 }()); 3703 f.extend(b.defaults, { 3704 scrollbarWidth: f.scrollbarWidth(), 3705 fixed: f.support.fixedPosition, 3706 parent: f("body") 3707 }); 3708 a = f(s).width(); 3709 K.addClass("fancybox-lock-test"); 3710 d = f(s).width(); 3711 K.removeClass("fancybox-lock-test"); 3712 f("<style type='text/css'>.fancybox-margin{margin-right:" + (d - a) + "px;}</style>").appendTo("head") 3713 }) 3714})(window, document, jQuery); 3715 3716 3717 3718 3719 3720 3721/*! 3722 * Media helper for fancyBox 3723 * version: 1.0.6 (Fri, 14 Jun 2013) 3724 * @requires fancyBox v2.0 or later 3725 * 3726 * Usage: 3727 * $(".fancybox").fancybox({ 3728 * helpers : { 3729 * media: true 3730 * } 3731 * }); 3732 * 3733 * Set custom URL parameters: 3734 * $(".fancybox").fancybox({ 3735 * helpers : { 3736 * media: { 3737 * youtube : { 3738 * params : { 3739 * autoplay : 0 3740 * } 3741 * } 3742 * } 3743 * } 3744 * }); 3745 * 3746 * Or: 3747 * $(".fancybox").fancybox({, 3748 * helpers : { 3749 * media: true 3750 * }, 3751 * youtube : { 3752 * autoplay: 0 3753 * } 3754 * }); 3755 * 3756 * Supports: 3757 * 3758 * Youtube 3759 * http://www.youtube.com/watch?v=opj24KnzrWo 3760 * http://www.youtube.com/embed/opj24KnzrWo 3761 * http://youtu.be/opj24KnzrWo 3762 * http://www.youtube-nocookie.com/embed/opj24KnzrWo 3763 * Vimeo 3764 * http://vimeo.com/40648169 3765 * http://vimeo.com/channels/staffpicks/38843628
vendor: 5,535 bytes, lines 3766-3914
3766 * http://vimeo.com/groups/surrealism/videos/36516384 3767 * http://player.vimeo.com/video/45074303 3768 * Metacafe 3769 * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/ 3770 * http://www.metacafe.com/watch/7635964/ 3771 * Dailymotion 3772 * http://www.dailymotion.com/video/xoytqh_dr-seuss-the-lorax-premiere_people 3773 * Twitvid 3774 * http://twitvid.com/QY7MD 3775 * Twitpic 3776 * http://twitpic.com/7p93st 3777 * Instagram 3778 * http://instagr.am/p/IejkuUGxQn/ 3779 * http://instagram.com/p/IejkuUGxQn/ 3780 * Google maps 3781 * http://maps.google.com/maps?q=Eiffel+Tower,+Avenue+Gustave+Eiffel,+Paris,+France&t=h&z=17 3782 * http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16 3783 * http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56 3784 */ 3785(function ($) { 3786 "use strict"; 3787 3788 //Shortcut for fancyBox object 3789 var F = $.fancybox, 3790 format = function( url, rez, params ) { 3791 params = params || ''; 3792 3793 if ( $.type( params ) === "object" ) { 3794 params = $.param(params, true); 3795 } 3796 3797 $.each(rez, function(key, value) { 3798 url = url.replace( '$' + key, value || '' ); 3799 }); 3800 3801 if (params.length) { 3802 url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params; 3803 } 3804 3805 return url; 3806 }; 3807 3808 //Add helper object 3809 F.helpers.media = { 3810 defaults : { 3811 youtube : { 3812 matcher : /(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i, 3813 params : { 3814 autoplay : 1, 3815 autohide : 1, 3816 fs : 1, 3817 rel : 0, 3818 hd : 1, 3819 wmode : 'opaque', 3820 enablejsapi : 1 3821 }, 3822 type : 'iframe', 3823 url : '//www.youtube.com/embed/$3' 3824 }, 3825 vimeo : { 3826 matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/, 3827 params : { 3828 autoplay : 1, 3829 hd : 1, 3830 show_title : 1, 3831 show_byline : 1, 3832 show_portrait : 0, 3833 fullscreen : 1 3834 }, 3835 type : 'iframe', 3836 url : '//player.vimeo.com/video/$1' 3837 }, 3838 metacafe : { 3839 matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/, 3840 params : { 3841 autoPlay : 'yes' 3842 }, 3843 type : 'swf', 3844 url : function( rez, params, obj ) { 3845 obj.swf.flashVars = 'playerVars=' + $.param( params, true ); 3846 3847 return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf'; 3848 } 3849 }, 3850 dailymotion : { 3851 matcher : /dailymotion.com\/video\/(.*)\/?(.*)/, 3852 params : { 3853 additionalInfos : 0, 3854 autoStart : 1 3855 }, 3856 type : 'swf', 3857 url : '//www.dailymotion.com/swf/video/$1' 3858 }, 3859 twitvid : { 3860 matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i, 3861 params : { 3862 autoplay : 0 3863 }, 3864 type : 'iframe', 3865 url : '//www.twitvid.com/embed.php?guid=$1' 3866 }, 3867 twitpic : { 3868 matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i, 3869 type : 'image', 3870 url : '//twitpic.com/show/full/$1/' 3871 }, 3872 instagram : { 3873 matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i, 3874 type : 'image', 3875 url : '//$1/p/$2/media/?size=l' 3876 }, 3877 google_maps : { 3878 matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i, 3879 type : 'iframe', 3880 url : function( rez ) { 3881 return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed'); 3882 } 3883 } 3884 }, 3885 3886 beforeLoad : function(opts, obj) { 3887 var url = obj.href || '', 3888 type = false, 3889 what, 3890 item, 3891 rez, 3892 params; 3893 3894 for (what in opts) { 3895 if (opts.hasOwnProperty(what)) { 3896 item = opts[ what ]; 3897 rez = url.match( item.matcher ); 3898 3899 if (rez) { 3900 type = item.type; 3901 params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null)); 3902 3903 url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params ); 3904 3905 break; 3906 } 3907 } 3908 } 3909 3910 if (type) { 3911 obj.href = url; 3912 obj.type = type; 3913 3914 obj.autoHeight = false;
3915 } 3916 } 3917 }; 3918 3919}(jQuery)); 3920; 3921(function ($, window, document, undefined) { 3922 3923 var pluginName = "MegaMenu", 3924 defaults = { 3925 propertyName: "value" 3926 }; 3927 var DELAY = 250; 3928 3929 // the list of menus 3930 var menus = []; 3931 3932 function CustomMenu(element, options) { 3933 this.element = element; 3934 3935 this.options = $.extend({}, defaults, options); 3936 3937 this._defaults = defaults; 3938 this._name = pluginName; 3939 3940 this.init(); 3941 } 3942 3943 CustomMenu.prototype = { 3944 isOpen: false, 3945 timeout: null, 3946 init: function () { 3947 3948 var that = this; 3949 3950 $(this).each(function(index, menu) { 3951 that.node = menu.element; 3952 that.addListeners(menu.element); 3953 3954 var $menu = $(menu.element); 3955 $menu.addClass("dropdownJavascript"); 3956 menus.push(menu.element); 3957 3958 $menu.find('ul > li').each(function(index, submenu) { 3959 if ($(submenu).find('ul').length > 0 ) { 3960 $(submenu).addClass('with-menu'); 3961 } 3962 }); 3963 }); 3964 }, 3965 addListeners: function(menu) { 3966 var that = this; 3967 $(menu).mouseover(function(e) { 3968 that.handleMouseOver.call(that, e); 3969 }).mouseout(function(e) { 3970 that.handleMouseOut.call(that, e); 3971 }); 3972 }, 3973 handleMouseOver: function (e) { 3974 var that = this; 3975 // clear the timeout 3976 this.clearTimeout(); 3977 3978 // find the parent list item 3979 //var item = ('target' in e ? e.target : e.srcElement); 3980 var item = e.target || e.srcElement; 3981 while (item.nodeName != 'LI' && item != this.node) { 3982 item = item.parentNode; 3983 } 3984 3985 // if the target is within a list item, set the timeout 3986 if (item.nodeName == 'LI') { 3987 this.toOpen = item; 3988 this.timeout = setTimeout(function() { 3989 that.open.call(that); 3990 }, this.options.delay); 3991 } 3992 3993 }, 3994 handleMouseOut: function () { 3995 var that = this; 3996 // clear the timeout 3997 this.clearTimeout(); 3998 3999 this.timeout = setTimeout(function() { 4000 that.close.call(that); 4001 }, this.options.delay); 4002 4003 }, 4004 clearTimeout: function () { 4005 4006 // clear the timeout 4007 if (this.timeout) { 4008 clearTimeout(this.timeout); 4009 this.timeout = null; 4010 } 4011 4012 }, 4013 open: function () { 4014 4015 var that = this; 4016 // store that the menu is open 4017 this.isOpen = true; 4018 4019 // loop over the list items with the same parent 4020 var items = $(this.toOpen).parent().children('li'); 4021 $(items).each(function(index, item) { 4022 $(item).find("ul").each(function(index, submenu) { 4023 if (item != that.toOpen) { 4024 // close the submenu 4025 $(item).removeClass("dropdownOpen"); 4026 that.close(item); 4027 4028 } else if (!$(item).hasClass('dropdownOpen')) { 4029 4030 // open the submenu 4031 //if ( !$(item).parents('li').hasClass('has-mega-menu') ) { 4032 $(item).addClass("dropdownOpen"); 4033 //} 4034 4035 4036 // determine the location of the edges of the submenu 4037 var left = 0; 4038 var node = submenu; 4039 while (node) { 4040 //abs is because when you make menus right to left 4041 //the offsetLeft would be negative 4042 left += Math.abs(node.offsetLeft); 4043 node = node.offsetParent; 4044 } 4045 var right = left + submenu.offsetWidth; 4046 4047 4048 //We should refactor this code to execute only when menu is vertical 4049 var menuHeight = $(submenu).outerHeight(); 4050 var parentTop = $(submenu).offset().top - $(window).scrollTop(); 4051 var totalHeight = menuHeight + parentTop; 4052 var windowHeight = window.innerHeight; 4053 4054 /* if (totalHeight > windowHeight) { 4055 var bestTop = (windowHeight - totalHeight) - 20; 4056 $(submenu).css('margin-top', bestTop + "px"); 4057 }*/ 4058 4059 //remove any previous classes 4060 $(item).removeClass('dropdownRightToLeft'); 4061 4062 // move the submenu to the right of the item if appropriate 4063 if (left < 0) $(item).addClass('dropdownLeftToRight'); 4064 4065 // move the submenu to the left of the item if appropriate 4066 if (right > document.body.clientWidth) { 4067 $(item).addClass('dropdownRightToLeft'); 4068 } 4069 4070 } 4071 }); 4072 }); 4073 4074 }, 4075 4076 4077 close: function (node) { 4078 4079 // if no node was specified, close all menus 4080 if (!node) { 4081 this.isOpen = false;
4082 node = this.node; 4083 } 4084 4085 // loop over the items, closing their submenus 4086 $(node).find('li').each(function(index, item) { 4087 $(item).removeClass('dropdownOpen'); 4088 }); 4089 4090 } 4091 }; 4092 4093 $.fn[pluginName] = function (options) { 4094 return this.each(function () { 4095 if (!$.data(this, "plugin_" + pluginName)) { 4096 $.data(this, "plugin_" + pluginName, 4097 new CustomMenu(this, options)); 4098 } 4099 }); 4100 }; 4101 4102})(jQuery, window, document); 4103 4104/* Modernizr 2.6.2 (Custom Build) | MIT & BSD 4105 * Build: http://modernizr.com/download/#-cssanimations-csstransitions-touch-shiv-cssclasses-prefixed-teststyles-testprop-testallprops-prefixes-domprefixes-load 4106 */ 4107; 4108window.Modernizr = function(a, b, c) { 4109 function z(a) { 4110 j.cssText = a 4111 } 4112 4113 function A(a, b) { 4114 return z(m.join(a + ";") + (b || "")) 4115 } 4116 4117 function B(a, b) { 4118 return typeof a === b 4119 } 4120 4121 function C(a, b) { 4122 return !!~("" + a).indexOf(b) 4123 } 4124 4125 function D(a, b) { 4126 for (var d in a) { 4127 var e = a[d]; 4128 if (!C(e, "-") && j[e] !== c) return b == "pfx" ? e : !0 4129 } 4130 return !1 4131 } 4132 4133 function E(a, b, d) { 4134 for (var e in a) { 4135 var f = b[a[e]]; 4136 if (f !== c) return d === !1 ? a[e] : B(f, "function") ? f.bind(d || b) : f 4137 } 4138 return !1 4139 } 4140 4141 function F(a, b, c) { 4142 var d = a.charAt(0).toUpperCase() + a.slice(1), 4143 e = (a + " " + o.join(d + " ") + d).split(" "); 4144 return B(b, "string") || B(b, "undefined") ? D(e, b) : (e = (a + " " + p.join(d + " ") + d).split(" "), E(e, b, c)) 4145 } 4146 var d = "2.6.2", 4147 e = {}, 4148 f = !0, 4149 g = b.documentElement, 4150 h = "modernizr", 4151 i = b.createElement(h), 4152 j = i.style, 4153 k, l = {}.toString, 4154 m = " -webkit- -moz- -o- -ms- ".split(" "), 4155 n = "Webkit Moz O ms", 4156 o = n.split(" "), 4157 p = n.toLowerCase().split(" "), 4158 q = {}, 4159 r = {}, 4160 s = {}, 4161 t = [], 4162 u = t.slice, 4163 v, w = function(a, c, d, e) { 4164 var f, i, j, k, l = b.createElement("div"), 4165 m = b.body, 4166 n = m || b.createElement("body"); 4167 if (parseInt(d, 10)) 4168 while (d--) j = b.createElement("div"), j.id = e ? e[d] : h + (d + 1), l.appendChild(j); 4169 return f = ["­", '<style id="s', h, '">', a, "</style>"].join(""), l.id = h, (m ? l : n).innerHTML += f, n.appendChild(l), m || (n.style.background = "", n.style.overflow = "hidden", k = g.style.overflow, g.style.overflow = "hidden", g.appendChild(n)), i = c(l, a), m ? l.parentNode.removeChild(l) : (n.parentNode.removeChild(n), g.style.overflow = k), !!i 4170 }, 4171 x = {}.hasOwnProperty, 4172 y; 4173 !B(x, "undefined") && !B(x.call, "undefined") ? y = function(a, b) { 4174 return x.call(a, b) 4175 } : y = function(a, b) { 4176 return b in a && B(a.constructor.prototype[b], "undefined") 4177 }, Function.prototype.bind || (Function.prototype.bind = function(b) { 4178 var c = this; 4179 if (typeof c != "function") throw new TypeError; 4180 var d = u.call(arguments, 1), 4181 e = function() { 4182 if (this instanceof e) { 4183 var a = function() {}; 4184 a.prototype = c.prototype; 4185 var f = new a, 4186 g = c.apply(f, d.concat(u.call(arguments))); 4187 return Object(g) === g ? g : f 4188 } 4189 return c.apply(b, d.concat(u.call(arguments))) 4190 }; 4191 return e 4192 }), q.touch = function() { 4193 var c; 4194 return "ontouchstart" in a || a.DocumentTouch && b instanceof DocumentTouch ? c = !0 : w(["@media (", m.join("touch-enabled),("), h, ")", "{#modernizr{top:9px;position:absolute}}"].join(""), function(a) { 4195 c = a.offsetTop === 9 4196 }), c 4197 }, q.cssanimations = function() { 4198 return F("animationName") 4199 }, q.csstransitions = function() { 4200 return F("transition") 4201 }; 4202 for (var G in q) y(q, G) && (v = G.toLowerCase(), e[v] = q[G](), t.push((e[v] ? "" : "no-") + v)); 4203 return e.addTest = function(a, b) { 4204 if (typeof a == "object") 4205 for (var d in a) y(a, d) && e.addTest(d, a[d]); 4206 else { 4207 a = a.toLowerCase(); 4208 if (e[a] !== c) return e; 4209 b = typeof b == "function" ? b() : b, typeof f != "undefined" && f && (g.className += " " + (b ? "" : "no-") + a), e[a] = b 4210 } 4211 return e 4212 }, z(""), i = k = null, 4213 function(a, b) { 4214 function k(a, b) { 4215 var c = a.createElement("p"), 4216 d = a.getElementsByTagName("head")[0] || a.documentElement; 4217 return c.innerHTML = "x<style>" + b + "</style>", d.insertBefore(c.lastChild, d.firstChild) 4218 } 4219 4220 function l() { 4221 var a = r.elements; 4222 return typeof a == "string" ? a.split(" ") : a 4223 } 4224 4225 function m(a) { 4226 var b = i[a[g]]; 4227 return b || (b = {}, h++, a[g] = h, i[h] = b), b 4228 } 4229 4230 function n(a, c, f) { 4231 c || (c = b); 4232 if (j) return c.createElement(a); 4233 f || (f = m(c)); 4234 var g; 4235 return f.cache[a] ? g = f.cache[a].cloneNode() : e.test(a) ? g = (f.cache[a] = f.createElem(a)).cloneNode() : g = f.createElem(a), g.canHaveChildren && !d.test(a) ? f.frag.appendChild(g) : g 4236 } 4237 4238 function o(a, c) { 4239 a || (a = b); 4240 if (j) return a.createDocumentFragment(); 4241 c = c || m(a); 4242 var d = c.frag.cloneNode(), 4243 e = 0, 4244 f = l(), 4245 g = f.length; 4246 for (; e < g; e++) d.createElement(f[e]); 4247 return d 4248 } 4249 4250 function p(a, b) { 4251 b.cache || (b.cache = {}, b.createElem = a.createElement, b.createFrag = a.createDocumentFragment, b.frag = b.createFrag()), a.createElement = function(c) { 4252 return r.shivMethods ? n(c, a, b) : b.createElem(c) 4253 }, a.createDocumentFragment = Function("h,f", "return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(" + l().join().replace(/\w+/g, function(a) { 4254 return b.createElem(a), b.frag.createElement(a), 'c("' + a + '")' 4255 }) + ");return n}")(r, b.frag) 4256 } 4257 4258 function q(a) { 4259 a || (a = b); 4260 var c = m(a); 4261 return r.shivCSS && !f && !c.hasCSS && (c.hasCSS = !!k(a, "article,aside,figcaption,figure,footer,header,hgroup,nav,section{dis
4261play:block}mark{background:#FF0;color:#000}")), j || p(a, c), a 4262 } 4263 var c = a.html5 || {}, 4264 d = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i, 4265 e = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i, 4266 f, g = "_html5shiv", 4267 h = 0, 4268 i = {}, 4269 j; 4270 (function() { 4271 try { 4272 var a = b.createElement("a"); 4273 a.innerHTML = "<xyz></xyz>", f = "hidden" in a, j = a.childNodes.length == 1 || function() { 4274 b.createElement("a"); 4275 var a = b.createDocumentFragment(); 4276 return typeof a.cloneNode == "undefined" || typeof a.createDocumentFragment == "undefined" || typeof a.createElement == "undefined" 4277 }() 4278 } catch (c) { 4279 f = !0, j = !0 4280 } 4281 })(); 4282 var r = { 4283 elements: c.elements || "abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video", 4284 shivCSS: c.shivCSS !== !1, 4285 supportsUnknownElements: j, 4286 shivMethods: c.shivMethods !== !1, 4287 type: "default", 4288 shivDocument: q, 4289 createElement: n, 4290 createDocumentFragment: o 4291 }; 4292 a.html5 = r, q(b) 4293 }(this, b), e._version = d, e._prefixes = m, e._domPrefixes = p, e._cssomPrefixes = o, e.testProp = function(a) { 4294 return D([a]) 4295 }, e.testAllProps = F, e.testStyles = w, e.prefixed = function(a, b, c) { 4296 return b ? F(a, b, c) : F(a, "pfx") 4297 }, g.className = g.className.replace(/(^|\s)no-js(\s|$)/, "$1$2") + (f ? " js " + t.join(" ") : ""), e 4298}(this, this.document), 4299function(a, b, c) { 4300 function d(a) { 4301 return "[object Function]" == o.call(a) 4302 } 4303 4304 function e(a) { 4305 return "string" == typeof a 4306 } 4307 4308 function f() {} 4309 4310 function g(a) { 4311 return !a || "loaded" == a || "complete" == a || "uninitialized" == a 4312 } 4313 4314 function h() { 4315 var a = p.shift(); 4316 q = 1, a ? a.t ? m(function() { 4317 ("c" == a.t ? B.injectCss : B.injectJs)(a.s, 0, a.a, a.x, a.e, 1) 4318 }, 0) : (a(), h()) : q = 0 4319 } 4320 4321 function i(a, c, d, e, f, i, j) { 4322 function k(b) { 4323 if (!o && g(l.readyState) && (u.r = o = 1, !q && h(), l.onload = l.onreadystatechange = null, b)) { 4324 "img" != a && m(function() { 4325 t.removeChild(l) 4326 }, 50); 4327 for (var d in y[c]) y[c].hasOwnProperty(d) && y[c][d].onload() 4328 } 4329 } 4330 var j = j || B.errorTimeout, 4331 l = b.createElement(a), 4332 o = 0, 4333 r = 0, 4334 u = { 4335 t: d, 4336 s: c, 4337 e: f, 4338 a: i, 4339 x: j 4340 }; 4341 1 === y[c] && (r = 1, y[c] = []), "object" == a ? l.data = c : (l.src = c, l.type = a), l.width = l.height = "0", l.onerror = l.onload = l.onreadystatechange = function() { 4342 k.call(this, r) 4343 }, p.splice(e, 0, u), "img" != a && (r || 2 === y[c] ? (t.insertBefore(l, s ? null : n), m(k, j)) : y[c].push(l)) 4344 } 4345 4346 function j(a, b, c, d, f) { 4347 return q = 0, b = b || "j", e(a) ? i("c" == b ? v : u, a, b, this.i++, c, d, f) : (p.splice(this.i++, 0, a), 1 == p.length && h()), this 4348 } 4349 4350 function k() { 4351 var a = B; 4352 return a.loader = { 4353 load: j, 4354 i: 0 4355 }, a 4356 } 4357 var l = b.documentElement, 4358 m = a.setTimeout, 4359 n = b.getElementsByTagName("script")[0], 4360 o = {}.toString, 4361 p = [], 4362 q = 0, 4363 r = "MozAppearance" in l.style, 4364 s = r && !!b.createRange().compareNode, 4365 t = s ? l : n.parentNode, 4366 l = a.opera && "[object Opera]" == o.call(a.opera), 4367 l = !!b.attachEvent && !l, 4368 u = r ? "object" : l ? "script" : "img", 4369 v = l ? "script" : u, 4370 w = Array.isArray || function(a) { 4371 return "[object Array]" == o.call(a) 4372 }, 4373 x = [], 4374 y = {}, 4375 z = { 4376 timeout: function(a, b) { 4377 return b.length && (a.timeout = b[0]), a 4378 } 4379 }, 4380 A, B; 4381 B = function(a) { 4382 function b(a) { 4383 var a = a.split("!"), 4384 b = x.length, 4385 c = a.pop(), 4386 d = a.length, 4387 c = { 4388 url: c, 4389 origUrl: c, 4390 prefixes: a 4391 }, 4392 e, f, g; 4393 for (f = 0; f < d; f++) g = a[f].split("="), (e = z[g.shift()]) && (c = e(c, g)); 4394 for (f = 0; f < b; f++) c = x[f](c); 4395 return c 4396 } 4397 4398 function g(a, e, f, g, h) { 4399 var i = b(a), 4400 j = i.autoCallback; 4401 i.url.split(".").pop().split("?").shift(), i.bypass || (e && (e = d(e) ? e : e[a] || e[g] || e[a.split("/").pop().split("?")[0]]), i.instead ? i.instead(a, e, f, g, h) : (y[i.url] ? i.noexec = !0 : y[i.url] = 1, f.load(i.url, i.forceCSS || !i.forceJS && "css" == i.url.split(".").pop().split("?").shift() ? "c" : c, i.noexec, i.attrs, i.timeout), (d(e) || d(j)) && f.load(function() { 4402 k(), e && e(i.origUrl, h, g), j && j(i.origUrl, h, g), y[i.url] = 2 4403 }))) 4404 } 4405 4406 function h(a, b) { 4407 function c(a, c) { 4408 if (a) { 4409 if (e(a)) c || (j = function() { 4410 var a = [].slice.call(arguments); 4411 k.apply(this, a), l() 4412 }), g(a, j, b, 0, h); 4413 else if (Object(a) === a) 4414 for (n in m = function() { 4415 var b = 0, 4416 c; 4417 for (c in a) a.hasOwnProperty(c) && b++; 4418 return b 4419 }(), a) a.hasOwnProperty(n) && (!c && !--m && (d(j) ? j = function() { 4420 var a = [].slice.call(arguments); 4421 k.apply(this, a), l() 4422 } : j[n] = function(a) { 4423 return function() { 4424 var b = [].slice.call(arguments); 4425 a && a.apply(this, b), l() 4426 } 4427 }(k[n])), g(a[n], j, b, n, h)) 4428 } else !c && l() 4429 } 4430 var h = !!a.test, 4431 i = a.load || a.both, 4432 j = a.callback || f, 4433 k = j, 4434 l = a.complete || f, 4435 m, n; 4436 c(h ? a.yep : a.nope, !!i), i && c(i) 4437 } 4438 var i, j, l = this.yepnope.loader; 4439 if (e(a)) g(a, 0, l, 0); 4440 else if (w(a)) 4441 for (i = 0; i < a.length; i++) j = a[i], e(j) ? g(j, 0, l, 0) : w(j) ? B(j) : Object(j) === j && h(j, l); 4442 else Object(a) === a && h(a, l) 4443 }, B.addPrefix = function(a, b) { 4444 z[a] = b 4445 }, B.addFilter = function(a) { 4446 x.push(a) 4447 }, B.errorTimeout = 1e4, null == b.readyState && b.addEventListener && (b.readyState = "loading", b.addEventListener("DOMContentLoaded", A = function() { 4448 b.removeEventListener("DOMContentLoaded", A, 0), b.readyState = "complete" 4449 }, 0)), a.yepnope = k(), a.yepnope.executeStack = h, a.yepnope.injectJs = function(a, c, d, e, i, j) { 4450 var k = b.createElement("script"), 4451 l, o, e = e || B.errorTimeout; 4452 k.src = a; 4453 for (o in d) k.setAttribute(o, d[o]); 4454 c = j ? h : c || f, k.onreadystatechange = k.onload = function() { 4455 !l && g(k.readyState) && (l = 1, c(), k.onload = k.onreadystatechange = null) 4456 }, m(function() { 4457 l || (l = 1, c(1)) 4458 }, e), i ? k.onload() : n.parentNode.insertBefore(k, n) 4459 }, a.yepnope.injectCss = function(a, c, d, e, g, i) { 4460 var e = b.createElement("link"), 4461 j, c = i ? h : c || f; 4462 e.href = a, e.rel = "stylesheet", e.type = "text/css"; 4463 for (j in d) e.setAttribute(j, d[j]); 4464 g || (n.parentNode.insertBefore(e, n), m(c, 0)) 4465 } 4466}(this, document), Modernizr.load = function() { 4467 yepnope.apply(window, [].slice.call(arguments, 0)) 4468}; 4469 4470 4471; 4472(function($, window, undefined) { 4473 4474 'use strict'; 4475 4476 // global 4477 var Modernizr = window.Modernizr, 4478 $body = $('body'); 4479 4480 $.DLMenu = function(options, element) { 4481 this.$el = $(element); 4482 this._init(options); 4483 }; 4484 4485 $.DLMenu.defaults = { 4486 animationClasses: { 4487 classin: 'mk-vm-animate-in-' + mk_vertical_header_anim, 4488 classout: 'mk-vm-animate-out-' + mk_vertical_header_anim 4489 }, 4490 onLevelClick: function(el, name) { 4491 return false;
4492 }, 4493 onLinkClick: function(el, ev) { 4494 return false; 4495 } 4496 }; 4497 4498 $.DLMenu.prototype = { 4499 _init: function(options) { 4500 4501 this.options = $.extend(true, {}, $.DLMenu.defaults, options); 4502 this._config(); 4503 4504 var animEndEventNames = { 4505 'WebkitAnimation': 'webkitAnimationEnd', 4506 'OAnimation': 'oAnimationEnd', 4507 'msAnimation': 'MSAnimationEnd', 4508 'animation': 'animationend' 4509 }, 4510 transEndEventNames = { 4511 'WebkitTransition': 'webkitTransitionEnd', 4512 'MozTransition': 'transitionend', 4513 'OTransition': 'oTransitionEnd', 4514 'msTransition': 'MSTransitionEnd', 4515 'transition': 'transitionend' 4516 }; 4517 4518 this.animEndEventName = animEndEventNames[Modernizr.prefixed('animation')] + '.dlmenu'; 4519 this.transEndEventName = transEndEventNames[Modernizr.prefixed('transition')] + '.dlmenu'; 4520 4521 this.animEndEventNameUnsufixed = animEndEventNames[Modernizr.prefixed('animation')]; 4522 this.transEndEventNameUnsufixed = transEndEventNames[Modernizr.prefixed('transition')]; 4523 4524 this.supportAnimations = Modernizr.cssanimations; 4525 this.supportTransitions = Modernizr.csstransitions; 4526 4527 this._initEvents(); 4528 4529 }, 4530 _config: function() { 4531 this.open = false; 4532 this.$trigger = this.$el.children('.mk-vm-trigger'); 4533 this.$menu = this.$el.children('ul.mk-vm-menu'); 4534 this.$menuitems = this.$menu.find('li:not(.mk-vm-back)'); 4535 this.$el.find('ul.sub-menu').prepend('<li class="mk-vm-back"><a href="#">' + mk_vertical_header_back + '</a></li>'); 4536 this.$back = this.$menu.find('li.mk-vm-back'); 4537 }, 4538 _initEvents: function() { 4539 4540 var self = this; 4541 4542 $('.mk-vm-menuwrapper a').on('transitionend', function(event) { 4543 event.stopPropagation(); 4544 }); 4545 4546 this.$menuitems.on('click.dlmenu', 'a', function(event) { 4547 4548 // Breaks smooth scroll in vertical menu 4549 // event.stopPropagation(); 4550 4551 var $item = $(event.delegateTarget), 4552 $submenu = $(event.currentTarget).siblings('ul.sub-menu'); 4553 4554 if ($submenu.length > 0) { 4555 4556 var $flyin = $submenu.clone().css('opacity', 0).insertAfter(self.$menu), 4557 onAnimationEndFn = function() { 4558 self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classout).addClass('mk-vm-subview'); 4559 $item.addClass('mk-vm-subviewopen').parents('.mk-vm-subviewopen:first').removeClass('mk-vm-subviewopen').addClass('mk-vm-subview'); 4560 $flyin.remove(); 4561 }; 4562 4563 setTimeout(function() { 4564 $flyin.addClass(self.options.animationClasses.classin); 4565 self.$menu.addClass(self.options.animationClasses.classout); 4566 if (self.supportAnimations) { 4567 self.$menu.on(self.animEndEventName, onAnimationEndFn); 4568 } else { 4569 onAnimationEndFn.call(); 4570 } 4571 4572 self.options.onLevelClick($item, $item.children('a:first').text()); 4573 }); 4574 4575 4576 if (self.open) { 4577 self._closeMenu(); 4578 } else { 4579 self._openMenu(); 4580 } 4581 4582 return false; 4583 4584 } else { 4585 self.options.onLinkClick($item, event); 4586 } 4587 4588 }); 4589 4590 4591 // this.$trigger.on('click.dlmenu', function() { 4592 4593 // if (self.open) { 4594 // self._closeMenu(); 4595 // } else { 4596 // // if( ! $(this).hasClass('menu-item-has-children') ) return false; 4597 // self._openMenu(); 4598 // } 4599 // return false; 4600 4601 // }); 4602 4603 this.$back.on('click.dlmenu', function(event) { 4604 4605 var $this = $(this), 4606 $submenu = $this.parents('ul.sub-menu:first'), 4607 $item = $submenu.parent(), 4608 4609 $flyin = $submenu.clone().insertAfter(self.$menu); 4610 4611 var onAnimationEndFn = function() { 4612 self.$menu.off(self.animEndEventName).removeClass(self.options.animationClasses.classin); 4613 $flyin.remove(); 4614 }; 4615 4616 setTimeout(function() { 4617 $flyin.addClass(self.options.animationClasses.classout); 4618 self.$menu.addClass(self.options.animationClasses.classin); 4619 if (self.supportAnimations) { 4620 self.$menu.on(self.animEndEventName, onAnimationEndFn); 4621 } else { 4622 onAnimationEndFn.call(); 4623 } 4624 4625 $item.removeClass('mk-vm-subviewopen'); 4626 4627 var $subview = $this.parents('.mk-vm-subview:first'); 4628 if ($subview.is('li')) { 4629 $subview.addClass('mk-vm-subviewopen'); 4630 } 4631 $subview.removeClass('mk-vm-subview'); 4632 }); 4633 4634 return false;
4635 4636 }); 4637 4638 }, 4639 closeMenu: function() { 4640 if (this.open) { 4641 this._closeMenu(); 4642 } 4643 }, 4644 _closeMenu: function() { 4645 var self = this, 4646 onTransitionEndFn = function() { 4647 self.$menu.off(self.transEndEventName); 4648 self._resetMenu(); 4649 }; 4650 4651 this.$menu.removeClass('mk-vm-menuopen'); 4652 this.$menu.addClass('mk-vm-menu-toggle'); 4653 this.$trigger.removeClass('mk-vm-active'); 4654 4655 if (this.supportTransitions) { 4656 this.$menu.on(this.transEndEventName, onTransitionEndFn); 4657 } else { 4658 onTransitionEndFn.call(); 4659 } 4660 4661 this.open = false; 4662 }, 4663 openMenu: function() { 4664 if (!this.open) { 4665 this._openMenu(); 4666 } 4667 }, 4668 _openMenu: function() { 4669 var self = this; 4670 $body.off('click').on('click.dlmenu', function() { 4671 self._closeMenu(); 4672 }); 4673 this.$menu.addClass('mk-vm-menuopen mk-vm-menu-toggle').on(this.transEndEventName, function() { 4674 $(this).removeClass('mk-vm-menu-toggle'); 4675 }); 4676 this.$trigger.addClass('mk-vm-active'); 4677 this.open = true; 4678 }, 4679 _resetMenu: function() { 4680 this.$menu.removeClass('mk-vm-subview'); 4681 this.$menuitems.removeClass('mk-vm-subview mk-vm-subviewopen'); 4682 } 4683 }; 4684 4685 var logError = function(message) { 4686 if (window.console) { 4687 window.console.error(message); 4688 } 4689 }; 4690 4691 $.fn.dlmenu = function(options) { 4692 if (typeof options === 'string') { 4693 var args = Array.prototype.slice.call(arguments, 1); 4694 this.each(function() { 4695 var instance = $.data(this, 'dlmenu'); 4696 if (!instance) { 4697 logError("cannot call methods on dlmenu prior to initialization; " + 4698 "attempted to call method '" + options + "'"); 4699 return; 4700 } 4701 if (!$.isFunction(instance[options]) || options.charAt(0) === "_") { 4702 logError("no such method '" + options + "' for dlmenu instance"); 4703 return; 4704 } 4705 instance[options].apply(instance, args); 4706 }); 4707 } else { 4708 this.each(function() { 4709 var instance = $.data(this, 'dlmenu'); 4710 if (instance) { 4711 instance._init(); 4712 } else { 4713 instance = $.data(this, 'dlmenu', new $.DLMenu(options, this)); 4714 } 4715 }); 4716 } 4717 return this; 4718 }; 4719 4720})(jQuery, window); 4721( function($) { 4722 'use strict'; 4723 4724 /* 4725 * Define popup / hover states manually to prevent click for IE on touchdevices 4726 */ 4727 4728 $('.menu-item-has-children').children('a').attr('aria-haspopup', 'true'); 4729 $('.animated-column-item').attr('aria-haspopup', 'true'); 4730 4731})( jQuery ); 4732(function($) { 4733 'use strict'; 4734 4735 var Accordion = function(el) { 4736 // Private 4737 var that = this, 4738 $el = $(el), 4739 initial = $el.data('initialindex'), 4740 timeout; 4741 4742 // Public 4743 this.$el = $el; 4744 this.$single = $('.' + this.dom.single, $el); 4745 this.isExpendable = ($el.data('style') === 'toggle-action'); 4746 4747 // Init 4748 this.bindClicks(); 4749 // Reveal initial tab on load event (wait for possible images inside) 4750 $(window).on('load', function() { 4751 if( initial !== -1 ) that.show(that.$single.eq(initial)) 4752 }); 4753 $(window).on('resize', function() { 4754 clearTimeout(timeout); 4755 timeout = setTimeout(that.bindClicks.bind(that), 500); 4756 }); 4757 } 4758 4759 Accordion.prototype.dom = { 4760 // only class names please! 4761 single : 'mk-accordion-single', 4762 tab : 'mk-accordion-tab', 4763 pane : 'mk-accordion-pane', 4764 current : 'current', 4765 mobileToggle : 'mobile-false', 4766 mobileBreakPoint : 767 4767 } 4768 4769 Accordion.prototype.bindClicks = function() { 4770 // Prevent multiple events binding 4771 this.$single.off('click', '.' + this.dom.tab); 4772 4773 if( !(window.matchMedia('(max-width: ' + this.dom.mobileBreakPoint +'px)').matches 4774 && this.$el.hasClass(this.dom.mobileToggle)) ) { 4775 4776 this.$single.on('click', '.' + this.dom.tab, this.handleEvent.bind(this)); 4777 // When website is loaded in mobile view and resized to desktop 'current' will 4778 // inherit display: none from css. Repair it by calling show() on this element 4779 var $current = $('.' + this.dom.current, this.$el); 4780 if($('.' + this.dom.pane, $current).css('display') === 'none') this.show($current); 4781 } 4782 } 4783 4784 Accordion.prototype.handleEvent = function(e) { 4785 e.preventDefault(); 4786 e.stopPropagation(); 4787 4788 var $single = $(e.delegateTarget); 4789 4790 if(!$single.hasClass(this.dom.current)) { 4791 this.show($single); 4792 } 4793 else { 4794 if(this.isExpendable) this.hide($single); 4795 } 4796 } 4797 4798 Accordion.prototype.hide = function($single) { 4799 $single.removeClass(this.dom.current);
4800 $('.' + this.dom.pane, $single).slideUp(); 4801 } 4802 4803 Accordion.prototype.show = function($single) { 4804 // hide currently opened tab 4805 if(!this.isExpendable) { 4806 var that = this; 4807 this.hide($('.' + this.dom.current, that.$el)); 4808 } 4809 4810 $single.addClass(this.dom.current); 4811 $('.' + this.dom.pane, $single).slideDown(); 4812 } 4813 4814 4815 4816 // /////////////////////////////////////// 4817 // 4818 // Apply to: 4819 // 4820 // /////////////////////////////////////// 4821 4822 $('.mk-accordion').each(function() { 4823 new Accordion(this); 4824 }); 4825 4826})(jQuery); 4827 4828(function($) { 4829 4830 'use strict'; 4831 4832 if( typeof Raphael === 'undefined' ) return; 4833 4834 var SkillDiagram = function( el ) { 4835 this.el = el; 4836 } 4837 4838 SkillDiagram.prototype = { 4839 init : function() { 4840 this.cacheElements(); 4841 this.createDiagram(); 4842 this.$skills.each( this.createSkill.bind( this ) ); 4843 }, 4844 4845 cacheElements : function() { 4846 this.$el = $( this.el ); 4847 this.$skills = this.$el.find( '.mk-meter-arch'); 4848 this.config = this.$el.data(); 4849 this.config.radius = this.config.dimension / 2; 4850 }, 4851 4852 random : function( l, u ) { 4853 return Math.floor( ( Math.random() * ( u - l + 1 ) ) + l ); 4854 }, 4855 4856 createDiagram : function() { 4857 var self = this; 4858 4859 this.diagram = Raphael( this.el, this.config.dimension, this.config.dimension ); 4860 4861 this.diagram.circle( this.config.radius, this.config.radius, 80 ).attr({ 4862 stroke: 'none', 4863 fill: this.config.circleColor 4864 }); 4865 4866 // Export title 4867 this.title = this.diagram.text( this.config.radius, this.config.radius, this.config.defaultText ).attr({ 4868 font: "22px helvetica", 4869 fill: this.config.defaultTextColor 4870 }).toFront(); 4871 4872 this.diagram.customAttributes.arc = function(value, color, rad){ 4873 var v = 3.6 * value, 4874 alpha = v == 360 ? 359.99 : v, 4875 r = self.random( 91, 240 ), 4876 a = (r - alpha) * Math.PI/180, 4877 b = r * Math.PI/180, 4878 sx = self.config.radius + rad * Math.cos(b), 4879 sy = self.config.radius - rad * Math.sin(b), 4880 x = self.config.radius + rad * Math.cos(a), 4881 y = self.config.radius - rad * Math.sin(a), 4882 path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]]; 4883 4884 return { 4885 path: path, 4886 stroke: color 4887 } 4888 } 4889 }, 4890 4891 createSkill : function( id, el ) { 4892 var self = this, 4893 $this = $( el ), 4894 config = $this.data(), 4895 radMin = 72, 4896 radVal = 27, 4897 newRad = radMin + ( radVal * (id + 1) ); 4898 4899 var $path = this.diagram.path().attr({ 4900 'stroke-width': 28, 4901 arc: [config.percent, config.color, newRad] 4902 }); 4903 4904 $path.mouseover( function() { 4905 self.showSkill( this, config.name, config.percent ); 4906 }).mouseout( function() { 4907 self.hideSkill( this ) 4908 }); 4909 }, 4910 4911 showSkill : function( self, name, percent ) { 4912 var $this = self, 4913 time = 250; 4914 4915 //solves IE problem 4916 if(Raphael.type != 'VML') $this.toFront(); 4917 4918 $this.animate({ 4919 'stroke-width': 50, 4920 'opacity': 0.9, 4921 }, 800, 'elastic' ); 4922 4923 this.title.stop() 4924 .animate({ opacity: 0 }, time, '>', function(){ 4925 this.attr({ text: name + '\n' + percent + '%' }).animate({ opacity: 1 }, time, '<'); 4926 }); 4927 }, 4928 4929 hideSkill : function( self ) { 4930 var $this = self, 4931 self = this, 4932 time = 250; 4933 4934 $this.stop().animate({ 4935 'stroke-width': 28, 4936 opacity: 1 4937 }, time * 4, 'elastic' ); 4938 4939 self.title.stop() 4940 .animate({ opacity: 0 }, time, '>', function(){ 4941 self.title.attr({ text: self.config.defaultText }) 4942 .animate({ opacity: 1 }, time, '<'); 4943 }); 4944 } 4945 } 4946 4947 4948 $( '.mk-skill-diagram' ).each( function() { 4949 var diagram = new SkillDiagram( this ); 4950 diagram.init(); 4951 }); 4952 4953 4954})(jQuery); 4955/* 4956 * Tab delegation 4957 * Action for modules when we don't have access to chidren DOM on processing templates 4958 * yet we want ass option of opening link in new tab. 4959 * Helpful for use with external widgets like flickr 4960 */ 4961 4962(function($) { 4963 4964 'use strict'; 4965 4966 $( '[data-js="tab-delegation"]' ).each( tabDelegation ); 4967 4968 function tabDelegation() { 4969 var $this = $( this ), 4970 data = $this.data(); 4971 4972 // Create delegation on parent element to affect async loaded children 4973 if( data.tab ) $this.on( 'click', 'a', openInTab ); 4974 } 4975 4976 function openInTab( e ) { 4977 e.preventDefault(); 4978 4979 var $this = $( this ), 4980 url = $this.attr( 'href' ); 4981 4982 window.open( url, '_blank' ); 4983 } 4984 4985})(jQuery); 4986(function($) { 4987 'use strict'; 4988 4989 var Toggle = function(el) { 4990 var that = this, 4991 $el = $(el); 4992 4993 this.$el = $el; 4994 4995 $(window).on('load', function() { 4996 $el.toggle(that.open.bind(that), that.close.bind(that)); 4997 }); 4998 }; 4999 5000 Toggle.prototype.dom = { 5001 pane : 'mk-toggle-pane', 5002 active : 'active-toggle' 5003 }; 5004 5005 Toggle.prototype.open = function() { 5006 var $this = this.$el; 5007 $this.addClass(this.dom.active); 5008 $this.siblings('.' + this.dom.pane).slideDown(200); 5009 }; 5010 5011 Toggle.prototype.close = function() { 5012 var $this = this.$el; 5013 $this.removeClass(this.dom.active); 5014 $this.siblings('.' + this.dom.pane).slideUp(200); 5015 }; 5016 5017 5018 5019 // /////////////////////////////////////// 5020 // 5021 // Apply to: 5022 // 5023 // /////////////////////////////////////// 5024 5025 var $toggle = $('.mk-toggle-title'); 5026 5027 if(!$toggle.length) return; 5028 5029 $toggle.each(function() { 5030 new Toggle(this); 5031 }); 5032 5033})(jQuery);
5034////////////////////////////////////////////////////////////////////////// 5035// 5036// Init all scripts 5037// 5038////////////////////////////////////////////////////////////////////////// 5039 5040// This is bad but we don't have other access to this scope. 5041// Ajax Portfolio is defined as plugin and on success needs these to be reinited 5042// We'll refactor all of this. 5043window.ajaxInit = function() { 5044 mk_lightbox_init(); 5045 mk_click_events(); 5046 mk_social_share_global(); 5047 mk_social_share(); 5048 mk_gallery(); 5049 loop_audio_init(); 5050}; 5051 5052window.ajaxDelayedInit = function() { 5053 mk_flexslider_init(); 5054 // mk_portfolio_ajax(); 5055}; 5056 5057$(document).ready(function() { 5058 mk_lightbox_init(); 5059 mk_login_form(); 5060 mk_backgrounds_parallax(); 5061 mk_flexslider_init(); 5062 mk_event_countdown(); 5063 mk_skill_meter(); 5064 mk_milestone(); 5065 mk_ajax_search(); 5066 mk_hover_events(); 5067 mk_portfolio_ajax(); 5068 mk_love_post(); 5069 product_loop_add_cart(); 5070 mk_social_share(); 5071 mk_portfolio_widget(); 5072 mk_contact_form(); 5073 mk_blog_carousel(); 5074 mk_header_searchform(); 5075 mk_click_events(); 5076 mk_text_typer(); 5077 mk_tab_slider_func(); 5078 mk_one_page_scroller(); 5079 mk_one_pager_resposnive(); 5080 5081 $(window).load(function() { 5082 mk_unfold_footer(); 5083 mk_tabs(); 5084 mk_accordion_toggles_tooltip(); 5085 mk_gallery(); 5086 mk_edge_fullpage_pagination(); 5087 mk_theatre_responsive_calculator(); 5088 mk_tabs_responsive(); 5089 mk_start_tour_resize(); 5090 mk_header_social_resize(); 5091 mk_page_section_social_video_bg(); 5092 loop_audio_init(); 5093 5094 setTimeout(function() { 5095 /* 5096 Somehow the values are not correctly updated for the screens 5097 and we need to put setTimeout to fix the issue 5098 */ 5099 mk_mobile_tablet_responsive_calculator(); 5100 }, 300); 5101 5102 console.log("ready for rock"); 5103 }); 5104 5105 5106 var onDebouncedResize = function() { 5107 mk_theatre_responsive_calculator(); 5108 mk_mobile_tablet_responsive_calculator(); 5109 mk_tabs_responsive(); 5110 mk_accordion_toggles_tooltip(); 5111 mk_start_tour_resize(); 5112 mk_header_social_resize(); 5113 5114 setTimeout(function() { 5115 mk_one_pager_resposnive(); 5116 mk_unfold_footer(); 5117 }, 300); 5118 }; 5119 5120 var debounceResize = null; 5121 $(window).on("resize", function() { 5122 if( debounceResize !== null ) { clearTimeout( debounceResize ); } 5123 debounceResize = setTimeout( onDebouncedResize, 300 ); 5124 }); 5125 5126 5127 var onDebouncedScroll = function() { 5128 mk_skill_meter(); 5129 //TODO: Ask to Bart how we can call javascript component 5130 //mk_charts(); 5131 mk_milestone(); 5132 }; 5133 5134 var debounceScroll = null; 5135 $(window).on("scroll", function() { 5136 if( debounceScroll !== null ) { clearTimeout( debounceScroll ); } 5137 debounceScroll = setTimeout( onDebouncedScroll, 100 ); 5138 }); 5139 5140 if (MK.utils.isMobile()) { 5141 $('body').addClass('no-transform'); 5142 } 5143 5144}); 5145 5146/* Typer */ 5147/* -------------------------------------------------------------------- */ 5148function mk_text_typer() { 5149 5150 "use strict"; 5151 5152 $('[data-typer-targets]').each(function() { 5153 var that = this; 5154 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.typed.js' ], function() { 5155 var $this = $(that), 5156 $first_string = [$this.text()], 5157 $rest_strings = $this.attr('data-typer-targets').split(','), 5158 $strings = $first_string.concat($rest_strings); 5159 5160 $this.text(''); 5161 5162 $this.typed({ 5163 strings: $strings, 5164 typeSpeed: 30, // typing speed 5165 backDelay: 1200, // pause before backspacing 5166 loop: true, // loop on or off (true or false) 5167 loopCount: false, // number of loops, false = infinite 5168 }); 5169 }); 5170 }); 5171} 5172 5173 5174 5175/* Tab Slider */ 5176/* -------------------------------------------------------------------- */ 5177 5178function mk_tab_slider_func() { 5179 5180 "use strict"; 5181 5182 $('.mk-tab-slider').each(function() { 5183 var that = this; 5184 5185 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.swiper.js' ], function() { 5186 var $this = $(that), 5187 id = $this.data('id'), 5188 $autoplayTime = $this.data('autoplay'), 5189 $content = $('.mk-slider-content'); 5190 5191 var mk_tab_slider = $this.swiper({ 5192 wrapperClass: 'mk-tab-slider-wrapper', 5193 slideClass: 'mk-tab-slider-item', 5194 calculateHeight: true, 5195 speed: 500, 5196 autoplay: $autoplayTime, 5197 onSlideChangeStart: function() { 5198 $('.mk-tab-slider-nav[data-id="' + id + '"]').find(".active").removeClass('active') 5199 $('.mk-tab-slider-nav[data-id="' + id + '"]').find("a").eq(mk_tab_slider.activeIndex).addClass('active') 5200 } 5201 }); 5202 5203 // Simple repaint for firefox issue (can't handle 100% height after plugin init) 5204 function repaintFirefox() { 5205 $content.css('display','block'); 5206 setTimeout(function() { 5207 mk_tab_slider.reInit(); 5208 $content.css('display','table'); 5209 },100); 5210 } 5211 5212 $('.mk-tab-slider-nav[data-id="' + id + '"]').find("a").first().addClass('active'); 5213 5214 $('.mk-tab-slider-nav[data-id="' + id + '"]').find("a").on('touchstart mousedown', function(e) { 5215 e.preventDefault() 5216 $('.mk-tab-slider-nav[data-id="' + id + '"]').find(".active").removeClass('active') 5217 $(this).addClass('active') 5218 mk_tab_slider.swipeTo($(this).index()) 5219 }); 5220 5221 $('.mk-tab-slider-nav[data-id="' + id + '"]').find("a").click(function(e) { 5222 e.preventDefault(); 5223 }); 5224 5225 repaintFirefox(); 5226 $(window).on('resize', repaintFirefox); 5227 }); 5228 5229 }); 5230 5231} 5232 5233 5234 5235/* Edge One Pager */ 5236/* -------------------------------------------------------------------- */ 5237function mk_one_page_scroller() { 5238 5239 "use strict"; 5240 5241 $('.mk-edge-one-pager').each(function() { 5242 var self = this; 5243 5244 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.fullpage.js' ], function() { 5245 5246 var $this = $(self), 5247 $tooltip_txt = []; 5248 5249 $this.find('.section').each(function() { 5250 $tooltip_txt.push($(this).attr('data-title')); 5251 }); 5252 5253 var scrollable = true; 5254 $this.find('.section').each(function() { 5255 var $section = $(this), 5256 $content = $section.find('.edge-slide-content'), 5257 sectionHeight = $section.height(),
5258 contentHeight = $content.innerHeight(); 5259 5260 if((contentHeight + 30) > $(window).height()) { 5261 scrollable = false; 5262 } 5263 }); 5264 5265 if(!scrollable){ 5266 $this.find('.section').each(function() { 5267 var $section = $(this); 5268 $section.addClass('active').css({ 5269 'padding-bottom': '50px' 5270 }); 5271 }); 5272 } 5273 5274 if(scrollable) { 5275 $this.fullpage({ 5276 verticalCentered: false, 5277 resize: true, 5278 slidesColor: ['#ccc', '#fff'], 5279 anchors: $tooltip_txt, 5280 scrollingSpeed: 600, 5281 easing: 'easeInQuart', 5282 menu: false, 5283 navigation: true, 5284 navigationPosition: 'right', 5285 navigationTooltips: false, 5286 slidesNavigation: true, 5287 slidesNavPosition: 'bottom', 5288 loopBottom: false, 5289 loopTop: false, 5290 loopHorizontal: true, 5291 autoScrolling: true, 5292 scrollOverflow: false, 5293 css3: true, 5294 paddingTop: 0, 5295 paddingBottom: 0, 5296 normalScrollElements: '.mk-header, .mk-responsive-wrap', 5297 normalScrollElementTouchThreshold: 5, 5298 keyboardScrolling: true, 5299 touchSensitivity: 15, 5300 continuousVertical: false, 5301 animateAnchor: true, 5302 5303 onLeave: function(index, nextIndex, direction) { 5304 var currentSkin = $this.find('.one-pager-slide').eq(nextIndex - 1).attr('data-header-skin'); 5305 MK.utils.eventManager.publish( 'firstElSkinChange', currentSkin ); 5306 $('#fullPage-nav').removeClass('light-skin dark-skin').addClass(currentSkin + '-skin'); 5307 5308 }, 5309 afterRender: function() { 5310 setTimeout(function() { 5311 var currentSkin = $this.find('.one-pager-slide').eq(0).attr('data-header-skin'); 5312 MK.utils.eventManager.publish( 'firstElSkinChange', currentSkin ); 5313 $('#fullPage-nav').removeClass('light-skin dark-skin').addClass(currentSkin + '-skin'); 5314 }, 300); 5315 5316 }, 5317 }); 5318 } 5319 }); 5320 }); 5321 5322} 5323 5324 5325function mk_one_pager_resposnive() { 5326 5327 "use strict"; 5328 5329 $('.mk-edge-one-pager').each(function() { 5330 var $this = $(this), 5331 $header_height = 0; 5332 5333 var $window_height = $(window).outerHeight(); 5334 5335 if ($(window).width() <= mk_responsive_nav_width) { 5336 $header_height = $('.mk-header').data('height'); 5337 } 5338 5339 $this.find('.one-pager-slide').each(function() { 5340 5341 5342 var $this = $(this), 5343 $content = $this.find('.edge-slide-content'); 5344 5345 if ($this.hasClass('left_center') || $this.hasClass('center_center') || $this.hasClass('right_center')) { 5346 5347 var $this_height_half = $content.outerHeight() / 2, 5348 $window_half = $window_height / 2; 5349 $distance_from_top = ($window_half - $this_height_half), 5350 $distance_from_top = ($distance_from_top < 50) ? 50 + ($header_height / 2) : $distance_from_top + ($header_height / 2); 5351 5352 $content.css('marginTop', $distance_from_top); 5353 $content.css('marginBottom', $distance_from_top); 5354 } 5355 5356 if ($this.hasClass('left_bottom') || $this.hasClass('center_bottom') || $this.hasClass('right_bottom')) { 5357 5358 var $distance_from_top = $window_height - $content.outerHeight() - 90; 5359 5360 $content.css('marginTop', ($distance_from_top)); 5361 } 5362 5363 }); 5364 }); 5365 5366} 5367 5368/* Image Gallery */ 5369/* -------------------------------------------------------------------- */ 5370 5371function mk_gallery() { 5372 5373 "use strict"; 5374 5375 $('.mk-gallery .mk-gallery-item.hover-overlay_layer .item-holder').each(function() { 5376 var itemHolder = $(this), 5377 galleryDesc = itemHolder.find('.gallery-desc'); 5378 5379 function updatePosition() { 5380 var parentHeight = itemHolder.outerHeight(), 5381 contentHeight = galleryDesc.innerHeight(); 5382 5383 var paddingVal = (parentHeight - contentHeight) / 2; 5384 galleryDesc.css({ 5385 'top': paddingVal, 5386 // 'padding-bottom': paddingVal 5387 }); 5388 5389 // console.log(parentHeight); 5390 // console.log(contentHeight); 5391 5392 5393 } 5394 updatePosition(); 5395 5396 $(window).on('resize', function() { 5397 setTimeout(function() { 5398 updatePosition(); 5399 }, 1000); 5400 }); 5401 }); 5402} 5403 5404 5405 5406/* Adds pagination style in fullpage Edge Slider */ 5407/* -------------------------------------------------------------------- */ 5408function mk_edge_fullpage_pagination() { 5409 5410 "use strict"; 5411 5412 var style = $('#fullpage').attr('data-pagination'); 5413 // console.log(style); 5414 $('#fullPage-nav').addClass('pagination-' + style); 5415} 5416 5417 5418 5419/* Theatre Slider Responsive Calculator */ 5420/* -------------------------------------------------------------------- */ 5421 5422function mk_theatre_responsive_calculator() { 5423 var $laptopContainer = $(".laptop-theatre-slider"); 5424 var $computerContainer = $(".desktop-theatre-slider"); 5425 $laptopContainer.each(function() { 5426 var $this = $(this), 5427 $window = $(window), 5428 $windowWidth = $window.outerWidth(), 5429 $windowHeight = $window.outerHeight(), 5430 $width = $this.outerWidth(), 5431 $height = $this.outerHeight(), 5432 $paddingTop = 38, 5433 $paddingRight = 143, 5434 $paddingBottom = 78, 5435 $paddingLeft = 143; 5436 5437 var $player = $this.find('.player-container'); 5438 5439 if ($windowWidth > $width) { 5440 $player.css({ 5441 'padding-left': parseInt(($width * $paddingLeft) / 1200), 5442 'padding-right': parseInt(($width * $paddingRight) / 1200), 5443 'padding-top': parseInt(($height * $paddingTop) / 690), 5444 'padding-bottom': parseInt(($height * $paddingBottom) / 690), 5445 }); 5446 } 5447 5448 }); 5449 5450 $computerContainer.each(function() { 5451 var $this = $(this), 5452 $window = $(window), 5453 $windowWidth = $window.outerWidth(), 5454 $windowHeight = $window.outerHeight(), 5455 $width = $this.outerWidth(), 5456 $height = $this.outerHeight(), 5457 $paddingTop = 60, 5458 $paddingRight = 52, 5459 $paddingBottom = 290, 5460 $paddingLeft = 49; 5461 5462 var $player = $this.find('.player-container'); 5463 5464 if ($windowWidth > $width) { 5465 $player.css({ 5466 'padding-left': parseInt(($width * $paddingLeft) / 1200), 5467 'padding-right': parseInt(($width * $paddingRight) / 1200), 5468 'padding-top': parseInt(($height * $paddingTop) / 969), 5469 'padding-bottom': parseInt(($height * $paddingBottom) / 969), 5470 }); 5471 } 5472 5473 }); 5474 5475} 5476 5477/* Mobile and Tablet Slideshow Responsive Calculator */ 5478/* -------------------------------------------------------------------- */ 5479function mk_mobile_tablet_responsive_calculator() { 5480 var $laptopSlideshow = $(".mk-laptop-slideshow-shortcode"); 5481 var $lcdSlideshow = $(".mk-lcd-slideshow"); 5482 5483 if ($.exists(".mk-laptop-slideshow-shortcode")) { 5484 $laptopSlideshow.each(function() { 5485 var $this = $(this), 5486 $window = $(window), 5487 $windowWidth = $window.outerWidth(), 5488 $windowHeight = $window.outerHeight(), 5489 $width = $this.outerWidth(), 5490 $height = $this.outerHeight(), 5491 $paddingTop = 28, 5492 $paddingRight = 102, 5493 $paddingBottom = 52, 5494 $paddingLeft = 102; 5495 5496 var $player = $this.find(".slideshow-container"); 5497 5498 $player.css({ 5499 "padding-left": parseInt(($width * $paddingLeft) / 836), 5500 "padding-right": parseInt(($width * $paddingRight) / 836), 5501 "padding-top": parseInt(($height * $paddingTop) / 481), 5502 "padding-bottom": parseInt(($height * $paddingBottom) / 481), 5503 }); 5504 5505 }); 5506 } 5507 5508 if ($.exists(".mk-lcd-slideshow")) {
5509 $lcdSlideshow.each(function() { 5510 var $this = $(this), 5511 $window = $(window), 5512 $windowWidth = $window.outerWidth(), 5513 $windowHeight = $window.outerHeight(), 5514 $width = $this.outerWidth(), 5515 $height = $this.outerHeight(), 5516 $paddingTop = 35, 5517 $paddingRight = 39, 5518 $paddingBottom = 213, 5519 $paddingLeft = 36; 5520 5521 var $player = $this.find(".slideshow-container"); 5522 $player.css({ 5523 "padding-left": parseInt(($width * $paddingLeft) / 886), 5524 "padding-right": parseInt(($width * $paddingRight) / 886), 5525 "padding-top": parseInt(($height * $paddingTop) / 713), 5526 "padding-bottom": parseInt(($height * $paddingBottom) / 713), 5527 }); 5528 }); 5529 } 5530} 5531 5532 5533/* Start a tour resize function */ 5534/* -------------------------------------------------------------------- */ 5535function mk_start_tour_resize() { 5536 5537 $('.mk-header-start-tour').each(function() { 5538 5539 var $windowWidth = $(document).width(), 5540 $this = $(this), 5541 $linkWidth = $this.width() + 15, 5542 $padding = ($windowWidth - mk_responsive_nav_width) / 2; 5543 5544 5545 5546 function updateStartTour(){ 5547 if($windowWidth < mk_responsive_nav_width){ 5548 $this.removeClass('hidden'); 5549 $this.addClass('show'); 5550 }else{ 5551 if($padding < $linkWidth){ 5552 $this.removeClass('show'); 5553 $this.addClass('hidden'); 5554 }else{ 5555 $this.removeClass('hidden'); 5556 $this.addClass('show'); 5557 } 5558 } 5559 } 5560 5561 setTimeout(function() { 5562 updateStartTour(); 5563 }, 300); 5564 }); 5565} 5566 5567/* Header social resize function */ 5568/* -------------------------------------------------------------------- */ 5569function mk_header_social_resize() { 5570 5571 $('.mk-header-social.header-section').each(function() { 5572 5573 var $windowWidth = $(document).width(), 5574 $this = $(this), 5575 $linkWidth = $this.width() + 15, 5576 $padding = ($windowWidth - mk_responsive_nav_width) / 2; 5577 5578 5579 5580 function updateStartTour(){ 5581 if($windowWidth < mk_responsive_nav_width){ 5582 $this.removeClass('hidden'); 5583 $this.addClass('show'); 5584 }else{ 5585 if($padding < $linkWidth){ 5586 $this.removeClass('show'); 5587 $this.addClass('hidden'); 5588 }else{ 5589 $this.removeClass('hidden'); 5590 $this.addClass('show'); 5591 } 5592 } 5593 } 5594 5595 setTimeout(function() { 5596 updateStartTour(); 5597 }, 300); 5598 }); 5599} 5600 5601/* Page Section Socail Video Player Controls */ 5602/* -------------------------------------------------------------------- */ 5603 5604function mk_page_section_social_video_bg() { 5605 $(".mk-page-section.social-hosted").each(function() { 5606 var $container = $(this), 5607 $source = $container.data('source'), 5608 player; 5609 5610 if ($source == 'youtube') { 5611 var youtube = $container.find('iframe')[0]; 5612 player = new YT.Player(youtube); 5613 setTimeout(function() { 5614 player.playVideo(); 5615 player.mute(); 5616 }, 1000); 5617 } 5618 if ($source == 'vimeo') { 5619 var vimeo = $container.find('iframe')[0]; 5620 player = $f(vimeo); 5621 setTimeout(function() { 5622 player.api('play'); 5623 player.api('setVolume', 0); 5624 }, 1000); 5625 } 5626 5627 }); 5628} 5629 5630// Pre RequireJS hot bug fixing 5631 5632function videoLoadState() { 5633 $('.mk-section-video video').each(function() { 5634 var mkVideo = this; 5635 5636 this.onload = fire(); 5637 5638 function fire() { 5639 setTimeout(function() { 5640 $(mkVideo).animate({ 5641 'opacity': 1 5642 }, 300); 5643 }, 1000); 5644 } 5645 }); 5646} 5647videoLoadState(); 5648function mk_accordion_toggles_tooltip() { 5649 5650 "use strict"; 5651 5652 5653 /* Message Boxes */ 5654 /* -------------------------------------------------------------------- */ 5655 5656 $('.box-close-btn').on('click', function() { 5657 $(this).parent().fadeOut(300); 5658 return false;
5659 5660 }); 5661 5662} 5663 5664function mk_portfolio_ajax() { 5665 "use strict"; 5666 5667 var headerHeight = 0; 5668 if ($.exists("#wpadminbar")) { 5669 headerHeight += $("#wpadminbar").height(); 5670 } 5671 if (!$.exists('.mk-vm-menuwrapper')) { 5672 headerHeight += parseInt($('.mk-header').attr('data-sticky-height')); 5673 } 5674 5675 function init() { 5676 // wait for ajax response propagation and insertion 5677 setTimeout(function() { 5678 $('.portfolio-grid.portfolio-ajax-enabled').each( function() { 5679 $( this ).ajaxPortfolio({ 5680 extraOffset: headerHeight 5681 }); 5682 }); 5683 }, 100); 5684 } 5685 5686 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.ajax.portfolio.js' ], init); 5687 // Reinit when ajax loaded stuff 5688 MK.utils.eventManager.subscribe('ajaxLoaded', init); 5689} 5690 5691/* Ajax Search */ 5692/* -------------------------------------------------------------------- */ 5693 5694function mk_ajax_search() { 5695 5696 "use strict"; 5697 5698 if ($.exists('.main-nav-side-search') && mk_ajax_search_option == "beside_nav") { 5699 var security = $('#mk-ajax-search-input').siblings('input[name="security"]').val(), 5700 _wp_http_referer = $('#mk-ajax-search-input').siblings('input[name="_wp_http_referer"]').val(); 5701 $("#mk-ajax-search-input").autocomplete({ 5702 delay: 40, 5703 minLength: 2, 5704 appendTo: $("#mk-nav-search-wrapper"), 5705 search: function (event, ui) { 5706 $(this).parent('form').addClass('ajax-searching'); 5707 }, 5708 source: function (req, response) { 5709 var query_spliter = (ajaxurl.indexOf('?') > -1) ? '&' : '?'; 5710 5711 $.getJSON(ajaxurl + query_spliter + 'callback=?&action=mk_ajax_search&security='+security+'&_wp_http_referer='+_wp_http_referer, req, response); 5712 }, 5713 select: function (event, ui) { 5714 window.location.href = ui.item.link; 5715 }, 5716 response: function (event, ui) { 5717 $(this).parent('form').removeClass('ajax-searching').addClass('ajax-search-complete'); 5718 } 5719 5720 }).data("ui-autocomplete")._renderItem = function (ul, item) { 5721 5722 5723 return $("<li>").append("<a>" + item.image + "<span class='search-title'>" + item.label + "</span><span class='search-date'>" + item.date + "</span></a>").appendTo(ul); 5724 5725 }; 5726 } 5727} 5728 5729 5730 5731/* Background Parallax Effects */ 5732/* -------------------------------------------------------------------- */ 5733 5734function mk_backgrounds_parallax() { 5735 5736 "use strict"; 5737 5738 if (mk_header_parallax == true) { 5739 $('.mk-header-bg').addClass('mk-parallax-enabled'); 5740 } 5741 if (mk_body_parallax == true) { 5742 $('body').addClass('mk-parallax-enabled'); 5743 } 5744 if (mk_banner_parallax == true) { 5745 $('.mk-header').addClass('mk-parallax-enabled'); 5746 } 5747 if (mk_page_parallax == true) { 5748 $('#theme-page').addClass('mk-parallax-enabled'); 5749 } 5750 if (mk_footer_parallax == true) { 5751 $('#mk-footer').addClass('mk-parallax-enabled'); 5752 } 5753 5754 $('.mk-parallax-enabled').each(function () { 5755 var $this = $( this ); 5756 if (!MK.utils.isMobile()) { 5757 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.parallax.js' ], function() { 5758 $this.parallax("49%", 0.3); 5759 }); 5760 } 5761 }); 5762 5763 $('.mk-fullwidth-slideshow.parallax-slideshow').each(function () { 5764 var $this = $( this ); 5765 if (!MK.utils.isMobile()) { 5766 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.parallax.js' ], function() { 5767 var speed_factor = $this.attr('data-speedFactor'); 5768 $this.parallax("49%", speed_factor); 5769 }); 5770 } 5771 }); 5772 5773} 5774/* Blog, Portfolio Audio */ 5775/* -------------------------------------------------------------------- */ 5776 5777function loop_audio_init() { 5778 if ($.exists('.jp-jplayer')) { 5779 $('.jp-jplayer.mk-blog-audio').each(function () { 5780 var $this = $( this ); 5781 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.jplayer.js' ], function() { 5782 var css_selector_ancestor = "#" + $this.siblings('.jp-audio').attr('id'); 5783 var ogg_file, mp3_file, mk_theme_js_path; 5784 ogg_file = $this.attr('data-ogg'); 5785 mp3_file = $this.attr('data-mp3'); 5786 $this.jPlayer({ 5787 ready: function () { 5788 $this.jPlayer("setMedia", { 5789 mp3: mp3_file, 5790 ogg: ogg_file
5791 }); 5792 }, 5793 play: function () { // To avoid both jPlayers playing together. 5794 $this.jPlayer("pauseOthers"); 5795 }, 5796 swfPath: mk_theme_js_path, 5797 supplied: "mp3, ogg", 5798 cssSelectorAncestor: css_selector_ancestor, 5799 wmode: "window" 5800 }); 5801 }); 5802 }); 5803 } 5804} 5805 5806 5807/* Blog Loop Carousel Shortcode */ 5808/* -------------------------------------------------------------------- */ 5809 5810 5811function mk_blog_carousel() { 5812 5813 "use strict"; 5814 5815 if (!$.exists('.mk-blog-showcase')) { 5816 return; 5817 } 5818 $('.mk-blog-showcase ul li').each(function () { 5819 5820 $(this).on('hover', function () { 5821 5822 $(this).siblings('li').removeClass('mk-blog-first-el').end().addClass('mk-blog-first-el'); 5823 5824 }); 5825 5826 }); 5827 5828 5829} 5830 5831 5832 5833 5834/* Contact Form */ 5835/* -------------------------------------------------------------------- */ 5836 5837 5838function mk_contact_form() { 5839 5840 "use strict"; 5841 5842 if( $('.mk-contact-form').length ) { 5843 5844 $('.mk-contact-form').each( function() { 5845 var $this = $( this ); 5846 var $input = $this.find( 'input, textarea' ); 5847 var activeClass = 'is-active'; 5848 5849 $input.filter('[type=email]').attr('type', 'emailModern'); 5850 5851 var setActive = function () { 5852 $( this ).parent().addClass( activeClass ); 5853 }; 5854 5855 var unsetActive = function () { 5856 if( isEmpty( this ) ) { 5857 $( this ).parent().removeClass( activeClass ); 5858 } 5859 }; 5860 5861 var isEmpty = function ( el ) { 5862 return $( el ).val() === ''; 5863 }; 5864 5865 var markActive = function () { 5866 var $this = $( this ); 5867 5868 5869 $this.on({ 5870 focus: setActive, 5871 blur: unsetActive 5872 }); 5873 }; 5874 5875 $input.each( markActive ); 5876 }); 5877 5878 5879 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.tools.validator.js' ], function() { 5880 5881 $('.captcha-image-holder').append('<img src="' + mk_theme_dir + '/captcha/captcha.php" class="captcha-image" alt="captcha txt">'); 5882 5883 $.tools.validator.addEffect("contact_form", function(errors) { 5884 $.each(errors, function(index, error) { 5885 var input = error.input; 5886 5887 input.addClass('mk-invalid'); 5888 }); 5889 }, function(inputs) { 5890 inputs.removeClass('mk-invalid'); 5891 }); 5892 5893 $(".captcha-change-image").on("click", function(e) { 5894 e.preventDefault(); 5895 changeCaptcha(); 5896 }); 5897 5898 5899 // Update regex to allow new top level domains but first update type to avoid old regex validation forced by plugin 5900 // https://github.com/jquerytools/jquerytools/issues/1089 5901 $('.mk-contact-form').find('[type=email]').attr('type', 'emailModern'); 5902 $.tools.validator.fn('[type=emailModern]', 'Please supply a valid email address for me', function(input, value) { 5903 return /^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,63})$/i.test(value); 5904 }); 5905 5906 var changeCaptcha = function() { 5907 $(".captcha-image").attr("src", mk_theme_dir + "/captcha/captcha.php?"+Math.random()); 5908 }; 5909 5910 var sendForm; 5911 var checkCaptcha = function(form, enteredCaptcha) { 5912 window.get.captcha(enteredCaptcha).done(function( data ) { 5913 if(data != "ok") { 5914 changeCaptcha(); 5915 form.find(".captcha-form").val("").addClass('contact-captcha-invalid').attr("placeholder", mk_captcha_invalid_txt); 5916 } else { 5917 sendForm(); 5918 changeCaptcha(); 5919 form.find(".captcha-form").val("").addClass('contact-captcha-valid').attr("placeholder", mk_captcha_correct_txt); 5920 } 5921 }); 5922 }; 5923 5924 $('.mk-contact-form').validator({ 5925 effect: 'contact_form' 5926 }).submit(function(e) { 5927 var form = $(this); 5928 var captcha_text = form.find(".captcha-form").attr('data-placeholder'); 5929 if (!e.isDefaultPrevented()) { 5930 5931 var data = { 5932 action: 'mk_contact_form', 5933 security : form.find('input[name="security"]').val(), 5934 _wp_http_referer : form.find('input[name="_wp_http_referer"]').val(), 5935 p_id : form.find('input[name="p_id"]').val(), 5936 sh_id: form.find('input[name="sh_id"]').val(), 5937 name: form.find('input[name="contact_name"]').val(), 5938 last_name: form.find('input[name="contact_last_name"]').val(), 5939 phone: form.find('input[name="contact_phone"]').val(), 5940 email: form.find('input[name="contact_email"]').val(), 5941 website: form.find('input[name="contact_website"]').val(), 5942 content: form.find('textarea[name="contact_content"]').val() 5943 }; 5944 5945 sendForm = function() { 5946 progressButton.loader(form); 5947 $.post(ajaxurl, data, function(response) { 5948 form.find('.mk-contact-loading').fadeOut('slow'); 5949 form.find('.text-input').val(''); 5950 form.find('textarea').val(''); 5951 form.find('.captcha-form').removeClass('contact-captcha-valid contact-captcha-invalid').attr('placeholder', captcha_text); 5952 progressButton.success(form); 5953 }); 5954 }; 5955 5956 var enteredCaptcha = form.find('input[name="captcha"]').val(); 5957 5958 if(form.find('.captcha-form').length){ 5959 checkCaptcha(form, enteredCaptcha); 5960 } else { 5961 sendForm(); 5962 } 5963 5964 e.preventDefault(); 5965 } 5966 }); 5967 5968 }); 5969 } 5970} 5971 5972 5973/* Ajax Login Form */ 5974/* -------------------------------------------------------------------- */ 5975 5976function mk_login_form() { 5977 5978 $('form.mk-login-form').each(function() { 5979 var $this = $(this); 5980 $this.on('submit', function(e) { 5981 $('p.mk-login-status', $this).show().text(ajax_login_object.loadingmessage); 5982 $.ajax({ 5983 type: 'POST', 5984 dataType: 'json', 5985 url: ajax_login_object.ajaxurl, 5986 data: { 5987 'action': 'ajaxlogin', 5988 'username': $('#username', $this).val(), 5989 'password': $('#password', $this).val(), 5990 'security': $('#security', $this).val() 5991 }, 5992 success: function(data) { 5993 $('p.mk-login-status', $this).text(data.message); 5994 if (data.loggedin === true) { 5995 document.location.href = ajax_login_object.redirecturl; 5996 } 5997 } 5998 }); 5999 e.preventDefault(); 6000 }); 6001 }); 6002} 6003 6004 6005/* Progress Button */ 6006/* -------------------------------------------------------------------- */ 6007 6008var progressButton = { 6009 loader: function(form) { 6010 MK.core.loadDependencies([ MK.core.path.plugins + 'tweenmax.js' ], function() { 6011 var $form = form, 6012 progressBar = $form.find(".mk-progress-button .mk-progress-inner"), 6013 buttonText = $form.find(".mk-progress-button .mk-progress-button-content"), 6014 progressButton = new TimelineLite(); 6015 6016 progressButton 6017 .to(progressBar, 0, { 6018 width: "100%", 6019 scaleX: 0, 6020 scaleY: 1 6021 }) 6022 .to(buttonText, .3, { 6023 y: -5 6024 }) 6025 .to(progressBar, 1.5, { 6026 scaleX: 1, 6027 ease: Power2.easeInOut 6028 }, "-=.1") 6029 .to(buttonText, .3, { 6030 y: 0 6031 }) 6032 .to(progressBar, .3, { 6033 scaleY: 0 6034 }); 6035 }); 6036 }, 6037 6038 success: function(form) { 6039 MK.core.loadDependencies([ MK.core.path.plugins + 'tweenmax.js' ], function() { 6040 var $form = form, 6041 buttonText = $form.find(".mk-button .mk-progress-button-content, .mk-contact-button .mk-progress-button-content"), 6042 successIcon = $form.find(".mk-progress-button .state-success"), 6043 progressButtonSuccess = new TimelineLite({ 6044 onComplete: hideSuccessMessage 6045 }); 6046 6047 progressButtonSuccess 6048 .to(buttonText, .3, { 6049 paddingRight: 20, 6050 ease: Power2.easeInOut 6051 }, "+=1") 6052 .to(successIcon, .3, { 6053 opacity: 1 6054 }) 6055 .to(successIcon, 2, { 6056 opacity: 1 6057 }); 6058 6059 function hideSuccessMessage() { 6060 progressButtonSuccess.reverse() 6061 } 6062 }); 6063 }, 6064 6065 error: function(form) { 6066 MK.core.loadDependencies([ MK.core.path.plugins + 'tweenmax.js' ], function() { 6067 var $form = form, 6068 buttonText = $form.find(".mk-button .mk-progress-button-content, .mk-contact-button .mk-progress-button-content"), 6069 errorIcon = $form.find(".mk-progress-button .state-error"), 6070 progressButtonError = new TimelineLite({ 6071 onComplete: hideErrorMessage 6072 }); 6073 6074 progressButtonError 6075 .to(buttonText, .3, { 6076 paddingRight: 20 6077 }, "+=1") 6078 .to(errorIcon, .3, { 6079 opacity: 1 6080 }) 6081 .to(errorIcon, 2, { 6082 opacity: 1 6083 }); 6084 6085 function hideErrorMessage() { 6086 progressButtonError.reverse() 6087 } 6088 }); 6089 } 6090} 6091function mk_click_events() { 6092 "use strict"; 6093 6094 var eventtype = 'click'; 6095 6096 $(".mk-header-login, .mk-header-signup, .mk-side-dashboard, .mk-quick-contact-wrapper, .mk-dashboard-trigger, .blog-share-container, .news-share-buttons, .main-nav-side-search, #mk-fullscreen-search-wrapper, #fullscreen-navigation").on(eventtype, function(event) { 6097 if (event.stopPropagation) { 6098 event.stopPropagation(); 6099 } else if (window.event) { 6100 window.event.cancelBubble = true; 6101 } 6102 }); 6103 $("html").on(eventtype, function() {
6104 $(this).find(".mk-login-register, .mk-header-subscribe, #mk-quick-contact, .single-share-buttons, .single-share-box, .blog-social-share, .news-share-buttons, .mk-nav-search-wrapper").fadeOut(100); 6105 $('.mk-quick-contact-link').removeClass('quick-contact-active'); 6106 // Removed By Maki for repairing fullnav scroll issue. Hope it odesnt break anything 6107 // $('body').css('overflow', 'visible'); 6108 }); 6109 6110 $('.mk-fullscreen-search-overlay').on(eventtype,function(){ 6111 $(this).removeClass('mk-fullscreen-search-overlay-show'); 6112 }); 6113 6114 $('.mk-forget-password').on(eventtype, function() { 6115 $('.mk-forget-panel').siblings().hide().end().show(); 6116 }); 6117 6118 $('.mk-create-account').on(eventtype, function() { 6119 $('#mk-register-panel').siblings().hide().end().show(); 6120 }); 6121 6122 $('.mk-return-login').on(eventtype, function() { 6123 $('#mk-login-panel').siblings().hide().end().show(); 6124 }); 6125 6126 6127 $('.mk-quick-contact-link').on(eventtype, function() { 6128 var $this = $(this), 6129 $quickContact = $('#mk-quick-contact'); 6130 if (!$this.hasClass('quick-contact-active')) { 6131 $quickContact.addClass('quick-contact-anim').fadeIn(250); 6132 $this.addClass('quick-contact-active'); 6133 } else { 6134 $quickContact.removeClass('quick-contact-anim').fadeOut(100); 6135 $this.removeClass('quick-contact-active'); 6136 } 6137 return false; 6138 }); 6139 6140} 6141 6142function mk_social_share_global() { 6143 6144 "use strict"; 6145 6146 var eventtype = 'click'; 6147 6148 $('.twitter-share').on(eventtype, function() { 6149 var $this = $(this), 6150 $url = $this.attr('data-url'), 6151 $title = $this.attr('data-title'); 6152 6153 window.open('http://twitter.com/intent/tweet?text=' + $title + ' ' + $url, "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6154 return false; 6155 }); 6156 6157 $('.pinterest-share').on(eventtype, function() { 6158 var $this = $(this), 6159 $url = $this.attr('data-url'), 6160 $title = $this.attr('data-title'), 6161 $image = $this.attr('data-image'); 6162 window.open('http://pinterest.com/pin/create/button/?url=' + $url + '&media=' + $image + '&description=' + $title, "twitterWindow", "height=320,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6163 return false; 6164 }); 6165 6166 $('.facebook-share').on(eventtype, function() { 6167 var $url = $(this).attr('data-url'); 6168 window.open('https://www.facebook.com/sharer/sharer.php?u=' + $url, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6169 return false; 6170 }); 6171 6172 $('.googleplus-share').on(eventtype, function() { 6173 var $url = $(this).attr('data-url'); 6174 window.open('https://plus.google.com/share?url=' + $url, "googlePlusWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6175 return false; 6176 }); 6177 6178 $('.linkedin-share').on(eventtype, function() { 6179 var $this = $(this), 6180 $url = $this.attr('data-url'), 6181 $title = $this.attr('data-title'), 6182 $desc = $this.attr('data-desc'); 6183 window.open('http://www.linkedin.com/shareArticle?mini=true&url=' + $url + '&title=' + $title + '&summary=' + $desc, "linkedInWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6184 return false; 6185 }); 6186} 6187 6188 6189/* Event Count Down */ 6190/* -------------------------------------------------------------------- */ 6191 6192function mk_event_countdown() { 6193 if ($.exists('.mk-event-countdown')) { 6194 6195 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.countdown.js' ], function() { 6196 6197 $('.mk-event-countdown').each(function () { 6198 var $this = $(this), 6199 $date = $this.attr('data-date'), 6200 $offset = $this.attr('data-offset'); 6201 6202 $this.downCount({ 6203 date: $date, 6204 offset: $offset 6205 }); 6206 }); 6207 6208 }); 6209 } 6210} 6211/* Flexslider init */ 6212/* -------------------------------------------------------------------- */ 6213 6214function mk_flexslider_init() { 6215 6216 $('.js-flexslider').each(function () { 6217 6218 if ($(this).parents('.mk-tabs').length || $(this).parents('.mk-accordion').length) { 6219 $(this).removeData("flexslider"); 6220 } 6221 6222 var $this = $(this), 6223 $selector = $this.attr('data-selector'), 6224 $animation = $this.attr('data-animation'), 6225 $easing = $this.attr('data-easing'), 6226 $direction = $this.attr('data-direction'), 6227 $smoothHeight = $this.attr('data-smoothHeight') == "true" ? true : false,
6228 $slideshowSpeed = $this.attr('data-slideshowSpeed'), 6229 $animationSpeed = $this.attr('data-animationSpeed'), 6230 $controlNav = $this.attr('data-controlNav') == "true" ? true : false, 6231 $directionNav = $this.attr('data-directionNav') == "true" ? true : false, 6232 $pauseOnHover = $this.attr('data-pauseOnHover') == "true" ? true : false, 6233 $isCarousel = $this.attr('data-isCarousel') == "true" ? true : false, 6234 $arrowLeft = $this.attr('data-arrow-left'), 6235 $arrowRight = $this.attr('data-arrow-right'); 6236 6237 if($arrowLeft === undefined) { 6238 $arrowLeft = '<i class="mk-jupiter-icon-arrow-left"></i>'; 6239 } else { 6240 $arrowLeft = '<i class="'+$arrowLeft+'"></i>'; 6241 } 6242 6243 if($arrowRight === undefined) { 6244 $arrowRight = '<i class="mk-jupiter-icon-arrow-right"></i>'; 6245 } else { 6246 $arrowRight = '<i class="'+$arrowRight+'"></i>'; 6247 } 6248 6249 6250 if ($selector !== undefined) { 6251 var $selector_class = $selector; 6252 } else { 6253 var $selector_class = ".mk-flex-slides > li"; 6254 } 6255 6256 if ($isCarousel === true) { 6257 var $itemWidth = parseInt($this.attr('data-itemWidth')), 6258 $itemMargin = parseInt($this.attr('data-itemMargin')), 6259 $minItems = parseInt($this.attr('data-minItems')), 6260 $maxItems = parseInt($this.attr('data-maxItems')), 6261 $move = parseInt($this.attr('data-move')); 6262 } else { 6263 var $itemWidth = $itemMargin = $minItems = $maxItems = $move = 0; 6264 } 6265 6266 MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.flexslider.js' ], function() { 6267 $this.flexslider({ 6268 selector: $selector_class, 6269 animation: $animation, 6270 easing: $easing, 6271 direction: $direction, 6272 smoothHeight: $smoothHeight, 6273 slideshow: true, 6274 slideshowSpeed: $slideshowSpeed, 6275 animationSpeed: $animationSpeed, 6276 controlNav: $controlNav, 6277 directionNav: $directionNav, 6278 pauseOnHover: $pauseOnHover, 6279 prevText: "", 6280 nextText: "", 6281 directionNavArrowsLeft: $arrowLeft, 6282 directionNavArrowsRight:$arrowRight, 6283 itemWidth: $itemWidth, 6284 itemMargin: $itemMargin, 6285 minItems: $minItems, 6286 maxItems: $maxItems, 6287 move: $move 6288 }); 6289 }); 6290 6291 }); 6292 6293} 6294 6295/* Header Search Form */ 6296/* -------------------------------------------------------------------- */ 6297 6298function mk_header_searchform() { 6299 6300 $('.mk-search-trigger').click(function(){ 6301 $('#mk-ajax-search-input').focus(); 6302 }); 6303 6304 "use strict"; 6305 6306 $('.mk-header-toolbar .mk-header-searchform .text-input').on('focus', function () { 6307 6308 if ($('.mk-header-toolbar .mk-header-searchform .text-input').hasClass('on-close-state')) { 6309 $('.mk-header-toolbar .mk-header-searchform .text-input').removeClass('on-close-state').animate({ 6310 'width': '200px' 6311 }, 200); 6312 return false; 6313 } 6314 }); 6315 6316 $(".mk-header-toolbar .mk-header-searchform").click(function (event) { 6317 if (event.stopPropagation) { 6318 event.stopPropagation(); 6319 } else if (window.event) { 6320 window.event.cancelBubble = true; 6321 } 6322 }); 6323 6324 6325 $("html").click(function () { 6326 $(this).find(".mk-header-toolbar .mk-header-searchform .text-input").addClass('on-close-state').animate({ 6327 'width': 90 6328 }, 300); 6329 }); 6330 6331} 6332 6333 6334 6335 6336/* Hover Events */ 6337/* -------------------------------------------------------------------- */ 6338 6339function mk_hover_events() { 6340 6341 "use strict"; 6342 6343 $('.shopping-cart-header').hover( 6344 function() { 6345 $(this).find('.mk-shopping-cart-box').stop(true, true).fadeIn(250); 6346 }, 6347 function() { 6348 $(this).find('.mk-shopping-cart-box').stop(true, true).fadeOut(250); 6349 } 6350 ); 6351 6352 6353 $('.widget-sub-navigation > ul > li, .widget_nav_menu ul.menu > li, .widget_product_categories ul > .cat-item').each(function() { 6354 6355 var $this = $(this), 6356 $subLevel = $this.find('ul').first(); 6357 6358 if ($this.hasClass('page_item_has_children') || $this.hasClass('menu-item-has-children') || $this.hasClass('cat-parent')) { 6359 $this.hover( 6360 function() { 6361 setTimeout(function(){ 6362 $subLevel.stop(true, true).slideDown(700); 6363 }, 500); 6364 }, 6365 function() { 6366 setTimeout(function(){
6367 $subLevel.stop(true, true).slideUp(700); 6368 }, 500); 6369 } 6370 ); 6371 } 6372 6373 }); 6374 6375 // var eventtype = mobilecheck() ? 'touchstart' : 'click'; 6376 var eventtype = 'click'; 6377 6378 $('.mk-fullscreen-trigger').on(eventtype, function(e) { 6379 $('.mk-fullscreen-search-overlay').addClass('mk-fullscreen-search-overlay-show'); 6380 setTimeout(function(){ 6381 $("#mk-fullscreen-search-input").focus(); 6382 }, 300); 6383 e.preventDefault(); 6384 }); 6385 6386 $('.mk-fullscreen-close').on(eventtype, function(e) { 6387 $('.mk-fullscreen-search-overlay').removeClass('mk-fullscreen-search-overlay-show'); 6388 e.preventDefault(); 6389 }); 6390 6391} 6392 6393function mk_unfold_footer() { 6394 var $this = $('#mk-footer'), 6395 $spacer = $('#mk-footer-unfold-spacer'), 6396 $footerHeight = $this.outerHeight(); 6397 6398 // Stick with CSS media query breakpoint to target exact screen width 6399 if( !window.matchMedia("(max-width: 767px)").matches ) { 6400 if ($this.hasClass('mk-footer-unfold')) { 6401 $spacer.css('height', $footerHeight); 6402 } 6403 } else { 6404 $spacer.css('height', 0); 6405 } 6406} 6407/* jQuery fancybox lightbox */ 6408/* -------------------------------------------------------------------- */ 6409function mk_lightbox_init() { 6410 6411 6412 $(".mk-lightbox").fancybox({ 6413 padding: 15, 6414 margin: 15, 6415 6416 width: 800, 6417 height: 600, 6418 minWidth: 100, 6419 minHeight: 100, 6420 maxWidth: 9999, 6421 maxHeight: 9999, 6422 pixelRatio: 1, // Set to 2 for retina display support 6423 6424 autoSize: true, 6425 autoHeight: false, 6426 autoWidth: false, 6427 6428 autoResize: true, 6429 fitToView: true, 6430 aspectRatio: false, 6431 topRatio: 0.5, 6432 leftRatio: 0.5, 6433 6434 scrolling: 'auto', // 'auto', 'yes' or 'no' 6435 wrapCSS: '', 6436 6437 arrows: true, 6438 closeBtn: true, 6439 closeClick: false, 6440 nextClick: false, 6441 mouseWheel: true, 6442 autoPlay: false, 6443 playSpeed: 3000, 6444 preload: 3, 6445 modal: false, 6446 loop: true, 6447 // Properties for each animation type 6448 // Opening fancyBox 6449 openEffect: 'fade', // 'elastic', 'fade' or 'none' 6450 openSpeed: 200, 6451 openEasing: 'swing', 6452 openOpacity: true, 6453 openMethod: 'zoomIn', 6454 6455 // Closing fancyBox 6456 closeEffect: 'fade', // 'elastic', 'fade' or 'none' 6457 closeSpeed: 200, 6458 closeEasing: 'swing', 6459 closeOpacity: true, 6460 closeMethod: 'zoomOut', 6461 6462 // Changing next gallery item 6463 nextEffect: 'none', // 'elastic', 'fade' or 'none' 6464 nextSpeed: 350, 6465 nextEasing: 'swing', 6466 nextMethod: 'changeIn', 6467 6468 // Changing previous gallery item 6469 prevEffect: 'none', // 'elastic', 'fade' or 'none' 6470 prevSpeed: 350, 6471 prevEasing: 'swing', 6472 prevMethod: 'changeOut', 6473 helpers : { 6474 media : {}, 6475 overlay: { 6476 locked: true 6477 } 6478 }, 6479 6480 tpl: { 6481 wrap: '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>', 6482 image: '<img class="fancybox-image" src="{href}" alt="" />', 6483 error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>', 6484 closeBtn: '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"><i class="mk-moon-close-2"></i></a>', 6485 next: '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span><i class="mk-jupiter-icon-arrow-right"></i></span></a>', 6486 prev: '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span><i class="mk-jupiter-icon-arrow-left"></i></span></a>', 6487 loading: '<div id="fancybox-loading"><div></div></div>' 6488 }, 6489 6490 afterLoad: function() { 6491 $('html').addClass('fancybox-lock'); 6492 $('.fancybox-wrap').appendTo('.fancybox-overlay'); 6493 } 6494 6495 }); 6496} 6497 6498 6499/* Love This */ 6500/* -------------------------------------------------------------------- */ 6501 6502function mk_love_post() { 6503 6504 "use strict"; 6505 6506 $('body').on('click', '.mk-love-this', function () { 6507 var $this = $(this), 6508 $id = $this.attr('id'); 6509 6510 if ($this.hasClass('item-loved')) return false;
6511 6512 if ($this.hasClass('item-inactive')) return false; 6513 6514 var $sentdata = { 6515 action: 'mk_love_post', 6516 post_id: $id 6517 } 6518 6519 $.post(ajaxurl, $sentdata, function (data) { 6520 $this.find('.mk-love-count').html(data); 6521 $this.addClass('item-loved'); 6522 }); 6523 6524 $this.addClass('item-inactive'); 6525 return false; 6526 }); 6527 6528} 6529 6530 6531 6532 6533/* Milestone Number Shortcode */ 6534/* -------------------------------------------------------------------- */ 6535 6536function mk_milestone() { 6537 6538 "use strict"; 6539 6540 if( !$.exists('.mk-milestone') ) return; 6541 6542 $('.mk-milestone').each(function () { 6543 var $this = $(this), 6544 stop_number = $this.find('.milestone-number').attr('data-stop'), 6545 animation_speed = parseInt($this.find('.milestone-number').attr('data-speed')); 6546 6547 var build = function() { 6548 if (!$this.hasClass('scroll-animated')) { 6549 $this.addClass('scroll-animated'); 6550 6551 $({ 6552 countNum: $this.find('.milestone-number').text() 6553 }).animate({ 6554 countNum: stop_number 6555 }, { 6556 duration: animation_speed, 6557 easing: 'linear', 6558 step: function () { 6559 $this.find('.milestone-number').text(Math.floor(this.countNum)); 6560 }, 6561 complete: function () { 6562 $this.find('.milestone-number').text(this.countNum); 6563 } 6564 }); 6565 } 6566 }; 6567 6568 if ( !MK.utils.isMobile() ) { 6569 // refactored only :in-viewport logic. rest is to-do 6570 MK.utils.scrollSpy( this, { 6571 position: 'bottom', 6572 after: build 6573 }); 6574 } else { 6575 build(); 6576 } 6577 6578 }); 6579 6580} 6581 6582 6583 6584 6585/* Recent Works Widget */ 6586/* -------------------------------------------------------------------- */ 6587 6588function mk_portfolio_widget() { 6589 6590 "use strict"; 6591 6592 $('.widget_recent_portfolio li').each(function () { 6593 6594 $(this).find('.portfolio-widget-thumb').hover(function () { 6595 6596 $(this).siblings('.portfolio-widget-info').animate({ 6597 'opacity': 1 6598 }, 200); 6599 }, function () { 6600 6601 $(this).siblings('.portfolio-widget-info').animate({ 6602 'opacity': 0 6603 }, 200); 6604 }); 6605 6606 }); 6607} 6608 6609 6610 6611/* Skill Meter and Charts */ 6612/* -------------------------------------------------------------------- */ 6613function mk_skill_meter() { 6614 "use strict"; 6615 if ($.exists('.mk-skill-meter')) { 6616 if (!MK.utils.isMobile()) { 6617 $(".mk-skill-meter .progress-outer").each(function() { 6618 var $this = $(this); 6619 6620 var build = function() { 6621 if (!$this.hasClass('scroll-animated')) { 6622 $this.addClass('scroll-animated'); 6623 $this.animate({ 6624 width: $this.attr("data-width") + '%' 6625 }, 2000); 6626 } 6627 }; 6628 6629 MK.utils.scrollSpy( this, { 6630 position: 'bottom', 6631 after: build 6632 }); 6633 }); 6634 } else { 6635 $(".mk-skill-meter .progress-outer").each(function() { 6636 var $this = $(this); 6637 if (!$this.hasClass('scroll-animated')) { 6638 $this.addClass('scroll-animated'); 6639 $this.css({ 6640 width: $(this).attr("data-width") + '%' 6641 }); 6642 } 6643 }); 6644 } 6645 } 6646} 6647 6648// function mk_charts() { 6649// "use strict"; 6650 6651// if( !$.exists('.mk-chart') ) return; 6652 6653// MK.core.loadDependencies([ MK.core.path.plugins + 'jquery.easyPieChart.js' ], function() { 6654 6655// $('.mk-chart').each(function() { 6656 6657// var $this = $(this), 6658// $parent_width = $(this).parent().width(), 6659// $chart_size = parseInt($this.attr('data-barSize')); 6660 6661// if ($parent_width < $chart_size) { 6662// $chart_size = $parent_width; 6663// $this.css('line-height', $chart_size); 6664// $this.find('i').css({ 6665// 'line-height': $chart_size + 'px' 6666// }); 6667// $this.css({ 6668// 'line-height': $chart_size + 'px' 6669// }); 6670// } 6671 6672// var build = function() { 6673// $this.easyPieChart({ 6674// animate: 1300, 6675// lineCap: 'butt', 6676// lineWidth: $this.attr('data-lineWidth'), 6677// size: $chart_size, 6678// barColor: $this.attr('data-barColor'), 6679// trackColor: $this.attr('data-trackColor'), 6680// scaleColor: 'transparent', 6681// onStep: function(value) {
6682// this.$el.find('.chart-percent span').text(Math.ceil(value)); 6683// } 6684// }); 6685// }; 6686 6687// // refactored only :in-viewport logic. rest is to-do 6688// MK.utils.scrollSpy( this, { 6689// position: 'bottom', 6690// after: build 6691// }); 6692 6693 6694// }); 6695// }); 6696// } 6697/* Social Share */ 6698/* -------------------------------------------------------------------- */ 6699 6700function mk_social_share() { 6701 6702 "use strict"; 6703 6704 $('.twitter-share').on('click', function () { 6705 var $url = $(this).attr('data-url'), 6706 $title = $(this).attr('data-title'); 6707 6708 window.open('http://twitter.com/intent/tweet?text=' + $title + ' ' + $url, "twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6709 return false; 6710 }); 6711 6712 $('.pinterest-share').on('click', function () { 6713 var $url = $(this).attr('data-url'), 6714 $title = $(this).attr('data-title'), 6715 $image = $(this).attr('data-image'); 6716 window.open('http://pinterest.com/pin/create/button/?url=' + $url + '&media=' + $image + '&description=' + $title, "twitterWindow", "height=320,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6717 return false; 6718 }); 6719 6720 $('.facebook-share').on('click', function () { 6721 var $url = $(this).attr('data-url'); 6722 window.open('https://www.facebook.com/sharer/sharer.php?u=' + $url, "facebookWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6723 return false; 6724 }); 6725 6726 $('.googleplus-share').on('click', function () { 6727 var $url = $(this).attr('data-url'); 6728 window.open('https://plus.google.com/share?url=' + $url, "googlePlusWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6729 return false; 6730 }); 6731 6732 $('.linkedin-share').on('click', function () { 6733 var $url = $(this).attr('data-url'), 6734 $title = $(this).attr('data-title'), 6735 $desc = $(this).attr('data-desc'); 6736 window.open('http://www.linkedin.com/shareArticle?mini=true&url=' + $url + '&title=' + $title + '&summary=' + $desc, "linkedInWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0"); 6737 return false; 6738 }); 6739} 6740 6741 6742 6743 6744/* Woocommerce Add to card */ 6745/* -------------------------------------------------------------------- */ 6746 6747function product_loop_add_cart() { 6748 6749 "use strict"; 6750 6751 var $body = $('body'); 6752 $body.on('click', '.add_to_cart_button', function () { 6753 var product = $(this).parents('.product:eq(0)').addClass('adding-to-cart').removeClass('added-to-cart'); 6754 }) 6755 6756 $body.bind('added_to_cart', function () { 6757 $('.adding-to-cart').removeClass('adding-to-cart').addClass('added-to-cart'); 6758 }); 6759} 6760 6761 6762 6763 6764(function( $ ) { 6765 'use strict'; 6766 6767 var $wrapper = $('.js-bottom-corner-btns'); 6768 var $contactBtn = $wrapper.find('.js-bottom-corner-btn--contact'); 6769 var $backBtn = $wrapper.find('.js-bottom-corner-btn--back'); 6770 var hasContactBtn = $contactBtn.length; 6771 var hasBackBtn = $backBtn.length; 6772 6773 if(!hasBackBtn) return; 6774 6775 function deactivate() { 6776 $contactBtn.removeClass('is-active'); 6777 $backBtn.removeClass('is-active'); 6778 } 6779 6780 function activate() { 6781 $contactBtn.addClass('is-active'); 6782 $backBtn.addClass('is-active'); 6783 } 6784 6785 MK.utils.scrollSpy( 400, { 6786 before: deactivate, 6787 after: activate 6788 }); 6789 6790})( jQuery ); 6791(function($) { 6792 'use strict'; 6793 6794 $('.mk-fullscreen-nav-close, .mk-fullscreen-nav-wrapper, #fullscreen-navigation a').on('click', function(e) { 6795 6796 // Close nav with removing classes 6797 $('.mk-fullscreen-nav').removeClass('opened'); 6798 $('.mk-dashboard-trigger').removeClass('fullscreen-active'); 6799 $('body').removeClass('fullscreen-nav-opened'); 6800 6801 var anchor = MK.utils.detectAnchor( this ), 6802 $this = $( this ); 6803 6804 // Scroll to anchor if exists 6805 if( anchor.length ) { 6806 e.preventDefault(); 6807 MK.utils.scrollToAnchor( anchor ); 6808 6809 // Or do nothing if pointless # as href 6810 // BAD PRACTICE: it is very popular to use "#" for click elements that we listen to with
6810js. 6811 // GOOD PRACTICE: prefer "javascript:;" as easier to handle and more readable version 6812 } else if( $this.attr( 'href' ) === '#' ) { 6813 e.preventDefault(); 6814 } 6815 }); 6816 6817}(jQuery)); 6818(function($) { 6819 'use strict'; 6820 6821 /** 6822 * Mega menu 6823 */ 6824 var $navList = $(".main-navigation-ul"); 6825 var megaMenu = function megaMenu() { 6826 6827 $navList.MegaMenu({ 6828 type: "vertical", 6829 delay: 200 6830 }); 6831 }; 6832 6833 $(window).on('load', megaMenu); 6834 6835}(jQuery)); 6836(function($) { 6837 'use strict'; 6838 6839 /** 6840 * One pager menu hash update. 6841 * Smooth scroll is appended globally whenever the click element has corresponding #el 6842 */ 6843 var onePageNavItem = function onePageNavItem() { 6844 var $this = $( this ), 6845 link = $this.find( 'a' ), 6846 anchor = MK.utils.detectAnchor( link ); // anchor on current page 6847 6848 if( !anchor.length ) return; 6849 6850 $this.removeClass( 'current-menu-item current-menu-ancestor current-menu-parent' ); 6851 6852 var activeNav = function( state ) { 6853 return function() { 6854 $this[ state ? 'addClass' : 'removeClass' ]( 'current-menu-item' ); 6855 window.history.replaceState( undefined, undefined, [ state ? anchor : ' ' ] ); 6856 }; 6857 }; 6858 6859 MK.utils.scrollSpy( $( anchor )[0], { 6860 before : activeNav( false ), 6861 active : activeNav( true ), 6862 after : activeNav( false ), 6863 }); 6864 }; 6865 6866 var $navItems = $('.js-main-nav').find( 'li' ); 6867 6868 $(window).on('load', function() { 6869 // Wait with spying anchors so we do not assign anchor that is browser scroll to after page load 6870 // Especially when there are anchors on top - refreshing page can cause grabbing one of them into url 6871 // and force unwanted scroll 6872 setTimeout(function() { 6873 $navItems.each( onePageNavItem ); 6874 }, 1000); 6875 }); 6876 6877}(jQuery)); 6878(function($) { 6879 'use strict'; 6880 6881 var $window = $(window); 6882 var $body = $('body'); 6883 var $resMenuWrap = $('.mk-responsive-wrap'); 6884 var $post_nav = $('.mk-post-nav'); 6885 var $toolbar = $('.mk-header-toolbar'); 6886 var $resMenuLink = $('.mk-nav-responsive-link'); 6887 6888 // Flags 6889 var hasResMenu = ($resMenuWrap.length > 0); 6890 6891 // We keep this handler above hasResMenu flag. 6892 // Even if our header doesn't contain droppable responsive menu (in favor of fullscreen or side menu) 6893 // we still transform tollbar into collapsible menu part in responsive state 6894 $('.mk-toolbar-resposnive-icon').on('click',function(e) { 6895 e.preventDefault(); 6896 console.log('clicked'); 6897 if ($body.hasClass('toolbar-opened')) { 6898 $body.removeClass('toolbar-opened').addClass('toolbar-closed'); 6899 $toolbar.hide(); 6900 } else { 6901 $body.removeClass('toolbar-closed').addClass('toolbar-opened'); 6902 $toolbar.show(); 6903 } 6904 }); 6905 6906 6907 if(!hasResMenu) return; 6908 6909 function toggleResMenu(e) { 6910 e.preventDefault(); 6911 var $this = $(this); 6912 var $headerInner = $this.parents('header'); 6913 var $resMenu = $headerInner.find('.mk-responsive-wrap'); 6914 6915 if ($body.hasClass('mk-opened-nav')) { 6916 $this.removeClass('is-active'); 6917 $body.removeClass('mk-opened-nav').addClass('mk-closed-nav').trigger('mk-closed-nav'); 6918 $resMenu.hide(); 6919 $post_nav.removeClass('post-nav-backward'); 6920 } else { 6921 $this.addClass('is-active'); 6922 $body.removeClass('mk-closed-nav').addClass('mk-opened-nav').trigger('mk-opened-nav'); 6923 $resMenu.show(); 6924 $post_nav.addClass('post-nav-backward'); 6925 6926 var offset = $headerInner.offset().top; 6927 var headerHeight = MK.val.offsetHeaderHeight(offset); 6928 MK.utils.scrollTo(offset - headerHeight + 5); 6929 } 6930 } 6931 6932 $resMenuLink.each(function() { 6933 $(this).on('click', toggleResMenu); 6934 }); 6935 6936 /*$('.mk-nav-arrow').stop(true).on('click', function(e) { 6937 // Prevent any unexpected behaviour here 6938 e.stopPropagation(); 6939 var $arrow = $(this); 6940 6941 if($(e.target).hasClass('mk-nav-arrow') || $(e.target).hasClass('mk-nav-open')) { 6942 e.preventDefault(); 6943 if ($arrow.hasClass('mk-nav-sub-closed')) { 6944 $arrow.next().show().end().removeClass('mk-nav-sub-closed').addClass('mk-nav-sub-opened'); 6945 } else { 6946 $arrow.next().hide().end().removeClass('mk-nav-sub-opened').addClass('mk-nav-sub-closed'); 6947 } 6948 } 6949 });*/ 6950 6951 6952 var setResMenuHeight = function() { 6953 var height = $window.height() - MK.val.offsetHeaderHeight(0); 6954 $resMenuWrap.css('max-height', height); 6955 }; 6956 6957 setResMenuHeight(); 6958 $window.on('resize', setResMenuHeight); 6959 6960 6961 var hideResMenu = function hideResMenu() { 6962 if(MK.utils.isResponsiveMenuState()) { 6963 // hide toggled menu and its states 6964 if ($body.hasClass('mk-opened-nav')) { 6965 $resMenuLink.filter('.is-active').trigger('click'); 6966 } 6967 // hide menu wrapper 6968 $resMenuWrap.hide(); 6969 } 6970 }; 6971 6972 $window.on('resize', hideResMenu); 6973 $resMenuWrap.on('click', 'a', hideResMenu); 6974 6975}(jQuery)); 6976(function($) { 6977 'use strict'; 6978 6979 var $header = $('.mk-header'); 6980 var hasHeader = ($header.length > 0); 6981 6982 if(!hasHeader) return; 6983 6984 var $sticky_style = $header.attr('data-header-style'); 6985 6986 //if ($sticky_style !== 3) return; 6987 6988 $('.sidedash-navigation-ul > li').each(function() { 6989 var $this = $(this); 6990 6991 $this.children('ul').siblings('a').after('<span class="mk-moon-arrow-down mk-nav-arrow mk-nav-sub-closed"></span>'); 6992 }); 6993 6994 $('.mk-nav-arrow').stop(true).on('click', function(e) { 6995 e.preventDefault(); 6996 var $this = $(this); 6997 6998 if ($this.hasClass('mk-nav-sub-closed')) { 6999 $this.siblings('ul').slideDown(450).end().removeClass('mk-nav-sub-closed').addClass('mk-nav-sub-opened'); 7000 } else { 7001 $this.siblings('ul').slideUp(450).end().removeClass('mk-nav-sub-opened').addClass('mk-nav-sub-closed'); 7002 } 7003 }); 7004 7005 $('.mk-dashboard-trigger').on('click', function(e) { 7006 var $this = $(this), 7007 $body = $('body'), 7008 $fullscreen_box = $('.mk-fullscreen-nav'); 7009 7010 if ($this.hasClass('dashboard-style')){ 7011 if (!$this.hasClass('dashboard-active')) { 7012 $this.addClass('dashboard-active'); 7013 $body.addClass('dashboard-opened'); 7014 } else { 7015 $this.removeClass('dashboard-active'); 7016 $body.removeClass('dashboard-opened'); 7017 } 7018 }else if($this.hasClass('fullscreen-style')){ 7019 if (!$this.hasClass('fullscreen-active')) { 7020 $this.addClass('fullscreen-active'); 7021 $body.addClass('fullscreen-nav-opened'); 7022 $fullscreen_box.addClass('opened'); 7023 // MK.utils.scroll.disable(); 7024 } else { 7025 $this.removeClass('fullscreen-active'); 7026 $body.removeClass('fullscreen-nav-opened'); 7027 $fullscreen_box.removeClass('opened'); 7028 } 7029 } 7030 7031 e.preventDefault(); 7032 }); 7033 7034 $('html').on('click', function() { 7035 $('body').removeClass('dashboard-opened'); 7036 $('.mk-dashboard-trigger').removeClass('dashboard-active'); 7037 }); 7038 7039}(jQuery)); 7040(function($) { 7041 'use strict'; 7042 7043 /** 7044 * Vertical menu 7045 */ 7046 var $verticalMenu = $('#mk-vm-menu'); 7047 var verticalMenu = function verticalMenu() { 7048 if(!$verticalMenu.data('vertical-menu') && !MK.utils.isResponsiveMenuState()) { 7049 $verticalMenu.dlmenu(); 7050 $verticalMenu.data('vertical-menu', true); 7051 } 7052 }; 7053 7054 verticalMenu(); 7055 $(window).on('resize', verticalMenu); 7056 7057}(jQuery)); 7058(function($) { 7059 'use strict'; 7060 7061 // WPML 7062 var $lang_item = $('.mk-main-navigation > .main-navigation-ul > .menu-item-language'); 7063 $lang_item.addClass('no-mega-menu').css('visibility', 'visible'); 7064 $('.mk-main-navigation .menu-item-language > a').addClass('menu-item-link'); 7065 7066})(jQuery); 7067(function($) { 7068 'use strict'; 7069 7070 var $header = $( '.mk-header' ).first(); // Theme header is always first, do not apply to shortcode headers. 7071 var hasHeader = ($header.length > 0); 7072 7073 if(!hasHeader) return; 7074 7075 var $window = $( window ); 7076 var $document = $( document ); 7077 var $headerHolder = $header.find( '.mk-header-holder' ); 7078 var $paddingWrapper = $header.find('.mk-header-padding-wrapper'); 7079 var config = $header.data(); 7080 7081 /** 7082 * Flags 7083 * @type {Boolean} 7084 */ 7085 var isStickyLazy = (config.stickyStyle === 'lazy'); 7086 var isStickyFixed = (config.stickyStyle === 'fixed'); 7087 var isStickySlide = (config.stickyStyle === 'slide'); 7088 7089 function isSticky() { // Check for sticky compatibility 7090 //return config.headerStyle !== 4; header style 4 needs sticky state for transparent header. 7091 return true; 7092 } 7093
7094 function isColorable() { // Check for coloring compatibility 7095 // TODO make it explicit in DOM that header is transparent as this is only scenario for colorable header 7096 // Monkey patch - exclude header styles that don't fit colorable 7097 return config.headerStyle !== 4; 7098 } 7099 7100 7101 /** 7102 * Change header skin 7103 */ 7104 function changeSkin( e, skin ) { 7105 $header.attr( 'data-transparent-skin', skin ); 7106 // Fix for class based skining 7107 var contrast = skin === 'light' ? 'dark' : 'light'; 7108 $header.addClass(skin + '-skin'); 7109 $header.removeClass(contrast + '-skin'); 7110 } 7111 7112 if(isColorable()) MK.utils.eventManager.subscribe( 'firstElSkinChange', changeSkin ); 7113 7114 7115 // Assign sticky scenarions 7116 if (isSticky() && isStickyLazy) { 7117 if(config.headerStyle !== 2) { 7118 lazySticky(); 7119 } 7120 } 7121 else if (isSticky() && isStickyFixed) fixedSticky(); 7122 else if (isSticky() && isStickySlide) slideSticky(); 7123 7124 /** 7125 * Sticky header behavior: Lazy 7126 */ 7127 function lazySticky() { 7128 var elClassHidden = 'header--hidden'; 7129 var elClassSticky = 'a-sticky'; 7130 var wScrollCurrent = 0; 7131 var wScrollBefore = 0; 7132 var wScrollDiff = 0; 7133 var wHeight = 0; 7134 var dHeight = 0; 7135 7136 var setSizes = function setSizes() { 7137 dHeight = $document.height(); 7138 wHeight = $window.height(); 7139 }; 7140 7141 var onScroll = function onScroll() { 7142 wScrollCurrent = MK.val.scroll(); 7143 wScrollDiff = wScrollBefore - wScrollCurrent; 7144 7145 if( wScrollCurrent <= 0 ) { // scrolled to the very top; element sticks to the top 7146 $headerHolder.removeClass( elClassHidden ); 7147 $header.removeClass( elClassSticky ); 7148 7149 } else if( wScrollDiff > 0 && $headerHolder.hasClass( elClassHidden ) ) { // scrolled up; element slides in 7150 $headerHolder.removeClass( elClassHidden ); 7151 $header.addClass( elClassSticky ); 7152 7153 } else if( wScrollDiff < 0 ) { // scrolled down 7154 7155 if( wScrollCurrent + wHeight >= dHeight && $headerHolder.hasClass( elClassHidden ) ) { // scrolled to the very bottom; element slides in 7156 $headerHolder.removeClass( elClassHidden ); 7157 $header.addClass( elClassSticky ); 7158 } else { // scrolled down; element slides out 7159 $headerHolder.addClass( elClassHidden ); 7160 $header.removeClass( elClassSticky ); 7161 } 7162 } 7163 7164 wScrollBefore = wScrollCurrent; 7165 }; 7166 7167 setSizes(); 7168 onScroll(); 7169 $window.on( 'resize', MK.utils.throttle( 100, setSizes ) ); 7170 $window.on( 'scroll', MK.utils.throttle( 500, onScroll ) ); 7171 } 7172 7173 7174 /** 7175 * Sticky header behavior: Fixed 7176 */ 7177 function fixedSticky() { 7178 var sticked = false; 7179 var scrollPos; 7180 7181 var toggleState = function toggleState() { 7182 scrollPos = MK.val.scroll() + MK.val.adminbarHeight(); 7183 7184 if( (scrollPos > MK.val.stickyOffset() ) && ! MK.utils.isResponsiveMenuState() ) { 7185 if(sticked) return; // stop if already sticked 7186 $header.addClass('a-sticky'); 7187 sticked = true; 7188 } else { 7189 if(!sticked) return; // stop if already unsticked 7190 $header.removeClass('a-sticky'); 7191 sticked = false; 7192 } 7193 }; 7194 7195 toggleState(); 7196 $window.on( 'scroll', toggleState ); 7197 $window.on( 'resize', toggleState ); 7198 } 7199 7200 7201 /** 7202 * Sticky header behavior: Slide 7203 */ 7204 function slideSticky() { 7205 var sticked = false; 7206 var onScroll = function onScroll() { 7207 if (MK.val.scroll() > MK.val.stickyOffset()) { 7208 if(sticked) return; // stop if already sticked 7209 $header.addClass('pre-sticky'); 7210 $paddingWrapper.addClass('enable-padding'); 7211 setTimeout(function() { 7212 $header.addClass('a-sticky'); 7213 }, 1); 7214 sticked = true; 7215 } else { 7216 if(!sticked) return; // stop if already unsticked 7217 $header.removeClass('a-sticky'); 7218 $header.removeClass('pre-sticky'); 7219 $paddingWrapper.removeClass('enable-padding'); 7220 sticked = false;
7221 } 7222 }; 7223 7224 onScroll(); 7225 $window.on( 'scroll', onScroll ); 7226 } 7227 7228 // TODO 7229 // var pageIntro = $('body').data('intro'); // block scrolling on page intro 7230 7231 7232})( jQuery ); 7233(function( $ ) { 7234 'use strict'; 7235 7236 MK.ui.preloader = { 7237 dom : { 7238 overlay: '.mk-body-loader-overlay' 7239 }, 7240 7241 hide : function hide() { 7242 $( this.dom.overlay ).fadeOut(600, "easeInOutExpo", function() { 7243 $('body').removeClass('loading'); 7244 //$( this ).remove(); 7245 }); 7246 } 7247 }; 7248 7249})( jQuery ); 7250(function($) { 7251 'use strict'; 7252 7253 var _ajaxUrl = MK.core.path.ajaxUrl; 7254 var _instances = {}; 7255 7256 MK.utils.ajaxLoader = function ajaxLoader(el) { 7257 // retrun a cached instance to have control over state from within multiple places 7258 // we may need for example to reset pageId when do filtering. It is really one instance that controls both filtering and pagination / load more 7259 var id = '#' + ($(el).attr('id')); 7260 if(typeof _instances[id] !== 'undefined') return _instances[id]; 7261 7262 // else lets start new instance 7263 this.id = id; 7264 this.el = el; 7265 this.isLoading = false; 7266 this.xhrCounter = 0; 7267 }; 7268 7269 MK.utils.ajaxLoader.prototype = { 7270 init: function init() { 7271 // prevent double initialization of we return an instance 7272 if(this.initialized) return; 7273 7274 this.createInstance(); 7275 this.cacheElements(); 7276 7277 this.initialized = true; 7278 }, 7279 7280 cacheElements: function cacheElements() { 7281 this.$container = $(this.el); 7282 this.id = '#' + (this.$container.attr('id')); 7283 this.categories = this.$container.data('loop-categories'); 7284 7285 this.data = {}; 7286 this.data.action = 'mk_load_more'; 7287 this.data.query = this.$container.data('query'); 7288 this.data.atts = this.$container.data('loop-atts'); 7289 this.data.loop_iterator = this.$container.data('loop-iterator'); 7290 this.data.author = this.$container.data('loop-author'); 7291 this.data.posts = this.$container.data('loop-posts'); 7292 this.data.safe_load_more = this.$container.siblings('#safe_load_more').val(); 7293 this.data._wp_http_referer = this.$container.siblings('input[name="_wp_http_referer"]').val(); 7294 this.data.paged = 1; 7295 this.data.maxPages = this.$container.data('max-pages'); 7296 this.data.term = this.categories; 7297 }, 7298 7299 createInstance: function() { 7300 _instances[this.id] = this; 7301 }, 7302 7303 load: function load(unique) { 7304 var self = this; 7305 var seq = ++this.xhrCounter; 7306 this.isLoading = true; 7307 7308 return $.when( 7309 $.ajax({ 7310 url : _ajaxUrl, 7311 type : "POST", 7312 data : self.data 7313 }) 7314 ).done(function(response) { 7315 self.onDone(response, unique, seq); 7316 }); 7317 }, 7318 7319 onDone: function(response, unique, seq) { 7320 if(seq === this.xhrCounter) { 7321 var self = this; 7322 7323 response = $.parseJSON(response); 7324 response.unique = unique; 7325 response.id = this.id; 7326 7327 this.setData({ 7328 maxPages: response.maxPages, 7329 loop_iterator: response.i 7330 }); 7331 7332 // Preload images first by creating object from returned content. 7333 // imagesLoaded() method will create a promise that gets resolved when all images inside are loaded. 7334 // Our ajaxLoad is somehow more similar to window.onload event now. 7335 $(response.content).imagesLoaded().then(function() { 7336 MK.utils.eventManager.publish('ajaxLoaded', response); 7337 self.isLoading = false; 7338 self.initNewComponents(); 7339 }); 7340 7341 } else console.log('XHR request nr '+ seq +' aborted'); 7342 7343 }, 7344 7345 setData: function setData(atts) { 7346 for(var att in atts) { 7347 if(att === 'term' && atts[att] === '*') this.data.term = ''; 7348 else this.data[att] = atts[att]; 7349 } 7350 }, 7351 7352 getData: function getData(att) { 7353 return this.data[att]; 7354 }, 7355 7356 initNewComponents: function initNewComponents() { 7357 // Legacy scripts reinit 7358 window.ajaxInit(); 7359 setTimeout(window.ajaxDelayedInit, 1000); 7360 // New way to init apended things 7361 MK.core.initAll(this.el); 7362 } 7363 }; 7364 7365}(jQuery)); 7366(function( $ ) { 7367 'use strict'; 7368 7369 var val = MK.val; 7370 7371 MK.component.FullHeight = function( el ) { 7372 var $window = $( window ), 7373 $this = $( el ), 7374 container = document.getElementById( 'mk-theme-container' ), 7375 winH = null, 7376 height = null, 7377 update_count = 0, 7378 testing = MK.utils.getUrlParameter('testing'), 7379 offset = null; 7380 7381 // We need to provide height on the same specificity level for workaround to IE bug 7382 // connect.microsoft.com/IE/feedback/details/802625/min-height-and-flexbox-flex-direction-column-dont-work-together-in-ie-10-11-preview 7383 // stackoverflow.com/questions/19371626/flexbox-not-centering-vertically-in-ie 7384 if(MK.utils.browser.name === ('IE' || 'Edge')) $this.css( 'height', '1px' ); 7385 7386 var update = function() { 7387 if(update_count === 0) { 7388 winH = $window.height(); 7389 offset = $this.offset().top; 7390 height = winH - val.offsetHeaderHeight( offset ); 7391 // set 7392 $this.css( 'min-height', height ); 7393 if(testing !== undefined ) 7394 update_count++; 7395 } 7396 7397 }; 7398 7399 // TODO remove scroll listener by dynamic offset reader 7400 var init = function() { 7401 update(); 7402 $window.on( 'resize', update ); 7403 $window.on( 'scroll', update ); 7404 window.addResizeListener( container, update ); 7405 }; 7406 7407 return { 7408 init : init 7409 }; 7410 }; 7411 7412})( jQuery ); 7413 7414 7415(function( $ ) { 7416 'use strict'; 7417 7418 var core = MK.core, 7419 utils = MK.utils, 7420 path = MK.core.path; 7421 7422 7423 MK.ui.FullScreenGallery = function( element, settings ) { 7424 this.element = element; 7425 this.config = settings; 7426 7427 this.isFullScreen = false;
7428 }; 7429 7430 7431 // preload slick PLUGIN TO USE THIS 7432 MK.ui.FullScreenGallery.prototype = { 7433 dom : { 7434 fullScrBtn : '.slick-full-screen', 7435 exitFullScrBtn : '.slick-minimize', 7436 playBtn : '.slick-play', 7437 pauseBtn : '.slick-pause', 7438 shareBtn : '.slick-share', 7439 socialShare : '.slick-social-share', 7440 wrapper : '.slick-slider-wrapper', 7441 slider : '.slick-slides', 7442 slides : '.slick-slide', 7443 dots : '.slick-dot', 7444 active : '.slick-active', 7445 hiddenClass : 'is-hidden', 7446 dataId : 'slick-index' 7447 }, 7448 7449 tpl: { 7450 dot : '<div class="slick-dot"></div>', 7451 next : '<a href="javascript:;" class="slick-next"> <svg width="33px" height="65px"> <polyline fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points=" 0.5,0.5 32.5,32.5 0.5,64.5"/> </svg> </a>', 7452 prev : '<a href="javascript:;" class="slick-prev"> <svg width="33px" height="65px"> <polyline fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points=" 32.5,64.5 0.5,32.5 32.5,0.5"/> </svg> </a>' 7453 }, 7454 7455 init : function() { 7456 var self = this; 7457 7458 // core.loadDependencies([ path.plugins + 'slick.js' ], function() { 7459 self.cacheElements(); 7460 self.getViewportSizes(); 7461 self.updateSizes( 'window' ); 7462 self.create(); 7463 // update cache with elements propagated by plugin 7464 self.updateCacheElements(); 7465 self.createPagination(); 7466 self.bindEvents(); 7467 // }); 7468 }, 7469 7470 create : function() { 7471 var self = this; 7472 7473 this.slick = this.$gallery.slick({ 7474 dots: true, 7475 arrows: true, 7476 infinite: true, 7477 speed: 300, 7478 slidesToShow: 1, 7479 centerMode: true, 7480 centerPadding: '0px', 7481 variableWidth: true, 7482 autoplay: false, 7483 autoplaySpeed: 3000, 7484 useTransform: true, 7485 prevArrow: self.tpl.prev, 7486 nextArrow: self.tpl.next, 7487 customPaging: function(slider, i) { 7488 return self.tpl.dot; 7489 }, 7490 }); 7491 }, 7492 7493 cacheElements : function() { 7494 this.$window = $( window ); 7495 this.$gallery = $( this.element ); 7496 7497 this.$fullScrBtn = $( this.dom.fullScrBtn ); 7498 this.$exitFullScrBtn = $( this.dom.exitFullScrBtn ); 7499 this.$playBtn = $( this.dom.playBtn ); 7500 this.$pauseBtn = $( this.dom.pauseBtn ); 7501 this.$shareBtn = $( this.dom.shareBtn ); 7502 this.$socialShare = $( this.dom.socialShare ); 7503 7504 this.$wrapper = $( this.dom.wrapper ); 7505 this.$slider = $( this.dom.slider ); 7506 this.$slides = $( this.dom.slides ); 7507 this.$imgs = this.$slides.find( 'img' ); 7508 // store reference to initial images without slides appended by pugin 7509 // - needed for creating of pagination 7510 this.$originalImgs = this.$imgs; 7511 }, 7512 7513 updateCacheElements : function() { 7514 this.$slides = $( this.dom.slides ); 7515 this.$imgs = this.$slides.find( 'img' ); 7516 this.$dots = $( this.dom.dots ); 7517 }, 7518 7519 bindEvents : function() { 7520 var self = this; 7521 this.$fullScrBtn.on( 'click', this.toFullScreen.bind( this ) ); 7522 this.$exitFullScrBtn.on( 'click', this.exitFullScreen.bind( this ) ); 7523 this.$playBtn.on( 'click', this.play.bind( this ) ); 7524 this.$pauseBtn.on( 'click', this.pause.bind( this ) ); 7525 this.$shareBtn.on( 'click', this.toggleShare.bind( this ) ); 7526 this.$socialShare.on( 'click', 'a', this.socialShare.bind( this ) ); 7527 this.$window.on( 'resize', this.onResize.bind( this ) ); 7528 this.$window.on( 'keydown', function(e) { 7529 if(e.keyCode === 39) self.$gallery.slick('slickNext'); 7530 if(e.keyCode === 37) self.$gallery.slick('slickPrev'); 7531 }); 7532 $( document ).on( 'fullscreenchange mozfullscreenchange webkitfullscreenchange msfullcreenchange', this.exitFullScreen.bind( this ) ); 7533 }, 7534 7535 getViewportSizes : function() { 7536 this.screen = { 7537 w: screen.width, 7538 h: screen.height 7539 }; 7540 this.window = { 7541 w: this.$window.width(), 7542 h: this.$window.height() 7543 }; 7544 }, 7545 7546 updateSizes : function( viewport ) { 7547 this.$wrapper.width( this[ viewport ].w ); 7548 this.$wrapper.height( this[ viewport ].h ); 7549 this.$imgs.height( this[ viewport ].h - 110 ); 7550 }, 7551 7552 createPagination : function() { 7553 var self = this; 7554 this.$dots.each( function( i ) { 7555 var img = self.$originalImgs.eq( i ).attr( 'src' ); 7556 7557 $( this ).css({ 7558 'background-image': 'url('+ img +')' 7559 }); 7560 }); 7561 }, 7562 7563 play : function() { 7564 this.$playBtn.addClass( this.dom.hiddenClass ); 7565 this.$pauseBtn.removeClass( this.dom.hiddenClass ); 7566 $( this.element ).slick( 'slickPlay' ); 7567 }, 7568 7569 pause : function() { 7570 this.$pauseBtn.addClass( this.dom.hiddenClass ); 7571 this.$playBtn.removeClass( this.dom.hiddenClass ); 7572 $( this.element ).slick( 'slickPause' ); 7573 }, 7574 7575 toggleShare : function() { 7576 this.$socialShare.toggleClass( this.dom.hiddenClass ); 7577 }, 7578 7579 getCurentId : function() { 7580 return this.$slides.filter( this.dom.active ).data( this.dom.dataId ); 7581 }, 7582 7583 toFullScreen : function() { 7584 var self = this; 7585 7586 this.$fullScrBtn.addClass( this.dom.hiddenClass ); 7587 this.$exitFullScrBtn.removeClass( this.dom.hiddenClass ); 7588 7589 this.$slider.hide().fadeIn( 500 ); 7590 utils.launchIntoFullscreen( document.documentElement ); 7591 this.updateSizes( 'screen' ); 7592 $( this.element ).slick( 'slickGoTo', this.getCurentId(), true ); 7593 7594 // Update state with delay so we avoid triggering exitFullScreen fn from 7595 // fullscreenchange event 7596 setTimeout( function() { 7597 self.isFullScreen = true; 7598 }, 1000); 7599 }, 7600 7601 exitFullScreen : function() { 7602 if( this.isFullScreen ) { 7603 this.$exitFullScrBtn.addClass( this.dom.hiddenClass ); 7604 this.$fullScrBtn.removeClass( this.dom.hiddenClass ); 7605 7606 utils.exitFullscreen(); 7607 this.updateSizes( 'window' ); 7608 $( this.element ).slick( 'slickGoTo', this.getCurentId(), true ); 7609 7610 this.isFullScreen = false;
7611 } 7612 7613 }, 7614 7615 onResize : function() { 7616 this.getViewportSizes(); 7617 this.updateSizes( this.isFullScreen ? 'screen' : 'window' ); 7618 $( this.element ).slick( 'slickGoTo', this.getCurentId(), true ); 7619 }, 7620 7621 socialShare : function( e ) { 7622 e.preventDefault(); 7623 var $this = $( e.currentTarget ), 7624 network = $this.data( 'network' ), 7625 id = this.config.id, 7626 url = this.config.url, 7627 name; 7628 7629 switch( network ) { 7630 case 'facebook': 7631 url = 'https://www.facebook.com/sharer/sharer.php?u=' + url + '#id=' + id; 7632 name = 'Facebook Share'; 7633 break; 7634 case 'twitter': 7635 url = 'http://twitter.com/intent/tweet?text=' + url + '#id=' + id; 7636 name = 'Twitter Share'; 7637 break; 7638 case 'pinterest': 7639 url = 'http://pinterest.com/pin/create/button/?url=' + url + '#id=' + id; 7640 // other available link paranmeters: media, description 7641 name = 'Pinterest Share'; 7642 break; 7643 7644 } 7645 7646 window.open( url, name, "height=380 ,width=660, resizable=0, toolbar=0, menubar=0, status=0, location=0, scrollbars=0" ); 7647 } 7648 }; 7649 7650})( jQuery ); 7651(function($) { 7652 'use strict'; 7653 7654 MK.component.Grid = function( el ) { 7655 var $container = $(el); 7656 var config = $container.data( 'grid-config' ); 7657 var isSlideshow = $container.closest('[data-mk-component="SwipeSlideshow"]').length; 7658 7659 var init = function init(){ 7660 // Flags for cancelling usage goes first : 7661 // Quit early if we discover that Grid is used inside SwipeSlideshow as it brings bug with crossoverriding positioning 7662 // + grid is not really needed as we have single row all handled by slider. 7663 // It happens only in woocommerce carousel as of hardcoded Grid in loop-start.php 7664 if(isSlideshow) return; 7665 MK.core.loadDependencies([ MK.core.path.plugins + 'minigrid.js' ], create); 7666 }; 7667 7668 // // Remove el hidden without adding proper class 7669 var removeOddlyHidden = function removeOddlyHidden() { 7670 var $item = $(this); 7671 var isHidden = ($item.css('display') === 'none'); 7672 if(isHidden) { 7673 console.log('removed by grid component: ', this); 7674 $item.remove(); 7675 } 7676 }; 7677 7678 var create = function create() { 7679 7680 function grid(item) { 7681 var selector = (typeof item === 'string') ? item : config.item; 7682 7683 // Prevent plugin breaking when feeding it with hidden elements 7684 var $items = $container.find(selector); 7685 $items.each( removeOddlyHidden ); 7686 7687 minigrid({ 7688 container: el, 7689 item: selector, 7690 gutter: 0 7691 }); 7692 } 7693 7694 grid(); 7695 7696 $(window).off('resize', grid); 7697 $(window).on('resize', grid); 7698 7699 MK.utils.eventManager.subscribe('item-expanded', grid); 7700 MK.utils.eventManager.subscribe('ajaxLoaded', grid); 7701 }; 7702 7703 7704 return { 7705 init : init 7706 }; 7707 }; 7708 7709})(jQuery); 7710 7711 7712 7713 7714 7715 7716 7717 7718(function($, window){ 7719 'use strict'; 7720 7721 var scrollY = MK.val.scroll; 7722 var dynamicHeight = MK.val.dynamicHeight; 7723 7724 var $window = $(window); 7725 var $containers = $('.js-loop'); 7726 7727 $containers.each( pagination ); 7728 7729 function pagination() { 7730 var unique = Date.now(); 7731 var $container = $(this); 7732 var $superContainer = $container.parent(); // should contain clearing so it stretches with floating children 7733 var $loadBtn = $container.siblings('.js-loadmore-button'); 7734 var $loadScroll = $('.js-load-more-scroll'); 7735 var style = $container.data('pagination-style'); 7736 var maxPages = $container.data('max-pages'); 7737 var id = '#' + ($container.attr('id')); 7738 var ajaxLoader = new MK.utils.ajaxLoader(id); 7739 var isLoadBtn = (style === 2); 7740 var isInfiniteScroll = (style === 3); // add flag for last container 7741 var scrollCheckPoint = null; 7742 var isHandlerBinded = false; 7743 7744 ajaxLoader.init(); 7745 7746 init(); 7747 7748 function init() { 7749 MK.utils.eventManager.subscribe('ajaxLoaded', onLoad); 7750 bindHandlers(); 7751 if( isInfiniteScroll ) scrollCheckPoint = spyScrollCheckPoint(); 7752 } 7753 7754 function bindHandlers() { 7755 if( isLoadBtn ) $loadBtn.on('click', handleClick); 7756 if( isInfiniteScroll ) $window.on('scroll', handleScroll); 7757 isHandlerBinded = true; 7758 } 7759 7760 function unbindHandlers() { 7761 if( isLoadBtn ) $loadBtn.off('click', handleClick); 7762 if( isInfiniteScroll ) $window.off('scroll', handleScroll); 7763 isHandlerBinded = false;
7764 } 7765 7766 function handleClick(e) { 7767 e.preventDefault(); 7768 if(!ajaxLoader.isLoading) loadMore(); 7769 } 7770 7771 function handleScroll() { 7772 if((scrollY() > scrollCheckPoint()) && !ajaxLoader.isLoading) loadMore(); 7773 } 7774 7775 function loadMore() { 7776 loadingIndicatorStart(); 7777 var page = ajaxLoader.getData('paged'); 7778 ajaxLoader.setData({paged: ++page}); 7779 ajaxLoader.load(unique); 7780 } 7781 7782 function onLoad(e, response) { 7783 if(response.id === id) { 7784 if( ajaxLoader.getData('paged') >= ajaxLoader.getData('maxPages')) loadingIndicatorHide(); 7785 else loadingIndicatorShow(); 7786 if(response.unique === unique) $container.append(response.content); 7787 loadingIndicatorStop(); 7788 } 7789 } 7790 7791 function loadingIndicatorStart() { 7792 if(isLoadBtn) $loadBtn.addClass('is-active'); 7793 else if(isInfiniteScroll) MK.ui.loader.add('.js-load-more-scroll'); 7794 7795 } 7796 7797 function loadingIndicatorStop() { 7798 if(isLoadBtn) $loadBtn.removeClass('is-active'); 7799 else if(isInfiniteScroll) MK.ui.loader.remove('.js-load-more-scroll'); 7800 } 7801 7802 function loadingIndicatorShow() { 7803 if(isHandlerBinded) return; 7804 if(isLoadBtn) $loadBtn.show(); 7805 else if(isInfiniteScroll) $loadScroll.show(); 7806 bindHandlers(); 7807 } 7808 7809 function loadingIndicatorHide() { 7810 if(!isHandlerBinded) return; 7811 if(isLoadBtn) $loadBtn.hide(); 7812 else if(isInfiniteScroll) $loadScroll.hide(); 7813 unbindHandlers(); 7814 } 7815 7816 7817 function spyScrollCheckPoint() { 7818 var containerO = 0; 7819 var containerH = dynamicHeight( $superContainer ); 7820 var winH = dynamicHeight( window ); 7821 7822 var setVals = function() { 7823 containerO = $superContainer.offset().top; 7824 }; 7825 7826 setVals(); 7827 $window.on('resize', function() { requestAnimationFrame(setVals); }); 7828 7829 return function() { 7830 return (containerH() + containerO) - (winH() * 2); 7831 }; 7832 } 7833 } 7834 7835})(jQuery, window); 7836(function($) { 7837 'use strict'; 7838 7839 // Check if it's inside hidden parent 7840 // Cannot be position: fixed 7841 function isHidden(el) { 7842 return (el.offsetParent === null); 7843 } 7844 7845 MK.component.Masonry = function(el) { 7846 var $window = $(window); 7847 var $container = $(el); 7848 var config = $container.data( 'masonry-config' ); 7849 var $masonryItems = $container.find(config.item); 7850 var cols = config.cols || 8; 7851 var $filterItems = null; // assign only when apply filter 7852 var wall = null; 7853 7854 var init = function init() { 7855 MK.core.loadDependencies([ MK.core.path.plugins + 'freewall.js' ], onDepLoad); 7856 }; 7857 7858 var onDepLoad = function onDepLoad() { 7859 masonry(); 7860 7861 // Events 7862 $window.on('resize', onResize); 7863 MK.utils.eventManager.subscribe('ajaxLoaded', onPostAddition); 7864 }; 7865 7866 var masonry = function masonry() { 7867 // Quit for hidden elements for now. 7868 if(isHidden(el)) return; 7869 7870 var newCols; 7871 if(window.matchMedia( '(max-width:600px)' ).matches) newCols = 2; 7872 else if(window.matchMedia( '(max-width:850px)' ).matches) newCols = 4; 7873 else newCols = cols; 7874 7875 var colW = $container.width() / newCols; 7876 7877 wall = new Freewall( config.container ); 7878 7879 // We need to pass settings to a plugin via reset method. Strange but works fine. 7880 wall.reset({ 7881 selector: config.item + ':not(.is-hidden)', 7882 gutterX: 0, // set default gutter to 0 and again - apply margins to item holders in css 7883 gutterY: 0, 7884 cellW: colW, 7885 cellH: colW 7886 }); 7887 7888 wall.fillHoles(); 7889 wall.fitWidth(); 7890 7891 $masonryItems.each(function() { 7892 $(this).data('loaded', true); 7893 }); 7894 }; 7895 7896 7897 // Clear attributes after the plugin. It's API method dosn't handle it properly 7898 var destroyContainer = function destroyContainer() { 7899 $container.removeAttr('style') 7900 .removeData('wall-height') 7901 .removeData('wall-width') 7902 .removeData('min-width') 7903 .removeData('total-col') 7904 .removeData('total-row') 7905 .removeAttr('data-wall-height') 7906 .removeAttr('data-wall-width') 7907 .removeAttr('data-min-width') 7908 .removeAttr('data-total-col') 7909 .removeAttr('data-total-row'); 7910 }; 7911 7912 var destroyItem = function destroyItem() { 7913 var $item = $(this); 7914 $item.removeAttr('style') 7915 .removeData('delay') 7916 .removeData('height') 7917 .removeData('width') 7918 .removeData('state') 7919 .removeAttr('data-delay') 7920 .removeAttr('data-height') 7921 .removeAttr('data-width') 7922 .removeAttr('data-state'); 7923 }; 7924 7925 var destroyAll = function destroyAll() { 7926 if( !wall ) return; 7927 wall.destroy(); // API destroy 7928 destroyContainer(); 7929 $masonryItems.each( destroyItem ); // run our deeper destroy 7930 }; 7931 7932 var onResize = function onResize() { 7933 requestAnimationFrame(resize); 7934 }; 7935 7936 var refresh = function refresh() { 7937 if( !wall ) return; 7938 setTimeout(wall.fitWidth.bind(wall), 5); 7939 }; 7940 7941 var resize = function resize() { 7942 destroyAll(); 7943 masonry(); 7944 }; 7945 7946 var onPostAddition = function onPostAddition() { 7947 $masonryItems = $container.find(config.item); 7948 7949 $masonryItems.each(function() { 7950 var $item = $(this), 7951 isLoaded = $item.data('loaded'); 7952 7953 if(!isLoaded) $item.css('visibility', 'hidden'); 7954 }); 7955 7956 7957 $container.imagesLoaded().then(function() { 7958 destroyAll(); 7959 masonry(); 7960 }); 7961 }; 7962 7963 return { 7964 init : init 7965 }; 7966 }; 7967 7968}(jQuery)); 7969(function($) { 7970 'use strict'; 7971 7972 MK.component.Pagination = function(el) { 7973 this.el = el; 7974 }; 7975 7976 MK.component.Pagination.prototype = {
7977 init: function init() { 7978 this.cacheElements(); 7979 this.bindEvents(); 7980 }, 7981 7982 cacheElements: function cacheElements() { 7983 this.lastId = 1; 7984 this.unique = Date.now(); 7985 this.$pagination = $(this.el); 7986 this.$container = this.$pagination.prev('.js-loop'); 7987 this.$pageLinks = this.$pagination.find('.js-pagination-page'); 7988 this.$nextLink = this.$pagination.find('.js-pagination-next'); 7989 this.$prevLink = this.$pagination.find('.js-pagination-prev'); 7990 this.$current = this.$pagination.find('.js-current-page'); 7991 this.$maxPages = this.$pagination.find('.pagination-max-pages'); // TODO change in DOM and here to js class 7992 this.containerId = '#' + this.$container.attr('id'); 7993 this.ajaxLoader = new MK.utils.ajaxLoader('#' + this.$container.attr('id')); 7994 this.ajaxLoader.init(); 7995 }, 7996 7997 bindEvents: function bindEvents() { 7998 this.$pageLinks.on('click', this.pageClick.bind(this)); 7999 this.$nextLink.on('click', this.nextClick.bind(this)); 8000 this.$prevLink.on('click', this.prevClick.bind(this)); 8001 MK.utils.eventManager.subscribe('ajaxLoaded', this.onLoad.bind(this)); 8002 }, 8003 8004 pageClick: function pageClick(e) { 8005 e.preventDefault(); 8006 var $this = $(e.currentTarget); 8007 var id = parseFloat($this.attr('data-page-id')); 8008 8009 if(id > this.ajaxLoader.getData('maxPages') || id < 1) return; 8010 this.load(id, $this); 8011 }, 8012 8013 nextClick: function nextClick(e) { 8014 e.preventDefault(); 8015 if(this.ajaxLoader.getData('paged') === this.ajaxLoader.getData('maxPages')) return; 8016 this.load(++this.lastId, $(e.currentTarget)); 8017 }, 8018 8019 prevClick: function prevClick(e) { 8020 e.preventDefault(); 8021 if(this.ajaxLoader.getData('paged') === 1) return; 8022 this.load(--this.lastId, $(e.currentTarget)); 8023 }, 8024 8025 load: function load(id, $el) { 8026 this.lastId = id; 8027 this.ajaxLoader.setData({paged: id}); 8028 this.ajaxLoader.load(this.unique); 8029 this.removeIndicator(); 8030 MK.ui.loader.add($el); 8031 }, 8032 8033 onLoad: function success(e, response) { 8034 if(response.id === this.containerId) { 8035 this.updatePagination(); 8036 this.lastId = this.ajaxLoader.getData('paged'); 8037 8038 if(response.unique === this.unique) { 8039 this.removeIndicator(); 8040 this.scrollPage(); 8041 this.$container.html(response.content); 8042 } 8043 } 8044 }, 8045 8046 updatePagination: function updatePagination() { 8047 var self = this; 8048 8049 // Hide / show arrows 8050 var isFirst = (this.ajaxLoader.getData('paged') === 1); 8051 var isLast = (this.ajaxLoader.getData('paged') === this.ajaxLoader.getData('maxPages')); 8052 8053 if(isFirst) this.$prevLink.addClass('is-vis-hidden'); 8054 else this.$prevLink.removeClass('is-vis-hidden'); 8055 8056 if(isLast) this.$nextLink.addClass('is-vis-hidden'); 8057 else this.$nextLink.removeClass('is-vis-hidden'); 8058 8059 // X of Y 8060 this.$current.html(this.ajaxLoader.getData('paged')); 8061 this.$maxPages.html(this.ajaxLoader.getData('maxPages')); 8062 8063 // Move overfloating items 8064 var displayItems = 10; 8065 var centerAt = displayItems / 2; 8066 8067 if(this.ajaxLoader.getData('maxPages') > displayItems) { 8068 this.$pageLinks.each(function(i) { 8069 8070 var id = self.lastId - centerAt; 8071 id = Math.max(id, 1); 8072 id = Math.min(id, self.ajaxLoader.getData('maxPages') - displayItems + 1); 8073 id = id + i; 8074 8075 $(this).html( id ).attr('data-page-id', id).show(); 8076 8077 if(i === 0 && id > 1) $(this).html('...'); 8078 if(i === displayItems - 1 && id < self.ajaxLoader.getData('maxPages')) $(this).html('...'); 8079 }); 8080 } else { 8081 this.$pageLinks.each(function(i) { 8082 var $link = $(this); 8083 var id = i + 1; 8084 8085 $link.html(id).attr('data-page-id', id); 8086 8087 if( self.ajaxLoader.getData('maxPages') === 1) { 8088 self.$pageLinks.hide(); 8089 } else { 8090 if(i > self.ajaxLoader.getData('maxPages') - 1) $link.hide(); 8091 else $link.show(); 8092 } 8093 8094 }); 8095 } 8096 8097 // Highlight current only 8098 this.$pageLinks.filter('[data-page-id="' + this.ajaxLoader.getData('paged') + '"]' ).addClass('current-page') 8099 .siblings().removeClass('current-page'); 8100 8101 }, 8102 8103 scrollPage: function scrollPage() { 8104 var containerOffset = this.$container.offset().top; 8105 var offset = containerOffset - MK.val.offsetHeaderHeight( containerOffset ) - 20; 8106 MK.utils.scrollTo( offset ); 8107 }, 8108 8109 removeIndicator: function removeIndicator() { 8110 MK.ui.loader.remove('.js-pagination-page, .js-pagination-next, .js-pagination-prev'); 8111 } 8112 }; 8113 8114}(jQuery)); 8115(function( $ ) { 8116 'use strict'; 8117 8118 var val = MK.val, 8119 utils = MK.utils; 8120 8121 MK.component.Parallax = function( el ) { 8122 var self = this, 8123 $this = $( el ), 8124 obj = $this[0], 8125 $window = $( window ), 8126 container = document.getElementById( 'mk-theme-container' ), 8127 config = $this.data( 'parallax-config' ), 8128 $holder = $( config.holder ), 8129 headerHeight = null, 8130 offset = null, 8131 elHeight = null, 8132 ticking = false, 8133 isMobile = null; 8134 8135 8136 var clientRect = null; 8137 8138 var update = function() { 8139 // Clear styles to check for natural styles 8140 // then apply position and size 8141 obj.style.transform = null; 8142 obj.style.top = null; 8143 obj.style.bottom = null; 8144 8145 isMobile = MK.utils.isMobile(); 8146 8147 if( isMobile ) { 8148 $this.css( 'height', '' ); 8149 return; 8150 } 8151 8152 clientRect = $this[ 0 ].getBoundingClientRect(); 8153 offset = clientRect.top; 8154 elHeight = clientRect.height; 8155 headerHeight = val.offsetHeaderHeight( offset ); 8156 offset = offset - headerHeight + val.scroll(); 8157 8158 setPosition(); 8159 setSize( ); 8160 }; 8161 8162 8163 var h = 0, 8164 winH = 0, 8165 proportion = 0, 8166 height = 0; 8167 8168 // Position and background attachement should me moved to CSS but we repair it high specificity here as styles are not reliable currently 8169 var setSize = function() { 8170 $this.css( 'height', '' ); 8171 winH = $window.height() - headerHeight; 8172 h = obj.getBoundingClientRect().height; 8173 8174 if( config.speed <= 1 && config.speed > 0 ) { 8175 if( offset === 0 ) { 8176 $this.css({ 8177 backgroundAttachment: 'scroll', 8178 'will-change': 'transform' 8179 }); 8180 } else { 8181 $this.css({ 8182 height : h + ( (winH - h) * config.speed ), 8183 backgroundAttachment: 'scroll', 8184 'will-change': 'transform' 8185 }); 8186 } 8187 8188 } else if ( config.speed >
8188 1 && h <= winH ) { 8189 $this.css({ 8190 // good for full heights - 2 because it's viewable by 2 screen heights 8191 height: ( winH + ( ( winH * config.speed ) - winH ) * 2 ), 8192 top: -( ( winH * config.speed ) - winH ), 8193 backgroundAttachment: 'scroll', 8194 'will-change': 'transform' 8195 }); 8196 8197 } else if ( config.speed > 1 && h > winH ) { 8198 proportion = h / winH; 8199 height = ( winH + ( ( winH * config.speed ) - winH ) * (1 + proportion) ); 8200 8201 $this.css({ 8202 height: height, 8203 top: -( height - (winH * config.speed) ), 8204 backgroundAttachment: 'scroll', 8205 'will-change': 'transform' 8206 }); 8207 8208 } else if ( config.speed < 0 && h >= winH ) { 8209 height = h * (1 - config.speed); 8210 $this.css({ 8211 height: height + (height - h), 8212 top: h - height, 8213 backgroundAttachment: 'scroll', 8214 'will-change': 'transform' 8215 }); 8216 8217 } else if ( config.speed < 0 && h < winH ) { 8218 // candidate to change 8219 var display = (winH + h) / winH; 8220 height = h * -config.speed * display; 8221 $this.css({ 8222 height: h + (height * 2), 8223 top: -height, 8224 backgroundAttachment: 'scroll', 8225 'will-change': 'transform' 8226 }); 8227 } 8228 }; 8229 8230 8231 var currentPoint = null, 8232 progressVal = null, 8233 startPoint = null, 8234 endPoint = null, 8235 $opacityLayer = config.opacity ? $this.find( config.opacity ) : null, 8236 scrollY = null; 8237 8238 var setPosition = function() { 8239 startPoint = offset - winH; 8240 endPoint = offset + elHeight + winH - headerHeight; 8241 scrollY = val.scroll(); 8242 8243 if( scrollY < startPoint || scrollY > endPoint ) { 8244 ticking = false; 8245 return; 8246 } 8247 8248 currentPoint = (( -offset + scrollY ) * config.speed); 8249 8250 $this.css({ 8251 '-webkit-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 8252 '-moz-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 8253 '-ms-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 8254 '-o-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 8255 'transform': 'translateY(' + currentPoint + 'px) translateZ(0)' 8256 }); 8257 8258 ticking = false; 8259 }; 8260 8261 8262 var requestTick = function() { 8263 if( !ticking && !isMobile ) { 8264 window.requestAnimationFrame( setPosition ); 8265 ticking = true; 8266 } 8267 }; 8268 8269 8270 var init = function() { 8271 // Disable scroll effects when smooth scroll is disabled 8272 if( !MK.utils.isSmoothScroll ) { return; } 8273 8274 update(); 8275 setTimeout(update, 100); 8276 $window.on( 'load', update ); 8277 $window.on( 'resize', update ); 8278 window.addResizeListener( container, update ); 8279 8280 $window.on( 'scroll', requestTick ); 8281 }; 8282 8283 8284 return { 8285 init : init 8286 }; 8287 }; 8288 8289})( jQuery ); 8290(function($) { 8291 'use strict'; 8292 8293 MK.component.Preloader = function(el) { 8294 this.el = el; 8295 }; 8296 8297 MK.component.Preloader.prototype = { 8298 init: function init() { 8299 this.cacheElements(); 8300 this.bindEvents(); 8301 }, 8302 8303 cacheElements: function cacheElements() { 8304 this.$preloader = $(this.el); 8305 }, 8306 8307 bindEvents: function bindEvents() { 8308 this.onLoad(); // all components inited on page load 8309 }, 8310 8311 onLoad: function onLoad() { 8312 setTimeout(this.hidePreloader.bind(this), 300); 8313 }, 8314 8315 hidePreloader: function hidePreloader() { 8316 this.$preloader.hide(); 8317 } 8318 }; 8319 8320}(jQuery)); 8321 8322(function($) { 8323 'use strict'; 8324 8325 // Image added for proportional scaling 8326 MK.ui.loader = { 8327 tpl : function() { 8328 return '<div class="mk-loading-indicator">' + 8329 '<div class="mk-loading-indicator__inner">' + 8330 '<div class="mk-loading-indicator__icon"></div>' + 8331 '<img style="height:100%; width:auto;" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">' + 8332 '</div>' + 8333 '</div>'; 8334 }, 8335 8336 add : function(item) { 8337 $(item).append(this.tpl); 8338 }, 8339 8340 remove : function(item) { 8341 $(item).find('.mk-loading-indicator').remove(); 8342 } 8343 }; 8344 8345}(jQuery)); 8346(function( $ ) { 8347 // IE / Edge fix for fixed positioned elements 8348 // MS clip path doesnt redraw properly so we expirience similar bug like with background attachement fixed on Chrome 8349 if (navigator.userAgent.match(/MSIE 10/i) || 8350 navigator.userAgent.match(/Trident\/7\./) || 8351 navigator.userAgent.match(/Edge\/12\./)) { 8352 8353 var val = 1; 8354 8355 var $edgeClipper = $('.mk-slider-slide'); // edge slider 8356 var $sectionClipper = $('.clipper-true'); // edge slider 8357 var $bgLayer = $('.background-layer'); // page section 8358 8359 var onScroll = function onScroll() { 8360 val *= -1; 8361 if( $edgeClipper.length ) $edgeClipper.each( redraw ); 8362 if( $sectionClipper.length ) $sectionClipper.each( redraw ); 8363 if( $bgLayer.length ) $bgLayer.each( redraw ); 8364 }; 8365 8366 var redraw = function redraw() { 8367 $(this).css('margin-top', val / 100); 8368 }; 8369 8370 $(window).on("scroll", function () { 8371 window.requestAnimationFrame(onScroll); 8372 }); 8373 } 8374}(jQuery)); 8375(function( $ ) { 8376 'use strict'; 8377 8378 var utils = MK.utils; 8379 var val = MK.val; 8380 8381 /** 8382 * Keep track of top Level sections so we can easly skip to next one. 8383 * We must be explicit about DOM level to nested sections. 8384 * The list of sections is static. If you'd need to refreh it on ajax etc do it with pub/sub (not really needed now). 8385 * We keep track for the same sections in Footer for mutating window location with '!loading' to prevent native anchor behaviour. 8386 */ 8387 var $topLevelSections = $('#theme-page > .vc_row, #theme-page > .mk-main-wrapper-holder, #theme-page > .mk-page-section'); 8388 8389 $( document ).on( 'click', '.mk-skip-to-next', function() { 8390 var $this = $( this ), 8391 offset = $this.offset().top ,
8392 nextOffset = utils.nextHigherVal( offset, utils.offsets( $topLevelSections ) ); 8393 8394 utils.scrollTo( nextOffset - val.offsetHeaderHeight( nextOffset ) ); 8395 }); 8396 8397})( jQuery ); 8398(function($) { 8399 'use strict'; 8400 8401 // 8402 // Constructor 8403 // 8404 // ///////////////////////////////////////////////////////// 8405 8406 MK.ui.Slider = function( container, config ) { 8407 8408 var defaults = { 8409 slide : '.mk-slider-slide', 8410 nav : '.mk-slider-nav', 8411 effect : 'roulete', 8412 ease : 'easeOutQuart', // should not be changed, remove 8413 slidesPerView : 1, 8414 slidesToView : 1, 8415 transitionTime : 700, 8416 displayTime : 3000, 8417 autoplay : true, 8418 hasNav : true, 8419 hasPagination : true, 8420 paginationTpl : '<span></span>', 8421 paginationEl : '#pagination', 8422 draggable : true, 8423 fluidHeight : false, 8424 pauseOnHover : false, 8425 activeClass : 'is-active', 8426 onInitialize : function() {}, 8427 onAfterSlide : function( id ) {}, 8428 onBeforeSlide : function( id ) {} 8429 }; 8430 8431 this.state = { 8432 id : 0, 8433 moveForward : true, 8434 running : false, 8435 zIFlow : null, 8436 stop : false, 8437 }; 8438 8439 this.config = $.extend( defaults, config ); 8440 this.container = container; 8441 8442 this.initPerView = this.config.slidesPerView; 8443 8444 // Timer holder 8445 this.activeTimer = null; 8446 this.autoplay = null; 8447 this.timer = null; 8448 this.timerRemaining = parseInt(this.config.displayTime); 8449 }; 8450 8451 8452 8453 // 8454 // Shared methods 8455 // 8456 // ///////////////////////////////////////////////////////// 8457 8458 MK.ui.Slider.prototype = { 8459 8460 init : function() { 8461 this.setPerViewItems(); 8462 this.cacheElements(); 8463 this.getSlideSize(); 8464 this.bindEvents(); 8465 this.setSize(); 8466 this.setPos(); 8467 8468 // Hack for preparing 'prev' on first click if needed 8469 this.updateId( -1 ); 8470 this.updateId( 1 ); 8471 8472 this.val = this.dynamicVal(); 8473 this.timeline = this.prepareTimeline( this.config.transitionTime ); 8474 8475 this.timeline.build(); 8476 8477 if( this.config.hasPagination ) { this.buildPagination(); } 8478 if( this.config.autoplay && document.hasFocus() ) { this.setTimer(); } 8479 8480 if( typeof this.config.onInitialize === 'function' ) { 8481 this.config.onInitialize( this.slides ); 8482 } 8483 8484 if( this.config.fluidHeight === true ) { 8485 $( this.slides ).height( 'auto' ); 8486 $( this.container ).css( 'transition', 'height ' + 200 + 'ms ease-out' ); 8487 this.setHeight( 0 ); 8488 } 8489 8490 8491 if( this.config.fluidHeight === 'toHighest' ) { 8492 this.setHeightToHighest(); 8493 } 8494 }, 8495 8496 8497 cacheElements : function () { 8498 this.container = this.isNode( this.container ) ? this.container 8499 : document.querySelectorAll( this.container )[0]; 8500 this.slides = this.container.querySelectorAll( this.config.slide ); 8501 8502 if( this.config.hasNav ) { this.$nav = $( this.config.nav ); } 8503 if( this.config.hasPagination ) { this.$pagination = $( this.config.paginationEl ); } 8504 }, 8505 8506 8507 bindEvents : function() { 8508 var $window = $( window ); 8509 8510 if( this.config.slidesPerView > 1 ) { $window.on( 'resize', this.setPerViewItems.bind( this ) ); } 8511 if( this.config.hasNav ) { this.eventsNav(); } 8512 if( this.config.hasPagination ) { this.eventsPag(); } 8513 if( this.config.draggable ) { this.dragHandler(); } 8514 if( this.config.autoplay ) { 8515 $window.on( 'focus', this.windowActive.bind( this ) ); 8516 $window.on( 'blur', this.windowInactive.bind( this ) ); 8517 } 8518 if( this.config.pauseOnHover ) { 8519 $(this.container).on( 'mouseleave', this.setTimer.bind( this ) ); 8520 $(this.container).on( 'mouseenter', this.unsetTimer.bind( this ) ); 8521 } 8522 if( this.config.fluidHeight === 'toHighest' ) { 8523 $window.on( 'resize', this.setHeightToHighest.bind( this ) ); 8524 } 8525 }, 8526 8527 8528 setPerViewItems: function() { 8529 if(window.matchMedia( '(max-width: 500px)' ).matches) { this.config.slidesPerView = 1; } 8530 else if(window.matchMedia( '(max-width: 767px)' ).matches && this.initPerView >= 2 ) { this.config.slidesPerView = 2; } 8531 else if(window.matchMedia( '(max-width: 1024px)' ).matches && this.initPerView >= 3 ) { this.config.slidesPerView = 3; } 8532 else { this.config.slidesPerView = this.initPerView; } 8533 8534 if( typeof this.slides === 'undefined' ) return;
8535 this.getSlideSize(); 8536 this.setSize(); 8537 this.setPos(); 8538 this.timeline = this.prepareTimeline( this.config.transitionTime ); 8539 this.timeline.build(); 8540 }, 8541 8542 8543 eventsNav : function() { 8544 this.$nav.on( 'click', 'a', this.handleNav.bind( this ) ); 8545 }, 8546 8547 8548 eventsPag : function() { 8549 this.$pagination.on( 'click', 'a', this.handlePagination.bind( this ) ); 8550 }, 8551 8552 8553 handleNav : function( e ) { 8554 e.preventDefault(); 8555 8556 if( this.state.running ) { return; } 8557 this.state.running = true; 8558 8559 var $this = $( e.currentTarget ), 8560 moveForward = $this.data( 'direction' ) === 'next'; 8561 8562 8563 if( this.config.autoplay ) { 8564 this.unsetTimer(); 8565 setTimeout( this.setTimer.bind( this ), this.config.transitionTime ); 8566 } 8567 8568 this.state.moveForward = moveForward; 8569 this.timeline.build(); 8570 this.timeline.play(); 8571 8572 this.setActive( this.nextId( moveForward ? 1 : -1 ) ); 8573 if( this.config.fluidHeight ) { this.setHeight( this.nextId( moveForward ? 1 : -1 ) ); } 8574 }, 8575 8576 8577 handlePagination : function( e ) { 8578 e.preventDefault(); 8579 8580 var $this = $( e.currentTarget ), 8581 id = $this.index(); 8582 8583 this.goTo( id ); 8584 }, 8585 8586 8587 reset: function() { 8588 this.state.stop = true; 8589 this.state.id = 0; 8590 this.setPos(); 8591 this.unsetTimer(); 8592 this.setTimer(); 8593 }, 8594 8595 8596 goTo : function(id) { 8597 if( this.state.running ) { return; } 8598 this.state.running = true; 8599 8600 var lastId = this.state.id; 8601 8602 if( lastId === id ) { 8603 return; 8604 } else if( lastId < id ) { 8605 this.state.moveForward = true; 8606 } else { 8607 this.state.moveForward = false; 8608 } 8609 8610 if( this.config.autoplay ) { 8611 this.unsetTimer(); 8612 setTimeout( this.setTimer.bind( this ), this.config.transitionTime ); 8613 } 8614 8615 this.timeline.build( Math.abs( lastId - id ) ); 8616 this.timeline.play(); 8617 8618 this.setActive( id ); 8619 if( this.config.fluidHeight ) { this.setHeight( id ); } 8620 }, 8621 8622 8623 windowActive : function() { 8624 this.setTimer(false, true); 8625 $(this.container).removeClass('is-paused'); 8626 }, 8627 8628 8629 windowInactive : function() { 8630 this.unsetTimer(); 8631 $(this.container).addClass('is-paused'); 8632 }, 8633 8634 8635 updateId : function( val ) { 8636 var len = this.slides.length, 8637 insertVal = this.state.id + val; 8638 insertVal = ( insertVal >= 0 ) ? insertVal : len + val; 8639 insertVal = ( insertVal >= len ) ? 0 : insertVal; // 0 maybe with modulo 8640 8641 this.state.id = insertVal; 8642 }, 8643 8644 nextId : function( val ) { 8645 var len = this.slides.length, 8646 insertVal = this.state.id + val; 8647 insertVal = ( insertVal >= 0 ) ? insertVal : len + val; 8648 insertVal = ( insertVal >= len ) ? 0 : insertVal; 8649 8650 return insertVal; 8651 }, 8652 8653 8654 setStyle : function( obj, style ) { 8655 var hasT = style.transform, 8656 t = { 8657 x : ( hasT ) ? style.transform.translateX : null, 8658 y : ( hasT ) ? style.transform.translateY : null, 8659 scale : ( hasT ) ? style.transform.scale : null, 8660 rotate : ( hasT ) ? style.transform.rotate : null, 8661 rotateX : ( hasT ) ? style.transform.rotateX : null, 8662 rotateY : ( hasT ) ? style.transform.rotateY : null 8663 }, 8664 z = 'translateZ(0)', 8665 x = (t.x) ? 'translateX(' + t.x + '%)' : 'translateX(0)', 8666 y = (t.y) ? 'translateY(' + t.y + '%)' : 'translateY(0)', 8667 s = (t.scale) ? 'scale(' + t.scale + ')' : 'scale(1)', 8668 r = (t.rotate) ? 'rotate(' + t.rotate + 'deg)' : 'rotate(0)', 8669 rX = (t.rotateX) ? 'rotateX(' + t.rotateX + 'deg)' : '', 8670 rY = (t.rotateY) ? 'rotateY(' + t.rotateY + 'deg)' : '', 8671 8672 o = style.opacity, 8673 h = style.height, 8674 w = style.width; 8675 8676 var c = z + x + y + s + r + rX + rY; 8677 8678 if( c.length ) { 8679 obj.style.webkitTransform = c; 8680 obj.style.msTransform = c; 8681 obj.style.transform = c; 8682 } 8683 8684 if( typeof o === 'number' ) { obj.style.opacity = o; } 8685 if( h ) { obj.style.height = h + '%'; } 8686 if( w ) { obj.style.width = w + '%'; } 8687 }, 8688 8689 8690 setPos : function() { 8691 if( typeof this.slides === 'undefined' ) return; 8692 var id = this.state.id, 8693 i = 0, 8694 len = this.slides.length, 8695 animation = this.animation[ this.config.effect ], 8696 axis = animation.axis, 8697 animNext = animation.next, 8698 animActi = animation.active, 8699 animPrev = animation.prev, 8700 perView = this.config.slidesPerView, 8701 slideId = null, 8702 zIFlow = null, 8703 style = {}; 8704 8705 style.transform = {}; 8706 8707 8708 for( ; i < len; i += 1 ) { 8709 if(i < perView) { 8710 // Position for visible slides. Apply active styles 8711 style = animActi; 8712 style.transform[ 'translate' + axis ] = i * 100; 8713 } else { 8714 // Rest slides move after edge based on axis and moveForward. Apply Next / Prev styles 8715 style = this.state.moveForward ? animNext : animPrev; 8716 style.transform[ 'translate' + axis ] = this.state.moveForward ? perView * 100 : -100; 8717 } 8718 8719 this.slides[ i ].style.zIndex = 0; 8720 8721 slideId = ( i + id ) % len; 8722 this.setStyle( this.slides[ slideId ], style ); 8723 } 8724 }, 8725 8726 8727 // When we're setting animation along Y axis we're going to set up height 8728 // otherwise width. It is shared amongst all slides 8729 setSize : function() { 8730 if( typeof this.slides === 'undefined' ) return; 8731 var i = 0, 8732 len = this.slides.length, 8733 axis = this.animation[ this.config.effect ].axis, 8734 slideSize = this.slideSize, 8735 style = {}; 8736 8737 if( axis === 'Y' ) { 8738 style.height = slideSize[ axis ]; 8739 } else { 8740 style.width = slideSize[ axis ]; 8741 } 8742 8743 for( ; i < len; i += 1 ) { 8744 this.setStyle( this.slides[ i ], style ); 8745 } 8746 }, 8747 8748 8749 setHeight : function( id ) { 8750 var $slides = $( this.slides ), 8751 $activeSlide = $slides.eq( id ); 8752 8753 var currentHeight = $activeSlide.height(); 8754 $( this.container ).height( currentHeight ); 8755 }, 8756 8757 8758 setHeightToHighest : function() { 8759 // this is becouse of alliginig woocommrece carousel. Too much DOM 8760 // Refactor someday 8761 var $slides = $( this.slides ), 8762 height = 0; 8763 8764 $slides.each(function() { 8765 height = Math.max(height, $(this).find('> div').outerHeight()); 8766 }); 8767 8768 $( this.container ).height( height ); 8769 }, 8770 8771 8772 // Little utility inspired by GreenSock. 8773 // We export this to this.timeline on init. 8774 prepareTimeline : function( time ) { 8775 var self = this, 8776 iteration = 0, 8777 totalIter = time / (1000 / 60), 8778 animLoop = [], 8779 aL = 0, // animation length 8780 loops = 1, 8781 ease = this.config.ease, 8782 currentStyle, timeProg, 8783 build, move, add, play, reverse, progress, kill; 8784 8785 8786 // Build constants, run them only once 8787 // take out possibly 8788 var len = this.slides.length, 8789 perView = this.config.slidesPerView, 8790 animation = this.animation[ this.config.effect ], 8791 animAxis = animation.axis, 8792 animNext = animation.next, 8793 animActi = animation.active, 8794 animPrev = animation.prev, 8795 style = {}, 8796 slideId = null, 8797 zIFlow = null; 8798 8799 style.transform = {}; 8800 8801 8802 build = function( repeats ) { 8803 var currentEase = ease; 8804 loops = repeats || loops; 8805 8806 // console.log('build', loops); 8807 8808 if( !loops ) { return; } 8809 if( loops > 1 ) { 8810 currentEase = 'linearEase'; 8811 } 8812 8813 // clean before running new build 8814 kill(); 8815 // set new positions 8816 self.setPos(); 8817 8818 var id = self.state.id, 8819 moveForward = self.state.moveForward, 8820 i = 0, 8821 axisMove = (moveForward) ? -100 : 100; 8822
8823 for( ; i <= perView; i += 1 ) { 8824 slideId = ( (moveForward) ? i + id : i + id - 1 ) % len; 8825 slideId = ( slideId < 0 ) ? len + slideId : slideId; 8826 8827 if( i === 0 ) { 8828 style = moveForward ? animPrev : animActi; 8829 } else if( i === perView ) { 8830 style = moveForward ? animActi : animNext; 8831 } else { 8832 style = animActi; 8833 } 8834 8835 zIFlow = (self.state.moveForward) ? animNext.zIndex : animPrev.zIndex; 8836 if( zIFlow ) { 8837 // console.log( zIFlow ); 8838 self.slides[ slideId ].style.zIndex = (zIFlow === '+') ? i + 1 : len - i; 8839 } 8840 8841 style.transform[ 'translate' + animAxis ] = axisMove; 8842 add( self.slides[ slideId ], style, currentEase ); 8843 } 8844 }; 8845 8846 add = function( slide, toStyles, ease ) { 8847 if( typeof slide === 'undefined' ) { 8848 throw 'Add at least one slide'; 8849 } 8850 8851 var fromStyles = slide.style, 8852 style = self.refStyle( toStyles, fromStyles ); 8853 8854 animLoop.push( [slide, style, ease] ); 8855 aL += 1; 8856 }; 8857 8858 move = function( startProg, mode ) { 8859 var currentTotalIter = totalIter; 8860 8861 if( loops > 1 ) { 8862 currentTotalIter = totalIter / 5; 8863 } 8864 8865 if( !self.state.running ) { self.state.running = true; } 8866 8867 if( startProg ) { 8868 // update iteration val to cached outside var 8869 // ceil to handle properly play after mouse up / touch end 8870 iteration = Math.ceil(startProg * currentTotalIter); 8871 } 8872 8873 timeProg = iteration / currentTotalIter; 8874 progress( timeProg ); 8875 8876 // Break loop 8877 if( iteration >= currentTotalIter && mode === 'play' || 8878 iteration <= 0 && mode === 'reverse' ) { 8879 8880 self.state.running = false; 8881 iteration = 0; 8882 kill(); 8883 self.updateId( self.state.moveForward ? 1 : -1 ); 8884 // If we're creating multiple animation loop we trigger outside only first pass to start all game. 8885 // the rest are triggered as callback 8886 loops -= 1; 8887 if( loops > 0 ) { 8888 build(); 8889 play(); 8890 } 8891 8892 // if we run all loops reset back the default value 8893 if( !loops ) { 8894 loops = 1; 8895 self.timerRemaining = parseInt(self.config.displayTime); 8896 self.config.onAfterSlide( self.state.id ); 8897 } 8898 8899 return; 8900 } 8901 8902 // Run in given mode 8903 if( mode === 'play') { 8904 iteration += 1; 8905 } else { 8906 iteration -= 1; 8907 } 8908 8909 requestAnimationFrame( function() { 8910 if(self.state.stop) return; 8911 move( 0, mode ); 8912 }); 8913 }; 8914 8915 play = function( startProg ) { 8916 var start = startProg || 0; 8917 iteration = 0; 8918 self.state.stop = false; 8919 move( start, 'play' ); 8920 self.config.onBeforeSlide( self.state.id ); 8921 }; 8922 8923 reverse = function( startProg ) { 8924 var start = startProg || 1; 8925 move( start, 'reverse' ); 8926 }; 8927 8928 progress = function( progVal ) { 8929 var aI = 0, 8930 currentStyle; 8931 8932 for( aI; aI < aL; aI++ ) { 8933 if( progVal !== 1 && progVal !== 0 ) { 8934 currentStyle = self.currentStyle( progVal, animLoop[ aI ][ 1 ], animLoop[ aI ][ 2 ] ); 8935 } else if( progVal === 1) { 8936 currentStyle = self.currentStyle( progVal, animLoop[ aI ][ 1 ], 'linearEase' ); 8937 } else if ( progVal === 0 ) { 8938 currentStyle = self.currentStyle( progVal, animLoop[ aI ][ 1 ], 'linearEase' ); 8939 } 8940 self.setStyle( animLoop[ aI ][ 0 ], currentStyle ); 8941 } 8942 }; 8943 8944 // Clear previous loop 8945 kill = function() { 8946 animLoop = []; 8947 aL = 0; 8948 }; 8949 8950 8951 return { 8952 build : build, 8953 add : add, 8954 play : play, 8955 reverse : reverse, 8956 progress : progress 8957 }; 8958 }, 8959 8960 8961 // Build reference styles. 8962 // Return object with array containig initial style and change of its value 8963 // as required for easing functions 8964 refStyle : function( toStyles, fromStyles ) { 8965 var axis = this.animation[ this.config.effect ].axis, 8966 style = {}, 8967 initVal, changeVal, endVal, dynamicEnd, styleProp, transProp, transform; 8968 8969 for( styleProp in toStyles ) { 8970 8971 if( styleProp === 'transform' ) { 8972 transform = this.getTransforms( fromStyles ); 8973 style.transform = {}; 8974 8975 for( transProp in toStyles.transform ) { 8976 // don't care about z 8977 if( transProp === 'translateZ' ) { continue; } 8978 8979 initVal = transform[ transProp ] || 0; // if it is undefined it means it's 0 8980 dynamicEnd = ( transProp === 'translate' + axis ) ? initVal : 0; 8981 endVal = toStyles.transform[ transProp ] + dynamicEnd; // it is dynamic, based on slide position in current set 8982 changeVal = endVal - initVal; 8983 style.transform[ transProp ] = [ initVal, changeVal ]; 8984 } 8985 } else if( styleProp === 'zIndex' ) { 8986 // console.log( 'z' ); 8987 continue; 8988 } else { 8989 initVal = parseFloat( fromStyles[ styleProp ] ) || 0; // if it is undefined it means it's 0 8990 endVal = toStyles[ styleProp ]; 8991 changeVal = endVal - initVal; 8992 style[ styleProp ] = [ initVal, changeVal ]; 8993 } 8994 } 8995 8996 return style; 8997 }, 8998 8999 9000 currentStyle : function( progress, style, ease ) { 9001 var self = this, 9002 currentStyle = {}, 9003 currentVals, styleProp, transProp, prog; 9004 9005 // Redo same loop but construct currentStyle object out of cached values 9006 for( styleProp in style ) { 9007 9008 if( styleProp === 'transform' ) { 9009 currentStyle.transform = {}; 9010 9011 for( transProp in style.transform ) { 9012 // remove this line. double check first if needed by logging 9013 if( transProp === 'translateZ' ) { continue; } 9014 9015 currentVals = style.transform[ transProp ]; 9016 currentStyle.transform[ transProp ] = 9017 // (currentIteration, startValue, changeInValue, totalIterations) 9018 self.ease[ ease ]( progress, currentVals[ 0 ], currentVals[ 1 ], 1 ); 9019 } 9020 } else { 9021 currentVals = style[ styleProp ]; 9022 currentStyle[ styleProp ] = 9023 self.ease[ ease ]( progress, currentVals[ 0 ], currentVals[ 1 ], 1 ); 9024 } 9025 } 9026 9027 return currentStyle; 9028 }, 9029 9030 9031 setActive : function( id ) { 9032 var $slides = $( this.slides ), 9033 className = this.config.activeClass; 9034 9035 $slides.removeClass( className ); 9036 9037 if( this.config.hasPagination ) { 9038 var $pagination = this.$pagination.find( 'a' ); 9039 $pagination.removeClass( className ); 9040 $pagination.eq( id ).addClass( className ); 9041 } 9042 9043 if( this.activeTimer ) { 9044 // console.log( 'clearActive' ); 9045 clearTimeout( this.activeTimer ); 9046 } 9047 9048 this.activeTimer = setTimeout( function() { 9049 // console.log('setActive'); 9050 $slides.eq( id ).addClass( className ); 9051 }, this.config.transitionTime ); 9052 }, 9053 9054 9055 9056 setTimer : function( isFirst, isPaused ) { 9057 var self = this, 9058 interval = parseInt( this.config.displayTime ), 9059 trans = parseInt( this.config.transitionTime ), 9060 timer = interval + trans, 9061 first = isFirst || true, 9062 create, run; 9063 9064 this.timer = true; 9065 this.lastSetTimer = Date.now(); 9066 9067 create = function() { 9068 // console.log( 'autorun' ); 9069 if( self.autoplay ) { clearTimeout( self.autoplay ); } 9070 if( !self.timer ) { 9071 return; 9072 } 9073 self.state.moveForward = true; 9074 self.timeline.build(); 9075 self.timeline.play(); 9076 self.setActive( self.nextId( 1 ) ); 9077 if( self.config.fluidHeight ) { self.setHeight( self.nextId( 1 ) ); } 9078 first = false;
9079 self.lastSetTimer = Date.now(); 9080 run(); 9081 }; 9082 9083 run = function(interval) { 9084 var time = interval || timer; 9085 self.autoplay = setTimeout( create, time ); 9086 }; 9087 9088 if(isPaused) { 9089 run(this.timerRemaining); 9090 } 9091 else run(); 9092 }, 9093 9094 9095 unsetTimer : function() { 9096 this.timer = false; 9097 this.lastUnsetTimer = Date.now(); 9098 this.timerRemaining -= this.lastUnsetTimer - this.lastSetTimer; 9099 if( this.autoplay ) { clearTimeout( this.autoplay ); } 9100 }, 9101 9102 9103 buildPagination : function() { 9104 var i = 0, 9105 len = this.slides.length, 9106 tpl = ''; 9107 9108 for( ; i < len; i += 1 ) { 9109 tpl += '<a href="javascript:;">' + this.config.paginationTpl + '</a>'; 9110 } 9111 9112 this.$pagination.html( tpl ); 9113 this.setActive( 0 ); 9114 }, 9115 9116 9117 getSlideSize : function() { 9118 this.slideSize = { 9119 X: 100 / this.config.slidesPerView, 9120 Y: 100 / this.config.slidesPerView 9121 }; 9122 }, 9123 9124 9125 getTransforms : function( style ) { 9126 // console.log( style ); 9127 var transform = style.transform || style.webkitTransform || style.mozTransform, 9128 regex = /(\w+)\(([^)]*)\)/g, 9129 match, 9130 T = {}; 9131 9132 if( typeof transform !== 'string' ) { 9133 throw 'Transform prop is not a string.'; 9134 } 9135 9136 if( !transform ) { return; } 9137 9138 // Run regex assignment 9139 while( match = regex.exec( transform ) ) { 9140 T[ match[ 1 ] ] = parseFloat( match[ 2 ] ); 9141 } 9142 9143 return T; 9144 }, 9145 9146 isNode : function( o ) { 9147 return ( 9148 typeof Node === "object" ? o instanceof Node : 9149 o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName==="string" 9150 ); 9151 }, 9152 9153 9154 dragHandler : function() { 9155 var self = this, 9156 $container = $( this.container ), 9157 prevBuild = false, 9158 nextBuild = false, 9159 dragging = false, 9160 buffor = 5, // helpful for decoupling with click events 9161 dragStart, dragMove, dragEnd, progress; 9162 9163 progress = function( moveX ) { 9164 return moveX / self.val.viewportW(); 9165 }; 9166 9167 dragStart = function( moveX, startX ) { 9168 // console.log( 'start', moveX, startX ); 9169 }; 9170 9171 dragMove = function( moveX ) { 9172 // console.log('move'); 9173 if( self.state.running ) return; 9174 9175 // Don't need to check for existance here 9176 9177 if( moveX < -buffor ) { 9178 9179 if( !nextBuild ) { 9180 self.state.moveForward = true; 9181 self.timeline.build(); 9182 nextBuild = true; 9183 prevBuild = false; 9184 self.unsetTimer(); 9185 } else { 9186 // turn progress into positive val 9187 self.timeline.progress( -progress( moveX ) ); 9188 } 9189 dragging = true; 9190 } else if( moveX > buffor ) { 9191 9192 if( !prevBuild ) { 9193 self.state.moveForward = false; 9194 self.timeline.build(); 9195 prevBuild = true; 9196 nextBuild = false; 9197 self.unsetTimer(); 9198 } else { 9199 self.timeline.progress( progress( moveX ) ); 9200 } 9201 dragging = true; 9202 } 9203 }; 9204 9205 dragEnd = function( moveX ) { 9206 if( dragging ) { 9207 var prog = progress( moveX ), 9208 absProg = prog < 0 ? -prog : prog; 9209 9210 if( absProg > 0.1 ) { 9211 self.timeline.play( absProg ); 9212 self.setActive( self.nextId( prog < 0 ? 1 : -1 ) ); 9213 if( self.config.fluidHeight ) { self.setHeight( self.nextId( prog < 0 ? 1 : -1 ) ); } 9214 } else { 9215 self.timeline.reverse( absProg ); 9216 // eventually move this to reverse callbacks 9217 if(prog < 0) { 9218 self.updateId( -1 ); 9219 } else { 9220 self.updateId( 1 ); 9221 } 9222 } 9223 9224 prevBuild = false; 9225 nextBuild = false; 9226 dragging = false; 9227 if( self.config.autoplay ) { self.setTimer( false ); } 9228 } 9229 }; 9230 9231 this.drag( $container, dragStart, dragMove, dragEnd ); 9232 }, 9233 9234 9235 drag : function( $el, startFn, moveFn, stopFn ) { 9236 9237 var touchX, touchY, movX, movY, go, evt, 9238 prevent, start, move, stop; 9239 9240 prevent = function( e ) { 9241 e.preventDefault(); 9242 }; 9243 9244 start = function( e ) { 9245 // $el.on("touchmove", prevent); 9246 $el.on("mousemove", prevent); 9247 $el.on("touchmove", move); 9248 $el.on("mousemove", move); 9249 9250 evt = (e.type === 'touchstart') ? e.originalEvent.touches[0] : e; 9251 touchX = evt.pageX; 9252 9253 if(typeof startFn === 'function') { 9254 startFn(movX, touchX); 9255 } 9256 }; 9257 9258 move = function( e ) { 9259 evt = (e.type === 'touchmove') ? e.originalEvent.touches[0] : e; 9260 movX = evt.pageX - touchX; 9261 9262 if(typeof moveFn === 'function') { 9263 moveFn(movX); 9264 } 9265 }; 9266 9267 stop = function( e ) { 9268 // $el.off("touchmove", prevent); 9269 $el.off("mousemove", prevent); 9270 $el.off("touchmove", move); 9271 $el.off("mousemove", move); 9272 9273 if(typeof stopFn === 'function') { 9274 stopFn(movX); 9275 } 9276 }; 9277 9278 $el.on("touchstart", start); 9279 $el.on("mousedown", start); 9280 $el.on("touchend", stop); 9281 $el.on("touchleave", stop); 9282 $el.on("touchcancel", stop);
9283 $el.on("mouseup", stop); 9284 $el.on("mouseleave", stop); 9285 }, 9286 9287 9288 dynamicVal : function() { 9289 var $window = $( window ), 9290 update, 9291 getViewportW, viewportW; 9292 9293 update = function() { 9294 viewportW = $window.width(); 9295 }; 9296 9297 getViewportW = function() { 9298 return viewportW; 9299 }; 9300 9301 update(); 9302 $window.on( 'load', update ); 9303 $window.on( 'resize', update ); 9304 9305 return { 9306 viewportW : getViewportW 9307 }; 9308 } 9309 }; 9310 9311 9312 9313 // 9314 // Set of de fault animations 9315 // 9316 // ///////////////////////////////////////////////////////// 9317 9318 MK.ui.Slider.prototype.animation = { 9319 9320 slide : { 9321 axis : 'X', 9322 next : { transform: {} }, 9323 active : { transform: {} }, 9324 prev : { transform: {} } 9325 }, 9326 9327 vertical_slide : { 9328 axis : 'Y', 9329 next : { transform: {} }, 9330 active : { transform: {} }, 9331 prev : { transform: {} } 9332 }, 9333 9334 perspective_flip : { 9335 axis : 'Y', 9336 next : { 9337 transform: { 9338 rotateX : 80 9339 } 9340 }, 9341 active : { 9342 transform: { 9343 rotateX : 0 9344 } 9345 }, 9346 prev : { 9347 transform: { 9348 rotateX : 0 9349 } 9350 } 9351 }, 9352 9353 zoom : { 9354 axis : 'Z', 9355 next: { 9356 opacity : 0, 9357 transform : { 9358 scale : 0.9 9359 } 9360 }, 9361 active: { 9362 opacity : 1, 9363 transform : { 9364 scale : 1 9365 } 9366 }, 9367 prev: { 9368 opacity : 0, 9369 transform : { 9370 scale : 1.1 9371 } 9372 } 9373 }, 9374 9375 fade : { 9376 axis : 'Z', 9377 next: { 9378 opacity : 0, 9379 transform : {} 9380 }, 9381 active: { 9382 opacity : 1, 9383 transform : {} 9384 }, 9385 prev: { 9386 opacity : 0, 9387 transform : {} 9388 } 9389 }, 9390 9391 kenburned : { 9392 axis : 'Z', 9393 next: { 9394 opacity : 0, 9395 transform : {} 9396 }, 9397 active: { 9398 opacity : 1, 9399 transform : {} 9400 }, 9401 prev: { 9402 opacity : 0, 9403 transform : {} 9404 } 9405 }, 9406 9407 zoom_out : { 9408 axis : 'Z', 9409 next: { 9410 zIndex : '+', 9411 opacity : 1, 9412 transform : { 9413 translateY : 100, 9414 scale : 1 9415 } 9416 }, 9417 active: { 9418 opacity : 1, 9419 transform : { 9420 translateY : 0, 9421 scale : 1 9422 } 9423 }, 9424 prev: { 9425 zIndex : '+', 9426 opacity : 0, 9427 transform : { 9428 translateY : 0, 9429 scale : 0.5 9430 } 9431 } 9432 }, 9433 9434 // Problem with Z-Flow 9435 horizontal_curtain : { 9436 axis : 'Z', 9437 next: { 9438 zIndex : '+', 9439 transform : { 9440 translateX : 100, 9441 } 9442 }, 9443 active: { 9444 transform : { 9445 translateX : 0, 9446 } 9447 }, 9448 prev: { 9449 zIndex : '+', 9450 transform : { 9451 translateX : -70, 9452 } 9453 } 9454 }, 9455 9456 roulete : { 9457 axis : 'X', 9458 next: { 9459 opacity : 0.5, 9460 transform : { 9461 scale : 0.5, 9462 rotate : 10, 9463 translateY : 20 9464 } 9465 }, 9466 active: { 9467 opacity : 1, 9468 transform : { 9469 scale : 1, 9470 rotate : 0, 9471 translateY : 0 9472 } 9473 }, 9474 prev: { 9475 opacity : 0.3, 9476 transform : { 9477 scale : 0.5, 9478 rotate : -10, 9479 translateY : 20 9480 } 9481 } 9482 } 9483 }; 9484 9485 9486 9487 // 9488 // Penner's easing library 9489 // 9490 // ///////////////////////////////////////////////////////// 9491 9492 MK.ui.Slider.prototype.ease = { 9493 /* 9494 *
9495 * TERMS OF USE - EASING EQUATIONS 9496 * 9497 * Open source under the BSD License. 9498 * 9499 * Copyright é 2001 Robert Penner 9500 * All rights reserved. 9501 * 9502 * Redistribution and use in source and binary forms, with or without modification, 9503 * are permitted provided that the following conditions are met: 9504 * 9505 * Redistributions of source code must retain the above copyright notice, this list of 9506 * conditions and the following disclaimer. 9507 * Redistributions in binary form must reproduce the above copyright notice, this list 9508 * of conditions and the following disclaimer in the documentation and/or other materials 9509 * provided with the distribution. 9510 * 9511 * Neither the name of the author nor the names of contributors may be used to endorse 9512 * or promote products derived from this software without specific prior written permission. 9513 * 9514 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 9515 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 9516 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 9517 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 9518 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 9519 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 9520 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 9521 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 9522 * OF THE POSSIBILITY OF SUCH DAMAGE. 9523 * 9524 */ 9525 linearEase : function(currentIteration, startValue, changeInValue, totalIterations) { 9526 return changeInValue * currentIteration / totalIterations + startValue; 9527 }, 9528 9529 easeInQuad : function(currentIteration, startValue, changeInValue, totalIterations) { 9530 return changeInValue * (currentIteration /= totalIterations) * currentIteration + startValue; 9531 }, 9532 9533 easeOutQuad : function(currentIteration, startValue, changeInValue, totalIterations) { 9534 return -changeInValue * (currentIteration /= totalIterations) * (currentIteration - 2) + startValue; 9535 }, 9536 9537 easeInOutQuad : function(currentIteration, startValue, changeInValue, totalIterations) { 9538 if ((currentIteration /= totalIterations / 2) < 1) { 9539 return changeInValue / 2 * currentIteration * currentIteration + startValue; 9540 } 9541 return -changeInValue / 2 * ((--currentIteration) * (currentIteration - 2) - 1) + startValue; 9542 }, 9543 9544 easeInCubic : function(currentIteration, startValue, changeInValue, totalIterations) { 9545 return changeInValue * Math.pow(currentIteration / totalIterations, 3) + startValue; 9546 }, 9547 9548 easeOutCubic : function(currentIteration, startValue, changeInValue, totalIterations) { 9549 return changeInValue * (Math.pow(currentIteration / totalIterations - 1, 3) + 1) + startValue; 9550 }, 9551 9552 easeInOutCubic : function(currentIteration, startValue, changeInValue, totalIterations) { 9553 if ((currentIteration /= totalIterations / 2) < 1) { 9554 return changeInValue / 2 * Math.pow(currentIteration, 3) + startValue; 9555 } 9556 return changeInValue / 2 * (Math.pow(currentIteration - 2, 3) + 2) + startValue; 9557 }, 9558 9559 easeInQuart : function(currentIteration, startValue, changeInValue, totalIterations) { 9560 return changeInValue * Math.pow (currentIteration / totalIterations, 4) + startValue; 9561 }, 9562 9563 easeOutQuart : function(currentIteration, startValue, changeInValue, totalIterations) { 9564 return -changeInValue * (Math.pow(currentIteration / totalIterations - 1, 4) - 1) + startValue; 9565 }, 9566 9567 easeInOutQuart : function(currentIteration, startValue, changeInValue, totalIterations) { 9568 if ((currentIteration /= totalIterations / 2) < 1) { 9569 return changeInValue / 2 * Math.pow(currentIteration, 4) + startValue; 9570 } 9571 return -changeInValue/2 * (Math.pow(currentIteration - 2, 4) - 2) + startValue; 9572 }, 9573 9574 easeInQuint : function(currentIteration, startValue, changeInValue, totalIterations) { 9575 return changeInValue * Math.pow (currentIteration / totalIterations, 5) + startValue; 9576 }, 9577 9578 easeOutQuint : function(currentIteration, startValue, changeInValue, totalIterations) { 9579 return changeInValue * (Math.pow(currentIteration / totalIterations - 1, 5) + 1) + startValue; 9580 }, 9581 9582 easeInOutQuint : function(currentIteration, startValue, changeInValue, totalIterations) { 9583 if ((currentIteration /= totalIterations / 2) < 1) { 9584 return changeInValue / 2 * Math.pow(currentIteration, 5) + startValue; 9585 } 9586 return changeInValue / 2 * (Math.pow(currentIteration - 2, 5) + 2) + startValue; 9587 }, 9588 9589 easeInSine : function(currentIteration, startValue, changeInValue, totalIterations) { 9590 return changeInValue * (1 - Math.cos(currentIteration / totalIterations * (Math.PI / 2))) + startValue; 9591 }, 9592 9593 easeOutSine : function(currentIteration, startValue, changeInValue, totalIterations) { 9594 return changeInValue * Math.sin(currentIteration / totalIterations * (Math.PI / 2)) + startValue; 9595 }, 9596 9597 easeInOutSine : function(currentIteration, startValue, changeInValue, totalIterations) { 9598 return changeInValue / 2 * (1 - Math.cos(Math.PI * currentIteration / totalIterations)) + startValue; 9599 }, 9600 9601 easeInExpo : function(currentIteration, startValue, changeInValue, totalIterations) { 9602 return changeInValue * Math.pow(2, 10 * (currentIteration / totalIterations - 1)) + startValue; 9603 }, 9604 9605 easeOutExpo : function(currentIteration, startValue, changeInValue, totalIterations) { 9606 return changeInValue * (-Math.pow(2, -10 * currentIteration / totalIterations) + 1) + startValue; 9607 }, 9608 9609 easeInOutExpo : function(currentIteration, startValue, changeInValue, totalIterations) { 9610 if ((currentIteration /= totalIterations / 2) < 1) { 9611 return changeInValue / 2 * Math.pow(2, 10 * (currentIteration - 1)) + startValue; 9612 } 9613 return changeInValue / 2 * (-Math.pow(2, -10 * --currentIteration) + 2) + startValue; 9614 }, 9615 9616 easeInCirc : function(currentIteration, startValue, changeInValue, totalIterations) { 9617 return changeInValue * (1 - Math.sqrt(1 - (currentIteration /= totalIterations) * currentIteration)) + startValue; 9618 }, 9619 9620 easeOutCirc : function(currentIteration, startValue, changeInValue, totalIterations) { 9621 return changeInValue * Math.sqrt(1 - (currentIteration = currentIteration / totalIterations - 1) * currentIteration) + startValue; 9622 }, 9623 9624 easeInOutCirc : function(currentIteration, startValue, changeInValue, totalIterations) { 9625 if ((currentIteration /= totalIterations / 2) < 1) { 9626 return changeInValue / 2 * (1 - Math.sqrt(1 - currentIteration * currentIteration)) + startValue; 9627 } 9628 return changeInValue / 2 * (Math.sqrt(1 - (currentIteration -= 2) * currentIteration) + 1) + startValue; 9629 } 9630 }; 9631 9632})(jQuery); 9633(function($) { 9634 'use strict'; 9635 9636 MK.component.Sortable = function(el) { 9637 this.el = el; 9638 }; 9639 9640 MK.component.Sortable.prototype = {
9641 init: function init() { 9642 this.cacheElements(); 9643 this.bindEvents(); 9644 }, 9645 9646 cacheElements: function cacheElements() { 9647 this.unique = Date.now(); 9648 this.$filter = $(this.el); 9649 this.config = this.$filter.data('sortable-config'); 9650 9651 this.ajaxLoader = new MK.utils.ajaxLoader(this.config.container); 9652 this.ajaxLoader.init(); 9653 9654 this.$container = $( this.config.container ); 9655 this.$navItems = this.$filter.find('a'); 9656 }, 9657 9658 bindEvents: function bindEvents() { 9659 this.$navItems.on('click', this.handleClick.bind(this)); 9660 MK.utils.eventManager.subscribe('ajaxLoaded', this.onLoad.bind(this)); 9661 }, 9662 9663 handleClick: function handleClick(e) { 9664 e.preventDefault(); 9665 9666 var $item = $(e.currentTarget); 9667 var term = $item.data('filter'); 9668 9669 MK.ui.loader.remove(this.$filter); 9670 MK.ui.loader.add($item); 9671 9672 this.$navItems.removeClass('current'); 9673 $item.addClass('current'); 9674 9675 this.ajaxLoader.setData({ 9676 paged: 1, 9677 term: term 9678 }); 9679 this.ajaxLoader.load(this.unique); 9680 }, 9681 9682 onLoad: function onLoad(e, response) { 9683 if(response.id === this.config.container) { 9684 MK.ui.loader.remove(this.$filter); 9685 if(response.unique === this.unique) { 9686 this.$container.html(response.content); 9687 this.ajaxLoader.setData({paged: 1}); 9688 } 9689 } 9690 } 9691 }; 9692 9693})(jQuery); 9694(function($) { 9695 'use strict'; 9696 9697 MK.component.Tabs = function( el ) { 9698 var defaults = { 9699 activeClass : 'is-active' 9700 }; 9701 9702 this.config = defaults; 9703 this.el = el; 9704 }; 9705 9706 MK.component.Tabs.prototype = { 9707 9708 init : function() { 9709 this.cacheElements(); 9710 this.bindEvents(); 9711 }, 9712 9713 cacheElements : function() { 9714 this.$this = $( this.el ); 9715 this.$tabs = this.$this.find( '.mk-tabs-tab' ); 9716 this.$panes = this.$this.find( '.mk-tabs-pane' ); 9717 this.currentId = 0; 9718 }, 9719 9720 bindEvents : function() { 9721 var self = this; 9722 9723 this.$tabs.on( 'click', this.switchPane.bind( this ) ); 9724 }, 9725 9726 switchPane : function( evt ) { 9727 evt.preventDefault(); 9728 9729 var clickedId = $( evt.currentTarget ).index(); 9730 9731 this.hide( this.currentId ); 9732 this.show( clickedId ); 9733 9734 // Update current id 9735 this.currentId = clickedId; 9736 }, 9737 9738 show : function( id ) { 9739 this.$tabs.eq( id ).addClass( this.config.activeClass ); 9740 this.$panes.eq( id ).addClass( this.config.activeClass ); 9741 }, 9742 9743 hide : function( id ) { 9744 this.$tabs.eq( id ).removeClass( this.config.activeClass ); 9745 this.$panes.eq( id ).removeClass( this.config.activeClass ); 9746 } 9747 }; 9748 9749})(jQuery); 9750 9751 9752/* Tabs */ 9753/* -------------------------------------------------------------------- */ 9754 9755function mk_tabs() { 9756 9757 // "use strict"; 9758 9759 // if ($.exists('.mk-tabs, .mk-news-tab, .mk-woo-tabs')) { 9760 // $(".mk-tabs, .mk-news-tab, .mk-woo-tabs").tabs(); 9761 9762 // $('.mk-tabs').on('click', function () { 9763 // $('.mk-theme-loop').isotope('layout'); 9764 // }); 9765 9766 // $('.mk-tabs.vertical-style').each(function () { 9767 // $(this).find('.mk-tabs-pane').css('minHeight', $(this).find('.mk-tabs-tabs').height() - 1); 9768 // }); 9769 9770 // } 9771} 9772 9773function mk_tabs_responsive(){ 9774 // $('.mk-tabs, .mk-news-tab').each(function () { 9775 // $this = $(this); 9776 // if ($this.hasClass('mobile-true')) { 9777 // if (window.matchMedia('(max-width: 767px)').matches) 9778 // { 9779 // $this.tabs("destroy"); 9780 // } else { 9781 // $this.tabs(); 9782 // } 9783 // } 9784 // }); 9785 9786} 9787 9788 9789(function($) { 9790 'use strict'; 9791 9792 $(document).on('click', function(e) { 9793 $('.mk-toggle-trigger').removeClass('mk-toggle-active'); 9794 }); 9795 9796 function toggle(e) { 9797 e.preventDefault(); 9798 e.stopPropagation(); 9799 var $this = $(e.currentTarget); 9800 9801 if (!$this.hasClass('mk-toggle-active')) { 9802 9803 $('.mk-box-to-trigger').fadeOut(200); 9804 $this.parent().find('.mk-box-to-trigger').fadeIn(250); 9805 $('.mk-toggle-trigger').removeClass('mk-toggle-active'); 9806 $this.addClass('mk-toggle-active'); 9807 9808 } else { 9809 9810 $('.mk-box-to-trigger').fadeOut(200); 9811 $this.removeClass('mk-toggle-active'); 9812 9813 } 9814 } 9815 9816 function assignToggle() { 9817 // wait for ajax response propagation and insertion 9818 setTimeout(function() { 9819 $('.mk-toggle-trigger').off('click', toggle); 9820 $('.mk-toggle-trigger').on('click', toggle); 9821 }, 100); 9822 } 9823 9824 assignToggle(); 9825 MK.utils.eventManager.subscribe('ajaxLoaded', assignToggle); 9826 MK.utils.eventManager.subscribe('ajax-preview', assignToggle); 9827 9828}(jQuery)); 9829(function($) { 9830 'use strict'; 9831 9832 var $iframes = $('iframe'); 9833 9834 $iframes.each(function() { 9835 var $iframe = $(this); 9836 var parent = $iframe.parent().get(0); 9837 var tagName = parent.tagName; 9838 9839 if(tagName === 'P') $iframe.wrap('<div class="mk-video-container"></div>'); 9840 }); 9841 9842}(jQuery)); 9843(function( $ ) { 9844 'use strict'; 9845 9846 if( MK.utils.isMobile() ) { 9847 $('.mk-animate-element').removeClass('mk-animate-element'); 9848 return; 9849 } 9850 9851 // TODO solidify by one class name like js-master-wrapper and apply it to dom 9852 var $rootLevelEls = $('.js-master-row, .widget'); 9853 9854
9855 var init = function init() { 9856 $rootLevelEls.each( spyViewport ); 9857 $rootLevelEls.each( function rootLevelEl() { 9858 var $animateEl = $(this).find( '.mk-animate-element' ); 9859 $animateEl.each( spyViewport ); 9860 }); 9861 }; 9862 9863 var spyViewport = function spyViewport(i) { 9864 var self = this; 9865 9866 MK.utils.scrollSpy( this, { 9867 position : 'bottom', 9868 threshold : 200, 9869 after : function() { 9870 animate.call(self, i); 9871 } 9872 }); 9873 }; 9874 9875 var animate = function animate(i) { 9876 var $this = $(this); 9877 9878 setTimeout(function() { 9879 $this.addClass( 'mk-in-viewport' ); 9880 }, 100 * i); 9881 }; 9882 9883 9884 $(window).on('load', init); 9885 9886}(jQuery)); 9887(function($) { 9888 'use strict'; 9889 9890 $(document).on('change', '.variations_form select', moveToFirstSlide); 9891 9892 function moveToFirstSlide() { 9893 var $switcher = $('.variations_form select'), 9894 $wrapper = $switcher.parents('.mk-product'), 9895 id = $wrapper.find('.mk-slider-holder').parent().attr('id'); 9896 9897 MK.utils.eventManager.publish('gallery-update', { 9898 id: id 9899 }); 9900 } 9901 9902}(jQuery)); 9903(function($) { 9904 'use strict'; 9905 9906 /** 9907 * Entry point of application. Runs all components 9908 */ 9909 $( window ).on( 'load', function() { 9910 var MK = window.MK || {}; 9911 MK.core.initAll( document ); 9912 MK.utils.scrollToURLHash(); 9913 // TODO move preloader to components and manage it state from within 9914 setTimeout( function() { 9915 MK.ui.preloader.hide(); // site wide 9916 $('.mk-preloader').hide(); // components 9917 $('body').removeClass('loading'); 9918 }, 150 ); 9919 }); 9920 9921 /** 9922 * Assign global click handlers 9923 */ 9924 $( document ).on( 'click', '.js-smooth-scroll, .js-main-nav a', smoothScrollToAnchor); 9925 $( '.side_dashboard_menu a' ).on( 'click', smoothScrollToAnchor); 9926 9927 function smoothScrollToAnchor( evt ) { 9928 var MK = window.MK || {}; 9929 var anchor = MK.utils.detectAnchor( this ); 9930 9931 if( anchor.length ) { 9932 evt.preventDefault(); 9933 MK.utils.scrollToAnchor( anchor ); 9934 9935 } else if( $this.attr( 'href' ) === '#' ) { 9936 evt.preventDefault(); 9937 } 9938 } 9939 9940}(jQuery));}(jQuery))
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.