mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 09:05:45 +00:00
69 lines
1.3 KiB
JavaScript
69 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
import $ from "jquery";
|
|
|
|
/**
|
|
* Route side-wide events
|
|
*/
|
|
|
|
const EventsUI = (($) => {
|
|
const on = $.fn.on;
|
|
const off = $.fn.off;
|
|
|
|
// Constants
|
|
const W = window;
|
|
const $W = $(W);
|
|
const D = document;
|
|
const $Body = $("body");
|
|
|
|
const NAME = "EventsUI";
|
|
|
|
class EventsUI {
|
|
static process(el, args) {
|
|
let modEl = el;
|
|
const eventName = args[0];
|
|
const tagName = typeof el !== undefined ? $(el).prop("tagName") : null;
|
|
|
|
switch (tagName) {
|
|
case "HTML":
|
|
case "BODY":
|
|
modEl = $W;
|
|
break;
|
|
}
|
|
|
|
return [modEl, args];
|
|
}
|
|
}
|
|
|
|
// rewrite jQuery functions
|
|
$.fn.on = function () {
|
|
const result = EventsUI.process(this, arguments);
|
|
return on.apply(...result);
|
|
};
|
|
|
|
$.fn.off = function () {
|
|
const result = EventsUI.process(this, arguments);
|
|
return off.apply(...result);
|
|
};
|
|
|
|
const scrollTop = $.fn.scrollTop;
|
|
// rewrite scrollTop
|
|
$.fn.scrollTop = function () {
|
|
let el = this;
|
|
const args = arguments;
|
|
|
|
const tagName = typeof el !== undefined ? $(el).prop("tagName") : null;
|
|
|
|
switch (tagName) {
|
|
case "HTML":
|
|
case "BODY":
|
|
el = $W;
|
|
break;
|
|
}
|
|
|
|
return scrollTop.apply(el, args);
|
|
};
|
|
})($);
|
|
|
|
export default EventsUI;
|