*/
removeErrorClasses($el) {
// radios need to clear all of the els
- if ($el[0].type == 'radio') {
+ if ($el[0].type === 'radio') {
return this.removeRadioErrorClasses($el.attr('name'));
}
// checkboxes need to clear all of the els
- else if ($el[0].type == 'checkbox') {
+ else if ($el[0].type === 'checkbox') {
return this.removeCheckboxErrorClasses($el.attr('name'));
}
checked++;
}
if (typeof $(e).attr('data-min-required') !== 'undefined') {
- minRequired = parseInt($(e).attr('data-min-required'));
+ minRequired = parseInt($(e).attr('data-min-required'), 10);
}
});
// Domain || URL
website: {
test: (text) => {
- return Abide.defaults.patterns['domain'].test(text) || Abide.defaults.patterns['url'].test(text);
+ return Abide.defaults.patterns.domain.test(text) || Abide.defaults.patterns.url.test(text);
}
}
},
* Optional validation functions to be used. `equalTo` being the only default included function.
* Functions should return only a boolean if the input is valid or not. Functions are given the following arguments:
* el : The jQuery element to validate.
- * required : Boolean value of the required attribute be present or not.
- * parent : The direct parent of the input.
* @option
*/
validators: {
- equalTo: function (el, required, parent) {
+ equalTo: function (el) {
return $(`#${el.attr('data-equalto')}`).val() === el.val();
}
}
if ($submenu.length) {
if (_this.options.submenuToggle) {
- $(this).children('.submenu-toggle').off('click.zf.accordionMenu').on('click.zf.accordionMenu', function(e) {
+ $(this).children('.submenu-toggle').off('click.zf.accordionMenu').on('click.zf.accordionMenu', function() {
_this.toggle($submenu);
});
} else {
*/
.trigger(`destroyed.zf.${pluginName}`);
for(var prop in plugin){
- plugin[prop] = null;//clean up script to prep for garbage collection.
+ if(typeof plugin[prop] === 'function'){
+ plugin[prop] = null; //clean up script to prep for garbage collection.
+ }
}
return;
},
$('[data-'+ plugins +']').foundation('_init');
},
'undefined': function(){
- this['object'](Object.keys(_this._plugins));
+ this.object(Object.keys(_this._plugins));
}
};
fns[type](plugins);
opts = { reflow: true };
if($el.attr('data-options')){
- $el.attr('data-options').split(';').forEach(function(option, _index){
+ $el.attr('data-options').split(';').forEach(function(option){
var opt = option.split(':').map(function(el){ return el.trim(); });
if(opt[0]) opts[opt[0]] = parseValue(opt[1]);
});
},
getFnName: functionName,
- addToJquery: function($) {
+ addToJquery: function() {
// TODO: consider not making this a jQuery function
// TODO: need way to reflow vs. re-initialize
/**
}
})();
if (!Function.prototype.bind) {
+ /* eslint-disable no-extend-native */
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
-import $ from 'jquery';
import { GetYoDigits } from './foundation.core.utils';
// Abstract class for providing lifecycle hooks. Expect plugins to define AT LEAST
*/
.trigger(`destroyed.zf.${pluginName}`);
for(var prop in this){
- this[prop] = null;//clean up script to prep for garbage collection.
+ if (this.hasOwnProperty(prop)) {
+ this[prop] = null; //clean up script to prep for garbage collection.
+ }
}
}
}
var _this = this;
$elem.off('click.zf.drilldown')
- .on('click.zf.drilldown', function(e){
+ .on('click.zf.drilldown', function(e) {
if($(e.target).parentsUntil('ul', 'li').hasClass('is-drilldown-submenu-parent')){
e.preventDefault();
}
if(_this.options.closeOnClick){
var $body = $('body');
- $body.off('.zf.drilldown').on('click.zf.drilldown', function(e){
+ $body.off('.zf.drilldown').on('click.zf.drilldown', function() {
if (e.target === _this.$element[0] || $.contains(_this.$element[0], e.target)) { return; }
e.preventDefault();
_this._hideAll();
*/
_scrollTop() {
var _this = this;
- var $scrollTopElement = _this.options.scrollTopElement!=''?$(_this.options.scrollTopElement):_this.$element,
+ var $scrollTopElement = _this.options.scrollTopElement !== ''?$(_this.options.scrollTopElement):_this.$element,
scrollPos = parseInt($scrollTopElement.offset().top+_this.options.scrollTopOffset, 10);
$('html, body').stop(true).animate({ scrollTop: scrollPos }, _this.options.animationDuration, _this.options.animationEasing,function(){
/**
var _this = this;
$elem.off('click.zf.drilldown');
$elem.children('.js-drilldown-back')
- .on('click.zf.drilldown', function(e){
+ .on('click.zf.drilldown', function() {
// console.log('mouseup on back');
_this._hide($elem);
var _this = this;
this.$menuItems.not('.is-drilldown-submenu-parent')
.off('click.zf.drilldown')
- .on('click.zf.drilldown', function(e){
- setTimeout(function(){
+ .on('click.zf.drilldown', function() {
+ setTimeout(function() {
_this._hideAll();
}, 0);
});
// Reset drilldown
var $expandedSubmenus = this.$element.find('li[aria-expanded="true"] > ul[data-submenu]');
- $expandedSubmenus.each(function(index) {
+ $expandedSubmenus.each(function() {
_this._setHideSubMenuClasses($(this));
});
_this.$wrapper.css('height', $(this).data('calcHeight'));
}
- var isLastChild = index == $submenus.length - 1;
+ var isLastChild = index === $submenus.length - 1;
// Add transitionsend listener to last child (root due to reverse order) to open target menu's first link
// Last child makes sure the event gets always triggered even if going through several menus
*/
_hide($elem) {
if(this.options.autoHeight) this.$wrapper.css({height:$elem.parent().closest('ul').data('calcHeight')});
- var _this = this;
$elem.parent().closest('ul').removeClass('invisible');
$elem.parent('li').attr('aria-expanded', false);
$elem.attr('aria-hidden', true);
// Recalculate menu heights and total max height
this.$submenus.add(this.$element).each(function(){
- var numOfElems = $(this).children('li').length;
var height = Box.GetDimensions(this).height;
maxHeight = height > maxHeight ? height : maxHeight;
});
if (this.options.autoHeight)
- result['height'] = this.$currentMenu.data('calcHeight');
+ result.height = this.$currentMenu.data('calcHeight');
else
result['min-height'] = `${maxHeight}px`;
}
this.$anchors.add(this.$element).on('keydown.zf.dropdown', function(e) {
- var $target = $(this),
- visibleFocusableElements = Keyboard.findFocusable(_this.$element);
+ var $target = $(this);
Keyboard.handleKey(e, 'Dropdown', {
open: function() {
// Handle Leaf element Clicks
if(_this.options.closeOnClickInside){
- this.$menuItems.on('click.zf.dropdownMenu', function(e) {
+ this.$menuItems.on('click.zf.dropdownMenu', function() {
var $elem = $(this),
hasSub = $elem.hasClass(parClass);
if(!hasSub){
if (hasTouch && this.options.disableHoverOnTouch) this.options.disableHover = true;
if (!this.options.disableHover) {
- this.$menuItems.on('mouseenter.zf.dropdownMenu', function (e) {
+ this.$menuItems.on('mouseenter.zf.dropdownMenu', function () {
var $elem = $(this),
hasSub = $elem.hasClass(parClass);
_this._show($elem.children('.is-dropdown-submenu'));
}, _this.options.hoverDelay));
}
- }).on('mouseleave.zf.dropdownMenu', ignoreMousedisappear(function (e) {
+ }).on('mouseleave.zf.dropdownMenu', ignoreMousedisappear(function () {
var $elem = $(this),
hasSub = $elem.hasClass(parClass);
if (hasSub && _this.options.autoclose) {
if ($elem && $elem.length) {
$toClose = $elem;
} else if (typeof idx !== 'undefined') {
- $toClose = this.$tabs.not(function(i, el) {
+ $toClose = this.$tabs.not(function(i) {
return i === idx;
});
}
* function to handle $elements resizeme.zf.trigger, with bound this on _bindHandler.onResizeMeBound
* @private
*/
- _onResizeMe(e) {
+ _onResizeMe() {
this._reflow();
}
* @private
*/
_events() {
- var _this = this;
this._pauseEvents();
if(this.hasNested){
this.$element.on('postequalized.zf.equalizer', this._bindHandler.onPostEqualizedBound);
this.$watched[i].style.height = 'auto';
//maybe could use this.$watched[i].offsetTop
var elOffsetTop = $(this.$watched[i]).offset().top;
- if (elOffsetTop!=lastElTopOffset) {
+ if (elOffsetTop !== lastElTopOffset) {
group++;
groups[group] = [];
lastElTopOffset=elOffsetTop;
* Checks the Interchange element for the provided media query + content pairings
* @function
* @private
- * @param {Object} element - jQuery object that is an Interchange instance
* @returns {Array} scenarios - Array of objects that have 'mq' and 'path' keys with corresponding keys
*/
- _generateRules(element) {
+ _generateRules() {
var rulesList = [];
var rules;
*/
_init() {
var id = this.$element[0].id || GetYoDigits(6, 'magellan');
- var _this = this;
this.$targets = $('[data-magellan-target]');
this.$links = this.$element.find('a');
this.$element.attr({
});
});
- this._deepLinkScroll = function(e) {
+ this._deepLinkScroll = function() {
if(_this.options.deepLinking) {
_this.scrollToLoc(window.location.hash);
}
else if(newScrollPos + this.winHeight === this.docHeight){ activeIdx = this.points.length - 1; }
// Otherwhise, use the last visible link
else{
- const visibleLinks = this.points.filter((p, i) => {
+ const visibleLinks = this.points.filter((p) => {
return (p - this.options.offset - (isScrollingUp ? this.options.threshold : 0)) <= newScrollPos;
});
activeIdx = visibleLinks.length ? visibleLinks.length - 1 : 0;
* @function
* @private
*/
- _stopScrolling(event) {
+ _stopScrolling() {
return false;
}
* @fires OffCanvas#close
* @fires OffCanvas#closed
*/
- close(cb) {
+ close() {
if (!this.$element.hasClass('is-open') || this.isRevealed) { return; }
/**
*/
this.$element.trigger('close.zf.offCanvas');
- var _this = this;
-
this.$element.removeClass('is-open');
this.$element.attr('aria-hidden', 'true');
// Listen to transitionEnd: add class, re-enable scrolling and release focus when done.
- this.$element.one(transitionend(this.$element), (e) => {
+ this.$element.one(transitionend(this.$element), () => {
this.$element.addClass('is-closed');
this._removeContentClasses();
* @private
*/
_prepareForOrbit() {
- var _this = this;
this._setWrapperHeight();
}
*/
_reset() {
// Don't do anything if there are no slides (first run)
- if (typeof this.$slides == 'undefined') {
+ if (typeof this.$slides === 'undefined') {
return;
}
}
_alignmentsExhausted(position) {
- return this.triedPositions[position] && this.triedPositions[position].length == ALIGNMENTS[position].length;
+ return this.triedPositions[position] && this.triedPositions[position].length === ALIGNMENTS[position].length;
}
tmpPlugin.destroy();
}
catch(e) {
+ console.log(e);
}
}
}
* @see Tabs.selectTab
* @function
*/
- open(_target) {
+ open() {
if (this.currentRule && typeof this.currentRule.open === 'function') {
return this.currentRule.open(this.currentPlugin, ...arguments);
}
* @see Accordion.up
* @function
*/
- close(_target) {
+ close() {
if (this.currentRule && typeof this.currentRule.close === 'function') {
return this.currentRule.close(this.currentPlugin, ...arguments);
}
* @see Accordion.toggle
* @function
*/
- toggle(_target) {
+ toggle() {
if (this.currentRule && typeof this.currentRule.toggle === 'function') {
return this.currentRule.toggle(this.currentPlugin, ...arguments);
}
* @param {jQuery} element - jQuery object to make into a dropdown menu.
* @param {Object} options - Overrides to the default plugin settings.
*/
- _setup(element, options) {
+ _setup(element) {
this.$element = $(element);
this.rules = this.$element.data('responsive-menu');
this.currentMq = null;
* @private
*/
_events() {
- var _this = this;
-
this._updateMqHandler = this._update.bind(this);
$(window).on('changed.zf.mediaquery', this._updateMqHandler);
* Handles modal methods on back/forward button clicks or any other event that triggers hashchange.
* @private
*/
- _handleState(e) {
+ _handleState() {
if(window.location.hash === ( '#' + this.id) && !this.isActive){ this.open(); }
else{ this.close(); }
}
* @param {number} scrollTop - Scroll to restore, html "top" property by default (as set by `_disableScroll`)
*/
_enableScroll(scrollTop) {
- scrollTop = scrollTop || parseInt($("html").css("top"));
+ scrollTop = scrollTop || parseInt($("html").css("top"), 10);
if ($(document).height() > $(window).height()) {
$("html")
.css("top", "");
// Get the current top before the modal is closed and restore the scroll after.
// TODO: use component properties instead of HTML properties
// See https://github.com/foundation/foundation-sites/pull/10786
- var scrollTop = parseInt($("html").css("top"));
+ var scrollTop = parseInt($("html").css("top"), 10);
if ($('.reveal:visible').length === 0) {
_this._removeGlobalClasses(); // also remove .is-reveal-open from the html element when there is no opened reveal
'ARROW_UP': 'increase',
'ARROW_DOWN': 'decrease',
'ARROW_LEFT': 'decrease',
- 'SHIFT_ARROW_RIGHT': 'increase_fast',
- 'SHIFT_ARROW_UP': 'increase_fast',
- 'SHIFT_ARROW_DOWN': 'decrease_fast',
- 'SHIFT_ARROW_LEFT': 'decrease_fast',
+ 'SHIFT_ARROW_RIGHT': 'increaseFast',
+ 'SHIFT_ARROW_UP': 'increaseFast',
+ 'SHIFT_ARROW_DOWN': 'decreaseFast',
+ 'SHIFT_ARROW_LEFT': 'decreaseFast',
'HOME': 'min',
'END': 'max'
},
'rtl': {
'ARROW_LEFT': 'increase',
'ARROW_RIGHT': 'decrease',
- 'SHIFT_ARROW_LEFT': 'increase_fast',
- 'SHIFT_ARROW_RIGHT': 'decrease_fast'
+ 'SHIFT_ARROW_LEFT': 'increaseFast',
+ 'SHIFT_ARROW_RIGHT': 'decreaseFast'
}
});
}
this.$input = this.inputs.length ? this.inputs.eq(0) : $(`#${this.$handle.attr('aria-controls')}`);
this.$fill = this.$element.find('[data-slider-fill]').css(this.options.vertical ? 'height' : 'width', 0);
- var _this = this;
if (this.options.disabled || this.$element.hasClass(this.options.disabledClass)) {
this.options.disabled = true;
this.$element.addClass(this.options.disabledClass);
//empty variable, will be used for min-height/width for fill bar
dim,
//percentage w/h of the handle compared to the slider bar
- handlePct = ~~(percent(handleDim, elemDim) * 100);
+ handlePct = Math.floor(percent(handleDim, elemDim) * 100);
//if left handle, the math is slightly different than if it's the right handle, and the left/top property needs to be changed for the fill bar
if (isLeftHndl) {
//left or top percentage value to apply to the fill bar.
* TODO clean this up, there's a lot of repeated code between this and the _setHandlePos fn.
*/
_handleEvent(e, $handle, val) {
- var value, hasVal;
+ var value;
if (!val) {//click or drag events
e.preventDefault();
var _this = this,
if (Rtl() && !this.options.vertical) {value = this.options.end - value;}
value = _this._adjustValue(null, value);
- //boolean flag for the setHandlePos fn, specifically for vertical sliders
- hasVal = false;
if (!$handle) {//figure out which handle it is, pass it to the next function.
var firstHndlPos = absPosition(this.$handle, direction, barXY, param),
} else {//change event on input
value = this._adjustValue(null, val);
- hasVal = true;
}
this._setHandlePos($handle, value);
var val,
step = this.options.step,
div = parseFloat(step/2),
- left, prev_val, next_val;
+ left, previousVal, nextVal;
if (!!$handle) {
val = parseFloat($handle.attr('aria-valuenow'));
}
} else {
left = step + (val % step);
}
- prev_val = val - left;
- next_val = prev_val + step;
+ previousVal = val - left;
+ nextVal = previousVal + step;
if (left === 0) {
return val;
}
- val = val >= prev_val + div ? next_val : prev_val;
+ val = val >= previousVal + div ? nextVal : previousVal;
return val;
}
// listen for the enter key and trigger a change
// @see https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
this.inputs.off('keyup.zf.slider').on('keyup.zf.slider', function (e) {
- if(e.keyCode == 13) handleChangeEvent.call(this, e);
+ if(e.keyCode === 13) handleChangeEvent.call(this, e);
});
this.inputs.off('change.zf.slider').on('change.zf.slider', handleChangeEvent);
curHandle = $(e.currentTarget);
- $body.on('mousemove.zf.slider', function(e) {
+ $body.on('mousemove.zf.slider', function() {
e.preventDefault();
_this._handleEvent(e, curHandle);
- }).on('mouseup.zf.slider', function(e) {
+ }).on('mouseup.zf.slider', function() {
_this._handleEvent(e, curHandle);
$handle.removeClass('is-dragging');
increase: function() {
newValue = oldValue + _this.options.step;
},
- decrease_fast: function() {
+ decreaseFast: function() {
newValue = oldValue - _this.options.step * 10;
},
- increase_fast: function() {
+ increaseFast: function() {
newValue = oldValue + _this.options.step * 10;
},
min: function() {
this.isStuck = false;
this.onLoadListener = onLoad($(window), function () {
//We calculate the container height to have correct values for anchor points offset calculation.
- _this.containerHeight = _this.$element.css("display") == "none" ? 0 : _this.$element[0].getBoundingClientRect().height;
+ _this.containerHeight = _this.$element.css("display") === "none" ? 0 : _this.$element[0].getBoundingClientRect().height;
_this.$container.css('height', _this.containerHeight);
_this.elemHeight = _this.containerHeight;
if (_this.options.anchor !== '') {
* @private
*/
_parsePoints() {
- var top = this.options.topAnchor == "" ? 1 : this.options.topAnchor,
- btm = this.options.btmAnchor== "" ? document.documentElement.scrollHeight : this.options.btmAnchor,
+ var top = this.options.topAnchor === "" ? 1 : this.options.topAnchor,
+ btm = this.options.btmAnchor === "" ? document.documentElement.scrollHeight : this.options.btmAnchor,
pts = [top, btm],
breaks = {};
for (var i = 0, len = pts.length; i < len && pts[i]; i++) {
if (this.canStick) {
this.isOn = true;
$(window).off(scrollListener)
- .on(scrollListener, function(e) {
+ .on(scrollListener, function() {
if (_this.scrollCount === 0) {
_this.scrollCount = _this.options.checkEvery;
_this._setSizes(function() {
}
this.$element.off('resizeme.zf.trigger')
- .on('resizeme.zf.trigger', function(e, el) {
+ .on('resizeme.zf.trigger', function() {
_this._eventsHandler(id);
});
- this.$element.on('mutateme.zf.trigger', function (e, el) {
+ this.$element.on('mutateme.zf.trigger', function () {
_this._eventsHandler(id);
});
if(this.$anchor) {
- this.$anchor.on('mutateme.zf.trigger', function (e, el) {
+ this.$anchor.on('mutateme.zf.trigger', function () {
_this._eventsHandler(id);
});
}
css[mrgn] = 0;
- css['bottom'] = 'auto';
+ css.bottom = 'auto';
if(isTop) {
- css['top'] = 0;
+ css.top = 0;
} else {
- css['top'] = anchorPt;
+ css.top = anchorPt;
}
this.isStuck = false;
if (cb && typeof cb === 'function') { cb(); }
}
- var _this = this,
- newElemWidth = this.$container[0].getBoundingClientRect().width,
- comp = window.getComputedStyle(this.$container[0]),
- pdngl = parseInt(comp['padding-left'], 10),
- pdngr = parseInt(comp['padding-right'], 10);
+ var newElemWidth = this.$container[0].getBoundingClientRect().width,
+ comp = window.getComputedStyle(this.$container[0]),
+ pdngl = parseInt(comp['padding-left'], 10),
+ pdngr = parseInt(comp['padding-right'], 10);
if (this.$anchor && this.$anchor.length) {
this.anchorHeight = this.$anchor[0].getBoundingClientRect().height;
if (this.options.dynamicHeight || !this.containerHeight) {
// Get the sticked element height and apply it to the container to "hold the place"
var newContainerHeight = this.$element[0].getBoundingClientRect().height || this.containerHeight;
- newContainerHeight = this.$element.css("display") == "none" ? 0 : newContainerHeight;
+ newContainerHeight = this.$element.css("display") === "none" ? 0 : newContainerHeight;
this.$container.css('height', newContainerHeight);
this.containerHeight = newContainerHeight;
}
* @function
*/
_collapseTab($target) {
- var $target_anchor = $target
+ var $targetAnchor = $target
.removeClass(`${this.options.linkActiveClass}`)
.find('[role="tab"]')
.attr({
'tabindex': -1
});
- $(`#${$target_anchor.attr('aria-controls')}`)
+ $(`#${$targetAnchor.attr('aria-controls')}`)
.removeClass(`${this.options.panelActiveClass}`)
.attr({ 'aria-hidden': 'true' })
}
_events() {
const _this = this;
const hasTouch = 'ontouchstart' in window || (typeof window.ontouchstart !== 'undefined');
- const $template = this.template;
var isFocus = false;
// `disableForTouch: Fully disable the tooltip on touch devices
if (!this.options.disableHover) {
this.$element
- .on('mouseenter.zf.tooltip', function(e) {
+ .on('mouseenter.zf.tooltip', function() {
if (!_this.isActive) {
_this.timeout = setTimeout(function() {
_this.show();
}, _this.options.hoverDelay);
}
})
- .on('mouseleave.zf.tooltip', ignoreMousedisappear(function(e) {
+ .on('mouseleave.zf.tooltip', ignoreMousedisappear(function() {
clearTimeout(_this.timeout);
if (!isFocus || (_this.isClick && !_this.options.clickOpen)) {
_this.hide();
if (hasTouch) {
this.$element
- .on('tap.zf.tooltip touchend.zf.tooltip', function (e) {
+ .on('tap.zf.tooltip touchend.zf.tooltip', function () {
_this.isActive ? _this.hide() : _this.show();
});
}
if (this.options.clickOpen) {
- this.$element.on('mousedown.zf.tooltip', function(e) {
+ this.$element.on('mousedown.zf.tooltip', function() {
if (_this.isClick) {
//_this.hide();
// _this.isClick = false;
}
});
} else {
- this.$element.on('mousedown.zf.tooltip', function(e) {
+ this.$element.on('mousedown.zf.tooltip', function() {
_this.isClick = true;
});
}
});
this.$element
- .on('focus.zf.tooltip', function(e) {
+ .on('focus.zf.tooltip', function() {
isFocus = true;
if (_this.isClick) {
// If we're not showing open on clicks, we need to pretend a click-launched focus isn't
}
})
- .on('focusout.zf.tooltip', function(e) {
+ .on('focusout.zf.tooltip', function() {
isFocus = false;
_this.isClick = false;
_this.hide();
* @param {Func} callback - Function to execute when image is fully loaded.
*/
function onImagesLoaded(images, callback){
- var self = this,
- unloaded = images.length;
+ var unloaded = images.length;
if (unloaded === 0) {
callback();
var image = new Image();
// Still count image as loaded if it finalizes with an error.
var events = "load.zf.images error.zf.images";
- $(image).one(events, function me(event){
+ $(image).one(events, function me(){
// Unbind the event listeners. We're using 'one' but only one of the two events will have fired.
$(this).off(events, me);
singleImageLoaded();
return true;
})
.sort( function( a, b ) {
- if ($(a).attr('tabindex') == $(b).attr('tabindex')) {
+ if ($(a).attr('tabindex') === $(b).attr('tabindex')) {
return 0;
}
- let aTabIndex = parseInt($(a).attr('tabindex')),
- bTabIndex = parseInt($(b).attr('tabindex'));
+ let aTabIndex = parseInt($(a).attr('tabindex'), 10),
+ bTabIndex = parseInt($(b).attr('tabindex'), 10);
// Undefined is treated the same as 0
- if (typeof $(a).attr('tabindex') == 'undefined' && bTabIndex > 0) {
+ if (typeof $(a).attr('tabindex') === 'undefined' && bTabIndex > 0) {
return 1;
}
- if (typeof $(b).attr('tabindex') == 'undefined' && aTabIndex > 0) {
+ if (typeof $(b).attr('tabindex') === 'undefined' && aTabIndex > 0) {
return -1;
}
- if (aTabIndex == 0 && bTabIndex > 0) {
+ if (aTabIndex === 0 && bTabIndex > 0) {
return 1;
}
- if (bTabIndex == 0 && aTabIndex > 0) {
+ if (bTabIndex === 0 && aTabIndex > 0) {
return -1;
}
if (aTabIndex < bTabIndex) {
*/
function getKeyCodes(kcs) {
var k = {};
- for (var kc in kcs) k[kcs[kc]] = kcs[kc];
+ for (var kc in kcs) {
+ if (kcs.hasOwnProperty(kc)) k[kcs[kc]] = kcs[kc];
+ }
return k;
}
import $ from 'jquery';
// Default set of media queries
-const defaultQueries = {
- 'default' : 'only screen',
- landscape : 'only screen and (orientation: landscape)',
- portrait : 'only screen and (orientation: portrait)',
- retina : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
- 'only screen and (min--moz-device-pixel-ratio: 2),' +
- 'only screen and (-o-min-device-pixel-ratio: 2/1),' +
- 'only screen and (min-device-pixel-ratio: 2),' +
- 'only screen and (min-resolution: 192dpi),' +
- 'only screen and (min-resolution: 2dppx)'
- };
+// const defaultQueries = {
+// 'default' : 'only screen',
+// landscape : 'only screen and (orientation: landscape)',
+// portrait : 'only screen and (orientation: portrait)',
+// retina : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
+// 'only screen and (min--moz-device-pixel-ratio: 2),' +
+// 'only screen and (-o-min-device-pixel-ratio: 2/1),' +
+// 'only screen and (min-device-pixel-ratio: 2),' +
+// 'only screen and (min-resolution: 192dpi),' +
+// 'only screen and (min-resolution: 2dppx)'
+// };
// matchMedia() polyfill - Test a CSS media type/query in JS.
-import $ from 'jquery';
-
function Timer(elem, options, cb) {
var _this = this,
duration = options.duration,//options is an object for easily adding features later.
var Touch = {};
var startPosX,
- startPosY,
startTime,
elapsedTime,
startEvent,
if (e.touches.length === 1) {
startPosX = e.touches[0].pageX;
- startPosY = e.touches[0].pageY;
startEvent = e;
isMoving = true;
didMoved = false;
this.addEventListener && this.addEventListener('touchstart', onTouchStart, { passive : true });
}
-function teardown() {
- this.removeEventListener('touchstart', onTouchStart);
-}
+// function teardown() {
+// this.removeEventListener('touchstart', onTouchStart);
+// }
class SpotSwipe {
- constructor($) {
+ constructor() {
this.version = '1.0.0';
this.enabled = 'ontouchstart' in document.documentElement;
this.preventDefault = false;
this.moveThreshold = 75;
this.timeThreshold = 200;
- this.$ = $;
this._init();
}
_init() {
- var $ = this.$;
+ // var $ = this.$;
$.event.special.swipe = { setup: init };
$.event.special.tap = { setup: init };
* values, and do not add event handlers directly. *
****************************************************/
-Touch.setupSpotSwipe = function($) {
+Touch.setupSpotSwipe = function() {
$.spotSwipe = new SpotSwipe($);
};
/****************************************************
* Method for adding pseudo drag events to elements *
***************************************************/
-Touch.setupTouchHandler = function($) {
+Touch.setupTouchHandler = function() {
$.fn.addTouch = function(){
- this.each(function(i,el){
+ this.each(function(i, el){
$(el).bind('touchstart touchmove touchend touchcancel', function(event) {
//we pass the original event object because the jQuery event
//object is normalized to w3c specs and does not provide the TouchList
});
});
- var handleTouch = function(event){
+ var handleTouch = function(event) {
var touches = event.changedTouches,
first = touches[0],
eventTypes = {
};
};
-Touch.init = function ($) {
-
+Touch.init = function () {
if(typeof($.spotSwipe) === 'undefined') {
Touch.setupSpotSwipe($);
Touch.setupTouchHandler($);
}
}
return false;
-}());
+})();
const triggers = (el, type) => {
el.data(type).split(' ').forEach(id => {
function debounceGlobalListener(debounce, trigger, listener) {
let timer, args = Array.prototype.slice.call(arguments, 3);
- $(window).off(trigger).on(trigger, function(e) {
+ $(window).off(trigger).on(trigger, function() {
if (timer) { clearTimeout(timer); }
timer = setTimeout(function(){
listener.apply(null, args);
}
-Triggers.init = function ($, Foundation) {
+Triggers.init = function (__, Foundation) {
onLoad($(window), function () {
if ($.triggersInitialized !== true) {
Triggers.Initializers.addSimpleListeners();