-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsmart.card.js
6 lines (4 loc) · 1.91 KB
/
smart.card.js
1
2
3
4
5
6
/* Smart UI v15.2.0 (2023-04-20)
Copyright (c) 2011-2023 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart("smart-card",class extends Smart.ContentElement{static get properties(){return{dataSource:{value:null,type:"object?",reflectToAttribute:!1},itemTemplate:{value:null,type:"any?",reflectToAttribute:!1},contentHandler:{value:null,type:"function?",reflectToAttribute:!1}}}static get listeners(){return{mouseenter:"_mouseEnterHandler",mouseleave:"_mouseLeaveHandler",swipeleft:"_swipeHandler",swiperight:"_swipeHandler",swipetop:"_swipeHandler",swipebottom:"_swipeHandler"}}static get styleUrls(){return["smart.card.css"]}template(){return'<div id="container" inner-h-t-m-l="[[innerHTML]]" role="presentation">\n <content></content>\n </div>'}propertyChangedHandler(e,t,n){super.propertyChangedHandler(e,t,n);const r=this;switch(e){case"itemTemplate":r._template=r._handleTemplate(),r.innerHTML=r._processTemplate(),r.contentHandler&&r.contentHandler(r);break;case"dataSource":r.innerHTML=r._processTemplate(),r.contentHandler&&r.contentHandler(r);break;case"contentHandler":r.contentHandler&&r.contentHandler(r)}}ready(){super.ready()}render(){const e=this;e.setAttribute("role","group"),e._template=e._handleTemplate(),e._template.hasBindings?e.innerHTML=e._processTemplate():e.itemTemplate&&(e.innerHTML=e._template.content),e.contentHandler&&e.contentHandler(e),super.render()}_handleTemplate(){const e=this;let t=e.itemTemplate,n="",r=!1;return e.itemTemplate?t instanceof HTMLElement?n=t.innerHTML:(t=document.getElementById(t),n=t?t.innerHTML:""):n=e.innerHTML,/{{\w+}}/g.exec(n)&&(r=!0),{content:n,hasBindings:r}}_processTemplate(){const e=this,t=e._template.content.match(/{{\w+}}/g),n=e.dataSource||{};let r=e._template.content;return t&&0!==t.length?(t.forEach((function(e){const t=e.replace("{{","").replace("}}","");let a=n[t];void 0===a&&(a=""),r=r.replace(e,a)})),r):r}_swipeHandler(){}});