import $ from './$';
|
|
const noTrigger = ('resize scroll').split(' ');
|
function eventShortcut(name, ...args) {
|
if (typeof args[0] === 'undefined') {
|
for (let i = 0; i < this.length; i += 1) {
|
if (noTrigger.indexOf(name) < 0) {
|
if (name in this[i]) this[i][name]();
|
else {
|
$(this[i]).trigger(name);
|
}
|
}
|
}
|
return this;
|
}
|
return this.on(name, ...args);
|
}
|
|
function click(...args) {
|
return eventShortcut.bind(this)('click', ...args);
|
}
|
function blur(...args) {
|
return eventShortcut.bind(this)('blur', ...args);
|
}
|
function focus(...args) {
|
return eventShortcut.bind(this)('focus', ...args);
|
}
|
function focusin(...args) {
|
return eventShortcut.bind(this)('focusin', ...args);
|
}
|
function focusout(...args) {
|
return eventShortcut.bind(this)('focusout', ...args);
|
}
|
function keyup(...args) {
|
return eventShortcut.bind(this)('keyup', ...args);
|
}
|
function keydown(...args) {
|
return eventShortcut.bind(this)('keydown', ...args);
|
}
|
function keypress(...args) {
|
return eventShortcut.bind(this)('keypress', ...args);
|
}
|
function submit(...args) {
|
return eventShortcut.bind(this)('submit', ...args);
|
}
|
function change(...args) {
|
return eventShortcut.bind(this)('change', ...args);
|
}
|
function mousedown(...args) {
|
return eventShortcut.bind(this)('mousedown', ...args);
|
}
|
function mousemove(...args) {
|
return eventShortcut.bind(this)('mousemove', ...args);
|
}
|
function mouseup(...args) {
|
return eventShortcut.bind(this)('mouseup', ...args);
|
}
|
function mouseenter(...args) {
|
return eventShortcut.bind(this)('mouseenter', ...args);
|
}
|
function mouseleave(...args) {
|
return eventShortcut.bind(this)('mouseleave', ...args);
|
}
|
function mouseout(...args) {
|
return eventShortcut.bind(this)('mouseout', ...args);
|
}
|
function mouseover(...args) {
|
return eventShortcut.bind(this)('mouseover', ...args);
|
}
|
function touchstart(...args) {
|
return eventShortcut.bind(this)('touchstart', ...args);
|
}
|
function touchend(...args) {
|
return eventShortcut.bind(this)('touchend', ...args);
|
}
|
function touchmove(...args) {
|
return eventShortcut.bind(this)('touchmove', ...args);
|
}
|
function resize(...args) {
|
return eventShortcut.bind(this)('resize', ...args);
|
}
|
function scroll(...args) {
|
return eventShortcut.bind(this)('scroll', ...args);
|
}
|
|
export {
|
click,
|
blur,
|
focus,
|
focusin,
|
focusout,
|
keyup,
|
keydown,
|
keypress,
|
submit,
|
change,
|
mousedown,
|
mousemove,
|
mouseup,
|
mouseenter,
|
mouseleave,
|
mouseout,
|
mouseover,
|
touchstart,
|
touchend,
|
touchmove,
|
resize,
|
scroll,
|
};
|