/** * File: jquery.awe-map.ts * Description: Create jquery plugin init for google map element * Author: DuyNg */ /// var AweMapPlugin = (function () { function AweMapPlugin(el, options) { this.markers = []; if ( window.google === undefined || window.google.maps === undefined || window.google.maps.Map === undefined ) throw Error("You must load google map api before use this plugin"); this.el = el; this.options = jQuery.extend( true, {}, AweMapPlugin.defaultOptions, options ); this.initialize(); } AweMapPlugin.prototype.initialize = function () { // set element height jQuery(this.el).css("width", "100%").height(this.options.height); // init map var options = jQuery.extend(true, {}, this.options); delete options.height; delete options.markers; options.center = AweMapPlugin.parsePosition(options.center); // wait to el is visible var _self = this, wait; wait = setInterval(function () { if (jQuery(_self.el).is(":visible")) { clearInterval(wait); _self.map = new window.google.maps.Map(_self.el, options); // init markers _self.initMarkers(); } }, 100); }; /** * add markers to map */ AweMapPlugin.prototype.initMarkers = function () { var _self = this, options = this.options; if (options.markers && options.markers.enable) { this.markers = []; if ( jQuery.isArray(options.markers.data) && options.markers.data.length > 0 ) { jQuery.each(options.markers.data, function (index, marker) { marker.index = index + 1; _self.addMarker(marker); }); } } }; /** * add new marker to map * @param data * @param index */ AweMapPlugin.prototype.addMarker = function (data, index) { if (typeof data === "object" && data.position !== undefined) { var position = AweMapPlugin.parsePosition(data.position); if (position) { var markerOptions = { position: position, title: data.title, zIndex: data.index, map: this.map, }; if (data.icon && data.icon.fid !== -1) { markerOptions.icon = { url: data.icon.url }; } if (data.animation !== "none") { markerOptions.animation = window.google.maps.Animation[data.animation]; } var marker_1 = new window.google.maps.Marker(markerOptions); if (data.animation === "BOUNCE") { marker_1.addListener("click", function () { marker_1.setAnimation(null); }); } if (data.description) { var _self_1 = this, isOpen_1 = false, infoWindow_1 = new window.google.maps.InfoWindow({ content: '

' + data.title + '

