PHP Classes

File: assets/htmlwidgets.min.js

Recommend this page to a friend!
  Classes of Nikos M.   PHP Widget Library for HTML Pages   assets/htmlwidgets.min.js   Download  
File: assets/htmlwidgets.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Widget Library for HTML Pages
Generate HTML and JavaScript to show page widgets
Author: By
Last change: v.2.3.0

* enable adding handlers to restore dynamically structured elements
back to default state and remove any event handlers
in case they are re-rendered on same page
* add modelview re-render test example
* minor changes and corrections
Date: 1 year ago
Size: 2,478 bytes
 

Contents

Class file image Download
/** * HtmlWidget, client-side utilities * * @version: 2.3.0 * https://github.com/foo123/HtmlWidget * **/ !function(t,n,e){"use strict";"object"==typeof module&&module.exports?module.exports=e():(t[n]=e(),"function"==typeof define&&define.amd&&define(function(e){return t[n]}))}("undefined"!=typeof self?self:this,"htmlwidgets",function(){"use strict";var t=/^\s+|\s+$/g,n=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(t,"")},e="undefined"!=typeof window&&!!window.document,i=e&&!!window.addEventListener,o=e?window.document:null,u=null,r={};function s(){var t=!1,e={};if(i)try{Object.defineProperty(e,"passive",{get:function(){return!(t=!0)}}),window.addEventListener("test",null,e),window.removeEventListener("test",null,e)}catch(e){t=!1}return t}function a(e,t,n){var r,i;return e&&((i=e.ownerDocument||o).createEvent?((r=i.createEvent("HTMLEvents")).initEvent(t,!0,!1),null!=n&&(r.data=n),e.dispatchEvent(r)):i.createEventObject&&(r=i.createEventObject(),null!=n&&(r.data=n),e.fireEvent("on"+t,r))),e}function c(e,t){return!!e&&(e.classList?e.classList.contains(t):-1!==(" "+e.className+" ").indexOf(" "+t+" "))}return{noop:function(){},addEvent:function(e,t,n,r){return null==u&&(u=s()),i?e.addEventListener(t,n,u?r:"object"==typeof r?!!r.capture:!!r):e.attachEvent("on"+t,n),e},removeEvent:function(e,t,n,r){return null==u&&(u=s()),i?e.removeEventListener(t,n,u?r:"object"==typeof r?!!r.capture:!!r):e.detachEvent("on"+t,n),e},fireEvent:a,addHandler:function(e,t,n){e&&e.id&&(e="hw_"+String(e.id),r[e]||(r[e]={}),r[e][String(t||"")]=n)},removeHandler:function(e){e&&e.id&&(e="hw_"+String(e.id),r[e]&&delete r[e])},getHandler:function(e,t,n){if(e&&e.id){e="hw_"+String(e.id);if(r[e])return r[e][String(t||"")]||n}return n},hasClass:c,addClass:function(e,t){return e&&!c(e,t)&&(e.classList?e.classList.add(t):e.className=""===e.className?t:e.className+" "+t),e},removeClass:function(e,t){return e&&(e.classList?e.classList.remove(t):e.className=n((" "+e.className+" ").replace(" "+t+" "," "))),e},resetInput:function(e,t){var n=e.parentNode,r=e.nextSibling,i=o.createElement("form");return i.appendChild(e),i.reset(),r?n.insertBefore(e,r):n.appendChild(e),i=null,t&&a(e,t),e},throttle:function(t,n){var r=!1;return function(){var e=arguments;r||(t.apply(this,e),r=!0,setTimeout(function(){r=!1},n))}},debounce:function(n,r){var i=null;return function(){var e=this,t=arguments;clearTimeout(i),i=setTimeout(function(){n.apply(e,t)},r)}}}});