| Current Path : /home/azimutno/azimutno/www/demo/media/mod_pwebbox/js/ |
| Current File : /home/azimutno/azimutno/www/demo/media/mod_pwebbox/js/jquery.pwebbox.js |
/**
* @package pwebbox
* @version 2.0.0
*
* @copyright Copyright (C) 2015 Perfect Web. All rights reserved. http://www.perfect-web.co
* @license GNU General Public Licence http://www.gnu.org/licenses/gpl-3.0.html
*
* jQuery 1.8+
*/
var pwebBoxes = pwebBoxes || [], pwebbox_l10n = pwebbox_l10n || {};
(function (a) {
pwebBox = function (b) {
this.init(b)
};
pwebBox.prototype = (function () {
var b = {};
return{constructor: pwebBox, defaults: {id: "", selector: "#pwebbox", selectorClass: ".pwebbox", debug: false, bootstrap: 2, openAuto: false, openDelay: 0, maxAutoOpen: 0, closeAuto: false, closeDelay: 0, closeOther: true, layout: "slidebox", theme: "", position: "left", offsetPosition: "top", msgCloseDelay: 10, togglerNameOpen: "", togglerNameClose: "", slideWidth: 0, slideDuration: 400, slideTransition: "swing", accordionDuration: 500, accordionEaseIn: "easeInBack", accordionEaseOut: "easeOutBounce", modalBackdrop: true, modalClose: true, modalStyle: "default", modalEffect: "fade", modalEffectDuration: 400, modalEaseIn: "easeInCubic", modalEaseOut: "easeOutCubic", cookieLifetime: 30, cookiePath: "/", cookieDomain: "", onLoad: function () {
}, onOpen: function () {
}, onClose: function () {
}, onComplete: function (c) {
}, onTrack: function () {
}, onError: function (c) {
}}, status: 0, hidden: true, timer: false, init: function (c) {
var e = this;
this.options = a.extend({}, this.defaults, c);
this.options.selector = this.options.selector + this.options.id;
this.options.selectorClass = this.options.selectorClass + this.options.id;
this.element = a(this.options.selector);
this.Content = a(this.options.selector + "_content");
this.Toggler = a(this.options.selector + "_toggler");
this.Box = a(this.options.selector + "_box");
this.Container = a(this.options.selector + "_container");
this.options.autoClose = (this.options.closeDelay > 0) ? true : false;
this.options.tracked = false;
this.options.openEvent = 'click';
if (this.Box.hasClass('pweb-open-event-mouseenter'))
{
this.options.openEvent = 'mouseenter';
}
this.options.closeEvent = 'click';
if (this.Box.hasClass('pweb-close-event-mouseleave'))
{
this.options.closeEvent = 'mouseleave';
}
b[this.options.id] = {enabled: 0, status: -1};
a("a[href=" + this.options.selector + "_toggler]").addClass((this.options.selector.replace("#", "")) + "_toggler");
if (this.options.layout == "slidebox") {
this.element.appendTo(document.body);
this.initSlidebox()
} else {
if (this.options.layout == "modal") {
this.element.appendTo(document.body);
if (!this.initModal()) {
return false
}
} else {
if (this.options.layout == "accordion") {
this.initAccordion()
}
}
}
this.options.onLoad.apply(this);
var d = false;
if (document.location.hash.indexOf(this.options.selector + ":") !== -1) {
var f = document.location.hash.replace(this.options.selector + ":", "");
if (f.indexOf("open") === 0 && (typeof f[4] === "undefined" || f[4] == ":")) {
f = f.replace(/open(:)?/i, "");
d = true
}
}
if (this.options.layout != "static") {
if (this.options.openEvent == 'click' && this.options.closeEvent == 'click') {
a(this.options.selectorClass + "_toggler").click(function (g) {
g.preventDefault();
e.toggleBox(-1, -1, this, g)
});
} else {
this.Box.find('.pweb-button-close').click(function (g) {
g.preventDefault();
e.toggleBox(-1, -1, this, g)
});
if (this.options.openEvent == 'mouseenter') {
a(this.Toggler).mouseenter(function (g) {
g.preventDefault();
e.toggleBox(1, 1, this, g)
});
}
else {
a(this.Toggler).click(function (g) {
g.preventDefault();
e.toggleBox(1, 1, this, g)
});
}
if (this.options.closeEvent == 'mouseleave') {
var mouseTarget = this.element;
if (this.options.layout == 'modal') {
mouseTarget = this.Box;
}
a(mouseTarget).mouseleave(function (g) {
if (e.Toggler.hasClass('pweb-opened')) {
g.preventDefault();
e.toggleBox(0, -1, this, g);
}
});
}
else {
a(this.Toggler).click(function (g) {
if (e.Toggler.hasClass('pweb-opened')) {
g.preventDefault();
e.toggleBox(0, -1, this, g);
}
});
}
}
if (this.options.togglerNameClose) {
this.options.togglerNameOpen = this.Toggler.find(".pweb-text").text()
}
if (this.options.closeOther) {
pwebBoxes.push(this)
}
if (d) {
this.autoPopupOnPageLoad()
} else {
if (this.options.openAuto) {
if (this.options.maxAutoOpen > 0) {
if (!this.initAutoPopupCookie()) {
this.options.openAuto = false
}
}
switch (this.options.openAuto) {
case 1:
this.autoPopupOnPageLoad();
break;
case 2:
this.autoPopupOnPageScroll();
break;
case 3:
this.autoPopupOnPageExit();
}
}
}
if(e.options.layout == 'bottombar'){
var bottomBarHeight = a(e.options.selector).find('.pwebbox-container').outerHeight();
e.Toggler.height(bottomBarHeight).css('line-height', bottomBarHeight + 'px');
}
a(window).resize(function() {
if(e.options.layout == 'bottombar'){
var bottomBarHeight = a(e.options.selector).find('.pwebbox-container').outerHeight();
e.Toggler.height(bottomBarHeight).css('line-height', bottomBarHeight + 'px');
}
});
}
this.initHiddenFields();
return this
}, initSlidebox: function () {
var c = this;
this.options.togglerSlide = this.Box.hasClass("pweb-toggler-slide");
this.options.togglerHidden = this.Box.hasClass("pweb-toggler-hidden");
this.options.slidePos = this.element.css("position");
if (!this.options.slideWidth) {
this.options.slideWidth = parseInt(this.Box.css("max-width"))
}
this.Box.css("width", this.options.slideWidth);
if (this.options.position == "left" || this.options.position == "right") {
this.Box.css(this.options.position, -this.options.slideWidth);
this.options.togglerWidth = this.options.togglerSlide ? this.Toggler.outerWidth() : 0;
this.options.togglerHeight = this.options.togglerSlide ? parseInt(this.Box.css("top")) : 0;
this.options.slideOffset = parseInt(this.element.css("top"));
if (this.options.togglerSlide) {
this.Toggler.css(this.options.position == "left" ? "right" : "left", -this.Toggler.outerWidth())
}
} else {
setTimeout(function () {
c.Box.css(c.options.position, -c.Box.height())
}, 100);
this.options.togglerWidth = 0;
this.options.togglerHeight = this.options.togglerSlide ? this.Toggler.outerHeight() : 0;
this.options.slideOffset = 0;
if (this.options.togglerSlide) {
this.Toggler.css(this.options.position == "top" ? "bottom" : "top", -this.Toggler.outerHeight())
}
}
this.Box.addClass("pweb-closed");
setTimeout(function () {
c.Box.removeClass("pweb-init")
}, 100);
if (this.options.togglerHidden) {
this.Toggler.fadeOut(0).removeClass("pweb-closed").addClass("pweb-opened");
if (this.options.togglerNameClose) {
this.Toggler.find(".pweb-text").text(this.options.togglerNameClose)
}
}
this.isFF = navigator.userAgent.indexOf("Gecko") != -1;
a(window).scroll(function (d) {
if (!c.hidden && c.element.css("position") == "absolute" && c.options.slidePos == "fixed") {
var f = a(this).scrollTop();
if (c.options.position == "bottom") {
f = f + a(this).height();
if (f > c.element.offset().top) {
if (c.isFF) {
c.element.css("top", f)
} else {
c.element.stop().animate({top: f}, 250, "linear")
}
}
} else {
f = f + c.options.slideOffset;
if (f < c.element.offset().top) {
if (c.isFF) {
c.element.css("top", f)
} else {
c.element.stop().animate({top: f}, 250, "linear")
}
}
}
}
});
a(window).resize(function () {
if (!c.hidden) {
var d = {width: c.options.slideWidth};
var e = a(window).width();
if (c.options.position == "left" || c.options.position == "right") {
if (c.options.slideWidth + c.options.togglerWidth > e) {
d.width = e - c.options.togglerWidth
}
} else {
var f = c.element.offset().left;
if (c.options.offsetPosition == "right") {
f = a(document).width() - f
}
if (c.options.slideWidth + f > e) {
d.width = e - f
}
}
c.Box.css(d);
if (c.options.slidePos == "fixed") {
var d = {position: "absolute"};
if (c.options.position == "left" || c.options.position == "right") {
d.top = c.element.offset().top;
if (c.Box.height() + c.options.togglerHeight + d.top - a(window).scrollTop() <= a(window).height()) {
d.position = "fixed";
d.top = c.options.slideOffset
}
} else {
if (c.Box.height() + c.options.togglerHeight > a(window).height()) {
d.top = c.element.offset().top;
if (c.options.position == "bottom") {
d.bottom = "auto"
}
} else {
d.position = "fixed";
d[c.options.position] = 0;
if (c.options.position == "bottom") {
d.top = "auto"
}
}
}
c.element.css(d)
}
}
})
}, initModal: function () {
var c = this;
if (typeof a.fn.modal === "function") {
this.Modal = a(this.options.selector + "_modal");
this.options.modalClass = "pwebbox" + this.options.id + "_modal-open pweb-modal-open" + (this.options.theme ? " pweb-theme-" + this.options.theme : "") + " pweb-modal-" + this.options.modalStyle;
this.Modal.appendTo(document.body).modal({show: false, keyboard: false, backdrop: !this.options.modalClose && this.options.modalBackdrop ? "static" : this.options.modalBackdrop}).on(this.options.bootstrap === 2 ? "hidden" : "hidden.bs.modal", function (d) {
d.stopPropagation();
if (d.target !== d.currentTarget) {
return
}
c.toggleBox(0);
a(document.body).removeClass(c.options.modalClass);
c.Box.addClass("pweb-closed")
}).on(this.options.bootstrap === 2 ? "show" : "show.bs.modal", function (d) {
d.stopPropagation();
if (d.target !== d.currentTarget) {
return
}
a(document.body).addClass(c.options.modalClass);
c.Box.removeClass("pweb-closed")
}).click(function (d) {
if (d.target !== d.currentTarget || !c.options.modalClose) {
return
}
c.toggleBox(0)
});
if (this.options.modalEffect !== "fade" && this.options.modalEffect !== "drop") {
this.initGenie()
}
return true
} else {
if (this.options.debug) {
this.debug("Bootstrap Modal Plugin is not loaded")
}
}
return false
}, initGenie: function () {
var c = this, d = this.Box.attr("class").match(/pweb-bg-[a-z]+/i);
this.options.modalGenieClass = "pweb-genie pweb-" + this.options.modalEffect + "-" + (this.options.position !== "static" ? this.options.position : "bottom") + " pwebbox" + this.options.id + "-genie" + (this.options.theme ? " pweb-theme-" + this.options.theme : "") + (this.Box.hasClass("pweb-radius") ? " pweb-radius" : "") + (this.Box.hasClass("pweb-shadow") ? " pweb-shadow" : "") + (d ? " " + d[0] : "");
if (this.options.modalEffect === "smooth") {
this.options.modalEaseIn = "easeInQuart";
this.options.modalEaseOut = "easeOutQuart"
} else {
if (this.options.modalEffect === "rotate") {
this.options.modalEaseIn = "easeInQuint";
this.options.modalEaseOut = "easeOutQuint"
}
}
this.Modal.on(this.options.bootstrap === 2 ? "show" : "show.bs.modal", function (f) {
f.stopPropagation();
if (f.target !== f.currentTarget) {
return
}
if (typeof c.eventSource !== "undefined" && a(c.eventSource).length) {
c.Container.css({visibility: "hidden", opacity: 0})
}
}).on(this.options.bootstrap === 2 ? "shown" : "shown.bs.modal", function (f) {
f.stopPropagation();
if (f.target !== f.currentTarget) {
return
}
if (typeof c.eventSource !== "undefined" && a(c.eventSource).length) {
a(c.eventSource).trigger("modalOpen")
}
});
a(this.options.selectorClass + "_toggler").on("modalOpen", function () {
a(this).effect({effect: "transfer", to: c.Container, duration: c.options.modalEffectDuration, easing: c.options.modalEaseIn, className: "pweb-genie-show " + c.options.modalGenieClass, complete: function () {
c.Container.css({visibility: "visible", opacity: 1})
}})
});
this.Container.on("modalClose", function () {
a(this).css({visibility: "hidden", opacity: 0}).effect({effect: "transfer", to: a(c.eventSource), duration: c.options.modalEffectDuration, easing: c.options.modalEaseOut, className: "pweb-genie-hide " + c.options.modalGenieClass, complete: function () {
c.Modal.modal("hide")
}})
})
}, initAccordion: function () {
var c = this;
a(this.options.selectorClass + "_toggler").on("openAccordion", function () {
c.Box.removeClass("pweb-closed").slideDown({duration: c.options.accordionDuration, easing: c.options.accordionEaseOut, complete: function () {
var d = a(window).height(), f = c.element.outerHeight(), e = c.element.offset().top;
if (e + f > a(window).scrollTop() + d) {
if (f < d) {
e = e + f - d
}
a("html,body").animate({scrollTop: parseInt(e)}, 500)
}
a(c.Toggler).trigger("openedAccordion");
}})
});
a(this.element).on("closeAccordion", function () {
c.Box.slideUp({duration: c.options.accordionDuration, easing: c.options.accordionEaseIn, complete: function () {
c.Box.addClass("pweb-closed")
}})
});
this.Box.css("display", "none").removeClass("pweb-init");
return true
}, initHiddenFields: function () {
a("<input/>", {type: "hidden", name: "screen_resolution", value: screen.width + "x" + screen.height}).appendTo(this.Content);
if (this.options.debug) {
a("<input/>", {type: "hidden", name: "debug", value: 1}).appendTo(this.Content)
}
return true
}, close: function () {
this.toggleBox(0)
}, toggleBox: function (c, i, h, d) {
var g = this;
if (typeof c === "undefined") {
c = -1
}
if (typeof h === "undefined") {
h = this.Toggler
}
if (!this.hidden && (c === -1 || c === 0)) {
this.hidden = true;
if (this.Toggler.length && !this.options.togglerHidden) {
this.Toggler.removeClass("pweb-opened").addClass("pweb-closed");
if (this.options.togglerNameClose) {
this.Toggler.find(".pweb-text").text(this.options.togglerNameOpen)
}
}
if (this.options.openAuto === false && this.timer) {
clearTimeout(this.timer)
}
if (this.options.layout == "slidebox") {
var f = {};
f[this.options.position] = (this.options.position == "left" || this.options.position == "right") ? -this.Box.width() : -this.Box.height();
this.Box.stop(true, false).animate(f, this.options.slideDuration, this.options.slideTransition, function () {
g.Box.addClass("pweb-closed");
if (g.element.css("position") == "absolute" && g.options.slidePos == "fixed") {
var l = {position: "fixed"};
if (g.options.position == "left" || g.options.position == "right") {
l.top = g.options.slideOffset
} else {
l[g.options.position] = 0;
if (g.options.position == "bottom") {
l.top = "auto"
}
}
g.element.css(l)
}
a(h).trigger("closedSlidebox");
});
if (this.options.togglerHidden) {
this.Toggler.fadeOut(this.options.slideDuration)
}
} else {
if (this.options.layout == "modal") {
if (this.options.modalEffect !== "fade" && this.options.modalEffect !== "drop" && typeof this.eventSource !== "undefined") {
this.Container.trigger("modalClose")
} else {
this.Modal.modal("hide")
}
} else {
if (this.options.layout == "accordion") {
a(h).trigger("closeAccordion")
} else {
if (this.options.layout == "bottombar") {
this.element.hide();
}
}
}
}
this.options.onClose.apply(this);
} else {
if (this.hidden && (c === -1 || c === 1)) {
if (this.options.closeOther) {
a.each(pwebBoxes, function () {
if (this.options.id != g.options.id && typeof this.close === "function") {
this.close()
}
})
}
if (this.options.openAuto === 1 || this.options.openAuto === 2) {
this.options.openAuto = false;
if (this.timer) {
clearTimeout(this.timer)
}
}
if (typeof i === "number" && i >= 0) {
var j = a(this.options.selector + "_mailto");
if (j.length) {
j[0].selectedIndex = parseInt(i);
if (this.Box.hasClass("pweb-labels-over")) {
j.trigger("focus").trigger("blur")
}
}
}
if (a(h).length) {
if (a(h).data("pwebbox-fields")) {
this.preloadFields(a(h).data("pwebbox-fields"))
}
if (a(h).data("pwebbox-fields-once")) {
this.preloadFields(a(h).data("pwebbox-fields-once"));
a(h).data("pwebbox-fields-once", "")
}
}
this.hidden = false;
if (this.Toggler.length && !this.options.togglerHidden) {
this.Toggler.removeClass("pweb-closed").addClass("pweb-opened");
if (this.options.togglerNameClose) {
this.Toggler.find(".pweb-text").text(this.options.togglerNameClose)
}
}
if (this.options.layout == "slidebox") {
var f = {width: this.options.slideWidth};
f[this.options.position] = 0;
var k = a(window).width();
if (this.options.position == "left" || this.options.position == "right") {
if (this.options.slideWidth + this.options.togglerWidth > k) {
f.width = k - this.options.togglerWidth
}
} else {
var e = this.element.offset().left;
if (this.options.offsetPosition == "right") {
e = a(document).width() - e
}
if (this.options.slideWidth + e > k) {
f.width = k - e
}
}
this.Box.stop(true, false).animate(f, this.options.slideDuration, this.options.slideTransition, function () {
if (g.options.slidePos == "fixed") {
var l = {position: "absolute"};
if (g.options.position == "left" || g.options.position == "right") {
l.top = g.element.offset().top;
if (g.Box.height() + g.options.togglerHeight + l.top - a(window).scrollTop() > a(window).height()) {
l.top = g.element.offset().top;
g.element.css(l)
}
} else {
if (g.Box.height() + g.options.togglerHeight > a(window).height()) {
l.top = g.element.offset().top;
if (g.options.position == "bottom") {
l.bottom = "auto"
}
g.element.css(l)
}
}
}
a(h).trigger("shownSlidebox");
}).css("overflow", "visible").removeClass("pweb-closed");
if (this.options.togglerHidden) {
this.Toggler.fadeIn(this.options.slideDuration)
}
} else {
if (this.options.layout == "modal") {
if (this.options.modalEffect !== "fade" && this.options.modalEffect !== "drop" && a(h).length) {
this.eventSource = h
}
this.Modal.modal("show")
} else {
if (this.options.layout == "accordion") {
a(h).trigger("openAccordion")
} else {
if (this.options.layout == "bottombar") {
this.Box.parent().show();
}
}
}
}
this.options.onOpen.apply(this);
if(!this.options.tracked) {
this.options.tracked = true;
this.options.onTrack.apply(this);
}
this.autoClose();
}
}
}, initAutoPopupCookie: function () {
if (typeof a.cookie === "function") {
var c = parseInt(a.cookie("pwebbox" + this.options.id + "_openauto"));
c = isNaN(c) ? 1 : c + 1;
if (c <= this.options.maxAutoOpen) {
a.cookie("pwebbox" + this.options.id + "_openauto", c, {domain: this.options.cookieDomain, path: this.options.cookiePath, expires: this.options.cookieLifetime});
return true
}
} else {
if (this.options.debug) {
this.debug("jQuery Cookie Plugin is not loaded")
}
}
return false
}, autoPopupOnPageLoad: function () {
if (this.options.openDelay) {
this.timer = this.delay(this.toggleBox, this.options.openDelay, this, [1])
} else {
this.toggleBox(1)
}
}, autoPopupOnPageScroll: function () {
var c = this;
this.autoOpen = true;
a(window).scroll(function () {
if (c.autoOpen) {
c.autoOpen = false;
if (c.options.openDelay) {
c.timer = c.delay(c.toggleBox, c.options.openDelay, c, [1])
} else {
c.toggleBox(1)
}
}
})
}, autoPopupOnPageExit: function () {
var c = this;
this.autoOpen = -1;
a(window).mousemove(function (d) {
if (c.autoOpen == -1 && d.clientY > 70) {
c.autoOpen = 1
} else {
if (c.autoOpen == 1 && d.clientY < 30) {
c.autoOpen = 0;
if (c.options.openDelay) {
c.timer = c.delay(c.toggleBox, c.options.openDelay, c, [1])
} else {
c.toggleBox(1)
}
}
}
})
}, autoClose: function () {
if (this.options.autoClose) {
this.options.autoClose = false;
if (this.options.closeDelay) {
this.timer = this.delay(this.toggleBox, this.options.closeDelay, this, [0])
} else {
this.toggleBox(0)
}
}
}, delay: function (e, d, f, c) {
return setTimeout(function () {
return e.apply(f, c || arguments)
}, d)
}, displayAlert: function (c, d, e, g) {
if (typeof a.fn.alert === "function") {
var f = a('<div class="pweb-alert alert alert-block ' + (d ? "alert-" + d : "") + ' fade in"><button data-dismiss="alert" class="close" type="button">×</button>' + (typeof e !== "undefined" ? '<h4 class="alert-heading">' + e + "</h4>" : "") + "<p>" + c + "</p></div>").alert().appendTo(document.body);
if ((typeof g === "undefined" || g) && this.options.msgCloseDelay) {
setTimeout(function () {
f.alert("close")
}, this.options.msgCloseDelay * 1000)
}
} else {
f(c.replace("<br>", "\r\n"))
}
}, debug: function (c, d) {
if (a.isArray(c)) {
c = c.join("<br>")
}
if (typeof d !== "undefined") {
c = c + "<br>Response code: " + d
}
this.displayAlert(c, "info", "Perfect Popup Box", false)
}}
})();
pwebBox.options = pwebBox.prototype.options
})(window.jQuery);