' + data.description + "
", }); marker_1.addListener("click", function () { if (!isOpen_1) { infoWindow_1.open(_self_1.map, marker_1); isOpen_1 = true; } else { infoWindow_1.close(); isOpen_1 = false; } }); } if (index !== undefined && this.markers[index] !== undefined) { this.markers[index].setMap(null); this.markers[index] = marker_1; } else this.markers.push(marker_1); } } }; /** * delete a marker from map * @param index */ AweMapPlugin.prototype.removeMarker = function (index) { if (this.markers[index] !== undefined) { var marker = this.markers.splice(index, 1)[0]; marker.setMap(null); } }; /** * remove all markers from map */ AweMapPlugin.prototype.removeAllMarkers = function () { jQuery.each(this.markers, function (index, marker) { marker.setMap(null); }); this.markers = []; }; /** * change option value * @param optionName * @param value */ AweMapPlugin.prototype.setOption = function (optionName, value) { var options = this.options; if (options[optionName] !== undefined) { if (optionName !== "markers") options[optionName] = value; this.applyOptionChange(optionName, value); } }; /** * apply view change when change option value * @param optionName * @param value */ AweMapPlugin.prototype.applyOptionChange = function (optionName, value) { var options = this.options; if (options[optionName] !== undefined) { if (value === undefined) value = options[optionName]; switch (optionName) { case "center": this.map.setCenter(AweMapPlugin.parsePosition(value)); break; case "zoom": this.map.setZoom(value); break; case "mapTypeId": this.map.setMapTypeId(value); break; case "height": case "scrollwheel": case "disableDefaultUI": this.destroy(); this.initialize(); break; case "markers": var action = value.action; if (action === "enableMarkers") options.markers.enable = value.enable; else this.options.markers.data = value.current; if (action === "add") { var marker = value.current.slice(-1).pop(); marker.index = value.current.length; this.addMarker(marker); } else if (action === "delete") { this.removeMarker(value.index); } else if (action === "update") { var marker = value.current.slice(-1).pop(); marker.index = value.index + 1; this.addMarker(marker, value.index); } else if (action === "sort") { this.removeAllMarkers(); this.initMarkers(); } else if (action === "enableMarkers") { if (value.enable) this.initMarkers(); else this.removeAllMarkers(); } break; } } }; /** * set options for map * @param options */ AweMapPlugin.prototype.setOptions = function (options) { this.options = jQuery.extend(true, this.options, options); this.destroy(); this.initialize(); }; /** * destroy map */ AweMapPlugin.prototype.destroy = function () { jQuery(this.el).removeAttr("style").html(""); }; /** * convert string position to object for map * @param value * @returns {{lat: number, lng: number}} */ AweMapPlugin.parsePosition = function (value) { if (typeof value === "string") { var center_arr = value.split(","); if (center_arr.length === 2) { return { lat: parseFloat(center_arr[0].trim()), lng: parseFloat(center_arr[1].trim()), }; } } console.log("Map position parse must be a string and have 2 params."); return false; }; AweMapPlugin.defaultOptions = { height: 400, center: "21.001763,105.820591", zoom: 14, mapTypeId: "roadmap", disableDefaultUI: true, scrollwheel: false, markers: { enable: false, data: [], }, }; return AweMapPlugin; })(); jQuery.fn.aweMap = function (options, extra) { var params = Array.prototype.slice.call(arguments, 1); jQuery(this).each(function () { var el = this, map = jQuery(el).data("awe-map"); if (options == undefined) options = JSON.parse(jQuery(el).attr("data-map")); var showMap = setInterval(function () { if (jQuery(el).width()) { clearInterval(showMap); switch (jQuery.type(options)) { case "string": if (jQuery.inArray(options, ["setOption", "destroy"]) > -1) { if (map) { switch (options) { case "setOption": var paramsType = jQuery.type(params[0]); if (paramsType === "string") map.setOption(params[0], params[1]); else if (paramsType === "object") map.setOptions(params[1]); else throw Error( "aweMapPlugin: setOption method only support string or object type for first parameter." ); break; case "destroy": map.destroy(); break; } } else throw Error( "aweMapPlugin: could not implement method '" + options + "' before initialize." ); } else throw Error("aweMapPlugin didn't have '" + options + "' method."); break; case "object": if (map) map.setOptions(options); else { map = new AweMapPlugin(el, options); jQuery(el).data("awe-map", map); } break; case undefined: if (!map) { map = new AweMapPlugin(el); jQuery(el).data("awe-map", map); } break; default: throw Error( "aweMapPlugin didn't support '" + jQuery.type(options) + "' type parameter." ); break; } } }, 500); }); return this; }; jQuery(document).ready(function ($) { $(".js-front-map").aweMap(); }); (function ($) { $.fn.mdShare = function () { if ($(".share-1").length > 0) { $(this).css( "background-color", $(this).children("a").attr("data-bg-color") ); $(this) .children("a") .css("color", $(this).children("a").attr("data-color")); $(this) .children("a") .hover( function () { $(this).css("color", $(this).attr("data-hover-color")); $(this) .parent(".module") .css("background-color", $(this).attr("data-bg-hover-color")); }, function () { $(this).css("color", $(this).attr("data-color")); $(this) .parent(".module") .css("background-color", $(this).attr("data-bg-color")); } ); } if ($(".share-2").length > 0) { $(this) .children("a") .find(".__name") .css({ color: $(this).children("a").attr("data-color"), "background-color": $(this).children("a").attr("data-bg-color"), }); $(this) .children("a") .find(".__icon") .css({ color: $(this).children("a").attr("data-hover-color"), "background-color": $(this).children("a").attr("data-bg-hover-color"), }); } }; $(document).ready(function () { $(".share-1 > .module").each(function () { $(this).mdShare(); }); $(".share-2 > .module").each(function () { $(this).mdShare(); }); }); })(jQuery); /*! Magnific Popup - v1.1.0 - 2016-02-20 * http://dimsemenov.com/plugins/magnific-popup/ * Copyright (c) 2016 Dmitry Semenov; */ !(function (a) { "function" == typeof define && define.amd ? define(["jquery"], a) : a( "object" == typeof exports ? require("jquery") : window.jQuery || window.Zepto ); })(function (a) { var b, c, d, e, f, g, h = "Close", i = "BeforeClose", j = "AfterClose", k = "BeforeAppend", l = "MarkupParse", m = "Open", n = "Change", o = "mfp", p = "." + o, q = "mfp-ready", r = "mfp-removing", s = "mfp-prevent-close", t = function () {}, u = !!window.jQuery, v = a(window), w = function (a, c) { b.ev.on(o + a + p, c); }, x = function (b, c, d, e) { var f = document.createElement("div"); return ( (f.className = "mfp-" + b), d && (f.innerHTML = d), e ? c && c.appendChild(f) : ((f = a(f)), c && f.appendTo(c)), f ); }, y = function (c, d) { b.ev.triggerHandler(o + c, d), b.st.callbacks && ((c = c.charAt(0).toLowerCase() + c.slice(1)), b.st.callbacks[c] && b.st.callbacks[c].apply(b, a.isArray(d) ? d : [d])); }, z = function (c) { return ( (c === g && b.currTemplate.closeBtn) || ((b.currTemplate.closeBtn = a( b.st.closeMarkup.replace("%title%", b.st.tClose) )), (g = c)), b.currTemplate.closeBtn ); }, A = function () { a.magnificPopup.instance || ((b = new t()), b.init(), (a.magnificPopup.instance = b)); }, B = function () { var a = document.createElement("p").style, b = ["ms", "O", "Moz", "Webkit"]; if (void 0 !== a.transition) return !0; for (; b.length; ) if (b.pop() + "Transition" in a) return !0; return !1; }; (t.prototype = { constructor: t, init: function () { var c = navigator.appVersion; (b.isLowIE = b.isIE8 = document.all && !document.addEventListener), (b.isAndroid = /android/gi.test(c)), (b.isIOS = /iphone|ipad|ipod/gi.test(c)), (b.supportsTransition = B()), (b.probablyMobile = b.isAndroid || b.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test( navigator.userAgent )), (d = a(document)), (b.popupsCache = {}); }, open: function (c) { var e; if (c.isObj === !1) { (b.items = c.items.toArray()), (b.index = 0); var g, h = c.items; for (e = 0; e < h.length; e++) if (((g = h[e]), g.parsed && (g = g.el[0]), g === c.el[0])) { b.index = e; break; } } else (b.items = a.isArray(c.items) ? c.items : [c.items]), (b.index = c.index || 0); if (b.isOpen) return void b.updateItemHTML(); (b.types = []), (f = ""), c.mainEl && c.mainEl.length ? (b.ev = c.mainEl.eq(0)) : (b.ev = d), c.key ? (b.popupsCache[c.key] || (b.popupsCache[c.key] = {}), (b.currTemplate = b.popupsCache[c.key])) : (b.currTemplate = {}), (b.st = a.extend(!0, {}, a.magnificPopup.defaults, c)), (b.fixedContentPos = "auto" === b.st.fixedContentPos ? !b.probablyMobile : b.st.fixedContentPos), b.st.modal && ((b.st.closeOnContentClick = !1), (b.st.closeOnBgClick = !1), (b.st.showCloseBtn = !1), (b.st.enableEscapeKey = !1)), b.bgOverlay || ((b.bgOverlay = x("bg").on("click" + p, function () { b.close(); })), (b.wrap = x("wrap") .attr("tabindex", -1) .on("click" + p, function (a) { b._checkIfClose(a.target) && b.close(); })), (b.container = x("container", b.wrap))), (b.contentContainer = x("content")), b.st.preloader && (b.preloader = x("preloader", b.container, b.st.tLoading)); var i = a.magnificPopup.modules; for (e = 0; e < i.length; e++) { var j = i[e]; (j = j.charAt(0).toUpperCase() + j.slice(1)), b["init" + j].call(b); } y("BeforeOpen"), b.st.showCloseBtn && (b.st.closeBtnInside ? (w(l, function (a, b, c, d) { c.close_replaceWith = z(d.type); }), (f += " mfp-close-btn-in")) : b.wrap.append(z())), b.st.alignTop && (f += " mfp-align-top"), b.fixedContentPos ? b.wrap.css({ overflow: b.st.overflowY, overflowX: "hidden", overflowY: b.st.overflowY, }) : b.wrap.css({ top: v.scrollTop(), position: "absolute" }), (b.st.fixedBgPos === !1 || ("auto" === b.st.fixedBgPos && !b.fixedContentPos)) && b.bgOverlay.css({ height: d.height(), position: "absolute" }), b.st.enableEscapeKey && d.on("keyup" + p, function (a) { 27 === a.keyCode && b.close(); }), v.on("resize" + p, function () { b.updateSize(); }), b.st.closeOnContentClick || (f += " mfp-auto-cursor"), f && b.wrap.addClass(f); var k = (b.wH = v.height()), n = {}; if (b.fixedContentPos && b._hasScrollBar(k)) { var o = b._getScrollbarSize(); o && (n.marginRight = o); } b.fixedContentPos && (b.isIE7 ? a("body, html").css("overflow", "hidden") : (n.overflow = "hidden")); var r = b.st.mainClass; return ( b.isIE7 && (r += " mfp-ie7"), r && b._addClassToMFP(r), b.updateItemHTML(), y("BuildControls"), a("html").css(n), b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo || a(document.body)), (b._lastFocusedEl = document.activeElement), setTimeout(function () { b.content ? (b._addClassToMFP(q), b._setFocus()) : b.bgOverlay.addClass(q), d.on("focusin" + p, b._onFocusIn); }, 16), (b.isOpen = !0), b.updateSize(k), y(m), c ); }, close: function () { b.isOpen && (y(i), (b.isOpen = !1), b.st.removalDelay && !b.isLowIE && b.supportsTransition ? (b._addClassToMFP(r), setTimeout(function () { b._close(); }, b.st.removalDelay)) : b._close()); }, _close: function () { y(h); var c = r + " " + q + " "; if ( (b.bgOverlay.detach(), b.wrap.detach(), b.container.empty(), b.st.mainClass && (c += b.st.mainClass + " "), b._removeClassFromMFP(c), b.fixedContentPos) ) { var e = { marginRight: "" }; b.isIE7 ? a("body, html").css("overflow", "") : (e.overflow = ""), a("html").css(e); } d.off("keyup" + p + " focusin" + p), b.ev.off(p), b.wrap.attr("class", "mfp-wrap").removeAttr("style"), b.bgOverlay.attr("class", "mfp-bg"), b.container.attr("class", "mfp-container"), !b.st.showCloseBtn || (b.st.closeBtnInside && b.currTemplate[b.currItem.type] !== !0) || (b.currTemplate.closeBtn && b.currTemplate.closeBtn.detach()), b.st.autoFocusLast && b._lastFocusedEl && a(b._lastFocusedEl).focus(), (b.currItem = null), (b.content = null), (b.currTemplate = null), (b.prevHeight = 0), y(j); }, updateSize: function (a) { if (b.isIOS) { var c = document.documentElement.clientWidth / window.innerWidth, d = window.innerHeight * c; b.wrap.css("height", d), (b.wH = d); } else b.wH = a || v.height(); b.fixedContentPos || b.wrap.css("height", b.wH), y("Resize"); }, updateItemHTML: function () { var c = b.items[b.index]; b.contentContainer.detach(), b.content && b.content.detach(), c.parsed || (c = b.parseEl(b.index)); var d = c.type; if ( (y("BeforeChange", [b.currItem ? b.currItem.type : "", d]), (b.currItem = c), !b.currTemplate[d]) ) { var f = b.st[d] ? b.st[d].markup : !1; y("FirstMarkupParse", f), f ? (b.currTemplate[d] = a(f)) : (b.currTemplate[d] = !0); } e && e !== c.type && b.container.removeClass("mfp-" + e + "-holder"); var g = b["get" + d.charAt(0).toUpperCase() + d.slice(1)]( c, b.currTemplate[d] ); b.appendContent(g, d), (c.preloaded = !0), y(n, c), (e = c.type), b.container.prepend(b.contentContainer), y("AfterChange"); }, appendContent: function (a, c) { (b.content = a), a ? b.st.showCloseBtn && b.st.closeBtnInside && b.currTemplate[c] === !0 ? b.content.find(".mfp-close").length || b.content.append(z()) : (b.content = a) : (b.content = ""), y(k), b.container.addClass("mfp-" + c + "-holder"), b.contentContainer.append(b.content); }, parseEl: function (c) { var d, e = b.items[c]; if ( (e.tagName ? (e = { el: a(e) }) : ((d = e.type), (e = { data: e, src: e.src })), e.el) ) { for (var f = b.types, g = 0; g < f.length; g++) if (e.el.hasClass("mfp-" + f[g])) { d = f[g]; break; } (e.src = e.el.attr("data-mfp-src")), e.src || (e.src = e.el.attr("href")); } return ( (e.type = d || b.st.type || "inline"), (e.index = c), (e.parsed = !0), (b.items[c] = e), y("ElementParse", e), b.items[c] ); }, addGroup: function (a, c) { var d = function (d) { (d.mfpEl = this), b._openClick(d, a, c); }; c || (c = {}); var e = "click.magnificPopup"; (c.mainEl = a), c.items ? ((c.isObj = !0), a.off(e).on(e, d)) : ((c.isObj = !1), c.delegate ? a.off(e).on(e, c.delegate, d) : ((c.items = a), a.off(e).on(e, d))); }, _openClick: function (c, d, e) { var f = void 0 !== e.midClick ? e.midClick : a.magnificPopup.defaults.midClick; if ( f || !(2 === c.which || c.ctrlKey || c.metaKey || c.altKey || c.shiftKey) ) { var g = void 0 !== e.disableOn ? e.disableOn : a.magnificPopup.defaults.disableOn; if (g) if (a.isFunction(g)) { if (!g.call(b)) return !0; } else if (v.width() < g) return !0; c.type && (c.preventDefault(), b.isOpen && c.stopPropagation()), (e.el = a(c.mfpEl)), e.delegate && (e.items = d.find(e.delegate)), b.open(e); } }, updateStatus: function (a, d) { if (b.preloader) { c !== a && b.container.removeClass("mfp-s-" + c), d || "loading" !== a || (d = b.st.tLoading); var e = { status: a, text: d }; y("UpdateStatus", e), (a = e.status), (d = e.text), b.preloader.html(d), b.preloader.find("a").on("click", function (a) { a.stopImmediatePropagation(); }), b.container.addClass("mfp-s-" + a), (c = a); } }, _checkIfClose: function (c) { if (!a(c).hasClass(s)) { var d = b.st.closeOnContentClick, e = b.st.closeOnBgClick; if (d && e) return !0; if ( !b.content || a(c).hasClass("mfp-close") || (b.preloader && c === b.preloader[0]) ) return !0; if (c === b.content[0] || a.contains(b.content[0], c)) { if (d) return !0; } else if (e && a.contains(document, c)) return !0; return !1; } }, _addClassToMFP: function (a) { b.bgOverlay.addClass(a), b.wrap.addClass(a); }, _removeClassFromMFP: function (a) { this.bgOverlay.removeClass(a), b.wrap.removeClass(a); }, _hasScrollBar: function (a) { return ( (b.isIE7 ? d.height() : document.body.scrollHeight) > (a || v.height()) ); }, _setFocus: function () { (b.st.focus ? b.content.find(b.st.focus).eq(0) : b.wrap).focus(); }, _onFocusIn: function (c) { return c.target === b.wrap[0] || a.contains(b.wrap[0], c.target) ? void 0 : (b._setFocus(), !1); }, _parseMarkup: function (b, c, d) { var e; d.data && (c = a.extend(d.data, c)), y(l, [b, c, d]), a.each(c, function (c, d) { if (void 0 === d || d === !1) return !0; if (((e = c.split("_")), e.length > 1)) { var f = b.find(p + "-" + e[0]); if (f.length > 0) { var g = e[1]; "replaceWith" === g ? f[0] !== d[0] && f.replaceWith(d) : "img" === g ? f.is("img") ? f.attr("src", d) : f.replaceWith( a("").attr("src", d).attr("class", f.attr("class")) ) : f.attr(e[1], d); } } else b.find(p + "-" + c).html(d); }); }, _getScrollbarSize: function () { if (void 0 === b.scrollbarSize) { var a = document.createElement("div"); (a.style.cssText = "width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;"), document.body.appendChild(a), (b.scrollbarSize = a.offsetWidth - a.clientWidth), document.body.removeChild(a); } return b.scrollbarSize; }, }), (a.magnificPopup = { instance: null, proto: t.prototype, modules: [], open: function (b, c) { return ( A(), (b = b ? a.extend(!0, {}, b) : {}), (b.isObj = !0), (b.index = c || 0), this.instance.open(b) ); }, close: function () { return a.magnificPopup.instance && a.magnificPopup.instance.close(); }, registerModule: function (b, c) { c.options && (a.magnificPopup.defaults[b] = c.options), a.extend(this.proto, c.proto), this.modules.push(b); }, defaults: { disableOn: 0, key: null, midClick: !1, mainClass: "", preloader: !0, focus: "", closeOnContentClick: !1, closeOnBgClick: !0, closeBtnInside: !0, showCloseBtn: !0, enableEscapeKey: !0, modal: !1, alignTop: !1, removalDelay: 0, prependTo: null, fixedContentPos: "auto", fixedBgPos: "auto", overflowY: "auto", closeMarkup: '', tClose: "Close (Esc)", tLoading: "Loading...", autoFocusLast: !0, }, }), (a.fn.magnificPopup = function (c) { A(); var d = a(this); if ("string" == typeof c) if ("open" === c) { var e, f = u ? d.data("magnificPopup") : d[0].magnificPopup, g = parseInt(arguments[1], 10) || 0; f.items ? (e = f.items[g]) : ((e = d), f.delegate && (e = e.find(f.delegate)), (e = e.eq(g))), b._openClick({ mfpEl: e }, d, f); } else b.isOpen && b[c].apply(b, Array.prototype.slice.call(arguments, 1)); else (c = a.extend(!0, {}, c)), u ? d.data("magnificPopup", c) : (d[0].magnificPopup = c), b.addGroup(d, c); return d; }); var C, D, E, F = "inline", G = function () { E && (D.after(E.addClass(C)).detach(), (E = null)); }; a.magnificPopup.registerModule(F, { options: { hiddenClass: "hide", markup: "", tNotFound: "Content not found", }, proto: { initInline: function () { b.types.push(F), w(h + "." + F, function () { G(); }); }, getInline: function (c, d) { if ((G(), c.src)) { var e = b.st.inline, f = a(c.src); if (f.length) { var g = f[0].parentNode; g && g.tagName && (D || ((C = e.hiddenClass), (D = x(C)), (C = "mfp-" + C)), (E = f.after(D).detach().removeClass(C))), b.updateStatus("ready"); } else b.updateStatus("error", e.tNotFound), (f = a("
")); return (c.inlineElement = f), f; } return b.updateStatus("ready"), b._parseMarkup(d, {}, c), d; }, }, }); var H, I = "ajax", J = function () { H && a(document.body).removeClass(H); }, K = function () { J(), b.req && b.req.abort(); }; a.magnificPopup.registerModule(I, { options: { settings: null, cursor: "mfp-ajax-cur", tError: 'The content could not be loaded.', }, proto: { initAjax: function () { b.types.push(I), (H = b.st.ajax.cursor), w(h + "." + I, K), w("BeforeChange." + I, K); }, getAjax: function (c) { H && a(document.body).addClass(H), b.updateStatus("loading"); var d = a.extend( { url: c.src, success: function (d, e, f) { var g = { data: d, xhr: f }; y("ParseAjax", g), b.appendContent(a(g.data), I), (c.finished = !0), J(), b._setFocus(), setTimeout(function () { b.wrap.addClass(q); }, 16), b.updateStatus("ready"), y("AjaxContentAdded"); }, error: function () { J(), (c.finished = c.loadError = !0), b.updateStatus( "error", b.st.ajax.tError.replace("%url%", c.src) ); }, }, b.st.ajax.settings ); return (b.req = a.ajax(d)), ""; }, }, }); var L, M = function (c) { if (c.data && void 0 !== c.data.title) return c.data.title; var d = b.st.image.titleSrc; if (d) { if (a.isFunction(d)) return d.call(b, c); if (c.el) return c.el.attr(d) || ""; } return ""; }; a.magnificPopup.registerModule("image", { options: { markup: '
', cursor: "mfp-zoom-out-cur", titleSrc: "title", verticalFit: !0, tError: 'The image could not be loaded.', }, proto: { initImage: function () { var c = b.st.image, d = ".image"; b.types.push("image"), w(m + d, function () { "image" === b.currItem.type && c.cursor && a(document.body).addClass(c.cursor); }), w(h + d, function () { c.cursor && a(document.body).removeClass(c.cursor), v.off("resize" + p); }), w("Resize" + d, b.resizeImage), b.isLowIE && w("AfterChange", b.resizeImage); }, resizeImage: function () { var a = b.currItem; if (a && a.img && b.st.image.verticalFit) { var c = 0; b.isLowIE && (c = parseInt(a.img.css("padding-top"), 10) + parseInt(a.img.css("padding-bottom"), 10)), a.img.css("max-height", b.wH - c); } }, _onImageHasSize: function (a) { a.img && ((a.hasSize = !0), L && clearInterval(L), (a.isCheckingImgSize = !1), y("ImageHasSize", a), a.imgHidden && (b.content && b.content.removeClass("mfp-loading"), (a.imgHidden = !1))); }, findImageSize: function (a) { var c = 0, d = a.img[0], e = function (f) { L && clearInterval(L), (L = setInterval(function () { return d.naturalWidth > 0 ? void b._onImageHasSize(a) : (c > 200 && clearInterval(L), c++, void (3 === c ? e(10) : 40 === c ? e(50) : 100 === c && e(500))); }, f)); }; e(1); }, getImage: function (c, d) { var e = 0, f = function () { c && (c.img[0].complete ? (c.img.off(".mfploader"), c === b.currItem && (b._onImageHasSize(c), b.updateStatus("ready")), (c.hasSize = !0), (c.loaded = !0), y("ImageLoadComplete")) : (e++, 200 > e ? setTimeout(f, 100) : g())); }, g = function () { c && (c.img.off(".mfploader"), c === b.currItem && (b._onImageHasSize(c), b.updateStatus("error", h.tError.replace("%url%", c.src))), (c.hasSize = !0), (c.loaded = !0), (c.loadError = !0)); }, h = b.st.image, i = d.find(".mfp-img"); if (i.length) { var j = document.createElement("img"); (j.className = "mfp-img"), c.el && c.el.find("img").length && (j.alt = c.el.find("img").attr("alt")), (c.img = a(j).on("load.mfploader", f).on("error.mfploader", g)), (j.src = c.src), i.is("img") && (c.img = c.img.clone()), (j = c.img[0]), j.naturalWidth > 0 ? (c.hasSize = !0) : j.width || (c.hasSize = !1); } return ( b._parseMarkup(d, { title: M(c), img_replaceWith: c.img }, c), b.resizeImage(), c.hasSize ? (L && clearInterval(L), c.loadError ? (d.addClass("mfp-loading"), b.updateStatus("error", h.tError.replace("%url%", c.src))) : (d.removeClass("mfp-loading"), b.updateStatus("ready")), d) : (b.updateStatus("loading"), (c.loading = !0), c.hasSize || ((c.imgHidden = !0), d.addClass("mfp-loading"), b.findImageSize(c)), d) ); }, }, }); var N, O = function () { return ( void 0 === N && (N = void 0 !== document.createElement("p").style.MozTransform), N ); }; a.magnificPopup.registerModule("zoom", { options: { enabled: !1, easing: "ease-in-out", duration: 300, opener: function (a) { return a.is("img") ? a : a.find("img"); }, }, proto: { initZoom: function () { var a, c = b.st.zoom, d = ".zoom"; if (c.enabled && b.supportsTransition) { var e, f, g = c.duration, j = function (a) { var b = a .clone() .removeAttr("style") .removeAttr("class") .addClass("mfp-animated-image"), d = "all " + c.duration / 1e3 + "s " + c.easing, e = { position: "fixed", zIndex: 9999, left: 0, top: 0, "-webkit-backface-visibility": "hidden", }, f = "transition"; return ( (e["-webkit-" + f] = e["-moz-" + f] = e["-o-" + f] = e[f] = d), b.css(e), b ); }, k = function () { b.content.css("visibility", "visible"); }; w("BuildControls" + d, function () { if (b._allowZoom()) { if ( (clearTimeout(e), b.content.css("visibility", "hidden"), (a = b._getItemToZoom()), !a) ) return void k(); (f = j(a)), f.css(b._getOffset()), b.wrap.append(f), (e = setTimeout(function () { f.css(b._getOffset(!0)), (e = setTimeout(function () { k(), setTimeout(function () { f.remove(), (a = f = null), y("ZoomAnimationEnded"); }, 16); }, g)); }, 16)); } }), w(i + d, function () { if (b._allowZoom()) { if ((clearTimeout(e), (b.st.removalDelay = g), !a)) { if (((a = b._getItemToZoom()), !a)) return; f = j(a); } f.css(b._getOffset(!0)), b.wrap.append(f), b.content.css("visibility", "hidden"), setTimeout(function () { f.css(b._getOffset()); }, 16); } }), w(h + d, function () { b._allowZoom() && (k(), f && f.remove(), (a = null)); }); } }, _allowZoom: function () { return "image" === b.currItem.type; }, _getItemToZoom: function () { return b.currItem.hasSize ? b.currItem.img : !1; }, _getOffset: function (c) { var d; d = c ? b.currItem.img : b.st.zoom.opener(b.currItem.el || b.currItem); var e = d.offset(), f = parseInt(d.css("padding-top"), 10), g = parseInt(d.css("padding-bottom"), 10); e.top -= a(window).scrollTop() - f; var h = { width: d.width(), height: (u ? d.innerHeight() : d[0].offsetHeight) - g - f, }; return ( O() ? (h["-moz-transform"] = h.transform = "translate(" + e.left + "px," + e.top + "px)") : ((h.left = e.left), (h.top = e.top)), h ); }, }, }); var P = "iframe", Q = "//about:blank", R = function (a) { if (b.currTemplate[P]) { var c = b.currTemplate[P].find("iframe"); c.length && (a || (c[0].src = Q), b.isIE8 && c.css("display", a ? "block" : "none")); } }; a.magnificPopup.registerModule(P, { options: { markup: '
', srcAction: "iframe_src", patterns: { youtube: { index: "youtube.com", id: "v=", src: "//www.youtube.com/embed/%id%?autoplay=1", }, vimeo: { index: "vimeo.com/", id: "/", src: "//player.vimeo.com/video/%id%?autoplay=1", }, gmaps: { index: "//maps.google.", src: "%id%&output=embed" }, }, }, proto: { initIframe: function () { b.types.push(P), w("BeforeChange", function (a, b, c) { b !== c && (b === P ? R() : c === P && R(!0)); }), w(h + "." + P, function () { R(); }); }, getIframe: function (c, d) { var e = c.src, f = b.st.iframe; a.each(f.patterns, function () { return e.indexOf(this.index) > -1 ? (this.id && (e = "string" == typeof this.id ? e.substr( e.lastIndexOf(this.id) + this.id.length, e.length ) : this.id.call(this, e)), (e = this.src.replace("%id%", e)), !1) : void 0; }); var g = {}; return ( f.srcAction && (g[f.srcAction] = e), b._parseMarkup(d, g, c), b.updateStatus("ready"), d ); }, }, }); var S = function (a) { var c = b.items.length; return a > c - 1 ? a - c : 0 > a ? c + a : a; }, T = function (a, b, c) { return a.replace(/%curr%/gi, b + 1).replace(/%total%/gi, c); }; a.magnificPopup.registerModule("gallery", { options: { enabled: !1, arrowMarkup: '', preload: [0, 2], navigateByImgClick: !0, arrows: !0, tPrev: "Previous (Left arrow key)", tNext: "Next (Right arrow key)", tCounter: "%curr% of %total%", }, proto: { initGallery: function () { var c = b.st.gallery, e = ".mfp-gallery"; return ( (b.direction = !0), c && c.enabled ? ((f += " mfp-gallery"), w(m + e, function () { c.navigateByImgClick && b.wrap.on("click" + e, ".mfp-img", function () { return b.items.length > 1 ? (b.next(), !1) : void 0; }), d.on("keydown" + e, function (a) { 37 === a.keyCode ? b.prev() : 39 === a.keyCode && b.next(); }); }), w("UpdateStatus" + e, function (a, c) { c.text && (c.text = T(c.text, b.currItem.index, b.items.length)); }), w(l + e, function (a, d, e, f) { var g = b.items.length; e.counter = g > 1 ? T(c.tCounter, f.index, g) : ""; }), w("BuildControls" + e, function () { if (b.items.length > 1 && c.arrows && !b.arrowLeft) { var d = c.arrowMarkup, e = (b.arrowLeft = a( d.replace(/%title%/gi, c.tPrev).replace(/%dir%/gi, "left") ).addClass(s)), f = (b.arrowRight = a( d .replace(/%title%/gi, c.tNext) .replace(/%dir%/gi, "right") ).addClass(s)); e.click(function () { b.prev(); }), f.click(function () { b.next(); }), b.container.append(e.add(f)); } }), w(n + e, function () { b._preloadTimeout && clearTimeout(b._preloadTimeout), (b._preloadTimeout = setTimeout(function () { b.preloadNearbyImages(), (b._preloadTimeout = null); }, 16)); }), void w(h + e, function () { d.off(e), b.wrap.off("click" + e), (b.arrowRight = b.arrowLeft = null); })) : !1 ); }, next: function () { (b.direction = !0), (b.index = S(b.index + 1)), b.updateItemHTML(); }, prev: function () { (b.direction = !1), (b.index = S(b.index - 1)), b.updateItemHTML(); }, goTo: function (a) { (b.direction = a >= b.index), (b.index = a), b.updateItemHTML(); }, preloadNearbyImages: function () { var a, c = b.st.gallery.preload, d = Math.min(c[0], b.items.length), e = Math.min(c[1], b.items.length); for (a = 1; a <= (b.direction ? e : d); a++) b._preloadItem(b.index + a); for (a = 1; a <= (b.direction ? d : e); a++) b._preloadItem(b.index - a); }, _preloadItem: function (c) { if (((c = S(c)), !b.items[c].preloaded)) { var d = b.items[c]; d.parsed || (d = b.parseEl(c)), y("LazyLoad", d), "image" === d.type && (d.img = a('') .on("load.mfploader", function () { d.hasSize = !0; }) .on("error.mfploader", function () { (d.hasSize = !0), (d.loadError = !0), y("LazyLoadError", d); }) .attr("src", d.src)), (d.preloaded = !0); } }, }, }); var U = "retina"; a.magnificPopup.registerModule(U, { options: { replaceSrc: function (a) { return a.src.replace(/\.\w+$/, function (a) { return "@2x" + a; }); }, ratio: 1, }, proto: { initRetina: function () { if (window.devicePixelRatio > 1) { var a = b.st.retina, c = a.ratio; (c = isNaN(c) ? c() : c), c > 1 && (w("ImageHasSize." + U, function (a, b) { b.img.css({ "max-width": b.img[0].naturalWidth / c, width: "100%", }); }), w("ElementParse." + U, function (b, d) { d.src = a.replaceSrc(d, c); })); } }, }, }), A(); }); /* * Copyright (C) 2009 Joel Sutherland * Licenced under the MIT license * http://www.newmediacampaigns.com/page/jquery-flickr-plugin * * Available tags for templates: * title, link, date_taken, description, published, author, author_id, tags, image* */ (function ($) { $.fn.jflickrfeed = function (settings, callback) { settings = $.extend( true, { flickrbase: "http://api.flickr.com/services/feeds/", feedapi: "photos_public.gne", limit: 20, qstrings: { lang: "en-us", format: "json", jsoncallback: "?", }, cleanDescription: true, useTemplate: true, itemTemplate: "", itemCallback: function () {}, }, settings ); var url = settings.flickrbase + settings.feedapi + "?"; var first = true; for (var key in settings.qstrings) { if (!first) url += "&"; url += key + "=" + settings.qstrings[key]; first = false; } return $(this).each(function () { var $container = $(this); var container = this; $.getJSON(url, function (data) { $.each(data.items, function (i, item) { if (i < settings.limit) { // Clean out the Flickr Description if (settings.cleanDescription) { var regex = /

