From f21c0e004960fdeb5cfed3c2f042d67bd14fc770 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 10 Aug 2024 21:43:10 +0100 Subject: [PATCH] Added build pipeline Changed to use sprites Added guardian and cascade options --- .gitignore | 2 + build.bat | 22 - build/bbtreeview.min.css | 5 - build/bbtreeview.min.js | 18 - build/checkbox.png | Bin 337 -> 0 bytes build/collapse.png | Bin 185 -> 0 bytes build/expand.png | Bin 199 -> 0 bytes build/folder.png | Bin 322 -> 0 bytes build/line.png | Bin 125 -> 0 bytes build/uncheckbox.png | Bin 234 -> 0 bytes demo-test.html | 94 +- package-lock.json | 2343 +++++++++++++++++ package.json | 12 + src/checkbox.png | Bin 337 -> 0 bytes src/checkbox.svg | 64 - src/collapse.png | Bin 185 -> 0 bytes src/expand.png | Bin 199 -> 0 bytes src/folder.png | Bin 322 -> 0 bytes src/folder.svg | 44 - src/icon.svg | 62 - src/index.js | 5 + src/line.png | Bin 125 -> 128 bytes src/sprite.png | Bin 0 -> 720 bytes src/{bbtreeview.css => treeview.css} | 79 +- src/{bbtreeview.js => treeview/treeview.js} | 182 +- .../treeviewnode.js} | 277 +- src/uncheckbox.png | Bin 234 -> 0 bytes src/version.txt | 4 - webpack.config.js | 48 + 29 files changed, 2721 insertions(+), 540 deletions(-) create mode 100644 .gitignore delete mode 100644 build.bat delete mode 100644 build/bbtreeview.min.css delete mode 100644 build/bbtreeview.min.js delete mode 100644 build/checkbox.png delete mode 100644 build/collapse.png delete mode 100644 build/expand.png delete mode 100644 build/folder.png delete mode 100644 build/line.png delete mode 100644 build/uncheckbox.png create mode 100644 package-lock.json create mode 100644 package.json delete mode 100644 src/checkbox.png delete mode 100644 src/checkbox.svg delete mode 100644 src/collapse.png delete mode 100644 src/expand.png delete mode 100644 src/folder.png delete mode 100644 src/folder.svg delete mode 100644 src/icon.svg create mode 100644 src/index.js create mode 100644 src/sprite.png rename src/{bbtreeview.css => treeview.css} (50%) rename src/{bbtreeview.js => treeview/treeview.js} (81%) rename src/{bbtreeviewnode.js => treeview/treeviewnode.js} (59%) delete mode 100644 src/uncheckbox.png delete mode 100644 src/version.txt create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c925c21 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/dist +/node_modules diff --git a/build.bat b/build.bat deleted file mode 100644 index e8ed8f6..0000000 --- a/build.bat +++ /dev/null @@ -1,22 +0,0 @@ -del bbtreeview.min.js -del bbtreeview.min.tmp -del build/bbtreeview.min.js - -cd src - -type version.txt >> ../bbtreeview.min.js - -@REM "C:\B\Portable Files (dev)\Google Closure Compiler\closure-compiler-v20231112.jar" --js *.js --js_output_file ../bbtreeview.min.tmp -@REM npx google-closure-compiler --compilation_level=ADVANCED --js=*.js --js_output_file=../bbtreeview.min.tmp -@REM npx google-closure-compiler --compilation_level=ADVANCED --warning_level=VERBOSE --js=*.js --js_output_file=bbtreeview.min.tmp -@REM npx google-closure-compiler --warning_level=VERBOSE --js=*.js --js_output_file=bbtreeview.min.tmp - -move bbtreeview.min.tmp ../bbtreeview.min.tmp - -cd.. - -type bbtreeview.min.tmp >> bbtreeview.min.js - -move bbtreeview.min.js build/bbtreeview.min.js - -del bbtreeview.min.tmp diff --git a/build/bbtreeview.min.css b/build/bbtreeview.min.css deleted file mode 100644 index 4e4654d..0000000 --- a/build/bbtreeview.min.css +++ /dev/null @@ -1,5 +0,0 @@ -/** - * BBTreeview - * @version v0.1.1.006 (2023/09/27 2218) - */ - ul.bbtreeview{background-image:url(line.png);background-position:4px 8px;background-repeat:repeat-y;list-style:none;padding:0;margin:0 0 0 8px}ul.bbtreeview ul{background-image:url(line.png);background-position:4px 8px;background-repeat:repeat-y;list-style:none;margin:0 0 0 8px;padding:0}ul.bbtreeview li{background-position:0 calc((1.2em - 9px)/ 2);background-repeat:no-repeat;cursor:default;display:block;padding-left:14px;width:100%}ul.bbtreeview li.c{background-image:url(expand.png)}ul.bbtreeview li.e{background-image:url(collapse.png)}ul.bbtreeview li.hidden{display:none}ul.bbtreeview div.li{display:block;height:1.2em;padding-left:4px}ul.bbtreeview div.li.highlighted{background-color:rgb(169,201,249,.7)}ul.bbtreeview div.li>div.icon{background-position:0 center;background-repeat:no-repeat;display:inline-block;height:100%;width:calc(16px)}ul.bbtreeview div.li>div.folder{background-image:url(folder.png)}ul.bbtreeview li>div.li>div.checkbox{background-image:url(uncheckbox.png)}ul.bbtreeview li.x>div.li>div.checkbox{background-image:url(checkbox.png)}ul.bbtreeview div.li>span{-webkit-user-select:none;-ms-user-select:none;user-select:none;display:inline-block;height:1.2em;line-height:1.2em;overflow:hidden;padding-left:6px;text-overflow:ellipsis;vertical-align:top;white-space:nowrap}ul.bbtreeview div.li>span.noicon{padding-left:0!important} \ No newline at end of file diff --git a/build/bbtreeview.min.js b/build/bbtreeview.min.js deleted file mode 100644 index 6c4f307..0000000 --- a/build/bbtreeview.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * BBTreeview - * @version v0.1.2.044 (2024/01/09 2118) - */ -class BBTreeview{constructor(a){this.Options={};this.initialiseComponents(a)}initialiseComponents(a){this.Options=Object.assign({ID:null,ShowCheckbox:!1,ShowSelection:!0,EnablePullUp:!1,ShowIcon:!0},a);this.createTreeview()}get Container(){return this.getTreeview()}AddItem(a){a=Object.assign({ID:null,ParentID:null,Name:"",Hint:"",Value:"",Icon:"folder",Checked:!1,Tag:null},a);null==a.ID&&(a.ID=this.generateID());null==a.Tag&&(a.Tag="");if(null!=this.Find(a.ID))return!1;let b=null;if(null!=a.ParentID&& -(b=this.Find(a.ParentID),null==b))return!1;b=null==b?this.Container:b.ChildNode;const c=this.generateNodeHtml(a);this.appendHtml(b,c);this.Find(a.ID).InvalidateEvents();return!0}Remove(a){a=this.Find(a);if(null==a)return!1;a.Remove();return!0}Clear(){this.initialiseComponents(this.Options)}CollapseAll(){this.GetAllNodes().forEach(function(a){a.Collapse()})}ExpandAll(){this.GetAllNodes().forEach(function(a){a.Expand()})}CheckAll(a){this.Options.ShowCheckbox&&this.GetAllNodes().forEach(function(b){b.Check(a)})}Find(a){if(null== -this.Container)console.log("BBTreeview container not found");else return a=this.Container.querySelectorAll("li[data-bbtv-id='"+a+"']"),0>=a.length?null:new BBTreeviewNode(this,a[0])}FindByName(a){let b=[];this.GetAllNodes().forEach(function(c){c.Name==a&&b.push(c)});return b}FindByValue(a){let b=[];this.GetAllNodes().forEach(function(c){c.Value==a&&b.push(c)});return b}GetAllNodes(){const a=this,b=a.Container.querySelectorAll("li");if(0>=b.length)return[];let c=[];b.forEach(function(d){d=d.getAttribute("data-bbtv-id"); -a.isNullOrWhitespace(d)||(d=a.Find(d),null!=d&&c.push(d))});return c}GetCheckedNodes(){let a=[];this.GetAllNodes().forEach(function(b){b.IsChecked&&a.push(b)});return a}GetCheckedValues(){let a=[];this.GetCheckedNodes().map(function(b){a.push(b.Value)});return a}GetCheckedTags(){let a=[];this.GetCheckedNodes().map(function(b){a.push(b.Tag)});return a}GetSelectedNode(){let a=null;this.GetAllNodes().forEach(function(b){if(b.IsHighlighted)return a=b,!1});return a}appendHtml(a,b){let c=document.createElement("template"); -c.innerHTML=b;c=c.content.firstChild;a.appendChild(c)}createTreeview(){let a=this.getContainer();null!=a&&(a.innerHTML='')}generateID(){return"treeviewItem"+(Math.floor(1000001*Math.random())+100).toString()}generateNodeHtml(a){var b="";this.isNullOrWhitespace(a.Tag)||(b=encodeURIComponent(JSON.stringify(a.Tag)));b='
  • ';b+='
    ';this.Options.ShowCheckbox&&(b+='
    '); -this.Options.ShowIcon?(b+='
    ',b+=''+a.Name+""):b+=''+a.Name+"";return b+"
  • "}getContainer(){let a=document.getElementsByTagName("body");if(!(0>=a.length||(a=a[0],a=a.querySelectorAll(this.Options.ID),0>=a.length)))return a=a[0]}getNode(a){a=(this.isTag(a,"li")?a:this.parentsUntilTagName(a,"li")).getAttribute("data-bbtv-id");return this.isNullOrWhitespace(a)?null:this.Find(a)}getTreeview(){let a= -this.getContainer();if(null!=a&&(a=a.querySelectorAll("ul.bbtreeview"),!(0>=a.length)))return a=a[0]}isNullOrWhitespace(a){return"undefined"==typeof a||null==a?!0:0>=a.toString().trim().length}isTag(a,b){return a.tagName.toLowerCase()==b}parentsUntilTagName(a,b){for(;"undefined"!=typeof a.parentNode;){a=a.parentNode;if("undefined"==typeof a)break;if(this.isTag(a,"ul")&&a.classList.contains("bbtreeview"))return null;if(this.isTag(a,b))break}return a}};class BBTreeviewNode{constructor(a,b){this.Treeview=a;this.Node=b}get Checkbox(){if(!this.Treeview.Options.ShowCheckbox)return null;const a=this.Node.querySelectorAll("div.icon.checkbox");return"undefined"==typeof a?null:a[0]}get ChildNode(){let a=this.Node.querySelectorAll("ul");return 0>=a.length?null:a[0]}get ChildNodes(){const a=this.ChildNode;if(null==a)return[];let b=a.querySelectorAll("li");if(0>=b.length)return[];let c=[];b.forEach(function(d){"undefined"!=typeof d.parentNode&&d.parentNode== -a&&c.push(d)});return c}get IsChecked(){return this.Treeview.Options.ShowCheckbox?this.Node.classList.contains("x"):!1}get Container(){return this.Node.querySelectorAll("div.li")[0]}get Hint(){return this.Label.getAttribute("title")}get ID(){return this.Node.getAttribute("data-bbtv-id")}get IsExpanded(){return this.Node.classList.contains("e")?!0:this.Node.classList.contains("c")?!1:null}get IsHighlighted(){return this.Container.classList.contains("highlighted")}get Label(){return this.Node.querySelectorAll("span")[0]}get Name(){return this.Label.textContent}get ParentID(){const a= -this.ParentNode;return null==a?null:a.getAttribute("data-bbtv-id")}get ParentNode(){return this.parentsUntilTagName(this.Node,"li")}get Tag(){let a=this.Node.getAttribute("data-bbtv-tag");return this.Treeview.isNullOrWhitespace(a)?null:JSON.parse(decodeURIComponent(a))}get Value(){return this.Node.getAttribute("data-bbtv-value")}Check(a){const b=this;b.setCheckbox(b.Node,a);b.Node.querySelectorAll("li").forEach(function(d){b.setCheckbox(d,a)});let c=b.ParentNode;if(null!=c)if(b.Treeview.Options.EnablePullUp)for(;;){const d= -0=d)}}Collapse(){this.Node.classList.contains("e")&&(this.Node.classList.remove("e"),this.Node.classList.add("c"));this.ChildNodes.forEach(function(a){a.classList.add("hidden")})}Expand(){this.Node.classList.contains("c")&&(this.Node.classList.remove("c"),this.Node.classList.add("e")); -this.ChildNodes.forEach(function(a){a.classList.remove("hidden")})}Remove(){null!=this.ParentNode&&(this.ParentNode.classList.contains("e")&&this.ParentNode.classList.remove("e"),this.ParentNode.classList.contains("c")&&this.ParentNode.classList.remove("c"));this.Node.parentNode.removeChild(this.Node)}InvalidateEvents(){const a=this;a.Node.addEventListener("click",function(b){b.stopPropagation();b.preventDefault();!a.isTag(b.target,"li")||0>b.offsetX||16b.offsetY||16*~g3ml%978PplO=vN2znVyNJ~#=Sm~zljEOse zJ-%_rzc)8G?-kHn#i(%7K}~I$wSb_{hxhmGMHRO4Wiar&v@|wydNnhM2OOMwdAa}n z-~a#H+fP`}a#+F6Lq>)FNinmbjKb~*_5qD16EwL>jyfvv8nLk1G4XC>eq`>jbGd`~ zfv<|Y8F*&QoXOfK(xvNgfcJ_9OX^|<9%c{LE9MX0-{1efQAERS!ol!_AA6cN1v0cT zK0iNyKgXB#%mTZW65ETPpNnnMa%5Cl%Dmuph@_F|!@$E>;JVWk ee!c?-7#RL!!lvI66}TXMsm# zF#`kNArNL1)$nQn3aWd$IEF}EPEHUJ5eZ2!C@d^AOyFRg#Asl&*G84Wm1U8eb3i}< ZBZHzM*EO$=bs<1444$rjF6*2UngAnZG_n8y diff --git a/build/expand.png b/build/expand.png deleted file mode 100644 index 72f77673d71288cf01f3f535c86b9a89891cf74f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4?3?zm2ODh8@#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6-k0X`wFXV0Epvu4e?bLUpATJ`_`|CK9O=H})~Nl6tH6euYvF*7r-UcI`d zzU(tlJ!gSOWHAE+-yslY6xHx*01E1Ox;TbNTux395fKSVFeof6G)&+q^ep6Ln53$( nsW_E;4zF1Iii=`ESq26>Kkm1NTc*zf>SOS9^>bP0l+XkKT>&~= diff --git a/build/folder.png b/build/folder.png deleted file mode 100644 index 8527862cf8e4e872637387de11b4c82e151fbf6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 322 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBufiR<}hF1en@VcjqV~B-+@&XZqeO3<>51%-(rQzX!`_vT@ z9Dn|wKX5@YZR29DQ^z?a;^%+ab^OpV{qqM`A7Bwp{_**z5jlR|HgZoyB0Alcv(Jk=Kr*0a|Vuo zfBzo)@c1(Gfi6|G&Dujh7jm9{fIjn`(sh<}({61~E&x@h)g$ zjF@a>_~7{R-~a#p`S+vYVM%xNb!1@J z*w6hZkrl}2EbxddW?8eR=RK_O2U#}J9|A{9u3;Thx N44$rjF6*2Ung9~g97O;C diff --git a/build/uncheckbox.png b/build/uncheckbox.png deleted file mode 100644 index 8b6fd109ddc1a92ecd2875850d2acbe2771b4990..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBuf-vKbiP>*~g7uy*jv*HQ$r8UB1ig$Uq@|}btaMX&#>Ab# z9^bg*-SU4GYf8=LmXs|v_VpXV| zV5K3>Gh>0t&4eoqS`rRHRzH4!U$3RC{5a}KNyD2aD}^|AAD!~T#0hB%>smGBWf~e8 Z88(|+-jrup><4rTgQu&X%Q~loCIDfbN7(=X diff --git a/demo-test.html b/demo-test.html index 49cfa67..776a14e 100644 --- a/demo-test.html +++ b/demo-test.html @@ -11,10 +11,10 @@ - - - - + + + + @@ -31,16 +31,35 @@

    Create demo treeview

    -

    -

    -

    -

    +

    + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + +

    +

    Load sample nodes

    - +

    @@ -118,53 +137,30 @@ body {