first commit
This commit is contained in:
38
js/jquery.ba-cond.js
Executable file
38
js/jquery.ba-cond.js
Executable file
@@ -0,0 +1,38 @@
|
||||
/*!
|
||||
* cond - v0.1 - 6/10/2009
|
||||
* http://benalman.com/projects/jquery-cond-plugin/
|
||||
*
|
||||
* Copyright (c) 2009 "Cowboy" Ben Alman
|
||||
* Licensed under the MIT license
|
||||
* http://benalman.com/about/license/
|
||||
*
|
||||
* Based on suggestions and sample code by Stephen Band and DBJDBJ in the
|
||||
* jquery-dev Google group: http://bit.ly/jqba1
|
||||
*/
|
||||
|
||||
(function($){
|
||||
'$:nomunge'; // Used by YUI compressor.
|
||||
|
||||
$.fn.cond = function() {
|
||||
var undefined,
|
||||
args = arguments,
|
||||
i = 0,
|
||||
test,
|
||||
callback,
|
||||
result;
|
||||
|
||||
while ( !test && i < args.length ) {
|
||||
test = args[ i++ ];
|
||||
callback = args[ i++ ];
|
||||
|
||||
test = $.isFunction( test ) ? test.call( this ) : test;
|
||||
|
||||
result = !callback ? test
|
||||
: test ? callback.call( this, test )
|
||||
: undefined;
|
||||
}
|
||||
|
||||
return result !== undefined ? result : this;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
12
js/jquery.ba-cond.min.js
vendored
Executable file
12
js/jquery.ba-cond.min.js
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
|
||||
* cond - v0.1 - 6/10/2009
|
||||
|
||||
* http://benalman.com/projects/jquery-cond-plugin/
|
||||
|
||||
*
|
||||
|
||||
* Copyright (c) 2009 "Cowboy" Ben Alman
|
||||
|
||||
* Licensed under the MIT license
|
||||
|
||||
469
js/jquery.slicknav.js
Executable file
469
js/jquery.slicknav.js
Executable file
@@ -0,0 +1,469 @@
|
||||
/*!
|
||||
* SlickNav Responsive Mobile Menu v1.0.3
|
||||
* (c) 2015 Josh Cope
|
||||
* licensed under MIT
|
||||
*/
|
||||
;(function ($, document, window) {
|
||||
var
|
||||
// default settings object.
|
||||
defaults = {
|
||||
label: 'MENU',
|
||||
duplicate: true,
|
||||
duration: 200,
|
||||
easingOpen: 'swing',
|
||||
easingClose: 'swing',
|
||||
closedSymbol: '►',
|
||||
openedSymbol: '▼',
|
||||
prependTo: 'body',
|
||||
parentTag: 'a',
|
||||
closeOnClick: false,
|
||||
allowParentLinks: false,
|
||||
nestedParentLinks: true,
|
||||
showChildren: false,
|
||||
removeIds: false,
|
||||
removeClasses: false,
|
||||
brand: '',
|
||||
init: function () {},
|
||||
beforeOpen: function () {},
|
||||
beforeClose: function () {},
|
||||
afterOpen: function () {},
|
||||
afterClose: function () {}
|
||||
},
|
||||
mobileMenu = 'slicknav',
|
||||
prefix = 'slicknav';
|
||||
|
||||
function Plugin(element, options) {
|
||||
this.element = element;
|
||||
|
||||
// jQuery has an extend method which merges the contents of two or
|
||||
// more objects, storing the result in the first object. The first object
|
||||
// is generally empty as we don't want to alter the default options for
|
||||
// future instances of the plugin
|
||||
this.settings = $.extend({}, defaults, options);
|
||||
|
||||
this._defaults = defaults;
|
||||
this._name = mobileMenu;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype.init = function () {
|
||||
var $this = this,
|
||||
menu = $(this.element),
|
||||
settings = this.settings,
|
||||
iconClass,
|
||||
menuBar;
|
||||
|
||||
// clone menu if needed
|
||||
if (settings.duplicate) {
|
||||
$this.mobileNav = menu.clone();
|
||||
//remove ids from clone to prevent css issues
|
||||
$this.mobileNav.removeAttr('id');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('id');
|
||||
});
|
||||
} else {
|
||||
$this.mobileNav = menu;
|
||||
|
||||
// remove ids if set
|
||||
$this.mobileNav.removeAttr('id');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('id');
|
||||
});
|
||||
}
|
||||
|
||||
// remove classes if set
|
||||
if (settings.removeClasses) {
|
||||
$this.mobileNav.removeAttr('class');
|
||||
$this.mobileNav.find('*').each(function (i, e) {
|
||||
$(e).removeAttr('class');
|
||||
});
|
||||
}
|
||||
|
||||
// styling class for the button
|
||||
iconClass = prefix + '_icon';
|
||||
|
||||
if (settings.label === '') {
|
||||
iconClass += ' ' + prefix + '_no-text';
|
||||
}
|
||||
|
||||
if (settings.parentTag == 'a') {
|
||||
settings.parentTag = 'a href="#"';
|
||||
}
|
||||
|
||||
// create menu bar
|
||||
$this.mobileNav.attr('class', prefix + '_nav');
|
||||
menuBar = $('<div class="' + prefix + '_menu"></div>');
|
||||
if (settings.brand !== '') {
|
||||
var brand = $('<div class="' + prefix + '_brand">'+settings.brand+'</div>');
|
||||
$(menuBar).append(brand);
|
||||
}
|
||||
$this.btn = $(
|
||||
['<' + settings.parentTag + ' aria-haspopup="true" tabindex="0" class="' + prefix + '_btn ' + prefix + '_collapsed">',
|
||||
'<span class="' + prefix + '_menutxt">' + settings.label + '</span>',
|
||||
'<span class="' + iconClass + '">',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'<span class="' + prefix + '_icon-bar"></span>',
|
||||
'</span>',
|
||||
'</' + settings.parentTag + '>'
|
||||
].join('')
|
||||
);
|
||||
$(menuBar).append($this.btn);
|
||||
$(settings.prependTo).prepend(menuBar);
|
||||
menuBar.append($this.mobileNav);
|
||||
|
||||
// iterate over structure adding additional structure
|
||||
var items = $this.mobileNav.find('li');
|
||||
$(items).each(function () {
|
||||
var item = $(this),
|
||||
data = {};
|
||||
data.children = item.children('ul').attr('role', 'menu');
|
||||
item.data('menu', data);
|
||||
|
||||
// if a list item has a nested menu
|
||||
if (data.children.length > 0) {
|
||||
|
||||
// select all text before the child menu
|
||||
// check for anchors
|
||||
|
||||
var a = item.contents(),
|
||||
containsAnchor = false;
|
||||
nodes = [];
|
||||
|
||||
$(a).each(function () {
|
||||
if (!$(this).is('ul')) {
|
||||
nodes.push(this);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($(this).is("a")) {
|
||||
containsAnchor = true;
|
||||
}
|
||||
});
|
||||
|
||||
var wrapElement = $(
|
||||
'<' + settings.parentTag + ' role="menuitem" aria-haspopup="true" tabindex="-1" class="' + prefix + '_item"/>'
|
||||
);
|
||||
|
||||
// wrap item text with tag and add classes unless we are separating parent links
|
||||
if ((!settings.allowParentLinks || settings.nestedParentLinks) || !containsAnchor) {
|
||||
var $wrap = $(nodes).wrapAll(wrapElement).parent();
|
||||
$wrap.addClass(prefix+'_row');
|
||||
} else
|
||||
$(nodes).wrapAll('<span class="'+prefix+'_parent-link '+prefix+'_row"/>').parent();
|
||||
|
||||
item.addClass(prefix+'_collapsed');
|
||||
item.addClass(prefix+'_parent');
|
||||
|
||||
// create parent arrow. wrap with link if parent links and separating
|
||||
var arrowElement = $('<span class="'+prefix+'_arrow">'+settings.closedSymbol+'</span>');
|
||||
|
||||
if (settings.allowParentLinks && !settings.nestedParentLinks && containsAnchor)
|
||||
arrowElement = arrowElement.wrap(wrapElement).parent();
|
||||
|
||||
//append arrow
|
||||
$(nodes).last().after(arrowElement);
|
||||
|
||||
|
||||
} else if ( item.children().length === 0) {
|
||||
item.addClass(prefix+'_txtnode');
|
||||
}
|
||||
|
||||
// accessibility for links
|
||||
item.children('a').attr('role', 'menuitem').click(function(event){
|
||||
//Ensure that it's not a parent
|
||||
if (settings.closeOnClick && !$(event.target).parent().closest('li').hasClass(prefix+'_parent')) {
|
||||
//Emulate menu close if set
|
||||
$($this.btn).click();
|
||||
}
|
||||
});
|
||||
|
||||
//also close on click if parent links are set
|
||||
if (settings.closeOnClick && settings.allowParentLinks) {
|
||||
item.children('a').children('a').click(function (event) {
|
||||
//Emulate menu close
|
||||
$($this.btn).click();
|
||||
});
|
||||
|
||||
item.find('.'+prefix+'_parent-link a:not(.'+prefix+'_item)').click(function(event){
|
||||
//Emulate menu close
|
||||
$($this.btn).click();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// structure is in place, now hide appropriate items
|
||||
$(items).each(function () {
|
||||
var data = $(this).data('menu');
|
||||
if (!settings.showChildren){
|
||||
$this._visibilityToggle(data.children, null, false, null, true);
|
||||
}
|
||||
});
|
||||
|
||||
// finally toggle entire menu
|
||||
$this._visibilityToggle($this.mobileNav, null, false, 'init', true);
|
||||
|
||||
// accessibility for menu button
|
||||
$this.mobileNav.attr('role','menu');
|
||||
|
||||
// outline prevention when using mouse
|
||||
$(document).mousedown(function(){
|
||||
$this._outlines(false);
|
||||
});
|
||||
|
||||
$(document).keyup(function(){
|
||||
$this._outlines(true);
|
||||
});
|
||||
|
||||
// menu button click
|
||||
$($this.btn).click(function (e) {
|
||||
e.preventDefault();
|
||||
$this._menuToggle();
|
||||
});
|
||||
|
||||
// click on menu parent
|
||||
$this.mobileNav.on('click', '.' + prefix + '_item', function (e) {
|
||||
e.preventDefault();
|
||||
$this._itemClick($(this));
|
||||
});
|
||||
|
||||
// check for enter key on menu button and menu parents
|
||||
$($this.btn).keydown(function (e) {
|
||||
var ev = e || event;
|
||||
if(ev.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
$this._menuToggle();
|
||||
}
|
||||
});
|
||||
|
||||
$this.mobileNav.on('keydown', '.'+prefix+'_item', function(e) {
|
||||
var ev = e || event;
|
||||
if(ev.keyCode == 13) {
|
||||
e.preventDefault();
|
||||
$this._itemClick($(e.target));
|
||||
}
|
||||
});
|
||||
|
||||
// allow links clickable within parent tags if set
|
||||
if (settings.allowParentLinks && settings.nestedParentLinks) {
|
||||
$('.'+prefix+'_item a').click(function(e){
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//toggle menu
|
||||
Plugin.prototype._menuToggle = function (el) {
|
||||
var $this = this;
|
||||
var btn = $this.btn;
|
||||
var mobileNav = $this.mobileNav;
|
||||
|
||||
if (btn.hasClass(prefix+'_collapsed')) {
|
||||
btn.removeClass(prefix+'_collapsed');
|
||||
btn.addClass(prefix+'_open');
|
||||
} else {
|
||||
btn.removeClass(prefix+'_open');
|
||||
btn.addClass(prefix+'_collapsed');
|
||||
}
|
||||
btn.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(mobileNav, btn.parent(), true, btn);
|
||||
};
|
||||
|
||||
// toggle clicked items
|
||||
Plugin.prototype._itemClick = function (el) {
|
||||
var $this = this;
|
||||
var settings = $this.settings;
|
||||
var data = el.data('menu');
|
||||
if (!data) {
|
||||
data = {};
|
||||
data.arrow = el.children('.'+prefix+'_arrow');
|
||||
data.ul = el.next('ul');
|
||||
data.parent = el.parent();
|
||||
//Separated parent link structure
|
||||
if (data.parent.hasClass(prefix+'_parent-link')) {
|
||||
data.parent = el.parent().parent();
|
||||
data.ul = el.parent().next('ul');
|
||||
}
|
||||
el.data('menu', data);
|
||||
}
|
||||
if (data.parent.hasClass(prefix+'_collapsed')) {
|
||||
data.arrow.html(settings.openedSymbol);
|
||||
data.parent.removeClass(prefix+'_collapsed');
|
||||
data.parent.addClass(prefix+'_open');
|
||||
data.parent.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(data.ul, data.parent, true, el);
|
||||
} else {
|
||||
data.arrow.html(settings.closedSymbol);
|
||||
data.parent.addClass(prefix+'_collapsed');
|
||||
data.parent.removeClass(prefix+'_open');
|
||||
data.parent.addClass(prefix+'_animating');
|
||||
$this._visibilityToggle(data.ul, data.parent, true, el);
|
||||
}
|
||||
};
|
||||
|
||||
// toggle actual visibility and accessibility tags
|
||||
Plugin.prototype._visibilityToggle = function(el, parent, animate, trigger, init) {
|
||||
var $this = this;
|
||||
var settings = $this.settings;
|
||||
var items = $this._getActionItems(el);
|
||||
var duration = 0;
|
||||
if (animate) {
|
||||
duration = settings.duration;
|
||||
}
|
||||
|
||||
if (el.hasClass(prefix+'_hidden')) {
|
||||
el.removeClass(prefix+'_hidden');
|
||||
//Fire beforeOpen callback
|
||||
if (!init) {
|
||||
settings.beforeOpen(trigger);
|
||||
}
|
||||
el.slideDown(duration, settings.easingOpen, function(){
|
||||
|
||||
$(trigger).removeClass(prefix+'_animating');
|
||||
$(parent).removeClass(prefix+'_animating');
|
||||
|
||||
//Fire afterOpen callback
|
||||
if (!init) {
|
||||
settings.afterOpen(trigger);
|
||||
}
|
||||
});
|
||||
el.attr('aria-hidden','false');
|
||||
items.attr('tabindex', '0');
|
||||
$this._setVisAttr(el, false);
|
||||
} else {
|
||||
el.addClass(prefix+'_hidden');
|
||||
|
||||
//Fire init or beforeClose callback
|
||||
if (!init){
|
||||
settings.beforeClose(trigger);
|
||||
}else if (trigger == 'init'){
|
||||
settings.init();
|
||||
}
|
||||
|
||||
el.slideUp(duration, this.settings.easingClose, function() {
|
||||
el.attr('aria-hidden','true');
|
||||
items.attr('tabindex', '-1');
|
||||
$this._setVisAttr(el, true);
|
||||
el.hide(); //jQuery 1.7 bug fix
|
||||
|
||||
$(trigger).removeClass(prefix+'_animating');
|
||||
$(parent).removeClass(prefix+'_animating');
|
||||
|
||||
//Fire init or afterClose callback
|
||||
if (!init){
|
||||
settings.afterClose(trigger);
|
||||
}
|
||||
else if (trigger == 'init'){
|
||||
settings.init();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// set attributes of element and children based on visibility
|
||||
Plugin.prototype._setVisAttr = function(el, hidden) {
|
||||
var $this = this;
|
||||
|
||||
// select all parents that aren't hidden
|
||||
var nonHidden = el.children('li').children('ul').not('.'+prefix+'_hidden');
|
||||
|
||||
// iterate over all items setting appropriate tags
|
||||
if (!hidden) {
|
||||
nonHidden.each(function(){
|
||||
var ul = $(this);
|
||||
ul.attr('aria-hidden','false');
|
||||
var items = $this._getActionItems(ul);
|
||||
items.attr('tabindex', '0');
|
||||
$this._setVisAttr(ul, hidden);
|
||||
});
|
||||
} else {
|
||||
nonHidden.each(function(){
|
||||
var ul = $(this);
|
||||
ul.attr('aria-hidden','true');
|
||||
var items = $this._getActionItems(ul);
|
||||
items.attr('tabindex', '-1');
|
||||
$this._setVisAttr(ul, hidden);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// get all 1st level items that are clickable
|
||||
Plugin.prototype._getActionItems = function(el) {
|
||||
var data = el.data("menu");
|
||||
if (!data) {
|
||||
data = {};
|
||||
var items = el.children('li');
|
||||
var anchors = items.find('a');
|
||||
data.links = anchors.add(items.find('.'+prefix+'_item'));
|
||||
el.data('menu', data);
|
||||
}
|
||||
return data.links;
|
||||
};
|
||||
|
||||
Plugin.prototype._outlines = function(state) {
|
||||
if (!state) {
|
||||
$('.'+prefix+'_item, .'+prefix+'_btn').css('outline','none');
|
||||
} else {
|
||||
$('.'+prefix+'_item, .'+prefix+'_btn').css('outline','');
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.prototype.toggle = function(){
|
||||
var $this = this;
|
||||
$this._menuToggle();
|
||||
};
|
||||
|
||||
Plugin.prototype.open = function(){
|
||||
var $this = this;
|
||||
if ($this.btn.hasClass(prefix+'_collapsed')) {
|
||||
$this._menuToggle();
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.prototype.close = function(){
|
||||
var $this = this;
|
||||
if ($this.btn.hasClass(prefix+'_open')) {
|
||||
$this._menuToggle();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[mobileMenu] = function ( options ) {
|
||||
var args = arguments;
|
||||
|
||||
// Is the first parameter an object (options), or was omitted, instantiate a new instance
|
||||
if (options === undefined || typeof options === 'object') {
|
||||
return this.each(function () {
|
||||
|
||||
// Only allow the plugin to be instantiated once due to methods
|
||||
if (!$.data(this, 'plugin_' + mobileMenu)) {
|
||||
|
||||
// if it has no instance, create a new one, pass options to our plugin constructor,
|
||||
// and store the plugin instance in the elements jQuery data object.
|
||||
$.data(this, 'plugin_' + mobileMenu, new Plugin( this, options ));
|
||||
}
|
||||
});
|
||||
|
||||
// If is a string and doesn't start with an underscore or 'init' function, treat this as a call to a public method.
|
||||
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
||||
|
||||
// Cache the method call to make it possible to return a value
|
||||
var returns;
|
||||
|
||||
this.each(function () {
|
||||
var instance = $.data(this, 'plugin_' + mobileMenu);
|
||||
|
||||
// Tests that there's already a plugin-instance and checks that the requested public method exists
|
||||
if (instance instanceof Plugin && typeof instance[options] === 'function') {
|
||||
|
||||
// Call the method of our plugin instance, and pass it the supplied arguments.
|
||||
returns = instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
|
||||
}
|
||||
});
|
||||
|
||||
// If the earlier cached method gives a value back return the value, otherwise return this to preserve chainability.
|
||||
return returns !== undefined ? returns : this;
|
||||
}
|
||||
};
|
||||
}(jQuery, document, window));
|
||||
7
js/jquery.slicknav.min.js
vendored
Executable file
7
js/jquery.slicknav.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
564
js/jquery.slitslider.js
Executable file
564
js/jquery.slitslider.js
Executable file
@@ -0,0 +1,564 @@
|
||||
/**
|
||||
* jquery.slitslider.js v1.1.0
|
||||
* http://www.codrops.com
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Copyright 2012, Codrops
|
||||
* http://www.codrops.com
|
||||
*/
|
||||
;( function( $, window, undefined ) {
|
||||
|
||||
'use strict';
|
||||
/*
|
||||
* debouncedresize: special jQuery event that happens once after a window resize
|
||||
*
|
||||
* latest version and complete README available on Github:
|
||||
* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
|
||||
*
|
||||
* Copyright 2011 @louis_remi
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
var $event = $.event,
|
||||
$special,
|
||||
resizeTimeout;
|
||||
$special = $event.special.debouncedresize = {
|
||||
setup: function() {
|
||||
$( this ).on( "resize", $special.handler );
|
||||
},
|
||||
teardown: function() {
|
||||
$( this ).off( "resize", $special.handler );
|
||||
},
|
||||
handler: function( event, execAsap ) {
|
||||
// Save the context
|
||||
var context = this,
|
||||
args = arguments,
|
||||
dispatch = function() {
|
||||
// set correct event type
|
||||
event.type = "debouncedresize";
|
||||
$event.dispatch.apply( context, args );
|
||||
};
|
||||
if ( resizeTimeout ) {
|
||||
clearTimeout( resizeTimeout );
|
||||
}
|
||||
execAsap ?
|
||||
dispatch() :
|
||||
resizeTimeout = setTimeout( dispatch, $special.threshold );
|
||||
},
|
||||
threshold: 20
|
||||
};
|
||||
// global
|
||||
var $window = $( window ),
|
||||
$document = $( document ),
|
||||
Modernizr = window.Modernizr;
|
||||
$.Slitslider = function( options, element ) {
|
||||
|
||||
this.$elWrapper = $( element );
|
||||
this._init( options );
|
||||
|
||||
};
|
||||
$.Slitslider.defaults = {
|
||||
// transitions speed
|
||||
speed : 800,
|
||||
// if true the item's slices will also animate the opacity value
|
||||
optOpacity : false,
|
||||
// amount (%) to translate both slices - adjust as necessary
|
||||
translateFactor : 230,
|
||||
// maximum possible angle
|
||||
maxAngle : 25,
|
||||
// maximum possible scale
|
||||
maxScale : 2,
|
||||
// slideshow on / off
|
||||
autoplay : true,
|
||||
// keyboard navigation
|
||||
keyboard : true,
|
||||
// time between transitions
|
||||
interval : 8000,
|
||||
// callbacks
|
||||
onBeforeChange : function( slide, idx ) { return false; },
|
||||
onAfterChange : function( slide, idx ) { return false; }
|
||||
};
|
||||
$.Slitslider.prototype = {
|
||||
_init : function( options ) {
|
||||
|
||||
// options
|
||||
this.options = $.extend( true, {}, $.Slitslider.defaults, options );
|
||||
// https://github.com/twitter/bootstrap/issues/2870
|
||||
this.transEndEventNames = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd',
|
||||
'MozTransition' : 'transitionend',
|
||||
'OTransition' : 'oTransitionEnd',
|
||||
'msTransition' : 'MSTransitionEnd',
|
||||
'transition' : 'transitionend'
|
||||
};
|
||||
this.transEndEventName = this.transEndEventNames[ Modernizr.prefixed( 'transition' ) ];
|
||||
// suport for css 3d transforms and css transitions
|
||||
this.support = Modernizr.csstransitions && Modernizr.csstransforms3d;
|
||||
// the slider
|
||||
this.$el = this.$elWrapper.children( '.sl-slider' );
|
||||
// the slides
|
||||
this.$slides = this.$el.children( '.sl-slide' ).hide();
|
||||
// total slides
|
||||
this.slidesCount = this.$slides.length;
|
||||
// current slide
|
||||
this.current = 0;
|
||||
// control if it's animating
|
||||
this.isAnimating = false;
|
||||
// get container size
|
||||
this._getSize();
|
||||
// layout
|
||||
this._layout();
|
||||
// load some events
|
||||
this._loadEvents();
|
||||
// slideshow
|
||||
if( this.options.autoplay ) {
|
||||
|
||||
this._startSlideshow();
|
||||
|
||||
}
|
||||
},
|
||||
// gets the current container width & height
|
||||
_getSize : function() {
|
||||
this.size = {
|
||||
width : this.$elWrapper.outerWidth( true ),
|
||||
height : this.$elWrapper.outerHeight( true )
|
||||
};
|
||||
},
|
||||
_layout : function() {
|
||||
|
||||
this.$slideWrapper = $( '<div class="sl-slides-wrapper" />' );
|
||||
|
||||
// wrap the slides
|
||||
this.$slides.wrapAll( this.$slideWrapper ).each( function( i ) {
|
||||
|
||||
var $slide = $( this ),
|
||||
// vertical || horizontal
|
||||
orientation = $slide.data( 'orientation' );
|
||||
|
||||
$slide.addClass( 'sl-slide-' + orientation )
|
||||
.children()
|
||||
.wrapAll( '<div class="sl-content-wrapper" />' )
|
||||
.wrapAll( '<div class="sl-content" />' );
|
||||
|
||||
} );
|
||||
|
||||
// set the right size of the slider/slides for the current window size
|
||||
this._setSize();
|
||||
// show first slide
|
||||
this.$slides.eq( this.current ).show();
|
||||
|
||||
},
|
||||
_navigate : function( dir, pos ) {
|
||||
|
||||
if( this.isAnimating || this.slidesCount < 2 ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
this.isAnimating = true;
|
||||
var self = this,
|
||||
$currentSlide = this.$slides.eq( this.current );
|
||||
// if position is passed
|
||||
if( pos !== undefined ) {
|
||||
this.current = pos;
|
||||
}
|
||||
// if not check the boundaries
|
||||
else if( dir === 'next' ) {
|
||||
this.current = this.current < this.slidesCount - 1 ? ++this.current : 0;
|
||||
}
|
||||
else if( dir === 'prev' ) {
|
||||
this.current = this.current > 0 ? --this.current : this.slidesCount - 1;
|
||||
}
|
||||
this.options.onBeforeChange( $currentSlide, this.current );
|
||||
|
||||
// next slide to be shown
|
||||
var $nextSlide = this.$slides.eq( this.current ),
|
||||
// the slide we want to cut and animate
|
||||
$movingSlide = ( dir === 'next' ) ? $currentSlide : $nextSlide,
|
||||
|
||||
// the following are the data attrs set for each slide
|
||||
configData = $movingSlide.data(),
|
||||
config = {};
|
||||
|
||||
config.orientation = configData.orientation || 'horizontal',
|
||||
config.slice1angle = configData.slice1Rotation || 0,
|
||||
config.slice1scale = configData.slice1Scale || 1,
|
||||
config.slice2angle = configData.slice2Rotation || 0,
|
||||
config.slice2scale = configData.slice2Scale || 1;
|
||||
|
||||
this._validateValues( config );
|
||||
|
||||
var cssStyle = config.orientation === 'horizontal' ? {
|
||||
marginTop : -this.size.height / 2
|
||||
} : {
|
||||
marginLeft : -this.size.width / 2
|
||||
},
|
||||
// default slide's slices style
|
||||
resetStyle = {
|
||||
'transform' : 'translate(0%,0%) rotate(0deg) scale(1)',
|
||||
opacity : 1
|
||||
},
|
||||
// slice1 style
|
||||
slice1Style = config.orientation === 'horizontal' ? {
|
||||
'transform' : 'translateY(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
|
||||
} : {
|
||||
'transform' : 'translateX(-' + this.options.translateFactor + '%) rotate(' + config.slice1angle + 'deg) scale(' + config.slice1scale + ')'
|
||||
},
|
||||
// slice2 style
|
||||
slice2Style = config.orientation === 'horizontal' ? {
|
||||
'transform' : 'translateY(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
|
||||
} : {
|
||||
'transform' : 'translateX(' + this.options.translateFactor + '%) rotate(' + config.slice2angle + 'deg) scale(' + config.slice2scale + ')'
|
||||
};
|
||||
|
||||
if( this.options.optOpacity ) {
|
||||
|
||||
slice1Style.opacity = 0;
|
||||
slice2Style.opacity = 0;
|
||||
|
||||
}
|
||||
|
||||
// we are adding the classes sl-trans-elems and sl-trans-back-elems to the slide that is either coming "next"
|
||||
// or going "prev" according to the direction.
|
||||
// the idea is to make it more interesting by giving some animations to the respective slide's elements
|
||||
//( dir === 'next' ) ? $nextSlide.addClass( 'sl-trans-elems' ) : $currentSlide.addClass( 'sl-trans-back-elems' );
|
||||
|
||||
$currentSlide.removeClass( 'sl-trans-elems' );
|
||||
var transitionProp = {
|
||||
'transition' : 'all ' + this.options.speed + 'ms ease-in-out'
|
||||
};
|
||||
// add the 2 slices and animate them
|
||||
$movingSlide.css( 'z-index', this.slidesCount )
|
||||
.find( 'div.sl-content-wrapper' )
|
||||
.wrap( $( '<div class="sl-content-slice" />' ).css( transitionProp ) )
|
||||
.parent()
|
||||
.cond(
|
||||
dir === 'prev',
|
||||
function() {
|
||||
|
||||
var slice = this;
|
||||
this.css( slice1Style );
|
||||
setTimeout( function() {
|
||||
|
||||
slice.css( resetStyle );
|
||||
}, 50 );
|
||||
|
||||
},
|
||||
function() {
|
||||
|
||||
var slice = this;
|
||||
setTimeout( function() {
|
||||
|
||||
slice.css( slice1Style );
|
||||
}, 50 );
|
||||
|
||||
}
|
||||
)
|
||||
.clone()
|
||||
.appendTo( $movingSlide )
|
||||
.cond(
|
||||
dir === 'prev',
|
||||
function() {
|
||||
|
||||
var slice = this;
|
||||
this.css( slice2Style );
|
||||
setTimeout( function() {
|
||||
$currentSlide.addClass( 'sl-trans-back-elems' );
|
||||
if( self.support ) {
|
||||
slice.css( resetStyle ).on( self.transEndEventName, function() {
|
||||
self._onEndNavigate( slice, $currentSlide, dir );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
self._onEndNavigate( slice, $currentSlide, dir );
|
||||
}
|
||||
}, 50 );
|
||||
|
||||
},
|
||||
function() {
|
||||
|
||||
var slice = this;
|
||||
setTimeout( function() {
|
||||
$nextSlide.addClass( 'sl-trans-elems' );
|
||||
|
||||
if( self.support ) {
|
||||
slice.css( slice2Style ).on( self.transEndEventName, function() {
|
||||
self._onEndNavigate( slice, $currentSlide, dir );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
self._onEndNavigate( slice, $currentSlide, dir );
|
||||
}
|
||||
}, 50 );
|
||||
|
||||
}
|
||||
)
|
||||
.find( 'div.sl-content-wrapper' )
|
||||
.css( cssStyle );
|
||||
|
||||
$nextSlide.show();
|
||||
|
||||
},
|
||||
_validateValues : function( config ) {
|
||||
|
||||
// OK, so we are restricting the angles and scale values here.
|
||||
// This is to avoid the slices wrong sides to be shown.
|
||||
// you can adjust these values as you wish but make sure you also ajust the
|
||||
// paddings of the slides and also the options.translateFactor value and scale data attrs
|
||||
if( config.slice1angle > this.options.maxAngle || config.slice1angle < -this.options.maxAngle ) {
|
||||
|
||||
config.slice1angle = this.options.maxAngle;
|
||||
|
||||
}
|
||||
if( config.slice2angle > this.options.maxAngle || config.slice2angle < -this.options.maxAngle ) {
|
||||
|
||||
config.slice2angle = this.options.maxAngle;
|
||||
|
||||
}
|
||||
if( config.slice1scale > this.options.maxScale || config.slice1scale <= 0 ) {
|
||||
|
||||
config.slice1scale = this.options.maxScale;
|
||||
|
||||
}
|
||||
if( config.slice2scale > this.options.maxScale || config.slice2scale <= 0 ) {
|
||||
|
||||
config.slice2scale = this.options.maxScale;
|
||||
|
||||
}
|
||||
if( config.orientation !== 'vertical' && config.orientation !== 'horizontal' ) {
|
||||
|
||||
config.orientation = 'horizontal'
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
_onEndNavigate : function( $slice, $oldSlide, dir ) {
|
||||
|
||||
// reset previous slide's style after next slide is shown
|
||||
var $slide = $slice.parent(),
|
||||
removeClasses = 'sl-trans-elems sl-trans-back-elems';
|
||||
|
||||
// remove second slide's slice
|
||||
$slice.remove();
|
||||
// unwrap..
|
||||
$slide.css( 'z-index', 1 )
|
||||
.find( 'div.sl-content-wrapper' )
|
||||
.unwrap();
|
||||
|
||||
// hide previous current slide
|
||||
$oldSlide.hide().removeClass( removeClasses );
|
||||
$slide.removeClass( removeClasses );
|
||||
// now we can navigate again..
|
||||
this.isAnimating = false;
|
||||
this.options.onAfterChange( $slide, this.current );
|
||||
|
||||
},
|
||||
_setSize : function() {
|
||||
|
||||
// the slider and content wrappers will have the window's width and height
|
||||
var cssStyle = {
|
||||
width : this.size.width,
|
||||
height : this.size.height
|
||||
};
|
||||
|
||||
this.$el.css( cssStyle ).find( 'div.sl-content-wrapper' ).css( cssStyle );
|
||||
|
||||
},
|
||||
_loadEvents : function() {
|
||||
|
||||
var self = this;
|
||||
|
||||
$window.on( 'debouncedresize.slitslider', function( event ) {
|
||||
|
||||
// update size values
|
||||
self._getSize();
|
||||
// set the sizes again
|
||||
self._setSize();
|
||||
|
||||
} );
|
||||
if ( this.options.keyboard ) {
|
||||
|
||||
$document.on( 'keydown.slitslider', function(e) {
|
||||
var keyCode = e.keyCode || e.which,
|
||||
arrow = {
|
||||
left: 37,
|
||||
up: 38,
|
||||
right: 39,
|
||||
down: 40
|
||||
};
|
||||
switch (keyCode) {
|
||||
|
||||
case arrow.left :
|
||||
self._stopSlideshow();
|
||||
self._navigate( 'prev' );
|
||||
break;
|
||||
|
||||
case arrow.right :
|
||||
|
||||
self._stopSlideshow();
|
||||
self._navigate( 'next' );
|
||||
break;
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
},
|
||||
_startSlideshow: function() {
|
||||
var self = this;
|
||||
this.slideshow = setTimeout( function() {
|
||||
self._navigate( 'next' );
|
||||
if ( self.options.autoplay ) {
|
||||
self._startSlideshow();
|
||||
}
|
||||
}, this.options.interval );
|
||||
},
|
||||
_stopSlideshow: function() {
|
||||
if ( this.options.autoplay ) {
|
||||
clearTimeout( this.slideshow );
|
||||
this.isPlaying = false;
|
||||
this.options.autoplay = false;
|
||||
}
|
||||
},
|
||||
_destroy : function( callback ) {
|
||||
|
||||
this.$el.off( '.slitslider' ).removeData( 'slitslider' );
|
||||
$window.off( '.slitslider' );
|
||||
$document.off( '.slitslider' );
|
||||
this.$slides.each( function( i ) {
|
||||
var $slide = $( this ),
|
||||
$content = $slide.find( 'div.sl-content' ).children();
|
||||
$content.appendTo( $slide );
|
||||
$slide.children( 'div.sl-content-wrapper' ).remove();
|
||||
} );
|
||||
this.$slides.unwrap( this.$slideWrapper ).hide();
|
||||
this.$slides.eq( 0 ).show();
|
||||
if( callback ) {
|
||||
callback.call();
|
||||
}
|
||||
},
|
||||
// public methos: adds more slides to the slider
|
||||
add : function( $slides, callback ) {
|
||||
this.$slides = this.$slides.add( $slides );
|
||||
var self = this;
|
||||
|
||||
|
||||
$slides.each( function( i ) {
|
||||
var $slide = $( this ),
|
||||
// vertical || horizontal
|
||||
orientation = $slide.data( 'orientation' );
|
||||
$slide.hide().addClass( 'sl-slide-' + orientation )
|
||||
.children()
|
||||
.wrapAll( '<div class="sl-content-wrapper" />' )
|
||||
.wrapAll( '<div class="sl-content" />' )
|
||||
.end()
|
||||
.appendTo( self.$el.find( 'div.sl-slides-wrapper' ) );
|
||||
} );
|
||||
this._setSize();
|
||||
this.slidesCount = this.$slides.length;
|
||||
|
||||
if ( callback ) {
|
||||
callback.call( $items );
|
||||
}
|
||||
},
|
||||
// public method: shows next slide
|
||||
next : function() {
|
||||
this._stopSlideshow();
|
||||
this._navigate( 'next' );
|
||||
},
|
||||
// public method: shows previous slide
|
||||
previous : function() {
|
||||
this._stopSlideshow();
|
||||
this._navigate( 'prev' );
|
||||
},
|
||||
// public method: goes to a specific slide
|
||||
jump : function( pos ) {
|
||||
pos -= 1;
|
||||
if( pos === this.current || pos >= this.slidesCount || pos < 0 ) {
|
||||
return false;
|
||||
}
|
||||
this._stopSlideshow();
|
||||
this._navigate( pos > this.current ? 'next' : 'prev', pos );
|
||||
},
|
||||
// public method: starts the slideshow
|
||||
// any call to next(), previous() or jump() will stop the slideshow
|
||||
play : function() {
|
||||
if( !this.isPlaying ) {
|
||||
this.isPlaying = true;
|
||||
this._navigate( 'next' );
|
||||
this.options.autoplay = true;
|
||||
this._startSlideshow();
|
||||
}
|
||||
},
|
||||
// public method: pauses the slideshow
|
||||
pause : function() {
|
||||
if( this.isPlaying ) {
|
||||
this._stopSlideshow();
|
||||
}
|
||||
},
|
||||
// public method: check if isAnimating is true
|
||||
isActive : function() {
|
||||
return this.isAnimating;
|
||||
},
|
||||
// publicc methos: destroys the slicebox instance
|
||||
destroy : function( callback ) {
|
||||
this._destroy( callback );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
var logError = function( message ) {
|
||||
if ( window.console ) {
|
||||
window.console.error( message );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.slitslider = function( options ) {
|
||||
var self = $.data( this, 'slitslider' );
|
||||
|
||||
if ( typeof options === 'string' ) {
|
||||
|
||||
var args = Array.prototype.slice.call( arguments, 1 );
|
||||
|
||||
this.each(function() {
|
||||
|
||||
if ( !self ) {
|
||||
logError( "cannot call methods on slitslider prior to initialization; " +
|
||||
"attempted to call method '" + options + "'" );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if ( !$.isFunction( self[options] ) || options.charAt(0) === "_" ) {
|
||||
logError( "no such method '" + options + "' for slitslider self" );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
self[ options ].apply( self, args );
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
this.each(function() {
|
||||
|
||||
if ( self ) {
|
||||
self._init();
|
||||
|
||||
}
|
||||
else {
|
||||
self = $.data( this, 'slitslider', new $.Slitslider( options, this ) );
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
};
|
||||
|
||||
} )( jQuery, window );
|
||||
4
js/modernizr.custom.79639.js
vendored
Executable file
4
js/modernizr.custom.79639.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1
js/scripts.js
Executable file
1
js/scripts.js
Executable file
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(function($){
|
||||
Reference in New Issue
Block a user