/// /// /// /// /// import JqueryFormSaver from './JqueryFormSaver'; import makeid from './makeid'; const uniqueid = makeid(5); /** * Element Counter */ // eslint-disable-next-line @typescript-eslint/no-unused-vars let Count = -1; /** * SMARTFORM * @todo save form user input */ /** * check if running in browser */ const isBrowser = new Function('try {return this===window;}catch(e){ return false;}'); //console.log(`is browser : ${isBrowser()}`); if (isBrowser()) { (function () { const isJqueryLoaded = typeof jQuery != 'undefined'; //console.log(`is jQuery loaded : ${isJqueryLoaded}`); if (isJqueryLoaded) { //console.log("Apply plugin smartform jQuery"); (function ($) { $.fn.getIDName = function () { if ($(this).attr('aria-autovalue')) { $(this).val(uniqueid).trigger('change'); } return JqueryFormSaver.get_identifier(this); }; $.fn.has_attr = function (name: string) { const attr = $(this).attr(name); // For some browsers, `attr` is undefined; for others, // `attr` is false. Check for both. return typeof attr !== 'undefined' && attr !== false; }; $.fn.smartForm = function () { Count++; new JqueryFormSaver($(this).get(0)); }; $.arrive = function (target, callback) { if (target) { $(target).bind('DOMNodeInserted', callback); } else { if (typeof callback == 'function') { $(document).bind('DOMNodeInserted', callback); } else if (typeof target == 'function') { $(document).bind('DOMNodeInserted', target); } } }; })(jQuery); } })(); }