( function( window, undefined ) {
"use strict";
/**
* Handles managing all events for whatever you plug it into. Priorities for hooks are based on lowest to highest in
* that, lowest priority hooks are fired first.
*/
var EventManager = function() {
/**
* Maintain a reference to the object scope so our public methods never get confusing.
*/
var MethodsAvailable = {
removeFilter : removeFilter,
applyFilters : applyFilters,
addFilter : addFilter,
removeAction : removeAction,
doAction : doAction,
addAction : addAction
};
/**
* Contains the hooks that get registered with this EventManager. The array for storage utilizes a "flat"
* object literal such that looking up the hook utilizes the native object literal hash.
*/
var STORAGE = {
actions : {},
filters : {}
};
/**
* Adds an action to the event manager.
*
* @param action Must contain namespace.identifier
* @param callback Must be a valid callback function before this action is added
* @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
* @param [context] Supply a value to be used for this
*/
function addAction( action, callback, priority, context ) {
if( typeof action === 'string' && typeof callback === 'function' ) {
priority = parseInt( ( priority || 10 ), 10 );
_addHook( 'actions', action, callback, priority, context );
}
return MethodsAvailable;
}
/**
* Performs an action if it exists. You can pass as many arguments as you want to this function; the only rule is
* that the first argument must always be the action.
*/
function doAction( /* action, arg1, arg2, ... */ ) {
var args = Array.prototype.slice.call( arguments );
var action = args.shift();
if( typeof action === 'string' ) {
_runHook( 'actions', action, args );
}
return MethodsAvailable;
}
/**
* Removes the specified action if it contains a namespace.identifier & exists.
*
* @param action The action to remove
* @param [callback] Callback function to remove
*/
function removeAction( action, callback ) {
if( typeof action === 'string' ) {
_removeHook( 'actions', action, callback );
}
return MethodsAvailable;
}
/**
* Adds a filter to the event manager.
*
* @param filter Must contain namespace.identifier
* @param callback Must be a valid callback function before this action is added
* @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
* @param [context] Supply a value to be used for this
*/
function addFilter( filter, callback, priority, context ) {
if( typeof filter === 'string' && typeof callback === 'function' ) {
priority = parseInt( ( priority || 10 ), 10 );
_addHook( 'filters', filter, callback, priority, context );
}
return MethodsAvailable;
}
/**
* Performs a filter if it exists. You should only ever pass 1 argument to be filtered. The only rule is that
* the first argument must always be the filter.
*/
function applyFilters( /* filter, filtered arg, arg2, ... */ ) {
var args = Array.prototype.slice.call( arguments );
var filter = args.shift();
if( typeof filter === 'string' ) {
return _runHook( 'filters', filter, args );
}
return MethodsAvailable;
}
/**
* Removes the specified filter if it contains a namespace.identifier & exists.
*
* @param filter The action to remove
* @param [callback] Callback function to remove
*/
function removeFilter( filter, callback ) {
if( typeof filter === 'string') {
_removeHook( 'filters', filter, callback );
}
return MethodsAvailable;
}
/**
* Removes the specified hook by resetting the value of it.
*
* @param type Type of hook, either 'actions' or 'filters'
* @param hook The hook (namespace.identifier) to remove
* @private
*/
function _removeHook( type, hook, callback, context ) {
if ( !STORAGE[ type ][ hook ] ) {
return;
}
if ( !callback ) {
STORAGE[ type ][ hook ] = [];
} else {
var handlers = STORAGE[ type ][ hook ];
var i;
if ( !context ) {
for ( i = handlers.length; i--; ) {
if ( handlers[i].callback === callback ) {
handlers.splice( i, 1 );
}
}
}
else {
for ( i = handlers.length; i--; ) {
var handler = handlers[i];
if ( handler.callback === callback && handler.context === context) {
handlers.splice( i, 1 );
}
}
}
}
}
/**
* Adds the hook to the appropriate storage container
*
* @param type 'actions' or 'filters'
* @param hook The hook (namespace.identifier) to add to our event manager
* @param callback The function that will be called when the hook is executed.
* @param priority The priority of this hook. Must be an integer.
* @param [context] A value to be used for this
* @private
*/
function _addHook( type, hook, callback, priority, context ) {
var hookObject = {
callback : callback,
priority : priority,
context : context
};
// Utilize 'prop itself' : http://jsperf.com/hasownproperty-vs-in-vs-undefined/19
var hooks = STORAGE[ type ][ hook ];
if( hooks ) {
hooks.push( hookObject );
hooks = _hookInsertSort( hooks );
}
else {
hooks = [ hookObject ];
}
STORAGE[ type ][ hook ] = hooks;
}
/**
* Use an insert sort for keeping our hooks organized based on priority. This function is ridiculously faster
* than bubble sort, etc: http://jsperf.com/javascript-sort
*
* @param hooks The custom array containing all of the appropriate hooks to perform an insert sort on.
* @private
*/
function _hookInsertSort( hooks ) {
var tmpHook, j, prevHook;
for( var i = 1, len = hooks.length; i < len; i++ ) {
tmpHook = hooks[ i ];
j = i;
while( ( prevHook = hooks[ j - 1 ] ) && prevHook.priority > tmpHook.priority ) {
hooks[ j ] = hooks[ j - 1 ];
--j;
}
hooks[ j ] = tmpHook;
}
return hooks;
}
/**
* Runs the specified hook. If it is an action, the value is not modified but if it is a filter, it is.
*
* @param type 'actions' or 'filters'
* @param hook The hook ( namespace.identifier ) to be ran.
* @param args Arguments to pass to the action/filter. If it's a filter, args is actually a single parameter.
* @private
*/
function _runHook( type, hook, args ) {
var handlers = STORAGE[ type ][ hook ];
if ( !handlers ) {
return (type === 'filters') ? args[0] : false;
}
var i = 0, len = handlers.length;
if ( type === 'filters' ) {
for ( ; i < len; i++ ) {
args[ 0 ] = handlers[ i ].callback.apply( handlers[ i ].context, args );
}
} else {
for ( ; i < len; i++ ) {
handlers[ i ].callback.apply( handlers[ i ].context, args );
}
}
return ( type === 'filters' ) ? args[ 0 ] : true;
}
// return all of the publicly available methods
return MethodsAvailable;
};
window.wp = window.wp || {};
window.wp.hooks = new EventManager();
} )( window );
var theme = {};
var helpers = {};
var model = {};
var settings = {};
(function($) {
"use strict";
/*
* Helpers
*
* description
*
* @type function
* @date 7/07/13
*
* @param {int} $post_id
* @return {int} $post_id
*/
helpers = {
/*
* add_action
*
* This function uses wp.hooks to mimics WP add_action
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
add_action: function() {
// defaults
var k;
// allow multiple action parameters such as 'ready append'
var actions = arguments[0].split(' ');
for( k in actions ) {
// prefix action
arguments[0] = 'asm.' + actions[ k ];
wp.hooks.addAction.apply(this, arguments);
}
return this;
},
/*
* remove_action
*
* This function uses wp.hooks to mimics WP remove_action
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
remove_action: function() {
// prefix action
arguments[0] = 'asm.' + arguments[0];
wp.hooks.removeAction.apply(this, arguments);
return this;
},
/*
* do_action
*
* This function uses wp.hooks to mimics WP do_action
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
do_action: function() {
// prefix action
arguments[0] = 'asm.' + arguments[0];
wp.hooks.doAction.apply(this, arguments);
return this;
},
/*
* add_filter
*
* This function uses wp.hooks to mimics WP add_filter
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
add_filter: function() {
// prefix action
arguments[0] = 'asm.' + arguments[0];
wp.hooks.addFilter.apply(this, arguments);
return this;
},
/*
* remove_filter
*
* This function uses wp.hooks to mimics WP remove_filter
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
remove_filter: function() {
// prefix action
arguments[0] = 'asm.' + arguments[0];
wp.hooks.removeFilter.apply(this, arguments);
return this;
},
/*
* apply_filters
*
* This function uses wp.hooks to mimics WP apply_filters
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
apply_filters: function() {
// prefix action
arguments[0] = 'asm.' + arguments[0];
return wp.hooks.applyFilters.apply(this, arguments);
},
/*
* debounce
*
* This function uses wp.hooks to mimics WP apply_filters
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
debounce: function(fn, delay) {
delay || (delay = 250);
// self
var self = this;
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(context, args);
}, delay);
};
},
/*
* throttle
*
* This function uses wp.hooks to mimics WP apply_filters
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
throttle: function(fn, threshold, scope) {
threshold || (threshold = 20);
var last,
deferTimer;
return function () {
var context = scope || this;
var now = +new Date,
args = arguments;
if (last && now < last + threshold) {
// hold on to it
clearTimeout(deferTimer);
deferTimer = setTimeout(function () {
last = now;
fn.apply(context, args);
}, threshold);
} else {
last = now;
fn.apply(context, args);
}
};
},
/*
* isMobile
*
* isMobile
*
* @type function
* @date 8/09/2014
* @since 5.0.0
*
* @param
* @return
*/
is_mobile: function () {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i
.test(userAgent) ||
/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i
.test(userAgent.substr(0, 4));
}
};
/*
* Prototyped helpers
*
* description
*
* @type function
* @date 7/07/13
*
* @param {int} $post_id
* @return {int} $post_id
*/
$.fn.exists = function() {
return $(this).length > 0;
};
/*
* model
*
* Scafold for creating modules
*
* @type object
* @date 8/09/2014
* @since 5.0.0
*
* @param (object)
* @return (object)
*/
model = {
// vars
actions: {},
filters: {},
events: {},
// extend
extend: function( args ){
// extend
var model = $.extend( {}, this, args );
// setup actions
$.each(model.actions, function( name, callback ){
// split
var data = name.split(' ');
// add missing priority
var name = data[0] || '',
priority = data[1] || 10;
// add action
helpers.add_action(name, model[ callback ], priority, model);
});
// setup filters
$.each(model.filters, function( name, callback ){
// split
var data = name.split(' ');
// add missing priority
var name = data[0] || '',
priority = data[1] || 10;
// add action
helpers.add_filter(name, model[ callback ], priority, model);
});
// setup events
$.each(model.events, function( k, callback ){
// vars
var event = k,
selector = '',
context = document,
dynamic_name;
// allow for selector
if( k.indexOf(' ') > 0 ) {
event = k.substr(0,k.indexOf(' ')),
selector = k.substr(k.indexOf(' ')+1)
// allow dynamic property name
if( dynamic_name = selector.match( /\{(.*?)\}/g ) ){
dynamic_name = dynamic_name[0].replace(/\{/g,'').replace(/\}/g,'');
selector = args[dynamic_name];
}
}
// window
if( event.substring(0, 6) == 'resize' || event.substring(0, 6) == 'scroll' ) {
context = window;
}
// add event
$(context).on(event, selector, function( e ){
// appen $el to event object
e.$el = $(this);
// callback
model[ callback ].apply(model, arguments);
});
});
// call init callback
if( typeof(model[ 'init' ]) === 'function' ){
model[ 'init' ].apply(model);
}
// setup events
/*$.each(model.events, function( k, callback ){
// vars
var event = k.substr(0,k.indexOf(' ')),
selector = k.substr(k.indexOf(' ')+1),
dynamic_name = selector.match( /\{(.*?)\}/g );
// allow dynamic property name
if( dynamic_name ){
dynamic_name = dynamic_name[0].replace(/\{/g,'').replace(/\}/g,'');
selector = args[dynamic_name];
}
// add event
$(document).on(event, selector, function( e ){
//console.log( 'event: %o %o %o %o', event, selector, $(this), model );
// appen $el to event object
e.$el = $(this);
// callback
model[ callback ].apply(model, [e]);
});
});*/
// return
return model;
}
};
/*
* theme
*
* description
*
* @type function
* @date 10/02/2015
* @since 5.1.5
*
* @param $post_id (int)
* @return $post_id (int)
*/
theme = model.extend({
// vars
o: {},
m: {},
// actions
actions: {
'ready': 'ready'
},
/*
* ready
*
* description
*
* @type function
* @date 9/08/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
ready: function(){
// theme ready
// Support IOS Back Button
$(window).bind("pageshow", function(event) {
if (event.originalEvent.persisted) {
window.location.reload();
}
});
}
});
/*
* header
*
* This model sets up all related functionlaity
*
* @type model
* @date 10/02/2015
* @since 5.1.5
*
* @param n/a
* @return n/a
*/
theme.m.header = model.extend({
// vars
$el: null,
_visible: true,
_stuck: false,
_hover: false,
_y: 0,
sticky_offset: 100,
offscreen_offset: 200,
_t: null,
sticky_class: 'asm-sticky',
offscreen_class: 'asm-sticky-offscreen',
disable_sticky_mobile: false,
disabled: false,
// actions
actions: {
'ready': 'ready'
},
// events
events: {
//'scroll.asm-header': 'scroll',
//'mouseenter {element_selector}': 'mouseenter',
//'mouseleave {element_selector}': 'mouseleave'
},
ready : function(){
// self
var self = this;
// filter for 3rd party customization
self = helpers.apply_filters( 'header_args', self );
// disable sticky for mobile if applies
self.disabled = self.disable_sticky_mobile && helpers.is_mobile();
// disable
if( self.disabled || self.$el == undefined ){
self.destroy();
return;
}
// scroll event
//$(window).scroll(function(){ self.scroll(); });
$(window).on('scroll.asm-header', function(){ self.scroll(); });
// mouseenter event
self.$el.mouseenter(function(){ self.mouseenter(); });
// mouseleave event
self.$el.mouseleave(function(){ self.mouseleave(); });
},
mouseenter: function(){
this._hover = true;
},
mouseleave: function(){
this._hover = false;
// set timeout
this._t = setTimeout(this.timeout, 1000, this);
},
scroll: helpers.throttle( function(){
// vars
var new_y = $(window).scrollTop(),
diff = new_y - this._y,
direction = ( new_y >= this._y ) ? 'down' : 'up';
// update
this._y = new_y;
// clear timeout
clearTimeout( this._t );
// add class beyond the sticky offset
if( new_y > this.sticky_offset ) {
// add class
this.$el.addClass( this.sticky_class );
$('body').addClass( this.sticky_class );
this._stuck = true;
}else{
this.$el.removeClass( this.sticky_class );
$('body').removeClass( this.sticky_class );
this._stuck = false;
}
// down?
if( direction == 'down' ) {
// bail early if not enought movement
if( diff < 2 ) {
return;
}
this.attempt_close();
} else {
if( new_y > this.offscreen_offset ) {
// bail early if not enought movement
if( diff > -20 ) {
return;
}
}
this.attempt_show();
}
}),
attempt_close: function(){
var new_y = $(window).scrollTop();
// bai learly if no el
if( !this.$el ) return;
// bail early if header is already hidden
if( !this._visible ) {
return;
}
// bail early if hovering
if( this._hover ) {
return;
}
// add class beyond the offscreen offset
if( new_y > this.offscreen_offset ) {
this.$el.addClass( this.offscreen_class );
this._visible = false;
}
},
attempt_show: function(){
// bai learly if no el
if( !this.$el ) return;
// bail early if header is already visible
if( this._visible ) {
return;
}
this.$el.removeClass( this.offscreen_class );
this._visible = true;
// set timeout
this._t = setTimeout(this.attempt_close, 4000, this);
},
timeout : function( self ){
self.attempt_close();
},
destroy: function(){
// off events
$(window).off( 'scroll.asm-header' );
this.$el != null && this.$el.off();
// delete object
delete this;
}
});
/*
* scrollnav
*
* This model sets up all related functionlaity
*
* @type model
* @date 10/02/2015
* @since 5.1.5
*
* @param n/a
* @return n/a
*/
/*theme.m.scrollnav = model.extend({
$el: $('.asm-header-menu'),
disabled: false,
anchors: null,
// actions
actions: {
'ready': 'ready'
},
// events
events: {
'click .asm-header-menu .menu-item a': 'click',
'scroll.asm-scrollnav': 'scroll',
},
ready : function(){
// self
var self = this;
// filter for 3rd party customization
self = helpers.apply_filters( 'scrollnav_args', self );
// disable
if( self.disabled || this.$el == null ){
self.destroy();
return false;
}
// anchor items
self.anchors = this.$el.find( '.menu-item a' ).map( function(){
var href = $(this).attr( 'href' );
if( href.substring(0, 1) != '#' ) return;
if( $(href).length > 0 ) return $(href);
});
// bail if no anchors
if( self.anchors == undefined || self.anchors.length == 0 ){
self.destroy();
return false;
}
},
click: function( e ){
// prevent
e.preventDefault();
// vars
var href = e.$el.attr( 'href' );
},
scroll: helpers.throttle( function(){
// vars
var last_id,
pos_y = $(window).scrollTop();
// validate
if( self.anchors == undefined || self.anchors.length == 0 ){
return false;
}
// get current anchor
var cur = this.anchors.map(function(){
if( $(this).offset().top < pos_y ) return this;
});
// get current anchor's id
cur = cur[cur.length-1];
var anchor_id = cur && cur.length ? cur[0].id : null;
// match id
if( last_id !== anchor_id ){
last_id = anchor_id;
// add / remove class
this.$el.find( '.menu-item a' )
.parent().removeClass( 'w--current' )
.end().filter( '[href=#' + anchor_id + ']' ).parent().addClass( 'w--current' );
}
}),
destroy: function(){
// off events
$(window).off( 'scroll.asm-scrollnav' );
this.$el != null && this.$el.off();
// delete object
delete this;
}
});*/
/*
* menus
*
* This model sets up all related functionlaity
*
* @type model
* @date 10/02/2015
* @since 5.1.5
*
* @param n/a
* @return n/a
*/
theme.m.menus = model.extend({
$el: null,
side: {
delays: {
open: 400,
close: 400,
submeu: {
initial: 50,
step: 80,
}
},
callbacks: {
open: null,
close: null,
is: {
closed: null,
open: null,
},
items: {
animated: null
},
submenu: {
open: null,
}
}
},
overlay: {
folding:{
enabled: true,
},
delays: {
open: 400,
close: 400,
submeu: {
initial: 50,
step: 80,
}
},
callbacks: {
open: null,
close: null,
is: {
closed: null,
open: null,
},
items: {
animated: null
},
submenu: {
open: null,
}
}
},
// actions
actions: {
'ready': 'ready'
},
// events
events: {
'click .burger-box.overlay': 'open_overlay',
'touchstart .burger-box.overlay': 'open_overlay',
'click .burger-box.side': 'open_side',
'touchstart .burger-box.side': 'open_side',
'click #menu-mask': 'close_side',
'click #menu-list > ul > .menu-item a': 'expand_submenus',
},
ready : function(){
// self
var self = this;
// filter for 3rd party customization
self = helpers.apply_filters( 'menu_args', self );
// disable
if( self.disabled ){
return false;
}
// prepend menu overlay to body
$('#menu-overlay').detach().prependTo('body');
// prepend menu side and mask to body
$('#menu-side, #menu-mask').detach().prependTo('body');
// only if enabled
if( self.overlay.folding.enabled == false )
return;
// save a data attribute of submenu's height for later use
$('#menu-overlay #menu-list > ul > .menu-item').each(function( i ){
// vars
var li = $(this),
submenu = li.find( '.sub-menu' );
// add transition delay
li.css( 'transition-delay', ( self.overlay.delays.submeu.initial + ( i * self.overlay.delays.submeu.step ) ) + 'ms' );
// set attribute
submenu.attr( 'data-height', submenu.height() );
// fold submenus
submenu.css( 'height', '0' );
});
// save a data attribute of submenu's height for later use
$('#menu-side #menu-list > ul > .menu-item').each(function( i ){
// vars
var li = $(this),
submenu = li.find( '.sub-menu' );
// add transition delay
li.css( 'transition-delay', ( self.side.delays.submeu.initial + ( i * self.side.delays.submeu.step ) ) + 'ms' );
// set attribute
submenu.attr( 'data-height', submenu.height() );
// fold submenus
submenu.css( 'height', '0' );
});
},
open_overlay: function( e ){
e.preventDefault();
//self
var self = this;
// toggle active
e.$el.toggleClass('active');
// validate if active
if( e.$el.hasClass('active') ){
// set active state
$('#menu-overlay').addClass('visible').addClass('open').addClass('active');
// prepend
$('body').prepend('');
// temporal menu
$('.menu-temporal').offset( e.$el.offset() ).on('touchstart click', function(){
// close
self.close_overlay( e );
return false;
});
// set open state
setTimeout(function(){
e.$el.addClass('open');
$('.menu-temporal').addClass('open').addClass('active');
// callback
if( typeof self.overlay.callbacks.is.open === "function" ) self.overlay.callbacks.is.open( e );
}, self.overlay.delays.open );
// callback for when close button has been clicked
if( typeof self.overlay.callbacks.open === "function" ) self.overlay.callbacks.open( e );
}else{
// close
this.close_overlay( e );
}
},
close_overlay: function( e ){
//self
var self = this;
// timeout to wait for animation to finish
setTimeout(function(){
// set state
//e.$el.removeClass('open').removeClass('active');
$('.burger-box.overlay').removeClass('open').removeClass('active');
$('#menu-overlay').removeClass('open');
setTimeout(function(){
$('#menu-overlay').removeClass('visible').removeClass('active');
$('.menu-temporal').remove();
}, 300);
// callback
if( typeof self.overlay.callbacks.is.closed === "function" ) self.overlay.callbacks.is.closed( e );
}, self.overlay.delays.close );
// callback for when close button has been clicked
if( typeof self.overlay.callbacks.close === "function" ) self.overlay.callbacks.close( e );
},
open_side: function( e ){
e.preventDefault();
//self
var self = this;
// toggle active
e.$el.toggleClass('active');
// validate if active
if( e.$el.hasClass('active') ){
// set active states
$('body .wrapper, .header').addClass('pushReady').addClass('pushLeft');
$('#menu-side').addClass('pushReady').addClass('pushLeft-faster');
$('#menu-side').addClass('open');
$('#menu-mask').addClass('visible').addClass('open');
// prepend
$('#menu-side').prepend('');
$('.menu-temporal').addClass('open');
// temporal menu
//$('.menu-temporal').offset( e.$el.offset() ).on('touchstart click', function(){
$('.menu-temporal').on('touchstart click', function(){
// close
self.close_side( e );
return false;
});
// callback for when finished open
setTimeout( function(){
$('body').addClass('asm-menu-open');
$('.menu-temporal').addClass('visible');
// callback
if( typeof self.side.callbacks.is.open === "function" ) self.side.callbacks.is.open( e );
}, self.side.delays.open );
// callback for when close button has been clicked
if( typeof self.side.callbacks.open === "function" ) self.side.callbacks.open( e );
// vars
var total_items = $('#menu-list').find( '> ul > li' ).length;
var all_items_delay = self.side.delays.submeu.initial + self.side.delays.open + ( total_items * self.side.delays.submeu.step )
// callback for when finished all item animations
setTimeout( function(){
// callback
if( typeof self.side.callbacks.items.animated === "function" ) self.side.callbacks.items.animated( e );
}, all_items_delay );
}else{
// close
this.close_side( e );
}
},
close_side: function( e ){
//self
var self = this;
// toggle active
$('.burger-box.side').toggleClass('active');
// set active states
$('body .wrapper, .header').removeClass('pushLeft');
$('body').removeClass('asm-menu-open');
$('#menu-side').removeClass('pushLeft-faster');
$('#menu-mask').removeClass('open');
$('.menu-temporal').removeClass('visible');
// timeout to wait for animation to finish
setTimeout(function(){
$('body .wrapper, .header').removeClass('pushReady');
$('#menu-mask').removeClass('visible');
$('#menu-side').removeClass('pushReady').removeClass('open');
$('.menu-temporal').remove();
// callback
if( typeof self.side.callbacks.is.close === "function" ) self.side.callbacks.is.close( e );
}, self.side.delays.close );
// callback for when close button has been clicked
if( typeof self.side.callbacks.close === "function" ) self.side.callbacks.close( e );
},
expand_submenus: function( e ){
//self
var self = this;
// only if enabled
if( self.overlay.folding.enabled == false )
return;
// vars
var li = e.$el.parent(),
submenu = li.find( '.sub-menu' ),
height = submenu.attr( 'data-height' );
// fold/unfold submenus
if( li.hasClass( 'menu-item-has-children' ) ){
e.preventDefault();
// fold/unfold
if( li.hasClass( 'open' ) ) submenu.css( 'height', 0 );
else submenu.css( 'height', height );
// toggle submeu open class
li.toggleClass( 'open' );
// callback
if( typeof self.side.callbacks.submenu.open === "function" ) self.side.callbacks.submenu.open( e, li.hasClass( 'open' ) );
}
},
});
/*
* interactions
*
* This model sets up all related functionlaity
*
* @type model
* @date 10/02/2015
* @since 5.1.5
*
* @param n/a
* @return n/a
*/
theme.m.interactions = model.extend({
// actions
actions: {
'ready': 'ready'
},
ready: function(){
Webflow.require('ix').init(
helpers.apply_filters( 'ix_list',
[
{"slug":"show-devices","name":"Show Devices","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"opacity":1,"transition":"transform 1500ms ease-out-cubic 0ms, opacity 1500ms ease-out-cubic 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"fadein-1","name":"FadeIn_1","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"opacity":1,"transition":"transform 500ms ease-out 0ms, opacity 500ms ease-out 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"fadein-2","name":"FadeIn_ 2","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"wait":500},{"opacity":1,"transition":"transform 900ms ease-out 0ms, opacity 900ms ease-out 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"fadein-3","name":"FadeIn_ 3","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"wait":1000},{"opacity":1,"transition":"transform 700ms ease-out 0ms, opacity 700ms ease-out 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"fadein-4","name":"FadeIn_ 4","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"wait":1500},{"opacity":1,"transition":"transform 700ms ease-out 0ms, opacity 700ms ease-out 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"fadein-5","name":"FadeIn_ 5","value":{"style":{"opacity":0,"x":"0px","y":"20px","z":"0px"},"triggers":[{"type":"load","stepsA":[{"wait":1800},{"opacity":1,"transition":"transform 700ms ease-out 0ms, opacity 700ms ease-out 0ms","x":"0px","y":"0px","z":"0px"}],"stepsB":[]}]}},
{"slug":"play-button","name":"Play Button","value":{"style":{"opacity":0,"scaleX":0.8,"scaleY":0.8,"scaleZ":1},"triggers":[{"type":"load","stepsA":[{"wait":2400},{"opacity":1,"transition":"transform 1600ms ease-in-out-quint 0ms, opacity 1600ms ease-in-out-quint 0ms","scaleX":1,"scaleY":1,"scaleZ":1}],"stepsB":[]}]}},
{"slug":"arrows","name":"Arrows","value":{"style":{"opacity":0,"scaleX":0.8,"scaleY":0.8,"scaleZ":1},"triggers":[{"type":"load","stepsA":[{"wait":2600},{"opacity":1,"transition":"transform 1600ms ease-in-out-quint 0ms, opacity 1600ms ease-in-out-quint 0ms","scaleX":1,"scaleY":1,"scaleZ":1}],"stepsB":[]}]}},
]
)
);
}
});
// Add kooks
helpers.add_action('ready', function( $el ){
// ready
});
helpers.add_action('load', function( $el ){
// load
});
helpers.add_action('filter_categories', function( $el, $extra ){
// filter_categories
});
/*
* ready
*
* description
*
* @type function
* @date 19/02/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
$(document).ready(function(){
// action for 3rd party customization
helpers.do_action('ready', $('body'));
});
/*
* load
*
* description
*
* @type function
* @date 19/02/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
$(window).load(function(){
// action for 3rd party customization
helpers.do_action('load', $('body'));
});
/*
* preventDefault helper
*
* This function will prevent default of any link with an href of #
*
* @type function
* @date 24/07/2014
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
/*$(document).on('click', '.acf-field a[href="#"]', function( e ){
e.preventDefault();
});*/
})(jQuery);