diff options
Diffstat (limited to 'js/src/util')
| -rw-r--r-- | js/src/util/index.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js index f1bf6c9fc..1bf9fe954 100644 --- a/js/src/util/index.js +++ b/js/src/util/index.js @@ -188,6 +188,22 @@ const onDOMContentLoaded = callback => { const isRTL = document.documentElement.dir === 'rtl' +const defineJQueryPlugin = (name, plugin) => { + onDOMContentLoaded(() => { + const $ = getjQuery() + /* istanbul ignore if */ + if ($) { + const JQUERY_NO_CONFLICT = $.fn[name] + $.fn[name] = plugin.jQueryInterface + $.fn[name].Constructor = plugin + $.fn[name].noConflict = () => { + $.fn[name] = JQUERY_NO_CONFLICT + return plugin.jQueryInterface + } + } + }) +} + export { TRANSITION_END, getUID, @@ -204,5 +220,6 @@ export { reflow, getjQuery, onDOMContentLoaded, - isRTL + isRTL, + defineJQueryPlugin } |
