web2app-spa
Version:
This template is primarily designed to easily convert HTML pages and URLs into a Capacitor/Cordova based iOS/Android app that can be used as Single-page application (SPA).
1 lines • 2.84 kB
JavaScript
;const UIItemList={alignType:{}};UIItemList.alignType.VERTICAL="vertical",UIItemList.alignType.HORIZONTAL="horizontal",UIItemList.alignType.BOTH="both",UIItemList.create=function(e={}){e.width||(e.width=600),e.height||(e.height=getDefaultContainerBox().height);const t=createBox();let n="block",l=[],i=[],c="",a=function(){};t.width=e.width,t.height=e.height,t.color="transparent",t.scrollX=0,t.scrollY=0,t.element.style.wordSpacing="0px",t.element.style.letterSpacing="0px",t.element.style.fontSize="0px";const o=function(e){e.element.style.position="relative",e.left=0,e.top=0,e.element.style.display=n,e.onClick((function(e,n){const l=s();a(t,e,l,n)})),e.isSelected=function(){for(let t=0;t<i.length;t++)if(i[t].getIndex()==e.getIndex())return 1;return 0},e.getData=function(){return e.data},e.getIndex=function(){return e.index},l.push(e),t.add(e),that=t},s=function(){let e="";return i.length>0&&(e=i[i.length-1]),e};return t.setItemCreationFunction=function(e){c=e},t.getItemList=function(){return[...l]},t.createItemsByDataList=function(e){if(t.clearItems(),c)for(let n=0;n<e.length;n++){const l=c(e[n],t);l.data=e[n],l.index=n,o(l)}else;},t.addItemToSelectedList=function(e){0==e.isSelected()&&i.push(e)},t.removeItemFromSelectedList=function(e){if(1==e.isSelected()){const t=[];for(let n=0;n<i.length;n++)i[n].getIndex()!=e.getIndex()&&t.push(i[n]);i=t}},t.getSelectedItemList=function(){return[...i]},t.selectItemByIndex=function(e){if(l.length>e){const n=l[e],i=s();a(t,n,i)}},t.clearItems=function(){t.html="",l=[],i=[]},t.onSelectionChange=function(e){a=e},t.searchItemByText=function(e){e=e.toLowerCase();for(let t=0;t<l.length;t++){let n=l[t].getData().searchText.toLowerCase();n=n.replace(/ı/g,"i"),e=e.replace(/ı/g,"i"),n=n.replace(/i̇/g,"i"),e=e.replace(/i̇/g,"i"),n=n.replace(/ç/g,"c"),e=e.replace(/ç/g,"c"),n=n.replace(/ğ/g,"g"),e=e.replace(/ğ/g,"g"),n=n.replace(/ş/g,"s"),e=e.replace(/ş/g,"s"),n=n.replace(/ü/g,"u"),e=e.replace(/ü/g,"u"),n=n.replace(/ö/g,"o"),e=e.replace(/ö/g,"o"),n.search(e)>-1||l[t].getData().searchText.indexOf("*")>-1?l[t].visible=1:l[t].visible=0}},t.setInnerSpaces=function(e,n,l,i){t.element.style.paddingLeft=e+"px",t.element.style.paddingTop=n+"px",t.element.style.paddingRight=l+"px",t.element.style.paddingBottom=i+"px"},t.setItemAlignment=function(e){switch(l.length,e){case UIItemList.alignType.BOTH:t.scrollX=0,t.scrollY=1,t.element.style.whiteSpace="normal",n="inline-block";break;case UIItemList.alignType.HORIZONTAL:t.scrollX=1,t.scrollY=0,t.element.style.whiteSpace="nowrap",n="inline-block";break;case UIItemList.alignType.VERTICAL:t.scrollX=0,t.scrollY=1,t.element.style.whiteSpace="normal",n="block";break}},t.forEach=function(e=function(){}){for(let t=0;t<l.length;t++)e(l[t])},t.setItemAlignment(UIItemList.alignType.VERTICAL),makeBasicObject(t),t};