", a("#" + o.scope.id + "_overlay").length < 1 && o.dom.append(r), "inline" == o.options.type && t.appendTo("#" + o.scope.id + " .modaal-content-container"), o.modaal_overlay("show");
},
create_basic: function create_basic() {
var t = this,
o = a(t.scope.source),
e = "";
o.length ? (e = o.contents().detach(), o.empty()) : e = "Content could not be loaded. Please check the source and try again.", t.build_modal(e);
},
create_instagram: function create_instagram() {
var t = this,
o = t.options.instagram_id,
e = "",
i = "Instagram photo couldn't be loaded, please check the embed code and try again.";
if (t.build_modal('
' + t.options.loading_content + "
"), "" != o && null !== o && void 0 !== o) {
var l = "https://api.instagram.com/oembed?url=http://instagr.am/p/" + o + "/";
a.ajax({
url: l,
dataType: "jsonp",
cache: !1,
success: function success(o) {
t.dom.append('
' + o.html + "
"), t.dom.attr("data-igloaded") ? window.instgrm.Embeds.process() : t.dom.attr("data-igloaded", "true");
var e = "#" + t.scope.id + " .modaal-content-container";
a(e).length > 0 && setTimeout(function () {
a("#temp-ig").contents().clone().appendTo(e), a("#temp-ig").remove();
}, 1e3);
},
error: function error() {
e = i;
var o = a("#" + t.scope.id + " .modaal-content-container");
o.length > 0 && (o.removeClass(t.options.loading_class).addClass(t.options.ajax_error_class), o.html(e));
}
});
} else e = i;
return !1;
},
fetch_ajax: function fetch_ajax(t) {
var o = this;
null == o.options.accessible_title && (o.options.accessible_title = "Dialog Window"), null !== o.xhr && (o.xhr.abort(), o.xhr = null), o.build_modal('
' + o.options.loading_content + "
"), o.xhr = a.ajax(t, {
success: function success(t) {
var e = a("#" + o.scope.id).find(".modaal-content-container");
e.length > 0 && (e.removeClass(o.options.loading_class), e.html(t), o.options.ajax_success.call(o, e));
},
error: function error(t) {
if ("abort" != t.statusText) {
var e = a("#" + o.scope.id + " .modaal-content-container");
e.length > 0 && (e.removeClass(o.options.loading_class).addClass(o.options.ajax_error_class), e.html("Content could not be loaded. Please check the source and try again."));
}
}
});
},
create_confirm: function create_confirm() {
var a,
t = this;
a = '
' + t.options.confirm_title + '
' + t.options.confirm_content + '
", t.build_modal(a);
},
create_image: function create_image() {
var t,
o,
e = this,
i = "";
if (e.$elem.is("[data-group]") || e.$elem.is("[rel]")) {
var l = e.$elem.is("[data-group]"),
n = l ? e.$elem.attr("data-group") : e.$elem.attr("rel"),
s = a(l ? '[data-group="' + n + '"]' : '[rel="' + n + '"]');
s.removeAttr("data-gallery-active", "is_active"), e.$elem.attr("data-gallery-active", "is_active"), o = s.length - 1;
var d = [];
i = '
', s.each(function (t, o) {
var e = "",
i = "",
l = "",
n = !1,
s = !1,
r = o.getAttribute("data-modaal-desc"),
c = o.getAttribute("data-gallery-active");
a(o).attr("data-modaal-content-source") ? e = a(o).attr("data-modaal-content-source") : a(o).attr("href") ? e = a(o).attr("href") : a(o).attr("src") ? e = a(o).attr("src") : (e = "trigger requires href or data-modaal-content-source attribute", s = !0), "" != r && null !== r && void 0 !== r ? (i = r, l = '
", c && (n = !0);
var m = {
url: e,
alt: i,
rawdesc: r,
desc: l,
active: n,
src_error: s
};
d.push(m);
});
for (var r = 0; r < d.length; r++) {
var c = "",
m = d[r].rawdesc ? "Image: " + d[r].rawdesc : "Image " + r + " no description";
d[r].active && (c = " " + e.private_options.active_class);
var p = d[r].src_error ? d[r].url : '';
i += '
' + p + d[r].desc + "
";
}
i += "
", 1 != e.options.outer_controls && (i += e.scope.prev_btn + e.scope.next_btn);
} else {
var _,
u = !1;
e.$elem.attr("data-modaal-content-source") ? _ = e.$elem.attr("data-modaal-content-source") : e.$elem.attr("href") ? _ = e.$elem.attr("href") : e.$elem.attr("src") ? _ = e.$elem.attr("src") : (_ = "trigger requires href or data-modaal-content-source attribute", u = !0);
var v = "",
f = "",
m = "";
e.$elem.attr("data-modaal-desc") ? (m = e.$elem.attr("data-modaal-desc"), v = e.$elem.attr("data-modaal-desc"), f = '
Image - ' + v.replace(//g, ">") + "
") : m = "Image with no description";
var p = u ? _ : '';
i = '
' + p + f + "
";
}
t = i, e.build_modal(t), a(".modaal-gallery-item.is_active").is(".gallery-item-0") && a(".modaal-gallery-prev").hide(), a(".modaal-gallery-item.is_active").is(".gallery-item-" + o) && a(".modaal-gallery-next").hide();
},
gallery_update: function gallery_update(t) {
var o = this,
e = a("#" + o.scope.id),
i = e.find(".modaal-gallery-item"),
l = i.length - 1;
if (0 == l) return !1;
var n = e.find(".modaal-gallery-prev"),
s = e.find(".modaal-gallery-next"),
d = 0,
r = 0,
c = e.find(".modaal-gallery-item." + o.private_options.active_class),
m = "next" == t ? c.next(".modaal-gallery-item") : c.prev(".modaal-gallery-item");
return o.options.before_image_change.call(o, c, m), ("prev" != t || !e.find(".gallery-item-0").hasClass("is_active")) && ("next" != t || !e.find(".gallery-item-" + l).hasClass("is_active")) && void c.stop().animate({
opacity: 0
}, 250, function () {
m.addClass("is_next").css({
position: "absolute",
display: "block",
opacity: 0
});
a(document).width();
e.find(".modaal-gallery-item.is_next").css({
"max-height": "80vh",
"max-width": "100%"
}), e.find(".modaal-gallery-item.is_next img").css({
"max-height": "80vh",
"max-width": "100%"
}), d = e.find(".modaal-gallery-item.is_next").find("img").width(), r = e.find(".modaal-gallery-item.is_next").find("img").height(), e.find(".modaal-gallery-item-wrap").stop().animate({
width: d,
height: r
}, 250, function () {
c.removeClass(o.private_options.active_class + " " + o.options.gallery_active_class).removeAttr("style"), c.find("img").removeAttr("style"), m.addClass(o.private_options.active_class + " " + o.options.gallery_active_class).removeClass("is_next").css("position", ""), m.stop().animate({
opacity: 1
}, 250, function () {
a(this).removeAttr("style").css({
width: "100%"
}), a(this).find("img").css({
"max-height": "80vh",
"max-width": "100%"
}), e.find(".modaal-gallery-item-wrap").removeAttr("style"), o.options.after_image_change.call(o, m);
}), e.find(".modaal-gallery-item").removeAttr("tabindex"), e.find(".modaal-gallery-item." + o.private_options.active_class).attr("tabindex", "0").focus(), e.find(".modaal-gallery-item." + o.private_options.active_class).is(".gallery-item-0") ? n.stop().animate({
opacity: 0
}, 150, function () {
a(this).hide();
}) : n.stop().css({
display: "block",
opacity: n.css("opacity")
}).animate({
opacity: 1
}, 150), e.find(".modaal-gallery-item." + o.private_options.active_class).is(".gallery-item-" + l) ? s.stop().animate({
opacity: 0
}, 150, function () {
a(this).hide();
}) : s.stop().css({
display: "block",
opacity: n.css("opacity")
}).animate({
opacity: 1
}, 150);
});
});
},
create_video: function create_video(a) {
var t,
o = this;
t = '', o.build_modal('
' + t + "
");
},
create_iframe: function create_iframe(a) {
var t,
o = this;
t = null !== o.options.width || void 0 !== o.options.width || null !== o.options.height || void 0 !== o.options.height ? '' : '
Please specify a width and height for your iframe
', o.build_modal(t);
},
modaal_open: function modaal_open() {
var t = this,
o = a("#" + t.scope.id),
e = t.options.animation;
"none" === e && (o.removeClass("modaal-start_none"), t.options.after_open.call(t, o)), "fade" === e && o.removeClass("modaal-start_fade"), "slide-down" === e && o.removeClass("modaal-start_slide_down");
var i = o;
a(".modaal-wrapper *[tabindex=0]").removeAttr("tabindex"), i = "image" == t.options.type ? a("#" + t.scope.id).find(".modaal-gallery-item." + t.private_options.active_class) : o.find(".modaal-iframe-elem").length ? o.find(".modaal-iframe-elem") : o.find(".modaal-video-wrap").length ? o.find(".modaal-video-wrap") : o.find(".modaal-focus"), i.attr("tabindex", "0").focus(), "none" !== e && setTimeout(function () {
t.options.after_open.call(t, o);
}, t.options.after_callback_delay);
},
modaal_close: function modaal_close() {
var t = this,
o = a("#" + t.scope.id);
t.options.before_close.call(t, o), null !== t.xhr && (t.xhr.abort(), t.xhr = null), "none" === t.options.animation && o.addClass("modaal-start_none"), "fade" === t.options.animation && o.addClass("modaal-start_fade"), "slide-down" === t.options.animation && o.addClass("modaal-start_slide_down"), setTimeout(function () {
"inline" == t.options.type && a("#" + t.scope.id + " .modaal-content-container").contents().detach().appendTo(t.scope.source), o.remove(), t.options.after_close.call(t), t.scope.is_open = !1;
}, t.options.after_callback_delay), t.modaal_overlay("hide"), null != t.lastFocus && t.lastFocus.focus();
},
modaal_overlay: function modaal_overlay(t) {
var o = this;
"show" == t ? (o.scope.is_open = !0, o.options.background_scroll || o.dom.addClass("modaal-noscroll"), a("#" + o.scope.id + "_overlay").length < 1 && o.dom.append(''), a("#" + o.scope.id + "_overlay").css("background", o.options.background).stop().animate({
opacity: o.options.overlay_opacity
}, o.options.animation_speed, function () {
o.modaal_open();
})) : "hide" == t && a("#" + o.scope.id + "_overlay").stop().animate({
opacity: 0
}, o.options.animation_speed, function () {
a(this).remove(), o.dom.removeClass("modaal-noscroll");
});
},
is_touch: function is_touch() {
return "ontouchstart" in window || navigator.maxTouchPoints;
}
},
e = [];
a.fn.modaal = function (t) {
return this.each(function (i) {
var l = a(this).data("modaal");
if (l) {
if ("string" == typeof t) switch (t) {
case "open":
l.create_modaal(l);
break;
case "close":
l.modaal_close();
}
} else {
var n = Object.create(o);
n.init(t, this), a.data(this, "modaal", n), e.push({
element: a(this).attr("class"),
options: t
});
}
});
}, a.fn.modaal.options = {
type: "inline",
content_source: null,
animation: "fade",
animation_speed: 300,
after_callback_delay: 350,
is_locked: !1,
hide_close: !1,
background: "#000",
overlay_opacity: "0.8",
overlay_close: !0,
accessible_title: "Dialog Window",
start_open: !1,
fullscreen: !1,
custom_class: "",
background_scroll: !1,
should_open: !0,
close_text: "Close",
close_aria_label: "Close (Press escape to close)",
width: null,
height: null,
gallery_prev_text: "Previous image",
gallery_prev_aria_label: "Previous image (use left arrow to change)",
gallery_next_text: "Next image",
gallery_next_aria_label: "Next image (use right arrow to change)",
before_open: function before_open() {},
after_open: function after_open() {},
before_close: function before_close() {},
after_close: function after_close() {},
source: function source(a, t) {
return t;
},
confirm_button_text: "Confirm",
confirm_cancel_button_text: "Cancel",
confirm_title: "Confirm Title",
confirm_content: "
This is the default confirm dialog content. Replace me through the options
",
confirm_callback: function confirm_callback() {},
confirm_cancel_callback: function confirm_cancel_callback() {},
gallery_active_class: "gallery_active_item",
outer_controls: !1,
before_image_change: function before_image_change(a, t) {},
after_image_change: function after_image_change(a) {},
loading_content: '
',
loading_class: "is_loading",
ajax_error_class: "modaal-error",
ajax_success: function ajax_success() {},
instagram_id: null
}, a(function () {
var o = a(".modaal");
o.length && o.each(function () {
t(a(this));
});
var i = new MutationObserver(function (o) {
o.forEach(function (o) {
if (o.addedNodes && o.addedNodes.length > 0) {
[].some.call(o.addedNodes, function (o) {
var i = a(o);
(i.is("a") || i.is("button")) && (i.hasClass("modaal") ? t(i) : e.forEach(function (t) {
if (t.element == i.attr("class")) return a(i).modaal(t.options), !1;
}));
});
}
});
}),
l = {
subtree: !0,
attributes: !0,
childList: !0,
characterData: !0
};
setTimeout(function () {
i.observe(document.body, l);
}, 500);
});
}(jQuery, window, document);