" )
.attr({
id: id,
role: "tooltip"
})
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
( this.options.tooltipClass || "" ) );
$( "
" )
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
tooltip.appendTo( this.document[0].body );
this.tooltips[ id ] = element;
return tooltip;
},
_find: function( target ) {
var id = target.data( "ui-tooltip-id" );
return id ? $( "#" + id ) : $();
},
_removeTooltip: function( tooltip ) {
tooltip.remove();
delete this.tooltips[ tooltip.attr( "id" ) ];
},
_destroy: function() {
var that = this;
// close open tooltips
$.each( this.tooltips, function( id, element ) {
// Delegate to close method to handle common cleanup
var event = $.Event( "blur" );
event.target = event.currentTarget = element[0];
that.close( event, true );
// Remove immediately; destroying an open tooltip doesn't use the
// hide animation
$( "#" + id ).remove();
// Restore the title
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
element.removeData( "ui-tooltip-title" );
}
});
}
});
}( jQuery ) );
(function($, undefined) {
var dataSpace = "ui-effects-";
$.effects = {
effect: {}
};
/*!
* jQuery Color Animations v2.1.2
* https://github.com/jquery/jquery-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: Wed Jan 16 08:47:09 2013 -0600
*/
(function( jQuery, undefined ) {
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
// plusequals test for += 100 -= 100
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
// a set of RE's that can match strings and generate color tuples.
stringParsers = [{
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ],
execResult[ 3 ],
execResult[ 4 ]
];
}
}, {
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ] * 2.55,
execResult[ 2 ] * 2.55,
execResult[ 3 ] * 2.55,
execResult[ 4 ]
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ], 16 )
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
];
}
}, {
re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
space: "hsla",
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ] / 100,
execResult[ 3 ] / 100,
execResult[ 4 ]
];
}
}],
// jQuery.Color( )
color = jQuery.Color = function( color, green, blue, alpha ) {
return new jQuery.Color.fn.parse( color, green, blue, alpha );
},
spaces = {
rgba: {
props: {
red: {
idx: 0,
type: "byte"
},
green: {
idx: 1,
type: "byte"
},
blue: {
idx: 2,
type: "byte"
}
}
},
hsla: {
props: {
hue: {
idx: 0,
type: "degrees"
},
saturation: {
idx: 1,
type: "percent"
},
lightness: {
idx: 2,
type: "percent"
}
}
}
},
propTypes = {
"byte": {
floor: true,
max: 255
},
"percent": {
max: 1
},
"degrees": {
mod: 360,
floor: true
}
},
support = color.support = {},
// element for support tests
supportElem = jQuery( "
" )[ 0 ],
// colors = jQuery.Color.names
colors,
// local aliases of functions called often
each = jQuery.each;
// determine rgba support immediately
supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
// define cache name and alpha properties
// for rgba and hsla spaces
each( spaces, function( spaceName, space ) {
space.cache = "_" + spaceName;
space.props.alpha = {
idx: 3,
type: "percent",
def: 1
};
});
function clamp( value, prop, allowEmpty ) {
var type = propTypes[ prop.type ] || {};
if ( value == null ) {
return (allowEmpty || !prop.def) ? null : prop.def;
}
// ~~ is an short way of doing floor for positive numbers
value = type.floor ? ~~value : parseFloat( value );
// IE will pass in empty strings as value for alpha,
// which will hit this case
if ( isNaN( value ) ) {
return prop.def;
}
if ( type.mod ) {
// we add mod before modding to make sure that negatives values
// get converted properly: -10 -> 350
return (value + type.mod) % type.mod;
}
// for now all property types without mod have min and max
return 0 > value ? 0 : type.max < value ? type.max : value;
}
function stringParse( string ) {
var inst = color(),
rgba = inst._rgba = [];
string = string.toLowerCase();
each( stringParsers, function( i, parser ) {
var parsed,
match = parser.re.exec( string ),
values = match && parser.parse( match ),
spaceName = parser.space || "rgba";
if ( values ) {
parsed = inst[ spaceName ]( values );
// if this was an rgba parse the assignment might happen twice
// oh well....
inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
rgba = inst._rgba = parsed._rgba;
// exit each( stringParsers ) here because we matched
return false;
}
});
// Found a stringParser that handled it
if ( rgba.length ) {
// if this came from a parsed string, force "transparent" when alpha is 0
// chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
if ( rgba.join() === "0,0,0,0" ) {
jQuery.extend( rgba, colors.transparent );
}
return inst;
}
// named colors
return colors[ string ];
}
color.fn = jQuery.extend( color.prototype, {
parse: function( red, green, blue, alpha ) {
if ( red === undefined ) {
this._rgba = [ null, null, null, null ];
return this;
}
if ( red.jquery || red.nodeType ) {
red = jQuery( red ).css( green );
green = undefined;
}
var inst = this,
type = jQuery.type( red ),
rgba = this._rgba = [];
// more than 1 argument specified - assume ( red, green, blue, alpha )
if ( green !== undefined ) {
red = [ red, green, blue, alpha ];
type = "array";
}
if ( type === "string" ) {
return this.parse( stringParse( red ) || colors._default );
}
if ( type === "array" ) {
each( spaces.rgba.props, function( key, prop ) {
rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
});
return this;
}
if ( type === "object" ) {
if ( red instanceof color ) {
each( spaces, function( spaceName, space ) {
if ( red[ space.cache ] ) {
inst[ space.cache ] = red[ space.cache ].slice();
}
});
} else {
each( spaces, function( spaceName, space ) {
var cache = space.cache;
each( space.props, function( key, prop ) {
// if the cache doesn't exist, and we know how to convert
if ( !inst[ cache ] && space.to ) {
// if the value was null, we don't need to copy it
// if the key was alpha, we don't need to copy it either
if ( key === "alpha" || red[ key ] == null ) {
return;
}
inst[ cache ] = space.to( inst._rgba );
}
// this is the only case where we allow nulls for ALL properties.
// call clamp with alwaysAllowEmpty
inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
});
// everything defined but alpha?
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
// use the default of 1
inst[ cache ][ 3 ] = 1;
if ( space.from ) {
inst._rgba = space.from( inst[ cache ] );
}
}
});
}
return this;
}
},
is: function( compare ) {
var is = color( compare ),
same = true,
inst = this;
each( spaces, function( _, space ) {
var localCache,
isCache = is[ space.cache ];
if (isCache) {
localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
each( space.props, function( _, prop ) {
if ( isCache[ prop.idx ] != null ) {
same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
return same;
}
});
}
return same;
});
return same;
},
_space: function() {
var used = [],
inst = this;
each( spaces, function( spaceName, space ) {
if ( inst[ space.cache ] ) {
used.push( spaceName );
}
});
return used.pop();
},
transition: function( other, distance ) {
var end = color( other ),
spaceName = end._space(),
space = spaces[ spaceName ],
startColor = this.alpha() === 0 ? color( "transparent" ) : this,
start = startColor[ space.cache ] || space.to( startColor._rgba ),
result = start.slice();
end = end[ space.cache ];
each( space.props, function( key, prop ) {
var index = prop.idx,
startValue = start[ index ],
endValue = end[ index ],
type = propTypes[ prop.type ] || {};
// if null, don't override start value
if ( endValue === null ) {
return;
}
// if null - use end
if ( startValue === null ) {
result[ index ] = endValue;
} else {
if ( type.mod ) {
if ( endValue - startValue > type.mod / 2 ) {
startValue += type.mod;
} else if ( startValue - endValue > type.mod / 2 ) {
startValue -= type.mod;
}
}
result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
}
});
return this[ spaceName ]( result );
},
blend: function( opaque ) {
// if we are already opaque - return ourself
if ( this._rgba[ 3 ] === 1 ) {
return this;
}
var rgb = this._rgba.slice(),
a = rgb.pop(),
blend = color( opaque )._rgba;
return color( jQuery.map( rgb, function( v, i ) {
return ( 1 - a ) * blend[ i ] + a * v;
}));
},
toRgbaString: function() {
var prefix = "rgba(",
rgba = jQuery.map( this._rgba, function( v, i ) {
return v == null ? ( i > 2 ? 1 : 0 ) : v;
});
if ( rgba[ 3 ] === 1 ) {
rgba.pop();
prefix = "rgb(";
}
return prefix + rgba.join() + ")";
},
toHslaString: function() {
var prefix = "hsla(",
hsla = jQuery.map( this.hsla(), function( v, i ) {
if ( v == null ) {
v = i > 2 ? 1 : 0;
}
// catch 1 and 2
if ( i && i < 3 ) {
v = Math.round( v * 100 ) + "%";
}
return v;
});
if ( hsla[ 3 ] === 1 ) {
hsla.pop();
prefix = "hsl(";
}
return prefix + hsla.join() + ")";
},
toHexString: function( includeAlpha ) {
var rgba = this._rgba.slice(),
alpha = rgba.pop();
if ( includeAlpha ) {
rgba.push( ~~( alpha * 255 ) );
}
return "#" + jQuery.map( rgba, function( v ) {
// default to 0 when nulls exist
v = ( v || 0 ).toString( 16 );
return v.length === 1 ? "0" + v : v;
}).join("");
},
toString: function() {
return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
}
});
color.fn.parse.prototype = color.fn;
// hsla conversions adapted from:
// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
function hue2rgb( p, q, h ) {
h = ( h + 1 ) % 1;
if ( h * 6 < 1 ) {
return p + (q - p) * h * 6;
}
if ( h * 2 < 1) {
return q;
}
if ( h * 3 < 2 ) {
return p + (q - p) * ((2/3) - h) * 6;
}
return p;
}
spaces.hsla.to = function ( rgba ) {
if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
return [ null, null, null, rgba[ 3 ] ];
}
var r = rgba[ 0 ] / 255,
g = rgba[ 1 ] / 255,
b = rgba[ 2 ] / 255,
a = rgba[ 3 ],
max = Math.max( r, g, b ),
min = Math.min( r, g, b ),
diff = max - min,
add = max + min,
l = add * 0.5,
h, s;
if ( min === max ) {
h = 0;
} else if ( r === max ) {
h = ( 60 * ( g - b ) / diff ) + 360;
} else if ( g === max ) {
h = ( 60 * ( b - r ) / diff ) + 120;
} else {
h = ( 60 * ( r - g ) / diff ) + 240;
}
// chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
// otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
if ( diff === 0 ) {
s = 0;
} else if ( l <= 0.5 ) {
s = diff / add;
} else {
s = diff / ( 2 - add );
}
return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
};
spaces.hsla.from = function ( hsla ) {
if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
return [ null, null, null, hsla[ 3 ] ];
}
var h = hsla[ 0 ] / 360,
s = hsla[ 1 ],
l = hsla[ 2 ],
a = hsla[ 3 ],
q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
p = 2 * l - q;
return [
Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
Math.round( hue2rgb( p, q, h ) * 255 ),
Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
a
];
};
each( spaces, function( spaceName, space ) {
var props = space.props,
cache = space.cache,
to = space.to,
from = space.from;
// makes rgba() and hsla()
color.fn[ spaceName ] = function( value ) {
// generate a cache for this space if it doesn't exist
if ( to && !this[ cache ] ) {
this[ cache ] = to( this._rgba );
}
if ( value === undefined ) {
return this[ cache ].slice();
}
var ret,
type = jQuery.type( value ),
arr = ( type === "array" || type === "object" ) ? value : arguments,
local = this[ cache ].slice();
each( props, function( key, prop ) {
var val = arr[ type === "object" ? key : prop.idx ];
if ( val == null ) {
val = local[ prop.idx ];
}
local[ prop.idx ] = clamp( val, prop );
});
if ( from ) {
ret = color( from( local ) );
ret[ cache ] = local;
return ret;
} else {
return color( local );
}
};
// makes red() green() blue() alpha() hue() saturation() lightness()
each( props, function( key, prop ) {
// alpha is included in more than one space
if ( color.fn[ key ] ) {
return;
}
color.fn[ key ] = function( value ) {
var vtype = jQuery.type( value ),
fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
local = this[ fn ](),
cur = local[ prop.idx ],
match;
if ( vtype === "undefined" ) {
return cur;
}
if ( vtype === "function" ) {
value = value.call( this, cur );
vtype = jQuery.type( value );
}
if ( value == null && prop.empty ) {
return this;
}
if ( vtype === "string" ) {
match = rplusequals.exec( value );
if ( match ) {
value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
}
}
local[ prop.idx ] = value;
return this[ fn ]( local );
};
});
});
// add cssHook and .fx.step function for each named hook.
// accept a space separated string of properties
color.hook = function( hook ) {
var hooks = hook.split( " " );
each( hooks, function( i, hook ) {
jQuery.cssHooks[ hook ] = {
set: function( elem, value ) {
var parsed, curElem,
backgroundColor = "";
if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
value = color( parsed || value );
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
while (
(backgroundColor === "" || backgroundColor === "transparent") &&
curElem && curElem.style
) {
try {
backgroundColor = jQuery.css( curElem, "backgroundColor" );
curElem = curElem.parentNode;
} catch ( e ) {
}
}
value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
backgroundColor :
"_default" );
}
value = value.toRgbaString();
}
try {
elem.style[ hook ] = value;
} catch( e ) {
// wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
}
}
};
jQuery.fx.step[ hook ] = function( fx ) {
if ( !fx.colorInit ) {
fx.start = color( fx.elem, hook );
fx.end = color( fx.end );
fx.colorInit = true;
}
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
};
});
};
color.hook( stepHooks );
jQuery.cssHooks.borderColor = {
expand: function( value ) {
var expanded = {};
each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
expanded[ "border" + part + "Color" ] = value;
});
return expanded;
}
};
// Basic color names only.
// Usage of any of the other color names requires adding yourself or including
// jquery.color.svg-names.js.
colors = jQuery.Color.names = {
// 4.1. Basic color keywords
aqua: "#00ffff",
black: "#000000",
blue: "#0000ff",
fuchsia: "#ff00ff",
gray: "#808080",
green: "#008000",
lime: "#00ff00",
maroon: "#800000",
navy: "#000080",
olive: "#808000",
purple: "#800080",
red: "#ff0000",
silver: "#c0c0c0",
teal: "#008080",
white: "#ffffff",
yellow: "#ffff00",
// 4.2.3. "transparent" color keyword
transparent: [ null, null, null, 0 ],
_default: "#ffffff"
};
})( jQuery );
/******************************************************************************/
/****************************** CLASS ANIMATIONS ******************************/
/******************************************************************************/
(function() {
var classAnimationActions = [ "add", "remove", "toggle" ],
shorthandStyles = {
border: 1,
borderBottom: 1,
borderColor: 1,
borderLeft: 1,
borderRight: 1,
borderTop: 1,
borderWidth: 1,
margin: 1,
padding: 1
};
$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
$.fx.step[ prop ] = function( fx ) {
if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
jQuery.style( fx.elem, prop, fx.end );
fx.setAttr = true;
}
};
});
function getElementStyles( elem ) {
var key, len,
style = elem.ownerDocument.defaultView ?
elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
elem.currentStyle,
styles = {};
if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
len = style.length;
while ( len-- ) {
key = style[ len ];
if ( typeof style[ key ] === "string" ) {
styles[ $.camelCase( key ) ] = style[ key ];
}
}
// support: Opera, IE <9
} else {
for ( key in style ) {
if ( typeof style[ key ] === "string" ) {
styles[ key ] = style[ key ];
}
}
}
return styles;
}
function styleDifference( oldStyle, newStyle ) {
var diff = {},
name, value;
for ( name in newStyle ) {
value = newStyle[ name ];
if ( oldStyle[ name ] !== value ) {
if ( !shorthandStyles[ name ] ) {
if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
diff[ name ] = value;
}
}
}
}
return diff;
}
// support: jQuery <1.8
if ( !$.fn.addBack ) {
$.fn.addBack = function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter( selector )
);
};
}
$.effects.animateClass = function( value, duration, easing, callback ) {
var o = $.speed( duration, easing, callback );
return this.queue( function() {
var animated = $( this ),
baseClass = animated.attr( "class" ) || "",
applyClassChange,
allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
// map the animated objects to store the original styles.
allAnimations = allAnimations.map(function() {
var el = $( this );
return {
el: el,
start: getElementStyles( this )
};
});
// apply class change
applyClassChange = function() {
$.each( classAnimationActions, function(i, action) {
if ( value[ action ] ) {
animated[ action + "Class" ]( value[ action ] );
}
});
};
applyClassChange();
// map all animated objects again - calculate new styles and diff
allAnimations = allAnimations.map(function() {
this.end = getElementStyles( this.el[ 0 ] );
this.diff = styleDifference( this.start, this.end );
return this;
});
// apply original class
animated.attr( "class", baseClass );
// map all animated objects again - this time collecting a promise
allAnimations = allAnimations.map(function() {
var styleInfo = this,
dfd = $.Deferred(),
opts = $.extend({}, o, {
queue: false,
complete: function() {
dfd.resolve( styleInfo );
}
});
this.el.animate( this.diff, opts );
return dfd.promise();
});
// once all animations have completed:
$.when.apply( $, allAnimations.get() ).done(function() {
// set the final class
applyClassChange();
// for each animated element,
// clear all css properties that were animated
$.each( arguments, function() {
var el = this.el;
$.each( this.diff, function(key) {
el.css( key, "" );
});
});
// this is guarnteed to be there if you use jQuery.speed()
// it also handles dequeuing the next anim...
o.complete.call( animated[ 0 ] );
});
});
};
$.fn.extend({
addClass: (function( orig ) {
return function( classNames, speed, easing, callback ) {
return speed ?
$.effects.animateClass.call( this,
{ add: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
})( $.fn.addClass ),
removeClass: (function( orig ) {
return function( classNames, speed, easing, callback ) {
return arguments.length > 1 ?
$.effects.animateClass.call( this,
{ remove: classNames }, speed, easing, callback ) :
orig.apply( this, arguments );
};
})( $.fn.removeClass ),
toggleClass: (function( orig ) {
return function( classNames, force, speed, easing, callback ) {
if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
// without speed parameter
return orig.apply( this, arguments );
} else {
return $.effects.animateClass.call( this,
(force ? { add: classNames } : { remove: classNames }),
speed, easing, callback );
}
} else {
// without force parameter
return $.effects.animateClass.call( this,
{ toggle: classNames }, force, speed, easing );
}
};
})( $.fn.toggleClass ),
switchClass: function( remove, add, speed, easing, callback) {
return $.effects.animateClass.call( this, {
add: add,
remove: remove
}, speed, easing, callback );
}
});
})();
/******************************************************************************/
/*********************************** EFFECTS **********************************/
/******************************************************************************/
(function() {
$.extend( $.effects, {
version: "1.10.2",
// Saves a set of properties in a data storage
save: function( element, set ) {
for( var i=0; i < set.length; i++ ) {
if ( set[ i ] !== null ) {
element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
}
}
},
// Restores a set of previously saved properties from a data storage
restore: function( element, set ) {
var val, i;
for( i=0; i < set.length; i++ ) {
if ( set[ i ] !== null ) {
val = element.data( dataSpace + set[ i ] );
// support: jQuery 1.6.2
// http://bugs.jquery.com/ticket/9917
// jQuery 1.6.2 incorrectly returns undefined for any falsy value.
// We can't differentiate between "" and 0 here, so we just assume
// empty string since it's likely to be a more common value...
if ( val === undefined ) {
val = "";
}
element.css( set[ i ], val );
}
}
},
setMode: function( el, mode ) {
if (mode === "toggle") {
mode = el.is( ":hidden" ) ? "show" : "hide";
}
return mode;
},
// Translates a [top,left] array into a baseline value
// this should be a little more flexible in the future to handle a string & hash
getBaseline: function( origin, original ) {
var y, x;
switch ( origin[ 0 ] ) {
case "top": y = 0; break;
case "middle": y = 0.5; break;
case "bottom": y = 1; break;
default: y = origin[ 0 ] / original.height;
}
switch ( origin[ 1 ] ) {
case "left": x = 0; break;
case "center": x = 0.5; break;
case "right": x = 1; break;
default: x = origin[ 1 ] / original.width;
}
return {
x: x,
y: y
};
},
// Wraps the element around a wrapper that copies position properties
createWrapper: function( element ) {
// if the element is already wrapped, return it
if ( element.parent().is( ".ui-effects-wrapper" )) {
return element.parent();
}
// wrap the element
var props = {
width: element.outerWidth(true),
height: element.outerHeight(true),
"float": element.css( "float" )
},
wrapper = $( "
" )
.addClass( "ui-effects-wrapper" )
.css({
fontSize: "100%",
background: "transparent",
border: "none",
margin: 0,
padding: 0
}),
// Store the size in case width/height are defined in % - Fixes #5245
size = {
width: element.width(),
height: element.height()
},
active = document.activeElement;
// support: Firefox
// Firefox incorrectly exposes anonymous content
// https://bugzilla.mozilla.org/show_bug.cgi?id=561664
try {
active.id;
} catch( e ) {
active = document.body;
}
element.wrap( wrapper );
// Fixes #7595 - Elements lose focus when wrapped.
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
$( active ).focus();
}
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
// transfer positioning properties to the wrapper
if ( element.css( "position" ) === "static" ) {
wrapper.css({ position: "relative" });
element.css({ position: "relative" });
} else {
$.extend( props, {
position: element.css( "position" ),
zIndex: element.css( "z-index" )
});
$.each([ "top", "left", "bottom", "right" ], function(i, pos) {
props[ pos ] = element.css( pos );
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
props[ pos ] = "auto";
}
});
element.css({
position: "relative",
top: 0,
left: 0,
right: "auto",
bottom: "auto"
});
}
element.css(size);
return wrapper.css( props ).show();
},
removeWrapper: function( element ) {
var active = document.activeElement;
if ( element.parent().is( ".ui-effects-wrapper" ) ) {
element.parent().replaceWith( element );
// Fixes #7595 - Elements lose focus when wrapped.
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
$( active ).focus();
}
}
return element;
},
setTransition: function( element, list, factor, value ) {
value = value || {};
$.each( list, function( i, x ) {
var unit = element.cssUnit( x );
if ( unit[ 0 ] > 0 ) {
value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
}
});
return value;
}
});
// return an effect options object for the given parameters:
function _normalizeArguments( effect, options, speed, callback ) {
// allow passing all options as the first parameter
if ( $.isPlainObject( effect ) ) {
options = effect;
effect = effect.effect;
}
// convert to an object
effect = { effect: effect };
// catch (effect, null, ...)
if ( options == null ) {
options = {};
}
// catch (effect, callback)
if ( $.isFunction( options ) ) {
callback = options;
speed = null;
options = {};
}
// catch (effect, speed, ?)
if ( typeof options === "number" || $.fx.speeds[ options ] ) {
callback = speed;
speed = options;
options = {};
}
// catch (effect, options, callback)
if ( $.isFunction( speed ) ) {
callback = speed;
speed = null;
}
// add options to effect
if ( options ) {
$.extend( effect, options );
}
speed = speed || options.duration;
effect.duration = $.fx.off ? 0 :
typeof speed === "number" ? speed :
speed in $.fx.speeds ? $.fx.speeds[ speed ] :
$.fx.speeds._default;
effect.complete = callback || options.complete;
return effect;
}
function standardAnimationOption( option ) {
// Valid standard speeds (nothing, number, named speed)
if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
return true;
}
// Invalid strings - treat as "normal" speed
if ( typeof option === "string" && !$.effects.effect[ option ] ) {
return true;
}
// Complete callback
if ( $.isFunction( option ) ) {
return true;
}
// Options hash (but not naming an effect)
if ( typeof option === "object" && !option.effect ) {
return true;
}
// Didn't match any standard API
return false;
}
$.fn.extend({
effect: function( /* effect, options, speed, callback */ ) {
var args = _normalizeArguments.apply( this, arguments ),
mode = args.mode,
queue = args.queue,
effectMethod = $.effects.effect[ args.effect ];
if ( $.fx.off || !effectMethod ) {
// delegate to the original method (e.g., .show()) if possible
if ( mode ) {
return this[ mode ]( args.duration, args.complete );
} else {
return this.each( function() {
if ( args.complete ) {
args.complete.call( this );
}
});
}
}
function run( next ) {
var elem = $( this ),
complete = args.complete,
mode = args.mode;
function done() {
if ( $.isFunction( complete ) ) {
complete.call( elem[0] );
}
if ( $.isFunction( next ) ) {
next();
}
}
// If the element already has the correct final state, delegate to
// the core methods so the internal tracking of "olddisplay" works.
if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
elem[ mode ]();
done();
} else {
effectMethod.call( elem[0], args, done );
}
}
return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
},
show: (function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) ) {
return orig.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
args.mode = "show";
return this.effect.call( this, args );
}
};
})( $.fn.show ),
hide: (function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) ) {
return orig.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
args.mode = "hide";
return this.effect.call( this, args );
}
};
})( $.fn.hide ),
toggle: (function( orig ) {
return function( option ) {
if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
return orig.apply( this, arguments );
} else {
var args = _normalizeArguments.apply( this, arguments );
args.mode = "toggle";
return this.effect.call( this, args );
}
};
})( $.fn.toggle ),
// helper functions
cssUnit: function(key) {
var style = this.css( key ),
val = [];
$.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
if ( style.indexOf( unit ) > 0 ) {
val = [ parseFloat( style ), unit ];
}
});
return val;
}
});
})();
/******************************************************************************/
/*********************************** EASING ***********************************/
/******************************************************************************/
(function() {
// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
var baseEasings = {};
$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
baseEasings[ name ] = function( p ) {
return Math.pow( p, i + 2 );
};
});
$.extend( baseEasings, {
Sine: function ( p ) {
return 1 - Math.cos( p * Math.PI / 2 );
},
Circ: function ( p ) {
return 1 - Math.sqrt( 1 - p * p );
},
Elastic: function( p ) {
return p === 0 || p === 1 ? p :
-Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
},
Back: function( p ) {
return p * p * ( 3 * p - 2 );
},
Bounce: function ( p ) {
var pow2,
bounce = 4;
while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
}
});
$.each( baseEasings, function( name, easeIn ) {
$.easing[ "easeIn" + name ] = easeIn;
$.easing[ "easeOut" + name ] = function( p ) {
return 1 - easeIn( 1 - p );
};
$.easing[ "easeInOut" + name ] = function( p ) {
return p < 0.5 ?
easeIn( p * 2 ) / 2 :
1 - easeIn( p * -2 + 2 ) / 2;
};
});
})();
})(jQuery);
(function( $, undefined ) {
var rvertical = /up|down|vertical/,
rpositivemotion = /up|left|vertical|horizontal/;
$.effects.effect.blind = function( o, done ) {
// Create element
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
direction = o.direction || "up",
vertical = rvertical.test( direction ),
ref = vertical ? "height" : "width",
ref2 = vertical ? "top" : "left",
motion = rpositivemotion.test( direction ),
animation = {},
show = mode === "show",
wrapper, distance, margin;
// if already wrapped, the wrapper's properties are my property. #6245
if ( el.parent().is( ".ui-effects-wrapper" ) ) {
$.effects.save( el.parent(), props );
} else {
$.effects.save( el, props );
}
el.show();
wrapper = $.effects.createWrapper( el ).css({
overflow: "hidden"
});
distance = wrapper[ ref ]();
margin = parseFloat( wrapper.css( ref2 ) ) || 0;
animation[ ref ] = show ? distance : 0;
if ( !motion ) {
el
.css( vertical ? "bottom" : "right", 0 )
.css( vertical ? "top" : "left", "auto" )
.css({ position: "absolute" });
animation[ ref2 ] = show ? margin : distance + margin;
}
// start at 0 if we are showing
if ( show ) {
wrapper.css( ref, 0 );
if ( ! motion ) {
wrapper.css( ref2, margin + distance );
}
}
// Animate
wrapper.animate( animation, {
duration: o.duration,
easing: o.easing,
queue: false,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.bounce = function( o, done ) {
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
// defaults:
mode = $.effects.setMode( el, o.mode || "effect" ),
hide = mode === "hide",
show = mode === "show",
direction = o.direction || "up",
distance = o.distance,
times = o.times || 5,
// number of internal animations
anims = times * 2 + ( show || hide ? 1 : 0 ),
speed = o.duration / anims,
easing = o.easing,
// utility:
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
motion = ( direction === "up" || direction === "left" ),
i,
upAnim,
downAnim,
// we will need to re-assemble the queue to stack our animations in place
queue = el.queue(),
queuelen = queue.length;
// Avoid touching opacity to prevent clearType and PNG issues in IE
if ( show || hide ) {
props.push( "opacity" );
}
$.effects.save( el, props );
el.show();
$.effects.createWrapper( el ); // Create Wrapper
// default distance for the BIGGEST bounce is the outer Distance / 3
if ( !distance ) {
distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
}
if ( show ) {
downAnim = { opacity: 1 };
downAnim[ ref ] = 0;
// if we are showing, force opacity 0 and set the initial position
// then do the "first" animation
el.css( "opacity", 0 )
.css( ref, motion ? -distance * 2 : distance * 2 )
.animate( downAnim, speed, easing );
}
// start at the smallest distance if we are hiding
if ( hide ) {
distance = distance / Math.pow( 2, times - 1 );
}
downAnim = {};
downAnim[ ref ] = 0;
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
for ( i = 0; i < times; i++ ) {
upAnim = {};
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
el.animate( upAnim, speed, easing )
.animate( downAnim, speed, easing );
distance = hide ? distance * 2 : distance / 2;
}
// Last Bounce when Hiding
if ( hide ) {
upAnim = { opacity: 0 };
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
el.animate( upAnim, speed, easing );
}
el.queue(function() {
if ( hide ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
});
// inject all the animations we just queued to be first in line (after "inprogress")
if ( queuelen > 1) {
queue.splice.apply( queue,
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
}
el.dequeue();
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.clip = function( o, done ) {
// Create element
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
direction = o.direction || "vertical",
vert = direction === "vertical",
size = vert ? "height" : "width",
position = vert ? "top" : "left",
animation = {},
wrapper, animate, distance;
// Save & Show
$.effects.save( el, props );
el.show();
// Create Wrapper
wrapper = $.effects.createWrapper( el ).css({
overflow: "hidden"
});
animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
distance = animate[ size ]();
// Shift
if ( show ) {
animate.css( size, 0 );
animate.css( position, distance / 2 );
}
// Create Animation Object:
animation[ size ] = show ? distance : 0;
animation[ position ] = show ? 0 : distance / 2;
// Animate
animate.animate( animation, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
if ( !show ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.drop = function( o, done ) {
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
direction = o.direction || "left",
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
animation = {
opacity: show ? 1 : 0
},
distance;
// Adjust
$.effects.save( el, props );
el.show();
$.effects.createWrapper( el );
distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
if ( show ) {
el
.css( "opacity", 0 )
.css( ref, motion === "pos" ? -distance : distance );
}
// Animation
animation[ ref ] = ( show ?
( motion === "pos" ? "+=" : "-=" ) :
( motion === "pos" ? "-=" : "+=" ) ) +
distance;
// Animate
el.animate( animation, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.explode = function( o, done ) {
var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
cells = rows,
el = $( this ),
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
// show and then visibility:hidden the element before calculating offset
offset = el.show().css( "visibility", "hidden" ).offset(),
// width and height of a piece
width = Math.ceil( el.outerWidth() / cells ),
height = Math.ceil( el.outerHeight() / rows ),
pieces = [],
// loop
i, j, left, top, mx, my;
// children animate complete:
function childComplete() {
pieces.push( this );
if ( pieces.length === rows * cells ) {
animComplete();
}
}
// clone the element for each row and cell.
for( i = 0; i < rows ; i++ ) { // ===>
top = offset.top + i * height;
my = i - ( rows - 1 ) / 2 ;
for( j = 0; j < cells ; j++ ) { // |||
left = offset.left + j * width;
mx = j - ( cells - 1 ) / 2 ;
// Create a clone of the now hidden main element that will be absolute positioned
// within a wrapper div off the -left and -top equal to size of our pieces
el
.clone()
.appendTo( "body" )
.wrap( "
" )
.css({
position: "absolute",
visibility: "visible",
left: -j * width,
top: -i * height
})
// select the wrapper - make it overflow: hidden and absolute positioned based on
// where the original was located +left and +top equal to the size of pieces
.parent()
.addClass( "ui-effects-explode" )
.css({
position: "absolute",
overflow: "hidden",
width: width,
height: height,
left: left + ( show ? mx * width : 0 ),
top: top + ( show ? my * height : 0 ),
opacity: show ? 0 : 1
}).animate({
left: left + ( show ? 0 : mx * width ),
top: top + ( show ? 0 : my * height ),
opacity: show ? 1 : 0
}, o.duration || 500, o.easing, childComplete );
}
}
function animComplete() {
el.css({
visibility: "visible"
});
$( pieces ).remove();
if ( !show ) {
el.hide();
}
done();
}
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.fade = function( o, done ) {
var el = $( this ),
mode = $.effects.setMode( el, o.mode || "toggle" );
el.animate({
opacity: mode
}, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: done
});
};
})( jQuery );
(function( $, undefined ) {
$.effects.effect.fold = function( o, done ) {
// Create element
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
show = mode === "show",
hide = mode === "hide",
size = o.size || 15,
percent = /([0-9]+)%/.exec( size ),
horizFirst = !!o.horizFirst,
widthFirst = show !== horizFirst,
ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
duration = o.duration / 2,
wrapper, distance,
animation1 = {},
animation2 = {};
$.effects.save( el, props );
el.show();
// Create Wrapper
wrapper = $.effects.createWrapper( el ).css({
overflow: "hidden"
});
distance = widthFirst ?
[ wrapper.width(), wrapper.height() ] :
[ wrapper.height(), wrapper.width() ];
if ( percent ) {
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
}
if ( show ) {
wrapper.css( horizFirst ? {
height: 0,
width: size
} : {
height: size,
width: 0
});
}
// Animation
animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
// Animate
wrapper
.animate( animation1, duration, o.easing )
.animate( animation2, duration, o.easing, function() {
if ( hide ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.highlight = function( o, done ) {
var elem = $( this ),
props = [ "backgroundImage", "backgroundColor", "opacity" ],
mode = $.effects.setMode( elem, o.mode || "show" ),
animation = {
backgroundColor: elem.css( "backgroundColor" )
};
if (mode === "hide") {
animation.opacity = 0;
}
$.effects.save( elem, props );
elem
.show()
.css({
backgroundImage: "none",
backgroundColor: o.color || "#ffff99"
})
.animate( animation, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
elem.hide();
}
$.effects.restore( elem, props );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.pulsate = function( o, done ) {
var elem = $( this ),
mode = $.effects.setMode( elem, o.mode || "show" ),
show = mode === "show",
hide = mode === "hide",
showhide = ( show || mode === "hide" ),
// showing or hiding leaves of the "last" animation
anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
duration = o.duration / anims,
animateTo = 0,
queue = elem.queue(),
queuelen = queue.length,
i;
if ( show || !elem.is(":visible")) {
elem.css( "opacity", 0 ).show();
animateTo = 1;
}
// anims - 1 opacity "toggles"
for ( i = 1; i < anims; i++ ) {
elem.animate({
opacity: animateTo
}, duration, o.easing );
animateTo = 1 - animateTo;
}
elem.animate({
opacity: animateTo
}, duration, o.easing);
elem.queue(function() {
if ( hide ) {
elem.hide();
}
done();
});
// We just queued up "anims" animations, we need to put them next in the queue
if ( queuelen > 1 ) {
queue.splice.apply( queue,
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
}
elem.dequeue();
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.puff = function( o, done ) {
var elem = $( this ),
mode = $.effects.setMode( elem, o.mode || "hide" ),
hide = mode === "hide",
percent = parseInt( o.percent, 10 ) || 150,
factor = percent / 100,
original = {
height: elem.height(),
width: elem.width(),
outerHeight: elem.outerHeight(),
outerWidth: elem.outerWidth()
};
$.extend( o, {
effect: "scale",
queue: false,
fade: true,
mode: mode,
complete: done,
percent: hide ? percent : 100,
from: hide ?
original :
{
height: original.height * factor,
width: original.width * factor,
outerHeight: original.outerHeight * factor,
outerWidth: original.outerWidth * factor
}
});
elem.effect( o );
};
$.effects.effect.scale = function( o, done ) {
// Create element
var el = $( this ),
options = $.extend( true, {}, o ),
mode = $.effects.setMode( el, o.mode || "effect" ),
percent = parseInt( o.percent, 10 ) ||
( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
direction = o.direction || "both",
origin = o.origin,
original = {
height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
},
factor = {
y: direction !== "horizontal" ? (percent / 100) : 1,
x: direction !== "vertical" ? (percent / 100) : 1
};
// We are going to pass this effect to the size effect:
options.effect = "size";
options.queue = false;
options.complete = done;
// Set default origin and restore for show/hide
if ( mode !== "effect" ) {
options.origin = origin || ["middle","center"];
options.restore = true;
}
options.from = o.from || ( mode === "show" ? {
height: 0,
width: 0,
outerHeight: 0,
outerWidth: 0
} : original );
options.to = {
height: original.height * factor.y,
width: original.width * factor.x,
outerHeight: original.outerHeight * factor.y,
outerWidth: original.outerWidth * factor.x
};
// Fade option to support puff
if ( options.fade ) {
if ( mode === "show" ) {
options.from.opacity = 0;
options.to.opacity = 1;
}
if ( mode === "hide" ) {
options.from.opacity = 1;
options.to.opacity = 0;
}
}
// Animate
el.effect( options );
};
$.effects.effect.size = function( o, done ) {
// Create element
var original, baseline, factor,
el = $( this ),
props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
// Always restore
props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
// Copy for children
props2 = [ "width", "height", "overflow" ],
cProps = [ "fontSize" ],
vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
// Set options
mode = $.effects.setMode( el, o.mode || "effect" ),
restore = o.restore || mode !== "effect",
scale = o.scale || "both",
origin = o.origin || [ "middle", "center" ],
position = el.css( "position" ),
props = restore ? props0 : props1,
zero = {
height: 0,
width: 0,
outerHeight: 0,
outerWidth: 0
};
if ( mode === "show" ) {
el.show();
}
original = {
height: el.height(),
width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
};
if ( o.mode === "toggle" && mode === "show" ) {
el.from = o.to || zero;
el.to = o.from || original;
} else {
el.from = o.from || ( mode === "show" ? zero : original );
el.to = o.to || ( mode === "hide" ? zero : original );
}
// Set scaling factor
factor = {
from: {
y: el.from.height / original.height,
x: el.from.width / original.width
},
to: {
y: el.to.height / original.height,
x: el.to.width / original.width
}
};
// Scale the css box
if ( scale === "box" || scale === "both" ) {
// Vertical props scaling
if ( factor.from.y !== factor.to.y ) {
props = props.concat( vProps );
el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
}
// Horizontal props scaling
if ( factor.from.x !== factor.to.x ) {
props = props.concat( hProps );
el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
}
}
// Scale the content
if ( scale === "content" || scale === "both" ) {
// Vertical props scaling
if ( factor.from.y !== factor.to.y ) {
props = props.concat( cProps ).concat( props2 );
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
}
}
$.effects.save( el, props );
el.show();
$.effects.createWrapper( el );
el.css( "overflow", "hidden" ).css( el.from );
// Adjust
if (origin) { // Calculate baseline shifts
baseline = $.effects.getBaseline( origin, original );
el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
}
el.css( el.from ); // set top & left
// Animate
if ( scale === "content" || scale === "both" ) { // Scale the children
// Add margins/font-size
vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
hProps = hProps.concat([ "marginLeft", "marginRight" ]);
props2 = props0.concat(vProps).concat(hProps);
el.find( "*[width]" ).each( function(){
var child = $( this ),
c_original = {
height: child.height(),
width: child.width(),
outerHeight: child.outerHeight(),
outerWidth: child.outerWidth()
};
if (restore) {
$.effects.save(child, props2);
}
child.from = {
height: c_original.height * factor.from.y,
width: c_original.width * factor.from.x,
outerHeight: c_original.outerHeight * factor.from.y,
outerWidth: c_original.outerWidth * factor.from.x
};
child.to = {
height: c_original.height * factor.to.y,
width: c_original.width * factor.to.x,
outerHeight: c_original.height * factor.to.y,
outerWidth: c_original.width * factor.to.x
};
// Vertical props scaling
if ( factor.from.y !== factor.to.y ) {
child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
}
// Horizontal props scaling
if ( factor.from.x !== factor.to.x ) {
child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
}
// Animate children
child.css( child.from );
child.animate( child.to, o.duration, o.easing, function() {
// Restore children
if ( restore ) {
$.effects.restore( child, props2 );
}
});
});
}
// Animate
el.animate( el.to, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
if ( el.to.opacity === 0 ) {
el.css( "opacity", el.from.opacity );
}
if( mode === "hide" ) {
el.hide();
}
$.effects.restore( el, props );
if ( !restore ) {
// we need to calculate our new positioning based on the scaling
if ( position === "static" ) {
el.css({
position: "relative",
top: el.to.top,
left: el.to.left
});
} else {
$.each([ "top", "left" ], function( idx, pos ) {
el.css( pos, function( _, str ) {
var val = parseInt( str, 10 ),
toRef = idx ? el.to.left : el.to.top;
// if original was "auto", recalculate the new value from wrapper
if ( str === "auto" ) {
return toRef + "px";
}
return val + toRef + "px";
});
});
}
}
$.effects.removeWrapper( el );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.shake = function( o, done ) {
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "effect" ),
direction = o.direction || "left",
distance = o.distance || 20,
times = o.times || 3,
anims = times * 2 + 1,
speed = Math.round(o.duration/anims),
ref = (direction === "up" || direction === "down") ? "top" : "left",
positiveMotion = (direction === "up" || direction === "left"),
animation = {},
animation1 = {},
animation2 = {},
i,
// we will need to re-assemble the queue to stack our animations in place
queue = el.queue(),
queuelen = queue.length;
$.effects.save( el, props );
el.show();
$.effects.createWrapper( el );
// Animation
animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
// Animate
el.animate( animation, speed, o.easing );
// Shakes
for ( i = 1; i < times; i++ ) {
el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
}
el
.animate( animation1, speed, o.easing )
.animate( animation, speed / 2, o.easing )
.queue(function() {
if ( mode === "hide" ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
});
// inject all the animations we just queued to be first in line (after "inprogress")
if ( queuelen > 1) {
queue.splice.apply( queue,
[ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
}
el.dequeue();
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.slide = function( o, done ) {
// Create element
var el = $( this ),
props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
mode = $.effects.setMode( el, o.mode || "show" ),
show = mode === "show",
direction = o.direction || "left",
ref = (direction === "up" || direction === "down") ? "top" : "left",
positiveMotion = (direction === "up" || direction === "left"),
distance,
animation = {};
// Adjust
$.effects.save( el, props );
el.show();
distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
$.effects.createWrapper( el ).css({
overflow: "hidden"
});
if ( show ) {
el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
}
// Animation
animation[ ref ] = ( show ?
( positiveMotion ? "+=" : "-=") :
( positiveMotion ? "-=" : "+=")) +
distance;
// Animate
el.animate( animation, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
if ( mode === "hide" ) {
el.hide();
}
$.effects.restore( el, props );
$.effects.removeWrapper( el );
done();
}
});
};
})(jQuery);
(function( $, undefined ) {
$.effects.effect.transfer = function( o, done ) {
var elem = $( this ),
target = $( o.to ),
targetFixed = target.css( "position" ) === "fixed",
body = $("body"),
fixTop = targetFixed ? body.scrollTop() : 0,
fixLeft = targetFixed ? body.scrollLeft() : 0,
endPosition = target.offset(),
animation = {
top: endPosition.top - fixTop ,
left: endPosition.left - fixLeft ,
height: target.innerHeight(),
width: target.innerWidth()
},
startPosition = elem.offset(),
transfer = $( "
" )
.appendTo( document.body )
.addClass( o.className )
.css({
top: startPosition.top - fixTop ,
left: startPosition.left - fixLeft ,
height: elem.innerHeight(),
width: elem.innerWidth(),
position: targetFixed ? "fixed" : "absolute"
})
.animate( animation, o.duration, o.easing, function() {
transfer.remove();
done();
});
};
})(jQuery);
/*!
* jQuery Color Animations v@VERSION
* https://github.com/jquery/jquery-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
(function( jQuery, undefined ) {
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
// plusequals test for += 100 -= 100
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
// a set of RE's that can match strings and generate color tuples.
stringParsers = [{
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ],
execResult[ 3 ],
execResult[ 4 ]
];
}
}, {
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ] * 2.55,
execResult[ 2 ] * 2.55,
execResult[ 3 ] * 2.55,
execResult[ 4 ]
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ], 16 )
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
];
}
}, {
re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
space: "hsla",
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ] / 100,
execResult[ 3 ] / 100,
execResult[ 4 ]
];
}
}],
// jQuery.Color( )
color = jQuery.Color = function( color, green, blue, alpha ) {
return new jQuery.Color.fn.parse( color, green, blue, alpha );
},
spaces = {
rgba: {
props: {
red: {
idx: 0,
type: "byte"
},
green: {
idx: 1,
type: "byte"
},
blue: {
idx: 2,
type: "byte"
}
}
},
hsla: {
props: {
hue: {
idx: 0,
type: "degrees"
},
saturation: {
idx: 1,
type: "percent"
},
lightness: {
idx: 2,
type: "percent"
}
}
}
},
propTypes = {
"byte": {
floor: true,
max: 255
},
"percent": {
max: 1
},
"degrees": {
mod: 360,
floor: true
}
},
support = color.support = {},
// element for support tests
supportElem = jQuery( "
" )[ 0 ],
// colors = jQuery.Color.names
colors,
// local aliases of functions called often
each = jQuery.each;
// determine rgba support immediately
supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
// define cache name and alpha properties
// for rgba and hsla spaces
each( spaces, function( spaceName, space ) {
space.cache = "_" + spaceName;
space.props.alpha = {
idx: 3,
type: "percent",
def: 1
};
});
function clamp( value, prop, allowEmpty ) {
var type = propTypes[ prop.type ] || {};
if ( value == null ) {
return (allowEmpty || !prop.def) ? null : prop.def;
}
// ~~ is an short way of doing floor for positive numbers
value = type.floor ? ~~value : parseFloat( value );
// IE will pass in empty strings as value for alpha,
// which will hit this case
if ( isNaN( value ) ) {
return prop.def;
}
if ( type.mod ) {
// we add mod before modding to make sure that negatives values
// get converted properly: -10 -> 350
return (value + type.mod) % type.mod;
}
// for now all property types without mod have min and max
return 0 > value ? 0 : type.max < value ? type.max : value;
}
function stringParse( string ) {
var inst = color(),
rgba = inst._rgba = [];
string = string.toLowerCase();
each( stringParsers, function( i, parser ) {
var parsed,
match = parser.re.exec( string ),
values = match && parser.parse( match ),
spaceName = parser.space || "rgba";
if ( values ) {
parsed = inst[ spaceName ]( values );
// if this was an rgba parse the assignment might happen twice
// oh well....
inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
rgba = inst._rgba = parsed._rgba;
// exit each( stringParsers ) here because we matched
return false;
}
});
// Found a stringParser that handled it
if ( rgba.length ) {
// if this came from a parsed string, force "transparent" when alpha is 0
// chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
if ( rgba.join() === "0,0,0,0" ) {
jQuery.extend( rgba, colors.transparent );
}
return inst;
}
// named colors
return colors[ string ];
}
color.fn = jQuery.extend( color.prototype, {
parse: function( red, green, blue, alpha ) {
if ( red === undefined ) {
this._rgba = [ null, null, null, null ];
return this;
}
if ( red.jquery || red.nodeType ) {
red = jQuery( red ).css( green );
green = undefined;
}
var inst = this,
type = jQuery.type( red ),
rgba = this._rgba = [];
// more than 1 argument specified - assume ( red, green, blue, alpha )
if ( green !== undefined ) {
red = [ red, green, blue, alpha ];
type = "array";
}
if ( type === "string" ) {
return this.parse( stringParse( red ) || colors._default );
}
if ( type === "array" ) {
each( spaces.rgba.props, function( key, prop ) {
rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
});
return this;
}
if ( type === "object" ) {
if ( red instanceof color ) {
each( spaces, function( spaceName, space ) {
if ( red[ space.cache ] ) {
inst[ space.cache ] = red[ space.cache ].slice();
}
});
} else {
each( spaces, function( spaceName, space ) {
var cache = space.cache;
each( space.props, function( key, prop ) {
// if the cache doesn't exist, and we know how to convert
if ( !inst[ cache ] && space.to ) {
// if the value was null, we don't need to copy it
// if the key was alpha, we don't need to copy it either
if ( key === "alpha" || red[ key ] == null ) {
return;
}
inst[ cache ] = space.to( inst._rgba );
}
// this is the only case where we allow nulls for ALL properties.
// call clamp with alwaysAllowEmpty
inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
});
// everything defined but alpha?
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
// use the default of 1
inst[ cache ][ 3 ] = 1;
if ( space.from ) {
inst._rgba = space.from( inst[ cache ] );
}
}
});
}
return this;
}
},
is: function( compare ) {
var is = color( compare ),
same = true,
inst = this;
each( spaces, function( _, space ) {
var localCache,
isCache = is[ space.cache ];
if (isCache) {
localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
each( space.props, function( _, prop ) {
if ( isCache[ prop.idx ] != null ) {
same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
return same;
}
});
}
return same;
});
return same;
},
_space: function() {
var used = [],
inst = this;
each( spaces, function( spaceName, space ) {
if ( inst[ space.cache ] ) {
used.push( spaceName );
}
});
return used.pop();
},
transition: function( other, distance ) {
var end = color( other ),
spaceName = end._space(),
space = spaces[ spaceName ],
startColor = this.alpha() === 0 ? color( "transparent" ) : this,
start = startColor[ space.cache ] || space.to( startColor._rgba ),
result = start.slice();
end = end[ space.cache ];
each( space.props, function( key, prop ) {
var index = prop.idx,
startValue = start[ index ],
endValue = end[ index ],
type = propTypes[ prop.type ] || {};
// if null, don't override start value
if ( endValue === null ) {
return;
}
// if null - use end
if ( startValue === null ) {
result[ index ] = endValue;
} else {
if ( type.mod ) {
if ( endValue - startValue > type.mod / 2 ) {
startValue += type.mod;
} else if ( startValue - endValue > type.mod / 2 ) {
startValue -= type.mod;
}
}
result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
}
});
return this[ spaceName ]( result );
},
blend: function( opaque ) {
// if we are already opaque - return ourself
if ( this._rgba[ 3 ] === 1 ) {
return this;
}
var rgb = this._rgba.slice(),
a = rgb.pop(),
blend = color( opaque )._rgba;
return color( jQuery.map( rgb, function( v, i ) {
return ( 1 - a ) * blend[ i ] + a * v;
}));
},
toRgbaString: function() {
var prefix = "rgba(",
rgba = jQuery.map( this._rgba, function( v, i ) {
return v == null ? ( i > 2 ? 1 : 0 ) : v;
});
if ( rgba[ 3 ] === 1 ) {
rgba.pop();
prefix = "rgb(";
}
return prefix + rgba.join() + ")";
},
toHslaString: function() {
var prefix = "hsla(",
hsla = jQuery.map( this.hsla(), function( v, i ) {
if ( v == null ) {
v = i > 2 ? 1 : 0;
}
// catch 1 and 2
if ( i && i < 3 ) {
v = Math.round( v * 100 ) + "%";
}
return v;
});
if ( hsla[ 3 ] === 1 ) {
hsla.pop();
prefix = "hsl(";
}
return prefix + hsla.join() + ")";
},
toHexString: function( includeAlpha ) {
var rgba = this._rgba.slice(),
alpha = rgba.pop();
if ( includeAlpha ) {
rgba.push( ~~( alpha * 255 ) );
}
return "#" + jQuery.map( rgba, function( v ) {
// default to 0 when nulls exist
v = ( v || 0 ).toString( 16 );
return v.length === 1 ? "0" + v : v;
}).join("");
},
toString: function() {
return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
}
});
color.fn.parse.prototype = color.fn;
// hsla conversions adapted from:
// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
function hue2rgb( p, q, h ) {
h = ( h + 1 ) % 1;
if ( h * 6 < 1 ) {
return p + (q - p) * h * 6;
}
if ( h * 2 < 1) {
return q;
}
if ( h * 3 < 2 ) {
return p + (q - p) * ((2/3) - h) * 6;
}
return p;
}
spaces.hsla.to = function ( rgba ) {
if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
return [ null, null, null, rgba[ 3 ] ];
}
var r = rgba[ 0 ] / 255,
g = rgba[ 1 ] / 255,
b = rgba[ 2 ] / 255,
a = rgba[ 3 ],
max = Math.max( r, g, b ),
min = Math.min( r, g, b ),
diff = max - min,
add = max + min,
l = add * 0.5,
h, s;
if ( min === max ) {
h = 0;
} else if ( r === max ) {
h = ( 60 * ( g - b ) / diff ) + 360;
} else if ( g === max ) {
h = ( 60 * ( b - r ) / diff ) + 120;
} else {
h = ( 60 * ( r - g ) / diff ) + 240;
}
// chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
// otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
if ( diff === 0 ) {
s = 0;
} else if ( l <= 0.5 ) {
s = diff / add;
} else {
s = diff / ( 2 - add );
}
return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
};
spaces.hsla.from = function ( hsla ) {
if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
return [ null, null, null, hsla[ 3 ] ];
}
var h = hsla[ 0 ] / 360,
s = hsla[ 1 ],
l = hsla[ 2 ],
a = hsla[ 3 ],
q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
p = 2 * l - q;
return [
Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
Math.round( hue2rgb( p, q, h ) * 255 ),
Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
a
];
};
each( spaces, function( spaceName, space ) {
var props = space.props,
cache = space.cache,
to = space.to,
from = space.from;
// makes rgba() and hsla()
color.fn[ spaceName ] = function( value ) {
// generate a cache for this space if it doesn't exist
if ( to && !this[ cache ] ) {
this[ cache ] = to( this._rgba );
}
if ( value === undefined ) {
return this[ cache ].slice();
}
var ret,
type = jQuery.type( value ),
arr = ( type === "array" || type === "object" ) ? value : arguments,
local = this[ cache ].slice();
each( props, function( key, prop ) {
var val = arr[ type === "object" ? key : prop.idx ];
if ( val == null ) {
val = local[ prop.idx ];
}
local[ prop.idx ] = clamp( val, prop );
});
if ( from ) {
ret = color( from( local ) );
ret[ cache ] = local;
return ret;
} else {
return color( local );
}
};
// makes red() green() blue() alpha() hue() saturation() lightness()
each( props, function( key, prop ) {
// alpha is included in more than one space
if ( color.fn[ key ] ) {
return;
}
color.fn[ key ] = function( value ) {
var vtype = jQuery.type( value ),
fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
local = this[ fn ](),
cur = local[ prop.idx ],
match;
if ( vtype === "undefined" ) {
return cur;
}
if ( vtype === "function" ) {
value = value.call( this, cur );
vtype = jQuery.type( value );
}
if ( value == null && prop.empty ) {
return this;
}
if ( vtype === "string" ) {
match = rplusequals.exec( value );
if ( match ) {
value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
}
}
local[ prop.idx ] = value;
return this[ fn ]( local );
};
});
});
// add cssHook and .fx.step function for each named hook.
// accept a space separated string of properties
color.hook = function( hook ) {
var hooks = hook.split( " " );
each( hooks, function( i, hook ) {
jQuery.cssHooks[ hook ] = {
set: function( elem, value ) {
var parsed, curElem,
backgroundColor = "";
if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
value = color( parsed || value );
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
while (
(backgroundColor === "" || backgroundColor === "transparent") &&
curElem && curElem.style
) {
try {
backgroundColor = jQuery.css( curElem, "backgroundColor" );
curElem = curElem.parentNode;
} catch ( e ) {
}
}
value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
backgroundColor :
"_default" );
}
value = value.toRgbaString();
}
try {
elem.style[ hook ] = value;
} catch( e ) {
// wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
}
}
};
jQuery.fx.step[ hook ] = function( fx ) {
if ( !fx.colorInit ) {
fx.start = color( fx.elem, hook );
fx.end = color( fx.end );
fx.colorInit = true;
}
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
};
});
};
color.hook( stepHooks );
jQuery.cssHooks.borderColor = {
expand: function( value ) {
var expanded = {};
each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
expanded[ "border" + part + "Color" ] = value;
});
return expanded;
}
};
// Basic color names only.
// Usage of any of the other color names requires adding yourself or including
// jquery.color.svg-names.js.
colors = jQuery.Color.names = {
// 4.1. Basic color keywords
aqua: "#00ffff",
black: "#000000",
blue: "#0000ff",
fuchsia: "#ff00ff",
gray: "#808080",
green: "#008000",
lime: "#00ff00",
maroon: "#800000",
navy: "#000080",
olive: "#808000",
purple: "#800080",
red: "#ff0000",
silver: "#c0c0c0",
teal: "#008080",
white: "#ffffff",
yellow: "#ffff00",
// 4.2.3. "transparent" color keyword
transparent: [ null, null, null, 0 ],
_default: "#ffffff"
};
})( jQuery );
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
'timeStamp', 'trace', 'warn'
];
var length = methods.length;
var console = (window.console = window.console || {});
while (length--) {
method = methods[length];
// Only stub undefined methods.
if (!console[method]) {
console[method] = noop;
}
}
}());
// Place any jQuery/helper plugins in here.
/*!
* jQuery carouFredSel 6.2.0
* Demo's and documentation:
* caroufredsel.dev7studios.com
*
* Copyright (c) 2013 Fred Heusschen
* www.frebsite.nl
*
* Dual licensed under the MIT and GPL licenses.
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*/
(function($) {
// LOCAL
if ( $.fn.carouFredSel )
{
return;
}
$.fn.caroufredsel = $.fn.carouFredSel = function(options, configs)
{
// no element
if (this.length == 0)
{
debug( true, 'No element found for "' + this.selector + '".' );
return this;
}
// multiple elements
if (this.length > 1)
{
return this.each(function() {
$(this).carouFredSel(options, configs);
});
}
var $cfs = this,
$tt0 = this[0],
starting_position = false;
if ($cfs.data('_cfs_isCarousel'))
{
starting_position = $cfs.triggerHandler('_cfs_triggerEvent', 'currentPosition');
$cfs.trigger('_cfs_triggerEvent', ['destroy', true]);
}
var FN = {};
FN._cfs_init = function(o, setOrig, start)
{
o = go_getObject($tt0, o);
o.items = go_getItemsObject($tt0, o.items);
o.scroll = go_getScrollObject($tt0, o.scroll);
o.auto = go_getAutoObject($tt0, o.auto);
o.prev = go_getPrevNextObject($tt0, o.prev);
o.next = go_getPrevNextObject($tt0, o.next);
o.pagination = go_getPaginationObject($tt0, o.pagination);
o.swipe = go_getSwipeObject($tt0, o.swipe);
o.mousewheel = go_getMousewheelObject($tt0, o.mousewheel);
if (setOrig)
{
opts_orig = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
}
opts = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
opts.d = cf_getDimensions(opts);
crsl.direction = (opts.direction == 'up' || opts.direction == 'left') ? 'next' : 'prev';
var a_itm = $cfs.children(),
avail_primary = ms_getParentSize($wrp, opts, 'width');
if (is_true(opts.cookie))
{
opts.cookie = 'caroufredsel_cookie_' + conf.serialNumber;
}
opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
// complement items and sizes
opts.items = in_complementItems(opts.items, opts, a_itm, start);
opts[opts.d['width']] = in_complementPrimarySize(opts[opts.d['width']], opts, a_itm);
opts[opts.d['height']] = in_complementSecondarySize(opts[opts.d['height']], opts, a_itm);
// primary size not set for a responsive carousel
if (opts.responsive)
{
if (!is_percentage(opts[opts.d['width']]))
{
opts[opts.d['width']] = '100%';
}
}
// primary size is percentage
if (is_percentage(opts[opts.d['width']]))
{
crsl.upDateOnWindowResize = true;
crsl.primarySizePercentage = opts[opts.d['width']];
opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage);
if (!opts.items.visible)
{
opts.items.visibleConf.variable = true;
}
}
if (opts.responsive)
{
opts.usePadding = false;
opts.padding = [0, 0, 0, 0];
opts.align = false;
opts.items.visibleConf.variable = false;
}
else
{
// visible-items not set
if (!opts.items.visible)
{
opts = in_complementVisibleItems(opts, avail_primary);
}
// primary size not set -> calculate it or set to "variable"
if (!opts[opts.d['width']])
{
if (!opts.items.visibleConf.variable && is_number(opts.items[opts.d['width']]) && opts.items.filter == '*')
{
opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
opts.align = false;
}
else
{
opts[opts.d['width']] = 'variable';
}
}
// align not set -> set to center if primary size is number
if (is_undefined(opts.align))
{
opts.align = (is_number(opts[opts.d['width']]))
? 'center'
: false;
}
// set variabe visible-items
if (opts.items.visibleConf.variable)
{
opts.items.visible = gn_getVisibleItemsNext(a_itm, opts, 0);
}
}
// set visible items by filter
if (opts.items.filter != '*' && !opts.items.visibleConf.variable)
{
opts.items.visibleConf.org = opts.items.visible;
opts.items.visible = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
}
opts.items.visible = cf_getItemsAdjust(opts.items.visible, opts, opts.items.visibleConf.adjust, $tt0);
opts.items.visibleConf.old = opts.items.visible;
if (opts.responsive)
{
if (!opts.items.visibleConf.min)
{
opts.items.visibleConf.min = opts.items.visible;
}
if (!opts.items.visibleConf.max)
{
opts.items.visibleConf.max = opts.items.visible;
}
opts = in_getResponsiveValues(opts, a_itm, avail_primary);
}
else
{
opts.padding = cf_getPadding(opts.padding);
if (opts.align == 'top')
{
opts.align = 'left';
}
else if (opts.align == 'bottom')
{
opts.align = 'right';
}
switch (opts.align)
{
// align: center, left or right
case 'center':
case 'left':
case 'right':
if (opts[opts.d['width']] != 'variable')
{
opts = in_getAlignPadding(opts, a_itm);
opts.usePadding = true;
}
break;
// padding
default:
opts.align = false;
opts.usePadding = (
opts.padding[0] == 0 &&
opts.padding[1] == 0 &&
opts.padding[2] == 0 &&
opts.padding[3] == 0
) ? false : true;
break;
}
}
if (!is_number(opts.scroll.duration))
{
opts.scroll.duration = 500;
}
if (is_undefined(opts.scroll.items))
{
opts.scroll.items = (opts.responsive || opts.items.visibleConf.variable || opts.items.filter != '*')
? 'visible'
: opts.items.visible;
}
opts.auto = $.extend(true, {}, opts.scroll, opts.auto);
opts.prev = $.extend(true, {}, opts.scroll, opts.prev);
opts.next = $.extend(true, {}, opts.scroll, opts.next);
opts.pagination = $.extend(true, {}, opts.scroll, opts.pagination);
// swipe and mousewheel extend later on, per direction
opts.auto = go_complementAutoObject($tt0, opts.auto);
opts.prev = go_complementPrevNextObject($tt0, opts.prev);
opts.next = go_complementPrevNextObject($tt0, opts.next);
opts.pagination = go_complementPaginationObject($tt0, opts.pagination);
opts.swipe = go_complementSwipeObject($tt0, opts.swipe);
opts.mousewheel = go_complementMousewheelObject($tt0, opts.mousewheel);
if (opts.synchronise)
{
opts.synchronise = cf_getSynchArr(opts.synchronise);
}
// DEPRECATED
if (opts.auto.onPauseStart)
{
opts.auto.onTimeoutStart = opts.auto.onPauseStart;
deprecated('auto.onPauseStart', 'auto.onTimeoutStart');
}
if (opts.auto.onPausePause)
{
opts.auto.onTimeoutPause = opts.auto.onPausePause;
deprecated('auto.onPausePause', 'auto.onTimeoutPause');
}
if (opts.auto.onPauseEnd)
{
opts.auto.onTimeoutEnd = opts.auto.onPauseEnd;
deprecated('auto.onPauseEnd', 'auto.onTimeoutEnd');
}
if (opts.auto.pauseDuration)
{
opts.auto.timeoutDuration = opts.auto.pauseDuration;
deprecated('auto.pauseDuration', 'auto.timeoutDuration');
}
// /DEPRECATED
}; // /init
FN._cfs_build = function() {
$cfs.data('_cfs_isCarousel', true);
var a_itm = $cfs.children(),
orgCSS = in_mapCss($cfs, ['textAlign', 'float', 'position', 'top', 'right', 'bottom', 'left', 'zIndex', 'width', 'height', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft']),
newPosition = 'relative';
switch (orgCSS.position)
{
case 'absolute':
case 'fixed':
newPosition = orgCSS.position;
break;
}
if (conf.wrapper == 'parent')
{
sz_storeOrigCss($wrp);
}
else
{
$wrp.css(orgCSS);
}
$wrp.css({
'overflow' : 'hidden',
'position' : newPosition
});
sz_storeOrigCss($cfs);
$cfs.data('_cfs_origCssZindex', orgCSS.zIndex);
$cfs.css({
'textAlign' : 'left',
'float' : 'none',
'position' : 'absolute',
'top' : 0,
'right' : 'auto',
'bottom' : 'auto',
'left' : 0,
'marginTop' : 0,
'marginRight' : 0,
'marginBottom' : 0,
'marginLeft' : 0
});
sz_storeMargin(a_itm, opts);
sz_storeOrigCss(a_itm);
if (opts.responsive)
{
sz_setResponsiveSizes(opts, a_itm);
}
}; // /build
FN._cfs_bind_events = function() {
FN._cfs_unbind_events();
// stop event
$cfs.bind(cf_e('stop', conf), function(e, imm) {
e.stopPropagation();
// button
if (!crsl.isStopped)
{
if (opts.auto.button)
{
opts.auto.button.addClass(cf_c('stopped', conf));
}
}
// set stopped
crsl.isStopped = true;
if (opts.auto.play)
{
opts.auto.play = false;
$cfs.trigger(cf_e('pause', conf), imm);
}
return true;
});
// finish event
$cfs.bind(cf_e('finish', conf), function(e) {
e.stopPropagation();
if (crsl.isScrolling)
{
sc_stopScroll(scrl);
}
return true;
});
// pause event
$cfs.bind(cf_e('pause', conf), function(e, imm, res) {
e.stopPropagation();
tmrs = sc_clearTimers(tmrs);
// immediately pause
if (imm && crsl.isScrolling)
{
scrl.isStopped = true;
var nst = getTime() - scrl.startTime;
scrl.duration -= nst;
if (scrl.pre)
{
scrl.pre.duration -= nst;
}
if (scrl.post)
{
scrl.post.duration -= nst;
}
sc_stopScroll(scrl, false);
}
// update remaining pause-time
if (!crsl.isPaused && !crsl.isScrolling)
{
if (res)
{
tmrs.timePassed += getTime() - tmrs.startTime;
}
}
// button
if (!crsl.isPaused)
{
if (opts.auto.button)
{
opts.auto.button.addClass(cf_c('paused', conf));
}
}
// set paused
crsl.isPaused = true;
// pause pause callback
if (opts.auto.onTimeoutPause)
{
var dur1 = opts.auto.timeoutDuration - tmrs.timePassed,
perc = 100 - Math.ceil( dur1 * 100 / opts.auto.timeoutDuration );
opts.auto.onTimeoutPause.call($tt0, perc, dur1);
}
return true;
});
// play event
$cfs.bind(cf_e('play', conf), function(e, dir, del, res) {
e.stopPropagation();
tmrs = sc_clearTimers(tmrs);
// sort params
var v = [dir, del, res],
t = ['string', 'number', 'boolean'],
a = cf_sortParams(v, t);
dir = a[0];
del = a[1];
res = a[2];
if (dir != 'prev' && dir != 'next')
{
dir = crsl.direction;
}
if (!is_number(del))
{
del = 0;
}
if (!is_boolean(res))
{
res = false;
}
// stopped?
if (res)
{
crsl.isStopped = false;
opts.auto.play = true;
}
if (!opts.auto.play)
{
e.stopImmediatePropagation();
return debug(conf, 'Carousel stopped: Not scrolling.');
}
// button
if (crsl.isPaused)
{
if (opts.auto.button)
{
opts.auto.button.removeClass(cf_c('stopped', conf));
opts.auto.button.removeClass(cf_c('paused', conf));
}
}
// set playing
crsl.isPaused = false;
tmrs.startTime = getTime();
// timeout the scrolling
var dur1 = opts.auto.timeoutDuration + del;
dur2 = dur1 - tmrs.timePassed;
perc = 100 - Math.ceil(dur2 * 100 / dur1);
if (opts.auto.progress)
{
tmrs.progress = setInterval(function() {
var pasd = getTime() - tmrs.startTime + tmrs.timePassed,
perc = Math.ceil(pasd * 100 / dur1);
opts.auto.progress.updater.call(opts.auto.progress.bar[0], perc);
}, opts.auto.progress.interval);
}
tmrs.auto = setTimeout(function() {
if (opts.auto.progress)
{
opts.auto.progress.updater.call(opts.auto.progress.bar[0], 100);
}
if (opts.auto.onTimeoutEnd)
{
opts.auto.onTimeoutEnd.call($tt0, perc, dur2);
}
if (crsl.isScrolling)
{
$cfs.trigger(cf_e('play', conf), dir);
}
else
{
$cfs.trigger(cf_e(dir, conf), opts.auto);
}
}, dur2);
// pause start callback
if (opts.auto.onTimeoutStart)
{
opts.auto.onTimeoutStart.call($tt0, perc, dur2);
}
return true;
});
// resume event
$cfs.bind(cf_e('resume', conf), function(e) {
e.stopPropagation();
if (scrl.isStopped)
{
scrl.isStopped = false;
crsl.isPaused = false;
crsl.isScrolling = true;
scrl.startTime = getTime();
sc_startScroll(scrl, conf);
}
else
{
$cfs.trigger(cf_e('play', conf));
}
return true;
});
// prev + next events
$cfs.bind(cf_e('prev', conf)+' '+cf_e('next', conf), function(e, obj, num, clb, que) {
e.stopPropagation();
// stopped or hidden carousel, don't scroll, don't queue
if (crsl.isStopped || $cfs.is(':hidden'))
{
e.stopImmediatePropagation();
return debug(conf, 'Carousel stopped or hidden: Not scrolling.');
}
// not enough items
var minimum = (is_number(opts.items.minimum)) ? opts.items.minimum : opts.items.visible + 1;
if (minimum > itms.total)
{
e.stopImmediatePropagation();
return debug(conf, 'Not enough items ('+itms.total+' total, '+minimum+' needed): Not scrolling.');
}
// get config
var v = [obj, num, clb, que],
t = ['object', 'number/string', 'function', 'boolean'],
a = cf_sortParams(v, t);
obj = a[0];
num = a[1];
clb = a[2];
que = a[3];
var eType = e.type.slice(conf.events.prefix.length);
if (!is_object(obj))
{
obj = {};
}
if (is_function(clb))
{
obj.onAfter = clb;
}
if (is_boolean(que))
{
obj.queue = que;
}
obj = $.extend(true, {}, opts[eType], obj);
// test conditions callback
if (obj.conditions && !obj.conditions.call($tt0, eType))
{
e.stopImmediatePropagation();
return debug(conf, 'Callback "conditions" returned false.');
}
if (!is_number(num))
{
if (opts.items.filter != '*')
{
num = 'visible';
}
else
{
var arr = [num, obj.items, opts[eType].items];
for (var a = 0, l = arr.length; a < l; a++)
{
if (is_number(arr[a]) || arr[a] == 'page' || arr[a] == 'visible') {
num = arr[a];
break;
}
}
}
switch(num) {
case 'page':
e.stopImmediatePropagation();
return $cfs.triggerHandler(cf_e(eType+'Page', conf), [obj, clb]);
break;
case 'visible':
if (!opts.items.visibleConf.variable && opts.items.filter == '*')
{
num = opts.items.visible;
}
break;
}
}
// resume animation, add current to queue
if (scrl.isStopped)
{
$cfs.trigger(cf_e('resume', conf));
$cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
e.stopImmediatePropagation();
return debug(conf, 'Carousel resumed scrolling.');
}
// queue if scrolling
if (obj.duration > 0)
{
if (crsl.isScrolling)
{
if (obj.queue)
{
if (obj.queue == 'last')
{
queu = [];
}
if (obj.queue != 'first' || queu.length == 0)
{
$cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
}
}
e.stopImmediatePropagation();
return debug(conf, 'Carousel currently scrolling.');
}
}
tmrs.timePassed = 0;
$cfs.trigger(cf_e('slide_'+eType, conf), [obj, num]);
// synchronise
if (opts.synchronise)
{
var s = opts.synchronise,
c = [obj, num];
for (var j = 0, l = s.length; j < l; j++) {
var d = eType;
if (!s[j][2])
{
d = (d == 'prev') ? 'next' : 'prev';
}
if (!s[j][1])
{
c[0] = s[j][0].triggerHandler('_cfs_triggerEvent', ['configuration', d]);
}
c[1] = num + s[j][3];
s[j][0].trigger('_cfs_triggerEvent', ['slide_'+d, c]);
}
}
return true;
});
// prev event
$cfs.bind(cf_e('slide_prev', conf), function(e, sO, nI) {
e.stopPropagation();
var a_itm = $cfs.children();
// non-circular at start, scroll to end
if (!opts.circular)
{
if (itms.first == 0)
{
if (opts.infinite)
{
$cfs.trigger(cf_e('next', conf), itms.total-1);
}
return e.stopImmediatePropagation();
}
}
sz_resetMargin(a_itm, opts);
// find number of items to scroll
if (!is_number(nI))
{
if (opts.items.visibleConf.variable)
{
nI = gn_getVisibleItemsPrev(a_itm, opts, itms.total-1);
}
else if (opts.items.filter != '*')
{
var xI = (is_number(sO.items)) ? sO.items : gn_getVisibleOrg($cfs, opts);
nI = gn_getScrollItemsPrevFilter(a_itm, opts, itms.total-1, xI);
}
else
{
nI = opts.items.visible;
}
nI = cf_getAdjust(nI, opts, sO.items, $tt0);
}
// prevent non-circular from scrolling to far
if (!opts.circular)
{
if (itms.total - nI < itms.first)
{
nI = itms.total - itms.first;
}
}
// set new number of visible items
opts.items.visibleConf.old = opts.items.visible;
if (opts.items.visibleConf.variable)
{
var vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
if (opts.items.visible+nI <= vI && nI < itms.total)
{
nI++;
vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
}
opts.items.visible = vI;
}
else if (opts.items.filter != '*')
{
var vI = gn_getVisibleItemsNextFilter(a_itm, opts, itms.total-nI);
opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
}
sz_resetMargin(a_itm, opts, true);
// scroll 0, don't scroll
if (nI == 0)
{
e.stopImmediatePropagation();
return debug(conf, '0 items to scroll: Not scrolling.');
}
debug(conf, 'Scrolling '+nI+' items backward.');
// save new config
itms.first += nI;
while (itms.first >= itms.total)
{
itms.first -= itms.total;
}
// non-circular callback
if (!opts.circular)
{
if (itms.first == 0 && sO.onEnd)
{
sO.onEnd.call($tt0, 'prev');
}
if (!opts.infinite)
{
nv_enableNavi(opts, itms.first, conf);
}
}
// rearrange items
$cfs.children().slice(itms.total-nI, itms.total).prependTo($cfs);
if (itms.total < opts.items.visible + nI)
{
$cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
}
// the needed items
var a_itm = $cfs.children(),
i_old = gi_getOldItemsPrev(a_itm, opts, nI),
i_new = gi_getNewItemsPrev(a_itm, opts),
i_cur_l = a_itm.eq(nI-1),
i_old_l = i_old.last(),
i_new_l = i_new.last();
sz_resetMargin(a_itm, opts);
var pL = 0,
pR = 0;
if (opts.align)
{
var p = cf_getAlignPadding(i_new, opts);
pL = p[0];
pR = p[1];
}
var oL = (pL < 0) ? opts.padding[opts.d[3]] : 0;
// hide items for fx directscroll
var hiddenitems = false,
i_skp = $();
if (opts.items.visible < nI)
{
i_skp = a_itm.slice(opts.items.visibleConf.old, nI);
if (sO.fx == 'directscroll')
{
var orgW = opts.items[opts.d['width']];
hiddenitems = i_skp;
i_cur_l = i_new_l;
sc_hideHiddenItems(hiddenitems);
opts.items[opts.d['width']] = 'variable';
}
}
// save new sizes
var $cf2 = false,
i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
w_siz = cf_mapWrapperSizes(ms_getSizes(i_new, opts, true), opts, !opts.usePadding),
i_siz_vis = 0,
a_cfs = {},
a_wsz = {},
a_cur = {},
a_old = {},
a_new = {},
a_lef = {},
a_lef_vis = {},
a_dur = sc_getDuration(sO, opts, nI, i_siz);
switch(sO.fx)
{
case 'cover':
case 'cover-fade':
i_siz_vis = ms_getTotalSize(a_itm.slice(0, opts.items.visible), opts, 'width');
break;
}
if (hiddenitems)
{
opts.items[opts.d['width']] = orgW;
}
sz_resetMargin(a_itm, opts, true);
if (pR >= 0)
{
sz_resetMargin(i_old_l, opts, opts.padding[opts.d[1]]);
}
if (pL >= 0)
{
sz_resetMargin(i_cur_l, opts, opts.padding[opts.d[3]]);
}
if (opts.align)
{
opts.padding[opts.d[1]] = pR;
opts.padding[opts.d[3]] = pL;
}
a_lef[opts.d['left']] = -(i_siz - oL);
a_lef_vis[opts.d['left']] = -(i_siz_vis - oL);
a_wsz[opts.d['left']] = w_siz[opts.d['width']];
// scrolling functions
var _s_wrapper = function() {},
_a_wrapper = function() {},
_s_paddingold = function() {},
_a_paddingold = function() {},
_s_paddingnew = function() {},
_a_paddingnew = function() {},
_s_paddingcur = function() {},
_a_paddingcur = function() {},
_onafter = function() {},
_moveitems = function() {},
_position = function() {};
// clone carousel
switch(sO.fx)
{
case 'crossfade':
case 'cover':
case 'cover-fade':
case 'uncover':
case 'uncover-fade':
$cf2 = $cfs.clone(true).appendTo($wrp);
break;
}
switch(sO.fx)
{
case 'crossfade':
case 'uncover':
case 'uncover-fade':
$cf2.children().slice(0, nI).remove();
$cf2.children().slice(opts.items.visibleConf.old).remove();
break;
case 'cover':
case 'cover-fade':
$cf2.children().slice(opts.items.visible).remove();
$cf2.css(a_lef_vis);
break;
}
$cfs.css(a_lef);
// reset all scrolls
scrl = sc_setScroll(a_dur, sO.easing, conf);
// animate / set carousel
a_cfs[opts.d['left']] = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
// animate / set wrapper
if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable')
{
_s_wrapper = function() {
$wrp.css(w_siz);
};
_a_wrapper = function() {
scrl.anims.push([$wrp, w_siz]);
};
}
// animate / set items
if (opts.usePadding)
{
if (i_new_l.not(i_cur_l).length)
{
a_cur[opts.d['marginRight']] = i_cur_l.data('_cfs_origCssMargin');
if (pL < 0)
{
i_cur_l.css(a_cur);
}
else
{
_s_paddingcur = function() {
i_cur_l.css(a_cur);
};
_a_paddingcur = function() {
scrl.anims.push([i_cur_l, a_cur]);
};
}
}
switch(sO.fx)
{
case 'cover':
case 'cover-fade':
$cf2.children().eq(nI-1).css(a_cur);
break;
}
if (i_new_l.not(i_old_l).length)
{
a_old[opts.d['marginRight']] = i_old_l.data('_cfs_origCssMargin');
_s_paddingold = function() {
i_old_l.css(a_old);
};
_a_paddingold = function() {
scrl.anims.push([i_old_l, a_old]);
};
}
if (pR >= 0)
{
a_new[opts.d['marginRight']] = i_new_l.data('_cfs_origCssMargin') + opts.padding[opts.d[1]];
_s_paddingnew = function() {
i_new_l.css(a_new);
};
_a_paddingnew = function() {
scrl.anims.push([i_new_l, a_new]);
};
}
}
// set position
_position = function() {
$cfs.css(a_cfs);
};
var overFill = opts.items.visible+nI-itms.total;
// rearrange items
_moveitems = function() {
if (overFill > 0)
{
$cfs.children().slice(itms.total).remove();
i_old = $( $cfs.children().slice(itms.total-(opts.items.visible-overFill)).get().concat( $cfs.children().slice(0, overFill).get() ) );
}
sc_showHiddenItems(hiddenitems);
if (opts.usePadding)
{
var l_itm = $cfs.children().eq(opts.items.visible+nI-1);
l_itm.css(opts.d['marginRight'], l_itm.data('_cfs_origCssMargin'));
}
};
var cb_arguments = sc_mapCallbackArguments(i_old, i_skp, i_new, nI, 'prev', a_dur, w_siz);
// fire onAfter callbacks
_onafter = function() {
sc_afterScroll($cfs, $cf2, sO);
crsl.isScrolling = false;
clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk);
queu = sc_fireQueue($cfs, queu, conf);
if (!crsl.isPaused)
{
$cfs.trigger(cf_e('play', conf));
}
};
// fire onBefore callback
crsl.isScrolling = true;
tmrs = sc_clearTimers(tmrs);
clbk.onBefore = sc_fireCallbacks($tt0, sO, 'onBefore', cb_arguments, clbk);
switch(sO.fx)
{
case 'none':
$cfs.css(a_cfs);
_s_wrapper();
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
_onafter();
break;
case 'fade':
scrl.anims.push([$cfs, { 'opacity': 0 }, function() {
_s_wrapper();
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
scrl = sc_setScroll(a_dur, sO.easing, conf);
scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
sc_startScroll(scrl, conf);
}]);
break;
case 'crossfade':
$cfs.css({ 'opacity': 0 });
scrl.anims.push([$cf2, { 'opacity': 0 }]);
scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
break;
case 'cover':
scrl.anims.push([$cf2, a_cfs, function() {
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
_onafter();
}]);
_a_wrapper();
break;
case 'cover-fade':
scrl.anims.push([$cfs, { 'opacity': 0 }]);
scrl.anims.push([$cf2, a_cfs, function() {
$cfs.css({ 'opacity': 1 });
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
_onafter();
}]);
_a_wrapper();
break;
case 'uncover':
scrl.anims.push([$cf2, a_wsz, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
break;
case 'uncover-fade':
$cfs.css({ 'opacity': 0 });
scrl.anims.push([$cfs, { 'opacity': 1 }]);
scrl.anims.push([$cf2, a_wsz, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingnew();
_s_paddingcur();
_position();
_moveitems();
break;
default:
scrl.anims.push([$cfs, a_cfs, function() {
_moveitems();
_onafter();
}]);
_a_wrapper();
_a_paddingold();
_a_paddingnew();
_a_paddingcur();
break;
}
sc_startScroll(scrl, conf);
cf_setCookie(opts.cookie, $cfs, conf);
$cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
return true;
});
// next event
$cfs.bind(cf_e('slide_next', conf), function(e, sO, nI) {
e.stopPropagation();
var a_itm = $cfs.children();
// non-circular at end, scroll to start
if (!opts.circular)
{
if (itms.first == opts.items.visible)
{
if (opts.infinite)
{
$cfs.trigger(cf_e('prev', conf), itms.total-1);
}
return e.stopImmediatePropagation();
}
}
sz_resetMargin(a_itm, opts);
// find number of items to scroll
if (!is_number(nI))
{
if (opts.items.filter != '*')
{
var xI = (is_number(sO.items)) ? sO.items : gn_getVisibleOrg($cfs, opts);
nI = gn_getScrollItemsNextFilter(a_itm, opts, 0, xI);
}
else
{
nI = opts.items.visible;
}
nI = cf_getAdjust(nI, opts, sO.items, $tt0);
}
var lastItemNr = (itms.first == 0) ? itms.total : itms.first;
// prevent non-circular from scrolling to far
if (!opts.circular)
{
if (opts.items.visibleConf.variable)
{
var vI = gn_getVisibleItemsNext(a_itm, opts, nI),
xI = gn_getVisibleItemsPrev(a_itm, opts, lastItemNr-1);
}
else
{
var vI = opts.items.visible,
xI = opts.items.visible;
}
if (nI + vI > lastItemNr)
{
nI = lastItemNr - xI;
}
}
// set new number of visible items
opts.items.visibleConf.old = opts.items.visible;
if (opts.items.visibleConf.variable)
{
var vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
while (opts.items.visible-nI >= vI && nI < itms.total)
{
nI++;
vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
}
opts.items.visible = vI;
}
else if (opts.items.filter != '*')
{
var vI = gn_getVisibleItemsNextFilter(a_itm, opts, nI);
opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
}
sz_resetMargin(a_itm, opts, true);
// scroll 0, don't scroll
if (nI == 0)
{
e.stopImmediatePropagation();
return debug(conf, '0 items to scroll: Not scrolling.');
}
debug(conf, 'Scrolling '+nI+' items forward.');
// save new config
itms.first -= nI;
while (itms.first < 0)
{
itms.first += itms.total;
}
// non-circular callback
if (!opts.circular)
{
if (itms.first == opts.items.visible && sO.onEnd)
{
sO.onEnd.call($tt0, 'next');
}
if (!opts.infinite)
{
nv_enableNavi(opts, itms.first, conf);
}
}
// rearrange items
if (itms.total < opts.items.visible+nI)
{
$cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
}
// the needed items
var a_itm = $cfs.children(),
i_old = gi_getOldItemsNext(a_itm, opts),
i_new = gi_getNewItemsNext(a_itm, opts, nI),
i_cur_l = a_itm.eq(nI-1),
i_old_l = i_old.last(),
i_new_l = i_new.last();
sz_resetMargin(a_itm, opts);
var pL = 0,
pR = 0;
if (opts.align)
{
var p = cf_getAlignPadding(i_new, opts);
pL = p[0];
pR = p[1];
}
// hide items for fx directscroll
var hiddenitems = false,
i_skp = $();
if (opts.items.visibleConf.old < nI)
{
i_skp = a_itm.slice(opts.items.visibleConf.old, nI);
if (sO.fx == 'directscroll')
{
var orgW = opts.items[opts.d['width']];
hiddenitems = i_skp;
i_cur_l = i_old_l;
sc_hideHiddenItems(hiddenitems);
opts.items[opts.d['width']] = 'variable';
}
}
// save new sizes
var $cf2 = false,
i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
w_siz = cf_mapWrapperSizes(ms_getSizes(i_new, opts, true), opts, !opts.usePadding),
i_siz_vis = 0,
a_cfs = {},
a_cfs_vis = {},
a_cur = {},
a_old = {},
a_lef = {},
a_dur = sc_getDuration(sO, opts, nI, i_siz);
switch(sO.fx)
{
case 'uncover':
case 'uncover-fade':
i_siz_vis = ms_getTotalSize(a_itm.slice(0, opts.items.visibleConf.old), opts, 'width');
break;
}
if (hiddenitems)
{
opts.items[opts.d['width']] = orgW;
}
if (opts.align)
{
if (opts.padding[opts.d[1]] < 0)
{
opts.padding[opts.d[1]] = 0;
}
}
sz_resetMargin(a_itm, opts, true);
sz_resetMargin(i_old_l, opts, opts.padding[opts.d[1]]);
if (opts.align)
{
opts.padding[opts.d[1]] = pR;
opts.padding[opts.d[3]] = pL;
}
a_lef[opts.d['left']] = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
// scrolling functions
var _s_wrapper = function() {},
_a_wrapper = function() {},
_s_paddingold = function() {},
_a_paddingold = function() {},
_s_paddingcur = function() {},
_a_paddingcur = function() {},
_onafter = function() {},
_moveitems = function() {},
_position = function() {};
// clone carousel
switch(sO.fx)
{
case 'crossfade':
case 'cover':
case 'cover-fade':
case 'uncover':
case 'uncover-fade':
$cf2 = $cfs.clone(true).appendTo($wrp);
$cf2.children().slice(opts.items.visibleConf.old).remove();
break;
}
switch(sO.fx)
{
case 'crossfade':
case 'cover':
case 'cover-fade':
$cfs.css('zIndex', 1);
$cf2.css('zIndex', 0);
break;
}
// reset all scrolls
scrl = sc_setScroll(a_dur, sO.easing, conf);
// animate / set carousel
a_cfs[opts.d['left']] = -i_siz;
a_cfs_vis[opts.d['left']] = -i_siz_vis;
if (pL < 0)
{
a_cfs[opts.d['left']] += pL;
}
// animate / set wrapper
if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable')
{
_s_wrapper = function() {
$wrp.css(w_siz);
};
_a_wrapper = function() {
scrl.anims.push([$wrp, w_siz]);
};
}
// animate / set items
if (opts.usePadding)
{
var i_new_l_m = i_new_l.data('_cfs_origCssMargin');
if (pR >= 0)
{
i_new_l_m += opts.padding[opts.d[1]];
}
i_new_l.css(opts.d['marginRight'], i_new_l_m);
if (i_cur_l.not(i_old_l).length)
{
a_old[opts.d['marginRight']] = i_old_l.data('_cfs_origCssMargin');
}
_s_paddingold = function() {
i_old_l.css(a_old);
};
_a_paddingold = function() {
scrl.anims.push([i_old_l, a_old]);
};
var i_cur_l_m = i_cur_l.data('_cfs_origCssMargin');
if (pL > 0)
{
i_cur_l_m += opts.padding[opts.d[3]];
}
a_cur[opts.d['marginRight']] = i_cur_l_m;
_s_paddingcur = function() {
i_cur_l.css(a_cur);
};
_a_paddingcur = function() {
scrl.anims.push([i_cur_l, a_cur]);
};
}
// set position
_position = function() {
$cfs.css(a_lef);
};
var overFill = opts.items.visible+nI-itms.total;
// rearrange items
_moveitems = function() {
if (overFill > 0)
{
$cfs.children().slice(itms.total).remove();
}
var l_itm = $cfs.children().slice(0, nI).appendTo($cfs).last();
if (overFill > 0)
{
i_new = gi_getCurrentItems(a_itm, opts);
}
sc_showHiddenItems(hiddenitems);
if (opts.usePadding)
{
if (itms.total < opts.items.visible+nI) {
var i_cur_l = $cfs.children().eq(opts.items.visible-1);
i_cur_l.css(opts.d['marginRight'], i_cur_l.data('_cfs_origCssMargin') + opts.padding[opts.d[1]]);
}
l_itm.css(opts.d['marginRight'], l_itm.data('_cfs_origCssMargin'));
}
};
var cb_arguments = sc_mapCallbackArguments(i_old, i_skp, i_new, nI, 'next', a_dur, w_siz);
// fire onAfter callbacks
_onafter = function() {
$cfs.css('zIndex', $cfs.data('_cfs_origCssZindex'));
sc_afterScroll($cfs, $cf2, sO);
crsl.isScrolling = false;
clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk);
queu = sc_fireQueue($cfs, queu, conf);
if (!crsl.isPaused)
{
$cfs.trigger(cf_e('play', conf));
}
};
// fire onBefore callbacks
crsl.isScrolling = true;
tmrs = sc_clearTimers(tmrs);
clbk.onBefore = sc_fireCallbacks($tt0, sO, 'onBefore', cb_arguments, clbk);
switch(sO.fx)
{
case 'none':
$cfs.css(a_cfs);
_s_wrapper();
_s_paddingold();
_s_paddingcur();
_position();
_moveitems();
_onafter();
break;
case 'fade':
scrl.anims.push([$cfs, { 'opacity': 0 }, function() {
_s_wrapper();
_s_paddingold();
_s_paddingcur();
_position();
_moveitems();
scrl = sc_setScroll(a_dur, sO.easing, conf);
scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
sc_startScroll(scrl, conf);
}]);
break;
case 'crossfade':
$cfs.css({ 'opacity': 0 });
scrl.anims.push([$cf2, { 'opacity': 0 }]);
scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingcur();
_position();
_moveitems();
break;
case 'cover':
$cfs.css(opts.d['left'], $wrp[opts.d['width']]());
scrl.anims.push([$cfs, a_lef, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingcur();
_moveitems();
break;
case 'cover-fade':
$cfs.css(opts.d['left'], $wrp[opts.d['width']]());
scrl.anims.push([$cf2, { 'opacity': 0 }]);
scrl.anims.push([$cfs, a_lef, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingcur();
_moveitems();
break;
case 'uncover':
scrl.anims.push([$cf2, a_cfs_vis, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingcur();
_position();
_moveitems();
break;
case 'uncover-fade':
$cfs.css({ 'opacity': 0 });
scrl.anims.push([$cfs, { 'opacity': 1 }]);
scrl.anims.push([$cf2, a_cfs_vis, _onafter]);
_a_wrapper();
_s_paddingold();
_s_paddingcur();
_position();
_moveitems();
break;
default:
scrl.anims.push([$cfs, a_cfs, function() {
_position();
_moveitems();
_onafter();
}]);
_a_wrapper();
_a_paddingold();
_a_paddingcur();
break;
}
sc_startScroll(scrl, conf);
cf_setCookie(opts.cookie, $cfs, conf);
$cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
return true;
});
// slideTo event
$cfs.bind(cf_e('slideTo', conf), function(e, num, dev, org, obj, dir, clb) {
e.stopPropagation();
var v = [num, dev, org, obj, dir, clb],
t = ['string/number/object', 'number', 'boolean', 'object', 'string', 'function'],
a = cf_sortParams(v, t);
obj = a[3];
dir = a[4];
clb = a[5];
num = gn_getItemIndex(a[0], a[1], a[2], itms, $cfs);
if (num == 0)
{
return false;
}
if (!is_object(obj))
{
obj = false;
}
if (dir != 'prev' && dir != 'next')
{
if (opts.circular)
{
dir = (num <= itms.total / 2) ? 'next' : 'prev';
}
else
{
dir = (itms.first == 0 || itms.first > num) ? 'next' : 'prev';
}
}
if (dir == 'prev')
{
num = itms.total-num;
}
$cfs.trigger(cf_e(dir, conf), [obj, num, clb]);
return true;
});
// prevPage event
$cfs.bind(cf_e('prevPage', conf), function(e, obj, clb) {
e.stopPropagation();
var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur-1, obj, 'prev', clb]);
});
// nextPage event
$cfs.bind(cf_e('nextPage', conf), function(e, obj, clb) {
e.stopPropagation();
var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur+1, obj, 'next', clb]);
});
// slideToPage event
$cfs.bind(cf_e('slideToPage', conf), function(e, pag, obj, dir, clb) {
e.stopPropagation();
if (!is_number(pag))
{
pag = $cfs.triggerHandler(cf_e('currentPage', conf));
}
var ipp = opts.pagination.items || opts.items.visible,
max = Math.ceil(itms.total / ipp)-1;
if (pag < 0)
{
pag = max;
}
if (pag > max)
{
pag = 0;
}
return $cfs.triggerHandler(cf_e('slideTo', conf), [pag*ipp, 0, true, obj, dir, clb]);
});
// jumpToStart event
$cfs.bind(cf_e('jumpToStart', conf), function(e, s) {
e.stopPropagation();
if (s)
{
s = gn_getItemIndex(s, 0, true, itms, $cfs);
}
else
{
s = 0;
}
s += itms.first;
if (s != 0)
{
if (itms.total > 0)
{
while (s > itms.total)
{
s -= itms.total;
}
}
$cfs.prepend($cfs.children().slice(s, itms.total));
}
return true;
});
// synchronise event
$cfs.bind(cf_e('synchronise', conf), function(e, s) {
e.stopPropagation();
if (s)
{
s = cf_getSynchArr(s);
}
else if (opts.synchronise)
{
s = opts.synchronise;
}
else
{
return debug(conf, 'No carousel to synchronise.');
}
var n = $cfs.triggerHandler(cf_e('currentPosition', conf)),
x = true;
for (var j = 0, l = s.length; j < l; j++)
{
if (!s[j][0].triggerHandler(cf_e('slideTo', conf), [n, s[j][3], true]))
{
x = false;
}
}
return x;
});
// queue event
$cfs.bind(cf_e('queue', conf), function(e, dir, opt) {
e.stopPropagation();
if (is_function(dir))
{
dir.call($tt0, queu);
}
else if (is_array(dir))
{
queu = dir;
}
else if (!is_undefined(dir))
{
queu.push([dir, opt]);
}
return queu;
});
// insertItem event
$cfs.bind(cf_e('insertItem', conf), function(e, itm, num, org, dev) {
e.stopPropagation();
var v = [itm, num, org, dev],
t = ['string/object', 'string/number/object', 'boolean', 'number'],
a = cf_sortParams(v, t);
itm = a[0];
num = a[1];
org = a[2];
dev = a[3];
if (is_object(itm) && !is_jquery(itm))
{
itm = $(itm);
}
else if (is_string(itm))
{
itm = $(itm);
}
if (!is_jquery(itm) || itm.length == 0)
{
return debug(conf, 'Not a valid object.');
}
if (is_undefined(num))
{
num = 'end';
}
sz_storeMargin(itm, opts);
sz_storeOrigCss(itm);
var orgNum = num,
before = 'before';
if (num == 'end')
{
if (org)
{
if (itms.first == 0)
{
num = itms.total-1;
before = 'after';
}
else
{
num = itms.first;
itms.first += itm.length;
}
if (num < 0)
{
num = 0;
}
}
else
{
num = itms.total-1;
before = 'after';
}
}
else
{
num = gn_getItemIndex(num, dev, org, itms, $cfs);
}
var $cit = $cfs.children().eq(num);
if ($cit.length)
{
$cit[before](itm);
}
else
{
debug(conf, 'Correct insert-position not found! Appending item to the end.');
$cfs.append(itm);
}
if (orgNum != 'end' && !org)
{
if (num < itms.first)
{
itms.first += itm.length;
}
}
itms.total = $cfs.children().length;
if (itms.first >= itms.total)
{
itms.first -= itms.total;
}
$cfs.trigger(cf_e('updateSizes', conf));
$cfs.trigger(cf_e('linkAnchors', conf));
return true;
});
// removeItem event
$cfs.bind(cf_e('removeItem', conf), function(e, num, org, dev) {
e.stopPropagation();
var v = [num, org, dev],
t = ['string/number/object', 'boolean', 'number'],
a = cf_sortParams(v, t);
num = a[0];
org = a[1];
dev = a[2];
var removed = false;
if (num instanceof $ && num.length > 1)
{
$removed = $();
num.each(function(i, el) {
var $rem = $cfs.trigger(cf_e('removeItem', conf), [$(this), org, dev]);
if ( $rem )
{
$removed = $removed.add($rem);
}
});
return $removed;
}
if (is_undefined(num) || num == 'end')
{
$removed = $cfs.children().last();
}
else
{
num = gn_getItemIndex(num, dev, org, itms, $cfs);
var $removed = $cfs.children().eq(num);
if ( $removed.length )
{
if (num < itms.first)
{
itms.first -= $removed.length;
}
}
}
if ( $removed && $removed.length )
{
$removed.detach();
itms.total = $cfs.children().length;
$cfs.trigger(cf_e('updateSizes', conf));
}
return $removed;
});
// onBefore and onAfter event
$cfs.bind(cf_e('onBefore', conf)+' '+cf_e('onAfter', conf), function(e, fn) {
e.stopPropagation();
var eType = e.type.slice(conf.events.prefix.length);
if (is_array(fn))
{
clbk[eType] = fn;
}
if (is_function(fn))
{
clbk[eType].push(fn);
}
return clbk[eType];
});
// currentPosition event
$cfs.bind(cf_e('currentPosition', conf), function(e, fn) {
e.stopPropagation();
if (itms.first == 0)
{
var val = 0;
}
else
{
var val = itms.total - itms.first;
}
if (is_function(fn))
{
fn.call($tt0, val);
}
return val;
});
// currentPage event
$cfs.bind(cf_e('currentPage', conf), function(e, fn) {
e.stopPropagation();
var ipp = opts.pagination.items || opts.items.visible,
max = Math.ceil(itms.total/ipp-1),
nr;
if (itms.first == 0)
{
nr = 0;
}
else if (itms.first < itms.total % ipp)
{
nr = 0;
}
else if (itms.first == ipp && !opts.circular)
{
nr = max;
}
else
{
nr = Math.round((itms.total-itms.first)/ipp);
}
if (nr < 0)
{
nr = 0;
}
if (nr > max)
{
nr = max;
}
if (is_function(fn))
{
fn.call($tt0, nr);
}
return nr;
});
// currentVisible event
$cfs.bind(cf_e('currentVisible', conf), function(e, fn) {
e.stopPropagation();
var $i = gi_getCurrentItems($cfs.children(), opts);
if (is_function(fn))
{
fn.call($tt0, $i);
}
return $i;
});
// slice event
$cfs.bind(cf_e('slice', conf), function(e, f, l, fn) {
e.stopPropagation();
if (itms.total == 0)
{
return false;
}
var v = [f, l, fn],
t = ['number', 'number', 'function'],
a = cf_sortParams(v, t);
f = (is_number(a[0])) ? a[0] : 0;
l = (is_number(a[1])) ? a[1] : itms.total;
fn = a[2];
f += itms.first;
l += itms.first;
if (items.total > 0)
{
while (f > itms.total)
{
f -= itms.total;
}
while (l > itms.total)
{
l -= itms.total;
}
while (f < 0)
{
f += itms.total;
}
while (l < 0)
{
l += itms.total;
}
}
var $iA = $cfs.children(),
$i;
if (l > f)
{
$i = $iA.slice(f, l);
}
else
{
$i = $( $iA.slice(f, itms.total).get().concat( $iA.slice(0, l).get() ) );
}
if (is_function(fn))
{
fn.call($tt0, $i);
}
return $i;
});
// isPaused, isStopped and isScrolling events
$cfs.bind(cf_e('isPaused', conf)+' '+cf_e('isStopped', conf)+' '+cf_e('isScrolling', conf), function(e, fn) {
e.stopPropagation();
var eType = e.type.slice(conf.events.prefix.length),
value = crsl[eType];
if (is_function(fn))
{
fn.call($tt0, value);
}
return value;
});
// configuration event
$cfs.bind(cf_e('configuration', conf), function(e, a, b, c) {
e.stopPropagation();
var reInit = false;
// return entire configuration-object
if (is_function(a))
{
a.call($tt0, opts);
}
// set multiple options via object
else if (is_object(a))
{
opts_orig = $.extend(true, {}, opts_orig, a);
if (b !== false) reInit = true;
else opts = $.extend(true, {}, opts, a);
}
else if (!is_undefined(a))
{
// callback function for specific option
if (is_function(b))
{
var val = eval('opts.'+a);
if (is_undefined(val))
{
val = '';
}
b.call($tt0, val);
}
// set individual option
else if (!is_undefined(b))
{
if (typeof c !== 'boolean') c = true;
eval('opts_orig.'+a+' = b');
if (c !== false) reInit = true;
else eval('opts.'+a+' = b');
}
// return value for specific option
else
{
return eval('opts.'+a);
}
}
if (reInit)
{
sz_resetMargin($cfs.children(), opts);
FN._cfs_init(opts_orig);
FN._cfs_bind_buttons();
var sz = sz_setSizes($cfs, opts);
$cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
}
return opts;
});
// linkAnchors event
$cfs.bind(cf_e('linkAnchors', conf), function(e, $con, sel) {
e.stopPropagation();
if (is_undefined($con))
{
$con = $('body');
}
else if (is_string($con))
{
$con = $($con);
}
if (!is_jquery($con) || $con.length == 0)
{
return debug(conf, 'Not a valid object.');
}
if (!is_string(sel))
{
sel = 'a.caroufredsel';
}
$con.find(sel).each(function() {
var h = this.hash || '';
if (h.length > 0 && $cfs.children().index($(h)) != -1)
{
$(this).unbind('click').click(function(e) {
e.preventDefault();
$cfs.trigger(cf_e('slideTo', conf), h);
});
}
});
return true;
});
// updatePageStatus event
$cfs.bind(cf_e('updatePageStatus', conf), function(e, build, sizes) {
e.stopPropagation();
if (!opts.pagination.container)
{
return;
}
var ipp = opts.pagination.items || opts.items.visible,
pgs = Math.ceil(itms.total/ipp);
if (build)
{
if (opts.pagination.anchorBuilder)
{
opts.pagination.container.children().remove();
opts.pagination.container.each(function() {
for (var a = 0; a < pgs; a++)
{
var i = $cfs.children().eq( gn_getItemIndex(a*ipp, 0, true, itms, $cfs) );
$(this).append(opts.pagination.anchorBuilder.call(i[0], a+1));
}
});
}
opts.pagination.container.each(function() {
$(this).children().unbind(opts.pagination.event).each(function(a) {
$(this).bind(opts.pagination.event, function(e) {
e.preventDefault();
$cfs.trigger(cf_e('slideTo', conf), [a*ipp, -opts.pagination.deviation, true, opts.pagination]);
});
});
});
}
var selected = $cfs.triggerHandler(cf_e('currentPage', conf)) + opts.pagination.deviation;
if (selected >= pgs)
{
selected = 0;
}
if (selected < 0)
{
selected = pgs-1;
}
opts.pagination.container.each(function() {
$(this).children().removeClass(cf_c('selected', conf)).eq(selected).addClass(cf_c('selected', conf));
});
return true;
});
// updateSizes event
$cfs.bind(cf_e('updateSizes', conf), function(e) {
var vI = opts.items.visible,
a_itm = $cfs.children(),
avail_primary = ms_getParentSize($wrp, opts, 'width');
itms.total = a_itm.length;
if (crsl.primarySizePercentage)
{
opts.maxDimension = avail_primary;
opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage);
}
else
{
opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
}
if (opts.responsive)
{
opts.items.width = opts.items.sizesConf.width;
opts.items.height = opts.items.sizesConf.height;
opts = in_getResponsiveValues(opts, a_itm, avail_primary);
vI = opts.items.visible;
sz_setResponsiveSizes(opts, a_itm);
}
else if (opts.items.visibleConf.variable)
{
vI = gn_getVisibleItemsNext(a_itm, opts, 0);
}
else if (opts.items.filter != '*')
{
vI = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
}
if (!opts.circular && itms.first != 0 && vI > itms.first) {
if (opts.items.visibleConf.variable)
{
var nI = gn_getVisibleItemsPrev(a_itm, opts, itms.first) - itms.first;
}
else if (opts.items.filter != '*')
{
var nI = gn_getVisibleItemsPrevFilter(a_itm, opts, itms.first) - itms.first;
}
else
{
var nI = opts.items.visible - itms.first;
}
debug(conf, 'Preventing non-circular: sliding '+nI+' items backward.');
$cfs.trigger(cf_e('prev', conf), nI);
}
opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
opts.items.visibleConf.old = opts.items.visible;
opts = in_getAlignPadding(opts, a_itm);
var sz = sz_setSizes($cfs, opts);
$cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
nv_showNavi(opts, itms.total, conf);
nv_enableNavi(opts, itms.first, conf);
return sz;
});
// destroy event
$cfs.bind(cf_e('destroy', conf), function(e, orgOrder) {
e.stopPropagation();
tmrs = sc_clearTimers(tmrs);
$cfs.data('_cfs_isCarousel', false);
$cfs.trigger(cf_e('finish', conf));
if (orgOrder)
{
$cfs.trigger(cf_e('jumpToStart', conf));
}
sz_restoreOrigCss($cfs.children());
sz_restoreOrigCss($cfs);
FN._cfs_unbind_events();
FN._cfs_unbind_buttons();
if (conf.wrapper == 'parent')
{
sz_restoreOrigCss($wrp);
}
else
{
$wrp.replaceWith($cfs);
}
return true;
});
// debug event
$cfs.bind(cf_e('debug', conf), function(e) {
debug(conf, 'Carousel width: ' + opts.width);
debug(conf, 'Carousel height: ' + opts.height);
debug(conf, 'Item widths: ' + opts.items.width);
debug(conf, 'Item heights: ' + opts.items.height);
debug(conf, 'Number of items visible: ' + opts.items.visible);
if (opts.auto.play)
{
debug(conf, 'Number of items scrolled automatically: ' + opts.auto.items);
}
if (opts.prev.button)
{
debug(conf, 'Number of items scrolled backward: ' + opts.prev.items);
}
if (opts.next.button)
{
debug(conf, 'Number of items scrolled forward: ' + opts.next.items);
}
return conf.debug;
});
// triggerEvent, making prefixed and namespaced events accessible from outside
$cfs.bind('_cfs_triggerEvent', function(e, n, o) {
e.stopPropagation();
return $cfs.triggerHandler(cf_e(n, conf), o);
});
}; // /bind_events
FN._cfs_unbind_events = function() {
$cfs.unbind(cf_e('', conf));
$cfs.unbind(cf_e('', conf, false));
$cfs.unbind('_cfs_triggerEvent');
}; // /unbind_events
FN._cfs_bind_buttons = function() {
FN._cfs_unbind_buttons();
nv_showNavi(opts, itms.total, conf);
nv_enableNavi(opts, itms.first, conf);
if (opts.auto.pauseOnHover)
{
var pC = bt_pauseOnHoverConfig(opts.auto.pauseOnHover);
$wrp.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
.bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
}
// play button
if (opts.auto.button)
{
opts.auto.button.bind(cf_e(opts.auto.event, conf, false), function(e) {
e.preventDefault();
var ev = false,
pC = null;
if (crsl.isPaused)
{
ev = 'play';
}
else if (opts.auto.pauseOnEvent)
{
ev = 'pause';
pC = bt_pauseOnHoverConfig(opts.auto.pauseOnEvent);
}
if (ev)
{
$cfs.trigger(cf_e(ev, conf), pC);
}
});
}
// prev button
if (opts.prev.button)
{
opts.prev.button.bind(cf_e(opts.prev.event, conf, false), function(e) {
e.preventDefault();
$cfs.trigger(cf_e('prev', conf));
});
if (opts.prev.pauseOnHover)
{
var pC = bt_pauseOnHoverConfig(opts.prev.pauseOnHover);
opts.prev.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
.bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
}
}
// next butotn
if (opts.next.button)
{
opts.next.button.bind(cf_e(opts.next.event, conf, false), function(e) {
e.preventDefault();
$cfs.trigger(cf_e('next', conf));
});
if (opts.next.pauseOnHover)
{
var pC = bt_pauseOnHoverConfig(opts.next.pauseOnHover);
opts.next.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
.bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
}
}
// pagination
if (opts.pagination.container)
{
if (opts.pagination.pauseOnHover)
{
var pC = bt_pauseOnHoverConfig(opts.pagination.pauseOnHover);
opts.pagination.container.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
.bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
}
}
// prev/next keys
if (opts.prev.key || opts.next.key)
{
$(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
var k = e.keyCode;
if (k == opts.next.key)
{
e.preventDefault();
$cfs.trigger(cf_e('next', conf));
}
if (k == opts.prev.key)
{
e.preventDefault();
$cfs.trigger(cf_e('prev', conf));
}
});
}
// pagination keys
if (opts.pagination.keys)
{
$(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
var k = e.keyCode;
if (k >= 49 && k < 58)
{
k = (k-49) * opts.items.visible;
if (k <= itms.total)
{
e.preventDefault();
$cfs.trigger(cf_e('slideTo', conf), [k, 0, true, opts.pagination]);
}
}
});
}
// swipe
if ($.fn.swipe)
{
var isTouch = 'ontouchstart' in window;
if ((isTouch && opts.swipe.onTouch) || (!isTouch && opts.swipe.onMouse))
{
var scP = $.extend(true, {}, opts.prev, opts.swipe),
scN = $.extend(true, {}, opts.next, opts.swipe),
swP = function() { $cfs.trigger(cf_e('prev', conf), [scP]) },
swN = function() { $cfs.trigger(cf_e('next', conf), [scN]) };
switch (opts.direction)
{
case 'up':
case 'down':
opts.swipe.options.swipeUp = swN;
opts.swipe.options.swipeDown = swP;
break;
default:
opts.swipe.options.swipeLeft = swN;
opts.swipe.options.swipeRight = swP;
}
if (crsl.swipe)
{
$cfs.swipe('destroy');
}
$wrp.swipe(opts.swipe.options);
$wrp.css('cursor', 'move');
crsl.swipe = true;
}
}
// mousewheel
if ($.fn.mousewheel)
{
if (opts.mousewheel)
{
var mcP = $.extend(true, {}, opts.prev, opts.mousewheel),
mcN = $.extend(true, {}, opts.next, opts.mousewheel);
if (crsl.mousewheel)
{
$wrp.unbind(cf_e('mousewheel', conf, false));
}
$wrp.bind(cf_e('mousewheel', conf, false), function(e, delta) {
e.preventDefault();
if (delta > 0)
{
$cfs.trigger(cf_e('prev', conf), [mcP]);
}
else
{
$cfs.trigger(cf_e('next', conf), [mcN]);
}
});
crsl.mousewheel = true;
}
}
if (opts.auto.play)
{
$cfs.trigger(cf_e('play', conf), opts.auto.delay);
}
if (crsl.upDateOnWindowResize)
{
var resizeFn = function(e) {
$cfs.trigger(cf_e('finish', conf));
if (opts.auto.pauseOnResize && !crsl.isPaused)
{
$cfs.trigger(cf_e('play', conf));
}
sz_resetMargin($cfs.children(), opts);
$cfs.trigger(cf_e('updateSizes', conf));
};
var $w = $(window),
onResize = null;
if ($.debounce && conf.onWindowResize == 'debounce')
{
onResize = $.debounce(200, resizeFn);
}
else if ($.throttle && conf.onWindowResize == 'throttle')
{
onResize = $.throttle(300, resizeFn);
}
else
{
var _windowWidth = 0,
_windowHeight = 0;
onResize = function() {
var nw = $w.width(),
nh = $w.height();
if (nw != _windowWidth || nh != _windowHeight)
{
resizeFn();
_windowWidth = nw;
_windowHeight = nh;
}
};
}
$w.bind(cf_e('resize', conf, false, true, true), onResize);
}
}; // /bind_buttons
FN._cfs_unbind_buttons = function() {
var ns1 = cf_e('', conf),
ns2 = cf_e('', conf, false);
ns3 = cf_e('', conf, false, true, true);
$(document).unbind(ns3);
$(window).unbind(ns3);
$wrp.unbind(ns2);
if (opts.auto.button)
{
opts.auto.button.unbind(ns2);
}
if (opts.prev.button)
{
opts.prev.button.unbind(ns2);
}
if (opts.next.button)
{
opts.next.button.unbind(ns2);
}
if (opts.pagination.container)
{
opts.pagination.container.unbind(ns2);
if (opts.pagination.anchorBuilder)
{
opts.pagination.container.children().remove();
}
}
if (crsl.swipe)
{
$cfs.swipe('destroy');
$wrp.css('cursor', 'default');
crsl.swipe = false;
}
if (crsl.mousewheel)
{
crsl.mousewheel = false;
}
nv_showNavi(opts, 'hide', conf);
nv_enableNavi(opts, 'removeClass', conf);
}; // /unbind_buttons
// START
if (is_boolean(configs))
{
configs = {
'debug': configs
};
}
// set vars
var crsl = {
'direction' : 'next',
'isPaused' : true,
'isScrolling' : false,
'isStopped' : false,
'mousewheel' : false,
'swipe' : false
},
itms = {
'total' : $cfs.children().length,
'first' : 0
},
tmrs = {
'auto' : null,
'progress' : null,
'startTime' : getTime(),
'timePassed' : 0
},
scrl = {
'isStopped' : false,
'duration' : 0,
'startTime' : 0,
'easing' : '',
'anims' : []
},
clbk = {
'onBefore' : [],
'onAfter' : []
},
queu = [],
conf = $.extend(true, {}, $.fn.carouFredSel.configs, configs),
opts = {},
opts_orig = $.extend(true, {}, options),
$wrp = (conf.wrapper == 'parent')
? $cfs.parent()
: $cfs.wrap('<'+conf.wrapper.element+' class="'+conf.wrapper.classname+'" />').parent();
conf.selector = $cfs.selector;
conf.serialNumber = $.fn.carouFredSel.serialNumber++;
conf.transition = (conf.transition && $.fn.transition) ? 'transition' : 'animate';
// create carousel
FN._cfs_init(opts_orig, true, starting_position);
FN._cfs_build();
FN._cfs_bind_events();
FN._cfs_bind_buttons();
// find item to start
if (is_array(opts.items.start))
{
var start_arr = opts.items.start;
}
else
{
var start_arr = [];
if (opts.items.start != 0)
{
start_arr.push(opts.items.start);
}
}
if (opts.cookie)
{
start_arr.unshift(parseInt(cf_getCookie(opts.cookie), 10));
}
if (start_arr.length > 0)
{
for (var a = 0, l = start_arr.length; a < l; a++)
{
var s = start_arr[a];
if (s == 0)
{
continue;
}
if (s === true)
{
s = window.location.hash;
if (s.length < 1)
{
continue;
}
}
else if (s === 'random')
{
s = Math.floor(Math.random()*itms.total);
}
if ($cfs.triggerHandler(cf_e('slideTo', conf), [s, 0, true, { fx: 'none' }]))
{
break;
}
}
}
var siz = sz_setSizes($cfs, opts),
itm = gi_getCurrentItems($cfs.children(), opts);
if (opts.onCreate)
{
opts.onCreate.call($tt0, {
'width': siz.width,
'height': siz.height,
'items': itm
});
}
$cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
$cfs.trigger(cf_e('linkAnchors', conf));
if (conf.debug)
{
$cfs.trigger(cf_e('debug', conf));
}
return $cfs;
};
// GLOBAL PUBLIC
$.fn.carouFredSel.serialNumber = 1;
$.fn.carouFredSel.defaults = {
'synchronise' : false,
'infinite' : true,
'circular' : true,
'responsive' : false,
'direction' : 'left',
'items' : {
'start' : 0
},
'scroll' : {
'easing' : 'swing',
'duration' : 500,
'pauseOnHover' : false,
'event' : 'click',
'queue' : false
}
};
$.fn.carouFredSel.configs = {
'debug' : false,
'transition' : false,
'onWindowResize': 'throttle',
'events' : {
'prefix' : '',
'namespace' : 'cfs'
},
'wrapper' : {
'element' : 'div',
'classname' : 'caroufredsel_wrapper'
},
'classnames' : {}
};
$.fn.carouFredSel.pageAnchorBuilder = function(nr) {
return ''+nr+'';
};
$.fn.carouFredSel.progressbarUpdater = function(perc) {
$(this).css('width', perc+'%');
};
$.fn.carouFredSel.cookie = {
get: function(n) {
n += '=';
var ca = document.cookie.split(';');
for (var a = 0, l = ca.length; a < l; a++)
{
var c = ca[a];
while (c.charAt(0) == ' ')
{
c = c.slice(1);
}
if (c.indexOf(n) == 0)
{
return c.slice(n.length);
}
}
return 0;
},
set: function(n, v, d) {
var e = "";
if (d)
{
var date = new Date();
date.setTime(date.getTime() + (d * 24 * 60 * 60 * 1000));
e = "; expires=" + date.toGMTString();
}
document.cookie = n + '=' + v + e + '; path=/';
},
remove: function(n) {
$.fn.carouFredSel.cookie.set(n, "", -1);
}
};
// GLOBAL PRIVATE
// scrolling functions
function sc_setScroll(d, e, c) {
if (c.transition == 'transition')
{
if (e == 'swing')
{
e = 'ease';
}
}
return {
anims: [],
duration: d,
orgDuration: d,
easing: e,
startTime: getTime()
};
}
function sc_startScroll(s, c) {
for (var a = 0, l = s.anims.length; a < l; a++)
{
var b = s.anims[a];
if (!b)
{
continue;
}
b[0][c.transition](b[1], s.duration, s.easing, b[2]);
}
}
function sc_stopScroll(s, finish) {
if (!is_boolean(finish))
{
finish = true;
}
if (is_object(s.pre))
{
sc_stopScroll(s.pre, finish);
}
for (var a = 0, l = s.anims.length; a < l; a++)
{
var b = s.anims[a];
b[0].stop(true);
if (finish)
{
b[0].css(b[1]);
if (is_function(b[2]))
{
b[2]();
}
}
}
if (is_object(s.post))
{
sc_stopScroll(s.post, finish);
}
}
function sc_afterScroll( $c, $c2, o ) {
if ($c2)
{
$c2.remove();
}
switch(o.fx) {
case 'fade':
case 'crossfade':
case 'cover-fade':
case 'uncover-fade':
$c.css('filter', '');
$c.css('opacity', 1);
break;
}
}
function sc_fireCallbacks($t, o, b, a, c) {
if (o[b])
{
o[b].call($t, a);
}
if (c[b].length)
{
for (var i = 0, l = c[b].length; i < l; i++)
{
c[b][i].call($t, a);
}
}
return [];
}
function sc_fireQueue($c, q, c) {
if (q.length)
{
$c.trigger(cf_e(q[0][0], c), q[0][1]);
q.shift();
}
return q;
}
function sc_hideHiddenItems(hiddenitems) {
hiddenitems.each(function() {
var hi = $(this);
hi.data('_cfs_isHidden', hi.is(':hidden')).hide();
});
}
function sc_showHiddenItems(hiddenitems) {
if (hiddenitems)
{
hiddenitems.each(function() {
var hi = $(this);
if (!hi.data('_cfs_isHidden'))
{
hi.show();
}
});
}
}
function sc_clearTimers(t) {
if (t.auto)
{
clearTimeout(t.auto);
}
if (t.progress)
{
clearInterval(t.progress);
}
return t;
}
function sc_mapCallbackArguments(i_old, i_skp, i_new, s_itm, s_dir, s_dur, w_siz) {
return {
'width': w_siz.width,
'height': w_siz.height,
'items': {
'old': i_old,
'skipped': i_skp,
'visible': i_new
},
'scroll': {
'items': s_itm,
'direction': s_dir,
'duration': s_dur
}
};
}
function sc_getDuration( sO, o, nI, siz ) {
var dur = sO.duration;
if (sO.fx == 'none')
{
return 0;
}
if (dur == 'auto')
{
dur = o.scroll.duration / o.scroll.items * nI;
}
else if (dur < 10)
{
dur = siz / dur;
}
if (dur < 1)
{
return 0;
}
if (sO.fx == 'fade')
{
dur = dur / 2;
}
return Math.round(dur);
}
// navigation functions
function nv_showNavi(o, t, c) {
var minimum = (is_number(o.items.minimum)) ? o.items.minimum : o.items.visible + 1;
if (t == 'show' || t == 'hide')
{
var f = t;
}
else if (minimum > t)
{
debug(c, 'Not enough items ('+t+' total, '+minimum+' needed): Hiding navigation.');
var f = 'hide';
}
else
{
var f = 'show';
}
var s = (f == 'show') ? 'removeClass' : 'addClass',
h = cf_c('hidden', c);
if (o.auto.button)
{
o.auto.button[f]()[s](h);
}
if (o.prev.button)
{
o.prev.button[f]()[s](h);
}
if (o.next.button)
{
o.next.button[f]()[s](h);
}
if (o.pagination.container)
{
o.pagination.container[f]()[s](h);
}
}
function nv_enableNavi(o, f, c) {
if (o.circular || o.infinite) return;
var fx = (f == 'removeClass' || f == 'addClass') ? f : false,
di = cf_c('disabled', c);
if (o.auto.button && fx)
{
o.auto.button[fx](di);
}
if (o.prev.button)
{
var fn = fx || (f == 0) ? 'addClass' : 'removeClass';
o.prev.button[fn](di);
}
if (o.next.button)
{
var fn = fx || (f == o.items.visible) ? 'addClass' : 'removeClass';
o.next.button[fn](di);
}
}
// get object functions
function go_getObject($tt, obj) {
if (is_function(obj))
{
obj = obj.call($tt);
}
else if (is_undefined(obj))
{
obj = {};
}
return obj;
}
function go_getItemsObject($tt, obj) {
obj = go_getObject($tt, obj);
if (is_number(obj))
{
obj = {
'visible': obj
};
}
else if (obj == 'variable')
{
obj = {
'visible': obj,
'width': obj,
'height': obj
};
}
else if (!is_object(obj))
{
obj = {};
}
return obj;
}
function go_getScrollObject($tt, obj) {
obj = go_getObject($tt, obj);
if (is_number(obj))
{
if (obj <= 50)
{
obj = {
'items': obj
};
}
else
{
obj = {
'duration': obj
};
}
}
else if (is_string(obj))
{
obj = {
'easing': obj
};
}
else if (!is_object(obj))
{
obj = {};
}
return obj;
}
function go_getNaviObject($tt, obj) {
obj = go_getObject($tt, obj);
if (is_string(obj))
{
var temp = cf_getKeyCode(obj);
if (temp == -1)
{
obj = $(obj);
}
else
{
obj = temp;
}
}
return obj;
}
function go_getAutoObject($tt, obj) {
obj = go_getNaviObject($tt, obj);
if (is_jquery(obj))
{
obj = {
'button': obj
};
}
else if (is_boolean(obj))
{
obj = {
'play': obj
};
}
else if (is_number(obj))
{
obj = {
'timeoutDuration': obj
};
}
if (obj.progress)
{
if (is_string(obj.progress) || is_jquery(obj.progress))
{
obj.progress = {
'bar': obj.progress
};
}
}
return obj;
}
function go_complementAutoObject($tt, obj) {
if (is_function(obj.button))
{
obj.button = obj.button.call($tt);
}
if (is_string(obj.button))
{
obj.button = $(obj.button);
}
if (!is_boolean(obj.play))
{
obj.play = true;
}
if (!is_number(obj.delay))
{
obj.delay = 0;
}
if (is_undefined(obj.pauseOnEvent))
{
obj.pauseOnEvent = true;
}
if (!is_boolean(obj.pauseOnResize))
{
obj.pauseOnResize = true;
}
if (!is_number(obj.timeoutDuration))
{
obj.timeoutDuration = (obj.duration < 10)
? 2500
: obj.duration * 5;
}
if (obj.progress)
{
if (is_function(obj.progress.bar))
{
obj.progress.bar = obj.progress.bar.call($tt);
}
if (is_string(obj.progress.bar))
{
obj.progress.bar = $(obj.progress.bar);
}
if (obj.progress.bar)
{
if (!is_function(obj.progress.updater))
{
obj.progress.updater = $.fn.carouFredSel.progressbarUpdater;
}
if (!is_number(obj.progress.interval))
{
obj.progress.interval = 50;
}
}
else
{
obj.progress = false;
}
}
return obj;
}
function go_getPrevNextObject($tt, obj) {
obj = go_getNaviObject($tt, obj);
if (is_jquery(obj))
{
obj = {
'button': obj
};
}
else if (is_number(obj))
{
obj = {
'key': obj
};
}
return obj;
}
function go_complementPrevNextObject($tt, obj) {
if (is_function(obj.button))
{
obj.button = obj.button.call($tt);
}
if (is_string(obj.button))
{
obj.button = $(obj.button);
}
if (is_string(obj.key))
{
obj.key = cf_getKeyCode(obj.key);
}
return obj;
}
function go_getPaginationObject($tt, obj) {
obj = go_getNaviObject($tt, obj);
if (is_jquery(obj))
{
obj = {
'container': obj
};
}
else if (is_boolean(obj))
{
obj = {
'keys': obj
};
}
return obj;
}
function go_complementPaginationObject($tt, obj) {
if (is_function(obj.container))
{
obj.container = obj.container.call($tt);
}
if (is_string(obj.container))
{
obj.container = $(obj.container);
}
if (!is_number(obj.items))
{
obj.items = false;
}
if (!is_boolean(obj.keys))
{
obj.keys = false;
}
if (!is_function(obj.anchorBuilder) && !is_false(obj.anchorBuilder))
{
obj.anchorBuilder = $.fn.carouFredSel.pageAnchorBuilder;
}
if (!is_number(obj.deviation))
{
obj.deviation = 0;
}
return obj;
}
function go_getSwipeObject($tt, obj) {
if (is_function(obj))
{
obj = obj.call($tt);
}
if (is_undefined(obj))
{
obj = {
'onTouch': false
};
}
if (is_true(obj))
{
obj = {
'onTouch': obj
};
}
else if (is_number(obj))
{
obj = {
'items': obj
};
}
return obj;
}
function go_complementSwipeObject($tt, obj) {
if (!is_boolean(obj.onTouch))
{
obj.onTouch = true;
}
if (!is_boolean(obj.onMouse))
{
obj.onMouse = false;
}
if (!is_object(obj.options))
{
obj.options = {};
}
if (!is_boolean(obj.options.triggerOnTouchEnd))
{
obj.options.triggerOnTouchEnd = false;
}
return obj;
}
function go_getMousewheelObject($tt, obj) {
if (is_function(obj))
{
obj = obj.call($tt);
}
if (is_true(obj))
{
obj = {};
}
else if (is_number(obj))
{
obj = {
'items': obj
};
}
else if (is_undefined(obj))
{
obj = false;
}
return obj;
}
function go_complementMousewheelObject($tt, obj) {
return obj;
}
// get number functions
function gn_getItemIndex(num, dev, org, items, $cfs) {
if (is_string(num))
{
num = $(num, $cfs);
}
if (is_object(num))
{
num = $(num, $cfs);
}
if (is_jquery(num))
{
num = $cfs.children().index(num);
if (!is_boolean(org))
{
org = false;
}
}
else
{
if (!is_boolean(org))
{
org = true;
}
}
if (!is_number(num))
{
num = 0;
}
if (!is_number(dev))
{
dev = 0;
}
if (org)
{
num += items.first;
}
num += dev;
if (items.total > 0)
{
while (num >= items.total)
{
num -= items.total;
}
while (num < 0)
{
num += items.total;
}
}
return num;
}
// items prev
function gn_getVisibleItemsPrev(i, o, s) {
var t = 0,
x = 0;
for (var a = s; a >= 0; a--)
{
var j = i.eq(a);
t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
if (t > o.maxDimension)
{
return x;
}
if (a == 0)
{
a = i.length;
}
x++;
}
}
function gn_getVisibleItemsPrevFilter(i, o, s) {
return gn_getItemsPrevFilter(i, o.items.filter, o.items.visibleConf.org, s);
}
function gn_getScrollItemsPrevFilter(i, o, s, m) {
return gn_getItemsPrevFilter(i, o.items.filter, m, s);
}
function gn_getItemsPrevFilter(i, f, m, s) {
var t = 0,
x = 0;
for (var a = s, l = i.length; a >= 0; a--)
{
x++;
if (x == l)
{
return x;
}
var j = i.eq(a);
if (j.is(f))
{
t++;
if (t == m)
{
return x;
}
}
if (a == 0)
{
a = l;
}
}
}
function gn_getVisibleOrg($c, o) {
return o.items.visibleConf.org || $c.children().slice(0, o.items.visible).filter(o.items.filter).length;
}
// items next
function gn_getVisibleItemsNext(i, o, s) {
var t = 0,
x = 0;
for (var a = s, l = i.length-1; a <= l; a++)
{
var j = i.eq(a);
t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
if (t > o.maxDimension)
{
return x;
}
x++;
if (x == l+1)
{
return x;
}
if (a == l)
{
a = -1;
}
}
}
function gn_getVisibleItemsNextTestCircular(i, o, s, l) {
var v = gn_getVisibleItemsNext(i, o, s);
if (!o.circular)
{
if (s + v > l)
{
v = l - s;
}
}
return v;
}
function gn_getVisibleItemsNextFilter(i, o, s) {
return gn_getItemsNextFilter(i, o.items.filter, o.items.visibleConf.org, s, o.circular);
}
function gn_getScrollItemsNextFilter(i, o, s, m) {
return gn_getItemsNextFilter(i, o.items.filter, m+1, s, o.circular) - 1;
}
function gn_getItemsNextFilter(i, f, m, s, c) {
var t = 0,
x = 0;
for (var a = s, l = i.length-1; a <= l; a++)
{
x++;
if (x >= l)
{
return x;
}
var j = i.eq(a);
if (j.is(f))
{
t++;
if (t == m)
{
return x;
}
}
if (a == l)
{
a = -1;
}
}
}
// get items functions
function gi_getCurrentItems(i, o) {
return i.slice(0, o.items.visible);
}
function gi_getOldItemsPrev(i, o, n) {
return i.slice(n, o.items.visibleConf.old+n);
}
function gi_getNewItemsPrev(i, o) {
return i.slice(0, o.items.visible);
}
function gi_getOldItemsNext(i, o) {
return i.slice(0, o.items.visibleConf.old);
}
function gi_getNewItemsNext(i, o, n) {
return i.slice(n, o.items.visible+n);
}
// sizes functions
function sz_storeMargin(i, o, d) {
if (o.usePadding)
{
if (!is_string(d))
{
d = '_cfs_origCssMargin';
}
i.each(function() {
var j = $(this),
m = parseInt(j.css(o.d['marginRight']), 10);
if (!is_number(m))
{
m = 0;
}
j.data(d, m);
});
}
}
function sz_resetMargin(i, o, m) {
if (o.usePadding)
{
var x = (is_boolean(m)) ? m : false;
if (!is_number(m))
{
m = 0;
}
sz_storeMargin(i, o, '_cfs_tempCssMargin');
i.each(function() {
var j = $(this);
j.css(o.d['marginRight'], ((x) ? j.data('_cfs_tempCssMargin') : m + j.data('_cfs_origCssMargin')));
});
}
}
function sz_storeOrigCss(i) {
i.each(function() {
var j = $(this);
j.data('_cfs_origCss', j.attr('style') || '');
});
}
function sz_restoreOrigCss(i) {
i.each(function() {
var j = $(this);
j.attr('style', j.data('_cfs_origCss') || '');
});
}
function sz_setResponsiveSizes(o, all) {
var visb = o.items.visible,
newS = o.items[o.d['width']],
seco = o[o.d['height']],
secp = is_percentage(seco);
all.each(function() {
var $t = $(this),
nw = newS - ms_getPaddingBorderMargin($t, o, 'Width');
$t[o.d['width']](nw);
if (secp)
{
$t[o.d['height']](ms_getPercentage(nw, seco));
}
});
}
function sz_setSizes($c, o) {
var $w = $c.parent(),
$i = $c.children(),
$v = gi_getCurrentItems($i, o),
sz = cf_mapWrapperSizes(ms_getSizes($v, o, true), o, false);
$w.css(sz);
if (o.usePadding)
{
var p = o.padding,
r = p[o.d[1]];
if (o.align && r < 0)
{
r = 0;
}
var $l = $v.last();
$l.css(o.d['marginRight'], $l.data('_cfs_origCssMargin') + r);
$c.css(o.d['top'], p[o.d[0]]);
$c.css(o.d['left'], p[o.d[3]]);
}
$c.css(o.d['width'], sz[o.d['width']]+(ms_getTotalSize($i, o, 'width')*2));
$c.css(o.d['height'], ms_getLargestSize($i, o, 'height'));
return sz;
}
// measuring functions
function ms_getSizes(i, o, wrapper) {
return [ms_getTotalSize(i, o, 'width', wrapper), ms_getLargestSize(i, o, 'height', wrapper)];
}
function ms_getLargestSize(i, o, dim, wrapper) {
if (!is_boolean(wrapper))
{
wrapper = false;
}
if (is_number(o[o.d[dim]]) && wrapper)
{
return o[o.d[dim]];
}
if (is_number(o.items[o.d[dim]]))
{
return o.items[o.d[dim]];
}
dim = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight';
return ms_getTrueLargestSize(i, o, dim);
}
function ms_getTrueLargestSize(i, o, dim) {
var s = 0;
for (var a = 0, l = i.length; a < l; a++)
{
var j = i.eq(a);
var m = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
if (s < m)
{
s = m;
}
}
return s;
}
function ms_getTotalSize(i, o, dim, wrapper) {
if (!is_boolean(wrapper))
{
wrapper = false;
}
if (is_number(o[o.d[dim]]) && wrapper)
{
return o[o.d[dim]];
}
if (is_number(o.items[o.d[dim]]))
{
return o.items[o.d[dim]] * i.length;
}
var d = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight',
s = 0;
for (var a = 0, l = i.length; a < l; a++)
{
var j = i.eq(a);
s += (j.is(':visible')) ? j[o.d[d]](true) : 0;
}
return s;
}
function ms_getParentSize($w, o, d) {
var isVisible = $w.is(':visible');
if (isVisible)
{
$w.hide();
}
var s = $w.parent()[o.d[d]]();
if (isVisible)
{
$w.show();
}
return s;
}
function ms_getMaxDimension(o, a) {
return (is_number(o[o.d['width']])) ? o[o.d['width']] : a;
}
function ms_hasVariableSizes(i, o, dim) {
var s = false,
v = false;
for (var a = 0, l = i.length; a < l; a++)
{
var j = i.eq(a);
var c = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
if (s === false)
{
s = c;
}
else if (s != c)
{
v = true;
}
if (s == 0)
{
v = true;
}
}
return v;
}
function ms_getPaddingBorderMargin(i, o, d) {
return i[o.d['outer'+d]](true) - i[o.d[d.toLowerCase()]]();
}
function ms_getPercentage(s, o) {
if (is_percentage(o))
{
o = parseInt( o.slice(0, -1), 10 );
if (!is_number(o))
{
return s;
}
s *= o/100;
}
return s;
}
// config functions
function cf_e(n, c, pf, ns, rd) {
if (!is_boolean(pf))
{
pf = true;
}
if (!is_boolean(ns))
{
ns = true;
}
if (!is_boolean(rd))
{
rd = false;
}
if (pf)
{
n = c.events.prefix + n;
}
if (ns)
{
n = n +'.'+ c.events.namespace;
}
if (ns && rd)
{
n += c.serialNumber;
}
return n;
}
function cf_c(n, c) {
return (is_string(c.classnames[n])) ? c.classnames[n] : n;
}
function cf_mapWrapperSizes(ws, o, p) {
if (!is_boolean(p))
{
p = true;
}
var pad = (o.usePadding && p) ? o.padding : [0, 0, 0, 0];
var wra = {};
wra[o.d['width']] = ws[0] + pad[1] + pad[3];
wra[o.d['height']] = ws[1] + pad[0] + pad[2];
return wra;
}
function cf_sortParams(vals, typs) {
var arr = [];
for (var a = 0, l1 = vals.length; a < l1; a++)
{
for (var b = 0, l2 = typs.length; b < l2; b++)
{
if (typs[b].indexOf(typeof vals[a]) > -1 && is_undefined(arr[b]))
{
arr[b] = vals[a];
break;
}
}
}
return arr;
}
function cf_getPadding(p) {
if (is_undefined(p))
{
return [0, 0, 0, 0];
}
if (is_number(p))
{
return [p, p, p, p];
}
if (is_string(p))
{
p = p.split('px').join('').split('em').join('').split(' ');
}
if (!is_array(p))
{
return [0, 0, 0, 0];
}
for (var i = 0; i < 4; i++)
{
p[i] = parseInt(p[i], 10);
}
switch (p.length)
{
case 0:
return [0, 0, 0, 0];
case 1:
return [p[0], p[0], p[0], p[0]];
case 2:
return [p[0], p[1], p[0], p[1]];
case 3:
return [p[0], p[1], p[2], p[1]];
default:
return [p[0], p[1], p[2], p[3]];
}
}
function cf_getAlignPadding(itm, o) {
var x = (is_number(o[o.d['width']])) ? Math.ceil(o[o.d['width']] - ms_getTotalSize(itm, o, 'width')) : 0;
switch (o.align)
{
case 'left':
return [0, x];
case 'right':
return [x, 0];
case 'center':
default:
return [Math.ceil(x/2), Math.floor(x/2)];
}
}
function cf_getDimensions(o) {
var dm = [
['width' , 'innerWidth' , 'outerWidth' , 'height' , 'innerHeight' , 'outerHeight' , 'left', 'top' , 'marginRight' , 0, 1, 2, 3],
['height' , 'innerHeight' , 'outerHeight' , 'width' , 'innerWidth' , 'outerWidth' , 'top' , 'left', 'marginBottom', 3, 2, 1, 0]
];
var dl = dm[0].length,
dx = (o.direction == 'right' || o.direction == 'left') ? 0 : 1;
var dimensions = {};
for (var d = 0; d < dl; d++)
{
dimensions[dm[0][d]] = dm[dx][d];
}
return dimensions;
}
function cf_getAdjust(x, o, a, $t) {
var v = x;
if (is_function(a))
{
v = a.call($t, v);
}
else if (is_string(a))
{
var p = a.split('+'),
m = a.split('-');
if (m.length > p.length)
{
var neg = true,
sta = m[0],
adj = m[1];
}
else
{
var neg = false,
sta = p[0],
adj = p[1];
}
switch(sta)
{
case 'even':
v = (x % 2 == 1) ? x-1 : x;
break;
case 'odd':
v = (x % 2 == 0) ? x-1 : x;
break;
default:
v = x;
break;
}
adj = parseInt(adj, 10);
if (is_number(adj))
{
if (neg)
{
adj = -adj;
}
v += adj;
}
}
if (!is_number(v) || v < 1)
{
v = 1;
}
return v;
}
function cf_getItemsAdjust(x, o, a, $t) {
return cf_getItemAdjustMinMax(cf_getAdjust(x, o, a, $t), o.items.visibleConf);
}
function cf_getItemAdjustMinMax(v, i) {
if (is_number(i.min) && v < i.min)
{
v = i.min;
}
if (is_number(i.max) && v > i.max)
{
v = i.max;
}
if (v < 1)
{
v = 1;
}
return v;
}
function cf_getSynchArr(s) {
if (!is_array(s))
{
s = [[s]];
}
if (!is_array(s[0]))
{
s = [s];
}
for (var j = 0, l = s.length; j < l; j++)
{
if (is_string(s[j][0]))
{
s[j][0] = $(s[j][0]);
}
if (!is_boolean(s[j][1]))
{
s[j][1] = true;
}
if (!is_boolean(s[j][2]))
{
s[j][2] = true;
}
if (!is_number(s[j][3]))
{
s[j][3] = 0;
}
}
return s;
}
function cf_getKeyCode(k) {
if (k == 'right')
{
return 39;
}
if (k == 'left')
{
return 37;
}
if (k == 'up')
{
return 38;
}
if (k == 'down')
{
return 40;
}
return -1;
}
function cf_setCookie(n, $c, c) {
if (n)
{
var v = $c.triggerHandler(cf_e('currentPosition', c));
$.fn.carouFredSel.cookie.set(n, v);
}
}
function cf_getCookie(n) {
var c = $.fn.carouFredSel.cookie.get(n);
return (c == '') ? 0 : c;
}
// init function
function in_mapCss($elem, props) {
var css = {};
for (var p = 0, l = props.length; p < l; p++)
{
css[props[p]] = $elem.css(props[p]);
}
return css;
}
function in_complementItems(obj, opt, itm, sta) {
if (!is_object(obj.visibleConf))
{
obj.visibleConf = {};
}
if (!is_object(obj.sizesConf))
{
obj.sizesConf = {};
}
if (obj.start == 0 && is_number(sta))
{
obj.start = sta;
}
// visible items
if (is_object(obj.visible))
{
obj.visibleConf.min = obj.visible.min;
obj.visibleConf.max = obj.visible.max;
obj.visible = false;
}
else if (is_string(obj.visible))
{
// variable visible items
if (obj.visible == 'variable')
{
obj.visibleConf.variable = true;
}
// adjust string visible items
else
{
obj.visibleConf.adjust = obj.visible;
}
obj.visible = false;
}
else if (is_function(obj.visible))
{
obj.visibleConf.adjust = obj.visible;
obj.visible = false;
}
// set items filter
if (!is_string(obj.filter))
{
obj.filter = (itm.filter(':hidden').length > 0) ? ':visible' : '*';
}
// primary item-size not set
if (!obj[opt.d['width']])
{
// responsive carousel -> set to largest
if (opt.responsive)
{
debug(true, 'Set a '+opt.d['width']+' for the items!');
obj[opt.d['width']] = ms_getTrueLargestSize(itm, opt, 'outerWidth');
}
// non-responsive -> measure it or set to "variable"
else
{
obj[opt.d['width']] = (ms_hasVariableSizes(itm, opt, 'outerWidth'))
? 'variable'
: itm[opt.d['outerWidth']](true);
}
}
// secondary item-size not set -> measure it or set to "variable"
if (!obj[opt.d['height']])
{
obj[opt.d['height']] = (ms_hasVariableSizes(itm, opt, 'outerHeight'))
? 'variable'
: itm[opt.d['outerHeight']](true);
}
obj.sizesConf.width = obj.width;
obj.sizesConf.height = obj.height;
return obj;
}
function in_complementVisibleItems(opt, avl) {
// primary item-size variable -> set visible items variable
if (opt.items[opt.d['width']] == 'variable')
{
opt.items.visibleConf.variable = true;
}
if (!opt.items.visibleConf.variable) {
// primary size is number -> calculate visible-items
if (is_number(opt[opt.d['width']]))
{
opt.items.visible = Math.floor(opt[opt.d['width']] / opt.items[opt.d['width']]);
}
// measure and calculate primary size and visible-items
else
{
opt.items.visible = Math.floor(avl / opt.items[opt.d['width']]);
opt[opt.d['width']] = opt.items.visible * opt.items[opt.d['width']];
if (!opt.items.visibleConf.adjust)
{
opt.align = false;
}
}
if (opt.items.visible == 'Infinity' || opt.items.visible < 1)
{
debug(true, 'Not a valid number of visible items: Set to "variable".');
opt.items.visibleConf.variable = true;
}
}
return opt;
}
function in_complementPrimarySize(obj, opt, all) {
// primary size set to auto -> measure largest item-size and set it
if (obj == 'auto')
{
obj = ms_getTrueLargestSize(all, opt, 'outerWidth');
}
return obj;
}
function in_complementSecondarySize(obj, opt, all) {
// secondary size set to auto -> measure largest item-size and set it
if (obj == 'auto')
{
obj = ms_getTrueLargestSize(all, opt, 'outerHeight');
}
// secondary size not set -> set to secondary item-size
if (!obj)
{
obj = opt.items[opt.d['height']];
}
return obj;
}
function in_getAlignPadding(o, all) {
var p = cf_getAlignPadding(gi_getCurrentItems(all, o), o);
o.padding[o.d[1]] = p[1];
o.padding[o.d[3]] = p[0];
return o;
}
function in_getResponsiveValues(o, all, avl) {
var visb = cf_getItemAdjustMinMax(Math.ceil(o[o.d['width']] / o.items[o.d['width']]), o.items.visibleConf);
if (visb > all.length)
{
visb = all.length;
}
var newS = Math.floor(o[o.d['width']]/visb);
o.items.visible = visb;
o.items[o.d['width']] = newS;
o[o.d['width']] = visb * newS;
return o;
}
// buttons functions
function bt_pauseOnHoverConfig(p) {
if (is_string(p))
{
var i = (p.indexOf('immediate') > -1) ? true : false,
r = (p.indexOf('resume') > -1) ? true : false;
}
else
{
var i = r = false;
}
return [i, r];
}
function bt_mousesheelNumber(mw) {
return (is_number(mw)) ? mw : null
}
// helper functions
function is_null(a) {
return (a === null);
}
function is_undefined(a) {
return (is_null(a) || typeof a == 'undefined' || a === '' || a === 'undefined');
}
function is_array(a) {
return (a instanceof Array);
}
function is_jquery(a) {
return (a instanceof jQuery);
}
function is_object(a) {
return ((a instanceof Object || typeof a == 'object') && !is_null(a) && !is_jquery(a) && !is_array(a));
}
function is_number(a) {
return ((a instanceof Number || typeof a == 'number') && !isNaN(a));
}
function is_string(a) {
return ((a instanceof String || typeof a == 'string') && !is_undefined(a) && !is_true(a) && !is_false(a));
}
function is_function(a) {
return (a instanceof Function || typeof a == 'function');
}
function is_boolean(a) {
return (a instanceof Boolean || typeof a == 'boolean' || is_true(a) || is_false(a));
}
function is_true(a) {
return (a === true || a === 'true');
}
function is_false(a) {
return (a === false || a === 'false');
}
function is_percentage(x) {
return (is_string(x) && x.slice(-1) == '%');
}
function getTime() {
return new Date().getTime();
}
function deprecated( o, n ) {
debug(true, o+' is DEPRECATED, support for it will be removed. Use '+n+' instead.');
}
function debug(d, m) {
if (!is_undefined(window.console) && !is_undefined(window.console.log))
{
if (is_object(d))
{
var s = ' ('+d.selector+')';
d = d.debug;
}
else
{
var s = '';
}
if (!d)
{
return false;
}
if (is_string(m))
{
m = 'carouFredSel'+s+': ' + m;
}
else
{
m = ['carouFredSel'+s+':', m];
}
window.console.log(m);
}
return false;
}
// EASING FUNCTIONS
$.extend($.easing, {
'quadratic': function(t) {
var t2 = t * t;
return t * (-t2 * t + 4 * t2 - 6 * t + 4);
},
'cubic': function(t) {
return t * (4 * t * t - 9 * t + 6);
},
'elastic': function(t) {
var t2 = t * t;
return t * (33 * t2 * t2 - 106 * t2 * t + 126 * t2 - 67 * t + 15);
}
});
})(jQuery);
/*!
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Script: jQuery throttle / debounce: Sometimes, less is more!
//
// *Version: 1.1, Last updated: 3/7/2010*
//
// Project Home - http://benalman.com/projects/jquery-throttle-debounce-plugin/
// GitHub - http://github.com/cowboy/jquery-throttle-debounce/
// Source - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.js
// (Minified) - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.min.js (0.7kb)
//
// About: License
//
// Copyright (c) 2010 "Cowboy" Ben Alman,
// Dual licensed under the MIT and GPL licenses.
// http://benalman.com/about/license/
//
// About: Examples
//
// These working examples, complete with fully commented code, illustrate a few
// ways in which this plugin can be used.
//
// Throttle - http://benalman.com/code/projects/jquery-throttle-debounce/examples/throttle/
// Debounce - http://benalman.com/code/projects/jquery-throttle-debounce/examples/debounce/
//
// About: Support and Testing
//
// Information about what version or versions of jQuery this plugin has been
// tested with, what browsers it has been tested in, and where the unit tests
// reside (so you can test it yourself).
//
// jQuery Versions - none, 1.3.2, 1.4.2
// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1.
// Unit Tests - http://benalman.com/code/projects/jquery-throttle-debounce/unit/
//
// About: Release History
//
// 1.1 - (3/7/2010) Fixed a bug in where trailing callbacks
// executed later than they should. Reworked a fair amount of internal
// logic as well.
// 1.0 - (3/6/2010) Initial release as a stand-alone project. Migrated over
// from jquery-misc repo v0.4 to jquery-throttle repo v1.0, added the
// no_trailing throttle parameter and debounce functionality.
//
// Topic: Note for non-jQuery users
//
// jQuery isn't actually required for this plugin, because nothing internal
// uses any jQuery methods or properties. jQuery is just used as a namespace
// under which these methods can exist.
//
// Since jQuery isn't actually required for this plugin, if jQuery doesn't exist
// when this plugin is loaded, the method described below will be created in
// the `Cowboy` namespace. Usage will be exactly the same, but instead of
// $.method() or jQuery.method(), you'll need to use Cowboy.method().
(function(window,undefined){
'$:nomunge'; // Used by YUI compressor.
// Since jQuery really isn't required for this plugin, use `jQuery` as the
// namespace only if it already exists, otherwise use the `Cowboy` namespace,
// creating it if necessary.
var $ = window.jQuery || window.Cowboy || ( window.Cowboy = {} ),
// Internal method reference.
jq_throttle;
// Method: jQuery.throttle
//
// Throttle execution of a function. Especially useful for rate limiting
// execution of handlers on events like resize and scroll. If you want to
// rate-limit execution of a function to a single time, see the
// method.
//
// In this visualization, | is a throttled-function call and X is the actual
// callback execution:
//
// > Throttled with `no_trailing` specified as false or unspecified:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X X X X X X X X X X X
// >
// > Throttled with `no_trailing` specified as true:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X X X X X X X X X
//
// Usage:
//
// > var throttled = jQuery.throttle( delay, [ no_trailing, ] callback );
// >
// > jQuery('selector').bind( 'someevent', throttled );
// > jQuery('selector').unbind( 'someevent', throttled );
//
// This also works in jQuery 1.4+:
//
// > jQuery('selector').bind( 'someevent', jQuery.throttle( delay, [ no_trailing, ] callback ) );
// > jQuery('selector').unbind( 'someevent', callback );
//
// Arguments:
//
// delay - (Number) A zero-or-greater delay in milliseconds. For event
// callbacks, values around 100 or 250 (or even higher) are most useful.
// no_trailing - (Boolean) Optional, defaults to false. If no_trailing is
// true, callback will only execute every `delay` milliseconds while the
// throttled-function is being called. If no_trailing is false or
// unspecified, callback will be executed one final time after the last
// throttled-function call. (After the throttled-function has not been
// called for `delay` milliseconds, the internal counter is reset)
// callback - (Function) A function to be executed after delay milliseconds.
// The `this` context and all arguments are passed through, as-is, to
// `callback` when the throttled-function is executed.
//
// Returns:
//
// (Function) A new, throttled, function.
$.throttle = jq_throttle = function( delay, no_trailing, callback, debounce_mode ) {
// After wrapper has stopped being called, this timeout ensures that
// `callback` is executed at the proper times in `throttle` and `end`
// debounce modes.
var timeout_id,
// Keep track of the last time `callback` was executed.
last_exec = 0;
// `no_trailing` defaults to falsy.
if ( typeof no_trailing !== 'boolean' ) {
debounce_mode = callback;
callback = no_trailing;
no_trailing = undefined;
}
// The `wrapper` function encapsulates all of the throttling / debouncing
// functionality and when executed will limit the rate at which `callback`
// is executed.
function wrapper() {
var that = this,
elapsed = +new Date() - last_exec,
args = arguments;
// Execute `callback` and update the `last_exec` timestamp.
function exec() {
last_exec = +new Date();
callback.apply( that, args );
};
// If `debounce_mode` is true (at_begin) this is used to clear the flag
// to allow future `callback` executions.
function clear() {
timeout_id = undefined;
};
if ( debounce_mode && !timeout_id ) {
// Since `wrapper` is being called for the first time and
// `debounce_mode` is true (at_begin), execute `callback`.
exec();
}
// Clear any existing timeout.
timeout_id && clearTimeout( timeout_id );
if ( debounce_mode === undefined && elapsed > delay ) {
// In throttle mode, if `delay` time has been exceeded, execute
// `callback`.
exec();
} else if ( no_trailing !== true ) {
// In trailing throttle mode, since `delay` time has not been
// exceeded, schedule `callback` to execute `delay` ms after most
// recent execution.
//
// If `debounce_mode` is true (at_begin), schedule `clear` to execute
// after `delay` ms.
//
// If `debounce_mode` is false (at end), schedule `callback` to
// execute after `delay` ms.
timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay );
}
};
// Set the guid of `wrapper` function to the same of original callback, so
// it can be removed in jQuery 1.4+ .unbind or .die by using the original
// callback as a reference.
if ( $.guid ) {
wrapper.guid = callback.guid = callback.guid || $.guid++;
}
// Return the wrapper function.
return wrapper;
};
// Method: jQuery.debounce
//
// Debounce execution of a function. Debouncing, unlike throttling,
// guarantees that a function is only executed a single time, either at the
// very beginning of a series of calls, or at the very end. If you want to
// simply rate-limit execution of a function, see the
// method.
//
// In this visualization, | is a debounced-function call and X is the actual
// callback execution:
//
// > Debounced with `at_begin` specified as false or unspecified:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X
// >
// > Debounced with `at_begin` specified as true:
// > ||||||||||||||||||||||||| (pause) |||||||||||||||||||||||||
// > X X
//
// Usage:
//
// > var debounced = jQuery.debounce( delay, [ at_begin, ] callback );
// >
// > jQuery('selector').bind( 'someevent', debounced );
// > jQuery('selector').unbind( 'someevent', debounced );
//
// This also works in jQuery 1.4+:
//
// > jQuery('selector').bind( 'someevent', jQuery.debounce( delay, [ at_begin, ] callback ) );
// > jQuery('selector').unbind( 'someevent', callback );
//
// Arguments:
//
// delay - (Number) A zero-or-greater delay in milliseconds. For event
// callbacks, values around 100 or 250 (or even higher) are most useful.
// at_begin - (Boolean) Optional, defaults to false. If at_begin is false or
// unspecified, callback will only be executed `delay` milliseconds after
// the last debounced-function call. If at_begin is true, callback will be
// executed only at the first debounced-function call. (After the
// throttled-function has not been called for `delay` milliseconds, the
// internal counter is reset)
// callback - (Function) A function to be executed after delay milliseconds.
// The `this` context and all arguments are passed through, as-is, to
// `callback` when the debounced-function is executed.
//
// Returns:
//
// (Function) A new, debounced, function.
$.debounce = function( delay, at_begin, callback ) {
return callback === undefined
? jq_throttle( delay, at_begin, false )
: jq_throttle( delay, callback, at_begin !== false );
};
})(this);
/*!
* touchSwipe - jQuery Plugin
* https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
* http://labs.skinkers.com/touchSwipe/
* http://plugins.jquery.com/project/touchSwipe
*
* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* $version: 1.4.0
*
* Changelog
* $Date: 2010-12-12 (Wed, 12 Dec 2010) $
* $version: 1.0.0
* $version: 1.0.1 - removed multibyte comments
*
* $Date: 2011-21-02 (Mon, 21 Feb 2011) $
* $version: 1.1.0 - added allowPageScroll property to allow swiping and scrolling of page
* - changed handler signatures so one handler can be used for multiple events
* $Date: 2011-23-02 (Wed, 23 Feb 2011) $
* $version: 1.2.0 - added click handler. This is fired if the user simply clicks and does not swipe. The event object and click target are passed to handler.
* - If you use the http://code.google.com/p/jquery-ui-for-ipad-and-iphone/ plugin, you can also assign jQuery mouse events to children of a touchSwipe object.
* $version: 1.2.1 - removed console log!
*
* $version: 1.2.2 - Fixed bug where scope was not preserved in callback methods.
*
* $Date: 2011-28-04 (Thurs, 28 April 2011) $
* $version: 1.2.4 - Changed licence terms to be MIT or GPL inline with jQuery. Added check for support of touch events to stop non compatible browsers erroring.
*
* $Date: 2011-27-09 (Tues, 27 September 2011) $
* $version: 1.2.5 - Added support for testing swipes with mouse on desktop browser (thanks to https://github.com/joelhy)
*
* $Date: 2012-14-05 (Mon, 14 May 2012) $
* $version: 1.2.6 - Added timeThreshold between start and end touch, so user can ignore slow swipes (thanks to Mark Chase). Default is null, all swipes are detected
*
* $Date: 2012-05-06 (Tues, 05 June 2012) $
* $version: 1.2.7 - Changed time threshold to have null default for backwards compatibility. Added duration param passed back in events, and refactored how time is handled.
*
* $Date: 2012-05-06 (Tues, 05 June 2012) $
* $version: 1.2.8 - Added the possibility to return a value like null or false in the trigger callback. In that way we can control when the touch start/move should take effect or not (simply by returning in some cases return null; or return false;) This effects the ontouchstart/ontouchmove event.
*
* $Date: 2012-06-06 (Wed, 06 June 2012) $
* $version: 1.3.0 - Refactored whole plugin to allow for methods to be executed, as well as exposed defaults for user override. Added 'enable', 'disable', and 'destroy' methods
*
* $Date: 2012-05-06 (Fri, 05 June 2012) $
* $version: 1.3.1 - Bug fixes - bind() with false as last argument is no longer supported in jQuery 1.6, also, if you just click, the duration is now returned correctly.
*
* $Date: 2012-29-07 (Sun, 29 July 2012) $
* $version: 1.3.2 - Added fallbackToMouseEvents option to NOT capture mouse events on non touch devices.
* - Added "all" fingers value to the fingers property, so any combinatin of fingers triggers the swipe, allowing event handlers to check the finger count
*
* $Date: 2012-09-08 (Thurs, 9 Aug 2012) $
* $version: 1.3.3 - Code tidy prep for minified version
*
* $Date: 2012-04-10 (wed, 4 Oct 2012) $
* $version: 1.4.0 - Added pinch support, pinchIn and pinchOut
*
* A jQuery plugin to capture left, right, up and down swipes on touch devices.
* You can capture 2 finger or 1 finger swipes, set the threshold and define either a catch all handler, or individual direction handlers.
* Options: The defaults can be overridden by setting them in $.fn.swipe.defaults
* swipe Function A catch all handler that is triggered for all swipe directions. Handler is passed 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down" , the distance of the swipe, the duration of the swipe and the finger count.
* swipeLeft Function A handler that is triggered for "left" swipes. Handler is passed 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down" , the distance of the swipe, the duration of the swipe and the finger count.
* swipeRight Function A handler that is triggered for "right" swipes. Handler is passed 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down" , the distance of the swipe, the duration of the swipe and the finger count.
* swipeUp Function A handler that is triggered for "up" swipes. Handler is passed 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down" , the distance of the swipe, the duration of the swipe and the finger count.
* swipeDown Function A handler that is triggered for "down" swipes. Handler is passed 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down" , the distance of the swipe, the duration of the swipe and the finger count.
* swipeStatus Function A handler triggered for every phase of the swipe. Handler is passed 4 arguments: event : The original event object, phase:The current swipe phase, either "start", "move", "end" or "cancel". direction : The swipe direction, either "up?, "down?, "left " or "right?.distance : The distance of the swipe.Duration : The duration of the swipe : The finger count
*
* pinchIn Function A handler triggered when the user pinch zooms inward. Handler is passed
* pinchOut Function A handler triggered when the user pinch zooms outward. Handler is passed
* pinchStatus Function A handler triggered for every phase of a pinch. Handler is passed 4 arguments: event : The original event object, phase:The current swipe face, either "start", "move", "end" or "cancel". direction : The swipe direction, either "in" or "out". distance : The distance of the pinch, zoom: the pinch zoom level
*
* click Function A handler triggered when a user just clicks on the item, rather than swipes it. If they do not move, click is triggered, if they do move, it is not.
*
* fingers int Default 1. The number of fingers to trigger the swipe, 1 or 2.
* threshold int Default 75. The number of pixels that the user must move their finger by before it is considered a swipe.
* maxTimeThreshold int Default null. Time, in milliseconds, between touchStart and touchEnd must NOT exceed in order to be considered a swipe.
* triggerOnTouchEnd Boolean Default true If true, the swipe events are triggered when the touch end event is received (user releases finger). If false, it will be triggered on reaching the threshold, and then cancel the touch event automatically.
* allowPageScroll String Default "auto". How the browser handles page scrolls when the user is swiping on a touchSwipe object.
* "auto" : all undefined swipes will cause the page to scroll in that direction.
* "none" : the page will not scroll when user swipes.
* "horizontal" : will force page to scroll on horizontal swipes.
* "vertical" : will force page to scroll on vertical swipes.
* fallbackToMouseEvents Boolean Default true if true mouse events are used when run on a non touch device, false will stop swipes being triggered by mouse events on non tocuh devices
*
* Methods: To be executed as strings, $el.swipe('disable');
* disable Will disable all touch events until enabled again
* enable Will re-enable the touch events
* destroy Will kill the plugin, and it must be re-instantiated if it needs to be used again
*
* This jQuery plugin will only run on devices running Mobile Webkit based browsers (iOS 2.0+, android 2.2+)
*/
(function ($) {
//Constants
var LEFT = "left",
RIGHT = "right",
UP = "up",
DOWN = "down",
IN = "in",
OUT = "out",
NONE = "none",
AUTO = "auto",
HORIZONTAL = "horizontal",
VERTICAL = "vertical",
ALL_FINGERS = "all",
PHASE_START = "start",
PHASE_MOVE = "move",
PHASE_END = "end",
PHASE_CANCEL = "cancel",
SUPPORTS_TOUCH = 'ontouchstart' in window,
PLUGIN_NS = 'TouchSwipe';
// Default thresholds & swipe functions
var defaults = {
fingers: 1, // int - The number of fingers to trigger the swipe, 1 or 2. Default is 1.
threshold: 75, // int - The number of pixels that the user must move their finger by before it is considered a swipe. Default is 75.
maxTimeThreshold: null, // int - Time, in milliseconds, between touchStart and touchEnd must NOT exceed in order to be considered a swipe.
swipe: null, // Function - A catch all handler that is triggered for all swipe directions. Accepts 2 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down", and the finger count.
swipeLeft: null, // Function - A handler that is triggered for "left" swipes. Accepts 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down", the distance of the swipe, and the finger count.
swipeRight: null, // Function - A handler that is triggered for "right" swipes. Accepts 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down", the distance of the swipe, and the finger count.
swipeUp: null, // Function - A handler that is triggered for "up" swipes. Accepts 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down", the distance of the swipe, and the finger count.
swipeDown: null, // Function - A handler that is triggered for "down" swipes. Accepts 3 arguments, the original event object, the direction of the swipe : "left", "right", "up", "down", the distance of the swipe, and the finger count.
swipeStatus: null, // Function - A handler triggered for every phase of the swipe. Handler is passed 4 arguments: event : The original event object, phase:The current swipe phase, either "start, "move, "end or "cancel. direction : The swipe direction, either "up", "down", "left" or "right". distance : The distance of the swipe, fingerCount: The finger count.
pinchIn:null, // Function - A handler triggered for pinch in events. Handler is passed 4 arguments: event : The original event object, direction : The swipe direction, either "in" or "out". distance : The distance of the pinch, zoom: the pinch zoom level
pinchOut:null, // Function - A handler triggered for pinch in events. Handler is passed 4 arguments: event : The original event object, direction : The swipe direction, either "in" or "out". distance : The distance of the pinch, zoom: the pinch zoom level
pinchStatus:null, // Function - A handler triggered for every phase of a pinch. Handler is passed 4 arguments: event : The original event object, phase:The current swipe face, either "start", "move", "end" or "cancel". direction : The swipe direction, either "in" or "out". distance : The distance of the pinch, zoom: the pinch zoom level
click: null, // Function - A handler triggered when a user just clicks on the item, rather than swipes it. If they do not move, click is triggered, if they do move, it is not.
triggerOnTouchEnd: true, // Boolean, if true, the swipe events are triggered when the touch end event is received (user releases finger). If false, it will be triggered on reaching the threshold, and then cancel the touch event automatically.
allowPageScroll: "auto", /* How the browser handles page scrolls when the user is swiping on a touchSwipe object.
"auto" : all undefined swipes will cause the page to scroll in that direction.
"none" : the page will not scroll when user swipes.
"horizontal" : will force page to scroll on horizontal swipes.
"vertical" : will force page to scroll on vertical swipes.
*/
fallbackToMouseEvents: true //Boolean, if true mouse events are used when run on a non touch device, false will stop swipes being triggered by mouse events on non tocuh devices
};
/**
* Main plugin entry point for jQuery
* This allows us to pass options object for instantiation,
* as well as execute methods by name as per jQuery plugin architecture
*/
$.fn.swipe = function (method) {
var $this = $(this),
plugin = $this.data(PLUGIN_NS);
//Check if we are already instantiated and trying to execute a method
if (plugin && typeof method === 'string') {
if (plugin[method]) {
return plugin[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else {
$.error('Method ' + method + ' does not exist on jQuery.swipe');
}
}
//Else not instantiated and trying to pass init object (or nothing)
else if (!plugin && (typeof method === 'object' || !method)) {
return init.apply(this, arguments);
}
return $this;
};
//Expose our defaults so a user could override the plugin defaults
$.fn.swipe.defaults = defaults;
//Expose our phase constants - READ ONLY
$.fn.swipe.phases = {
PHASE_START: PHASE_START,
PHASE_MOVE: PHASE_MOVE,
PHASE_END: PHASE_END,
PHASE_CANCEL: PHASE_CANCEL
};
//Expose our direction constants - READ ONLY
$.fn.swipe.directions = {
LEFT: LEFT,
RIGHT: RIGHT,
UP: UP,
DOWN: DOWN,
IN : IN,
OUT: OUT
};
//Expose our page scroll directions - READ ONLY
$.fn.swipe.pageScroll = {
NONE: NONE,
HORIZONTAL: HORIZONTAL,
VERTICAL: VERTICAL,
AUTO: AUTO
};
//EXPOSE our fingers values - READ ONLY
$.fn.swipe.fingers = {
ONE: 1,
TWO: 2,
THREE: 3,
ALL: ALL_FINGERS
};
/**
* Initialise the plugin for each DOM element matched
* This creates a new instance of the main TouchSwipe class for each DOM element, and then
* saves a reference to that instance in the elements data property.
*/
function init(options) {
//Prep and extend the options
if (options && (options.allowPageScroll === undefined && (options.swipe !== undefined || options.swipeStatus !== undefined))) {
options.allowPageScroll = NONE;
}
if (!options) {
options = {};
}
//pass empty object so we dont modify the defaults
options = $.extend({}, $.fn.swipe.defaults, options);
//For each element instantiate the plugin
return this.each(function () {
var $this = $(this);
//Check we havent already initialised the plugin
var plugin = $this.data(PLUGIN_NS);
if (!plugin) {
plugin = new touchSwipe(this, options);
$this.data(PLUGIN_NS, plugin);
}
});
}
/**
* Main TouchSwipe Plugin Class
*/
function touchSwipe(element, options) {
var useTouchEvents = (SUPPORTS_TOUCH || !options.fallbackToMouseEvents),
START_EV = useTouchEvents ? 'touchstart' : 'mousedown',
MOVE_EV = useTouchEvents ? 'touchmove' : 'mousemove',
END_EV = useTouchEvents ? 'touchend' : 'mouseup',
CANCEL_EV = 'touchcancel';
var distance = 0;
var direction = null;
var duration = 0;
var startTouchesDistance=0;
var endTouchesDistance=0;
var pinchZoom = 1;
var pinchDirection=0;
//jQuery wrapped element for this instance
var $element = $(element);
var phase = "start";
var fingerCount = 0; // the current number of fingers being used.
//track mouse points / delta
var fingerData=null;
//track times
var startTime = 0;
var endTime = 0;
// Add gestures to all swipable areas if supported
try {
$element.bind(START_EV, touchStart);
$element.bind(CANCEL_EV, touchCancel);
}
catch (e) {
$.error('events not supported ' + START_EV + ',' + CANCEL_EV + ' on jQuery.swipe');
}
//Public methods
/**
* re-enables the swipe plugin with the previous configuration
*/
this.enable = function () {
$element.bind(START_EV, touchStart);
$element.bind(CANCEL_EV, touchCancel);
return $element;
};
/**
* disables the swipe plugin
*/
this.disable = function () {
removeListeners();
return $element;
};
/**
* Destroy the swipe plugin completely. To use any swipe methods, you must re initialise the plugin.
*/
this.destroy = function () {
removeListeners();
$element.data(PLUGIN_NS, null);
return $element;
};
//Private methods
/**
* Event handler for a touch start event.
* Stops the default click event from triggering and stores where we touched
*/
function touchStart(event) {
//If we already in a touch event (a finger already in use) then ignore subsequent ones..
if( getTouchInProgress() )
return;
//As we use Jquery bind for events, we need to target the original event object
event = event.originalEvent;
var ret,
evt = SUPPORTS_TOUCH ? event.touches[0] : event;
phase = PHASE_START;
//If we support touches, get the finger count
if (SUPPORTS_TOUCH) {
// get the total number of fingers touching the screen
fingerCount = event.touches.length;
}
//Else this is the desktop, so stop the browser from dragging the image
else {
event.preventDefault();
}
//clear vars..
distance = 0;
direction = null;
pinchDirection=null;
duration = 0;
startTouchesDistance=0;
endTouchesDistance=0;
pinchZoom = 1;
fingerData=createFingerData();
// check the number of fingers is what we are looking for, or we are capturing pinches
if (!SUPPORTS_TOUCH || (fingerCount === options.fingers || options.fingers === ALL_FINGERS) || hasPinches()) {
// get the coordinates of the touch
fingerData[0].start.x = fingerData[0].end.x = evt.pageX;
fingerData[0].start.y = fingerData[0].end.y = evt.pageY;
startTime = getTimeStamp();
if(fingerCount==2) {
//Keep track of the initial pinch distance, so we can calculate the diff later
//Store second finger data as start
fingerData[1].start.x = fingerData[1].end.x = event.touches[1].pageX;
fingerData[1].start.y = fingerData[1].end.y = event.touches[1].pageY;
startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
}
if (options.swipeStatus || options.pinchStatus) {
ret = triggerHandler(event, phase);
}
}
else {
//A touch with more or less than the fingers we are looking for, so cancel
touchCancel(event);
ret = false; // actualy cancel so we dont register event...
}
//If we have a return value from the users handler, then return and cancel
if (ret === false) {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
return ret;
}
else {
setTouchInProgress(true);
$element.bind(MOVE_EV, touchMove);
$element.bind(END_EV, touchEnd);
}
};
/**
* Event handler for a touch move event.
* If we change fingers during move, then cancel the event
*/
function touchMove(event) {
//As we use Jquery bind for events, we need to target the original event object
event = event.originalEvent;
if (phase === PHASE_END || phase === PHASE_CANCEL)
return;
var ret,
evt = SUPPORTS_TOUCH ? event.touches[0] : event;
//Save the first finger data
fingerData[0].end.x = SUPPORTS_TOUCH ? event.touches[0].pageX : evt.pageX;
fingerData[0].end.y = SUPPORTS_TOUCH ? event.touches[0].pageY : evt.pageY;
endTime = getTimeStamp();
direction = calculateDirection(fingerData[0].start, fingerData[0].end);
if (SUPPORTS_TOUCH) {
fingerCount = event.touches.length;
}
phase = PHASE_MOVE;
//If we have 2 fingers get Touches distance as well
if(fingerCount==2) {
//Keep track of the initial pinch distance, so we can calculate the diff later
//We do this here as well as the start event, incase they start with 1 finger, and the press 2 fingers
if(startTouchesDistance==0) {
//Store second finger data as start
fingerData[1].start.x = event.touches[1].pageX;
fingerData[1].start.y = event.touches[1].pageY;
startTouchesDistance = endTouchesDistance = calculateTouchesDistance(fingerData[0].start, fingerData[1].start);
} else {
//Store second finger data as end
fingerData[1].end.x = event.touches[1].pageX;
fingerData[1].end.y = event.touches[1].pageY;
endTouchesDistance = calculateTouchesDistance(fingerData[0].end, fingerData[1].end);
pinchDirection = calculatePinchDirection(fingerData[0].end, fingerData[1].end);
}
pinchZoom = calculatePinchZoom(startTouchesDistance, endTouchesDistance);
}
if ((fingerCount === options.fingers || options.fingers === ALL_FINGERS) || !SUPPORTS_TOUCH) {
//Check if we need to prevent default evnet (page scroll / pinch zoom) or not
validateDefaultEvent(event, direction);
//Distance and duration are all off the main finger
distance = calculateDistance(fingerData[0].start, fingerData[0].end);
duration = calculateDuration(fingerData[0].start, fingerData[0].end);
if (options.swipeStatus || options.pinchStatus) {
ret = triggerHandler(event, phase);
}
//If we trigger whilst dragging, not on touch end, then calculate now...
if (!options.triggerOnTouchEnd) {
var cancel = !validateSwipeTime();
// if the user swiped more than the minimum length, perform the appropriate action
if (validateSwipeDistance() === true) {
phase = PHASE_END;
ret = triggerHandler(event, phase);
} else if (cancel) {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
}
}
else {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
if (ret === false) {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
}
/**
* Event handler for a touch end event.
* Calculate the direction and trigger events
*/
function touchEnd(event) {
//As we use Jquery bind for events, we need to target the original event object
event = event.originalEvent;
//If we are still in a touch another finger is down, then dont cancel
if(event.touches && event.touches.length>0)
return true;
event.preventDefault();
endTime = getTimeStamp();
//If we have any touches distance data (they pinched at some point) get Touches distance as well
if(startTouchesDistance!=0) {
endTouchesDistance = calculateTouchesDistance(fingerData[0].end, fingerData[1].end);
pinchZoom = calculatePinchZoom(startTouchesDistance, endTouchesDistance);
pinchDirection = calculatePinchDirection(fingerData[0].end, fingerData[1].end);
}
distance = calculateDistance(fingerData[0].start, fingerData[0].end);
direction = calculateDirection(fingerData[0].start, fingerData[0].end);
duration = calculateDuration();
//If we trigger handlers at end of swipe OR, we trigger during, but they didnt trigger and we are still in the move phase
if (options.triggerOnTouchEnd || (options.triggerOnTouchEnd === false && phase === PHASE_MOVE)) {
phase = PHASE_END;
// Validate the types of swipe we are looking for
//Either we are listening for a pinch, and got one, or we are NOT listening so dont care.
var hasValidPinchResult = didPinch() || !hasPinches();
//The number of fingers we want were matched, or on desktop we ignore
var hasCorrectFingerCount = ((fingerCount === options.fingers || options.fingers === ALL_FINGERS) || !SUPPORTS_TOUCH);
//We have an end value for the finger
var hasEndPoint = fingerData[0].end.x !== 0;
//Check if the above conditions are met to make this swipe count...
var isSwipe = (hasCorrectFingerCount && hasEndPoint && hasValidPinchResult);
//If we are in a swipe, validate the time and distance...
if (isSwipe) {
var hasValidTime = validateSwipeTime();
//Check the distance meets threshold settings
var hasValidDistance = validateSwipeDistance();
// if the user swiped more than the minimum length, perform the appropriate action
// hasValidDistance is null when no distance is set
if ((hasValidDistance === true || hasValidDistance === null) && hasValidTime) {
triggerHandler(event, phase);
}
else if (!hasValidTime || hasValidDistance === false) {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
}
else {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
}
else if (phase === PHASE_MOVE) {
phase = PHASE_CANCEL;
triggerHandler(event, phase);
}
$element.unbind(MOVE_EV, touchMove, false);
$element.unbind(END_EV, touchEnd, false);
setTouchInProgress(false);
}
/**
* Event handler for a touch cancel event.
* Clears current vars
*/
function touchCancel() {
// reset the variables back to default values
fingerCount = 0;
endTime = 0;
startTime = 0;
startTouchesDistance=0;
endTouchesDistance=0;
pinchZoom=1;
setTouchInProgress(false);
}
/**
* Trigger the relevant event handler
* The handlers are passed the original event, the element that was swiped, and in the case of the catch all handler, the direction that was swiped, "left", "right", "up", or "down"
*/
function triggerHandler(event, phase) {
var ret = undefined;
//update status
if (options.swipeStatus) {
ret = options.swipeStatus.call($element, event, phase, direction || null, distance || 0, duration || 0, fingerCount);
}
if (options.pinchStatus && didPinch()) {
ret = options.pinchStatus.call($element, event, phase, pinchDirection || null, endTouchesDistance || 0, duration || 0, fingerCount, pinchZoom);
}
if (phase === PHASE_CANCEL) {
if (options.click && (fingerCount === 1 || !SUPPORTS_TOUCH) && (isNaN(distance) || distance === 0)) {
ret = options.click.call($element, event, event.target);
}
}
if (phase == PHASE_END) {
//trigger catch all event handler
if (options.swipe) {
ret = options.swipe.call($element, event, direction, distance, duration, fingerCount);
}
//trigger direction specific event handlers
switch (direction) {
case LEFT:
if (options.swipeLeft) {
ret = options.swipeLeft.call($element, event, direction, distance, duration, fingerCount);
}
break;
case RIGHT:
if (options.swipeRight) {
ret = options.swipeRight.call($element, event, direction, distance, duration, fingerCount);
}
break;
case UP:
if (options.swipeUp) {
ret = options.swipeUp.call($element, event, direction, distance, duration, fingerCount);
}
break;
case DOWN:
if (options.swipeDown) {
ret = options.swipeDown.call($element, event, direction, distance, duration, fingerCount);
}
break;
}
switch (pinchDirection) {
case IN:
if (options.pinchIn) {
ret = options.pinchIn.call($element, event, pinchDirection || null, endTouchesDistance || 0, duration || 0, fingerCount, pinchZoom);
}
break;
case OUT:
if (options.pinchOut) {
ret = options.pinchOut.call($element, event, pinchDirection || null, endTouchesDistance || 0, duration || 0, fingerCount, pinchZoom);
}
break;
}
}
if (phase === PHASE_CANCEL || phase === PHASE_END) {
//Manually trigger the cancel handler to clean up data
touchCancel(event);
}
return ret;
}
/**
* Checks the user has swipe far enough
*/
function validateSwipeDistance() {
if (options.threshold !== null) {
return distance >= options.threshold;
}
return null;
}
/**
* Checks that the time taken to swipe meets the minimum / maximum requirements
*/
function validateSwipeTime() {
var result;
//If no time set, then return true
if (options.maxTimeThreshold) {
if (duration >= options.maxTimeThreshold) {
result = false;
} else {
result = true;
}
}
else {
result = true;
}
return result;
}
/**
* Checks direction of the swipe and the value allowPageScroll to see if we should allow or prevent the default behaviour from occurring.
* This will essentially allow page scrolling or not when the user is swiping on a touchSwipe object.
*/
function validateDefaultEvent(event, direction) {
if (options.allowPageScroll === NONE || hasPinches()) {
event.preventDefault();
} else {
var auto = options.allowPageScroll === AUTO;
switch (direction) {
case LEFT:
if ((options.swipeLeft && auto) || (!auto && options.allowPageScroll != HORIZONTAL)) {
event.preventDefault();
}
break;
case RIGHT:
if ((options.swipeRight && auto) || (!auto && options.allowPageScroll != HORIZONTAL)) {
event.preventDefault();
}
break;
case UP:
if ((options.swipeUp && auto) || (!auto && options.allowPageScroll != VERTICAL)) {
event.preventDefault();
}
break;
case DOWN:
if ((options.swipeDown && auto) || (!auto && options.allowPageScroll != VERTICAL)) {
event.preventDefault();
}
break;
}
}
}
/**
* Calcualte the duration of the swipe
*/
function calculateDuration() {
return endTime - startTime;
}
/**
* Calculate the distance between 2 touches (pinch)
*/
function calculateTouchesDistance(startPoint, endPoint) {
var diffX = Math.abs(startPoint.x - endPoint.x);
var diffY = Math.abs(startPoint.y - endPoint.y);
return Math.round(Math.sqrt(diffX*diffX+diffY*diffY));
}
/**
* Calculate the zoom factor between the start and end distances
*/
function calculatePinchZoom(startDistance, endDistance) {
var percent = (endDistance/startDistance) * 1;
return percent.toFixed(2);
}
/**
* Returns the pinch direction, either IN or OUT for the given points
*/
function calculatePinchDirection() {
if(pinchZoom<1) {
return OUT;
}
else {
return IN;
}
}
/**
* Calculate the length / distance of the swipe
* @param finger A finger object containing start and end points
*/
function calculateDistance(startPoint, endPoint) {
return Math.round(Math.sqrt(Math.pow(endPoint.x - startPoint.x, 2) + Math.pow(endPoint.y - startPoint.y, 2)));
}
/**
* Calcualte the angle of the swipe
* @param finger A finger object containing start and end points
*/
function caluculateAngle(startPoint, endPoint) {
var x = startPoint.x - endPoint.x;
var y = endPoint.y - startPoint.y;
var r = Math.atan2(y, x); //radians
var angle = Math.round(r * 180 / Math.PI); //degrees
//ensure value is positive
if (angle < 0) {
angle = 360 - Math.abs(angle);
}
return angle;
}
/**
* Calcualte the direction of the swipe
* This will also call caluculateAngle to get the latest angle of swipe
* @param finger A finger object containing start and end points
*/
function calculateDirection(startPoint, endPoint ) {
var angle = caluculateAngle(startPoint, endPoint);
if ((angle <= 45) && (angle >= 0)) {
return LEFT;
} else if ((angle <= 360) && (angle >= 315)) {
return LEFT;
} else if ((angle >= 135) && (angle <= 225)) {
return RIGHT;
} else if ((angle > 45) && (angle < 135)) {
return DOWN;
} else {
return UP;
}
}
/**
* Returns a MS time stamp of the current time
*/
function getTimeStamp() {
var now = new Date();
return now.getTime();
}
/**
* Removes all listeners that were associated with the plugin
*/
function removeListeners() {
$element.unbind(START_EV, touchStart);
$element.unbind(CANCEL_EV, touchCancel);
$element.unbind(MOVE_EV, touchMove);
$element.unbind(END_EV, touchEnd);
setTouchInProgress(false);
}
/**
* Returns true if any Pinch events have been registered
*/
function hasPinches() {
return options.pinchStatus || options.pinchIn || options.pinchOut;
}
/**
* Returns true if we are detecting pinches, and have one
*/
function didPinch() {
return pinchDirection && hasPinches();
}
/**
* gets a data flag to indicate that a touch is in progress
*/
function getTouchInProgress() {
return $element.data(PLUGIN_NS+'_intouch') === true ? true : false;
}
/**
* Sets a data flag to indicate that a touch is in progress
*/
function setTouchInProgress(val) {
val = val===true?true:false;
$element.data(PLUGIN_NS+'_intouch', val);
}
function createFingerData() {
var fingerData=[];
for (var i=0; i<=5; i++) {
fingerData.push({
start:{ x: 0, y: 0 },
end:{ x: 0, y: 0 },
delta:{ x: 0, y: 0 }
});
}
return fingerData;
}
}
})(jQuery);
/*!
* Stylish Select 0.4.9 - jQuery plugin to replace a select drop down box with a stylable unordered list
* http://github.com/scottdarby/Stylish-Select
*
* Requires: jQuery 1.3 or newer
*
* Contributions from Justin Beasley: http://www.harvest.org/
* Anatoly Ressin: http://www.artazor.lv/ Wilfred Hughes: https://github.com/Wilfred
* Grigory Zarubin: https://github.com/Craigy-
*
* Dual licensed under the MIT and GPL licenses.
*/
(function($){
//add class to html tag
$('html').addClass('stylish-select');
//Cross-browser implementation of indexOf from MDN: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
if (!Array.prototype.indexOf){
Array.prototype.indexOf = function(searchElement /*, fromIndex */){
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (len === 0)
return -1;
var n = 0;
if (arguments.length > 0){
n = Number(arguments[1]);
if (n !== n) // shortcut for verifying if it's NaN
n = 0;
else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0))
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
if (n >= len)
return -1;
var k = n >= 0
? n
: Math.max(len - Math.abs(n), 0);
for (; k < len; k++){
if (k in t && t[k] === searchElement)
return k;
}
return -1;
};
}
//utility methods
$.fn.extend({
getSetSSValue: function(value){
if (value){
//set value and trigger change event
$(this).val(value).change();
return this;
} else {
return $(this).find(':selected').val();
}
},
//added by Justin Beasley
resetSS: function(){
var oldOpts = $(this).data('ssOpts');
$this = $(this);
$this.next().remove();
//unbind all events and redraw
$this.unbind('.sSelect').sSelect(oldOpts);
}
});
$.fn.sSelect = function(options){
return this.each(function(){
var defaults = {
defaultText: 'Please select',
animationSpeed: 0, //set speed of dropdown
ddMaxHeight: '', //set css max-height value of dropdown
containerClass: '' //additional classes for container div
};
//initial variables
var opts = $.extend(defaults, options),
$input = $(this),
$containerDivText = $(''),
$containerDiv = $(''),
$containerDivWrapper = $(''),
$newUl = $(''),
currentIndex = -1,
prevIndex = -1,
keys = [],
prevKey = false,
prevented = false,
$newLi;
//added by Justin Beasley
$(this).data('ssOpts',options);
//build new list
$containerDiv.insertAfter($input);
$containerDiv.attr("tabindex", $input.attr("tabindex") || "0");
$containerDivText.prependTo($containerDiv);
$newUl.appendTo($containerDiv);
$newUl.wrap($containerDivWrapper);
$containerDivWrapper = $newUl.parent();
$input.hide();
if($input.is(':disabled')){
return;
}
//added by Justin Beasley (used for lists initialized while hidden)
$containerDivText.data('ssReRender',!$containerDivText.is(':visible'));
//add one item to list
function addItem(item, container) {
var option = $(item).text(),
key = $(item).val(),
isDisabled = $(item).is(':disabled');
if (!isDisabled && !$(item).parents().is(':disabled')) {
//add first letter of each word to array
keys.push(option.charAt(0).toLowerCase());
}
container.append($(''+option+'').data({
'key' : key,
'selected' : $(item).is(':selected')
}));
}
$input.children().each(function(){
if ($(this).is('option')){
addItem(this, $newUl);
} else {
var optionTitle = $(this).attr('label'),
$optGroup = $(''),
$optGroupList = $('');
$optGroup.appendTo($newUl);
$optGroupList.appendTo($optGroup);
$(this).children().each(function(){
addItem(this, $optGroupList);
});
}
});
//cache list items object
$newLi = $newUl.find('li a:not(.newListItemDisabled)').not(function(){
return $(this).parents().hasClass('newListOptionDisabled');
});
//get selected item from new list (because it doesn't contain disabled options)
$newLi.each(function(i){
if ($(this).parent().data('selected')){
opts.defaultText = $(this).html();
currentIndex = prevIndex = i;
}
});
//get heights of new elements for use later
var newUlHeight = $newUl.height(),
containerHeight = $containerDiv.height(),
newLiLength = $newLi.length;
//check if a value is selected
if (currentIndex != -1){
navigateList(currentIndex);
} else {
//set placeholder text
$containerDivText.text(opts.defaultText);
}
//decide if to place the new list above or below the drop-down
function newUlPos(){
var containerPosY = $containerDiv.offset().top,
docHeight = $(window).height(),
scrollTop = $(window).scrollTop();
//if height of list is greater then max height, set list height to max height value
if (newUlHeight > parseInt(opts.ddMaxHeight)){
newUlHeight = parseInt(opts.ddMaxHeight);
}
containerPosY = containerPosY-scrollTop;
if (containerPosY+newUlHeight >= docHeight){
$newUl.css({
height: newUlHeight
});
$containerDivWrapper.css({
top: '-'+newUlHeight+'px',
height: newUlHeight
});
$input.onTop = true;
} else {
$newUl.css({
height: newUlHeight
});
$containerDivWrapper.css({
top: containerHeight+'px',
height: newUlHeight
});
$input.onTop = false;
}
}
//run function on page load
newUlPos();
//run function on browser window resize
$(window).bind('resize.sSelect scroll.sSelect', newUlPos);
//positioning
function positionFix(){
$containerDiv.css('position','relative');
}
function positionHideFix(){
$containerDiv.css(
{
position: 'static'
});
}
$containerDivText.bind('click.sSelect',function(event){
event.stopPropagation();
//added by Justin Beasley
if($(this).data('ssReRender')){
newUlHeight = $newUl.height('').height();
$containerDivWrapper.height('');
containerHeight = $containerDiv.height();
$(this).data('ssReRender',false);
newUlPos();
}
//hide all menus apart from this one
$('.SSContainerDivWrapper')
.not($(this).next())
.hide()
.parent()
.css('position', 'static')
.removeClass('newListSelFocus');
//show/hide this menu
$containerDivWrapper.toggle();
positionFix();
//scroll list to selected item
if(currentIndex == -1) currentIndex = 0;
try {
$newLi.eq(currentIndex).focus();
} catch(ex) {}
});
function closeDropDown(fireChange, resetText){
if(fireChange == true){
prevIndex = currentIndex;
$input.change();
}
if(resetText == true){
currentIndex = prevIndex;
navigateList(currentIndex);
}
$containerDivWrapper.hide();
positionHideFix();
}
$newLi.bind('click.sSelect',function(e){
var $clickedLi = $(e.target);
//update counter
currentIndex = $newLi.index($clickedLi);
//remove all hilites, then add hilite to selected item
prevented = true;
navigateList(currentIndex, true);
closeDropDown();
});
$newLi.bind('mouseenter.sSelect',
function(e){
var $hoveredLi = $(e.target);
$hoveredLi.addClass('newListHover');
}).bind('mouseleave.sSelect',
function(e){
var $hoveredLi = $(e.target);
$hoveredLi.removeClass('newListHover');
});
function navigateList(currentIndex, fireChange){
if(currentIndex == -1){
$containerDivText.text(opts.defaultText);
$newLi.removeClass('hiLite');
} else {
$newLi.removeClass('hiLite')
.eq(currentIndex)
.addClass('hiLite');
var text = $newLi.eq(currentIndex).text(),
val = $newLi.eq(currentIndex).parent().data('key');
try {
$input.val(val);
} catch(ex) {
// handle ie6 exception
$input[0].selectedIndex = currentIndex;
}
$containerDivText.text(text);
//only fire change event if specified
if(fireChange == true){
prevIndex = currentIndex;
$input.change();
}
if ($containerDivWrapper.is(':visible')){
try {
$newLi.eq(currentIndex).focus();
} catch(ex) {}
}
}
}
$input.bind('change.sSelect',function(event){
var $targetInput = $(event.target);
//stop change function from firing
if (prevented == true){
prevented = false;
return false;
}
var $currentOpt = $targetInput.find(':selected');
currentIndex = $targetInput.find('option').index($currentOpt);
navigateList(currentIndex);
});
//handle up and down keys
function keyPress(element){
//when keys are pressed
$(element).unbind('keydown.sSelect').bind('keydown.sSelect',function(e){
var keycode = e.which;
//prevent change function from firing
prevented = true;
switch(keycode){
case 40: //down
case 39: //right
incrementList();
return false;
break;
case 38: //up
case 37: //left
decrementList();
return false;
break;
case 33: //page up
case 36: //home
gotoFirst();
return false;
break;
case 34: //page down
case 35: //end
gotoLast();
return false;
break;
case 13: //enter
case 27: //esc
closeDropDown(true);
return false;
break;
case 9: //tab
closeDropDown(true);
nextFormElement();
return false;
break;
}
//check for keyboard shortcuts
keyPressed = String.fromCharCode(keycode).toLowerCase();
var currentKeyIndex = keys.indexOf(keyPressed);
if (typeof currentKeyIndex != 'undefined'){ //if key code found in array
++currentIndex;
currentIndex = keys.indexOf(keyPressed, currentIndex); //search array from current index
if (currentIndex == -1 || currentIndex == null || prevKey != keyPressed){
// if no entry was found or new key pressed search from start of array
currentIndex = keys.indexOf(keyPressed);
}
navigateList(currentIndex);
//store last key pressed
prevKey = keyPressed;
return false;
}
});
}
function incrementList(){
if (currentIndex < (newLiLength-1)){
++currentIndex;
navigateList(currentIndex);
}
}
function decrementList(){
if (currentIndex > 0){
--currentIndex;
navigateList(currentIndex);
}
}
function gotoFirst(){
currentIndex = 0;
navigateList(currentIndex);
}
function gotoLast(){
currentIndex = newLiLength-1;
navigateList(currentIndex);
}
$containerDiv.bind('click.sSelect',function(e){
e.stopPropagation();
keyPress(this);
});
$containerDiv.bind('focus.sSelect',function(){
$(this).addClass('newListSelFocus');
keyPress(this);
});
$containerDiv.bind('blur.sSelect',function(){
$(this).removeClass('newListSelFocus');
});
//hide list on blur
$(document).bind('click.sSelect',function(){
$containerDiv.removeClass('newListSelFocus');
if ($containerDivWrapper.is(':visible')){
closeDropDown(false, true);
} else {
closeDropDown(false);
}
});
//select next form element in document
function nextFormElement() {
var fields = $('body').find('button,input,textarea,select'),
index = fields.index($input);
if (index > -1 && (index + 1) < fields.length) {
fields.eq(index + 1).focus();
}
return false;
}
// handle focus on original select element
$input.focus(function(){
$input.next().focus();
});
//add classes on hover
$containerDivText.bind('mouseenter.sSelect',
function(e){
var $hoveredTxt = $(e.target);
$hoveredTxt.parent().addClass('newListSelHover');
}).bind('mouseleave.sSelect',
function(e){
var $hoveredTxt = $(e.target);
$hoveredTxt.parent().removeClass('newListSelHover');
});
//reset left property and hide
$containerDivWrapper.css({
left: '0',
display: 'none',
visibility: 'visible'
});
});
};
})(jQuery);
/*
* rwdImageMaps jQuery plugin v1.4
*
* Allows image maps to be used in a responsive design by recalculating the area coordinates to match the actual image size on load and window.resize
*
* Copyright (c) 2012 Matt Stow
* https://github.com/stowball/jQuery-rwdImageMaps
* http://mattstow.com
* Licensed under the MIT license
*/
;(function($) {
$.fn.rwdImageMaps = function() {
var $img = this,
version = parseFloat($.fn.jquery);
var rwdImageMap = function() {
$img.each(function() {
if (typeof($(this).attr('usemap')) == 'undefined')
return;
var that = this,
$that = $(that);
// Since WebKit doesn't know the height until after the image has loaded, perform everything in an onload copy
$('').load(function() {
var w,
h,
attrW = 'width',
attrH = 'height';
// jQuery < 1.6 incorrectly uses the actual image width/height instead of the attribute's width/height
if (version < 1.6)
w = that.getAttribute(attrW),
h = that.getAttribute(attrH);
else
w = $that.attr(attrW),
h = $that.attr(attrH);
if (!w || !h) {
var temp = new Image();
temp.src = $that.attr('src');
if (!w)
w = temp.width;
if (!h)
h = temp.height;
}
var wPercent = $that.width()/100,
hPercent = $that.height()/100,
map = $that.attr('usemap').replace('#', ''),
c = 'coords';
$('map[name="' + map + '"]').find('area').each(function() {
var $this = $(this);
if (!$this.data(c))
$this.data(c, $this.attr(c));
var coords = $this.data(c).split(','),
coordsPercent = new Array(coords.length);
for (var i = 0; i < coordsPercent.length; ++i) {
if (i % 2 === 0)
coordsPercent[i] = parseInt(((coords[i]/w)*100)*wPercent);
else
coordsPercent[i] = parseInt(((coords[i]/h)*100)*hPercent);
}
$this.attr(c, coordsPercent.toString());
});
}).attr('src', $that.attr('src'));
});
};
$(window).resize(rwdImageMap).trigger('resize');
return this;
};
})(jQuery);
/*! http://mths.be/placeholder v2.0.7 by @mathias */
;(function(window, document, $) {
var isInputSupported = 'placeholder' in document.createElement('input'),
isTextareaSupported = 'placeholder' in document.createElement('textarea'),
prototype = $.fn,
valHooks = $.valHooks,
hooks,
placeholder;
if (isInputSupported && isTextareaSupported) {
placeholder = prototype.placeholder = function() {
return this;
};
placeholder.input = placeholder.textarea = true;
} else {
placeholder = prototype.placeholder = function() {
var $this = this;
$this
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
.not('.placeholder')
.bind({
'focus.placeholder': clearPlaceholder,
'blur.placeholder': setPlaceholder
})
.data('placeholder-enabled', true)
.trigger('blur.placeholder');
return $this;
};
placeholder.input = isInputSupported;
placeholder.textarea = isTextareaSupported;
hooks = {
'get': function(element) {
var $element = $(element);
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
},
'set': function(element, value) {
var $element = $(element);
if (!$element.data('placeholder-enabled')) {
return element.value = value;
}
if (value == '') {
element.value = value;
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
if (element != document.activeElement) {
// We can't use `triggerHandler` here because of dummy text/password inputs :(
setPlaceholder.call(element);
}
} else if ($element.hasClass('placeholder')) {
clearPlaceholder.call(element, true, value) || (element.value = value);
} else {
element.value = value;
}
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
return $element;
}
};
isInputSupported || (valHooks.input = hooks);
isTextareaSupported || (valHooks.textarea = hooks);
$(function() {
// Look for forms
$(document).delegate('form', 'submit.placeholder', function() {
// Clear the placeholder values so they don't get submitted
var $inputs = $('.placeholder', this).each(clearPlaceholder);
setTimeout(function() {
$inputs.each(setPlaceholder);
}, 10);
});
});
// Clear placeholder values upon page reload
$(window).bind('beforeunload.placeholder', function() {
$('.placeholder').each(function() {
this.value = '';
});
});
}
function args(elem) {
// Return an object of element attributes
var newAttrs = {},
rinlinejQuery = /^jQuery\d+$/;
$.each(elem.attributes, function(i, attr) {
if (attr.specified && !rinlinejQuery.test(attr.name)) {
newAttrs[attr.name] = attr.value;
}
});
return newAttrs;
}
function clearPlaceholder(event, value) {
var input = this,
$input = $(input);
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
if ($input.data('placeholder-password')) {
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
// If `clearPlaceholder` was called from `$.valHooks.input.set`
if (event === true) {
return $input[0].value = value;
}
$input.focus();
} else {
input.value = '';
$input.removeClass('placeholder');
input == document.activeElement && input.select();
}
}
}
function setPlaceholder() {
var $replacement,
input = this,
$input = $(input),
$origInput = $input,
id = this.id;
if (input.value == '') {
if (input.type == 'password') {
if (!$input.data('placeholder-textinput')) {
try {
$replacement = $input.clone().attr({ 'type': 'text' });
} catch(e) {
$replacement = $('').attr($.extend(args(this), { 'type': 'text' }));
}
$replacement
.removeAttr('name')
.data({
'placeholder-password': true,
'placeholder-id': id
})
.bind('focus.placeholder', clearPlaceholder);
$input
.data({
'placeholder-textinput': $replacement,
'placeholder-id': id
})
.before($replacement);
}
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
// Note: `$input[0] != input` now!
}
$input.addClass('placeholder');
$input[0].value = $input.attr('placeholder');
} else {
$input.removeClass('placeholder');
}
}
}(this, document, jQuery));
/*! Scripts for the tables test page
Author: Maggie Wachs, www.filamentgroup.com
Date: November 2011
Adapted: Florian Krumhuber, www.ecx.io
Date: April 2013
Dependencies: jQuery, jQuery UI widget factory
*/
//$tableBtnText = "TEST";
if(!$tableBtnText){
var $tableBtnText = "Option";
}
(function ($) {
$.widget("filament.table", { // need to come up with a better namespace var...
options : {
idprefix : null, // specify a prefix for the id/headers values
persist : null, // specify a class assigned to column headers (th) that should always be present; the script not create a checkbox for these columns
checkContainer : null, // container element where the hide/show checkboxes will be inserted; if none specified, the script creates a menu
btnText : $tableBtnText, // added ecx.io > custom Buttontext
autoPrio : "true" // added ecx.io > autoPrio Mode true/false
},
// Set up the widget
_create : function () {
var self = this,
o = self.options,
table = self.element;
if( !table.find("thead").length ){
// fix if no thead is in DOM
var tempThead;
if ( table.find("th").length ){
tempThead = table.find("th").parent("tr");
}else{
// fix if no th is in DOM
tempThead = table.find("tr:first-child");
tempThead.find("td").each(function(){
tempThead.prepend(""+$(this).html()+" | ");
$(this).remove();
});
}
table.prepend("");
table.find("thead").append(tempThead);
}
var thead = table.find("thead"),
tbody = table.find("tbody"),
hdrCols = thead.find("th"),
bodyRows = tbody.find("tr"),
container = o.checkContainer ? $(o.checkContainer) : $('');
// add class for scoping styles - cells should be hidden only when JS is on
table.addClass("enhanced").wrap("");
hdrCols.each(function (i) {
var th = $(this),
id = th.attr("id");
// added ecx.io > assign Prios wenn autoPrio = true
if (o.autoPrio == "true") {
th.removeClass();
switch(i){
case 0:
th.addClass("persist");
break;
case 1:
// nothing to do > no class
break;
case 2:
th.addClass("prio1");
break;
case 3:
th.addClass("prio2");
break;
case 4:
th.addClass("prio3");
break;
case 5:
th.addClass("prio4");
break;
default:
th.addClass("prio5");
break;
} // switch
//lastVisibleCol(th);
} // if
var classes = th.attr("class");
// assign an id to each header, if none is in the markup
if (!id) {
id = (o.idprefix ? o.idprefix : "col-") + i;
th.attr("id", id);
};
// assign matching "headers" attributes to the associated cells
// TEMP - needs to be edited to accommodate colspans
bodyRows.each(function () {
var cell = $(this).find("th, td").eq(i);
cell.attr("headers", id);
if (classes) {
cell.addClass(classes);
};
});
// create the hide/show toggles
if (!th.is("." + o.persist)) {
var toggle = $(' ');
container.find("ul").append(toggle);
toggle.find("input")
.change(function () {
var input = $(this),
val = input.val(),
cols = $("#" + val + ", [headers=" + val + "]");
if (input.is(":checked")) {
cols.show();
} else {
cols.hide();
};
lastVisibleCol(table);
})
.bind("updateCheck", function () {
if (th.css("display") == "table-cell" || th.css("display") == "inline") {
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
})
.trigger("updateCheck");
};
i++;
}); // end hdrCols loop
// added ecx.io > adds/removes class to remove right border on last table col
lastVisibleCol(table);
function lastVisibleCol(table){
table.find(".lastVisibleCol").each(function(){
$(this).removeClass("lastVisibleCol");
//alert("TEST");
});
table.find("tr").each(function(){
$(this).find("td:visible:last, th:visible:last").addClass("lastVisibleCol");
});
} // function
// update the inputs' checked status
$(window).bind("orientationchange resize", function () {
container.find("input").trigger("updateCheck");
lastVisibleCol(table);
});
// if no container specified for the checkboxes, create a "Display" menu
if (!o.checkContainer) {
var menuWrapper = $(''),
menuBtn = $('');
menuBtn.click(function () {
container.toggleClass("table-menu-hidden");
menuBtn.toggleClass("open");
return false;
});
menuWrapper.append(menuBtn).append(container);
table.before(menuWrapper);
table.wrap("");
// assign click-to-close event
$(document).click(function (e) {
//console.log(e);
if (!$(e.target).is(container) && !$(e.target).is(menuBtn) && !$(e.target).is(container.find("*"))) {
container.addClass("table-menu-hidden");
menuBtn.removeClass("open");
}
});
};
}, // end _create
disable : function () {
// TBD
},
enable : function () {
// TBD
}
});
}
(jQuery));
/*!
* fancyBox - jQuery Plugin
* version: 2.1.5 (Fri, 14 Jun 2013)
* @requires jQuery v1.6 or later
*
* Examples at http://fancyapps.com/fancybox/
* License: www.fancyapps.com/fancybox/#license
*
* Copyright 2012 Janis Skarnelis - janis@fancyapps.com
*
*/
(function (window, document, $, undefined) {
"use strict";
var H = $("html"),
W = $(window),
D = $(document),
F = $.fancybox = function () {
F.open.apply( this, arguments );
},
IE = navigator.userAgent.match(/msie/i),
didUpdate = null,
isTouch = document.createTouch !== undefined,
isQuery = function(obj) {
return obj && obj.hasOwnProperty && obj instanceof $;
},
isString = function(str) {
return str && $.type(str) === "string";
},
isPercentage = function(str) {
return isString(str) && str.indexOf('%') > 0;
},
isScrollable = function(el) {
return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
},
getScalar = function(orig, dim) {
var value = parseInt(orig, 10) || 0;
if (dim && isPercentage(orig)) {
value = F.getViewport()[ dim ] / 100 * value;
}
return Math.ceil(value);
},
getValue = function(value, dim) {
return getScalar(value, dim) + 'px';
};
$.extend(F, {
// The current version of fancyBox
version: '2.1.5',
defaults: {
padding : 15,
margin : 20,
width : 800,
height : 600,
minWidth : 100,
minHeight : 100,
maxWidth : 9999,
maxHeight : 9999,
pixelRatio: 1, // Set to 2 for retina display support
autoSize : true,
autoHeight : false,
autoWidth : false,
autoResize : true,
autoCenter : !isTouch,
fitToView : true,
aspectRatio : false,
topRatio : 0.5,
leftRatio : 0.5,
scrolling : 'auto', // 'auto', 'yes' or 'no'
wrapCSS : '',
arrows : true,
closeBtn : true,
closeClick : false,
nextClick : false,
mouseWheel : true,
autoPlay : false,
playSpeed : 3000,
preload : 3,
modal : false,
loop : true,
ajax : {
dataType : 'html',
headers : { 'X-fancyBox': true }
},
iframe : {
scrolling : 'auto',
preload : true
},
swf : {
wmode: 'transparent',
allowfullscreen : 'true',
allowscriptaccess : 'always'
},
keys : {
next : {
13 : 'left', // enter
34 : 'up', // page down
39 : 'left', // right arrow
40 : 'up' // down arrow
},
prev : {
8 : 'right', // backspace
33 : 'down', // page up
37 : 'right', // left arrow
38 : 'down' // up arrow
},
close : [27], // escape key
play : [32], // space - start/stop slideshow
toggle : [70] // letter "f" - toggle fullscreen
},
direction : {
next : 'left',
prev : 'right'
},
scrollOutside : true,
// Override some properties
index : 0,
type : null,
href : null,
content : null,
title : null,
// HTML templates
tpl: {
wrap : '',
image : '',
iframe : '',
error : 'The requested content cannot be loaded.
Please try again later.
',
closeBtn : '',
next : '',
prev : ''
},
// Properties for each animation type
// Opening fancyBox
openEffect : 'fade', // 'elastic', 'fade' or 'none'
openSpeed : 250,
openEasing : 'swing',
openOpacity : true,
openMethod : 'zoomIn',
// Closing fancyBox
closeEffect : 'fade', // 'elastic', 'fade' or 'none'
closeSpeed : 250,
closeEasing : 'swing',
closeOpacity : true,
closeMethod : 'zoomOut',
// Changing next gallery item
nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
nextSpeed : 250,
nextEasing : 'swing',
nextMethod : 'changeIn',
// Changing previous gallery item
prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
prevSpeed : 250,
prevEasing : 'swing',
prevMethod : 'changeOut',
// Enable default helpers
helpers : {
overlay : true,
title : true
},
// Callbacks
onCancel : $.noop, // If canceling
beforeLoad : $.noop, // Before loading
afterLoad : $.noop, // After loading
beforeShow : $.noop, // Before changing in current item
afterShow : $.noop, // After opening
beforeChange : $.noop, // Before changing gallery item
beforeClose : $.noop, // Before closing
afterClose : $.noop // After closing
},
//Current state
group : {}, // Selected group
opts : {}, // Group options
previous : null, // Previous element
coming : null, // Element being loaded
current : null, // Currently loaded element
isActive : false, // Is activated
isOpen : false, // Is currently open
isOpened : false, // Have been fully opened at least once
wrap : null,
skin : null,
outer : null,
inner : null,
player : {
timer : null,
isActive : false
},
// Loaders
ajaxLoad : null,
imgPreload : null,
// Some collections
transitions : {},
helpers : {},
/*
* Static methods
*/
open: function (group, opts) {
if (!group) {
return;
}
if (!$.isPlainObject(opts)) {
opts = {};
}
// Close if already active
if (false === F.close(true)) {
return;
}
// Normalize group
if (!$.isArray(group)) {
group = isQuery(group) ? $(group).get() : [group];
}
// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
$.each(group, function(i, element) {
var obj = {},
href,
title,
content,
type,
rez,
hrefParts,
selector;
if ($.type(element) === "object") {
// Check if is DOM element
if (element.nodeType) {
element = $(element);
}
if (isQuery(element)) {
obj = {
href : element.data('fancybox-href') || element.attr('href'),
title : element.data('fancybox-title') || element.attr('title'),
isDom : true,
element : element
};
if ($.metadata) {
$.extend(true, obj, element.metadata());
}
} else {
obj = element;
}
}
href = opts.href || obj.href || (isString(element) ? element : null);
title = opts.title !== undefined ? opts.title : obj.title || '';
content = opts.content || obj.content;
type = content ? 'html' : (opts.type || obj.type);
if (!type && obj.isDom) {
type = element.data('fancybox-type');
if (!type) {
rez = element.prop('class').match(/fancybox\.(\w+)/);
type = rez ? rez[1] : null;
}
}
if (isString(href)) {
// Try to guess the content type
if (!type) {
if (F.isImage(href)) {
type = 'image';
} else if (F.isSWF(href)) {
type = 'swf';
} else if (href.charAt(0) === '#') {
type = 'inline';
} else if (isString(element)) {
type = 'html';
content = element;
}
}
// Split url into two pieces with source url and content selector, e.g,
// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
if (type === 'ajax') {
hrefParts = href.split(/\s+/, 2);
href = hrefParts.shift();
selector = hrefParts.shift();
}
}
if (!content) {
if (type === 'inline') {
if (href) {
content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
} else if (obj.isDom) {
content = element;
}
} else if (type === 'html') {
content = href;
} else if (!type && !href && obj.isDom) {
type = 'inline';
content = element;
}
}
$.extend(obj, {
href : href,
type : type,
content : content,
title : title,
selector : selector
});
group[ i ] = obj;
});
// Extend the defaults
F.opts = $.extend(true, {}, F.defaults, opts);
// All options are merged recursive except keys
if (opts.keys !== undefined) {
F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
}
F.group = group;
return F._start(F.opts.index);
},
// Cancel image loading or abort ajax request
cancel: function () {
var coming = F.coming;
if (!coming || false === F.trigger('onCancel')) {
return;
}
F.hideLoading();
if (F.ajaxLoad) {
F.ajaxLoad.abort();
}
F.ajaxLoad = null;
if (F.imgPreload) {
F.imgPreload.onload = F.imgPreload.onerror = null;
}
if (coming.wrap) {
coming.wrap.stop(true, true).trigger('onReset').remove();
}
F.coming = null;
// If the first item has been canceled, then clear everything
if (!F.current) {
F._afterZoomOut( coming );
}
},
// Start closing animation if is open; remove immediately if opening/closing
close: function (event) {
F.cancel();
if (false === F.trigger('beforeClose')) {
return;
}
F.unbindEvents();
if (!F.isActive) {
return;
}
if (!F.isOpen || event === true) {
$('.fancybox-wrap').stop(true).trigger('onReset').remove();
F._afterZoomOut();
} else {
F.isOpen = F.isOpened = false;
F.isClosing = true;
$('.fancybox-item, .fancybox-nav').remove();
F.wrap.stop(true, true).removeClass('fancybox-opened');
F.transitions[ F.current.closeMethod ]();
}
},
// Manage slideshow:
// $.fancybox.play(); - toggle slideshow
// $.fancybox.play( true ); - start
// $.fancybox.play( false ); - stop
play: function ( action ) {
var clear = function () {
clearTimeout(F.player.timer);
},
set = function () {
clear();
if (F.current && F.player.isActive) {
F.player.timer = setTimeout(F.next, F.current.playSpeed);
}
},
stop = function () {
clear();
D.unbind('.player');
F.player.isActive = false;
F.trigger('onPlayEnd');
},
start = function () {
if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
F.player.isActive = true;
D.bind({
'onCancel.player beforeClose.player' : stop,
'onUpdate.player' : set,
'beforeLoad.player' : clear
});
set();
F.trigger('onPlayStart');
}
};
if (action === true || (!F.player.isActive && action !== false)) {
start();
} else {
stop();
}
},
// Navigate to next gallery item
next: function ( direction ) {
var current = F.current;
if (current) {
if (!isString(direction)) {
direction = current.direction.next;
}
F.jumpto(current.index + 1, direction, 'next');
}
},
// Navigate to previous gallery item
prev: function ( direction ) {
var current = F.current;
if (current) {
if (!isString(direction)) {
direction = current.direction.prev;
}
F.jumpto(current.index - 1, direction, 'prev');
}
},
// Navigate to gallery item by index
jumpto: function ( index, direction, router ) {
var current = F.current;
if (!current) {
return;
}
index = getScalar(index);
F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
F.router = router || 'jumpto';
if (current.loop) {
if (index < 0) {
index = current.group.length + (index % current.group.length);
}
index = index % current.group.length;
}
if (current.group[ index ] !== undefined) {
F.cancel();
F._start(index);
}
},
// Center inside viewport and toggle position type to fixed or absolute if needed
reposition: function (e, onlyAbsolute) {
var current = F.current,
wrap = current ? current.wrap : null,
pos;
if (wrap) {
pos = F._getPosition(onlyAbsolute);
if (e && e.type === 'scroll') {
delete pos.position;
wrap.stop(true, true).animate(pos, 200);
} else {
wrap.css(pos);
current.pos = $.extend({}, current.dim, pos);
}
}
},
update: function (e) {
var type = (e && e.type),
anyway = !type || type === 'orientationchange';
if (anyway) {
clearTimeout(didUpdate);
didUpdate = null;
}
if (!F.isOpen || didUpdate) {
return;
}
didUpdate = setTimeout(function() {
var current = F.current;
if (!current || F.isClosing) {
return;
}
F.wrap.removeClass('fancybox-tmp');
if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
F._setDimension();
}
if (!(type === 'scroll' && current.canShrink)) {
F.reposition(e);
}
F.trigger('onUpdate');
didUpdate = null;
}, (anyway && !isTouch ? 0 : 300));
},
// Shrink content to fit inside viewport or restore if resized
toggle: function ( action ) {
if (F.isOpen) {
F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
// Help browser to restore document dimensions
if (isTouch) {
F.wrap.removeAttr('style').addClass('fancybox-tmp');
F.trigger('onUpdate');
}
F.update();
}
},
hideLoading: function () {
D.unbind('.loading');
$('#fancybox-loading').remove();
},
showLoading: function () {
var el, viewport;
F.hideLoading();
el = $('').click(F.cancel).appendTo('body');
// If user will press the escape-button, the request will be canceled
D.bind('keydown.loading', function(e) {
if ((e.which || e.keyCode) === 27) {
e.preventDefault();
F.cancel();
}
});
if (!F.defaults.fixed) {
viewport = F.getViewport();
el.css({
position : 'absolute',
top : (viewport.h * 0.5) + viewport.y,
left : (viewport.w * 0.5) + viewport.x
});
}
},
getViewport: function () {
var locked = (F.current && F.current.locked) || false,
rez = {
x: W.scrollLeft(),
y: W.scrollTop()
};
if (locked) {
rez.w = locked[0].clientWidth;
rez.h = locked[0].clientHeight;
} else {
// See http://bugs.jquery.com/ticket/6724
rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width();
rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
}
return rez;
},
// Unbind the keyboard / clicking actions
unbindEvents: function () {
if (F.wrap && isQuery(F.wrap)) {
F.wrap.unbind('.fb');
}
D.unbind('.fb');
W.unbind('.fb');
},
bindEvents: function () {
var current = F.current,
keys;
if (!current) {
return;
}
// Changing document height on iOS devices triggers a 'resize' event,
// that can change document height... repeating infinitely
W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
keys = current.keys;
if (keys) {
D.bind('keydown.fb', function (e) {
var code = e.which || e.keyCode,
target = e.target || e.srcElement;
// Skip esc key if loading, because showLoading will cancel preloading
if (code === 27 && F.coming) {
return false;
}
// Ignore key combinations and key events within form elements
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
$.each(keys, function(i, val) {
if (current.group.length > 1 && val[ code ] !== undefined) {
F[ i ]( val[ code ] );
e.preventDefault();
return false;
}
if ($.inArray(code, val) > -1) {
F[ i ] ();
e.preventDefault();
return false;
}
});
}
});
}
if ($.fn.mousewheel && current.mouseWheel) {
F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
var target = e.target || null,
parent = $(target),
canScroll = false;
while (parent.length) {
if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
break;
}
canScroll = isScrollable( parent[0] );
parent = $(parent).parent();
}
if (delta !== 0 && !canScroll) {
if (F.group.length > 1 && !current.canShrink) {
if (deltaY > 0 || deltaX > 0) {
F.prev( deltaY > 0 ? 'down' : 'left' );
} else if (deltaY < 0 || deltaX < 0) {
F.next( deltaY < 0 ? 'up' : 'right' );
}
e.preventDefault();
}
}
});
}
},
trigger: function (event, o) {
var ret, obj = o || F.coming || F.current;
if (!obj) {
return;
}
if ($.isFunction( obj[event] )) {
ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
}
if (ret === false) {
return false;
}
if (obj.helpers) {
$.each(obj.helpers, function (helper, opts) {
if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
}
});
}
D.trigger(event);
},
isImage: function (str) {
return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
},
isSWF: function (str) {
return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
},
_start: function (index) {
var coming = {},
obj,
href,
type,
margin,
padding;
index = getScalar( index );
obj = F.group[ index ] || null;
if (!obj) {
return false;
}
coming = $.extend(true, {}, F.opts, obj);
// Convert margin and padding properties to array - top, right, bottom, left
margin = coming.margin;
padding = coming.padding;
if ($.type(margin) === 'number') {
coming.margin = [margin, margin, margin, margin];
}
if ($.type(padding) === 'number') {
coming.padding = [padding, padding, padding, padding];
}
// 'modal' propery is just a shortcut
if (coming.modal) {
$.extend(true, coming, {
closeBtn : false,
closeClick : false,
nextClick : false,
arrows : false,
mouseWheel : false,
keys : null,
helpers: {
overlay : {
closeClick : false
}
}
});
}
// 'autoSize' property is a shortcut, too
if (coming.autoSize) {
coming.autoWidth = coming.autoHeight = true;
}
if (coming.width === 'auto') {
coming.autoWidth = true;
}
if (coming.height === 'auto') {
coming.autoHeight = true;
}
/*
* Add reference to the group, so it`s possible to access from callbacks, example:
* afterLoad : function() {
* this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
* }
*/
coming.group = F.group;
coming.index = index;
// Give a chance for callback or helpers to update coming item (type, title, etc)
F.coming = coming;
if (false === F.trigger('beforeLoad')) {
F.coming = null;
return;
}
type = coming.type;
href = coming.href;
if (!type) {
F.coming = null;
//If we can not determine content type then drop silently or display next/prev item if looping through gallery
if (F.current && F.router && F.router !== 'jumpto') {
F.current.index = index;
return F[ F.router ]( F.direction );
}
return false;
}
F.isActive = true;
if (type === 'image' || type === 'swf') {
coming.autoHeight = coming.autoWidth = false;
coming.scrolling = 'visible';
}
if (type === 'image') {
coming.aspectRatio = true;
}
if (type === 'iframe' && isTouch) {
coming.scrolling = 'scroll';
}
// Build the neccessary markup
coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
$.extend(coming, {
skin : $('.fancybox-skin', coming.wrap),
outer : $('.fancybox-outer', coming.wrap),
inner : $('.fancybox-inner', coming.wrap)
});
$.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
});
F.trigger('onReady');
// Check before try to load; 'inline' and 'html' types need content, others - href
if (type === 'inline' || type === 'html') {
if (!coming.content || !coming.content.length) {
return F._error( 'content' );
}
} else if (!href) {
return F._error( 'href' );
}
if (type === 'image') {
F._loadImage();
} else if (type === 'ajax') {
F._loadAjax();
} else if (type === 'iframe') {
F._loadIframe();
} else {
F._afterLoad();
}
},
_error: function ( type ) {
$.extend(F.coming, {
type : 'html',
autoWidth : true,
autoHeight : true,
minWidth : 0,
minHeight : 0,
scrolling : 'no',
hasError : type,
content : F.coming.tpl.error
});
F._afterLoad();
},
_loadImage: function () {
// Reset preload image so it is later possible to check "complete" property
var img = F.imgPreload = new Image();
img.onload = function () {
this.onload = this.onerror = null;
F.coming.width = this.width / F.opts.pixelRatio;
F.coming.height = this.height / F.opts.pixelRatio;
F._afterLoad();
};
img.onerror = function () {
this.onload = this.onerror = null;
F._error( 'image' );
};
img.src = F.coming.href;
if (img.complete !== true) {
F.showLoading();
}
},
_loadAjax: function () {
var coming = F.coming;
F.showLoading();
F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
url: coming.href,
error: function (jqXHR, textStatus) {
if (F.coming && textStatus !== 'abort') {
F._error( 'ajax', jqXHR );
} else {
F.hideLoading();
}
},
success: function (data, textStatus) {
if (textStatus === 'success') {
coming.content = data;
F._afterLoad();
}
}
}));
},
_loadIframe: function() {
var coming = F.coming,
iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
.attr('src', coming.href);
// This helps IE
$(coming.wrap).bind('onReset', function () {
try {
$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
} catch (e) {}
});
if (coming.iframe.preload) {
F.showLoading();
iframe.one('load', function() {
$(this).data('ready', 1);
// iOS will lose scrolling if we resize
if (!isTouch) {
$(this).bind('load.fb', F.update);
}
// Without this trick:
// - iframe won't scroll on iOS devices
// - IE7 sometimes displays empty iframe
$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
F._afterLoad();
});
}
coming.content = iframe.appendTo( coming.inner );
if (!coming.iframe.preload) {
F._afterLoad();
}
},
_preloadImages: function() {
var group = F.group,
current = F.current,
len = group.length,
cnt = current.preload ? Math.min(current.preload, len - 1) : 0,
item,
i;
for (i = 1; i <= cnt; i += 1) {
item = group[ (current.index + i ) % len ];
if (item.type === 'image' && item.href) {
new Image().src = item.href;
}
}
},
_afterLoad: function () {
var coming = F.coming,
previous = F.current,
placeholder = 'fancybox-placeholder',
current,
content,
type,
scrolling,
href,
embed;
F.hideLoading();
if (!coming || F.isActive === false) {
return;
}
if (false === F.trigger('afterLoad', coming, previous)) {
coming.wrap.stop(true).trigger('onReset').remove();
F.coming = null;
return;
}
if (previous) {
F.trigger('beforeChange', previous);
previous.wrap.stop(true).removeClass('fancybox-opened')
.find('.fancybox-item, .fancybox-nav')
.remove();
}
F.unbindEvents();
current = coming;
content = coming.content;
type = coming.type;
scrolling = coming.scrolling;
$.extend(F, {
wrap : current.wrap,
skin : current.skin,
outer : current.outer,
inner : current.inner,
current : current,
previous : previous
});
href = current.href;
switch (type) {
case 'inline':
case 'ajax':
case 'html':
if (current.selector) {
content = $('').html(content).find(current.selector);
} else if (isQuery(content)) {
if (!content.data(placeholder)) {
content.data(placeholder, $('
').insertAfter( content ).hide() );
}
content = content.show().detach();
current.wrap.bind('onReset', function () {
if ($(this).find(content).length) {
content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
}
});
}
break;
case 'image':
content = current.tpl.image.replace('{href}', href);
break;
case 'swf':
content = '
';
break;
}
if (!(isQuery(content) && content.parent().is(current.inner))) {
current.inner.append( content );
}
// Give a chance for helpers or callbacks to update elements
F.trigger('beforeShow');
// Set scrolling before calculating dimensions
current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
// Set initial dimensions and start position
F._setDimension();
F.reposition();
F.isOpen = false;
F.coming = null;
F.bindEvents();
if (!F.isOpened) {
$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
} else if (previous.prevMethod) {
F.transitions[ previous.prevMethod ]();
}
F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
F._preloadImages();
},
_setDimension: function () {
var viewport = F.getViewport(),
steps = 0,
canShrink = false,
canExpand = false,
wrap = F.wrap,
skin = F.skin,
inner = F.inner,
current = F.current,
width = current.width,
height = current.height,
minWidth = current.minWidth,
minHeight = current.minHeight,
maxWidth = current.maxWidth,
maxHeight = current.maxHeight,
scrolling = current.scrolling,
scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
margin = current.margin,
wMargin = getScalar(margin[1] + margin[3]),
hMargin = getScalar(margin[0] + margin[2]),
wPadding,
hPadding,
wSpace,
hSpace,
origWidth,
origHeight,
origMaxWidth,
origMaxHeight,
ratio,
width_,
height_,
maxWidth_,
maxHeight_,
iframe,
body;
// Reset dimensions so we could re-check actual size
wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
wPadding = getScalar(skin.outerWidth(true) - skin.width());
hPadding = getScalar(skin.outerHeight(true) - skin.height());
// Any space between content and viewport (margin, padding, border, title)
wSpace = wMargin + wPadding;
hSpace = hMargin + hPadding;
origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
if (current.type === 'iframe') {
iframe = current.content;
if (current.autoHeight && iframe.data('ready') === 1) {
try {
if (iframe[0].contentWindow.document.location) {
inner.width( origWidth ).height(9999);
body = iframe.contents().find('body');
if (scrollOut) {
body.css('overflow-x', 'hidden');
}
origHeight = body.outerHeight(true);
}
} catch (e) {}
}
} else if (current.autoWidth || current.autoHeight) {
inner.addClass( 'fancybox-tmp' );
// Set width or height in case we need to calculate only one dimension
if (!current.autoWidth) {
inner.width( origWidth );
}
if (!current.autoHeight) {
inner.height( origHeight );
}
if (current.autoWidth) {
origWidth = inner.width();
}
if (current.autoHeight) {
origHeight = inner.height();
}
inner.removeClass( 'fancybox-tmp' );
}
width = getScalar( origWidth );
height = getScalar( origHeight );
ratio = origWidth / origHeight;
// Calculations for the content
minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
// These will be used to determine if wrap can fit in the viewport
origMaxWidth = maxWidth;
origMaxHeight = maxHeight;
if (current.fitToView) {
maxWidth = Math.min(viewport.w - wSpace, maxWidth);
maxHeight = Math.min(viewport.h - hSpace, maxHeight);
}
maxWidth_ = viewport.w - wMargin;
maxHeight_ = viewport.h - hMargin;
if (current.aspectRatio) {
if (width > maxWidth) {
width = maxWidth;
height = getScalar(width / ratio);
}
if (height > maxHeight) {
height = maxHeight;
width = getScalar(height * ratio);
}
if (width < minWidth) {
width = minWidth;
height = getScalar(width / ratio);
}
if (height < minHeight) {
height = minHeight;
width = getScalar(height * ratio);
}
} else {
width = Math.max(minWidth, Math.min(width, maxWidth));
if (current.autoHeight && current.type !== 'iframe') {
inner.width( width );
height = inner.height();
}
height = Math.max(minHeight, Math.min(height, maxHeight));
}
// Try to fit inside viewport (including the title)
if (current.fitToView) {
inner.width( width ).height( height );
wrap.width( width + wPadding );
// Real wrap dimensions
width_ = wrap.width();
height_ = wrap.height();
if (current.aspectRatio) {
while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
if (steps++ > 19) {
break;
}
height = Math.max(minHeight, Math.min(maxHeight, height - 10));
width = getScalar(height * ratio);
if (width < minWidth) {
width = minWidth;
height = getScalar(width / ratio);
}
if (width > maxWidth) {
width = maxWidth;
height = getScalar(width / ratio);
}
inner.width( width ).height( height );
wrap.width( width + wPadding );
width_ = wrap.width();
height_ = wrap.height();
}
} else {
width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
}
}
if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
width += scrollOut;
}
inner.width( width ).height( height );
wrap.width( width + wPadding );
width_ = wrap.width();
height_ = wrap.height();
canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
$.extend(current, {
dim : {
width : getValue( width_ ),
height : getValue( height_ )
},
origWidth : origWidth,
origHeight : origHeight,
canShrink : canShrink,
canExpand : canExpand,
wPadding : wPadding,
hPadding : hPadding,
wrapSpace : height_ - skin.outerHeight(true),
skinSpace : skin.height() - height
});
if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
inner.height('auto');
}
},
_getPosition: function (onlyAbsolute) {
var current = F.current,
viewport = F.getViewport(),
margin = current.margin,
width = F.wrap.width() + margin[1] + margin[3],
height = F.wrap.height() + margin[0] + margin[2],
rez = {
position: 'absolute',
top : margin[0],
left : margin[3]
};
if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
rez.position = 'fixed';
} else if (!current.locked) {
rez.top += viewport.y;
rez.left += viewport.x;
}
rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
return rez;
},
_afterZoomIn: function () {
var current = F.current;
if (!current) {
return;
}
F.isOpen = F.isOpened = true;
F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
F.update();
// Assign a click event
if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
e.preventDefault();
F[ current.closeClick ? 'close' : 'next' ]();
}
});
}
// Create a close button
if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
e.preventDefault();
F.close();
});
}
// Create navigation arrows
if (current.arrows && F.group.length > 1) {
if (current.loop || current.index > 0) {
$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
}
if (current.loop || current.index < F.group.length - 1) {
$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
}
}
F.trigger('afterShow');
// Stop the slideshow if this is the last item
if (!current.loop && current.index === current.group.length - 1) {
F.play( false );
} else if (F.opts.autoPlay && !F.player.isActive) {
F.opts.autoPlay = false;
F.play();
}
},
_afterZoomOut: function ( obj ) {
obj = obj || F.current;
$('.fancybox-wrap').trigger('onReset').remove();
$.extend(F, {
group : {},
opts : {},
router : false,
current : null,
isActive : false,
isOpened : false,
isOpen : false,
isClosing : false,
wrap : null,
skin : null,
outer : null,
inner : null
});
F.trigger('afterClose', obj);
}
});
/*
* Default transitions
*/
F.transitions = {
getOrigPosition: function () {
var current = F.current,
element = current.element,
orig = current.orig,
pos = {},
width = 50,
height = 50,
hPadding = current.hPadding,
wPadding = current.wPadding,
viewport = F.getViewport();
if (!orig && current.isDom && element.is(':visible')) {
orig = element.find('img:first');
if (!orig.length) {
orig = element;
}
}
if (isQuery(orig)) {
pos = orig.offset();
if (orig.is('img')) {
width = orig.outerWidth();
height = orig.outerHeight();
}
} else {
pos.top = viewport.y + (viewport.h - height) * current.topRatio;
pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
}
if (F.wrap.css('position') === 'fixed' || current.locked) {
pos.top -= viewport.y;
pos.left -= viewport.x;
}
pos = {
top : getValue(pos.top - hPadding * current.topRatio),
left : getValue(pos.left - wPadding * current.leftRatio),
width : getValue(width + wPadding),
height : getValue(height + hPadding)
};
return pos;
},
step: function (now, fx) {
var ratio,
padding,
value,
prop = fx.prop,
current = F.current,
wrapSpace = current.wrapSpace,
skinSpace = current.skinSpace;
if (prop === 'width' || prop === 'height') {
ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
if (F.isClosing) {
ratio = 1 - ratio;
}
padding = prop === 'width' ? current.wPadding : current.hPadding;
value = now - padding;
F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
}
},
zoomIn: function () {
var current = F.current,
startPos = current.pos,
effect = current.openEffect,
elastic = effect === 'elastic',
endPos = $.extend({opacity : 1}, startPos);
// Remove "position" property that breaks older IE
delete endPos.position;
if (elastic) {
startPos = this.getOrigPosition();
if (current.openOpacity) {
startPos.opacity = 0.1;
}
} else if (effect === 'fade') {
startPos.opacity = 0.1;
}
F.wrap.css(startPos).animate(endPos, {
duration : effect === 'none' ? 0 : current.openSpeed,
easing : current.openEasing,
step : elastic ? this.step : null,
complete : F._afterZoomIn
});
},
zoomOut: function () {
var current = F.current,
effect = current.closeEffect,
elastic = effect === 'elastic',
endPos = {opacity : 0.1};
if (elastic) {
endPos = this.getOrigPosition();
if (current.closeOpacity) {
endPos.opacity = 0.1;
}
}
F.wrap.animate(endPos, {
duration : effect === 'none' ? 0 : current.closeSpeed,
easing : current.closeEasing,
step : elastic ? this.step : null,
complete : F._afterZoomOut
});
},
changeIn: function () {
var current = F.current,
effect = current.nextEffect,
startPos = current.pos,
endPos = { opacity : 1 },
direction = F.direction,
distance = 200,
field;
startPos.opacity = 0.1;
if (effect === 'elastic') {
field = direction === 'down' || direction === 'up' ? 'top' : 'left';
if (direction === 'down' || direction === 'right') {
startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
endPos[ field ] = '+=' + distance + 'px';
} else {
startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
endPos[ field ] = '-=' + distance + 'px';
}
}
// Workaround for http://bugs.jquery.com/ticket/12273
if (effect === 'none') {
F._afterZoomIn();
} else {
F.wrap.css(startPos).animate(endPos, {
duration : current.nextSpeed,
easing : current.nextEasing,
complete : F._afterZoomIn
});
}
},
changeOut: function () {
var previous = F.previous,
effect = previous.prevEffect,
endPos = { opacity : 0.1 },
direction = F.direction,
distance = 200;
if (effect === 'elastic') {
endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
}
previous.wrap.animate(endPos, {
duration : effect === 'none' ? 0 : previous.prevSpeed,
easing : previous.prevEasing,
complete : function () {
$(this).trigger('onReset').remove();
}
});
}
};
/*
* Overlay helper
*/
F.helpers.overlay = {
defaults : {
closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
speedOut : 200, // duration of fadeOut animation
showEarly : true, // indicates if should be opened immediately or wait until the content is ready
css : {}, // custom CSS properties
locked : !isTouch, // if true, the content will be locked into overlay
fixed : true // if false, the overlay CSS position property will not be set to "fixed"
},
overlay : null, // current handle
fixed : false, // indicates if the overlay has position "fixed"
el : $('html'), // element that contains "the lock"
// Public methods
create : function(opts) {
opts = $.extend({}, this.defaults, opts);
if (this.overlay) {
this.close();
}
this.overlay = $('
').appendTo( F.coming ? F.coming.parent : opts.parent );
this.fixed = false;
if (opts.fixed && F.defaults.fixed) {
this.overlay.addClass('fancybox-overlay-fixed');
this.fixed = true;
}
},
open : function(opts) {
var that = this;
opts = $.extend({}, this.defaults, opts);
if (this.overlay) {
this.overlay.unbind('.overlay').width('auto').height('auto');
} else {
this.create(opts);
}
if (!this.fixed) {
W.bind('resize.overlay', $.proxy( this.update, this) );
this.update();
}
if (opts.closeClick) {
this.overlay.bind('click.overlay', function(e) {
if ($(e.target).hasClass('fancybox-overlay')) {
if (F.isActive) {
F.close();
} else {
that.close();
}
return false;
}
});
}
this.overlay.css( opts.css ).show();
},
close : function() {
var scrollV, scrollH;
W.unbind('resize.overlay');
if (this.el.hasClass('fancybox-lock')) {
$('.fancybox-margin').removeClass('fancybox-margin');
scrollV = W.scrollTop();
scrollH = W.scrollLeft();
this.el.removeClass('fancybox-lock');
W.scrollTop( scrollV ).scrollLeft( scrollH );
}
$('.fancybox-overlay').remove().hide();
$.extend(this, {
overlay : null,
fixed : false
});
},
// Private, callbacks
update : function () {
var width = '100%', offsetWidth;
// Reset width/height so it will not mess
this.overlay.width(width).height('100%');
// jQuery does not return reliable result for IE
if (IE) {
offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
if (D.width() > offsetWidth) {
width = D.width();
}
} else if (D.width() > W.width()) {
width = D.width();
}
this.overlay.width(width).height(D.height());
},
// This is where we can manipulate DOM, because later it would cause iframes to reload
onReady : function (opts, obj) {
var overlay = this.overlay;
$('.fancybox-overlay').stop(true, true);
if (!overlay) {
this.create(opts);
}
if (opts.locked && this.fixed && obj.fixed) {
if (!overlay) {
this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
}
obj.locked = this.overlay.append( obj.wrap );
obj.fixed = false;
}
if (opts.showEarly === true) {
this.beforeShow.apply(this, arguments);
}
},
beforeShow : function(opts, obj) {
var scrollV, scrollH;
if (obj.locked) {
if (this.margin !== false) {
$('*').filter(function(){
return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
}).addClass('fancybox-margin');
this.el.addClass('fancybox-margin');
}
scrollV = W.scrollTop();
scrollH = W.scrollLeft();
this.el.addClass('fancybox-lock');
W.scrollTop( scrollV ).scrollLeft( scrollH );
}
this.open(opts);
},
onUpdate : function() {
if (!this.fixed) {
this.update();
}
},
afterClose: function (opts) {
// Remove overlay if exists and fancyBox is not opening
// (e.g., it is not being open using afterClose callback)
//if (this.overlay && !F.isActive) {
if (this.overlay && !F.coming) {
this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
}
}
};
/*
* Title helper
*/
F.helpers.title = {
defaults : {
type : 'float', // 'float', 'inside', 'outside' or 'over',
position : 'bottom' // 'top' or 'bottom'
},
beforeShow: function (opts) {
var current = F.current,
text = current.title,
type = opts.type,
title,
target;
if ($.isFunction(text)) {
text = text.call(current.element, current);
}
if (!isString(text) || $.trim(text) === '') {
return;
}
title = $('
' + text + '
');
switch (type) {
case 'inside':
target = F.skin;
break;
case 'outside':
target = F.wrap;
break;
case 'over':
target = F.inner;
break;
default: // 'float'
target = F.skin;
title.appendTo('body');
if (IE) {
title.width( title.width() );
}
title.wrapInner('
');
//Increase bottom margin so this title will also fit into viewport
F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
break;
}
title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
}
};
// jQuery plugin initialization
$.fn.fancybox = function (options) {
var index,
that = $(this),
selector = this.selector || '',
run = function(e) {
var what = $(this).blur(), idx = index, relType, relVal;
if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
relType = options.groupAttr || 'data-fancybox-group';
relVal = what.attr(relType);
if (!relVal) {
relType = 'rel';
relVal = what.get(0)[ relType ];
}
if (relVal && relVal !== '' && relVal !== 'nofollow') {
what = selector.length ? $(selector) : that;
what = what.filter('[' + relType + '="' + relVal + '"]');
idx = what.index(this);
}
options.index = idx;
// Stop an event from bubbling if everything is fine
if (F.open(what, options) !== false) {
e.preventDefault();
}
}
};
options = options || {};
index = options.index || 0;
if (!selector || options.live === false) {
that.unbind('click.fb-start').bind('click.fb-start', run);
} else {
D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
}
this.filter('[data-fancybox-start=1]').trigger('click');
return this;
};
// Tests that need a body at doc ready
D.ready(function() {
var w1, w2;
if ( $.scrollbarWidth === undefined ) {
// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
$.scrollbarWidth = function() {
var parent = $('
').appendTo('body'),
child = parent.children(),
width = child.innerWidth() - child.height( 99 ).innerWidth();
parent.remove();
return width;
};
}
if ( $.support.fixedPosition === undefined ) {
$.support.fixedPosition = (function() {
var elem = $('
').appendTo('body'),
fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
elem.remove();
return fixed;
}());
}
$.extend(F.defaults, {
scrollbarWidth : $.scrollbarWidth(),
fixed : $.support.fixedPosition,
parent : $('body')
});
//Get real width of page scroll-bar
w1 = $(window).width();
H.addClass('fancybox-lock-test');
w2 = $(window).width();
H.removeClass('fancybox-lock-test');
$("").appendTo("head");
});
}(window, document, jQuery));
/*! jQuery multiSelect - v0.0.1 - 2014-08-04
* Copyright (c) 2014 ecx.io */
(function($) {
$.fn.multiSelect = function(options) {
// default option
var defaults = {
'letterCountMax' : 30, // max letter in box before cutting off
'callback': function() {}
};
options = $.extend(defaults, options);
this.each(function() {
// get element text
var _this = $(this);
_this.hide();
//Visible Text
var text = '';
var textOut = '';
var listItem = '';
for(var i=0;i<_this.find('option').length;i++){
text = _this.find('option').eq(i).text();
value = _this.find('option').eq(i).val();
if(_this.find('option').eq(i).attr('selected') == 'selected'){
textOut += text;
if(i<(_this.find('option:checked').length-1)){
textOut += ' | ';
}
listItem += '
'+
''+
''+
''+
'
'+
'';
}else{
listItem += '
'+
''+
''+
''+
'
'+
'';
}
}
if(textOut.length > options.letterCountMax){
textOut = textOut.substring(0,options.letterCountMax)+'...';
}else{
textOut = textOut;
}
var output = '
'+
'
'+textOut+'
'+
'
'+
'
';
output += listItem;
output += '
'+
'
'+
'
';
_this.after(output);
_this.next().find('input[type="checkbox"]')
.each(function(){
if($(this).parent().find('div.checkbox, div.radio').html() == undefined){
var $active = "";
if( $(this).attr("checked")=="checked" ){
$active = " checked";
}
$(this)
.hide()
.after("
");
}
});
_this.next().find('.check .checkbox, .check label').unbind('click');
_this.next().find('.check .checkbox, .check label').bind('click', function(){
_this = $(this).parent();
_this.find('.checkbox').toggleClass("checked");
if(_this.find('.checkbox').hasClass('checked')){
if(_this.parent().find('input[type="checkbox"]').val() == 'all'){
_this.parents('.newList').find('input[type="checkbox"]:not(input[type="checkbox"]:first)').removeAttr('checked');
_this.parents('.newList').find('.checkbox:not(.checkbox:first)').removeClass('checked');
}else{
_this.parents('.newList').find('input[type="checkbox"]:first').removeAttr('checked');
_this.parents('.newList').find('.checkbox:first').removeClass('checked');
}
_this.parent().find('input[type="checkbox"]').attr('checked', 'checked');
}else{
_this.parent().find('input[type="checkbox"]').removeAttr('checked');
}
_thisSelect = $(this).parents('.newList').find('.checkbox.checked');
if(_thisSelect.size() == 0){
$(this).parents('.newList').find('.checkbox:first').trigger('click');
}
text = '';
value = '';
_thisSelect.parents('.newListSelected').prev().find('option').removeAttr('selected');
for(var i=0;i<_thisSelect.size();i++){
text += _thisSelect.parents('.newListSelected').prev().find('option[value="'+_thisSelect.eq(i).prev().val()+'"]').text();
_thisSelect.parents('.newListSelected').prev().find('option[value="'+_thisSelect.eq(i).prev().val()+'"]').attr('selected', 'selected');
if(i<(_thisSelect.size()-1)){
text += ' | ';
}
}
if(text.length > options.letterCountMax){
textOut = text.substring(0,options.letterCountMax)+'...';
}else{
textOut = text;
}
_thisSelect.parents('.newListSelected').find('.selectedTxt').text(textOut);
});
_this.next().find('.selectedTxt').click(function(){
$(this).next().toggle();
});
_this.next().find('.SSContainerDivWrapper').mouseleave(function(){
$(this).hide();
});
_this.next().find('.SSContainerDivWrapper').hide();
options.callback.call(this);
});
return this;
};
}) (jQuery);
/*!
* imagesLoaded PACKAGED v3.0.4
* JavaScript is all like "You images are done yet or what?"
*/
/*!
* EventEmitter v4.2.0 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/
(function () {
// Place the script in strict mode
'use strict';
/**
* Class for managing events.
* Can be extended to provide event functionality in other classes.
*
* @class EventEmitter Manages event registering and emitting.
*/
function EventEmitter() {}
// Shortcuts to improve speed and size
// Easy access to the prototype
var proto = EventEmitter.prototype;
/**
* Finds the index of the listener for the event in it's storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
* @return {Number} Index of the specified listener, -1 if not found
* @api private
*/
function indexOfListener(listeners, listener) {
var i = listeners.length;
while (i--) {
if (listeners[i].listener === listener) {
return i;
}
}
return -1;
}
/**
* Returns the listener array for the specified event.
* Will initialise the event object and listener arrays if required.
* Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
* Each property in the object response is an array of listener functions.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Function[]|Object} All listener functions for the event.
*/
proto.getListeners = function getListeners(evt) {
var events = this._getEvents();
var response;
var key;
// Return a concatenated array of all matching events if
// the selector is a regular expression.
if (typeof evt === 'object') {
response = {};
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
response[key] = events[key];
}
}
}
else {
response = events[evt] || (events[evt] = []);
}
return response;
};
/**
* Takes a list of listener objects and flattens it into a list of listener functions.
*
* @param {Object[]} listeners Raw listener objects.
* @return {Function[]} Just the listener functions.
*/
proto.flattenListeners = function flattenListeners(listeners) {
var flatListeners = [];
var i;
for (i = 0; i < listeners.length; i += 1) {
flatListeners.push(listeners[i].listener);
}
return flatListeners;
};
/**
* Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
*
* @param {String|RegExp} evt Name of the event to return the listeners from.
* @return {Object} All listener functions for an event in an object.
*/
proto.getListenersAsObject = function getListenersAsObject(evt) {
var listeners = this.getListeners(evt);
var response;
if (listeners instanceof Array) {
response = {};
response[evt] = listeners;
}
return response || listeners;
};
/**
* Adds a listener function to the specified event.
* The listener will not be added if it is a duplicate.
* If the listener returns true then it will be removed after it is called.
* If you pass a regular expression as the event name then the listener will be added to all events that match it.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListener = function addListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var listenerIsWrapped = typeof listener === 'object';
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
listeners[key].push(listenerIsWrapped ? listener : {
listener: listener,
once: false
});
}
}
return this;
};
/**
* Alias of addListener
*/
proto.on = proto.addListener;
/**
* Semi-alias of addListener. It will add a listener that will be
* automatically removed after it's first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addOnceListener = function addOnceListener(evt, listener) {
return this.addListener(evt, {
listener: listener,
once: true
});
};
/**
* Alias of addOnceListener.
*/
proto.once = proto.addOnceListener;
/**
* Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
* You need to tell it what event names should be matched by a regex.
*
* @param {String} evt Name of the event to create.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvent = function defineEvent(evt) {
this.getListeners(evt);
return this;
};
/**
* Uses defineEvent to define multiple events.
*
* @param {String[]} evts An array of event names to define.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.defineEvents = function defineEvents(evts) {
for (var i = 0; i < evts.length; i += 1) {
this.defineEvent(evts[i]);
}
return this;
};
/**
* Removes a listener function from the specified event.
* When passed a regular expression as the event name, it will remove the listener from all events that match it.
*
* @param {String|RegExp} evt Name of the event to remove the listener from.
* @param {Function} listener Method to remove from the event.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListener = function removeListener(evt, listener) {
var listeners = this.getListenersAsObject(evt);
var index;
var key;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
index = indexOfListener(listeners[key], listener);
if (index !== -1) {
listeners[key].splice(index, 1);
}
}
}
return this;
};
/**
* Alias of removeListener
*/
proto.off = proto.removeListener;
/**
* Adds listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
* You can also pass it a regular expression to add the array of listeners to all events that match it.
* Yeah, this function does quite a bit. That's probably a bad thing.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.addListeners = function addListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(false, evt, listeners);
};
/**
* Removes listeners in bulk using the manipulateListeners method.
* If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be removed.
* You can also pass it a regular expression to remove the listeners from all events that match it.
*
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeListeners = function removeListeners(evt, listeners) {
// Pass through to manipulateListeners
return this.manipulateListeners(true, evt, listeners);
};
/**
* Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
* The first argument will determine if the listeners are removed (true) or added (false).
* If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
* You can also pass it an event name and an array of listeners to be added/removed.
* You can also pass it a regular expression to manipulate the listeners of all events that match it.
*
* @param {Boolean} remove True if you want to remove listeners, false if you want to add.
* @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
* @param {Function[]} [listeners] An optional array of listener functions to add/remove.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
var i;
var value;
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
// If evt is an object then pass each of it's properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
// Pass the single listener straight through to the singular method
if (typeof value === 'function') {
single.call(this, i, value);
}
else {
// Otherwise pass back to the multiple function
multiple.call(this, i, value);
}
}
}
}
else {
// So evt must be a string
// And listeners must be an array of listeners
// Loop over it and pass each one to the multiple method
i = listeners.length;
while (i--) {
single.call(this, evt, listeners[i]);
}
}
return this;
};
/**
* Removes all listeners from a specified event.
* If you do not specify an event then all listeners will be removed.
* That means every event will be emptied.
* You can also pass a regex to remove all events that match it.
*
* @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.removeEvent = function removeEvent(evt) {
var type = typeof evt;
var events = this._getEvents();
var key;
// Remove different things depending on the state of evt
if (type === 'string') {
// Remove all listeners for the specified event
delete events[evt];
}
else if (type === 'object') {
// Remove all events matching the regex.
for (key in events) {
if (events.hasOwnProperty(key) && evt.test(key)) {
delete events[key];
}
}
}
else {
// Remove all listeners in all events
delete this._events;
}
return this;
};
/**
* Emits an event of your choice.
* When emitted, every listener attached to that event will be executed.
* If you pass the optional argument array then those arguments will be passed to every listener upon execution.
* Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
* So they will not arrive within the array on the other side, they will be separate.
* You can also pass a regular expression to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {Array} [args] Optional array of arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emitEvent = function emitEvent(evt, args) {
var listeners = this.getListenersAsObject(evt);
var listener;
var i;
var key;
var response;
for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
i = listeners[key].length;
while (i--) {
// If the listener returns true then it shall be removed from the event
// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[key][i];
response = listener.listener.apply(this, args || []);
if (response === this._getOnceReturnValue() || listener.once === true) {
this.removeListener(evt, listeners[key][i].listener);
}
}
}
}
return this;
};
/**
* Alias of emitEvent
*/
proto.trigger = proto.emitEvent;
/**
* Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
* As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
*
* @param {String|RegExp} evt Name of the event to emit and execute listeners for.
* @param {...*} Optional additional arguments to be passed to each listener.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.emit = function emit(evt) {
var args = Array.prototype.slice.call(arguments, 1);
return this.emitEvent(evt, args);
};
/**
* Sets the current value to check against when executing listeners. If a
* listeners return value matches the one set here then it will be removed
* after execution. This value defaults to true.
*
* @param {*} value The new value to check for when executing listeners.
* @return {Object} Current instance of EventEmitter for chaining.
*/
proto.setOnceReturnValue = function setOnceReturnValue(value) {
this._onceReturnValue = value;
return this;
};
/**
* Fetches the current value to check against when executing listeners. If
* the listeners return value matches this one then it should be removed
* automatically. It will return true by default.
*
* @return {*|Boolean} The current value to check for or the default, true.
* @api private
*/
proto._getOnceReturnValue = function _getOnceReturnValue() {
if (this.hasOwnProperty('_onceReturnValue')) {
return this._onceReturnValue;
}
else {
return true;
}
};
/**
* Fetches the events object and creates one if required.
*
* @return {Object} The events storage object.
* @api private
*/
proto._getEvents = function _getEvents() {
return this._events || (this._events = {});
};
// Expose the class either via AMD, CommonJS or the global object
if (typeof define === 'function' && define.amd) {
define(function () {
return EventEmitter;
});
}
else if (typeof module !== 'undefined' && module.exports){
module.exports = EventEmitter;
}
else {
this.EventEmitter = EventEmitter;
}
}.call(this));
/*!
* eventie v1.0.3
* event binding helper
* eventie.bind( elem, 'click', myFn )
* eventie.unbind( elem, 'click', myFn )
*/
/*jshint browser: true, undef: true, unused: true */
/*global define: false */
( function( window ) {
'use strict';
var docElem = document.documentElement;
var bind = function() {};
if ( docElem.addEventListener ) {
bind = function( obj, type, fn ) {
obj.addEventListener( type, fn, false );
};
} else if ( docElem.attachEvent ) {
bind = function( obj, type, fn ) {
obj[ type + fn ] = fn.handleEvent ?
function() {
var event = window.event;
// add event.target
event.target = event.target || event.srcElement;
fn.handleEvent.call( fn, event );
} :
function() {
var event = window.event;
// add event.target
event.target = event.target || event.srcElement;
fn.call( obj, event );
};
obj.attachEvent( "on" + type, obj[ type + fn ] );
};
}
var unbind = function() {};
if ( docElem.removeEventListener ) {
unbind = function( obj, type, fn ) {
obj.removeEventListener( type, fn, false );
};
} else if ( docElem.detachEvent ) {
unbind = function( obj, type, fn ) {
obj.detachEvent( "on" + type, obj[ type + fn ] );
try {
delete obj[ type + fn ];
} catch ( err ) {
// can't delete window object properties
obj[ type + fn ] = undefined;
}
};
}
var eventie = {
bind: bind,
unbind: unbind
};
// transport
if ( typeof define === 'function' && define.amd ) {
// AMD
define( eventie );
} else {
// browser global
window.eventie = eventie;
}
})( this );
/*!
* imagesLoaded v3.0.4
* JavaScript is all like "You images are done yet or what?"
*/
( function( window ) {
'use strict';
var $ = window.jQuery;
var console = window.console;
var hasConsole = typeof console !== 'undefined';
// -------------------------- helpers -------------------------- //
// extend objects
function extend( a, b ) {
for ( var prop in b ) {
a[ prop ] = b[ prop ];
}
return a;
}
var objToString = Object.prototype.toString;
function isArray( obj ) {
return objToString.call( obj ) === '[object Array]';
}
// turn element or nodeList into an array
function makeArray( obj ) {
var ary = [];
if ( isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( typeof obj.length === 'number' ) {
// convert nodeList to array
for ( var i=0, len = obj.length; i < len; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
}
return ary;
}
// -------------------------- -------------------------- //
function defineImagesLoaded( EventEmitter, eventie ) {
/**
* @param {Array, Element, NodeList, String} elem
* @param {Object or Function} options - if function, use as callback
* @param {Function} onAlways - callback function
*/
function ImagesLoaded( elem, options, onAlways ) {
// coerce ImagesLoaded() without new, to be new ImagesLoaded()
if ( !( this instanceof ImagesLoaded ) ) {
return new ImagesLoaded( elem, options );
}
// use elem as selector string
if ( typeof elem === 'string' ) {
elem = document.querySelectorAll( elem );
}
this.elements = makeArray( elem );
this.options = extend( {}, this.options );
if ( typeof options === 'function' ) {
onAlways = options;
} else {
extend( this.options, options );
}
if ( onAlways ) {
this.on( 'always', onAlways );
}
this.getImages();
if ( $ ) {
// add jQuery Deferred object
this.jqDeferred = new $.Deferred();
}
// HACK check async to allow time to bind listeners
var _this = this;
setTimeout( function() {
_this.check();
});
}
ImagesLoaded.prototype = new EventEmitter();
ImagesLoaded.prototype.options = {};
ImagesLoaded.prototype.getImages = function() {
this.images = [];
// filter & find items if we have an item selector
for ( var i=0, len = this.elements.length; i < len; i++ ) {
var elem = this.elements[i];
// filter siblings
if ( elem.nodeName === 'IMG' ) {
this.addImage( elem );
}
// find children
var childElems = elem.querySelectorAll('img');
// concat childElems to filterFound array
for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
var img = childElems[j];
this.addImage( img );
}
}
};
/**
* @param {Image} img
*/
ImagesLoaded.prototype.addImage = function( img ) {
var loadingImage = new LoadingImage( img );
this.images.push( loadingImage );
};
ImagesLoaded.prototype.check = function() {
var _this = this;
var checkedCount = 0;
var length = this.images.length;
this.hasAnyBroken = false;
// complete if no images
if ( !length ) {
this.complete();
return;
}
function onConfirm( image, message ) {
if ( _this.options.debug && hasConsole ) {
console.log( 'confirm', image, message );
}
_this.progress( image );
checkedCount++;
if ( checkedCount === length ) {
_this.complete();
}
return true; // bind once
}
for ( var i=0; i < length; i++ ) {
var loadingImage = this.images[i];
loadingImage.on( 'confirm', onConfirm );
loadingImage.check();
}
};
ImagesLoaded.prototype.progress = function( image ) {
this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
// HACK - Chrome triggers event before object properties have changed. #83
var _this = this;
setTimeout( function() {
_this.emit( 'progress', _this, image );
if ( _this.jqDeferred ) {
_this.jqDeferred.notify( _this, image );
}
});
};
ImagesLoaded.prototype.complete = function() {
var eventName = this.hasAnyBroken ? 'fail' : 'done';
this.isComplete = true;
var _this = this;
// HACK - another setTimeout so that confirm happens after progress
setTimeout( function() {
_this.emit( eventName, _this );
_this.emit( 'always', _this );
if ( _this.jqDeferred ) {
var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve';
_this.jqDeferred[ jqMethod ]( _this );
}
});
};
// -------------------------- jquery -------------------------- //
if ( $ ) {
$.fn.imagesLoaded = function( options, callback ) {
var instance = new ImagesLoaded( this, options, callback );
return instance.jqDeferred.promise( $(this) );
};
}
// -------------------------- -------------------------- //
var cache = {};
function LoadingImage( img ) {
this.img = img;
}
LoadingImage.prototype = new EventEmitter();
LoadingImage.prototype.check = function() {
// first check cached any previous images that have same src
var cached = cache[ this.img.src ];
if ( cached ) {
this.useCached( cached );
return;
}
// add this to cache
cache[ this.img.src ] = this;
// If complete is true and browser supports natural sizes,
// try to check for image status manually.
if ( this.img.complete && this.img.naturalWidth !== undefined ) {
// report based on naturalWidth
this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
return;
}
// If none of the checks above matched, simulate loading on detached element.
var proxyImage = this.proxyImage = new Image();
eventie.bind( proxyImage, 'load', this );
eventie.bind( proxyImage, 'error', this );
proxyImage.src = this.img.src;
};
LoadingImage.prototype.useCached = function( cached ) {
if ( cached.isConfirmed ) {
this.confirm( cached.isLoaded, 'cached was confirmed' );
} else {
var _this = this;
cached.on( 'confirm', function( image ) {
_this.confirm( image.isLoaded, 'cache emitted confirmed' );
return true; // bind once
});
}
};
LoadingImage.prototype.confirm = function( isLoaded, message ) {
this.isConfirmed = true;
this.isLoaded = isLoaded;
this.emit( 'confirm', this, message );
};
// trigger specified handler for event type
LoadingImage.prototype.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
LoadingImage.prototype.onload = function() {
this.confirm( true, 'onload' );
this.unbindProxyEvents();
};
LoadingImage.prototype.onerror = function() {
this.confirm( false, 'onerror' );
this.unbindProxyEvents();
};
LoadingImage.prototype.unbindProxyEvents = function() {
eventie.unbind( this.proxyImage, 'load', this );
eventie.unbind( this.proxyImage, 'error', this );
};
// ----- ----- //
return ImagesLoaded;
}
// -------------------------- transport -------------------------- //
if ( typeof define === 'function' && define.amd ) {
// AMD
define( [
'eventEmitter/EventEmitter',
'eventie/eventie'
],
defineImagesLoaded );
} else {
// browser global
window.imagesLoaded = defineImagesLoaded(
window.EventEmitter,
window.eventie
);
}
})( window );
// jquery.event.move
//
// 1.3.1
//
// Stephen Band
//
// Triggers 'movestart', 'move' and 'moveend' events after
// mousemoves following a mousedown cross a distance threshold,
// similar to the native 'dragstart', 'drag' and 'dragend' events.
// Move events are throttled to animation frames. Move event objects
// have the properties:
//
// pageX:
// pageY: Page coordinates of pointer.
// startX:
// startY: Page coordinates of pointer at movestart.
// distX:
// distY: Distance the pointer has moved since movestart.
// deltaX:
// deltaY: Distance the finger has moved since last event.
// velocityX:
// velocityY: Average velocity over last few events.
(function (module) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], module);
} else {
// Browser globals
module(jQuery);
}
})(function(jQuery, undefined){
var // Number of pixels a pressed pointer travels before movestart
// event is fired.
threshold = 6,
add = jQuery.event.add,
remove = jQuery.event.remove,
// Just sugar, so we can have arguments in the same order as
// add and remove.
trigger = function(node, type, data) {
jQuery.event.trigger(type, data, node);
},
// Shim for requestAnimationFrame, falling back to timer. See:
// see http://paulirish.com/2011/requestanimationframe-for-smart-animating/
requestFrame = (function(){
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(fn, element){
return window.setTimeout(function(){
fn();
}, 25);
}
);
})(),
ignoreTags = {
textarea: true,
input: true,
select: true,
button: true
},
mouseevents = {
move: 'mousemove',
cancel: 'mouseup dragstart',
end: 'mouseup'
},
touchevents = {
move: 'touchmove',
cancel: 'touchend',
end: 'touchend'
};
// Constructors
function Timer(fn){
var callback = fn,
active = false,
running = false;
function trigger(time) {
if (active){
callback();
requestFrame(trigger);
running = true;
active = false;
}
else {
running = false;
}
}
this.kick = function(fn) {
active = true;
if (!running) { trigger(); }
};
this.end = function(fn) {
var cb = callback;
if (!fn) { return; }
// If the timer is not running, simply call the end callback.
if (!running) {
fn();
}
// If the timer is running, and has been kicked lately, then
// queue up the current callback and the end callback, otherwise
// just the end callback.
else {
callback = active ?
function(){ cb(); fn(); } :
fn ;
active = true;
}
};
}
// Functions
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
function preventDefault(e) {
e.preventDefault();
}
function preventIgnoreTags(e) {
// Don't prevent interaction with form elements.
if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; }
e.preventDefault();
}
function isLeftButton(e) {
// Ignore mousedowns on any button other than the left (or primary)
// mouse button, or when a modifier key is pressed.
return (e.which === 1 && !e.ctrlKey && !e.altKey);
}
function identifiedTouch(touchList, id) {
var i, l;
if (touchList.identifiedTouch) {
return touchList.identifiedTouch(id);
}
// touchList.identifiedTouch() does not exist in
// webkit yet… we must do the search ourselves...
i = -1;
l = touchList.length;
while (++i < l) {
if (touchList[i].identifier === id) {
return touchList[i];
}
}
}
function changedTouch(e, event) {
var touch = identifiedTouch(e.changedTouches, event.identifier);
// This isn't the touch you're looking for.
if (!touch) { return; }
// Chrome Android (at least) includes touches that have not
// changed in e.changedTouches. That's a bit annoying. Check
// that this touch has changed.
if (touch.pageX === event.pageX && touch.pageY === event.pageY) { return; }
return touch;
}
// Handlers that decide when the first movestart is triggered
function mousedown(e){
var data;
if (!isLeftButton(e)) { return; }
data = {
target: e.target,
startX: e.pageX,
startY: e.pageY,
timeStamp: e.timeStamp
};
add(document, mouseevents.move, mousemove, data);
add(document, mouseevents.cancel, mouseend, data);
}
function mousemove(e){
var data = e.data;
checkThreshold(e, data, e, removeMouse);
}
function mouseend(e) {
removeMouse();
}
function removeMouse() {
remove(document, mouseevents.move, mousemove);
remove(document, mouseevents.cancel, mouseend);
}
function touchstart(e) {
var touch, template;
// Don't get in the way of interaction with form elements.
if (ignoreTags[ e.target.tagName.toLowerCase() ]) { return; }
touch = e.changedTouches[0];
// iOS live updates the touch objects whereas Android gives us copies.
// That means we can't trust the touchstart object to stay the same,
// so we must copy the data. This object acts as a template for
// movestart, move and moveend event objects.
template = {
target: touch.target,
startX: touch.pageX,
startY: touch.pageY,
timeStamp: e.timeStamp,
identifier: touch.identifier
};
// Use the touch identifier as a namespace, so that we can later
// remove handlers pertaining only to this touch.
add(document, touchevents.move + '.' + touch.identifier, touchmove, template);
add(document, touchevents.cancel + '.' + touch.identifier, touchend, template);
}
function touchmove(e){
var data = e.data,
touch = changedTouch(e, data);
if (!touch) { return; }
checkThreshold(e, data, touch, removeTouch);
}
function touchend(e) {
var template = e.data,
touch = identifiedTouch(e.changedTouches, template.identifier);
if (!touch) { return; }
removeTouch(template.identifier);
}
function removeTouch(identifier) {
remove(document, '.' + identifier, touchmove);
remove(document, '.' + identifier, touchend);
}
// Logic for deciding when to trigger a movestart.
function checkThreshold(e, template, touch, fn) {
var distX = touch.pageX - template.startX,
distY = touch.pageY - template.startY;
// Do nothing if the threshold has not been crossed.
if ((distX * distX) + (distY * distY) < (threshold * threshold)) { return; }
triggerStart(e, template, touch, distX, distY, fn);
}
function handled() {
// this._handled should return false once, and after return true.
this._handled = returnTrue;
return false;
}
function flagAsHandled(e) {
e._handled();
}
function triggerStart(e, template, touch, distX, distY, fn) {
var node = template.target,
touches, time;
touches = e.targetTouches;
time = e.timeStamp - template.timeStamp;
// Create a movestart object with some special properties that
// are passed only to the movestart handlers.
template.type = 'movestart';
template.distX = distX;
template.distY = distY;
template.deltaX = distX;
template.deltaY = distY;
template.pageX = touch.pageX;
template.pageY = touch.pageY;
template.velocityX = distX / time;
template.velocityY = distY / time;
template.targetTouches = touches;
template.finger = touches ?
touches.length :
1 ;
// The _handled method is fired to tell the default movestart
// handler that one of the move events is bound.
template._handled = handled;
// Pass the touchmove event so it can be prevented if or when
// movestart is handled.
template._preventTouchmoveDefault = function() {
e.preventDefault();
};
// Trigger the movestart event.
trigger(template.target, template);
// Unbind handlers that tracked the touch or mouse up till now.
fn(template.identifier);
}
// Handlers that control what happens following a movestart
function activeMousemove(e) {
var event = e.data.event,
timer = e.data.timer;
updateEvent(event, e, e.timeStamp, timer);
}
function activeMouseend(e) {
var event = e.data.event,
timer = e.data.timer;
removeActiveMouse();
endEvent(event, timer, function() {
// Unbind the click suppressor, waiting until after mouseup
// has been handled.
setTimeout(function(){
remove(event.target, 'click', returnFalse);
}, 0);
});
}
function removeActiveMouse(event) {
remove(document, mouseevents.move, activeMousemove);
remove(document, mouseevents.end, activeMouseend);
}
function activeTouchmove(e) {
var event = e.data.event,
timer = e.data.timer,
touch = changedTouch(e, event);
if (!touch) { return; }
// Stop the interface from gesturing
e.preventDefault();
event.targetTouches = e.targetTouches;
updateEvent(event, touch, e.timeStamp, timer);
}
function activeTouchend(e) {
var event = e.data.event,
timer = e.data.timer,
touch = identifiedTouch(e.changedTouches, event.identifier);
// This isn't the touch you're looking for.
if (!touch) { return; }
removeActiveTouch(event);
endEvent(event, timer);
}
function removeActiveTouch(event) {
remove(document, '.' + event.identifier, activeTouchmove);
remove(document, '.' + event.identifier, activeTouchend);
}
// Logic for triggering move and moveend events
function updateEvent(event, touch, timeStamp, timer) {
var time = timeStamp - event.timeStamp;
event.type = 'move';
event.distX = touch.pageX - event.startX;
event.distY = touch.pageY - event.startY;
event.deltaX = touch.pageX - event.pageX;
event.deltaY = touch.pageY - event.pageY;
// Average the velocity of the last few events using a decay
// curve to even out spurious jumps in values.
event.velocityX = 0.3 * event.velocityX + 0.7 * event.deltaX / time;
event.velocityY = 0.3 * event.velocityY + 0.7 * event.deltaY / time;
event.pageX = touch.pageX;
event.pageY = touch.pageY;
timer.kick();
}
function endEvent(event, timer, fn) {
timer.end(function(){
event.type = 'moveend';
trigger(event.target, event);
return fn && fn();
});
}
// jQuery special event definition
function setup(data, namespaces, eventHandle) {
// Stop the node from being dragged
//add(this, 'dragstart.move drag.move', preventDefault);
// Prevent text selection and touch interface scrolling
//add(this, 'mousedown.move', preventIgnoreTags);
// Tell movestart default handler that we've handled this
add(this, 'movestart.move', flagAsHandled);
// Don't bind to the DOM. For speed.
return true;
}
function teardown(namespaces) {
remove(this, 'dragstart drag', preventDefault);
remove(this, 'mousedown touchstart', preventIgnoreTags);
remove(this, 'movestart', flagAsHandled);
// Don't bind to the DOM. For speed.
return true;
}
function addMethod(handleObj) {
// We're not interested in preventing defaults for handlers that
// come from internal move or moveend bindings
if (handleObj.namespace === "move" || handleObj.namespace === "moveend") {
return;
}
// Stop the node from being dragged
add(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid, preventDefault, undefined, handleObj.selector);
// Prevent text selection and touch interface scrolling
add(this, 'mousedown.' + handleObj.guid, preventIgnoreTags, undefined, handleObj.selector);
}
function removeMethod(handleObj) {
if (handleObj.namespace === "move" || handleObj.namespace === "moveend") {
return;
}
remove(this, 'dragstart.' + handleObj.guid + ' drag.' + handleObj.guid);
remove(this, 'mousedown.' + handleObj.guid);
}
jQuery.event.special.movestart = {
setup: setup,
teardown: teardown,
add: addMethod,
remove: removeMethod,
_default: function(e) {
var template, data;
// If no move events were bound to any ancestors of this
// target, high tail it out of here.
if (!e._handled()) { return; }
template = {
target: e.target,
startX: e.startX,
startY: e.startY,
pageX: e.pageX,
pageY: e.pageY,
distX: e.distX,
distY: e.distY,
deltaX: e.deltaX,
deltaY: e.deltaY,
velocityX: e.velocityX,
velocityY: e.velocityY,
timeStamp: e.timeStamp,
identifier: e.identifier,
targetTouches: e.targetTouches,
finger: e.finger
};
data = {
event: template,
timer: new Timer(function(time){
trigger(e.target, template);
})
};
if (e.identifier === undefined) {
// We're dealing with a mouse
// Stop clicks from propagating during a move
add(e.target, 'click', returnFalse);
add(document, mouseevents.move, activeMousemove, data);
add(document, mouseevents.end, activeMouseend, data);
}
else {
// We're dealing with a touch. Stop touchmove doing
// anything defaulty.
e._preventTouchmoveDefault();
add(document, touchevents.move + '.' + e.identifier, activeTouchmove, data);
add(document, touchevents.end + '.' + e.identifier, activeTouchend, data);
}
}
};
jQuery.event.special.move = {
setup: function() {
// Bind a noop to movestart. Why? It's the movestart
// setup that decides whether other move events are fired.
add(this, 'movestart.move', jQuery.noop);
},
teardown: function() {
remove(this, 'movestart.move', jQuery.noop);
}
};
jQuery.event.special.moveend = {
setup: function() {
// Bind a noop to movestart. Why? It's the movestart
// setup that decides whether other move events are fired.
add(this, 'movestart.moveend', jQuery.noop);
},
teardown: function() {
remove(this, 'movestart.moveend', jQuery.noop);
}
};
add(document, 'mousedown.move', mousedown);
add(document, 'touchstart.move', touchstart);
// Make jQuery copy touch event properties over to the jQuery event
// object, if they are not already listed. But only do the ones we
// really need. IE7/8 do not have Array#indexOf(), but nor do they
// have touch events, so let's assume we can ignore them.
if (typeof Array.prototype.indexOf === 'function') {
(function(jQuery, undefined){
var props = ["changedTouches", "targetTouches"],
l = props.length;
while (l--) {
if (jQuery.event.props.indexOf(props[l]) === -1) {
jQuery.event.props.push(props[l]);
}
}
})(jQuery);
};
});
// jQuery.event.swipe
// 0.5
// Stephen Band
// Dependencies
// jQuery.event.move 1.2
// One of swipeleft, swiperight, swipeup or swipedown is triggered on
// moveend, when the move has covered a threshold ratio of the dimension
// of the target node, or has gone really fast. Threshold and velocity
// sensitivity changed with:
//
// jQuery.event.special.swipe.settings.threshold
// jQuery.event.special.swipe.settings.sensitivity
(function (module) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], module);
} else {
// Browser globals
module(jQuery);
}
})(function(jQuery, undefined){
var add = jQuery.event.add,
remove = jQuery.event.remove,
// Just sugar, so we can have arguments in the same order as
// add and remove.
trigger = function(node, type, data) {
jQuery.event.trigger(type, data, node);
},
settings = {
// Ratio of distance over target finger must travel to be
// considered a swipe.
threshold: 0.4,
// Faster fingers can travel shorter distances to be considered
// swipes. 'sensitivity' controls how much. Bigger is shorter.
sensitivity: 6
};
function moveend(e) {
var w, h, event;
w = e.target.offsetWidth;
h = e.target.offsetHeight;
// Copy over some useful properties from the move event
event = {
distX: e.distX,
distY: e.distY,
velocityX: e.velocityX,
velocityY: e.velocityY,
finger: e.finger
};
// Find out which of the four directions was swiped
if (e.distX > e.distY) {
if (e.distX > -e.distY) {
if (e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) {
event.type = 'swiperight';
trigger(e.currentTarget, event);
}
}
else {
if (-e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) {
event.type = 'swipeup';
trigger(e.currentTarget, event);
}
}
}
else {
if (e.distX > -e.distY) {
if (e.distY/h > settings.threshold || e.velocityY * e.distY/w * settings.sensitivity > 1) {
event.type = 'swipedown';
trigger(e.currentTarget, event);
}
}
else {
if (-e.distX/w > settings.threshold || e.velocityX * e.distX/w * settings.sensitivity > 1) {
event.type = 'swipeleft';
trigger(e.currentTarget, event);
}
}
}
}
function getData(node) {
var data = jQuery.data(node, 'event_swipe');
if (!data) {
data = { count: 0 };
jQuery.data(node, 'event_swipe', data);
}
return data;
}
jQuery.event.special.swipe =
jQuery.event.special.swipeleft =
jQuery.event.special.swiperight =
jQuery.event.special.swipeup =
jQuery.event.special.swipedown = {
setup: function( data, namespaces, eventHandle ) {
var data = getData(this);
// If another swipe event is already setup, don't setup again.
if (data.count++ > 0) { return; }
add(this, 'moveend', moveend);
return true;
},
teardown: function() {
var data = getData(this);
// If another swipe event is still setup, don't teardown.
if (--data.count > 0) { return; }
remove(this, 'moveend', moveend);
return true;
},
settings: settings
};
});
/*!
* jQuery Migrate - v1.2.1 - 2013-05-08
* https://github.com/jquery/jquery-migrate
* Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT
*/
(function( jQuery, window, undefined ) {
// See http://bugs.jquery.com/ticket/13335
// "use strict";
var warnedAbout = {};
// List of warnings already given; public read only
jQuery.migrateWarnings = [];
// Set to true to prevent console output; migrateWarnings still maintained
// jQuery.migrateMute = false;
// Show a message on the console so devs know we're active
if ( !jQuery.migrateMute && window.console && window.console.log ) {
window.console.log("JQMIGRATE: Logging is active");
}
// Set to false to disable traces that appear with warnings
if ( jQuery.migrateTrace === undefined ) {
jQuery.migrateTrace = true;
}
// Forget any warnings we've already given; public
jQuery.migrateReset = function() {
warnedAbout = {};
jQuery.migrateWarnings.length = 0;
};
function migrateWarn( msg) {
var console = window.console;
if ( !warnedAbout[ msg ] ) {
warnedAbout[ msg ] = true;
jQuery.migrateWarnings.push( msg );
if ( console && console.warn && !jQuery.migrateMute ) {
console.warn( "JQMIGRATE: " + msg );
if ( jQuery.migrateTrace && console.trace ) {
console.trace();
}
}
}
}
function migrateWarnProp( obj, prop, value, msg ) {
if ( Object.defineProperty ) {
// On ES5 browsers (non-oldIE), warn if the code tries to get prop;
// allow property to be overwritten in case some other plugin wants it
try {
Object.defineProperty( obj, prop, {
configurable: true,
enumerable: true,
get: function() {
migrateWarn( msg );
return value;
},
set: function( newValue ) {
migrateWarn( msg );
value = newValue;
}
});
return;
} catch( err ) {
// IE8 is a dope about Object.defineProperty, can't warn there
}
}
// Non-ES5 (or broken) browser; just set the property
jQuery._definePropertyBroken = true;
obj[ prop ] = value;
}
if ( document.compatMode === "BackCompat" ) {
// jQuery has never supported or tested Quirks Mode
migrateWarn( "jQuery is not compatible with Quirks Mode" );
}
var attrFn = jQuery( "
", { size: 1 } ).attr("size") && jQuery.attrFn,
oldAttr = jQuery.attr,
valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
function() { return null; },
valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
function() { return undefined; },
rnoType = /^(?:input|button)$/i,
rnoAttrNodeType = /^[238]$/,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
ruseDefault = /^(?:checked|selected)$/i;
// jQuery.attrFn
migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
jQuery.attr = function( elem, name, value, pass ) {
var lowerName = name.toLowerCase(),
nType = elem && elem.nodeType;
if ( pass ) {
// Since pass is used internally, we only warn for new jQuery
// versions where there isn't a pass arg in the formal params
if ( oldAttr.length < 4 ) {
migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
}
if ( elem && !rnoAttrNodeType.test( nType ) &&
(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
return jQuery( elem )[ name ]( value );
}
}
// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
// for disconnected elements we don't warn on $( "
';
// Append marker and info window to map
infoWindow[i] = new google.maps.InfoWindow({
content: windowContent[i]
});
// Add click event to markers (to open info window)
google.maps.event.addListener(marker[i], 'click', function(){
// Close all info window
for (var w=0;w a.center').html() != undefined){
$.each($('.button > a.center'), function(){
bw = $(this).width()/2;
bwWrapper = $(this).parent().width();
$(this).css('margin-left', '-'+bw+'px');
});
}
}
}
function addSortableResponsiveTable(){
if($("table.sortable").html() != undefined){
}
}
function addDynamicDownloadThumbLightbox(){
$('.dynamicDownload .zoom').click(function(e){
e.preventDefault();
hrefData = $(this).attr('href');
$.fancybox({
type: 'image',
height: 'auto',
closeBtn: false,
padding: 20,
autoSize: true,
autoResize: true,
maxWidth: 740,
maxHeight: 740,
minWidth: 240,
href: hrefData,
//fitToView: false,
afterShow: function(){
link = $(this).attr('href');
$('.fancybox-outer').before('');
if( $deviceSelector == "isDesktop" ){
//$('.fancybox-skin > div:last').after('Download');
}
$('.fancyClose').click(function(){
$.fancybox.close();
});
//addSwipeEvents();
},
helpers : {
title : {
type : 'inside'
}
}
});
});
}
function makeDynamicDownloadResponsive(){
if($('.dynamicDownload').html() != undefined){
if($deviceSelector == "isMobile"){
$('dynamicDownload table').addClass('responsiveTable');
updateByNewContent();
}
$('.dynamicDownload input[type="checkbox"].selectAll').unbind("change"); //important because of possible multiple initialization
$('.dynamicDownload input[type="checkbox"].selectAll').change(function(){
if($(this).is(':checked')){
$(this).parents('.dynamicDownload').find('table .checkbox:not(".checked")').trigger('click');
$(this).parent().find('label').text(selectNoneText);
}else{
$(this).parents('.dynamicDownload').find('.checkbox.checked').trigger('click');
$(this).parent().find('label').text(selectAllText);
}
});
}
}
function showVideoLightbox(){
if($deviceSelector != "isMobile"){
$('.videoPlay').each(function(){
$(this).fancybox({
type: 'inline',
//width: $($(this).attr('href')+' object').last().width(),
//height: $($(this).attr('href')+' object').last().height()-50,
autoSize: false,
autoResize: false,
closeBtn: false,
content: $(this).attr('id'),
beforeShow: function(){
$('.fancybox-skin').addClass('fancyVideo');
},
afterShow: function(){
$('.fancybox-outer').before('');
$('.fancyClose').click(function(){
$.fancybox.close();
});
if (typeof HTMLVideoElement == 'function') {
$(".fancybox-wrap video").get(0).play();
}
updateVideoHeight();
videoHeight = $('.fancybox-inner video').height();
setTimeout(function(){
$('.fancybox-inner').height(videoHeight);
$('.fancybox-skin').css('background', 'transparent');
newTop = ($(window).height()-videoHeight)/2;
$('.fancybox-wrap').css('top', newTop+'px');
}, 10);
//alert(videoHeight);
}
});
})
}else{
$('.videoPlay').click(function(){
videoID = $(this).attr('href');
videoHtml = $(videoID).html();
$(this).replaceWith(videoHtml);
});
}
}
function updateFeatureSliderDimensions(){
imagesLoaded($('.featureTeaserSlider .sliderWrapper img'), function(){
setTimeout(function(){
$.each($('.featureTeaserSlider .sliderWrapper'), function(){
itemHeight = 0;
$.each($(this).find('img.back'), function(){
if(itemHeight < $(this).height()){
itemHeight = $(this).height();
}
});
//itemHeight = $(this).find('img:first').height();
$(this).find('div.controls').addClass('showIt').height(itemHeight+4);
$(this).find('div.controls.next').html('9');
$(this).find('div.controls.prev').html('?');
});
$.each($('.featureTeaserSlider.slider'), function(){
itemHeight = 0;
$.each($(this).find('li'), function(){
if(itemHeight < $(this).height()){
itemHeight = $(this).height();
}
});
itemHeight += 2;
$(this).find('ul').height(itemHeight).parent().height(itemHeight);
});
}, 500);
});
}
function updateAlbumHeight(){
$.each($('.featureTeaserSlider .sliderWrapper li'), function(){
$(this).find('img:not(img.back)').show();
thisHeight = $(this).find('img:not(img.back)').height()/2;
thisWidth = $(this).find('img:not(img.back)').width()/2;
$(this).find('img:not(img.back)').css({
"margin-left": '-'+thisWidth+'px',
"margin-top": '-'+thisHeight+'px'
});
});
}
function addSwipeEvents(){
slides = $('.fancybox-inner');
slides
.on('swipeleft', function(e) {
$('.fancybox-prev').trigger('click');
})
.on('swiperight', function(e) {
$('.fancybox-next').trigger('click');
});
}
function featureTeaserSlider(){
if($('.imageGallery.album').html() != undefined){
h = 0;
imagesLoaded($('.imageGallery .sliderWrapper li img'), function(){
$('.featureTeaserSlider img').css('visibility', 'visible');
$('.featureTeaserSlider ul li').show();
updateAlbumHeight();
});
if(!$.browser.msie){
window.addEventListener("orientationchange", function() {
$('.imageGallery.album .sliderWrapper li').removeAttr('style');
setTimeout(function(){
//updateAlbumHeight();
}, 1000);
}, false);
}
}
if($('.featureTeaserSlider.slider, .featureTeaserSlider.album').html() != undefined){
showWrapper = '';
$('.featureTeaserSlider .sliderWrapper ul li img').mouseenter(function(){
$('.featureTeaserSlider .sliderWrapper ul li .wrapper').hide();
obj = $(this);
clearTimeout(showWrapper);
showWrapper = setTimeout(function(){
obj.parents('.over').find('.wrapper').show(50, function(){
var galleryID = $(this).parent().find('.zoom').attr('data-id');
$(this).parent().find('.zoom').fancybox({
type: 'image',
height: 'auto',
closeBtn: false,
padding: 20,
autoSize: true,
autoResize: true,
maxWidth: 740,
maxHeight: 740,
minWidth: 240,
//fitToView: false,
beforeShow: function(){
link = $(this).attr('href');
var imageGalleryPath = $(this.element).data('imagepath');
$('.fancybox-outer').before('');
if( $deviceSelector == "isDesktop" ){
$('.fancybox-skin > div:last').after(''+downloadButtonText+'');
}
$('.fancyClose').click(function(){
$.fancybox.close();
});
addSwipeEvents();
imgHeight = $('.fancybox-inner img').height();
$('.fancybox-outer > a').height(imgHeight);
},
helpers : {
title : {
type : 'inside'
}
}
});
});
}, 200);
obj.parent().mouseleave(function(){
obj.parent().find('.wrapper').hide();
});
obj.parents('.featureTeaserSlider').mouseleave(function(){
clearTimeout(showWrapper);
});
return false;
});
imagesLoaded( $('.featureTeaserSlider img') , function(){
$('.featureTeaserSlider img').css('visibility', 'visible');
$('.featureTeaserSlider ul li').show();
$('.featureTeaserSlider ul li:first').css('display', 'list-item');
$('.cqHorizontalTabItem').show();
$('.toggle_container').show();
updateAlbumHeight();
var featureTeaserSliderCount = $('.featureTeaserSlider.slider').size();
var featureTeaserSliderLoaded = 0;
$.each($('.featureTeaserSlider.slider .sliderWrapper > ul'), function(){
if($deviceSelector == "isMobile"){
itemCount = 1;
addThis = 0;
}else if($(this).parent().parent().hasClass('single')){
itemCount = 1;
addThis = 0;
}else{
itemCount = 3;
addThis = 8;
}
if($(this).parents('.featureTeaserSlider').hasClass('imageGallery')){
makeCircular = false;
makeInfinite = false;
}else{
makeCircular = true;
makeInfinite = true;
}
$(this).carouFredSel({
//height: 300,
items: itemCount,
responsive : true,
circular: makeCircular,
infinite: makeInfinite,
auto : {
play : false,
timeoutDuration : 1000
},
scroll : {
pauseOnHover : true,
fx : "slide",
items: itemCount
},
prev : {
button: function() {
return $(this).parent().siblings(".prev");
}
},
next : {
button: function() {
return $(this).parent().siblings(".next");
}
},
onCreate: function(data){
ie8StageHeightFix( $(this), data.height );
updateFeatureSliderDimensions();
itemHeight = 0;
$.each($(this).find('li'), function(){
if(itemHeight < $(this).height()){
itemHeight = $(this).height();
}
});
$(this).height(itemHeight).parent().height(itemHeight);
//updateimagePosition($(this));
updateAlbumHeight();
featureTeaserSliderLoaded++;
if(featureTeaserSliderLoaded == featureTeaserSliderCount){
setTimeout(function(){
$.each($('.tabs'), function(){
tabObj = $(this);
if(tabObj.find('.tabNav ul li.active').html() != undefined){
tabObj.find('.tabNav ul li.active a').trigger('click');
}else{
tabObj.find('.tabNav ul li:first a').trigger('click');
}
});
}, 1000);
}
}
});
});
});
}
}
function videoGallery(){
if($('.videoGallery').size() > 0){
$.each($('.videoGallery'), function(){
var obj = $(this);
setTimeout(function(){
obj.find('.videos > ul').carouFredSel({
responsive : true,
auto : {
play : false,
timeoutDuration : 1000
},
scroll : {
pauseOnHover : true,
fx : "crossfade"
},
items: {
start: 1
},
pagination : {
container: function(){
return $(this).parent().parent().find('.pagination ul');
},
anchorBuilder: function(nr, item){
return ''+nr+'';
},
onAfter: function(){
videoHeight = obj.find('.videos li:first span').height();
obj.find('.videos .pagination').css('top', (videoHeight+10)+'px');
}
},
onCreate: function(data){
ie8StageHeightFix( $(this), data.height );
videoHeight = obj.find('.videos li:first span').height();
obj.find('.videos .pagination').css('top', (videoHeight+10)+'px');
setTimeout(function(){
obj.find('.videos .pagination ul li:first a').trigger('click');
}, 800);
}
});
obj.find('> ul li a').click(function(){
goTo = parseFloat($(this).attr('href').replace(/#video_/, ''));
obj.find('.videos ul').trigger("slideTo", [goTo, true]);
/*setTimeout(function(){
videoHeight = obj.find('.videos li:first span').height();
obj.find('.videos .pagination ul li:first a').trigger('click');
}, 500);*/
return false;
});
}, 100);
});
}
}
function updateMaxLength(){
if($('textarea[maxlength]').val() != undefined){
$.each($('textarea[maxlength]'), function(){
maxlength = $(this).attr('maxlength');
newValue = maxlength.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
$(this).parent().find('.labelright > span').html(newValue);
$(this).unbind("keyup"); //important because of possible multiple initialization
$(this).keyup(function(){
maxlength = $(this).attr('maxlength');
textLength = $(this).val();
value = maxlength-textLength.length;
newValue = value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
$(this).parent().find('.labelright > span').html(newValue);
});
});
}
}
function updateCareerSelectWrapperHeight(){
/*if($('.selectWrapper').html() != undefined){
ident = 0;
height = 0;
$.each($('.selectWrapper'), function(){
h = $(this).height();
if(h > height){
height = h;
}
if(ident%2==1){
$('.selectWrapper:eq("'+ident+'")').height(height);
$('.selectWrapper:eq("'+(ident-1)+'")').height(height);
height = 0;
}
ident++;
});
$('.selectWrapper .wrapper').css('position', 'absolute');
}*/
}
function addLightbox(){
if($('.fancy').html() != undefined){
$('.fancy').click(function(){
//if( $deviceSelector == "isDesktop" ){
//$('body').append('');
//$('.fancyload').load($(this).attr('href')+' #BodyContent', function(){
//fancyContent = $('.fancyload').html();
fancyContent = $('.fancyload').html();
$.get($(this).attr('href'), function(data) {
$.fancybox({
type: 'inline',
content: $(data).find('#BodyContent').html(),
width: 755,
height: 'auto',
autoSize: false,
autoResize: false,
closeBtn: false,
afterShow: function(){
//$('.fancyload').remove();
updateByNewContent();
$('.fancybox-outer').before('');
$('.fancyClose').click(function(){
$.fancybox.close();
});
addThisCode = $('.social').html();
$('.social').html('');
$('.social').html(addThisCode);
}
});
});
//});
return false;
//}
});
}
}
function autoLoadDarksite(){
$('.fancy.auto').trigger('click');
}
function brandMenu(){
if($('.brand').html() != undefined){
$('body.brand .showHide').unbind("click"); //important because of possible multiple initialization
$('body.brand .showHide').click(function(){
if($('.brand header').hasClass('min')){
if ( $(".brandSelect").hasClass('active') ) { //atu #60771, #61219
$(".brandSelect a.active").trigger("click");
$('.brand header').css({
"background": "#F1F2F2",
"box-shadow": "0 2px 3px 0 #E0E0E0",
"padding" : "12px 0 5px"
});
}
$('.brand header').removeClass('min');
$('.brand header').css({
"background": "#F1F2F2",
"box-shadow": "0 2px 3px 0 #E0E0E0",
"padding" : "12px 0 5px"
});
}else{
$('.brand header').css({
"background": "#F1F2F2",
"box-shadow": "0 2px 3px 0 #E0E0E0",
"padding" : "12px 0 5px"
});
$('.brand header').addClass('min');
}
});
}
}
function sitemapHeight(){
liHeight = 0;
ident = 0;
liItems = new Array();
arrayItemCount = 0;
$.each($('footer .sitemapWrapper > ul > li'), function(){
if($(this).height() > liHeight){
liHeight = $(this).height();
}
ident++;
liItems[arrayItemCount] = new Array();
liItems[arrayItemCount]['ident'] = ident;
liItems[arrayItemCount]['liHeight'] = liHeight;
if(ident%4==0){
arrayItemCount++;
liHeight = 0;
}
});
for(i=0; i ul > li:eq("0")').height(liHeight);
}
$('footer .sitemapWrapper > ul > li:gt("'+(ident-4)+'"):lt("'+(ident)+'")').height(liHeight);
}
}
function addAccordion(){
if($('.accordion').html() != undefined){
imagesLoaded($('.accordion').find('img'), function(){
$('.accordion .trigger_active').next('.toggle_container').hide().removeClass('show');
$('.accordion .trigger').unbind('click');
$('.accordion .trigger').bind('click', function() {
var trig = $(this);
if ( trig.hasClass('trigger_active') ) {
trig.next('.toggle_container').slideUp('slow');
trig.removeClass('trigger_active').next().removeClass('show');
} else {
//$('.accordion .trigger_active').next('.toggle_container').slideToggle('slow');
//$('.accordion .trigger_active').removeClass('trigger_active');
trig.next('.toggle_container').slideDown('slow');
trig.addClass('trigger_active').next().addClass('show');
};
return false;
});
setTimeout(function(){
$('.toggle_container').hide();
$('.accordion .trigger.active').not('.accordion .trigger_active').trigger('click');
}, 1000);
});
}
}
function headerNavigationMobile(){
if($('.tabs').html() != undefined){
$.each($('.tabs'), function(){
obj = $(this);
obj.find('.mobileTabNav select').html('');
for(i=0;i'+nameTab+'');
}
});
$('#BodyContent .tabs select').change(function(){
tabToGo = $(this).val();
text = $(this).find('option[value="'+tabToGo+'"]').html();
tabObj = $(this).parents('.tabs');
tabObj.find('div.cqhorizontaltabitem').hide();
tabObj.find('div.cqHorizontalTabPageItem').hide();
tabObj.find('.tabNav ul li').removeClass('active');
$(this).parent().addClass('active');
tabObj.find('.tabNav ul li').removeClass('active');
tabObj.find('.tabNav ul li a[href="'+tabToGo+'"]').parent().addClass('active');
$('.mobileTabNav > span').html(text);
tabObj.find("#"+tabToGo).parent().show();
return false;
});
}
}
function jumpToTab(){
url = location.href;
if(url.search(/#/) != -1){
tabs = url.split('#');
$('#BodyContent .tabs .tabNav ul li a[href="'+tabs[1]+'"]').trigger('click');
text = $('#BodyContent .tabs .tabNav select option[value="'+tabs[1]+'"]').html();
$('.mobileTabNav > span').text(text);
tabObjJump = $('#BodyContent .tabs .tabNav ul li a[href="'+tabs[1]+'"]').parents('.scroller');
w = 0;
found = false;
$.each(tabObjJump.find('li'), function(){
if(!$(this).hasClass('active') && !found){
$(this).addClass('scrolled');
w += $(this).width();
}else{
found = true;
}
});
tabObjJump.find('ul').css('left', (w*-1)+'px');
tabObjJump.parent().find('.prev').show();
}
}
function addTabs(){
if($('.tabs').html() != undefined){
headerNavigationMobile();
$.each($('.tabs'), function(){
tabObj = $(this);
if(tabObj.find('> div').size() > 0){
$.each(tabObj.find('.tabNav > .scroller > ul > li'), function(){
ew = Math.ceil($(this).find('span').width());
ew += Math.ceil(parseFloat($(this).find('span').css('padding-left').replace(/px/, '')));
ew += Math.ceil(parseFloat($(this).find('span').css('padding-right').replace(/px/, '')));
if($(this).parents('.tabs').parent().parent().hasClass('countryBrand')){
$(this).width(ew+26);
}else{
//$(this).width(ew+4);
}
});
tabObj.find('.tabNav > .scroller > ul').css('left', 0);
lastItem = '';
tabObj.find('.tabNav > .scroller > ul > li > a').unbind('click');
tabObj.find('.tabNav > .scroller > ul > li > a').bind('click',function(){
$(this).parents('ul').find('> li').removeClass('active');
$(this).parents('ul').find('> li').removeClass('nextToActive');
$(this).parents('ul').find('> li').removeClass('scrolled');
$(this).parent().addClass('active');
$(this).parent().next().addClass('nextToActive');
w = 0;
found = false;
$.each(tabObj.find('.tabNav > .scroller > ul > li'), function(){
if(!$(this).hasClass('active') && !found){
$(this).addClass('scrolled');
w += $(this).width();
}else{
found = true;
}
});
if(w == 0){
tabObj.find('.tabNav > span.prev').hide();
}
ulWidth = 0;
$.each(tabObj.find('.tabNav > .scroller > ul > li'), function(){
ulWidth += $(this).width();
});
tabObj.find('.tabNav > .scroller > ul').width(ulWidth+5);
if(tabObj.find('.tabNav > .scroller > ul').width() < (w+$(this).parents('.tabs').find('.tabNav > .scroller > ul > li.active').width()*2)){
tabObj.find('.tabNav > span.next').hide();
}
if(w > 30){
w = w+1;
//tabObj.find('.tabNav ul').parent().css('margin-left', '2px');
}else{
w = -1;
//tabObj.find('.tabNav ul').parent().css('margin-left', '0');
}
if(tabObj.find('.tabNav > .scroller > ul').width() > tabObj.find('.tabNav').width()){
tabObj.find('.tabNav > .scroller > ul').parent().css('border-left', ' 1px solid #a7a9ac');
tabObj.find('.tabNav > .scroller > ul').css('left', (w*-1)-1+'px');
}else{
tabObj.find('.tabNav').addClass('smaller');
}
if(tabObj.find('.scrolled').html() != undefined){
if(tabObj.find('.tabNav > .scroller > ul').width() > tabObj.find('.tabNav').width()){
tabObj.find('.prev').show();
}
}
setActive = $(this).attr('href').replace(/#/, '');
tabObj.find('.mobileTabNav select option').attr('selected');
tabObj.find('.mobileTabNav select option[value="'+setActive+'"]').attr('selected', 'selected');
text = $('#BodyContent .tabs .tabNav select option[value="'+setActive+'"]').html();
$('.mobileTabNav > span').html(text);
if(setActive != lastItem){
if(tabObj.hasClass('loaded')){
//$(this).parents('.tabs').find(' >div:not("div.tabNav")').hide();
//added for CQ
$(this).parents('.tabs').find('div.cqHorizontalTabItem').hide();
$(this).parents('.tabs').find('div.cqHorizontalTabPageItem').hide();
$('#'+setActive).parent().show();
lastItem = setActive;
}else{
//imagesLoaded($(this).parents('.tabs').find('img'), function(){
//setTimeout(function(){
//$(this).parents('.tabs').find(' >div:not("div.tabNav")').hide();
//added for CQ
$(this).parents('.tabs').find('div.cqHorizontalTabItem').hide();
$(this).parents('.tabs').find('div.cqHorizontalTabPageItem').hide();
$('#'+setActive).parent().show();
lastItem = setActive;
$(this).parents('.tabs').addClass('loaded');
//}, 200);
//});
}
}else{
if(!$(lastItem).is(':visible')){
$('#'+setActive).parent().show();
}
}
return false;
});
scrollerWidth = tabObj.width()-tabObj.find('.next').width()-tabObj.find('.next').width()-4-20;
tabObj.find('.scroller').width(scrollerWidth-1);
}
tabWidth = 0;
$.each(tabObj.find('.tabNav ul li'), function(){
tabWidth += $(this).width()+2;
});
//tabObj.find('.tabNav ul').width(tabWidth+14).css('left', '0');
tabObj.find('.tabNav > span.next').show();
showit = '';
if(tabWidth < tabObj.width()){
tabObj.find('.tabNav > span.next').hide();
}
tabObj.find('.tabNav span.next').unbind('click');
tabObj.find('.tabNav span.next').bind('click',function(){
if($(this).parent().find('.scroller ul li.scrolled').html() == undefined){
$(this).parent().find('.scroller ul li:first').addClass('scrolled');
}else{
$(this).parent().find('.scroller ul li.scrolled').next().addClass('scrolled');
}
w = 0;
found = false;
$.each(tabObj.find('li'), function(){
if(!$(this).hasClass('active') && !found){
w += $(this).width();
}else{
found = true;
}
});
w += tabObj.find('li.active').width();
tabObj.find('.tabNav span.prev').show();
nowLeft = parseFloat(tabObj.find('.tabNav ul').css('left').replace(/px/));
newLeft = w;
clearTimeout(showit);
showit = setTimeout(function(){
if(tabObj.find('.tabNav ul li.scrolled:last').next().html() != undefined){
tabObj.find('.tabNav ul li.scrolled:last').next().find('a').trigger('click');
}else{
tabObj.find('.tabNav ul li.scrolled:last').find('a').trigger('click');
}
}, 100);
if(tabObj.find('.tabNav ul').width() < (w+$(this).parent().find('.scroller ul li.active').width()*2)){
tabObj.find('.tabNav span.next').hide();
}
if(newLeft > 30){
newLeft = newLeft+2;
//tabObj.find('.tabNav ul').parent().css('margin-left', '2px');
}else{
newLeft = 0;
//tabObj.find('.tabNav ul').parent().css('margin-left', '0');
}
tabObj.find('.tabNav ul').parent().css('border-left', '0');
tabObj.find('.tabNav ul').css('left', (newLeft*-1)+'px');
return false;
});
tabObj.find('.tabNav span.prev').unbind('click');
tabObj.find('.tabNav span.prev').bind('click',function(){
$(this).parent().find('.scroller ul li.active').removeClass('active');
$(this).parent().find('.scroller ul li.scrolled:last').removeClass('scrolled').addClass('active');
w = 0;
found = false;
$.each(tabObj.find('li'), function(){
if(!$(this).hasClass('active') && !found){
w += $(this).width();
}else{
found = true;
}
});
if(tabWidth > tabObj.width()){
tabObj.find('.tabNav span.next').show();
}
nowLeft = parseFloat(tabObj.find('.tabNav ul').css('left').replace(/px/));
newLeft = w;
clearTimeout(showit);
showit = setTimeout(function(){
if(tabObj.find('.tabNav ul li.scrolled').html() != undefined){
tabObj.find('.tabNav ul li.scrolled:last').next().find('a').trigger('click');
}else{
tabObj.find('.tabNav ul li.active').find('a').trigger('click');
}
}, 100);
if((w*-1) >= 0){
tabObj.find('.tabNav span.prev').hide();
}
if(newLeft > 30){
newLeft = newLeft+2;
//tabObj.find('.tabNav ul').parent().css('margin-left', '1px');
}else{
newLeft = 0;
//tabObj.find('.tabNav ul').parent().css('margin-left', '0');
tabObj.find('.tabNav ul').parent().css('border-left', ' 1px solid #a7a9ac');
}
tabObj.find('.tabNav ul').css('left', (newLeft*-1)+'px');
return false;
});
text = $('.tabs .tabNav select option:first').html();
$('.mobileTabNav > span').text(text);
});
imagesLoaded($('.tabs').find('img'), function(){
$.each($('.tabs'), function(){
tabObj = $(this);
//if(tabObj.find('.featureTeaserSlider').size() == 0){
if(tabObj.find('.tabNav ul li.active').html() != undefined){
tabObj.find('.tabNav ul li.active a').trigger('click');
}else{
tabObj.find('.tabNav ul li:first a').trigger('click');
}
//}
});
});
$('.countryBrand .tabs .tabNav ul li:first a').trigger('click');
/*resizing = '';
if(!$('html').hasClass('lt-ie9')){
$(window).resize(function(){
clearTimeout(resizing);
resizing = setTimeout(function(){
//addTabs();
},100);
});
}*/
jumpToTab();
$('.tabs .tabNav .scroller ul li a').focus(function(){
$(this).trigger('click');
});
setTimeout(function(){
$('.mapLocator .tabs .cqHorizontalTabItem').slideUp();
$('.mapLocator .tabs .tabNav li').removeClass('active');
filterStart = $('.mapLocator .mobileTabNav').data('filterstart');
$('.mapLocator .mobileTabNav select option[value="filterStart"]').remove();
$('.mapLocator .mobileTabNav select option:first').before('');
$('.mapLocator .mobileTabNav select option').removeAttr('selected');
$('.mapLocator .mobileTabNav select option:first').attr('selected', 'selected');
$('.mapLocator .mobileTabNav span').text(filterStart);
$('.mapLocator .mobileTabNav select').change(function(){
$(this).find('option[value="filterStart"]').remove();
});
}, 2000);
}
$('.metaNavigation .wrapper ul li.brandSelect a').click(function(){
$('.countryBrand .tabs .tabNav ul li:first a').trigger('click');
$('.countryBrand .tabs .cqhorizontaltabitem').hide();
$('.countryBrand .tabs .cqhorizontaltabitem:first').show();
});
}
function logoAnimation(){
/***************************/
/*** Logo animation ***/
/***************************/
var logoColors = ["#dd1c31", "#f79421", "#16aa9d", "#25aae1", "#0872ba", "#663091", "#9d1f60"];
var animateLogoColor = function (counter) {
var color = logoColors[counter];
$('header .logo.transforming a span').delay('1200').animate({
backgroundColor: color
}, 4200);
delete logoColors[counter];
logoColors.push(color);
setTimeout(function() {
animateLogoColor(counter + 1);
}, 5400);
};
animateLogoColor(1);
}
function addNavigation(){
/***************************/
/*** NAVIGATION ***/
/***************************/
if($('#searchField').is("*")){
var searchField = $('#searchField');
searchField.placeholder();
searchField.closest("form").unbind("submit"); //important because of possible multiple initialization
searchField.closest("form").submit(function(){
var searchWord = searchField.val();
if($.trim(searchWord).length == 0){
searchField.focus().val("");
return false;
}
});
}
if( $deviceSelector=="isMobile" ){
$("#showMainNav").unbind("click"); //important because of possible multiple initialization
$("#showMainNav").click(function(){
$("nav#MainNavigation > ul > li").removeClass('open').find('> ul').slideUp();
$("nav#MainNavigation").slideToggle();
})
var showSearch = $("#showSearchBox");
var searchBox = $("header .searchBox");
//if(!$('#showMainNav:visible')[0]){
// searchBox.addClass('wide');
// showSearch.addClass('right');
//}
searchBox.find('.close').unbind("click"); //important because of possible multiple initialization
searchBox.find('.close').click(function(){
showSearch.fadeIn();
searchBox.fadeOut();
$('#languageBrandSelector, #showMainNav').fadeIn();
});
showSearch.unbind("click"); //important because of possible multiple initialization
showSearch.click(function(e){
e.preventDefault();
$(this).fadeOut();
$('#languageBrandSelector, #showMainNav').fadeOut();
searchBox.fadeIn();
});
$("nav#MainNavigation > ul > li > a").unbind("click"); //important because of possible multiple initialization
$("nav#MainNavigation > ul > li > a").on("click", function(e){
if($(this).parent().find('>ul').html() != undefined && !$(this).parent().hasClass('open')){
e.preventDefault();
e.stopPropagation();
var $thisVal = $(this).text();
var $open = $("nav#MainNavigation ul").children("li.open");
var $openVal = $open.children("a").text();
var $ul = $(this).next("ul");
var $li = $(this).parents("li");
if( $thisVal==$openVal || !$openVal ){
// Click on open LI or actually no open LI
if( $li.hasClass("open") ){
$li.removeClass("open");
$ul.slideUp();
}
else{
$li.addClass("open");
$ul.slideDown();
} // if-else
}
else{
// Click on any LI which isn't open
$open.removeClass("open");
$open.children("ul").slideUp();
$li.addClass("open");
$ul.slideDown();
} // if-else
}
})
}else{
// var hitEvent = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click';
buildNav();
} // if-else
}
function addExternalLinkDialog(){
/* External Link Dialog */
var $externalUrl, $externalTarget;
if( $deviceSelector == "isDesktop" ){
$( ".external-link-desclaimer" ).click(function(e) {
e.preventDefault();
$externalUrl = $(this).attr('href');
$externalTarget = $(this).attr('target');
//get href and attribute if class is on span tag
if($externalUrl == undefined){
if($(this).parent('a').length){
$externalUrl = $(this).parent('a').attr('href');
$externalTarget = $(this).parent('a').attr('target');
}
else{
$externalUrl = $(this).children('a').attr('href');
$externalTarget = $(this).children('a').attr('target');
}
}
$( "#externalDialog" ).dialog( "open" );
});
$( "#externalDialog" ).dialog({
autoOpen: false,
resizable: false,
width: 450,
closeText: "",
modal: true,
create: function(event,ui){
var siteLogo = $("#anchor_top .logo");
if(siteLogo.hasClass("transforming")){
var siteLogoPrint = siteLogo.find("img.showOnPrint");
$(this).parents(".ui-dialog").prepend('');
}
else {
siteLogo.clone().prependTo( $(this).parents(".ui-dialog") );
}
},
buttons: {
"Forward to external page": function() {
if( $externalTarget == "_blank" ){
window.open($externalUrl);
}else{
window.location.href = $externalUrl;
}
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
}else{
$( ".external-link-desclaimer" ).click(function(e) {
//console.log( $( "#externalDialog" ) );
Check = confirm( $( "#externalDialog" ).attr("title") + "\n\n" + $( "#externalDialog p" ).text() );
if (Check == false){
return false;
}
});
} // if-else
}
function addStage(){
/***************************/
/*** STAGE ***/
/***************************/
if( $("#Stage ul").length ){
$("#Stage img").each(function(){
$(this).data("mobileImageUrl",$(this).attr("src"));
switch($deviceSelector){
case "isMobile":
$(this).attr("src",$(this).data("mobileImageUrl"));
break;
case "isTablet":
$(this).attr("src",$(this).attr("data-tabletImageUrl"));
break;
case "isDesktop":
default:
$(this).attr("src",$(this).attr("data-desktopImageUrl"));
break;
} // switch
})
var $autoplay = true,
$interval = parseInt( $("#Stage").data("interval") )*1000;
if($interval<=0){
$autoplay = false;
}
if ( $("#Stage ul li").length > 1 ){
imagesLoaded($('#Stage ul img'), function(){
$('#Stage ul li').show();
$('#Stage ul li:first').css('display', 'list-item');
centerStageContentVertical();
if(navigator.appVersion.search('Nexus') != -1){
$("#Stage ul")
.carouFredSel({
responsive : true,
auto : {
play : $autoplay,
timeoutDuration : $interval,
onAfter: function(){
repositionStagePagination();
if($("#Stage ul li:first").hasClass('right')){
$('#Stage .pagination').addClass('right');
}else{
$('#Stage .pagination').removeClass('right');
}
}
},
scroll : {
pauseOnHover : true,
fx : "crossfade"
},
pagination : {
container: function(){
return $(this).parent().parent().find('.pagination');
},
onAfter: function(){
//repositionStagePagination();
if($("#Stage ul li:first").hasClass('right')){
$('#Stage .pagination').addClass('right');
}else{
$('#Stage .pagination').removeClass('right');
}
}
},
onCreate : function(data) {
ie8StageHeightFix( $(this), data.height );
repositionStagePagination();
}
})
.css("visibility","visible");
}else{
$("#Stage ul")
.carouFredSel({
responsive : true,
auto : {
play : $autoplay,
timeoutDuration : $interval,
onAfter: function(){
repositionStagePagination();
if($("#Stage ul li:first").hasClass('right')){
$('#Stage .pagination').addClass('right');
}else{
$('#Stage .pagination').removeClass('right');
}
}
},
height: 'variable',
items: {
height: 'variable'
},
scroll : {
pauseOnHover : true,
fx : "crossfade"
},
pagination : {
container: function(){
return $(this).parent().parent().find('.pagination');
},
onAfter: function(){
repositionStagePagination();
if($("#Stage ul li:first").hasClass('right')){
$('#Stage .pagination').addClass('right');
}else{
$('#Stage .pagination').removeClass('right');
}
}
},
onCreate : function(data) {
ie8StageHeightFix( $(this), data.height );
repositionStagePagination();
if($("#Stage ul li:first").hasClass('right')){
$('#Stage .pagination').addClass('right');
}else{
$('#Stage .pagination').removeClass('right');
}
}
})
.css("visibility","visible");
}
//
});
}else{
$("#Stage img").css("visibility","visible");
} // if-else
} // if
}
function addFormStyles(){
/***************************/
/*** INPUTLABELS ***/
/***************************/
$(".form .required").each(function(){
if($(this).is('textarea')){
$(this).parent().find("label").find('.required').remove();
$(this).parent().find("label").append("*")
}else if($(this).parent().find('label').hasClass('file-upload') && !$(this).is('textarea')){
$(this).parent().find(".label").find('.required').remove();
$(this).parent().find(".label").append("*")
}else{
$(this).parent().find("> label").find('.required').remove();
$(this).parent().find("> label").append("*")
}
});
/***************************/
/*** SELECTS ***/
/***************************/
if( $(".form select").length ){
$(".form select:visible:not(select[multiple])").sSelect({
ddMaxHeight: '200px'
}).change(function(){
$("#BodyContent").css({"padding-bottom":"0"});
if($(this).parent().find(".selectedTxt")[0]&&$(this).parent().find(".selectedTxt").ellipsis){
$(this).parent().find(".selectedTxt").ellipsis();
}
})
};
if( $(".mapLocator .radius select").length ){
$(".mapLocator .radius select:visible:not(select[multiple])").sSelect({
ddMaxHeight: '200px'
}).change(function(){
$("#BodyContent").css({"padding-bottom":"0"});
if($(this).parent().find(".selectedTxt")[0]&&$(this).parent().find(".selectedTxt").ellipsis){
$(this).parent().find(".selectedTxt").ellipsis();
}
})
};
if( $(".SubDeviceNav select").length ){
$(".SubDeviceNav select:visible").sSelect();
};
$("a.reset").click(function(e){
e.preventDefault();
$(this).parents("form").each(function(){
this.reset();
/** reset stylish select **/
$(this).find("select").each(function(){
if(typeof $(this).resetSS == 'function'){
$(this).resetSS();
}
});
/** reset textareas **/
$(this).find('textarea[maxlength]').each(function(){
$(this).prev().find('span').text($(this).attr('maxlength'))
})
/** reset checkboxes **/
$(this).find('input[type=checkbox]').each(function(){
if($(this).next().hasClass('checked')){
$(this).next().click()
}
})
})
})
/***************************/
/*** CHECK ***/
/***************************/
$("form input[type=checkbox], form input[type=radio]")
.each(function(){
if($(this).parent().find('div.checkbox, div.radio').html() == undefined){
var $active = "";
if( $(this).prop("checked")==true ){
$active = " checked";
}
$(this)
.hide()
.after("
");
}
});
$("form .checkbox, form .radio").unbind('click');
$("form .checkbox, form .radio").bind('click', function(){
if($(this).hasClass("radio")){
$(this).parents(".radio").find(".checked").removeClass("checked");
$(this).toggleClass("checked");
$(this).parent().find('input[type="checkbox"]').prop('checked', function(idx, oldProp) {
return !oldProp;
});
var check = $(this).prev("input[type=radio]");
}else{
var checkBoxes = $(this).parent().find('input');
if(checkBoxes.prop('checked')){
checkBoxes.removeAttr('checked');
$(this).removeClass("checked");
}else{
checkBoxes.attr('checked', 'checked');
$(this).addClass("checked");
}
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
var check = $(this).prev("input[type=checkbox]");
}
$('.downloadImage input[type="checkbox"].selectAll').unbind("change"); //important because of possible multiple initialization
$('.downloadImage input[type="checkbox"].selectAll').change(function(){
if($(this).is(':checked')){
$(this).parents('.downloadImage').find('table .checkbox:not(".checked")').trigger('click');
$(this).parent().find('label').text(selectNoneText);
}else{
$(this).parents('.downloadImage').find('.checkbox.checked').trigger('click');
$(this).parent().find('label').text(selectAllText);
}
});
check.trigger("click");
});
$("form .check > label")
.click(function(e){
//e.preventDefault();
});
//change the height of the dropdown if it's visible
// --> career.html
// --> because of the overflow:hidden style -> without this correction you won't see the full dd
$(".newListSelected .selectedTxt").click(function() {
if ( $(this).next(".SSContainerDivWrapper").css("display") == "block" ) {
var containerHeight = $(this).parent().find("ul.newList").height();
$("#BodyContent").css({"padding-bottom":containerHeight});
} else {
$("#BodyContent").css({"padding-bottom":"0"});
}
});
$("html").click(function() {
$("#BodyContent").css({"padding-bottom":"0"});
});
}
function resizeAction(){
/***************************/
/*** RESIZE ***/
/***************************/
try{
$(window).resize( $.debounce( 500, resize ) ); // Resize, waiting 500ms before doing anything
}catch(e){};
videoProp();
}
var navigationMouseEnter = function(element){
if(!element.hasClass("opened")){
if($('body').hasClass('rebrush')){
mainNavHeight = element.outerHeight()+16;
}else{
mainNavHeight = element.outerHeight();
}
$('#MainNavigation > ul > li > ul').css('top', mainNavHeight+'px');
navigationMouseLeave();
element.addClass("opened");
//console.log(element);
if( $("#MainNavigation").hasClass("noFade") ){ //Ticket #51124
element.children("ul").css("visibility", "visible").hide().show();
}else{
$("#MainNavigation").addClass("noFade");
element.children("ul").css("visibility", "visible").hide().fadeIn("fast");
}
element.children("ul").addClass("isVisible");
elementLeftPos = element.position().left;
}
if(element.is('#MainNavigation > ul > li')){
var height = 0;
element.find('>ul>li').each(function(){
if($(this).height()>height){
height = $(this).height();
}
});
}
ulMainHeight = $('#MainNavigation > ul > li').height();
ulMainHeight += element.find('>ul').height();
//ulMainHeight += parseFloat(element.find('>ul').css('padding-top').replace(/px/, ''));
//ulMainHeight += parseFloat(element.find('>ul').css('padding-bottom').replace(/px/, ''));
$('#MainNavigation > ul > li > ul').css('left', '-'+element.position().left+'px');
element.find('.close').css('left', (Math.round($('#MainNavigation').width()/2)-element.position().left)+'px');
element.find('.close').css('top', ulMainHeight+'px');
element.find('.close').show();
};
var navigationMouseLeave = function(){
$("html nav#MainNavigation > ul > li.opened").each(function(){
$(this).removeClass("opened");
if( $("#MainNavigation").hasClass("noFade") ){ //Ticket #51124
$(this).children("ul").hide();
}else{
$(this).children("ul").fadeOut("fast");
}
$(this).children("ul").removeClass("isVisible");
});
$('#MainNavigation > ul > li .close').hide();
};
var mainNavigationInitialization = function(){
$('#MainNavigation > ul > li > ul').width($('#MainNavigation').width()+3);
if($('html').hasClass('isTouchDevice')){
$.each($('#MainNavigation > ul >li'), function(){
if($(this).find('ul').html() != undefined){
$(this).find('>ul').after('8
');
}
});
$('#MainNavigation > ul >li .close').unbind('click');
$('#MainNavigation > ul >li .close').bind('click', function(){
//$(this).parent().slideUp(function(){
//$('nav.stageNav .arrowBack').removeClass('active');
//$('.stageNav ul li').removeClass('active');
$('#MainNavigation > ul >li .close').hide();
navigationMouseLeave();
mainNavigationInitialization();
//});
});
}
$("html:not(.isTouchDevice) nav#MainNavigation > ul > li > a").unbind("mouseenter"); //important because of possible multiple initialization
$("html:not(.isTouchDevice) nav#MainNavigation > ul > li > a")
.mouseenter(function(e){
navigationMouseEnter($(this).parent());
});
$("html:not(.isTouchDevice) nav#MainNavigation").unbind("mouseleave"); //important because of possible multiple initialization
$("html:not(.isTouchDevice) nav#MainNavigation")
.mouseleave(function(e){
$("#MainNavigation").removeClass("noFade"); //Ticket #51124
navigationMouseLeave();
});
//
$("html.isTouchDevice nav#MainNavigation > ul > li > a").unbind("click"); //important because of possible multiple initialization
$("html.isTouchDevice nav#MainNavigation > ul > li > a").on("click", function(e){
var li = $(this).parent();
var ul = $(this).parent().parent();
if(!li.hasClass("opened")){
$("#MainNavigation").find('.close').hide();
e.preventDefault(); // needed to not trigger click event
e.stopPropagation();
if(li.hasClass("opened")){
li.children("ul").hide().removeClass("isVisible");
li.removeClass("opened");
}
else {
ul.children("li.opened").children("ul").hide().removeClass("isVisible");
ul.children("li").removeClass("opened");
navigationMouseEnter(li);
}
}
});
};
function buildNav(){
if( $deviceSelector!="isMobile" ){
// to be sure corrects heights will be calculated a instance of the #mainNavigation will be cloned as safe
// > this html is always starting point while resize progress
if( $("nav#MainNavigationSafe").length ){
$("nav#MainNavigation > ul").remove();
$("nav#MainNavigationSafe > ul").clone().prependTo("nav#MainNavigation");
}else{
$("nav#MainNavigation")
.clone()
.hide()
.attr("id","MainNavigationSafe")
.prependTo("body");
}
$("nav#MainNavigation > ul > li")
.each(function(){
if( $(this).find("ul").length ){
// Positioning FlyOut Arrow
var $el = $(this);
setTimeout(function(){
// Timeout need because of fonts;
var $liPos = $el.position();
var $liWidth = $el.width();
var $posArrow = ($liWidth/2) - 10; /* left Position + half width of 1st level LI - 10px (10px = half of the arrow width - left padding) >> centers the arrow per 1st level li-Item */
$el.prepend("");
}, 1000);
} // if
/* Check onlyMobile Entries & add Classes for border management */
$(this).children("ul").each(function(){
var $i = 0,
$l = $(this).children("li:not(.onlyMobile)").length -1;
$(this).children("li:not(.onlyMobile)").each(function(){
if( $i===0 || $i===4 || $i===8 || $i===12 || $i===16 || $i===20 || $i===24 || $i===28 || $i===32 || $i===36 || $i===40 ){ // first-child & first each row
$(this).addClass("noLeftBorder");
} // if
if( $i===$l || $i===3 || $i===7 || $i===11 || $i===15 || $i===19 || $i===23 || $i===27 || $i===31 || $i===35 || $i===39 ){ // last-child & last each row
$(this).addClass("noRightBorder");
} // if
$i++;
});
});
if( !$(this).hasClass("no3rd") ){
// 3rd level should be displayed
var $fixNavHeightLength = $(this).find(".fixHeight:not(.onlyMobile)").length;
var $fixNavHeight = 0;
if( $fixNavHeightLength<=4 ){
// less or equal than 4 Items in level 2
handleNavRows($(this),".fixHeight:not(.onlyMobile)");
}
else{
// more than 4 Items in level 2 > row Mode
var $i = 1;
var $rowCount = 1;
$(this)
.find(".fixHeight:not(.onlyMobile)")
.each(function(){
// set rows
if( $i<=4 ){
// 1st row
$(this).addClass("row"+$rowCount);
}
else if( $i>=5 && $i<=8 ){
// 2nd row
$rowCount = 2;
$(this).addClass("row"+$rowCount);
}
else if( $i>=9 && $i<=12 ){
// 3rd row
$rowCount = 3;
$(this).addClass("row"+$rowCount);
} // else-if
$i++;
})
.addClass("rows");
for ( var i = 1; i <= $rowCount; i++ ){
//handleNavRows($(this),".rows.row"+i);
} // for
} // if-else
} // if
}) // each
mainNavigationInitialization();
}
}
function handleNavRows(element,selector){
$fixNavHeight = 0;
/*element.find(selector).each(function(){
var $liNavHeight = $(this).height();
if( $liNavHeight > $fixNavHeight ){
$fixNavHeight = $liNavHeight;
} // if
})
.height($fixNavHeight);*/
}
function stageInterval(interval){
//console.log( interval );
}
function repositionStagePagination(){
/*** reposition stage pagination ***/
if( ($deviceSelector == "isMobile") && ($("#Stage .pagination").is("*")) ){
var stageImageHeight = $("#Stage > div > ul > li:first-child img").height();
$("#Stage .pagination").css("top", stageImageHeight - 60 + "px");
}
}
function resize(){
deviceSelector();
buildNav();
repositioning();
videoProp();
$("#Stage ul").trigger("configuration", {
"reInit" : true
});
/*** reposition stage pagination ***/
repositionStagePagination();
$(".ie8CarouselFix").each(function(){
var liHeight = 0;
$(this).find("li").each(function(){
if( liHeight < $(this).height() ){
liHeight = $(this).height();
}
});
ie8StageHeightFix( $(this).find(".caroufredsel_wrapper>ul"), liHeight );
});
}
function deviceSelector() {
$deviceSelector = $(".deviceSelector:visible").attr("id");
$("body")
.removeClass("isTablet")
.removeClass("isMobile")
.removeClass("isDesktop")
.addClass( $deviceSelector );
}
function repositioning(){
// Device Switch to reposition elements
// define standard Position
$("nav#MainNavigation").insertAfter("header");
$("div#searchOptions").insertBefore(".resultMain");
// define device Position
switch($deviceSelector){
case "isMobile":
$("nav#MainNavigation").insertBefore("body > header");
$("div#searchOptions").insertAfter(".resultMain");
break;
case "isTablet":
break;
case "isDesktop":
break;
default:
break;
}
}
function videoProp(){
setTimeout(function(e){
/*$(".videoPlayer").each(function(){
var $format = new Array();
$format['compW'] = $(this).width(); // width of Component
$format['propW'] = parseInt( $(this).attr("data-propW") ); // prefered Proportion Width
$format['propH'] = parseInt( $(this).attr("data-propH") ); // prefered Proportion Height
$format['compH'] = ($format['compW']/$format['propW']) * $format['propH']; // calculated Component Height based on prefered Proportions and Width
$(this).find("div").height($format['compH']);
});*/ //commented out for #61225
},500);
}
function ie8StageHeightFix(el,height){ // fkr
if( $("html").hasClass("lt-ie9") ){
var cfw = el.parents(".caroufredsel_wrapper"),
carousel = cfw.parent("div");
carousel.addClass("ie8CarouselFix").height(height);
}
return false;
}
function showMoreFilter(){
if($('.newsFilter').html() != undefined){
$('.newsFilter a.more').click(function(){
$(this).parent().find('.hide').show();
$(this).remove();
return false;
});
$('.bodyContentWrapper .SubDeviceNav select').change(function(){
$(this).parents('.toggle_container').find('.remove').show();
name = $(this).attr('name');
value = $(this).val();
return false;
});
$('.accordionWrapper .remove').click(function(){
$(this).parent().find('select').getSetSSValue('#');
$(this).hide();
return false;
});
}
}
function cloneElementsForMobileDesign() {
$("#CloneTargetBox").empty(); //important because of possible multiple initialization
$("#sidebar > div").each(function(index, domElement){
var clonedQuicklinksContainer = $(this).clone();
clonedQuicklinksContainer.removeClass("desktop").addClass("tablet").addClass("mobile");
$("#CloneTargetBox").append(clonedQuicklinksContainer);
});
$.each($("#CloneTargetBox"), function(){
if($.trim($(this).html()) == ''){
$(this).remove();
}
});
}
function updateByNewContent(){
deviceSelector();
//if new content is loaded like by fancybox, this functions needed to run new
var i = 1;
$(".responsiveTable").each(function () {
$(this).attr("id","table"+i);
$(this).table({
idprefix : $(this).attr("id") + "-col",
persist : "persist",
btnText : $(this).attr("data-menuBtnText"),
autoPrio : $(this).attr("data-autoPrio")
});
i++;
});
addAccordion();
deviceSelector();
addExternalLinkDialog();
showMoreFilter();
addLightbox();
//videoGallery();
if(!$('.featureTeaserSlider').parents('.cqHorizontalTabPageContainer').length > 0){
featureTeaserSlider();
} else if($('.featureTeaserSlider').parents('.cqHorizontalTabPageContainer').length > 0 && $('.featureTeaserSlider').siblings(".imageGallery")){
featureTeaserSlider();
$('.cqHorizontalTabPageContainer .featureTeaserSlider.imageGallery .sliderWrapper ul li span.background img').css('left', '0px');
$('.cqHorizontalTabPageContainer .featureTeaserSlider.imageGallery .sliderWrapper ul li span.background img').css('top', '0px');
} else {
/*AAU-68*/
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul').css('display', 'inline-flex');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul li').css('display', 'block');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul li span.background img').css('visibility', 'visible');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul li span.background img').css('display', 'block');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper div.controls').css('display', 'none');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul li span.background img').css('left', '0px');
$('.cqHorizontalTabPageContainer .cqFeatureTeaserContainer .featureTeaserSlider .sliderWrapper ul li span.background img').css('top', '0px');
}
addDynamicDownloadThumbLightbox();
centerButtonComponent();
addFormStyles();
//setTeaserOverviewItemHeight();
$.each($("#CloneTargetBox"), function(){
if($.trim($(this).html()) == ''){
$(this).remove();
}
});
addTabs();
//mainNavWidthCalc();
}
function unobfuscateMail(){
$("a.mailfuscate").each(function(index, element){
mailValue = $(this).data('value');
if(mailValue !== undefined){
$(this).removeClass('mailfuscate');
obfuscatedMailAddress = mailValue;
var unobfuscatedMailAddress = obfuscatedMailAddress.replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
console.log(unobfuscatedMailAddress);
$(this).attr("href", "mailto:"+unobfuscatedMailAddress);
}else{
if($(this).find('span').size() == 0){
var obfuscatedMailAddress = $(this).text();
}else{
var obfuscatedMailAddress = $(this).find('span:last').text();
}
$(this).removeClass('mailfuscate');
var unobfuscatedMailAddress = obfuscatedMailAddress.replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
$(this).attr("href", "mailto:"+unobfuscatedMailAddress).html(''+unobfuscatedMailAddress+'');
}
});
}
function fetchAjaxComponentParts(){
if($(".ajax-container").size() > 0){
var ajaxContainerCount = $(".ajax-container").size();
var ajaxContainerLoaded = 0;
var flagofCookieGDPR = false;
$(".ajax-container").each(function(i,ajaxContainer){
var obj = $(this);
var indexOfAnalyticsWord = obj.attr("data-ajax-path");
if (indexOfAnalyticsWord.includes("analytics")){
var siteId = 12; //Setting site ID for Cookie GDPR
if($.cookie('cookieGDPR_' + siteId) != undefined){
flagofCookieGDPR = true; //
}
}
if(!flagofCookieGDPR) {
$.get($(ajaxContainer).attr("data-ajax-path")).success(function(data){
if(data.trim() != ""){
$("#" + $(ajaxContainer).attr("id")).replaceWith($(data));
}
ajaxContainerLoaded++;
//console.log('ajaxContainerCount: '+ajaxContainerCount+' - ajaxContainerLoaded: '+ajaxContainerLoaded);
if(!flagofCookieGDPR){
if(ajaxContainerCount <= ajaxContainerLoaded){
buildNav();
addNavigation();
repositioning();
updateByNewContent();
initializeComponents();
if( $(".SubDeviceNav select").length ){
$(".SubDeviceNav select:visible").sSelect();
};
unobfuscateMail();
//redirect mobile navigation
$(".bodyContentWrapper .SubDeviceNav select").unbind("change");
$(".bodyContentWrapper .SubDeviceNav select").change(function() {
window.location.href = $(this).val();
});
}
}
});
}
});
checkFornavigation();
}else{
buildNav();
addNavigation();
repositioning();
unobfuscateMail();
updateByNewContent();
initializeComponents();
}
}
function initializeComponents(){
//update download icon text for icon fonts
$.each($('.item.download .icon'), function(){
if($(this).hasClass('pdf')){
$(this).find('span').text('q');
}
if($(this).hasClass('ppt')){
$(this).find('span').text('s');
}
if($(this).hasClass('text')){
$(this).find('span').text('r');
}
if($(this).hasClass('daten')){
$(this).find('span').text('p');
}
if($(this).hasClass('overall')){
$(this).find('span').text('o');
}
if($(this).hasClass('external')){
$(this).find('span').text('u');
}
if($(this).hasClass('link')){
$(this).find('span').text('9');
}
if($(this).hasClass('locked')){
$(this).find('span').text('v');
}
});
$('body.pageSearchResult input[type="submit"]').val('m');
addDynamicDownloadPaging();
//addNavigation();
cloneElementsForMobileDesign();
//sitemapHeight();
brandMenu();
unobfuscateMail();
//updateByNewContent(); //check this
updateCareerSelectWrapperHeight();
updateMaxLength();
showVideoLightbox();
makeDynamicDownloadResponsive();
addSortableResponsiveTable();
setImageTeaserWidth(); // check
table.init();
metaNavigation();
updatePhoneNumber();
updateFormItemHeight();
countryBrandSelector(); //not needed
/*if($('#worldmap').size() > 0){
worldmap();
}*/
addTextImageMargin();
getVideoUrls();
disableHoverOnTouchDevice();
if($('img[usemap]').attr('usemap') != undefined){
$('img[usemap]').rwdImageMaps();
$.each($('map area'), function(){
link = $(this).attr('href');
externCheck = link.search(/(http)/);
if(externCheck != -1){
$(this).attr('target', 'blank');
}
});
}
//redirect mobile navigation
$(".bodyContentWrapper .SubDeviceNav select").unbind("change");
$(".bodyContentWrapper .SubDeviceNav select").change(function() {
window.location.href = $(this).val();
});
/*** special handling for RTE Tables in IE<9 ***/
$('html.lt-ie9 main#BodyContent div.textComponent div.responsiveTableWrapper div.table-menu input[type=checkbox]+label').unbind("click");
$('html.lt-ie9 main#BodyContent div.textComponent div.responsiveTableWrapper div.table-menu input[type=checkbox]+label').click(function(){
$(this).prev("input").click();
});
/*** needed to bubble click event on iPhone ***/
$('main#BodyContent div.textComponent div.responsiveTableWrapper div.table-menu input[type=checkbox]+label').on("click", function(){
//believe it or not - this works
});
$('.newsFilter').find('.hide').each(function(index){
if($(this).hasClass('active'))
{
$(this).parent().find('.hide').show();
$('.newsFilter a.more').hide();
}
});
if($(".solutionfinder .newListSelected .selectedTxt")[0]){
$(".solutionfinder .newListSelected .selectedTxt").ellipsis();
}
if($('body').hasClass('brand')){
logoPos = $('body.brand header .showHide').outerWidth()+53;
$('body.brand header .logo').css('right', logoPos+'px');
headWidth = $('body.brand header .wrapper').width();
$('body.brand header .wrapper >ul> li> ul').width(headWidth);
$.each($('body.brand header .wrapper >ul >li'), function(){
if($(this).find('>ul').html() != undefined){
$(this).find('>a').unbind('mouseenter');
$(this).find('>a').bind('mouseenter', function(){
posLeftLI = $(this).parent().position().left;
$(this).next().show();
$(this).parent().addClass('opened');
$(this).next().css('left', '-'+posLeftLI+'px')
});
$(this).unbind('mouseleave');
$(this).bind('mouseleave', function(){
$(this).find('>ul').hide();
$(this).removeClass('opened');
});
}
});
}
};
function checkFornavigation(){
if($('#MainNavigation').size() == 0 && $('#headerTopnavi-id').size() == 0 && $('#campaignPageTopnavi-id').size() == 0){
$('a#showMainNav').remove();
$.each($('body > header > a'), function(){
rightOld = parseFloat($(this).css('right').replace(/px/, ''));
$(this).css('right', (rightOld-60)+'px')
});
}
}
function updateVideoHeight(){
$.each($("video"), function () {
if ($(this).parents('li').length > 0)
{
videoHeight = Math.floor($(this).parents('li').width() / 16 * 9);
}
else
{
videoHeight = Math.floor($(this).width() / 16 * 9);
}
$(this).height(videoHeight);
});
videoGallery();
}
function sfdcCheck(){
if($("#sfdcForm").size() > 0){
var servletUrl = $('#sfdcForm').data('servleturl');
var webtrendsPageUrl = $('#sfdcForm').data('webtrendspageurl');
var webtrendsFormTag = $('#sfdcForm').data('webtrendsformtag');
$.validator.addMethod("matches", function (value, element, param) {
value = value.replace(new RegExp("-|\\(|\\)", "g" ), '');
return this.optional(element) || param.test(value);
});
var validator = $("#sfdcForm").validate({
rules: {
phone: {
matches: /^\u002B?([0-9]| )*$/
}
},
messages: validatorMessages,
ignore: ".ignore"
});
}
}
function showMoreComments(){
if($('.comment').size() > 0){
commentCount = 0;
$('.comment a.more').click(function(){
$.each($(this).parent().find('article.hide'), function(){
$(this).removeClass('hide');
commentCount++;
if(commentCount%5==0){
return false;
}
});
if($(this).parent().find('article.hide').size() == 0){
$(this).hide();
}
return false;
});
}
}
startCalc = '';
function kpiGraphCal(){
if($('.component.kpi').size() > 0){
resetKpiForm();
doKpiCal();
ident = 0;
$.each($('.component.kpi .set'), function(){
count = 0;
$.each($(this).find('.left .group, .left .total'), function(){
$(this).attr('id', 'group_'+ident);
$(this).parents('.set').find('.right .group').eq(count).attr('id', 'group_'+ident);
ident++;
count++;
});
});
ident = 0;
$.each($('.component.kpi .right .group'), function(){
//$(this).attr('id', 'group_'+ident);
ident++;
});
setCount = 0;
$.each($('.component.kpi .set:not(.component.kpi .set.last):not(.component.kpi .set.solo)'), function(){
obj = $(this);
obj.find('.leftFormComp input, .rightFormComp input').keyup(function(){
itemRoot = $(this);
origValue = itemRoot.val().replace(/\./g, '');
newValue = origValue.toString().replace(/[^0-9]+/g, "");
newValue = newValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
itemRoot.attr('value', newValue);
});
obj.find('.left .group input').keyup(function(){
itemRoot = $(this);
origValue = itemRoot.val().replace(/\./g, '');
newValue = origValue.toString().replace(/[^0-9]+/g, "");
newValue = newValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
itemRoot.attr('value', newValue);
clearTimeout(startCalc);
startCalc = setTimeout(function(){
totalValue = 0;
$.each(itemRoot.parents('.set').find('.left input[value!=""]'), function(){
totalValue += parseFloat($(this).attr('value').replace(/\./g, ''));
});
//set total value in site
itemRoot.parents('.set').find('.left .total > div:last').text(totalValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
//total value from first set
firstTotal = parseFloat($('.component.kpi .set:first .total div:last').text().replace(/\./g, ''));
hightestValue = 0;
$.each(itemRoot.parents('.set').find('.group input[value!=""]'), function(){
var item = $(this);
itemID = item.parent().attr('id');
value = item.val();
value = value.replace(/\./g, '');
kpiGraph = item.parents('.set').find('.right .group#'+itemID+' .sub:first .graph .title');
targetGraph = item.parents('.set').find('.right .group#'+itemID+' .sub:eq(1) .graph');
levelRed = targetGraph.parent().find('.title').data('red-from');
levelYellow = targetGraph.parent().find('.title').data('yellow-from');
levelGreen = targetGraph.parent().find('.title').data('green-from');
//calcluate color
if(setCount == 0){
yourPercentage = 100/totalValue*value;
console.log(totalValue+' * '+value);
}else{
yourPercentage = 100/firstTotal*value;
console.log(firstTotal+' * '+value);
}
yourPercentage = Math.round(yourPercentage * 100) / 100;
kpiValue = kpiGraph.text().replace(/.%/, '');
percentage = Math.round((yourPercentage/kpiValue) * 100);
levelClass = '';
if(levelRed > levelGreen){
if(percentage >= levelGreen){
levelClass = 'green';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelRed){
levelClass = 'red';
}
}else{
if(percentage >= levelRed){
levelClass = 'red';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelGreen){
levelClass = 'green';
}
}
targetGraph.parents('.right').css('visibility', 'visible');
targetGraph.parents('.group').css('visibility', 'visible');
$('.component.kpi .right').css('visibility', 'visible');
$('.component.kpi .right .group').css('visibility', 'visible');
//calcluate value
totalValue = $('.component.kpi .set:eq(0) .left .total div:eq(1)').text().replace(/\./g, '');
yourPercentage = value/totalValue;
yourPercentage = Math.round(yourPercentage * 100) / 100;
percentage = Math.round(yourPercentage*100);
if(percentage < 1){
targetGraph.css('width', '1px');
targetGraph.find('.title').text(percentage+' %');
}else{
if(percentage == 'Infinity'){
//targetGraph.hide();
}else{
targetGraph.show();
targetGraph.css('width', percentage+'%');
targetGraph.find('.title').text(percentage+' %');
}
}
targetGraph.removeClass('red green yellow').addClass(levelClass);
});
//Gross Total Calculation
grossTotal = parseFloat($('.component.kpi .set:eq(0) .left .total div:last').text().replace(/\./g, ''));
grossTotal -= parseFloat($('.component.kpi .set:eq(1) .left .total div:last').text().replace(/\./g, ''));
$('.component.kpi .set .left .total[data-type="grossProfit"] div:last').text(grossTotal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
//Result before Tasks Calculation
resultBeforeTasks = parseFloat($('.component.kpi .set .left .total[data-type="grossProfit"] div:last').text().replace(/\./g, ''));
resultBeforeTasks -= parseFloat($('.component.kpi .set:eq(3) .left .total div:last').text().replace(/\./g, ''));
$('.component.kpi .set .left .total[data-type="resultBeforeTasks"] div:last').text(resultBeforeTasks.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
$.each($('.component.kpi .set .left .total'), function(){
itemObj = $(this);
if(itemObj.parents('.left').find('.total').data('workgraph') == true){
totalValue = itemObj.find('> div:last').text().replace(/\./g, '');
kpiGraph = itemObj.parents('.set').find('.right .group:last .sub:first .graph .title');
targetGraph = itemObj.parents('.set').find('.right .group:last .sub:eq(1) .graph');
levelRed = targetGraph.parent().find('.title').data('red-from');
levelYellow = targetGraph.parent().find('.title').data('yellow-from');
levelGreen = targetGraph.parent().find('.title').data('green-from');
yourPercentage = Math.round(yourPercentage * 100) / 100;
percentage = (totalValue/firstTotal)*100;
yourPercentage = (totalValue/firstTotal)*100;;
yourPercentage = Math.round(yourPercentage * 100) / 100;
kpiValue = kpiGraph.text().replace(/.%/, '');
percentage = Math.round((totalValue/firstTotal) * 100);
if(percentage < 1){
targetGraph.css('width', '1px');
targetGraph.find('.title').text(percentage+' %');
}else{
targetGraph.css('width', (percentage)+'%');
targetGraph.find('.title').text(percentage+' %');
}
percentage = Math.round((yourPercentage/kpiValue) * 100);
levelClass = '';
if(levelRed > levelGreen){
if(percentage >= levelGreen){
levelClass = 'green';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelRed){
levelClass = 'red';
}
}else{
if(percentage >= levelRed){
levelClass = 'red';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelGreen){
levelClass = 'green';
}
}
}
targetGraph.removeClass('red green yellow').addClass(levelClass);
});
checkPercentageWidth();
}, 100);
});
setCount++;
});
}
}
function checkPercentageWidth(){
percentageSize = 1;
$.each($('.component.kpi .right .sub .graph .title'), function(){
checkValue = parseFloat($(this).text().replace(/.%/, ''));
if(checkValue > hightestValue){
hightestValue = checkValue;
}
});
if(percentage > hightestValue && percentage != 'Infinity'){
hightestValue = percentage;
}
if(hightestValue > 100){
percentageSize = 100/hightestValue;
}
$.each($('.component.kpi .right .group .sub .graph .title'), function(){
origValue = parseFloat($(this).text().replace(/.%/, ''));
if(Math.round((origValue*percentageSize)) <= 1){
$(this).parent().css('width', '1px');
}else{
$(this).parent().css('width', Math.round((origValue*percentageSize))+'%');
}
});
}
function resetKpiForm(){
$('.component.kpi a.reset').click(function(){
var confirmCheck = confirm($(this).data('confirmmessage'));
if (confirmCheck==true) {
$('.component.kpi input').attr('value', '');
$.each($('.component.kpi .total'), function(){
$(this).find('div:last').text(0);
});
$.each($('.component.kpi .right .group'), function(){
$(this).removeClass('red green yellow').addClass('red');
obj = $(this).find('.sub:last .graph');
obj.css('width', '1px');
obj.find('.title').text('0 %');
});
$('.component.kpi .kpiTable').hide();
$('.component.kpi .right').css('visibility', 'hidden');
$('.component.kpi .right .group').css('visibility', 'hidden');
}
});
}
function doKpiCal(){
$('.component.kpi .button a').click(function(){
$('.component.kpi .kpiTable').show();
if($('.component.kpi input[value!=""]').size() != $('.component.kpi input').size()){
$(document).scrollTop($('.component.kpi .kpiTable').position().top);
$('.component.kpi .kpiTable .error').show();
$('.component.kpi .kpiTable table').hide();
}else{
$(document).scrollTop($('.component.kpi .kpiTable').position().top);
$('.component.kpi .kpiTable .error').hide();
$('.component.kpi .kpiTable table').show();
ftes = $('.component.kpi .set:last input:eq(0)').val().replace(/\./g, '');
repairs = $('.component.kpi .set:last input:eq(1)').val().replace(/\./g, '');
hoursWorked = $('.component.kpi .set:last input:eq(2)').val().replace(/\./g, '');
hoursSold = $('.component.kpi .set:last input:eq(3)').val().replace(/\./g, '');
//Turnover by productive employee
total = $('.component.kpi .set:first .total div:last').text().replace(/\./g, '');
yours = Math.round(total/ftes);
yourValue = $('.component.kpi .kpiTable tbody tr:eq(0) td:eq(1)').text(yours.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
kpiValue = parseFloat($('.component.kpi .kpiTable tbody tr:eq(0) td:eq(3)').text().replace(/\./g, ''));
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(0) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Result by employee
total = $('.component.kpi .set:eq(4) .total div:last').text().replace(/\./g, '');
yours = Math.round(total/ftes);
yourValue = $('.component.kpi .kpiTable tbody tr:eq(1) td:eq(1)').text(yours.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "."));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(1) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(1) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Personnelcosts Factor from profit
total = $('.component.kpi .set:eq(3) .left .group:eq(0) input').val().replace(/\./g, '');
totalSec = $('.component.kpi .set:eq(4) .total div:last').text().replace(/\./g, '');
yours = total/totalSec;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(2) td:eq(1)').text((Math.round(yours*100)/100).toString().replace(/\./, ','));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(2) td:eq(3)').text().replace(/\./g, '').replace(/\,/g, '.');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(2) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Average Repair Amount
total = $('.component.kpi .set:eq(0) .total div:last').text().replace(/\./g, '');
yours = total/repairs;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(3) td:eq(1)').text(Math.round(yours));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(3) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(3) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Costprice per hour productive
total = $('.component.kpi .set:eq(3) .left .total div:last').text().replace(/\./g, '');
yours = total/hoursWorked;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(5) td:eq(1)').text((Math.round(yours*100)/100).toString().replace(/\./, ","));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(5) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(5) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Costprice per hour sold
total = $('.component.kpi .set:eq(3) .left .total div:last').text().replace(/\./g, '');
yours = total/hoursSold;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(6) td:eq(1)').text((Math.round(yours*100)/100).toString().replace(/\./, ","));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(6) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(6) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Revenu per hour productive
total = $('.component.kpi .set:eq(0) .left input:eq(0)').val().replace(/\./g, '');
yours = total/hoursWorked;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(7) td:eq(1)').text((Math.round(yours*100)/100).toString().replace(/\./, ","));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(7) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(7) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Revenu per hour sold
total = $('.component.kpi .set:eq(0) .left input:eq(0)').val().replace(/\./g, '');
yours = total/hoursSold;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(8) td:eq(1)').text((Math.round(yours*100)/100).toString().replace(/\./, ","));
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(8) td:eq(3)').text().replace(/\./g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(8) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Gross margin on parts
total = $('.component.kpi .set:eq(0) .left input:eq(1)').val().replace(/\./g, '');
totalSec = $('.component.kpi .set:eq(1) .left input:eq(0)').val().replace(/\./g, '');
yours = (total-totalSec)/total*100;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(10) td:eq(1)').text(yours.toFixed(2).replace(/\./, ',')+'%');
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(10) td:eq(3)').text().replace(/\./g, '').replace(/\,/g, '.').replace(/\%/g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(10) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Gross margin on material
total = $('.component.kpi .set:eq(0) .left input:eq(2)').val().replace(/\./g, '');
totalSec = $('.component.kpi .set:eq(1) .left input:eq(1)').val().replace(/\./g, '');
totalThird = $('.component.kpi .set:eq(1) .left input:eq(2)').val().replace(/\./g, '');
yours = (total-totalSec-totalThird)/total*100;
yours.toFixed(2).replace(/\./, ',')
yourValue = $('.component.kpi .kpiTable tbody tr:eq(11) td:eq(1)').text(yours.toFixed(2).replace(/\./, ',')+'%');
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(11) td:eq(3)').text().replace(/\./g, '').replace(/\%/g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(11) td:eq(2) div.color').attr('data-percentage', dotPercentage);
//Productive Efficiency
yours = hoursSold/hoursWorked*100;
yourValue = $('.component.kpi .kpiTable tbody tr:eq(13) td:eq(1)').text(yours.toFixed(2).replace(/\./, ",")+'%');
kpiValue = $('.component.kpi .kpiTable tbody tr:eq(13) td:eq(3)').text().replace(/\./g, '').replace(/\%/g, '');
dotPercentage = Math.round((yours/kpiValue)*100);
$('.component.kpi .kpiTable tbody tr:eq(13) div.color').attr('data-percentage', dotPercentage);
$.each($('.component.kpi .kpiTable table tbody tr'), function(){
var value = $(this).find('td:eq(3)').text();
var orig = $(this).find('td:eq(1)').text();
$(this).find('td:eq(1)').html(''+orig+'').append(''+value+'');
});
$.each($('.component.kpi .kpiTable table tbody tr td .color'), function(){
percentage = $(this).attr('data-percentage');
levelRed = $(this).data('red-from');
levelYellow = $(this).data('yellow-from');
levelGreen = $(this).data('green-from');
if(levelRed > levelGreen){
if(percentage >= levelGreen){
levelClass = 'green';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelRed){
levelClass = 'red';
}
}else{
if(percentage >= levelRed){
levelClass = 'red';
}
if(percentage >= levelYellow){
levelClass = 'yellow';
}
if(percentage >= levelGreen){
levelClass = 'green';
}
}
$(this).removeClass('red yellow green').addClass(levelClass);
$(this).parents('tr').find('td:eq(1) span').removeClass('red yellow green').addClass(levelClass);
});
}
return false;
});
}
function getAbsoluteUrl(href, shortUrl){
var link = document.createElement("a");
link.href = href;
return (link.protocol+"//"+link.host+shortUrl+link.search+link.hash);
}
function replaceContentPaths(){
$(".results a").each(function() {
if ($(this).hasClass("url")){
if (!$(this).html().startsWith("http:") && !$(this).html().startsWith("https:")) {
$(this).text(getAbsoluteUrl($(this).attr('href'), $(this).html()));
}
}
})
}
$(document).ready(function () {
if(typeof darkSitesPageOverlayLink != 'undefined'){
if(darkSitesPageOverlayLink != '' && darkSitesPageOverlayLink != undefined){
if(lastModifiedDarkSitesPageOverlay != lastModifiedDarkSitesPageOverlayCookie){
$('body').append('');
var domainName =document.domain;
var domainNameArray =domainName.split('.');
var domainNameShift=domainNameArray.shift();
var domainNameJoin ='.' +domainNameArray.join('.');
//document.write(" <\/a>");
$.cookie("lastModifiedDarkSitesPageOverlayCookie", lastModifiedDarkSitesPageOverlay, { expires: 17800, path: "/",domain :domainNameJoin }); // 50 years
}
}
}
window.addEventListener('orientationchange', function(){
location.reload();
});
kpiGraphCal();
setTimeout(function(){
updateVideoHeight();
}, 500);
$('#showSearchBox, #showMainNav').html('');
$('#languageBrandSelector').html('');
/*** do feature detection: float and BFCs with margin bug in webkit ***/
/*** https://bugs.webkit.org/show_bug.cgi?id=79046 ***/
$("body").append('');
var floatAndbfcWithMarginContainer = $("div.feature-detection.floatAndbfcWithMargin");
var bfc = floatAndbfcWithMarginContainer.children("div.bfc");
if(bfc.width() != 70){
$("html").addClass("isRenderingFloatsAndBFCsWithMarginsFalse");
}
floatAndbfcWithMarginContainer.remove();
/*** check if it as touch device ***/
var hitEvent = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click';
if(hitEvent === "touchstart"){
$("html").addClass("isTouchDevice");
}
countryRedirect();
deviceSelector();
repositioning();
logoAnimation();
addStage();
centerStageContentVertical();
setTimeout(function(){
autoLoadDarksite();
}, 1000);
//countryBrandSelector();
setVideoWidthForFlashObject();
addMapLocatorFilter();
getMapLocations();
resizeAction();
initializeComponents();
if($('#worldmap').size() > 0){
worldmap();
}
fetchAjaxComponentParts();
$(".urlForPrinting").text("http://www.axaltacoatingsystems.com" + window.location.pathname);
imagesLoaded($('.featureTeaserSlider img'), function(){
$.each($('.featureTeaserSlider.album ul'), function(){
//updateimagePosition($(this));
});
});
sfdcCheck();
showMoreComments();
replaceContentPaths();
//$('select[multiple]:visible').multiSelect();
});
/*
Jelly JavaScript, Copyright (c) 2008-2009 Pete Boere.
MIT style license: http://www.opensource.org/licenses/mit-license.php
project page: http://code.google.com/p/jelly-javascript/
this build compiled: 2009-08-19
*/
(function(){
/* base */
var au=window.JELLY={},ay=window,K=ay.document,aR=K.documentElement,F=K.getElementsByTagName("head")[0],N="addEventListener" in K,S="querySelectorAll" in K,W=function(){},aK=function(){var J=ay.navigator,a5=J.userAgent,bb="ActiveXObject" in ay,bc="XMLHttpRequest" in ay,a8="securityPolicy" in J,a7="taintEnabled" in J,a6=/opera/i.test(a5),a9=/firefox/i.test(a5),ba=/webkit/i.test(a5),Q=bb?(S?8:(bc?7:6)):0;return{ie:Q,ie6:Q===6,ie7:Q===7,ie8:Q===8,opera:a6,firefox:a9||(a8&&!bb&&!a6),webkit:ba||(!a7&&!bb&&!a6),safariMobile:/safari/i.test(a5)&&/mobile/i.test(a5),chrome:ba&&/chrome/i.test(a5)}}(),aB=aK.ie,aA=function(J){return typeof J!=="undefined"},Y=function(J){return typeof J==="undefined"},a1=function(J){return J===null},aQ=function(J){return typeof J==="boolean"},aY=function(J){return typeof J==="string"},U=function(J){return typeof J==="number"},ap=function(J){return U(J)?!(J%1):false},b=function(J){return U(J)?!!(J%1):false},p=function(J){return aY(J)||U(J)?/^\s*\d+\.?\d*?\s*$/.test((J+"")):false},H=function(J){return J+""==="[object Object]"},c=function(J){return !!J&&!H(J)&&(typeof J==="object"||aL(J))},aL=function(J){return{}.toString.call(J)==="[object Function]"},az=function(){if(!aB){return function(J){return c(J)&&!a(J)&&/^\[object HTML[A-Za-z]*Element\]$/.test(J+"")}}return function(J){return c(J)&&!!J.nodeName&&J.nodeType===1}}(),a0=function(){if(!aB){return function(J){return aI(J)&&/^\[object (HTMLCollection|NodeList)\]$/.test(J+"")}}return function(J){return aI(J)&&!!J.item}}(),a=function(J){return{}.toString.call(J)==="[object Array]"},aI=function(J){return c(J)&&!H(J)&&!a(J)&&!aL(J)&&ap(J.length)},x=function(Q,J){return J.indexOf(Q)!==-1},O=function(a5){var J=[],a6=a5.length,Q=0;for(Q;Qa7;a7++){a6.push(arguments[a7])}return Q.apply(a5,a6)}}},false);if(ay.HTMLElement&&HTMLElement.prototype){av(HTMLElement.prototype,{contains:function(J){return !!(this.compareDocumentPosition(J)&16)}},false)}av(Object,{keys:function(a5){var Q=[],J;for(J in a5){if(a5.hasOwnProperty(J)){Q.push(J)}}return Q}},false);
/* class */
var aE=function(a6,a8){var J=a8.__init||function(){},a5=a8.__static||{},a7=a8.__extends,Q=J.prototype;av(Q,o);(a(a7)?a7:(a7?[a7]:[])).each(function(a9){av(Q,a9.prototype);J.__parent=a9});av(J,a5);["__init","__static","__extends"].each(function(a9){delete a8[a9]});av(Q,a8);Q.constructor=J;J.__name=a6;au[a6]=J;return J},o={fireEvent:function(){var J=O(arguments),a5="on"+I(J.shift()),Q=this[a5];if(aN(J)){J.push(this)}return Q?Q.apply(this,J):false},isInstanceOf:function(){return this.constuctor.__name},set:function(Q,J){var a5=this;if(H(Q)){return av(a5,Q)}a5[Q]=J;return a5}};au.defineClass=aE;
/* strings */
var aa=function(J,Q){return J.indexOf(Q)!==-1},aS=function(J){return J.replace(/\s{2,}/g," ").trim()},I=function(J,Q){return J.replace(Q?/^\s*[a-z]/:/(^|\s+)[a-z]/g,function(a5){return a5.toUpperCase()})},g=function(J){return J.replace(/-([a-z])/g,function(Q,a5){return a5.toUpperCase()})},aW=function(a7){var J=a7.match(/[\d]{1,3}/g),a5=[],Q=0;for(Q;Q<3;Q++){var a6=(J[Q]-0).toString(16);a5.push(a6.length===1?"0"+a6:a6)}return"#"+a5.join("")},ah=function(a6,a7){var a5=a6.match(/^#([\w]{1,2})([\w]{1,2})([\w]{1,2})$/),J=[],Q=1;for(Q;Q]*>/g,"")}J=J.replace(/\s+/g,"").split(",").map(function(a5){return a5+" |"+a5+">|/"+a5+">"}).join("|");return Q.replace(new RegExp("<(?!"+J+")[^>]+>","g"),"")},aF=function(a5,Q){var J;while(J=/%\{\s*([^\}\s]+)\s*\}/.exec(a5)){a5=a5.replace(J[0],Q[J[1]]||"??")}return a5},f=function(Q){var a5=ao("div",{setHTML:Q}),J=[];O(R(a5,"script")).each(function(a6){J.push(ay["eval"](a6.innerHTML))});return J};av(au,{contains:aa,normalize:aS,capitalize:I,camelize:g,parseColour:aU,stripTags:aO,bindData:aF,evalScripts:f});
/* elements */
var aX=function(J,Q){J=aC(J);if(a4(J,Q)){return}J.className+=J.className?" "+Q:Q},aZ=function(J,a5){J=aC(J);if(!J.className){return}var Q=new RegExp("(^|\\s)"+a5+"(\\s|$)");J.className=aS(J.className.replace(Q," "))},a4=function(J,Q){return(" "+(aC(J)).className+" ").indexOf(Q)!==-1},z=function(J,Q){J=aC(J);if(a4(J,Q)){aZ(J,Q)}else{aX(J,Q)}},aC=function(J){return typeof J==="string"?K.getElementById(J):J},R=function(Q,J){return(J?aC(Q):K).getElementsByTagName(J||Q)},ao=function(bg,be){var Q;if(!/[#:\.]/.test(bg)){Q=K.createElement(bg),ar;for(ar in be){switch(ar){case"setHTML":Q.innerHTML=be[ar];break;case"setText":Q.appendChild(K.createTextNode(be[ar]));break;case"class":Q.className=be[ar];break;case"style":Q.style.cssText=be[ar];break;default:Q.setAttribute(ar,be[ar])}}}else{var bg=bg.trim(),a6="__JELLY_CE__",bd=[],a5;while(a5=/('|")([^\1]*?)\1/.exec(bg)){bg=bg.replace(a5[0],a6);bd.push(a5[2])}bg=bg.replace(/\s*(:|,)\s*/g,"$1");var a8=bg.split(" "),ba=a8.shift(),J=ba.indexOf("#")!==-1,bf=ba.indexOf(".")!==-1,bb="div",a7={},bc=null,a9;if(J||bf){a9=J?ba.split("#"):ba.split(".");bb=a9.shift()||bb;a7[J?"id":"class"]=a9.join(" ")}else{bb=ba}if(a8[0]){a8[0].split(",").each(function(bh){bh=bh.split(":");var bi=bh[1]===a6?bd.shift():bh[1];if(bh[0]==="@"){bc=bi}else{a7[bh[0]]=bi}})}Q=ao(bb.toLowerCase(),a7)}return be===true?{elem:Q,ref:bc}:Q},a2=function(){var J=O(arguments),a5={},Q,a6=function(a7){if(a7&&H(a7)){if(az(a7.root)){for(var a8 in a7){if(a(a7[a8])){var bc=a7[a8][0].nodeName.toLowerCase();a5[bc]=a5[bc]||[];a7[a8].each(function(bd){a5[bc].push(bd)})}else{if(a8!=="root"){a5[a8]=a7[a8]}}}return a7.root}else{if(az(a7)){return a7}}}else{if(!aY(a7)){return}}var bb=ao(a7,true),ba=bb.elem,a9=ba.nodeName.toLowerCase();a5[a9]=a5[a9]||[];a5[a9].push(ba);if(bb.ref){a5[bb.ref]=ba}return ba};a5.root=Q=a6(J.shift());J.each(function(a7){if(!a(a7)){Q=Q.appendChild(a6(a7))}else{a7.each(function(a8){Q.appendChild(a6(a8))})}});return a5},aD=function(Q,a6){Q=aC(Q);var a5=Q.parentNode,J=Q.nextSibling;a6.appendChild(Q);return J?a5.insertBefore(a6,J):a5.appendChild(a6)},l=function(Q,a5,J){Q=aC(Q);if(Q){return a5.call(J||Q,Q)}return Q},ak=function(Q,J){Q=aC(Q);return Q.parentNode.replaceChild(J,Q)},y=function(J){J=aC(J);return J.parentNode.removeChild(J)},aV=function(Q,J){Q=aC(Q);return(aC(J)||K.body).appendChild(Q)},j=function(Q,J){if(!(Q=aC(Q))||!(J=aC(J))){return false}if(J.firstChild){return J.insertBefore(Q,J.firstChild)}else{return J.appendChild(Q)}},an=function(Q,J){J=aC(J);return J.parentNode.insertBefore(aC(Q),J)},C=function(a5,J){if(!(a5=aC(a5))||!(J=aC(J))){return false}var Q=au.getNext(J);if(Q){return J.parentNode.insertBefore(a5,Q)}else{return J.parentNode.appendChild(a5)}},aT=function(J){J=J.firstChild;while(J&&J.nodeType!==1){J=J.nextSibling}return J},v=function(J){J=J.lastChild;while(J&&J.nodeType!==1){J=J.previousSibling}return J},M=function(J){J=J.nextSibling;while(J&&J.nodeType!==1){J=J.nextSibling}return J},at=function(J){J=J.previousSibling;while(J&&J.nodeType!==1){J=J.previousSibling}return J},D=function(J){var Q=[],J=J.firstChild;while(J){if(J.nodeType===1){Q[Q.length]=J}J=J.nextSibling}return Q},aM=function(Q){Q=aC(Q);var a8=[0,0];if(!Q){return a8}if("getBoundingClientRect" in Q){var a5=Q.getBoundingClientRect(),J=A(),a7=a5.left,a6=a5.top;a8=[a7+J[0],a6+J[1]]}else{a8=[Q.offsetLeft,Q.offsetTop];while(Q=Q.offsetParent){a8[0]+=Q.offsetLeft;a8[0]+=parseInt(aG(Q,"border-left-width"))||0;a8[1]+=Q.offsetTop;a8[1]+=parseInt(aG(Q,"border-top-width"))||0}}return a8},am=function(J,a6,a5,Q){J=aC(J);Q=Q||"px";J.style.left=a6+Q;J.style.top=a5+Q},w=function(J){return aM(J)[0]},aj=function(J,a5,Q){(aC(J)).style.left=a5+(Q||"px")},t=function(J){return aM(J)[1]},ai=function(J,a5,Q){(aC(J)).style.top=a5+(Q||"px")},s=function(){if(!aA(aR.hasAttribute)&&aB){return function(Q,J){switch(J){case"class":return Q.className||null;case"href":case"src":return Q.getAttribute(J,2)||null;case"style":return Q.getAttribute(J).cssText.toLowerCase()||null;case"for":return Q.attributes[J].nodeValue||null}return Q.getAttribute(J)||null}}return function(Q,J){return Q.getAttribute(J)}}(),aG=function(J,a5){var Q,a5=g(a5);if(a5==="opacity"){if(!aA(J.__opacity)){J.__opacity=1}return J.__opacity}if(J.style[a5]){return J.style[a5]}else{if("getComputedStyle" in ay){return ay.getComputedStyle(J,null)[a5]}else{if("currentStyle" in J){return J.currentStyle[a5]}}}},E=function(a5,Q,J){var a7=function(a9,a8){if(a9==="float"){a9="cssFloat"}if(a9==="opacity"){B(a5,a8)}else{a5.style[g(a9)]=a8}},a6;if(H(Q)){for(a6 in Q){a7(a6,Q[a6])}}else{if(J){a7(Q,J)}}},B=function(){if("filters" in aR){return function(J,Q){if(J.__opacity===undefined){J.__opacity=1}J.style.filter=Q===1?"":"alpha(opacity="+(Q*100)+")";J.__opacity=Q}}return function(J,Q){if(J.__opacity===undefined){J.__opacity=1}J.style.opacity=J.__opacity=Q}}(),P=function(a5,Q,a6){var J=aP,a7=J.ns;if(!(a5=aC(a5))){return}if(!(a7 in a5)){a5[a7]=ag();J[a5[a7]]={}}J[a5[a7]][Q]=a6},ax=function(a5,Q){var J=aP,a6=J.ns;if(!(a5=aC(a5))){return}if(a6 in a5&&a5[a6] in J){return J[a5[a6]][Q]}return null},V=function(a5,Q){var J=aP,a6=J.ns;if(!(a5=aC(a5))){return}if(a6 in a5&&a5[a6] in J){delete J[a5[a6]][Q]}},aP={ns:"jelly_"+(+new Date)},ag=function(){var J=0;return function(){return ++J}}();av(au,{addClass:aX,removeClass:aZ,hasClass:a4,toggleClass:z,getElements:R,getElement:aC,createElement:ao,createBranch:a2,wrapElement:aD,withElement:l,replaceElement:ak,removeElement:y,insertElement:aV,insertTop:j,insertBefore:an,insertAfter:C,getFirst:aT,getLast:v,getNext:M,getPrevious:at,getChildren:D,getXY:aM,setXY:am,getX:w,setX:aj,getY:t,setY:ai,getAttribute:s,getStyle:aG,setStyle:E,setOpacity:B,storeData:P,retrieveData:ax,removeData:V});
/* events */
var Z=function(a8,a5,Q){a8=aC(a8);var J=a5==="mouseenter",a6=a5==="mouseleave",a9,a7;if(a8===K&&a5==="domready"){return q(Q)}if(!N){a9=function(ba){Q.call(a8,e(ba))}}if(J||a6){a9=function(ba){ba=e(ba);if(!G.call(a8,ba)){return}Q.call(a8,ba)};a5=J?"mouseover":"mouseout"}a7=[a8,a5,a9||Q];m.push(a7);if(N){a8.addEventListener(a5,a9||Q,false)}else{a8.attachEvent("on"+a5,a9)}return a7},ac=function(J){if(J){if(!a(J)){return X(J)}if(N){J[0].removeEventListener(J[1],J[2],false)}else{J[0].detachEvent("on"+J[1],J[2])}}},m=[],L=function(){for(var J=0,Q;m[J];J++){Q=m[J];if(Q[0]!==ay&&Q[1]!=="unload"){ac(Q)}}},e=function(){if(N){return function(J){return J}}return function(J){J=ay.event;J.target=J.srcElement;J.relatedTarget=function(){switch(J.type){case"mouseover":return J.fromElement;case"mouseout":return J.toElement}}();J.stopPropagation=function(){J.cancelBubble=true};J.preventDefault=function(){J.returnValue=false};J.pageX=J.clientX+aR.scrollLeft;J.pageY=J.clientY+aR.scrollTop;return J}}(),G=function(a7){var a6,a5;if(a7.relatedTarget){try{a6=a7.relatedTarget;if(a6.nodeType!==1||a6===this){return false}var Q=this.getElementsByTagName("*"),a8=Q.length,a5=0;for(a5;a8>a5;a5++){if(a6===Q[a5]){return false}}}catch(J){}}return true},n=function(J){J=e(J);J.stopPropagation();J.preventDefault();return J};av(au,{addEvent:Z,removeEvent:ac,stopEvent:n,fixEvent:e});Z(ay,"unload",L);
/* dom ready */
(function(){var Q=au.DomReady={ready:false,handlers:{},add:function(a9,a8){var a8=a8||++a5;Q.handlers[a8]=a9;return a8},remove:function(a8){delete Q.handlers[a8]},fire:function(){if(Q.ready){return}Q.ready=true;clearTimeout(a6);for(var a9 in Q.handlers){try{Q.handlers[a9]()}catch(a8){ab(a8)}}}},a5=0,a6,a7=function(){if(K.readyState==="complete"){K.detachEvent("onreadystatechange",a7);Q.fire()}},J=function(){try{aR.doScroll("left")}catch(a8){a6=setTimeout(J,10);return}Q.fire()};if(N){Z(K,"DOMContentLoaded",Q.fire)}else{K.attachEvent("onreadystatechange",a7);if(ay===top){a6=setTimeout(J,0)}}Z(ay,"load",Q.fire)})();var r=au.DomReady,q=function(Q,J){return r.add(Q,J||null)},X=function(J){r.remove(J)};av(au,{addDomReady:q,removeDomReady:X});
/* cookies */
av(au,{getCookie:function(Q){var J=new RegExp(Q+"=([^; ]+)").exec(K.cookie);return J?unescape(J[1]):null},setCookie:function(Q,a7,J,a9,a6,a8){if(J){var a5=(+new Date)+((1000*60*60*24)*J);J=new Date(a5).toUTCString()}K.cookie=Q+"="+escape(a7)+(J?";expires="+J:"")+(a9?";path="+a9:"")+(a6?";domain="+a6:"")+(a8?";secure":"")},removeCookie:function(J,a5,Q){if(au.getCookie(J)){K.cookie=J+"="+(a5?";path="+a5:"")+(Q?";domain="+Q:"")+(";expires="+new Date(0))}}});
/* flash */
av(au,{getFlashVersion:function(){var J={major:0,build:0},a5=navigator.plugins,a8,Q;if(a5&&H(a5["Shockwave Flash"])){a8=a5["Shockwave Flash"].description;if(a8!==null){Q=a8.replace(/^[^\d]+/,"");version.major=parseInt(Q.replace(/^(.*)\..*$/,"$1"),10);version.build=parseInt(Q.replace(/^.*r(.*)$/,"$1"),10)}}else{if(aB){try{var a7=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");a8=a7.GetVariable("$version");if(a8!==null){Q=a8.replace(/^\S+\s+(.*)$/,"$1").split(",");version.major=parseInt(Q[0],10);version.build=parseInt(Q[2],10)}}catch(a6){}}}return version},createFlashObject:function(a7,a5,J,a9,a8,a6,Q){var a8=a8||{};a6=a6||{},attrs=Q||{},a9=a9||'You need Adobe Flash Player installed to view this content',data=[],ar,output=""},embedFlashObject:function(a6,a8,a5,J,a9,a7,Q){a6=aC(a6);a6.innerHTML=au.createFlashObject(a8,a5,J,a6.innerHTML,a9||{},a7||{},Q||{})}});
/* misc utilities */
var ae=function(){if(aA(aR.clientWidth)&&aR.clientWidth!==0){return function(){return[aR.clientWidth,aR.clientHeight]}}return function(){return[K.body.clientWidth||0,K.body.clientHeight||0]}}(),A=function(){if(aA(ay.pageYOffset)){return function(){return[ay.pageXOffset,ay.pageYOffset]}}return function(){if(aA(aR.scrollTop)&&(aR.scrollTop>0||aR.scrollLeft>0)){return[aR.scrollLeft,aR.scrollTop]}return[K.body.scrollLeft,K.body.scrollTop]}}(),aw=function(a5){a5=a5||ay.location;var a6={};if(/\?/.test(a5.href)){var J=a5.href.split("?")[1].split("&"),Q=J.length-1,a7;do{a7=J[Q].split("=");a6[a7[0]]=decodeURIComponent(a7[1].replace(/\+/g,"%20"))}while(Q--)}return a6},af=function(){var J=function(a5,a6){if(!a5){return}if(callbackFilter){a6=callbackFilter.call(a6,a6)}data.push(a5+"="+encodeURIComponent(a6).replace(/%20/g,"+"))},Q=function(a7){if(!az(a7)||!/^(input|textarea|select)$/i.test(a7.nodeName)){return}var a6=a7.type.toLowerCase(),a5=a7.name,a8=a7.value;switch(a6){case"checkbox":if(a7.checked){J(a5,a8||"on")}break;case"radio":if(a7.checked){J(a5,a8)}break;default:J(a5,a8)}};args=O(arguments),callbackFilter=aL(args[args.length-1])?args.pop():null;data=[];args.each(function(a5){if(H(a5)&&ap(a5.length)){(a(a5)?a5:O(a5)).each(Q)}else{if(H(a5,true)){for(var a6 in a5){J(a6,a5[a6])}}else{if(aY(a5)||az(a5)){var a7=aC(a5);if(a7){Q(a7);au.Q(a7,"textarea, input, select").each(Q)}else{data.push(a5)}}}}});return data.join("&")},aJ=function(){var J=["var J=JELLY"],a5,Q=1;for(a5 in au){J[Q++]=a5+"=J."+a5}return J.join(",")+";"};av(au,{getViewport:ae,getWindowScroll:A,parseQuery:aw,buildQuery:af,unpack:aJ});
/* page init */
if(aK.ie6){try{K.execCommand("BackgroundImageCache",false,true)}catch(a3){}}var T=["unknown"],ar;for(ar in aK){if(aK[ar]){if(T[0]==="unknown"){T=[ar]}else{T.push(ar)}}}aX(aR,"js "+T.join(" "));
/* selector engine */
(function(){var bw=function(bB){bf[bf.length]=bB},bA=function(bC){for(var bB=0,bD=bC.length;bB|~/.test(bC)){bE.type=a6;bE.val=bC}else{if(/:not\(/.test(bC)){bE=bb(bC.replace(/\:not\(|\)$/g,""));bE.not=true}else{if(/^:/.test(bC)){var bD=bC.replace(/^:|\)$/g,"").split("(");bE.type=a7;bE.kind=bD[0];bE.val=bD[1]}}}}}}}return bE},bv=function(bC){var bK=[],bE=aS(bC.replace(/(>|~(?!=)|\+(?!\d))/g," $1 ")).split(" "),bJ={mode:bq,type:bp,val:"*"},bB="getElementsByClassName" in K,bI=false;for(var bG=0,bH;bGbN.start){if(bH){bD(true)}}else{bD(((bN.start-bJ[bI].nodeIndex)%bN.jump===0)!==bH)}}}}}bA(bO);return bN.direction==="neg"?bQ.reverse():bQ},bt={"nth-child":function(bC,bB){return bx(bC,bB.val,false,false,bB.not)},"nth-of-type":function(bC,bB){return bx(bC,bB.val,true,false,bB.not)},"nth-last-child":function(bC,bB){return bx(bC,bB.val,false,true,bB.not)},"nth-last-of-type":function(bC,bB){return bx(bC,bB.val,true,true,bB.not)},"first-of-type":function(bC,bB){return bx(bC,"1",true,false,bB.not)},"last-of-type":function(bC,bB){return bx(bC,"1",true,true,bB.not)},"only-child":function(bB){return !M(bB)&&!at(bB)},"only-of-type":function(bE){var bC=R(bE.parentNode,bE.nodeName);if(bC.length===1&&bC[0].parentNode===bE.parentNode){return true}else{for(var bB=true,bG=bC.length,bD=0,bF=0;bD1){return false}}}return true}},"first-child":function(bB){return !at(bB)},"last-child":function(bB){return !M(bB)},checked:function(bB){return bB.checked},enabled:function(bB){return !bB.disabled},disabled:function(bB){return bB.disabled},empty:function(bB){return !bB.firstChild},lang:function(bC,bB){return bC.getAttribute("lang")===bB.val},root:function(bB){return bB===rootElement},target:function(bB){var bC=ay.location.href.split("#")[1]||null;return bB.id===bC||bB.name===bC}},bj=function(){for(var bB=0,bD=bo.length,bC;bB"){bB=true;continue}if(!bf[0]){return[]}bB=null;ba=0;bo=bf}if(bK.postFilter){return bz(bc(bo))}return bz(bo)},a5=function(bC,bB){try{return bz(O(bB?bC.querySelectorAll(bB):K.querySelectorAll(bC)))}catch(bD){aH(bD)}},bz=function(bC){for(var bB in bu){bC[bB]=bu[bB]}return bC},bu={};["addClass","removeClass","setStyle","addEvent"].each(function(bB){bu[bB]=function(){var bC=O(arguments),bE=this.length,bD=0;for(bD;bD=200&&bd<300)||bd===304||(bd===undefined&&aK.webkit);if(be){bc.fireEvent("success",bb);if(ba){ba.call(bc,bb)}}else{bc.fireEvent("fail",bb)}if(bc.cleanUp){bc.xhr=null}bc.inProgress=false}};for(var a9 in bc.requestHeaders){bb.setRequestHeader(a9,bc.requestHeaders[a9])}bb.setRequestHeader("X-Requested-With","XMLHttpRequest");bc.feedback.start();bc.timer=setTimeout(function(){bb.abort();bc.fireEvent("timeout",bb);bc.inProgress=false},bc.timeout||J.timeout);bc.inProgress=true;bb.send(a7);bc.fireEvent("request",bb);return true},post:function(Q,a5,a6){return this.send("post",Q+"?"+(a5||"empty"),a6)},get:function(Q,a5){return this.send("get",Q,a5)},getXHR:function(){if("XMLHttpRequest" in ay){return function(){return new XMLHttpRequest()}}return function(){var a5=false;try{a5=new ActiveXObject("Msxml2.XMLHTTP")}catch(Q){try{a5=new ActiveXObject("Microsoft.XMLHTTP")}catch(Q){}}return a5}}()})})();
/* easings */
au.easings={linear:function(a6,J,Q,a5){return Q*a6/a5+J},quadIn:function(a6,J,Q,a5){return Q*(a6/=a5)*a6+J},quadOut:function(a6,J,Q,a5){return -Q*(a6/=a5)*(a6-2)+J},quadInOut:function(a6,J,Q,a5){if((a6/=a5/2)<1){return Q/2*a6*a6+J}return -Q/2*((--a6)*(a6-2)-1)+J},cubicIn:function(a6,J,Q,a5){return Q*(a6/=a5)*a6*a6+J},cubicOut:function(a6,J,Q,a5){return Q*((a6=a6/a5-1)*a6*a6+1)+J},cubicInOut:function(a6,J,Q,a5){if((a6/=a5/2)<1){return Q/2*a6*a6*a6+J}return Q/2*((a6-=2)*a6*a6+2)+J},quartIn:function(a6,J,Q,a5){return Q*(a6/=a5)*a6*a6*a6+J},quartOut:function(a6,J,Q,a5){return -Q*((a6=a6/a5-1)*a6*a6*a6-1)+J},quartInOut:function(a6,J,Q,a5){if((a6/=a5/2)<1){return Q/2*a6*a6*a6*a6+J}return -Q/2*((a6-=2)*a6*a6*a6-2)+J},quintIn:function(a6,J,Q,a5){return Q*(a6/=a5)*a6*a6*a6*a6+J},quintOut:function(a6,J,Q,a5){return Q*((a6=a6/a5-1)*a6*a6*a6*a6+1)+J},quintInOut:function(a6,J,Q,a5){if((a6/=a5/2)<1){return Q/2*a6*a6*a6*a6*a6+J}return Q/2*((a6-=2)*a6*a6*a6*a6+2)+J},sineIn:function(a6,J,Q,a5){return -Q*Math.cos(a6/a5*(Math.PI/2))+Q+J},sineOut:function(a6,J,Q,a5){return Q*Math.sin(a6/a5*(Math.PI/2))+J},sineInOut:function(a6,J,Q,a5){return -Q/2*(Math.cos(Math.PI*a6/a5)-1)+J},expoIn:function(a6,J,Q,a5){return(a6==0)?J:Q*Math.pow(2,10*(a6/a5-1))+J},expoOut:function(a6,J,Q,a5){return(a6==a5)?J+Q:Q*(-Math.pow(2,-10*a6/a5)+1)+J},expoInOut:function(a6,J,Q,a5){if(a6==0){return J}if(a6==a5){return J+Q}if((a6/=a5/2)<1){return Q/2*Math.pow(2,10*(a6-1))+J}return Q/2*(-Math.pow(2,-10*--a6)+2)+J},circIn:function(a6,J,Q,a5){return -Q*(Math.sqrt(1-(a6/=a5)*a6)-1)+J},circOut:function(a6,J,Q,a5){return Q*Math.sqrt(1-(a6=a6/a5-1)*a6)+J},circInOut:function(a6,J,Q,a5){if((a6/=a5/2)<1){return -Q/2*(Math.sqrt(1-a6*a6)-1)+J}return Q/2*(Math.sqrt(1-(a6-=2)*a6)+1)+J},elasticIn:function(a8,J,Q,a5,a9,a6){if(a8==0){return J}if((a8/=a5)==1){return J+Q}if(!a6){a6=a5*0.3}if(!a9){a9=1}if(a9 -1) && (url.indexOf("to") >-1)) {
trig.next('.toggle_container').find('.remove').show();
trig.next('.toggle_container').slideToggle(1);
trig.addClass('trigger_active');
}
}
else {
// categoryName = trig.next('.toggle_container').find('.SubDeviceNav select').eq(0).attr("name");
categoryID = trig.next('.toggle_container').next('input[type=hidden]').val();
// categoryID = encodeURIComponent($('#' + categoryName).val());
escapeCategoryId = encodeURIComponent(categoryID);
if (categoryID != undefined && url.contains(escapeCategoryId)) {
trig.next('.toggle_container').find('.remove').show();
trig.next('.toggle_container').slideToggle(1);
trig.addClass('trigger_active');
}
}
});
}
// cqBlogComment
$(".form.sales .required").each(function () {
if ($(this).is('textarea')) {
$(this).prev("label").append("*");
}
});
$('.imageDownloadTable').fancybox({
height: 'auto',
closeBtn: false,
padding: 20,
type: 'inline',
href: '#downloadImageList',
//type: 'ajax',
//href: 'download_image.html',
afterShow: function () {
addFormStyles();
$('.fancybox-outer').before('');
$('.fancyClose').click(function () {
$.fancybox.close();
});
$('input[type="checkbox"].selectAll').change(function () {
if ($(this).next().hasClass('checked')) {
$('.downloadImage .check.option .checkbox:not(".checked")').trigger('click');
$('.downloadImage input[type="checkbox"].selectAll').parent().find('label').text(selectNoneText);
} else {
$('.downloadImage .check.option .checkbox.checked').trigger('click');
$('.downloadImage input[type="checkbox"].selectAll').parent().find('label').text(selectAllText);
}
});
},
afterClose: function () {
//$('.downloadImage table tbody').html('');
}
});
//cqVoting
$('.contentVoting').each(function () {
var target = $(this).has('.voting').find('.voting').first();
handleVoting(target);
var data = encodeURIComponent('url') + "=" + encodeURIComponent($(target).data('resource-path'));
ajaxServletCall(data, target);
});
}); // end: doc.ready();
function ajaxServletCall(data, target) {
$.ajax({
url: $(target).data('servlet-url'),
data: data,
type: "GET",
dataType: "json",
success: function (data, status, jqxhr) {
// post-servlet work
$(target).find('.like span').html("(" + data.like + ")");
$(target).find('.dislike span').html("(" + data.dislike + ")");
},
fail: function (jqxhr, status) {
throw status;
}
});
}
function voteClickHandler(_this, target) {
var resourcePath = $(target).data('resource-path');
var data = encodeURIComponent('vote') + "=" + encodeURIComponent($(_this).attr("class"))
+ "&" + encodeURIComponent('url') + "=" + encodeURIComponent(resourcePath);
ajaxServletCall(data, target);
};
function handleVoting(target) {
target.find("a").click(function (e) {
e.preventDefault();
voteClickHandler(this, target);
});
};
function addQueryParameter(oldURL, param) {
// var param = $('#filterSearchField2').val().trim();
var newURL = "";
param = "q=" + param;
if (oldURL.indexOf("?") !== -1) {
var posOfQ = oldURL.indexOf("q=");
if (posOfQ !== -1) {
var indexOfAND = oldURL.substring(posOfQ).indexOf("&");
if (indexOfAND === -1) {
indexOfAND = oldURL.substring(posOfQ).length;
}
newURL = oldURL.substring(0, posOfQ) + param + oldURL.substring(posOfQ + indexOfAND);
}
else {
param = "&" + param;
newURL = oldURL + param;
}
}
else {
param = "?" + param;
newURL = oldURL + param;
}
return newURL;
};
function toggleAllowBlankLinkText(box) {
var panel = box.findParentByType('panel');
var linkTextField = panel.findByType('textfield')[1];
var checked = box.getValue()[0];
if (checked === "yes") {
linkTextField.setDisabled(false);
panel.doLayout();
} else {
linkTextField.setDisabled(true);
panel.doLayout();
}
};
//Career Builder forms validation.
//1: Search
function cbSearchValidation() {
var flag = false;
if ($("#searchkeywords").val().length == 0) {
$("#searchkeywords").addClass('error');
$("#cbSearchForm").addClass('error');
flag = true;
}
else {
$("#searchkeywords").removeClass('error');
}
if ($("#searchjobtype").val() == -1) {
$("#searchjobtype").parent().addClass('error');
$("#cbSearchForm").addClass('error');
flag = true;
}
else {
$("#searchjobtype").parent().removeClass('error');
}
if ($("#searchlocation").val() == -1) {
$("#searchlocation").parent().addClass('error');
$("#cbSearchForm").addClass('error');
flag = true;
}
else {
$("#searchlocation").parent().removeClass('error');
}
if (flag === true) {
return false;
}
else {
$("#cbSearchForm").removeClass('error');
$("#cbSearchForm").submit();
}
}
function validateDownload() {
var flag = false;
if ($("#imagedown input:checked").length > 0) {
flag = true;
}
;
if (flag === false) {
return false;
}
else {
//$("#imagedown").submit();
$.fancybox.close();
}
}
function cbApplyJobValidation() {
var flag = false;
var email_pattern = '^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$';
$("#submitforjob .selectWrapper .wrapper input.required, #submitforjob .selectWrapper .wrapper select.required").each(function () {
if ($(this).val().length == 0 || $(this).val() == -1) {
$(this).not("span").parent().parent().addClass("error");
$("#submitforjob").addClass('error');
flag = true;
}
else {
$(this).not("span").parent().parent().removeClass("error");
$("#submitforjob").removeClass('error');
}
if (!$("#ApplicantEmail").val().match(email_pattern)) {
$("#ApplicantEmail").parent().parent().addClass("error");
$("#submitforjob").addClass('error');
flag = true;
}
else {
$("#ApplicantEmail").parent().parent().removeClass("error");
$("#submitforjob").removeClass('error');
}
});
var filename = $("#fileName").val();
var allowedExtensions = ['docx', 'doc', 'rtf', 'txt', 'pdf'];
if (($("#fileName").val() == "") || ($.inArray(filename.split('.').pop().toLowerCase(), allowedExtensions) == -1) /*|| ($("#fileName").val() != "" && $("#fileName")[0].files[0].size / 1024 > 500)*/) {
$("#fileName").parent().parent().parent().addClass("error");
$("#submitforjob").addClass('error');
flag = true;
} else {
$("#fileName").parent().parent().parent().removeClass("error");
$("#submitforjob").removeClass('error');
}
if (flag === true) {
return false;
}
else {
$("#submitforjob").submit();
}
}
function formFieldIsRequired(field, path) {
if (hasRequiredField(path) && field.getValue() != "email") {
field.setValue("required");
}
};
function checkFileUpload(field, path) {
if (path) {
var resourceInfo = CQ.HTTP.eval(path + ".1.json");
if (resourceInfo["formFile"] != null && resourceInfo["formFile"] != undefined) {
field.hide();
}
else {
field.show();
}
}
};
function toggleFieldSet(box) {
var panel = box.findParentByType('panel');
var fieldSet = panel.findByType('textfield');
var fieldSetLength = fieldSet.length;
var textField = fieldSet[fieldSetLength - 1];
var show = box.getValue();
if (show == "none") {
textField.hide();
} else {
textField.show();
panel.doLayout();
}
};
function isNotRequired(editRollover) {
var result = true;
if (editRollover != null && editRollover != undefined) {
var path = editRollover.path;
if (hasRequiredField(path)) {
result = false;
alert(CQ.I18n.getMessage("cqSalesforceFormGeneratorDeleteMessage"));
}
}
return result;
};
function hasRequiredField(path) {
var found = false;
if (path) {
var resourceInfo = CQ.HTTP.eval(path + ".json");
var attributes = resourceInfo["attributes"];
if (attributes != null && attributes != undefined && (attributes.indexOf("\"submit\"") != -1 || attributes.indexOf("required")) != -1) {
found = true;
} else {
var resJSON = CQ.HTTP.eval(path + ".1.json");
if (resJSON["par"] != null && resJSON["par"] != undefined && resJSON["par"] != "") {
var childrenJSON = CQ.HTTP.eval(path + "/par.1.json");
for (var key in childrenJSON) {
if (typeof childrenJSON[key] == 'object') {
found = hasRequiredField(path + "/par/" + key);
}
if (found) {
break;
}
}
}
}
}
return found;
};
function SSOCall(target, targetURL, params) {
var userUrl = location.href;
var currentPage = unescape(userUrl);
var newWindow;
$.ajax({
type: 'GET',
url: "/servlets/ssoLogin",
cache: false,
data: {
'currentPage': currentPage,
'targetURL': targetURL,
'params': params
},
success: function (response) {
if ((target == '_self') || (navigator.userAgent.search(/iPhone|iPad|iPod|safari/i) != -1 && navigator.userAgent.indexOf('Chrome') == -1)) {
window.location.href = response;
}
else {
newWindow = window.open('about:blank');
newWindow.location.replace(response);
}
}
});
};
function servletTest(countryShortcut, currentPage) {
$.get('/servlets/langredirection',
{countryShortcut: countryShortcut, currentPage: currentPage},
function (text) {
response = text;
alert(response);
});
}
function cqBlogCommentValidate(formName)
{
console.log("cqBlogCommentValidate start!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
console.log("formName: ", formName);
var valid = true;
var validationMessage = '';
var ulErrors = $(formName).find("ul.errorMsg");
var liError1 = $(ulErrors).find("li.cqBlogCommentError1");
var liError2 = $(ulErrors).find("li.cqBlogCommentError2");
var liError3 = $(ulErrors).find("li.cqBlogCommentError3");
//var inputName= $(formName).find("input.inputName");
//var inputEmail= $(formName).find("input.inputEmail");
//var inputQuestion= $(formName).find("input.inputQuestion");
var email_pattern = '^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$';
$("#name").val($("#name").val().trim());
$("#email").val($("#email").val().trim());
$("#question").val($("#question").val().trim());
if( $("#name").val().length == 0)
{
valid = false;
$("#name").addClass('error');
$(liError1).removeClass("hidden");
}
else
{
$("#name").removeClass('error');
$(liError1).addClass("hidden");
}
if( $("#question").val().length == 0)
{
valid = false;
$("#question").addClass('error');
$(liError2).removeClass("hidden");
}
else
{
$("#question").removeClass('error');
$(liError2).addClass("hidden");
}
if( $("#email").val().length == 0 || !$("#email").val().match(email_pattern))
{
valid = false;
$("#email").addClass('error');
$(liError3).removeClass("hidden");
}
else
{
$("#email").removeClass('error');
$(liError3).addClass("hidden");
}
if (valid == false)
{
$(formName).addClass('error');
}
else
{
$(formName).removeClass('error');
}
return valid;
}
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-geolocation-load
*/
;window.Modernizr=function(a,b,c){function t(a){i.cssText=a}function u(a,b){return t(prefixes.join(a+";")+(b||""))}function v(a,b){return typeof a===b}function w(a,b){return!!~(""+a).indexOf(b)}function x(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:v(f,"function")?f.bind(d||b):f}return!1}var d="2.6.2",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l={},m={},n={},o=[],p=o.slice,q,r={}.hasOwnProperty,s;!v(r,"undefined")&&!v(r.call,"undefined")?s=function(a,b){return r.call(a,b)}:s=function(a,b){return b in a&&v(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=p.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(p.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(p.call(arguments)))};return e}),l.geolocation=function(){return"geolocation"in navigator};for(var y in l)s(l,y)&&(q=y.toLowerCase(),e[q]=l[y](),o.push((e[q]?"":"no-")+q));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)s(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof enableClasses!="undefined"&&enableClasses&&(f.className+=" "+(b?"":"no-")+a),e[a]=b}return e},t(""),h=j=null,e._version=d,e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f