FEATURE #2341 @4h: add basics for template
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
body {
|
||||
font-family: Ubuntu;
|
||||
text-align: justify;
|
||||
background: url("./images/bg.png");
|
||||
}
|
||||
|
||||
header.top-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 100;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
header.top-bar ul {
|
||||
background: none;
|
||||
}
|
||||
|
||||
header.top-bar a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.logo {
|
||||
max-height: 35px;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4 {
|
||||
font-family: Comfortaa;
|
||||
color: rgb(81, 81, 81);
|
||||
}
|
||||
|
||||
.over-slider-stripe {
|
||||
position: absolute;
|
||||
top: 25%;
|
||||
font-size: 230%;
|
||||
font-family: Comfortaa;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
color: white;
|
||||
|
||||
}
|
||||
|
||||
.stripe {
|
||||
padding: 50px;
|
||||
margin: 50px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.stripe.light {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.stripe h1 {
|
||||
color: white;
|
||||
font-size: 270%;
|
||||
}
|
||||
|
||||
.stripe p {
|
||||
padding-left: 150px;
|
||||
}
|
||||
|
||||
.content-container {
|
||||
margin-top: 70px;
|
||||
line-height: 170%;
|
||||
}
|
||||
|
||||
.trainee-team .thumbnail {
|
||||
max-height: 150px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
margin-top: 10em;
|
||||
}
|
||||
|
||||
.rounded {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.trainer {
|
||||
max-width: 25%;
|
||||
padding: 3px;
|
||||
border: solid 1px #CCC;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* Lightbox library created by binarity s.r.o.
|
||||
* www.binarity.cz
|
||||
* version 1.0.0
|
||||
*
|
||||
* Vanilla JavaScript lightbox plugin.
|
||||
*
|
||||
* Can use custom invoker passed as first argument or uses a default one - .b-lightbox.
|
||||
* This allows to have more lightbox instances on one site to categorize items.
|
||||
*
|
||||
* Default behaviour:
|
||||
* - Hides on escape keydown event - settable (options.allow_escape).
|
||||
* - Hides on background click - settable (options.allow_backgroundclick).
|
||||
* - Hide button in top right corner - settable (options.close_text).
|
||||
* - Allows usage of arrow keys (left/right) to navigate through images - settable (option.allow_arrows).
|
||||
*
|
||||
* @param options
|
||||
* @param autorun
|
||||
* @constructor
|
||||
*/
|
||||
function BLightBox(options, autorun) {
|
||||
// Instance and instance variables.
|
||||
var BLightBox = this,
|
||||
escape_key_allowed = (!(options !== undefined && options.allow_escape === false)),
|
||||
hide_on_holder_allowed = (!(options !== undefined && options.allow_backgroundclick === false)),
|
||||
arrows_allowed = (!(options !== undefined && options.allow_arrows === false)),
|
||||
close_text = (options !== undefined && options.close_text !== undefined) ? options.close_text : 'Close',
|
||||
|
||||
// DOM
|
||||
lightbox_holder = document.createElement('div'),
|
||||
invoker_string = (options !== undefined && options.invoker !== undefined) ? options.invoker : '.b-lightbox',
|
||||
invokers = document.querySelectorAll(invoker_string),
|
||||
invokers_length = invokers.length,
|
||||
lightbox_image = document.createElement('img'),
|
||||
close_label = document.createElement('a'),
|
||||
previous_button = document.createElement('a'),
|
||||
next_button = document.createElement('a'),
|
||||
lightbox_label = document.createElement('span');
|
||||
|
||||
// BLightBox DOM default settings.
|
||||
lightbox_holder.className = 'b-lightbox-holder';
|
||||
lightbox_image.className = 'b-lightbox-image';
|
||||
close_label.className = 'b-lightbox-close-button';
|
||||
close_label.textContent = close_text;
|
||||
previous_button.className = 'b-lightbox-direction previous';
|
||||
previous_button.innerHTML = '‹';
|
||||
next_button.className = 'b-lightbox-direction next';
|
||||
next_button.innerHTML = '›';
|
||||
lightbox_label.className = 'b-lightbox-label';
|
||||
|
||||
/**
|
||||
* Show new image according to data-newindex attribute on directional button
|
||||
*/
|
||||
this.loadNewImage = function(event) {
|
||||
event.stopPropagation();
|
||||
var index = event.target.getAttribute('data-newindex'),
|
||||
label = invokers[index].getAttribute('data-label');
|
||||
|
||||
if(invokers[index]) {
|
||||
lightbox_image.style.display = 'none';
|
||||
this.decideFromLoad(invokers[index]);
|
||||
lightbox_image.style.display = 'block';
|
||||
if(label != '') {
|
||||
lightbox_label.innerHTML = label;
|
||||
}
|
||||
}
|
||||
|
||||
this.lightboxImageCenter(label != ''); // Center image.
|
||||
|
||||
// Change indexes to be opened.
|
||||
previous_button.setAttribute('data-newindex', this.getPreviousIndex(index));
|
||||
next_button.setAttribute('data-newindex', this.getNextIndex(index));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns first next index possible, or return very first index to allow rotation.
|
||||
* @param index
|
||||
* @returns {number}
|
||||
*/
|
||||
this.getNextIndex = function(index) {
|
||||
// Skip to last image if we are on the first.
|
||||
return (index == invokers_length - 1) ? 0 : parseInt(index) + 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns first previous index possible, or returns last array index to allow rotation.
|
||||
* @param index
|
||||
* @returns {number}
|
||||
*/
|
||||
this.getPreviousIndex = function(index) {
|
||||
// Skip to last image if we are on the first.
|
||||
return (index == 0) ? invokers_length - 1 : index - 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset ivokers_length variable for re-use.
|
||||
*/
|
||||
this.resetInvokersLength = function() {
|
||||
invokers_length = invokers.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides code for closing a lightbox and hiding images.
|
||||
*/
|
||||
this.listenActionClose = function(event) {
|
||||
lightbox_holder.style.display = 'none';
|
||||
lightbox_image.style.display = 'none';
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds src to lightbox image from element's style background-image.
|
||||
* Removes url() par of the string.
|
||||
* @param el
|
||||
*/
|
||||
this.loadImageFromBackgroundImage = function(el) {
|
||||
lightbox_image.src = el.style.backgroundImage.replace(/url\("?(.*[^"])"?\)/, '$1');
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds src to lightbox image from element's child img tag.
|
||||
* @param el
|
||||
*/
|
||||
this.loadImageFromChildImg = function(el) {
|
||||
var img = el.querySelector('img');
|
||||
if(img) {
|
||||
lightbox_image.src = img.src;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Move lightbox image to the center of screen.
|
||||
*/
|
||||
this.lightboxImageCenter = function(bool_label) {
|
||||
// Image
|
||||
lightbox_image.style.left = ((lightbox_holder.offsetWidth - lightbox_image.offsetWidth) / 2) + 'px';
|
||||
lightbox_image.style.top = ((lightbox_holder.offsetHeight - lightbox_image.offsetHeight) / 2) + 'px';
|
||||
|
||||
// Image label.
|
||||
if(bool_label === true) {
|
||||
lightbox_label.style.width = lightbox_image.offsetWidth + 'px';
|
||||
lightbox_label.style.left = ((lightbox_holder.offsetWidth - lightbox_image.offsetWidth) / 2) + 'px';
|
||||
lightbox_label.style.display = 'block';
|
||||
lightbox_label.style.top = (lightbox_image.offsetTop + lightbox_image.offsetHeight - lightbox_label.offsetHeight) + 'px';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns index in invokers array or false on unsuccessful attempt to find the element.
|
||||
* @param el
|
||||
* @returns {*}
|
||||
*/
|
||||
this.getIndexInInvokers = function(el) {
|
||||
var inv_length = invokers_length;
|
||||
while(inv_length--) {
|
||||
if(invokers[inv_length].isEqualNode(el)) {
|
||||
return inv_length;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method decides from where to load src attribute into lightbox_image.
|
||||
* @param el
|
||||
*/
|
||||
this.decideFromLoad = function(el) {
|
||||
// Decide from which source to get image url.
|
||||
if(el.hasAttribute('data-background')) {
|
||||
this.loadImageFromBackgroundImage(el);
|
||||
} else if(el.hasAttribute('data-img')) {
|
||||
this.loadImageFromChildImg(el);
|
||||
}
|
||||
|
||||
lightbox_label.style.display = 'none';
|
||||
lightbox_label.innerHTML = '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides code for opening a lightbox and displaying images.
|
||||
*/
|
||||
this.listenActionOpen = function(el, app, event) {
|
||||
var label = el.getAttribute('data-label');
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault(); // If element is a-tag, prevent from href requesting.
|
||||
|
||||
app.decideFromLoad(el); // Load image into lightbox_image.
|
||||
|
||||
// Change indexes to be opened.
|
||||
previous_button.setAttribute('data-newindex', app.getPreviousIndex(app.getIndexInInvokers(el)));
|
||||
next_button.setAttribute('data-newindex', app.getNextIndex(app.getIndexInInvokers(el)));
|
||||
|
||||
// Show lightbox and image.
|
||||
lightbox_holder.style.display = 'block';
|
||||
lightbox_image.style.display = 'block';
|
||||
if(label != '') {
|
||||
lightbox_label.innerHTML = label;
|
||||
}
|
||||
|
||||
// Center lightbox within the screen.
|
||||
app.lightboxImageCenter(label != '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Add lightbox closing method listener to given element.
|
||||
* @param el
|
||||
*/
|
||||
this.addCloseListenerFor = function(el) {
|
||||
el.addEventListener('click', this.listenActionClose.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Add lightbox opening method listener to given element.
|
||||
* @param el
|
||||
*/
|
||||
this.addOpenListenerFor = function(el) {
|
||||
var app = this;
|
||||
el.addEventListener('click', app.listenActionOpen.bind(app, el, this), true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes all possible listeners at once on class instance creation.
|
||||
*/
|
||||
this.initiateListeners = function() {
|
||||
// Open Listeners.
|
||||
while(invokers_length--) {
|
||||
this.addOpenListenerFor(invokers[invokers_length]);
|
||||
}
|
||||
this.resetInvokersLength();
|
||||
|
||||
// Close Listeners.
|
||||
// On background click.
|
||||
if(hide_on_holder_allowed){
|
||||
this.addCloseListenerFor(lightbox_holder);
|
||||
}
|
||||
// On escape key hit, if requested.
|
||||
if(escape_key_allowed) {
|
||||
window.addEventListener('keydown', function (event) {
|
||||
if(event.keyCode === 27) {
|
||||
BLightBox.listenActionClose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Directional buttons.
|
||||
previous_button.addEventListener('click',this.loadNewImage.bind(this));
|
||||
next_button.addEventListener('click',this.loadNewImage.bind(this));
|
||||
// Allow directing with arrows when enabled.
|
||||
if(arrows_allowed) {
|
||||
window.addEventListener('keydown', function arrowDirections(event) {
|
||||
if(event.keyCode === 37) {
|
||||
previous_button.click();
|
||||
} else if(event.keyCode === 39) {
|
||||
next_button.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialization method that starts BLightBox instance.
|
||||
* @returns {*}
|
||||
*/
|
||||
this.init = function() {
|
||||
// Append lightbox background.
|
||||
document.body.appendChild(lightbox_holder);
|
||||
lightbox_holder.appendChild(previous_button);
|
||||
lightbox_holder.appendChild(lightbox_image);
|
||||
lightbox_holder.appendChild(next_button);
|
||||
lightbox_holder.appendChild(close_label);
|
||||
lightbox_holder.appendChild(lightbox_label);
|
||||
// Add event listeners for invokers.
|
||||
this.initiateListeners();
|
||||
|
||||
// Auto centering on window.resize;
|
||||
window.addEventListener('resize', function() {
|
||||
BLightBox.lightboxImageCenter();
|
||||
});
|
||||
|
||||
return BLightBox;
|
||||
};
|
||||
|
||||
// If autorun is requested, create instance.
|
||||
if(autorun !== undefined && autorun === true) {
|
||||
return this.init();
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
$(document).foundation()
|
||||
|
||||
$ ('#formSend').click (function () {
|
||||
$ (this).value = 'Odesílám...';
|
||||
|
||||
var form = $(this).closest('form');
|
||||
|
||||
$.ajax ({
|
||||
url: form.attr('action'),
|
||||
method: 'post',
|
||||
data: form.serialize ()
|
||||
}).done (function (resp) {
|
||||
if (resp.status == 'success') {
|
||||
alert ('Zpráva úspěšně odeslána. Odpovíme co nejdříve!');
|
||||
window.top.location.reload ();
|
||||
} else {
|
||||
alert (resp.message);
|
||||
}
|
||||
$ (this).value = "ODESLAT";
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,335 @@
|
||||
/**
|
||||
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
|
||||
* @version v4.0.4
|
||||
* @link https://github.com/ten1seven/what-input
|
||||
* @license MIT
|
||||
*/
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
if(typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = factory();
|
||||
else if(typeof define === 'function' && define.amd)
|
||||
define("whatInput", [], factory);
|
||||
else if(typeof exports === 'object')
|
||||
exports["whatInput"] = factory();
|
||||
else
|
||||
root["whatInput"] = factory();
|
||||
})(this, function() {
|
||||
return /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
|
||||
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
module.exports = (function() {
|
||||
|
||||
/*
|
||||
---------------
|
||||
Variables
|
||||
---------------
|
||||
*/
|
||||
|
||||
// cache document.documentElement
|
||||
var docElem = document.documentElement;
|
||||
|
||||
// last used input type
|
||||
var currentInput = 'initial';
|
||||
|
||||
// last used input intent
|
||||
var currentIntent = null;
|
||||
|
||||
// form input types
|
||||
var formInputs = [
|
||||
'input',
|
||||
'select',
|
||||
'textarea'
|
||||
];
|
||||
|
||||
// list of modifier keys commonly used with the mouse and
|
||||
// can be safely ignored to prevent false keyboard detection
|
||||
var ignoreMap = [
|
||||
16, // shift
|
||||
17, // control
|
||||
18, // alt
|
||||
91, // Windows key / left Apple cmd
|
||||
93 // Windows menu / right Apple cmd
|
||||
];
|
||||
|
||||
// mapping of events to input types
|
||||
var inputMap = {
|
||||
'keyup': 'keyboard',
|
||||
'mousedown': 'mouse',
|
||||
'mousemove': 'mouse',
|
||||
'MSPointerDown': 'pointer',
|
||||
'MSPointerMove': 'pointer',
|
||||
'pointerdown': 'pointer',
|
||||
'pointermove': 'pointer',
|
||||
'touchstart': 'touch'
|
||||
};
|
||||
|
||||
// array of all used input types
|
||||
var inputTypes = [];
|
||||
|
||||
// boolean: true if touch buffer timer is running
|
||||
var isBuffering = false;
|
||||
|
||||
// map of IE 10 pointer events
|
||||
var pointerMap = {
|
||||
2: 'touch',
|
||||
3: 'touch', // treat pen like touch
|
||||
4: 'mouse'
|
||||
};
|
||||
|
||||
// touch buffer timer
|
||||
var touchTimer = null;
|
||||
|
||||
|
||||
/*
|
||||
---------------
|
||||
Set up
|
||||
---------------
|
||||
*/
|
||||
|
||||
var setUp = function() {
|
||||
|
||||
// add correct mouse wheel event mapping to `inputMap`
|
||||
inputMap[detectWheel()] = 'mouse';
|
||||
|
||||
addListeners();
|
||||
setInput();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
---------------
|
||||
Events
|
||||
---------------
|
||||
*/
|
||||
|
||||
var addListeners = function() {
|
||||
|
||||
// `pointermove`, `MSPointerMove`, `mousemove` and mouse wheel event binding
|
||||
// can only demonstrate potential, but not actual, interaction
|
||||
// and are treated separately
|
||||
|
||||
// pointer events (mouse, pen, touch)
|
||||
if (window.PointerEvent) {
|
||||
docElem.addEventListener('pointerdown', updateInput);
|
||||
docElem.addEventListener('pointermove', setIntent);
|
||||
} else if (window.MSPointerEvent) {
|
||||
docElem.addEventListener('MSPointerDown', updateInput);
|
||||
docElem.addEventListener('MSPointerMove', setIntent);
|
||||
} else {
|
||||
|
||||
// mouse events
|
||||
docElem.addEventListener('mousedown', updateInput);
|
||||
docElem.addEventListener('mousemove', setIntent);
|
||||
|
||||
// touch events
|
||||
if ('ontouchstart' in window) {
|
||||
docElem.addEventListener('touchstart', touchBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
// mouse wheel
|
||||
docElem.addEventListener(detectWheel(), setIntent);
|
||||
|
||||
// keyboard events
|
||||
docElem.addEventListener('keydown', updateInput);
|
||||
docElem.addEventListener('keyup', updateInput);
|
||||
};
|
||||
|
||||
// checks conditions before updating new input
|
||||
var updateInput = function(event) {
|
||||
|
||||
// only execute if the touch buffer timer isn't running
|
||||
if (!isBuffering) {
|
||||
var eventKey = event.which;
|
||||
var value = inputMap[event.type];
|
||||
if (value === 'pointer') value = pointerType(event);
|
||||
|
||||
if (
|
||||
currentInput !== value ||
|
||||
currentIntent !== value
|
||||
) {
|
||||
|
||||
var activeInput = (
|
||||
document.activeElement &&
|
||||
formInputs.indexOf(document.activeElement.nodeName.toLowerCase()) === -1
|
||||
) ? true : false;
|
||||
|
||||
if (
|
||||
value === 'touch' ||
|
||||
|
||||
// ignore mouse modifier keys
|
||||
(value === 'mouse' && ignoreMap.indexOf(eventKey) === -1) ||
|
||||
|
||||
// don't switch if the current element is a form input
|
||||
(value === 'keyboard' && activeInput)
|
||||
) {
|
||||
|
||||
// set the current and catch-all variable
|
||||
currentInput = currentIntent = value;
|
||||
|
||||
setInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// updates the doc and `inputTypes` array with new input
|
||||
var setInput = function() {
|
||||
docElem.setAttribute('data-whatinput', currentInput);
|
||||
docElem.setAttribute('data-whatintent', currentInput);
|
||||
|
||||
if (inputTypes.indexOf(currentInput) === -1) {
|
||||
inputTypes.push(currentInput);
|
||||
docElem.className += ' whatinput-types-' + currentInput;
|
||||
}
|
||||
};
|
||||
|
||||
// updates input intent for `mousemove` and `pointermove`
|
||||
var setIntent = function(event) {
|
||||
|
||||
// only execute if the touch buffer timer isn't running
|
||||
if (!isBuffering) {
|
||||
var value = inputMap[event.type];
|
||||
if (value === 'pointer') value = pointerType(event);
|
||||
|
||||
if (currentIntent !== value) {
|
||||
currentIntent = value;
|
||||
|
||||
docElem.setAttribute('data-whatintent', currentIntent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// buffers touch events because they frequently also fire mouse events
|
||||
var touchBuffer = function(event) {
|
||||
|
||||
// clear the timer if it happens to be running
|
||||
window.clearTimeout(touchTimer);
|
||||
|
||||
// set the current input
|
||||
updateInput(event);
|
||||
|
||||
// set the isBuffering to `true`
|
||||
isBuffering = true;
|
||||
|
||||
// run the timer
|
||||
touchTimer = window.setTimeout(function() {
|
||||
|
||||
// if the timer runs out, set isBuffering back to `false`
|
||||
isBuffering = false;
|
||||
}, 200);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
---------------
|
||||
Utilities
|
||||
---------------
|
||||
*/
|
||||
|
||||
var pointerType = function(event) {
|
||||
if (typeof event.pointerType === 'number') {
|
||||
return pointerMap[event.pointerType];
|
||||
} else {
|
||||
return (event.pointerType === 'pen') ? 'touch' : event.pointerType; // treat pen like touch
|
||||
}
|
||||
};
|
||||
|
||||
// detect version of mouse wheel event to use
|
||||
// via https://developer.mozilla.org/en-US/docs/Web/Events/wheel
|
||||
var detectWheel = function() {
|
||||
return 'onwheel' in document.createElement('div') ?
|
||||
'wheel' : // Modern browsers support "wheel"
|
||||
|
||||
document.onmousewheel !== undefined ?
|
||||
'mousewheel' : // Webkit and IE support at least "mousewheel"
|
||||
'DOMMouseScroll'; // let's assume that remaining browsers are older Firefox
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
---------------
|
||||
Init
|
||||
|
||||
don't start script unless browser cuts the mustard
|
||||
(also passes if polyfills are used)
|
||||
---------------
|
||||
*/
|
||||
|
||||
if (
|
||||
'addEventListener' in window &&
|
||||
Array.prototype.indexOf
|
||||
) {
|
||||
setUp();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
---------------
|
||||
API
|
||||
---------------
|
||||
*/
|
||||
|
||||
return {
|
||||
|
||||
// returns string: the current input type
|
||||
// opt: 'loose'|'strict'
|
||||
// 'strict' (default): returns the same value as the `data-whatinput` attribute
|
||||
// 'loose': includes `data-whatintent` value if it's more current than `data-whatinput`
|
||||
ask: function(opt) { return (opt === 'loose') ? currentIntent : currentInput; },
|
||||
|
||||
// returns array: all the detected input types
|
||||
types: function() { return inputTypes; }
|
||||
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
|
||||
/***/ }
|
||||
/******/ ])
|
||||
});
|
||||
;
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,t){"function"==typeof define&&define.amd?define([],function(){return t()}):"object"==typeof exports?module.exports=t():e.whatInput=t()}(this,function(){"use strict";function e(e){clearTimeout(s),n(e),f=!0,s=setTimeout(function(){f=!1},1e3)}function t(e){f||n(e)}function n(e){var t=o(e),n=r(e),d=w[e.type];"pointer"===d&&(d=i(e)),p!==d&&(!y&&p&&"keyboard"===d&&"tab"!==v[t]&&m.indexOf(n.nodeName.toLowerCase())>=0||(p=d,a.setAttribute("data-whatinput",p),-1===h.indexOf(p)&&h.push(p))),"keyboard"===d&&u(t)}function o(e){return e.keyCode?e.keyCode:e.which}function r(e){return e.target||e.srcElement}function i(e){return"number"==typeof e.pointerType?b[e.pointerType]:e.pointerType}function u(e){-1===c.indexOf(v[e])&&v[e]&&c.push(v[e])}function d(e){var t=o(e),n=c.indexOf(v[t]);-1!==n&&c.splice(n,1)}var s,c=[],a=document.body,f=!1,p=null,m=["input","select","textarea"],y=a.hasAttribute("data-whatinput-formtyping"),w={keydown:"keyboard",mousedown:"mouse",mouseenter:"mouse",touchstart:"touch",pointerdown:"pointer",MSPointerDown:"pointer"},h=[],v={9:"tab",13:"enter",16:"shift",27:"esc",32:"space",37:"left",38:"up",39:"right",40:"down"},b={2:"touch",3:"touch",4:"mouse"};return function(){var n="mousedown";window.PointerEvent?n="pointerdown":window.MSPointerEvent&&(n="MSPointerDown"),a.addEventListener(n,t),a.addEventListener("mouseenter",t),"ontouchstart"in document.documentElement&&a.addEventListener("touchstart",e),a.addEventListener("keydown",t),a.addEventListener("keyup",d)}(),{ask:function(){return p},keys:function(){return c},types:function(){return h},set:n}});
|
||||
Reference in New Issue
Block a user