(.*?)<\/p>/g; var input = item.description; if (regex.test(input)) { item.description = input.match(regex)[2]; if (item.description != undefined) item.description = item.description .replace("

", "") .replace("

", ""); } } // Add Image Sizes // http://www.flickr.com/services/api/misc.urls.html item["image_s"] = item.media.m.replace("_m", "_s"); item["image_q"] = item.media.m.replace("_m", "_q"); item["image_m"] = item.media.m.replace("_m", "_m"); item["image"] = item.media.m.replace("_m", ""); item["image_b"] = item.media.m.replace("_m", "_b"); item["image_z"] = item.media.m.replace("_m", "_z"); item["image_l"] = item.media.m.replace("_m", "_l"); item["image_o"] = item.media.m.replace("_m", "_o"); delete item.media; // Use Template if (settings.useTemplate) { var template = settings.itemTemplate; for (var key in item) { var rgx = new RegExp("{{" + key + "}}", "g"); template = template.replace(rgx, item[key]); } $container.append(template); } //itemCallback settings.itemCallback.call(container, item); } }); if ($.isFunction(callback)) { callback.call(container, data); } }); }); }; })(jQuery); (function ($) { function initFlickrResponsive($selector, options) { var window_width = $(window).width(), prefixClass = "type-column-"; $selector .removeClass(prefixClass + options.col_lg) .removeClass(prefixClass + options.col_md) .removeClass(prefixClass + options.col_sm) .removeClass(prefixClass + options.col_xs); if (window_width >= 1200) { $selector.addClass(prefixClass + options.col_lg); } else if (window_width <= 1199 && window_width > 991) { $selector.addClass(prefixClass + options.col_md); } else if (window_width <= 991 && window_width > 767) { $selector.addClass(prefixClass + options.col_sm); } else if (window_width <= 767) { $selector.addClass(prefixClass + options.col_xs); } } $.fn.aweFlickr = function () { var default_settings = { flickrbase: "https://api.flickr.com/services/feeds/", feedapi: "photos_public.gne", limit: 12, qstrings: "", itemTemplate: '
  • ' + '' + '{{title}}' + "" + "
  • ", enableLightbox: false, }; this.each(function () { var $item = $(this); if ($item.attr("data-flickr") != undefined) { var settings = JSON.parse($item.attr("data-flickr")); settings = $.extend(default_settings, settings); $item.jflickrfeed(settings, function () { if (settings.enableLightbox) { $item.find("a").magnificPopup({ type: "image", removalDelay: 300, mainClass: "mfp-fade", gallery: { enabled: true, preload: [0, 2], navigateByImgClick: true, }, zoom: { enabled: true, }, }); } }); // responsive if (settings.enableResponsive) { var $parentFlickr = $item.parent(); initFlickrResponsive($parentFlickr, settings); $(window).resize(function () { initFlickrResponsive($parentFlickr, settings); }); } } }); return this; }; $(document).ready(function () { $(".js-jflickr").aweFlickr(); }); })(jQuery); /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, Drupal) { var states = { postponed: [], }; Drupal.states = states; function invert(a, invertState) { return invertState && typeof a !== "undefined" ? !a : a; } function _compare2(a, b) { if (a === b) { return typeof a === "undefined" ? a : true; } return typeof a === "undefined" || typeof b === "undefined"; } function ternary(a, b) { if (typeof a === "undefined") { return b; } if (typeof b === "undefined") { return a; } return a && b; } Drupal.behaviors.states = { attach: function attach(context, settings) { var $states = $(context).find("[data-drupal-states]"); var il = $states.length; var _loop = function _loop(i) { var config = JSON.parse($states[i].getAttribute("data-drupal-states")); Object.keys(config || {}).forEach(function (state) { new states.Dependent({ element: $($states[i]), state: states.State.sanitize(state), constraints: config[state], }); }); }; for (var i = 0; i < il; i++) { _loop(i); } while (states.postponed.length) { states.postponed.shift()(); } }, }; states.Dependent = function (args) { var _this = this; $.extend(this, { values: {}, oldValue: null }, args); this.dependees = this.getDependees(); Object.keys(this.dependees || {}).forEach(function (selector) { _this.initializeDependee(selector, _this.dependees[selector]); }); }; states.Dependent.comparisons = { RegExp: function RegExp(reference, value) { return reference.test(value); }, Function: function Function(reference, value) { return reference(value); }, Number: function Number(reference, value) { return typeof value === "string" ? _compare2(reference.toString(), value) : _compare2(reference, value); }, }; states.Dependent.prototype = { initializeDependee: function initializeDependee(selector, dependeeStates) { var _this2 = this; this.values[selector] = {}; Object.keys(dependeeStates).forEach(function (i) { var state = dependeeStates[i]; if ($.inArray(state, dependeeStates) === -1) { return; } state = states.State.sanitize(state); _this2.values[selector][state.name] = null; $(selector).on( "state:" + state, { selector: selector, state: state }, function (e) { _this2.update(e.data.selector, e.data.state, e.value); } ); new states.Trigger({ selector: selector, state: state }); }); }, compare: function compare(reference, selector, state) { var value = this.values[selector][state.name]; if (reference.constructor.name in states.Dependent.comparisons) { return states.Dependent.comparisons[reference.constructor.name]( reference, value ); } return _compare2(reference, value); }, update: function update(selector, state, value) { if (value !== this.values[selector][state.name]) { this.values[selector][state.name] = value; this.reevaluate(); } }, reevaluate: function reevaluate() { var value = this.verifyConstraints(this.constraints); if (value !== this.oldValue) { this.oldValue = value; value = invert(value, this.state.invert); this.element.trigger({ type: "state:" + this.state, value: value, trigger: true, }); } }, verifyConstraints: function verifyConstraints(constraints, selector) { var result = void 0; if ($.isArray(constraints)) { var hasXor = $.inArray("xor", constraints) === -1; var len = constraints.length; for (var i = 0; i < len; i++) { if (constraints[i] !== "xor") { var constraint = this.checkConstraints(constraints[i], selector, i); if (constraint && (hasXor || result)) { return hasXor; } result = result || constraint; } } } else if ($.isPlainObject(constraints)) { for (var n in constraints) { if (constraints.hasOwnProperty(n)) { result = ternary( result, this.checkConstraints(constraints[n], selector, n) ); if (result === false) { return false; } } } } return result; }, checkConstraints: function checkConstraints(value, selector, state) { if (typeof state !== "string" || /[0-9]/.test(state[0])) { state = null; } else if (typeof selector === "undefined") { selector = state; state = null; } if (state !== null) { state = states.State.sanitize(state); return invert(this.compare(value, selector, state), state.invert); } return this.verifyConstraints(value, selector); }, getDependees: function getDependees() { var cache = {}; var _compare = this.compare; this.compare = function (reference, selector, state) { (cache[selector] || (cache[selector] = [])).push(state.name); }; this.verifyConstraints(this.constraints); this.compare = _compare; return cache; }, }; states.Trigger = function (args) { $.extend(this, args); if (this.state in states.Trigger.states) { this.element = $(this.selector); if (!this.element.data("trigger:" + this.state)) { this.initialize(); } } }; states.Trigger.prototype = { initialize: function initialize() { var _this3 = this; var trigger = states.Trigger.states[this.state]; if (typeof trigger === "function") { trigger.call(window, this.element); } else { Object.keys(trigger || {}).forEach(function (event) { _this3.defaultTrigger(event, trigger[event]); }); } this.element.data("trigger:" + this.state, true); }, defaultTrigger: function defaultTrigger(event, valueFn) { var oldValue = valueFn.call(this.element); this.element.on( event, $.proxy(function (e) { var value = valueFn.call(this.element, e); if (oldValue !== value) { this.element.trigger({ type: "state:" + this.state, value: value, oldValue: oldValue, }); oldValue = value; } }, this) ); states.postponed.push( $.proxy(function () { this.element.trigger({ type: "state:" + this.state, value: oldValue, oldValue: null, }); }, this) ); }, }; states.Trigger.states = { empty: { keyup: function keyup() { return this.val() === ""; }, }, checked: { change: function change() { var checked = false; this.each(function () { checked = $(this).prop("checked"); return !checked; }); return checked; }, }, value: { keyup: function keyup() { if (this.length > 1) { return this.filter(":checked").val() || false; } return this.val(); }, change: function change() { if (this.length > 1) { return this.filter(":checked").val() || false; } return this.val(); }, }, collapsed: { collapsed: function collapsed(e) { return typeof e !== "undefined" && "value" in e ? e.value : !this.is("[open]"); }, }, }; states.State = function (state) { this.pristine = state; this.name = state; var process = true; do { while (this.name.charAt(0) === "!") { this.name = this.name.substring(1); this.invert = !this.invert; } if (this.name in states.State.aliases) { this.name = states.State.aliases[this.name]; } else { process = false; } } while (process); }; states.State.sanitize = function (state) { if (state instanceof states.State) { return state; } return new states.State(state); }; states.State.aliases = { enabled: "!disabled", invisible: "!visible", invalid: "!valid", untouched: "!touched", optional: "!required", filled: "!empty", unchecked: "!checked", irrelevant: "!relevant", expanded: "!collapsed", open: "!collapsed", closed: "collapsed", readwrite: "!readonly", }; states.State.prototype = { invert: false, toString: function toString() { return this.name; }, }; var $document = $(document); $document.on("state:disabled", function (e) { if (e.trigger) { $(e.target) .prop("disabled", e.value) .closest(".js-form-item, .js-form-submit, .js-form-wrapper") .toggleClass("form-disabled", e.value) .find("select, input, textarea") .prop("disabled", e.value); } }); $document.on("state:required", function (e) { if (e.trigger) { if (e.value) { var label = "label" + (e.target.id ? "[for=" + e.target.id + "]" : ""); var $label = $(e.target) .attr({ required: "required", "aria-required": "true" }) .closest(".js-form-item, .js-form-wrapper") .find(label); if (!$label.hasClass("js-form-required").length) { $label.addClass("js-form-required form-required"); } } else { $(e.target) .removeAttr("required aria-required") .closest(".js-form-item, .js-form-wrapper") .find("label.js-form-required") .removeClass("js-form-required form-required"); } } }); $document.on("state:visible", function (e) { if (e.trigger) { $(e.target) .closest(".js-form-item, .js-form-submit, .js-form-wrapper") .toggle(e.value); } }); $document.on("state:checked", function (e) { if (e.trigger) { $(e.target).prop("checked", e.value); } }); $document.on("state:collapsed", function (e) { if (e.trigger) { if ($(e.target).is("[open]") === e.value) { $(e.target).find("> summary").trigger("click"); } } }); })(jQuery, Drupal); /** * @file * JavaScript behaviors for custom webform #states. */ (function ($, Drupal) { "use strict"; Drupal.webform = Drupal.webform || {}; Drupal.webform.states = Drupal.webform.states || {}; Drupal.webform.states.slideDown = Drupal.webform.states.slideDown || {}; Drupal.webform.states.slideDown.duration = "slow"; Drupal.webform.states.slideUp = Drupal.webform.states.slideUp || {}; Drupal.webform.states.slideUp.duration = "fast"; /** * Check if an element has a specified data attribute. * * @param {string} data * The data attribute name. * * @return {boolean} * TRUE if an element has a specified data attribute. */ $.fn.hasData = function (data) { return typeof this.data(data) !== "undefined"; }; /** * Check if element is within the webform or not. * * @return {boolean} * TRUE if element is within the webform. */ $.fn.isWebform = function () { return $(this).closest('form[id^="webform"]').length ? true : false; }; // The change event is triggered by cut-n-paste and select menus. // Issue #2445271: #states element empty check not triggered on mouse // based paste. // @see https://www.drupal.org/node/2445271 Drupal.states.Trigger.states.empty.change = function change() { return this.val() === ""; }; // Apply solution included in #1962800 patch. // Issue #1962800: Form #states not working with literal integers as // values in IE11. // @see https://www.drupal.org/project/drupal/issues/1962800 // @see https://www.drupal.org/files/issues/core-states-not-working-with-integers-ie11_1962800_46.patch // // This issue causes pattern, less than, and greater than support to break. // @see https://www.drupal.org/project/webform/issues/2981724 var states = Drupal.states; Drupal.states.Dependent.prototype.compare = function compare( reference, selector, state ) { var value = this.values[selector][state.name]; var name = reference.constructor.name; if (!name) { name = $.type(reference); name = name.charAt(0).toUpperCase() + name.slice(1); } if (name in states.Dependent.comparisons) { return states.Dependent.comparisons[name](reference, value); } if (reference.constructor.name in states.Dependent.comparisons) { return states.Dependent.comparisons[reference.constructor.name]( reference, value ); } return _compare2(reference, value); }; function _compare2(a, b) { if (a === b) { return typeof a === "undefined" ? a : true; } return typeof a === "undefined" || typeof b === "undefined"; } // Adds pattern, less than, and greater than support to #state API. // @see http://drupalsun.com/julia-evans/2012/03/09/extending-form-api-states-regular-expressions Drupal.states.Dependent.comparisons.Object = function (reference, value) { if ("pattern" in reference) { return new RegExp(reference["pattern"]).test(value); } else if ("!pattern" in reference) { return !new RegExp(reference["!pattern"]).test(value); } else if ("less" in reference) { return value !== "" && parseFloat(reference["less"]) > parseFloat(value); } else if ("greater" in reference) { return ( value !== "" && parseFloat(reference["greater"]) < parseFloat(value) ); } else { return reference.indexOf(value) !== false; } }; var $document = $(document); $document.on("state:required", function (e) { if (e.trigger && $(e.target).isWebform()) { var $target = $(e.target); // Fix #required file upload. // @see Issue #2860529: Conditional required File upload field don't work. if (e.value) { $target .find('input[type="file"]') .attr({ required: "required", "aria-required": "true" }); } else { $target.find('input[type="file"]').removeAttr("required aria-required"); } // Fix required label for checkboxes and radios. // @see Issue #2938414: Checkboxes don't support #states required // @see Issue #2731991: Setting required on radios marks all options required. // @see Issue #2856315: Conditional Logic - Requiring Radios in a Fieldset. // Fix #required for fieldsets. // @see Issue #2977569: Hidden fieldsets that become visible with conditional logic cannot be made required. if ( $target.is( ".js-webform-type-radios, .js-webform-type-checkboxes, fieldset" ) ) { if (e.value) { $target .find("legend span:not(.visually-hidden)") .addClass("js-form-required form-required"); } else { $target .find("legend span:not(.visually-hidden)") .removeClass("js-form-required form-required"); } } // Fix #required for radios. // @see Issue #2856795: If radio buttons are required but not filled form is nevertheless submitted. if ( $target.is( ".js-webform-type-radios, .js-form-type-webform-radios-other" ) ) { if (e.value) { $target .find('input[type="radio"]') .attr({ required: "required", "aria-required": "true" }); } else { $target .find('input[type="radio"]') .removeAttr("required aria-required"); } } // Fix #required for checkboxes. // @see Issue #2938414: Checkboxes don't support #states required. // @see checkboxRequiredhandler if ( $target.is( ".js-webform-type-checkboxes, .js-form-type-webform-checkboxes-other" ) ) { var $checkboxes = $target.find('input[type="checkbox"]'); if (e.value) { // Bind the event handler and add custom HTML5 required validation // to all checkboxes. $checkboxes.bind("click", checkboxRequiredhandler); if (!$checkboxes.is(":checked")) { $checkboxes.attr({ required: "required", "aria-required": "true" }); } } else { // Remove custom HTML5 required validation from all checkboxes // and unbind the event handler. $checkboxes .removeAttr("required aria-required") .unbind("click", checkboxRequiredhandler); } } // Issue #2986017: Fieldsets shouldn't have required attribute. if ($target.is("fieldset")) { $target.removeAttr("required aria-required"); } } }); $document.on("state:readonly", function (e) { if (e.trigger && $(e.target).isWebform()) { $(e.target) .prop("readonly", e.value) .closest(".js-form-item, .js-form-wrapper") .toggleClass("webform-readonly", e.value) .find("input, textarea") .prop("readonly", e.value); } }); $document.on("state:visible state:visible-slide", function (e) { if (e.trigger && $(e.target).isWebform()) { if (e.value) { $(":input", e.target) .addBack() .each(function () { restoreValueAndRequired(this); triggerEventHandlers(this); }); } else { // @see https://www.sitepoint.com/jquery-function-clear-form-data/ $(":input", e.target) .addBack() .each(function () { backupValueAndRequired(this); clearValueAndRequired(this); triggerEventHandlers(this); }); } } }); $document.bind("state:visible-slide", function (e) { if (e.trigger && $(e.target).isWebform()) { var effect = e.value ? "slideDown" : "slideUp"; var duration = Drupal.webform.states[effect].duration; $(e.target) .closest(".js-form-item, .js-form-submit, .js-form-wrapper") [effect](duration); } }); Drupal.states.State.aliases["invisible-slide"] = "!visible-slide"; $document.on("state:disabled", function (e) { if (e.trigger && $(e.target).isWebform()) { // Make sure disabled property is set before triggering webform:disabled. // Copied from: core/misc/states.js $(e.target) .prop("disabled", e.value) .closest(".js-form-item, .js-form-submit, .js-form-wrapper") .toggleClass("form-disabled", e.value) .find("select, input, textarea") .prop("disabled", e.value); // Trigger webform:disabled. $(e.target) .trigger("webform:disabled") .find("select, input, textarea") .trigger("webform:disabled"); } }); /** * Trigger custom HTML5 multiple checkboxes validation. * * @see https://stackoverflow.com/a/37825072/145846 */ function checkboxRequiredhandler() { var $checkboxes = $(this) .closest( ".js-webform-type-checkboxes, .js-form-type-webform-checkboxes-other" ) .find('input[type="checkbox"]'); if ($checkboxes.is(":checked")) { $checkboxes.removeAttr("required aria-required"); } else { $checkboxes.attr({ required: "required", "aria-required": "true" }); } } /** * Trigger an input's event handlers. * * @param {element} input * An input. */ function triggerEventHandlers(input) { var $input = $(input); var type = input.type; var tag = input.tagName.toLowerCase(); // Add 'webform.states' as extra parameter to event handlers. // @see Drupal.behaviors.webformUnsaved var extraParameters = ["webform.states"]; if (type === "checkbox" || type === "radio") { $input .trigger("change", extraParameters) .trigger("blur", extraParameters); } else if (tag === "select") { $input .trigger("change", extraParameters) .trigger("blur", extraParameters); } else if (type !== "submit" && type !== "button" && type !== "file") { $input .trigger("input", extraParameters) .trigger("change", extraParameters) .trigger("keydown", extraParameters) .trigger("keyup", extraParameters) .trigger("blur", extraParameters); } } /** * Backup an input's current value and required attribute * * @param {element} input * An input. */ function backupValueAndRequired(input) { var $input = $(input); var type = input.type; var tag = input.tagName.toLowerCase(); // Normalize case. // Backup required. if ($input.prop("required") && !$input.hasData("webform-required")) { $input.data("webform-required", true); } // Backup value. if (!$input.hasData("webform-value")) { if (type === "checkbox" || type === "radio") { $input.data("webform-value", $input.prop("checked")); } else if (tag === "select") { var values = []; $input.find("option:selected").each(function (i, option) { values[i] = option.value; }); $input.data("webform-value", values); } else if (type !== "submit" && type !== "button") { $input.data("webform-value", input.value); } } } /** * Restore an input's value and required attribute. * * @param {element} input * An input. */ function restoreValueAndRequired(input) { var $input = $(input); // Restore value. var value = $input.data("webform-value"); if (typeof value !== "undefined") { var type = input.type; var tag = input.tagName.toLowerCase(); // Normalize case. if (type === "checkbox" || type === "radio") { $input.prop("checked", value); } else if (tag === "select") { $.each(value, function (i, option_value) { $input .find("option[value='" + option_value + "']") .prop("selected", true); }); } else if (type !== "submit" && type !== "button") { input.value = value; } $input.removeData("webform-value"); } // Restore required. var required = $input.data("webform-required"); if (typeof required !== "undefined") { if (required) { $input.prop("required", true); } $input.removeData("webform-required"); } } /** * Clear an input's value and required attributes. * * @param {element} input * An input. */ function clearValueAndRequired(input) { var $input = $(input); // Check for #states no clear attribute. // @see https://css-tricks.com/snippets/jquery/make-an-jquery-hasattr/ if ($input.closest("[data-webform-states-no-clear]").length) { return; } // Clear value. var type = input.type; var tag = input.tagName.toLowerCase(); // Normalize case. if (type === "checkbox" || type === "radio") { $input.prop("checked", false); } else if (tag === "select") { if ($input.find('option[value=""]').length) { $input.val(""); } else { input.selectedIndex = -1; } } else if (type !== "submit" && type !== "button") { input.value = type === "color" ? "#000000" : ""; } // Clear required. $input.prop("required", false); } })(jQuery, Drupal); /** * @file * JavaScript behaviors for webforms. */ (function ($, Drupal) { "use strict"; /** * Autofocus first input. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches the behavior for the webform autofocusing. */ Drupal.behaviors.webformAutofocus = { attach: function (context) { $(context) .find( ".webform-submission-form.js-webform-autofocus :input:visible:enabled:first" ) .focus(); }, }; /** * Prevent webform autosubmit on wizard pages. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches the behavior for disabling webform autosubmit. * Wizard pages need to be progressed with the Previous or Next buttons, not by pressing Enter. */ Drupal.behaviors.webformDisableAutoSubmit = { attach: function (context) { // @see http://stackoverflow.com/questions/11235622/jquery-disable-form-submit-on-enter $(context) .find(".webform-submission-form.js-webform-disable-autosubmit input") .not(":button, :submit, :reset, :image, :file") .once("webform-disable-autosubmit") .on("keyup keypress", function (e) { var keyCode = e.keyCode || e.which; if (keyCode === 13) { e.preventDefault(); return false; } }); }, }; /** * Skip client-side validation when submit button is pressed. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches the behavior for the skipping client-side validation. */ Drupal.behaviors.webformSubmitNoValidate = { attach: function (context) { $(context) .find(":submit.js-webform-novalidate") .once("webform-novalidate") .on("click", function () { $(this.form).attr("novalidate", "novalidate"); }); }, }; /** * Attach behaviors to trigger submit button from input onchange. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches form trigger submit events. */ Drupal.behaviors.webformSubmitTrigger = { attach: function (context) { $("[data-webform-trigger-submit]") .once("webform-trigger-submit") .on("change", function () { var submit = $(this).attr("data-webform-trigger-submit"); $(submit).mousedown(); }); }, }; /** * Custom required error message. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attaches the behavior for the webform custom required error message. * * @see http://stackoverflow.com/questions/5272433/html5-form-required-attribute-set-custom-validation-message */ Drupal.behaviors.webformRequiredError = { attach: function (context) { $(context) .find(":input[data-webform-required-error]") .once("webform-required-error") .on("invalid", function () { this.setCustomValidity(""); if (!this.valid) { this.setCustomValidity($(this).attr("data-webform-required-error")); } }) .on("input, change", function () { // Find all related elements by name and reset custom validity. // This specifically applies to required radios and checkboxes. var name = $(this).attr("name"); $(this.form) .find(':input[name="' + name + '"]') .each(function () { this.setCustomValidity(""); }); }); }, }; // When #state:required is triggered we need to reset the target elements // custom validity. $(document).on("state:required", function (e) { $(e.target) .filter("[data-webform-required-error]") .each(function () { this.setCustomValidity(""); }); }); if (window.imceInput) { window.imceInput.processUrlInput = function (i, el) { var button = imceInput.createUrlButton( el.id, el.getAttribute("data-imce-type") ); el.parentNode.insertAfter(button, el); }; } })(jQuery, Drupal); /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function (Drupal, debounce) { var liveElement = void 0; var announcements = []; Drupal.behaviors.drupalAnnounce = { attach: function attach(context) { if (!liveElement) { liveElement = document.createElement("div"); liveElement.id = "drupal-live-announce"; liveElement.className = "visually-hidden"; liveElement.setAttribute("aria-live", "polite"); liveElement.setAttribute("aria-busy", "false"); document.body.appendChild(liveElement); } }, }; function announce() { var text = []; var priority = "polite"; var announcement = void 0; var il = announcements.length; for (var i = 0; i < il; i++) { announcement = announcements.pop(); text.unshift(announcement.text); if (announcement.priority === "assertive") { priority = "assertive"; } } if (text.length) { liveElement.innerHTML = ""; liveElement.setAttribute("aria-busy", "true"); liveElement.setAttribute("aria-live", priority); liveElement.innerHTML = text.join("\n"); liveElement.setAttribute("aria-busy", "false"); } } Drupal.announce = function (text, priority) { announcements.push({ text: text, priority: priority, }); return debounce(announce, 200)(); }; })(Drupal, Drupal.debounce); /** * @file * JavaScript behaviors for details element. */ (function ($, Drupal) { "use strict"; Drupal.webform = Drupal.webform || {}; Drupal.webform.detailsToggle = Drupal.webform.detailsToggle || {}; Drupal.webform.detailsToggle.options = Drupal.webform.detailsToggle.options || {}; /** * Attach handler to toggle details open/close state. * * @type {Drupal~behavior} */ Drupal.behaviors.webformDetailsToggle = { attach: function (context) { $(".js-webform-details-toggle", context) .once("webform-details-toggle") .each(function () { var $form = $(this); var $tabs = $form.find(".webform-tabs"); // Get only the main details elements and ignore all nested details. var selector = $tabs.length ? ".webform-tab" : ".js-webform-details-toggle"; var $details = $form.find("details").filter(function () { // @todo Figure out how to optimize the below code. var $parents = $(this).parentsUntil(selector); return $parents.find("details").length === 0; }); // Toggle is only useful when there are two or more details elements. if ($details.length < 2) { return; } var options = $.extend( { button: '', }, Drupal.webform.detailsToggle.options ); // Create toggle buttons. var $toggle = $(options.button) .attr("title", Drupal.t("Toggle details widget state.")) .on("click", function (e) { var open; if (isFormDetailsOpen($form)) { $form.find("details").removeAttr("open"); open = 0; } else { $form.find("details").attr("open", "open"); open = 1; } setDetailsToggleLabel($form); // Set the saved states for all the details elements. // @see webform.element.details.save.js if (!Drupal.webformDetailsSaveGetName) { $form.find("details").each(function () { var name = Drupal.webformDetailsSaveGetName($(this)); if (name) { localStorage.setItem(name, open); } }); } }) .wrap('
    ') .parent(); if ($tabs.length) { // Add toggle state before the tabs. $tabs.find(".item-list:first-child").before($toggle); } else { // Add toggle state link to first details element. $details.eq(0).before($toggle); } setDetailsToggleLabel($form); }); }, }; /** * Determine if a webform's details are all opened. * * @param {jQuery} $form * A webform. * * @return {boolean} * TRUE if a webform's details are all opened. */ function isFormDetailsOpen($form) { return $form.find("details[open]").length === $form.find("details").length; } /** * Set a webform's details toggle state widget label. * * @param {jQuery} $form * A webform. */ function setDetailsToggleLabel($form) { var isOpen = isFormDetailsOpen($form); var label = isOpen ? Drupal.t("Collapse all") : Drupal.t("Expand all"); $form.find(".webform-details-toggle-state").html(label); var text = isOpen ? Drupal.t("All details have been expanded.") : Drupal.t("All details have been collapsed."); Drupal.announce(text); } })(jQuery, Drupal); /** * @file * JavaScript behaviors for details element. */ (function ($, Drupal) { "use strict"; /** * Attach handler to save details open/close state. * * @type {Drupal~behavior} */ Drupal.behaviors.webformDetailsSave = { attach: function (context) { if (!window.localStorage) { return; } // Summary click event handler. $("details > summary", context) .once("webform-details-summary-save") .click(function () { var $details = $(this).parent(); // @see https://css-tricks.com/snippets/jquery/make-an-jquery-hasattr/ if ($details[0].hasAttribute("data-webform-details-nosave")) { return; } var name = Drupal.webformDetailsSaveGetName($details); if (!name) { return; } var open = $details.attr("open") !== "open" ? "1" : "0"; localStorage.setItem(name, open); }); // Initialize details open state via local storage. $("details", context) .once("webform-details-save") .each(function () { var $details = $(this); var name = Drupal.webformDetailsSaveGetName($details); if (!name) { return; } var open = localStorage.getItem(name); if (open === null) { return; } if (open === "1") { $details.attr("open", "open"); } else { $details.removeAttr("open"); } }); }, }; /** * Get the name used to store the state of details element. * * @param {jQuery} $details * A details element. * * @return {string} * The name used to store the state of details element. */ Drupal.webformDetailsSaveGetName = function ($details) { if (!window.localStorage) { return ""; } // Any details element not included a webform must have define its own id. var webformId = $details.attr("data-webform-element-id"); if (webformId) { return "Drupal.webform." + webformId.replace("--", "."); } var detailsId = $details.attr("id"); if (!detailsId) { return ""; } var $form = $details.parents("form"); if (!$form.length || !$form.attr("id")) { return ""; } var formId = $form.attr("id"); if (!formId) { return ""; } // ISSUE: When Drupal renders a webform in a modal dialog it appends a unique // identifier to webform ids and details ids. (i.e. my-form--FeSFISegTUI) // WORKAROUND: Remove the unique id that delimited using double dashes. formId = formId.replace(/--.+?$/, "").replace(/-/g, "_"); detailsId = detailsId.replace(/--.+?$/, "").replace(/-/g, "_"); return "Drupal.webform." + formId + "." + detailsId; }; })(jQuery, Drupal);