/wp-content/themes/mymaxiskirt/js/avia.js
https://bitbucket.org/sanders_nick/my-maxi-skirt · JavaScript · 2573 lines · 1794 code · 590 blank · 189 comment · 324 complexity · 0c54c222124c598d180742ac97f3d974 MD5 · raw file
Large files are truncated click here to view the full file
- /* this prevents dom flickering, needs to be outside of dom.ready event: */
- document.documentElement.className += 'js_active';
- /*end dom flickering =) */
- //global path: avia_framework_globals.installedAt
- jQuery.noConflict();
- jQuery(document).ready(function(){
- //browser class jquery
- add_browser_class();
- //activates the mega menu javascript
- if(jQuery.fn.aviaMegamenu)
- jQuery(".main_menu .menu").aviaMegamenu({modify_position:true});
-
- //activates the slideshow
- if(jQuery.fn.avia_ajax_portfolio)
- jQuery('.ajax_portfolio_container').avia_ajax_portfolio();
-
- // actiavte portfolio sorting
- if(jQuery.fn.avia_iso_sort)
- jQuery('.portfolio-sort-container').avia_iso_sort();
-
- // improves comment forms
- if(jQuery.fn.kriesi_empty_input)
- jQuery('#s, #search-fail input, .textwidget input, .widget_product_search input').kriesi_empty_input();
-
-
- // improves menu for mobile devices
- jQuery('.responsive .main_menu ul:eq(0)').mobileMenu({
- switchWidth: 768, //width (in px to switch at)
- topOptionText: jQuery('.main_menu').data('selectname'), //first option text
- indentString: ' ' //string for indenting nested items
- });
-
- // enhances contact form with ajax capabilities
- if(jQuery.fn.kriesi_ajax_form)
- jQuery('.ajax_form').kriesi_ajax_form();
-
-
-
- //smooth scrooling
- if(jQuery.fn.avia_smoothscroll)
- jQuery('a[href*=#]').avia_smoothscroll();
-
- //keep ratio of elements
- if(jQuery.fn.avia_ratio)
- jQuery(".avia_keep_ratio").avia_ratio();
-
- //fancy buttons
- if(jQuery.fn.avia_fancy_buttons)
- jQuery(".social_bookmarks li").avia_fancy_buttons({target:'a'});
-
- //fixed menu header
- if(jQuery.fn.avia_fixed_header)
- jQuery("body").avia_fixed_header();
-
-
- avia_ajax_call();
-
- avia_slideshow_caption_click();
-
-
- });
- // all functions within the avia_ajax_call function will be executed once the dynamic ajax portfolio has loaded
- function avia_ajax_call(container)
- {
- if(typeof container == 'undefined'){ container = 'body';};
- //activates the slideshow
- if(jQuery.fn.aviapoly)
- jQuery('.slideshow', container).aviapoly();
- jQuery('#slideshow_big .slideshow, .post-entry-type-gallery .slideshow', container).avia_base_control_hide();
-
- //activates the slideshow
- if(jQuery.fn.avia_external_controls)
- jQuery('.slide_container_big_thumbs', container).avia_external_controls();
-
- //activates the keyboard controlls
- if(jQuery.fn.avia_keyboard_controls)
- jQuery('.slideshow_container', container).avia_keyboard_controls();
-
- //activates the prettyphoto lightbox
- if(jQuery.fn.avia_activate_lightbox)
- jQuery(container).avia_activate_lightbox();
-
- //activates the hover effect for image links
- if(jQuery.fn.avia_activate_hover_effect)
- jQuery(container).avia_activate_hover_effect();
-
- //activates the shortcode content slider
- if(jQuery.fn.avia_sc_slider)
- jQuery(".content_slider", container).avia_sc_slider({appendControlls:{}});
-
- //activates the toggle shortcode
- if(jQuery.fn.avia_sc_toggle)
- jQuery('.togglecontainer', container).avia_sc_toggle();
-
- //activates the tabs shortcode
- if(jQuery.fn.avia_sc_tabs)
- {
- jQuery('.tabcontainer', container).avia_sc_tabs();
- jQuery('.sidebar_tabcontainer', container).avia_sc_tabs({heading: '.sidebar_tab', content:'.sidebar_tab_content', active:'sidebar_active_tab', sidebar:true});
- }
-
- if(jQuery.fn.hoverdir && jQuery('html').is('.csstransforms'))
- {
- var checkMobile = document.documentElement.ontouchstart !== undefined ? true : false;
-
- if(!checkMobile)
- {
- jQuery('.slideshow li:not(#slideshow_big .slideshow li)', container).hoverdir();
- }
- }
-
- avia_small_fixes(container);
- }
- function avia_slideshow_caption_click()
- {
- var body_tag = jQuery('body');
- body_tag.on('mouseenter', '.slideshow .container', function()
- {
- var container = jQuery(this),
- link_inner = container.prev('.slideshow_media_wrap').find('a').addClass('no_overlay');
-
- if(link_inner.length)
- {
- container.addClass('mousePointer');
- }
-
- });
- body_tag.on('click', '.slideshow .container', function(e)
- {
- if(!jQuery(e.srcElement).is('a')){
- jQuery(this).prev('.slideshow_media_wrap').find('a').trigger('click');
- }
- });
- }
- // -------------------------------------------------------------------------------------------
- // Header scroll top
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.fn.avia_fixed_header = function(passed_options)
- {
- var win = $(window),
- menu_header = $('.container_wrap_menu'),
- logo_header = $('.container_wrap_logo'),
- logo_header_height = 0,
- wrap_all_top = parseInt($('#wrap_all').css('margin-top'),10),
- top_pos = parseInt($('html').css('margin-top'),10) ,
- isMobile = 'ontouchstart' in document.documentElement,
- height_tracking = true,
- set_pos = function()
- {
- var st = win.scrollTop(), pos_type = menu_header.css('position');
-
- if(height_tracking || logo_header_height == 0) logo_header_height = logo_header.height();
-
- if (st < logo_header_height +wrap_all_top)
- {
- if(pos_type != 'relative') menu_header.css({position:'relative', top:0});
- }
- else
- {
- if(pos_type != 'fixed') menu_header.css({position:'fixed', top:top_pos});
- }
- };
-
-
- //dont apply fixed headers to mobile devices, because of small screen and poor handling of css "fixed" position
- if(!isMobile)
- {
- win.scroll(set_pos);
- set_pos();
- setTimeout(function(){height_tracking = false;}, 10000)
- }
- };
- })(jQuery);
-
-
- // -------------------------------------------------------------------------------------------
- // fancy hover effect
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.avia_utilities = $.avia_utilities || {};
- $.fn.avia_fancy_buttons = function(passed_options)
- {
- var win = $(window),
- defaults =
- {
- target: false,
- copy_img: true
- },
-
- options = $.extend({}, defaults, passed_options);
-
- return this.each(function()
- {
- //check if the browser supports element rotation
- if(!$.avia_utilities.supports('transition', ['Khtml', 'Ms','Moz','Webkit'])) { return false; }
-
- var buttons = $(this),
- current = false,
- target = false,
- html = "<span class='css_3_hover'></span>",
- effect = false;
-
- buttons.each(function()
- {
- current = $(this).addClass('css_3_hover_container');
- target = options.target ? current.find(options.target) : current;
- effect = $(html).appendTo(current);
-
- //fix the default hover color
- target.css('background-color', target.css('background-color'));
-
- if(options.copy_img)
- {
- effect.css('background-position', target.css('background-position'));
- effect.css('background-image', target.css('background-image'));
- }
- });
-
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Avia AJAX Portfolio
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.avia_utilities = $.avia_utilities || {};
-
- $.fn.avia_ajax_portfolio = function(passed_options)
- {
- var win = $(window),
- isMobile = document.documentElement.ontouchstart !== undefined ? true : false,
- defaults =
- {
- open_wrap: '.portfolio-details',
- open_in: '.portfolio-details-inner',
- items: '.portfolio-sort-container',
- easing: 'easeOutQuint',
- timing: 800,
- transition: 'slide' // 'fade' or 'slide'
- },
-
- options = $.extend({}, defaults, passed_options);
-
- return this.each(function()
- {
- var container = $(this),
- target_wrap = container.find(options.open_wrap),
- target_container = container.find(options.open_in),
- item_container = container.find(options.items),
- items = item_container.find('.post-entry'),
- content_retrieved = {},
- is_open = false,
- animating = false,
- index_open = false,
- ajax_call = false,
- methods,
- controls,
- loader = $.avia_utilities.loading();
-
- methods =
- {
- load_item: function()
- {
- if(animating == true) return false;
- animating = true;
-
- var link = $(this),
- post_container = link.parents('.post-entry:eq(0)'),
- post_id = "ID_" + post_container.data('ajax-id'),
- clickedIndex = items.index(post_container);
-
- //check if current item is the clicked item or if we are currently animating
- if(post_id === is_open)
- {
- return false;
- }
-
- item_container.find('.active_portfolio_item').removeClass('active_portfolio_item');
- post_container.addClass('active_portfolio_item');
- loader.show();
-
- methods.ajax_get_contents(post_id, clickedIndex);
- return false;
- },
-
- scroll_top: function()
- {
- var target_offset = container.offset().top - 100,
- window_offset = win.scrollTop();
-
- if(window_offset > target_offset || target_offset - window_offset > 100 )
- {
- $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target_offset }, options.timing, options.easing);
- }
- },
-
- attach_item: function(post_id)
- {
- content_retrieved[post_id] = $(content_retrieved[post_id]).appendTo(target_container);
- ajax_call = true;
- },
-
- remove_video: function()
- {
- var del = container.find('iframe, .avia_video').parents('.ajax_slide:not(.open_slide)');
- if(del.length > 0)
- {
- del.remove();
- content_retrieved["ID_" + del.data('slideId')] = undefined;
- }
- },
-
- show_item: function(post_id, clickedIndex)
- {
-
- //check if current item is the clicked item or if we are currently animating
- if(post_id === is_open)
- {
- return false;
- }
- animating = true;
- methods.scroll_top();
-
- loader.hide();
-
- if(false === is_open)
- {
- target_wrap.addClass('open_container');
- content_retrieved[post_id].addClass('open_slide');
- target_wrap.css({display:'none'}).slideDown(options.timing, options.easing, function()
- {
- if(ajax_call){ avia_ajax_call(content_retrieved[post_id]); ajax_call = false; }
- methods.remove_video();
- });
-
- index_open = clickedIndex;
- is_open = post_id;
- animating = false;
-
- }
- else
- {
- var initCSS = { zIndex:3 },
- easing = options.easing;
-
- if(index_open > clickedIndex) { initCSS.left = '-110%'; }
- if(options.transition === 'fade'){ initCSS.left = '0%'; initCSS.opacity = 0; easing = 'easeOutQuad'; }
-
- //fixate height for container during animation
- target_container.height(target_container.height()); //outerHeight = border problems?
-
- content_retrieved[post_id].css(initCSS).avia_animate({'left':"0%", opacity:1}, options.timing, easing);
- content_retrieved[is_open].avia_animate({opacity:0}, options.timing, easing, function()
- {
- content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
- content_retrieved[post_id].addClass('open_slide');
-
- target_container.avia_animate({height: content_retrieved[post_id].outerHeight()}, options.timing/2, options.easing, function()
- {
- target_container.attr({'style':""});
- is_open = post_id;
- index_open = clickedIndex;
- animating = false;
-
- methods.remove_video();
- if(ajax_call){ avia_ajax_call(content_retrieved[post_id]); ajax_call = false; }
-
- });
-
- });
- }
- },
-
- ajax_get_contents: function(post_id, clickedIndex)
- {
- if(content_retrieved[post_id] !== undefined)
- {
- methods.show_item(post_id, clickedIndex);
- return;
- }
-
- var url_params = methods.getUrlVars(), add_params = "";
- if(typeof url_params.style == "string") add_params = "&style=" + url_params.style
-
-
- $.ajax({
- url: avia_framework_globals.ajaxurl,
- type: "POST",
- data: "action=avia_check_portfolio&avia_ajax_request="+post_id.replace(/ID_/,"")+add_params,
- beforeSend: function()
- {
-
- },
- success: function(msg)
- {
- content_retrieved[post_id] = msg;
- methods.attach_item(post_id);
- setTimeout(function(){ methods.show_item(post_id, clickedIndex); },10);
- },
- error: function()
- {
- loader.hide();
- }
- });
- },
-
- add_controls: function()
- {
- controls = $('<div class="ajax_controlls"><a href="#prev" class="ajax_previous">-</a><a href="#next" class="ajax_next">+</a><a class="avia_close" href="#close">x</a></div>').appendTo(target_wrap);
- target_wrap.avia_keyboard_controls({27:'.avia_close', 37:'.ajax_previous', 39:'.ajax_next'});
- //target_wrap.avia_swipe_trigger({prev:'.ajax_previous', next:'.ajax_next'});
-
- items.each(function(){
-
- var current = $(this), overlay;
-
- current.addClass('no_combo').bind('click', function(event)
- {
- overlay = current.find('.slideshow_overlay');
-
- if(overlay.length)
- {
- event.stopPropagation();
- methods.load_item.apply(current.find('a:eq(0)'));
- return false;
- }
- });
-
-
- });
- },
-
- control_click: function()
- {
- var showItem,
- activeID = item_container.find('.active_portfolio_item').data('ajax-id'),
- active = item_container.find('.post-entry-'+activeID);
-
- switch(this.hash)
- {
- case '#next':
-
- showItem = active.nextAll('.post-entry:not(.isotope-hidden):eq(0)').find('a:eq(0)');
- if(!showItem.length) { showItem = $('.post-entry:not(.isotope-hidden):eq(0)', container).find('a:eq(0)'); }
- showItem.trigger('click');
-
- break;
- case '#prev':
-
- showItem = active.prevAll('.post-entry:not(.isotope-hidden):eq(0)').find('a:eq(0)');
- if(!showItem.length) { showItem = $('.post-entry:not(.isotope-hidden):last', container).find('a:eq(0)'); }
- showItem.trigger('click');
-
- break;
- case '#close':
-
- animating = true;
-
- target_wrap.slideUp( options.timing, options.easing, function()
- {
- item_container.find('.active_portfolio_item').removeClass('active_portfolio_item');
- content_retrieved[is_open].attr({'style':""}).removeClass('open_slide');
- target_wrap.removeClass('open_container');
- animating = is_open = index_open = false;
- methods.remove_video();
- });
-
- break;
- }
- return false;
- },
-
- getUrlVars: function() {
- var vars = {};
- var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
- vars[key] = value;
- });
- return vars;
- },
-
- resize_reset: function()
- {
- if(is_open === false)
- {
- target_container.html('');
- content_retrieved = [];
- }
- }
- };
-
- methods.add_controls();
-
- item_container.on("click", "a", methods.load_item);
- controls.on("click", "a", methods.control_click);
- if(jQuery.support.leadingWhitespace) { win.bind('smartresize', methods.resize_reset); }
-
- });
- };
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- // Avia AJAX Sorting
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
-
- $.fn.avia_iso_sort = function(options)
- {
-
- $.extend( $.Isotope.prototype, {
- _customModeReset : function() {
-
- this.fitRows = {
- x : 0,
- y : 0,
- height : 0
- };
-
- },
- _customModeLayout : function( $elems ) {
-
- var instance = this,
- containerWidth = this.element.width(),
- props = this.fitRows,
- margin = 0,//(containerWidth / 100) * 4, //margin based on %
- extraRange = 2; // adds a little range for % based calculation error in some browsers
-
- $elems.each( function() {
- var $this = $(this),
- atomW = $this.outerWidth() ,
- atomH = $this.outerHeight(true);
-
- if ( props.x !== 0 && atomW + props.x > containerWidth + extraRange ) {
- // if this element cannot fit in the current row
- props.x = 0;
- props.y = props.height;
- }
-
- //webkit gets blurry elements if position is a float value
- props.x = Math.round(props.x);
- props.y = Math.round(props.y);
-
- // position the atom
- instance._pushPosition( $this, props.x, props.y );
-
- props.height = Math.max( props.y + atomH, props.height );
- props.x += atomW + margin;
-
-
- });
-
- },
- _customModeGetContainerSize : function() {
-
- return { height : this.fitRows.height };
-
- },
- _customModeResizeChanged : function() {
-
- return true;
-
- }
- });
-
-
- return this.each(function()
- {
-
- var container = $(this),
- parentContainer = container.parents('.portfolio-wrap'),
- filter = parentContainer.prev('.sort_width_container').find('#js_sort_items').css({visibility:"visible", opacity:0}),
- links = filter.find('a'),
- isoActive = false,
- items = $('.post-entry', container);
-
- function applyIso()
- {
- container.addClass('isotope_activated').isotope({
- layoutMode : 'customMode', itemSelector : '.flex_column'
- }, function()
- {
- container.css({overflow:'visible'});
- });
-
- isoActive = true;
- setTimeout(function(){ parentContainer.addClass('avia_sortable_active'); }, 0);
- };
-
- links.bind('click',function()
- {
- var current = $(this),
- selector = current.data('filter');
- links.removeClass('active_sort');
- current.addClass('active_sort');
-
- parentContainer.find('.open_container .ajax_controlls .avia_close').trigger('click');
- container.css({overflow:'hidden'}).isotope({ layoutMode : 'customMode', itemSelector : '.flex_column' , filter: '.'+selector}, function()
- {
- container.css({overflow:'visible'});
- });
-
- return false;
- });
-
- // update columnWidth on window resize
- $(window).smartresize(function()
- {
- applyIso();
- });
- $(window).bind('avia_images_loaded', function()
- {
- setTimeout(function()
- {
- filter.animate({opacity:1}, 400);
- applyIso();
-
- }, 900);
-
-
- });
- ///applyIso();
- });
- };
- }(jQuery));
- // -------------------------------------------------------------------------------------------
- // input field improvements
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.kriesi_empty_input = function(options)
- {
- return this.each(function()
- {
- var currentField = $(this);
- currentField.methods =
- {
- startingValue: currentField.val(),
-
- resetValue: function()
- {
- var currentValue = currentField.val();
- if(currentField.methods.startingValue == currentValue) currentField.val('');
- },
-
- restoreValue: function()
- {
- var currentValue = currentField.val();
- if(currentValue == '') currentField.val(currentField.methods.startingValue);
- }
- };
-
- currentField.bind('focus',currentField.methods.resetValue);
- currentField.bind('blur',currentField.methods.restoreValue);
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Ratio function
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict";
- $.fn.avia_ratio = function()
- {
- var win = $(window);
-
- return this.each(function()
- {
- //check if the browser supports element rotation
- var container = $(this),
- height = container.height(),
- width = container.data('imgw'),
- ratio = height/width;
-
- function change_ratio()
- {
- container.height(container.outerWidth() * ratio);
- }
-
- change_ratio();
- win.bind('smartresize', change_ratio);
-
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Avia Menu
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.aviaMegamenu = function(variables)
- {
- var defaults =
- {
- modify_position:true,
- delay:300
- };
-
- var options = $.extend(defaults, variables);
-
- return this.each(function()
- {
- var isMobile = 'ontouchstart' in document.documentElement,
- menu = $(this),
- menuItems = menu.find(">li"),
- megaItems = menuItems.find(">div").parent().css({overflow:'hidden'}),
- menuActive = menu.find('>.current-menu-item>a, >.current_page_item>a'),
- dropdownItems = menuItems.find(">ul").parent(),
- parentContainerWidth = menu.parent().width(),
- delayCheck = {},
- mega_open = [];
-
- if(!menuActive.length){ menu.find('.current-menu-ancestor:eq(0) a:eq(0), .current_page_ancestor:eq(0) a:eq(0)').parent().addClass('active-parent-item')}
-
- menuItems.each(function()
- {
- var item = $(this),
- pos = item.position(),
- megaDiv = item.find("div:first").css({opacity:0, display:"none"}),
- normalDropdown = "";
-
- //check if we got a mega menu
- if(!megaDiv.length)
- {
- normalDropdown = item.find(">ul").css({display:"none"});
- }
-
- //if we got a mega menu or dropdown menu add the arrow beside the menu item
- if(megaDiv.length || normalDropdown.length)
- {
- var link = item.addClass('dropdown_ul_available').find('>a');
- link.html("<span class='dropdown_link'>"+link.html()+"</span>").append('<span class="dropdown_available"></span>');
- //is a mega menu main item doesnt have a link to click use the default cursor
- if(typeof link.attr('href') != 'string' || link.attr('href') == "#"){ link.css('cursor','default').click(function(){return false;}); }
- }
-
- //correct position of mega menus
- if(options.modify_position && megaDiv.length)
- {
- if(megaDiv.width() > pos.left)
- {
- megaDiv.css({left: (pos.left* -1)});
- //megaDiv.css({left: (Math.ceil() * -1)});
- }
- else if(pos.left + megaDiv.width() > parentContainerWidth)
- {
- megaDiv.css({left: (megaDiv.width() - pos.left) * -1 });
- }
- }
-
- });
-
-
- function megaDivShow(i)
- {
- if(delayCheck[i] == true)
- {
- var item = megaItems.filter(':eq('+i+')').css({overflow:'visible'}).find("div:first"),
- link = megaItems.filter(':eq('+i+')').find("a:first");
- mega_open["check"+i] = true;
-
- item.stop().css('display','block').animate({opacity:1},300);
-
- if(item.length)
- {
- link.addClass('open-mega-a');
- }
- }
- }
-
- function megaDivHide (i)
- {
- if(delayCheck[i] == false)
- {
- megaItems.filter(':eq('+i+')').find(">a").removeClass('open-mega-a');
-
- var listItem = megaItems.filter(':eq('+i+')'),
- item = listItem.find("div:first");
-
-
- item.stop().css('display','block').animate({opacity:0},300, function()
- {
- $(this).css('display','none');
- listItem.css({overflow:'hidden'});
- mega_open["check"+i] = false;
- });
- }
- }
- if(isMobile)
- {
- megaItems.each(function(i){
-
- $(this).bind('click', function()
- {
- if(mega_open["check"+i] != true) return false;
- });
- });
- }
- //bind event for mega menu
- megaItems.each(function(i){
-
- $(this).hover(
-
- function()
- {
- delayCheck[i] = true;
- setTimeout(function(){megaDivShow(i); },options.delay);
- },
-
- function()
- {
- delayCheck[i] = false;
- setTimeout(function(){megaDivHide(i); },options.delay);
- }
- );
- });
-
-
- // bind events for dropdown menu
- dropdownItems.find('li').andSelf().each(function()
- {
- var currentItem = $(this),
- sublist = currentItem.find('ul:first'),
- showList = false;
-
- if(sublist.length)
- {
- sublist.css({display:'block', opacity:0, visibility:'hidden'});
- var currentLink = currentItem.find('>a');
-
- currentLink.bind('mouseenter', function()
- {
- sublist.stop().css({visibility:'visible'}).animate({opacity:1});
- });
-
- currentItem.bind('mouseleave', function()
- {
- sublist.stop().animate({opacity:0}, function()
- {
- sublist.css({visibility:'hidden'});
- });
- });
- }
-
- });
-
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Tab shortcode javascript
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- "use strict"
-
- $.fn.avia_sc_tabs= function(options)
- {
- var defaults =
- {
- heading: '.tab',
- content:'.tab_content',
- active:'active_tab',
- sidebar: false
- };
-
- var win = $(window)
- options = $.extend(defaults, options);
-
- return this.each(function()
- {
- var container = $(this),
- tabs = $(options.heading, container),
- content = $(options.content, container),
- initialOpen = 1,
- newtabs = false,
- oldtabs = false;
-
- // sort tabs
-
- if(tabs.length < 2) return;
-
- if(container.is('.tab_initial_open'))
- {
- var myRegexp = /tab_initial_open__(\d+)/;
- var match = myRegexp.exec(container[0].className);
-
- if(match != null && parseInt(match[1]) > 0)
- {
- initialOpen = parseInt(match[1]);
- }
- }
-
- if(!initialOpen || initialOpen > tabs.length) initialOpen = 1;
-
- if(!options.sidebar)
- {
- tabs.prependTo(container);
- }
- else
- {
- var click_container = $("<div class='sidebar_tab_wrap'></div>").prependTo(container), min_height;
-
- newtabs = tabs.clone();
- oldtabs = tabs;
- tabs = newtabs;
- tabs.prependTo(click_container);
- var sidebar_shadow = $("<span class='sidebar_tab_shadow'></span>").prependTo(click_container);
- set_size(click_container, sidebar_shadow);
-
- win.smartresize(function(){ set_size(click_container, sidebar_shadow); });
- }
-
- tabs.each(function(i)
- {
- var tab = $(this), the_oldtab = false;
-
- if(newtabs) the_oldtab = oldtabs.filter(':eq('+i+')');
-
- //set default tab to open
- if(initialOpen == (i+1))
- {
- open_content(tab, i, the_oldtab);
-
- }
-
- tab.addClass('tab_counter_'+i).bind('click', function()
- {
- open_content(tab, i, the_oldtab);
- return false;
- });
-
- if(newtabs)
- {
-
- the_oldtab.bind('click', function()
- {
- open_content(the_oldtab, i, tab);
- return false;
- });
- }
- });
-
- function set_size(click_container, sidebar_shadow)
- {
- min_height = click_container.outerHeight();
- content.css({'min-height': ( min_height - parseInt(content.css('padding-top'),10) - parseInt(content.css('padding-bottom'),10) - parseInt(content.css('border-top-width'),10) - parseInt(content.css('border-bottom-width'),10) ) });
- sidebar_shadow.height(content.filter('.'+options.active+'_content').outerHeight());
- }
-
-
- function open_content(tab, i, alternate_tab)
- {
- if(!tab.is('.'+options.active))
- {
- $('.'+options.active, container).removeClass(options.active);
- $('.'+options.active+'_content', container).removeClass(options.active+'_content');
-
- tab.addClass(options.active);
- setTimeout(function(){avia_small_fixes($('.'+options.active+'_content', container));},10);
-
- if(alternate_tab) alternate_tab.addClass(options.active);
- var active_c = content.filter(':eq('+i+')').addClass(options.active+'_content');
-
- if(typeof click_container != 'undefined' && click_container.length)
- {
- sidebar_shadow.height(active_c.outerHeight());
- }
- }
- }
-
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Toggle shortcode javascript
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_sc_toggle = function(options)
- {
- var defaults =
- {
- heading: '.toggler',
- content: '.toggle_wrap'
- };
-
- var options = $.extend(defaults, options);
-
- return this.each(function()
- {
- var container = $(this),
- heading = $(options.heading, container),
- allContent = $(options.content, container),
- initialOpen = '';
-
- //check if the container has the class toggle initial open.
- // if thats the case extract the number from the following class and open that toggle
- if(container.is('.toggle_initial_open'))
- {
- var myRegexp = /toggle_initial_open__(\d+)/;
- var match = myRegexp.exec(container[0].className);
-
- if(match != null && parseInt(match[1]) > 0)
- {
- initialOpen = parseInt(match[1]);
- }
- }
-
- heading.each(function(i)
- {
- var thisheading = $(this),
- content = thisheading.next(options.content, container);
-
- if(initialOpen == (i+1)) { content.css({display:'block'}); setTimeout(function(){avia_small_fixes(content);},10); }
-
-
- if(content.is(':visible'))
- {
- thisheading.addClass('activeTitle');
- }
-
- thisheading.bind('click', function()
- {
- if(content.is(':visible'))
- {
- content.slideUp(300);
- thisheading.removeClass('activeTitle');
-
- }
- else
- {
- if(container.is('.toggle_close_all'))
- {
- allContent.slideUp(300);
- heading.removeClass('activeTitle');
- }
- content.slideDown(300);
- thisheading.addClass('activeTitle');
- avia_small_fixes(content);
- }
- });
- });
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Smooth scrooling when clicking on anchor links
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_smoothscroll = function(variables)
- {
- return this.each(function()
- {
- $(this).click(function() {
-
- var newHash=this.hash;
-
- if(newHash != '' && newHash != '#' && !$(this).is('.comment-reply-link, #cancel-comment-reply-link, .no-scroll'))
- {
- var container = $(this.hash);
-
- if(container.length)
- {
- var target = container.offset().top,
- oldLocation=window.location.href.replace(window.location.hash, ''),
- newLocation=this,
- duration=800,
- easing='easeOutQuint';
-
- // make sure it's the same location
- if(oldLocation+newHash==newLocation)
- {
- // animate to target and set the hash to the window.location after the animation
- $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {
-
- // add new hash to the browser location
- window.location.href=newLocation;
- });
-
- // cancel default click action
- return false;
- }
- }
- }
- });
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Ligthbox activation
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_activate_lightbox = function(variables)
- {
- var defaults =
- {
- autolinkElements: 'a[rel^="prettyPhoto"], a[rel^="lightbox"], a[href$=jpg], a[href$=png], a[href$=gif], a[href$=jpeg], a[href$=".mov"] , a[href$=".swf"] , a[href*="vimeo.com"] , a[href*="youtube.com"] , a[href*="screenr.com"]'
- };
-
- var options = $.extend(defaults, variables),
- win = $(window),
- ww = parseInt(win.width(),10) * 0.8, //controls the default lightbox width: 80% of the window size
- wh = (ww/16)*9; //controls the default lightbox height (16:9 ration for videos. images are resized by the lightbox anyway)
-
-
- return this.each(function()
- {
- var elements = $(options.autolinkElements, this).not('.noLightbox, .noLightbox a'),
- lastParent = "",
- counter = 0;
-
- elements.each(function()
- {
- var el = $(this),
- parentPost = el.parents('.post-entry:eq(0)'),
- group = 'auto_group';
-
- if(parentPost.get(0) != lastParent)
- {
- lastParent = parentPost.get(0);
- counter ++;
- }
-
- if((el.attr('rel') == undefined || el.attr('rel') == '') && !el.hasClass('noLightbox'))
- {
- el.attr('rel','lightbox['+group+counter+']');
- }
- });
-
- if($.fn.prettyPhoto)
- elements.prettyPhoto({ social_tools:'',slideshow: 5000, deeplinking: false, overlay_gallery:false, default_width: ww, default_height: wh });
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // Hover effect activation
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.avia_activate_hover_effect = function(variables)
- {
- var defaults =
- {
- autolinkElements: 'a[rel^="prettyPhoto"], a[rel^="lightbox"], a[href$=jpg], a[href$=png], a[href$=gif], a[href$=jpeg], a[href$=".mov"] , a[href$=".swf"] , a[href*="vimeo.com"] , a[href*="youtube.com"], a.external-link, .avia_mega a, .dynamic_template_columns a, .slideshow a'
- };
-
- var options = $.extend(defaults, variables), css3 = $('html').is('.csstransforms'), opacity_val = 0.8;
-
- return this.each(function()
- {
- if(css3)
- {
- opacity_val = 1;
- }
-
- $(options.autolinkElements, this).not(".noLightbox a").contents('img:not(.filtered-image)').each(function()
- {
- var img = $(this),
- a = img.parent(),
- preload = img.parents('.preloading'),
- $newclass = 'lightbox_video',
- applied= false;
-
-
- if(a.attr('href').match(/(jpg|gif|jpeg|png|tif)/))
- {
- $newclass = 'lightbox_image';
- }
-
- if(a.is('.external-link') || ! a.attr('href').match(/(jpg|gif|jpeg|png|\.tif|\.mov|\.swf|vimeo\.com|youtube\.com)/))
- {
- $newclass = 'external_image';
- }
-
- if(a.is('a'))
- {
- if(img.is('.alignright')) {img.removeClass('alignright'); a.addClass('alignright')}
- if(img.is('.alignleft')) {img.removeClass('alignleft'); a.addClass('alignleft')}
- if(img.css('float') == 'left' || img.css('float') == 'right') {a.css({float:img.css('float')})}
- if(!a.css('position') || a.css('position') == 'static') { a.css({position:'relative', display:'inline-block'}); }
- if(img.is('.aligncenter')) a.css({display:'block'});
- if(img.is('.avia_mega img')) a.css({position:'relative', display:'inline-block'});
- if(img.css('left')) { a.css({left: img.css('left')}); img.css('left', 0); }
- }
-
- var bg = $("<span class='image_overlay_effect'><span class='image_overlay_effect_inside'></span></span>").appendTo(a);
- bg.css({display:'block', zIndex:5, opacity:0});
-
- bg.hover(function()
- {
- if(applied == false && img.css('opacity') > 0.5)
- {
- bg.addClass($newclass);
- applied = true;
- }
-
- bg.stop().animate({opacity:opacity_val},400);
- },
- function()
- {
- bg.stop().animate({opacity:0},400);
- });
-
-
-
- });
- });
- };
- })(jQuery);
- // -------------------------------------------------------------------------------------------
- // small js fixes for pixel perfection :)
- // -------------------------------------------------------------------------------------------
- function avia_small_fixes(container)
- {
- if(!jQuery.support.opacity)
- {
- jQuery('.image_overlay_effect', container).css({'background-image':'none'});
- }
-
- if(jQuery('#slideshow_big').length) { jQuery('body').addClass('js-big-slider'); } else { jQuery('body').addClass('js-big-slider-false'); }
-
-
- setTimeout(function()
- {
- jQuery('.twitter-tweet-rendered', container).attr('style',"");
- }, 500);
-
- var win = jQuery(window),
- iframes = jQuery(' iframe:not(.slideshow iframe):not( iframe.no_resize)', container),
- adjust_iframes = function()
- {
- iframes.each(function(){
-
- var iframe = jQuery(this), frame_parent_w = iframe.parent().width(), proportions = 16/9;
-
- if(this.width && this.height)
- {
- proportions = Math.round(this.width / this.height * 1000) / 1000;
- iframes.css({width:frame_parent_w, height: frame_parent_w / proportions});
- }
-
- });
- };
- adjust_iframes();
- win.smartresize(adjust_iframes);
- }
- // -------------------------------------------------------------------------------------------
- // content slider
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.avia_utilities = $.avia_utilities || {};
- $.fn.avia_sc_slider = function(variables, callback)
- {
-
- return this.each(function()
- {
- var defaults =
- {
- slidePadding: 40,
- appendControlls: {'h1':'pos_h1', 'h2':'pos_h2', 'h3':'pos_h3', 'h4':'pos_h4', 'h5':'pos_h5', 'h6':'pos_h6'},
- controllContainerClass: 'contentSlideControlls',
- transitionDuration: 800, //how fast should images crossfade
- autorotation: true, //autorotation true or false? (this setting gets overwritten by the class autoslide_true and autoslide_false if applied to the container. easier for shortcode management)
- autorotationInterval: 3000, //interval between transition if autorotation is active ()also gets overwritten by autoslidedelay__(number)
- transitionEasing: 'easeOutQuint',
- slide: '.single_slide',
- group: false,
- arrowControll:false
- };
-
- var options = $.extend(defaults, variables);
-
- var container = $(this).css({overflow:'hidden'}),
- optionWrap = container.parent(':eq(0)'),
- slides = $(options.slide, container),
- isMobile = 'ontouchstart' in document.documentElement;
-
- if(!slides.length) { return false; }
-
- if(optionWrap.data('interval')){ options.autorotationInterval = optionWrap.data('interval') * 1000;}
- if(optionWrap.data('interval') === 0) options.autorotation = false;
-
- if(options.group)
- {
- var container_new = $('<div>').addClass(container.attr('class')).css({overflow:'hidden', width:'100%', position:'relative'}).insertAfter(container),
- start = 0,
- end = slides.index(slides.filter('.last:eq(0)'));
-
- if(end === -1) end = slides.length;
-
- var columns = end + 1,
- elements = slides.length,
- subgroup = {};
-
- slides.appendTo(container_new);
-
- for (i = 0; i <= elements; i += columns)
- {
-
- subgroup = slides.slice(i, i + columns);
- if(subgroup.length)
- {
- subgroup.wrapAll('<div class="single_slide"></div>');
- }
- }
-
- slides.each(function()
- {
- var current = $(this);
- current.find('>*').wrapAll('<div class="'+current.attr('class')+'"></div>');
- current.find('>div:eq(0)').insertAfter(current);
- });
-
- //reset values
- slides.remove();
- container.remove();
- container = container_new;
- options.slide = '.single_slide';
- slides = $(options.slide, container);
- }
-
- var slideCount = slides.length,
- firstSlide = slides.filter(':eq(0)'),
- followslides = $(options.slide+':not(:first)', container),
- innerContainer = "",
- innerContainerWidth = (container.width() * slideCount) + (options.slidePadding * slideCount),
- i = 0,
- interval = "",
- controlls = $(),
- arrowControlls = $(),
- nextArrow,
- prevArrow;
-
-
- container.animating = false;
- container.methods =
- {
- resize: function()
- {
- if(!innerContainer) return;
-
- innerContainerWidth = (container.width() * slideCount) + (options.slidePadding * slideCount);
- innerContainer.width(innerContainerWidth);
- slides.width(container.width());
- container.methods.change();
- },
-
- preload: function()
- {
- followslides.css({display:"none"});
-
- if(!slideCount)
- {
- container.methods.init();
- }
- else
- {
- $.avia_utilities.preload({container: container, single_callback: function(){ container.methods.init(); }});
- }
- },
-
- init: function()
- {
-
- if(slideCount > 1)
- {
- $(window).resize(container.methods.resize);
-
- //set container height to match the first slide
- container.height(firstSlide.outerHeight());
-
- //wrap additional container arround slides and align slides within that container
- slides.wrapAll('<div class="inner_slide_container" />').css({float:'left',
- width:container.width(),
- display:'block',
- paddingRight:options.slidePadding
- });
-
- innerContainer = $('.inner_slide_container', container).width(innerContainerWidth);
-
- //attach controll elements
- container.methods.appenControlls();
-
- //start autoslide
- container.methods.autoRotation();
-
- //start autoslide
- //container.methods.activate_touch_control();
-
-
- }
- container.addClass('not_animating_slides');
- slides.filter(':eq(0)').addClass('active_slide');
-
- },
-
- change: function()
- {
- container.animating = true;
- container.removeClass('not_animating_slides');
-
-
- var moveTo = ((-i * container.width()) - (i * options.slidePadding)),
- nextSlide = slides.removeClass('active_slide').filter(':eq('+i+')'),
- nextSlideHeight = nextSlide.outerHeight();
-
- //move inner container
- innerContainer.stop().animate({left: moveTo}, options.transitionDuration, options.transitionEasing, function()
- {
- container.animating = false;
- setTimeout(function(){
- container.addClass('not_animating_slides');
- },10);
-
- nextSlide.addClass('active_slide');
-
- });
-
- //change height of outer container
- container.stop().animate({height: nextSlideHeight}, options.transitionDuration, options.transitionEasing);
-
- //change active state of controlls
- var controllLinks = $('a', controlls);
- controllLinks.removeClass('activeItem');
- controllLinks.filter(':eq('+i+')').addClass('activeItem');
- },
-
- activate_touch_control:function()
- {
- var slider = container;
-
- if(isMobile)
- {
- slider.touchPos = {};
- slider.hasMoved = false;
-
- slider.bind('touchstart', function(event)
- {
- slider.touchPos.X = event.originalEvent.touches[0].clientX;
- slider.touchPos.Y = event.originalEvent.touches[0].clientY;
- });
-
- slider.bind('touchend', function(event)
- {
- slider.touchPos = {};
- if(slider.hasMoved) { event.preventDefault(); }
- slider.hasMoved = false;
- });
-
- slider.bind('touchmove', function(event)
- {
- if(!slider.touchPos.X)
- {
- slider.touchPos.X = event.originalEvent.touches[0].clientX;
- slider.touchPos.Y = event.originalEvent.touches[0].clientY;
- }
- else
- {
- var differenceX = event.originalEvent.touches[0].clientX - slider.touchPos.X;
- var differenceY = event.originalEvent.touches[0].clientY - slider.touchPos.Y;
-
- //check if user is scrolling the window or moving the slider
- if(Math.abs(differenceX) > Math.abs(differenceY))
- {
- event.preventDefault();
-
- if(!slider.animating)
- {
- if(slider.touchPos != event.originalEvent.touches[0].clientX)
- {
- if(Math.abs(differenceX) > 50)
- {
- i = differenceX > 0 ? i - 1 : i + 1;
-
- if(i+1 > slideCount) { i = 0; } else
- if(i < 0) {i = slideCount-1; }
-
- clearInterval(interval);
- container.methods.change();
- slider.touchPos = {};
- slider.hasMoved = true;
- return false;
- }
- }
-
- }
- }
- }
- });
- }
-
- },
-
- setSlideNumber: function(event)
- {
- var stop = false;
-
- if(event)
- {
- clearInterval(interval);
-
- if(event.data.show == 'next') i++;
- if(event.data.show == 'prev') i--;
- if(typeof(event.data.show) == 'number')
- {
- //check if next slide is the same as current slide
- if(i != event.data.show)
- {
- i = event.data.show;
- }
- else
- {
- stop = true;
- }
- }
- }
- else
- {
- i++;
- }
-
- if(i+1 > slideCount) { i = 0; } else
- if(i < 0) {i = slideCount-1; }
-
- if(!stop) // prevents transition if the next slide and the current slide are the same
- {
- container.methods.change();
- }
-
-
- return false;
- },
-
- appenControlls: function()
- {
- //if controlls should be added by javascript and we got more than 1 slide
- if(options.appendControlls && slideCount > 1)
- {
- //check where to position the controll element, depending on the first element within the slide
- var positioningClass = '';
-
- for (var key in options.appendControlls)
- {
- if(!positioningClass)
- {
- if($(':first', firstSlide).is(key))
- {
- positioningClass = options.appendControlls[key];
- }
-
- }
- }
-
-
- //append the controlls
- var firstClass = 'class="activeItem"';
-
- controlls = $('<div></div>').addClass(options.controllContainerClass)
- .addClass(positioningClass)
- .css({visibility:'hidden', opacity:0});
-
- if(positioningClass)
- {
- controlls.appendTo(container);
- }
- else
- {
- controlls.insertAfter(container);
- }
-
- slides.each(function(i)
- {
- var link = $('<a '+firstClass+' href="#">'+(i+1)+'</a>').appendTo(controlls); firstClass = "";
- link.bind('click', {show: i}, container.methods.setSlideNumber);
- });
-
- controlls.css({visibility:'visible', opacity:0}).animate({opacity:0.7},400);
- }
-
- //add arrow Controlls
- if(options.arrowControll && slideCount > 1)
- {
- arrowControlls = $('<div class="arrow_container"></div>');
- nextArrow = $('<a class="arrow_controll arrow_controll_next" href="#next">+</a>').appendTo(arrowControlls).bind('click', {show: 'next'}, container.methods.setSlideNumber).css({visibility:'visible', opacity:0});
- prevArrow = $('<a class="arrow_controll arrow_controll_prev" href="#prev">-</a>').appendTo(arrowControlls).bind('click', {show: 'prev'}, container.methods.setSlideNumber).css({visibility:'visible', opacity:0});
- }
-
- if(positioningClass)
- {
- arrowControlls.appendTo(container);
- }
- else
- {
- arrowControlls.insertAfter(container);
- }
-
- if(!isMobile)
- {
- arrowControlls.parent().hover(function()
- {
- prevArrow.stop().animate({opacity:0.7},400);
- nextArrow.stop().animate({opacity:0.7},400);
- },
- function()
- {
- prevArrow.stop().animate({opacity:0},400)
- nextArrow.stop().animate({opacity:0},400)
- });
- }
-
-
- },
-
- autoRotation: function()
- {
-
- if(container.is('.autoslide_true'))
- {
- options.autorotation = true;
-
- var myRegexp = /autoslidedelay__(\d+)/g;
- var match = myRegexp.exec(container[0].className);
-
- if(parseInt(match[1]) > 0)
- {
- options.autorotationInterval = parseInt(match[1]) * 1000;
- }
-
-
- }
- else if(container.is('.autoslide_false'))
- {
- options.autorotation = false;
- }
-
-
- if(options.autorotation)
- {
- interval = setInterval(function()
- {
- container.methods.setSlideNumber();
- },
- options.autorotationInterval);
- }
- }
- };
-
-
- container.methods.preload();
-
- });
- };
- })(jQuery);
-
- // -------------------------------------------------------------------------------------------
- // contact form ajax improvements
- // -------------------------------------------------------------------------------------------
- (function($)
- {
- $.fn.kriesi_ajax_form = function(variables)
- {
- var defaults =
- {
- sendPath: 'send.php',
- responseContainer: '#ajaxresponse'
- };
-
- var options = $.extend(defaults, variables);
-
- return this.each(function()
- {
- var form = $(this),
- form_sent = false,
- send =
- {
- formElements: form.find('textarea, select, input[type=text], input[type=checkbox], input[type=hidden]'),
- validationError:false,
- button : form.find('input:submit'),
- dataObj : {}
- };
-
- responseContainer = $(options.responseContainer+":eq(0)");
-
- send.button.bind('click', checkElements);
-
- function send_ajax_form()
- {
- if(form_sent){ return false; }
-
- form_sent = true;
- send.button.fadeOut(300);
-
- responseContainer.load(form.attr('action')+' '+options.responseContainer, send.dataObj, function()
- {
- responseContainer.find('.hidden').css({display:"block"});
- form.slideUp(400, function(){responseContainer.slideDown(400); send.formElements.val('');});
- });
-
-
- }
-
- function checkElements()
- {
- // reset validation var and send data
- send.validationError = false;
- send.datastring = 'ajax=true';
-
- send.formElements.each(function(i)
- {
- var currentElement = $(this),
- surroundingElement = currentElement.parent(),
- va…