/* Author: Armin Solecki * Options: * action (open/close) * size (small/medium/large) max-width of popUpWindow * modal true/false * buttons * onClose */ (function ($, window, document, undefined) { // Create the defaults var pluginName = 'popUpWindow', defaults = { action: "open", size: "large", modal: false }; function Plugin(element, options) { this.element = element; this.options = $.extend({}, defaults, options); this._defaults = defaults; this._name = pluginName; this.init(); } Plugin.prototype = { uniqueID: "pop-up-id-1", init: function () { var instance = this; //Generate random id var uniqueNumber = Math.floor(Math.random() * 10000), hasButtons = $.isArray(this.options.buttons) && this.options.buttons.length; this.uniqueID = "pop-up-id-" + uniqueNumber; var popUp = $('
'); //Close link click event var closeLink = $('Close').click(function (e) { e.preventDefault(); instance.close(instance.element, instance.options); }); $('.close', popUp).append(closeLink); // create the background cover var bgCover = $('').appendTo('body'); //Background click event if (!instance.options.modal) { bgCover.click(function (e) { e.preventDefault(); instance.close(instance.element, instance.options); }); } else { bgCover.addClass("pop-up-background-modal"); } //Create buttons if (hasButtons) { $.each(this.options.buttons, function (index, item) { var icon = item.icon ? '' : ""; var showText = item.iconOnly ? "screen-reader-text" : ""; var cssClass = item.cssClass || "pop-up-btn"; var button = $('' + icon + '' + item.text + '').click(function (e) { e.preventDefault(); // do the click, but set the context as the popup instance, going to pass through the button as a parameter item.click && item.click.apply(instance, [this]); }); $('.pop-up-footer', popUp).append(button); }); } //Place content into pop-up body var element = $(this.element).removeClass('pop-up-display-content'); $('.pop-up-main-content', popUp).append(element); //Append pop-up to body popUp.appendTo('body'); //Open pop-up this.open(this.element, this.options); }, //Opens pop-up open: function (el, options) { //console.log("Open"); var popUpObject = $('*[data-pop-up-id="' + this.uniqueID + '"]'); window.marginTop = $('body').scrollTop() > $('html').scrollTop() ? $('body').scrollTop() : $('html').scrollTop(); // android position absolute bug fix (http://code.google.com/p/android/issues/detail?id=6721) // var isAndroid = navigator.userAgent.indexOf("Android"); var isAndroid = 0; if (isAndroid > 0) { $('.page-wrapper').hide(); popUpObject.show().css({ visibility: "visible" }); $('html, body').scrollTop(0); } else { popUpObject .removeClass("pop-up-fit-screen") .css({ display: "block", visibility: "hidden", top: "" }) .find(".pop-up-content-scroller").height(""); //Position pop-up in center of screen var windowSize = $(window).height(); var contentSize = popUpObject.outerHeight(); if (windowSize > contentSize) { var contentOffset = Math.round(windowSize / 2) - Math.round(contentSize / 2); popUpObject.css("top", window.marginTop + contentOffset + "px"); } else { popUpObject.css("top", window.marginTop + 20 + "px"); } popUpObject.css({ display: "none", visibility: "visible" }).fadeIn(300); $('*[data-pop-up-background-id="' + this.uniqueID + '"]').fadeIn(300); } $.isFunction(options.onOpen) && options.onOpen.call(el); }, //Closes pop-up close: function (el, options) { //console.log("Close"); $(".pop-up-background").fadeOut(300); $(".pop-up").fadeOut(300); $('.page-wrapper').show(); $('html, body').scrollTop(window.marginTop); $.isFunction(this.options.onClose) && this.options.onClose.call(el); } }; $.fn[pluginName] = function (options) { return this.each(function () { if (!$.data(this, 'plugin_' + pluginName)) { $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); } else { var pluginInstance = $.data(this, 'plugin_' + pluginName); switch (options.action) { case "open": return pluginInstance.open(this, options); case "close": return pluginInstance.close(this, options); default: return pluginInstance.open(this, options); } } }); }; })(jQuery, window, document); "function"!==typeof Object.create&&(Object.create=function(f){function g(){}g.prototype=f;return new g}); (function(f,g,k){var l={init:function(a,b){this.$elem=f(b);this.options=f.extend({},f.fn.owlCarousel.options,this.$elem.data(),a);this.userOptions=a;this.loadContent()},loadContent:function(){function a(a){var d,e="";if("function"===typeof b.options.jsonSuccess)b.options.jsonSuccess.apply(this,[a]);else{for(d in a.owl)a.owl.hasOwnProperty(d)&&(e+=a.owl[d].item);b.$elem.html(e)}b.logIn()}var b=this,e;"function"===typeof b.options.beforeInit&&b.options.beforeInit.apply(this,[b.$elem]);"string"===typeof b.options.jsonPath? (e=b.options.jsonPath,f.getJSON(e,a)):b.logIn()},logIn:function(){this.$elem.data("owl-originalStyles",this.$elem.attr("style"));this.$elem.data("owl-originalClasses",this.$elem.attr("class"));this.$elem.css({opacity:0});this.orignalItems=this.options.items;this.checkBrowser();this.wrapperWidth=0;this.checkVisible=null;this.setVars()},setVars:function(){if(0===this.$elem.children().length)return!1;this.baseClass();this.eventTypes();this.$userItems=this.$elem.children();this.itemsAmount=this.$userItems.length; this.wrapItems();this.$owlItems=this.$elem.find(".owl-item");this.$owlWrapper=this.$elem.find(".owl-wrapper");this.playDirection="next";this.prevItem=0;this.prevArr=[0];this.currentItem=0;this.customEvents();this.onStartup()},onStartup:function(){this.updateItems();this.calculateAll();this.buildControls();this.updateControls();this.response();this.moveEvents();this.stopOnHover();this.owlStatus();!1!==this.options.transitionStyle&&this.transitionTypes(this.options.transitionStyle);!0===this.options.autoPlay&& (this.options.autoPlay=5E3);this.play();this.$elem.find(".owl-wrapper").css("display","block");this.$elem.is(":visible")?this.$elem.css("opacity",1):this.watchVisibility();this.onstartup=!1;this.eachMoveUpdate();"function"===typeof this.options.afterInit&&this.options.afterInit.apply(this,[this.$elem])},eachMoveUpdate:function(){!0===this.options.lazyLoad&&this.lazyLoad();!0===this.options.autoHeight&&this.autoHeight();this.onVisibleItems();"function"===typeof this.options.afterAction&&this.options.afterAction.apply(this, [this.$elem])},updateVars:function(){"function"===typeof this.options.beforeUpdate&&this.options.beforeUpdate.apply(this,[this.$elem]);this.watchVisibility();this.updateItems();this.calculateAll();this.updatePosition();this.updateControls();this.eachMoveUpdate();"function"===typeof this.options.afterUpdate&&this.options.afterUpdate.apply(this,[this.$elem])},reload:function(){var a=this;g.setTimeout(function(){a.updateVars()},0)},watchVisibility:function(){var a=this;if(!1===a.$elem.is(":visible"))a.$elem.css({opacity:0}), g.clearInterval(a.autoPlayInterval),g.clearInterval(a.checkVisible);else return!1;a.checkVisible=g.setInterval(function(){a.$elem.is(":visible")&&(a.reload(),a.$elem.animate({opacity:1},200),g.clearInterval(a.checkVisible))},500)},wrapItems:function(){this.$userItems.wrapAll('