selection.js
/**
* Enable/disable selectability of an element
* @module mucss/selection
*/
var css = require('./css');
/**
* Disable or Enable any selection possibilities for an element.
*
* @param {Element} el Target to make unselectable.
*/
exports.disable = function(el){
css(el, {
'user-select': 'none',
'user-drag': 'none',
'touch-callout': 'none'
});
el.setAttribute('unselectable', 'on');
el.addEventListener('selectstart', pd);
};
exports.enable = function(el){
css(el, {
'user-select': null,
'user-drag': null,
'touch-callout': null
});
el.removeAttribute('unselectable');
el.removeEventListener('selectstart', pd);
};
/** Prevent you know what. */
function pd(e){
e.preventDefault();
}