Skip to content

Commit

Permalink
rearrange itemcluster code
Browse files Browse the repository at this point in the history
  • Loading branch information
acenturyandabit committed Dec 21, 2021
1 parent 191c319 commit ecd0bd1
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 99 deletions.
55 changes: 44 additions & 11 deletions cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13334,6 +13334,35 @@ function _itemcluster_extend_svg(me) { // very polymorph_core functions!
}
};

function _itemcluster_extend_contextmenu_orbit() {
let orbitBtn = htmlwrap(`<li class="orbit">Toggle orbit around point</li>`);
this.rootContextMenu.appendChild(orbitBtn);
let orbiterParams;
orbitBtn.addEventListener("click", (e) => {
if (orbiterParams) {
// stop orbiting
clearInterval(orbiterParams.interval);
orbiterParams = undefined;
} else {
orbiterParams = {};

// Find the centre to orbit around
let coords = this.mapPageToSvgCoords(e.pageX, e.pageY);
orbiterParams.cx = coords.x;
orbiterParams.cy = coords.y;
// start orbiting
orbiterParams.interval = setInterval(() => {
if (this.container.visible()) {
for (let i in )
}
}, 500);
}
this.rootContextMenu.style.display = "none";
});


};

function _itemcluster_extend_contextmenu() {
///////////////////////////////////////////////////////////////////////////////////////
//Various context menus
Expand All @@ -13346,14 +13375,18 @@ function _itemcluster_extend_contextmenu() {
return true; //only activate on clicks to the background.
}
}
this.rootcontextMenu = contextMenuManager.registerContextMenu(`
this.rootContextMenu = contextMenuManager.registerContextMenu(`
<li class="pastebtn">Paste</li>
<li class="collect">Collect items here</li>
<li> Arrange in hierarchy
<ul>
<li class="hierarchy">Arrange in hierarchy</li>
<li class="hierarchy squashed">Arrange in squashed hierarchy</li>
<li class="hierarchy horizontal">Arrange in horizontal hierarchy</li>
<li class="hierarchy radial">Arrange in radial hierarchy</li>
<li class="hierarchy biradial">Arrange in biradial hierarchy</li>
</ul>
</li>
<li class="search">Search
<ul class="submenu">
<li><input class="searchbox"></li>
Expand All @@ -13362,7 +13395,8 @@ function _itemcluster_extend_contextmenu() {
</li>
<!--<li class="hierarchy radial stepped">Stepped radial hierarchy</li>-->
`, this.rootdiv, undefined, chk);
this.rootcontextMenu.querySelector(".pastebtn").addEventListener("click", (e) => {
_itemcluster_extend_contextmenu_orbit.apply(this);
this.rootContextMenu.querySelector(".pastebtn").addEventListener("click", (e) => {
if (polymorph_core.shared.itemclusterCopyElement) {
let coords = this.mapPageToSvgCoords(e.pageX, e.pageY);
polymorph_core.shared.itemclusterCopyElement.forEach((v) => {
Expand All @@ -13381,10 +13415,10 @@ function _itemcluster_extend_contextmenu() {
for (let i in polymorph_core.items) {
this.arrangeItem(i);
}
this.rootcontextMenu.style.display = "none";
this.rootContextMenu.style.display = "none";
}
})
this.rootcontextMenu.querySelector(".collect").addEventListener("click", (e) => {
this.rootContextMenu.querySelector(".collect").addEventListener("click", (e) => {
let rect = this.itemSpace.getBoundingClientRect();
for (let i in polymorph_core.items) {
if (polymorph_core.items[i].itemcluster && polymorph_core.items[i].itemcluster.viewData && polymorph_core.items[i].itemcluster.viewData[this.settings.currentViewName]) {
Expand Down Expand Up @@ -13930,7 +13964,7 @@ function _itemcluster_extend_contextmenu() {
}
}

this.rootcontextMenu.addEventListener("click", (e) => {
this.rootContextMenu.addEventListener("click", (e) => {
if (!e.target.classList.contains("hierarchy")) return;
let visibleItems = generateHierarchy();
//visible items looks like this:
Expand Down Expand Up @@ -13968,9 +14002,9 @@ function _itemcluster_extend_contextmenu() {
let focusSearchItem = (index) => {
let id = this.searchArray[index];
if (!id) {
this.rootcontextMenu.querySelector(".searchNextResult").style.background = "palevioletred";
this.rootContextMenu.querySelector(".searchNextResult").style.background = "palevioletred";
} else {
this.rootcontextMenu.querySelector(".searchNextResult").style.background = "white";
this.rootContextMenu.querySelector(".searchNextResult").style.background = "white";
let ic = polymorph_core.items[this.settings.currentViewName].itemcluster;
ic.scale = 1;
ic.cx = polymorph_core.items[id].itemcluster.viewData[this.settings.currentViewName].x * ic.XZoomFactor;
Expand All @@ -13979,20 +14013,20 @@ function _itemcluster_extend_contextmenu() {
this.viewGrid();
}
}
this.rootcontextMenu.querySelector(".search input").addEventListener("input", () => {
this.rootContextMenu.querySelector(".search input").addEventListener("input", () => {
//create the search array
this.searchArray = [];
for (let id in polymorph_core.items) {
if (this.itemIsOurs(id)) {
if (polymorph_core.items[id][this.settings.textProp] && polymorph_core.items[id][this.settings.textProp].includes(this.rootcontextMenu.querySelector(".search input").value)) {
if (polymorph_core.items[id][this.settings.textProp] && polymorph_core.items[id][this.settings.textProp].includes(this.rootContextMenu.querySelector(".search input").value)) {
this.searchArray.push(id);
}
}
}
if (searchArrayIndex > this.searchArray.length) searchArrayIndex = 0;
focusSearchItem(searchArrayIndex);
});
this.rootcontextMenu.querySelector(".searchNextResult").addEventListener("click", () => {
this.rootContextMenu.querySelector(".searchNextResult").addEventListener("click", () => {
searchArrayIndex++;
if (searchArrayIndex > this.searchArray.length) {
searchArrayIndex = 0;
Expand Down Expand Up @@ -14864,7 +14898,6 @@ polymorph_core.registerOperator("itemcluster2", {
}
})


////////////////////////////////////////Handle polymorph_core item updates//////////////////

this.itemRelevant = (id) => {
Expand Down
86 changes: 21 additions & 65 deletions filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@
"operators/calendar.js",
"3pt/svg.min.js",
"3pt/svg.foreignobject.js",
"operators/itemcluster.svg.js",
"operators/itemcluster.contextmenu.js",
"operators/itemcluster.scalegrid.js",
"operators/itemcluster.rapidentry.js",
"operators/itemcluster.js",
"operators/itemcluster/itemcluster.svg.js",
"operators/itemcluster/contextmenu/orbit.js",
"operators/itemcluster/itemcluster.contextmenu.js",
"operators/itemcluster/itemcluster.scalegrid.js",
"operators/itemcluster/itemcluster.rapidentry.js",
"operators/itemcluster/itemcluster.js",
"operators/welcome.js",
"operators/litem.js",
"operators/scriptrunner.js",
Expand All @@ -71,67 +72,22 @@
"core_modules/core/core.static.js",
];

let staticFileList = [
"3pt/localforage.min.js",
"utils.js",
"core.js",
"core_modules/ui/core.tutorial.js",
"core_modules/core/core.dedup.js",
"core_modules/core/core.docLoading.js",
"core_modules/ui/core.dialog.js",
"core_modules/ui/core.tutorial.js",
"core_modules/ui/core.customCSS.js",
"core_modules/core/core.dataUtils.js",
"core_modules/core/core.container.js",
"core_modules/ui/core.contextMenu.js",
"core_modules/core/core.itemfx.js",
"core_modules/core/core.operator.js",
"core_modules/ui/core.dragdrop.js",
"core_modules/core/core.phone.rect.js",
"core_modules/core/core.rect.js",
"core_modules/ui/core.phone.main.js",
"core_modules/ui/core.main.js",
"core_modules/ui/ccleaner.js",
"core_modules/ui/richText.js",
"core_modules/core/core.clip.js",
"operators/opSelect.js",
"genui/dateparser.js",
"operators/itemList.searchsort.js",
"operators/itemList.js",
"operators/itemList.phone.js",
"operators/descbox.js",
"genui/intervalParser.js",
"operators/terminal.js",
"operators/workflow/workflow.js",
"operators/workflow/focusMode.js",
"operators/workflow/search.js",
"operators/workflow/workflow_gitfriendly_contextmenu.js",
"operators/workflow/workflow_gitfriendly.js",
"operators/workflow/advancedentry.js",
//"operators/textflow.js",
"operators/inspector.js",
"operators/json_inspector.js",
"operators/inspectolist.js",
"operators/subframe.js",
"operators/deltaLogger.js",
"3pt/jquery.min.js",
"3pt/moment.min.js",
"3pt/fullcalendar.min.js",
"genui/quickNotify.js",
"operators/calendar.js",
"3pt/svg.min.js",
"3pt/svg.foreignobject.js",
"operators/itemcluster.svg.js",
"operators/itemcluster.contextmenu.js",
"operators/itemcluster.scalegrid.js",
"operators/itemcluster.rapidentry.js",
"operators/itemcluster.js",
"operators/welcome.js",
"operators/litem.js",
"operators/scriptrunner.js",
"operators/timer.js",
"core_modules/core/core.static.js",
let staticFileList = fileList.map(i => i);
let filesToRemoveInStatic = [
"core_modules/ui/core.loadSaveUI.js",
"saveSources/outputToText.js",
"saveSources/localforage2.js",
"saveSources/permalink.js",
"saveSources/lobby.js",
"saveSources/server.js",
"saveSources/gitlite.js",
"saveSources/gitlite2.js",
"saveSources/broadcastsync.js"
];
filesToRemoveInStatic.forEach(i => {
staticFileList.splice(staticFileList.indexOf(i), 1);
});
//staticFileList = [...staticFileList, ""];

try {
//we are working in the browser context
Expand Down
1 change: 0 additions & 1 deletion operators/itemcluster.HDC.js

This file was deleted.

25 changes: 15 additions & 10 deletions operators/itemcluster.contextmenu.js → ...rs/itemcluster/itemcluster.contextmenu.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ function _itemcluster_extend_contextmenu() {
return true; //only activate on clicks to the background.
}
}
this.rootcontextMenu = contextMenuManager.registerContextMenu(`
this.rootContextMenu = contextMenuManager.registerContextMenu(`
<li class="pastebtn">Paste</li>
<li class="collect">Collect items here</li>
<li> Arrange in hierarchy
<ul>
<li class="hierarchy">Arrange in hierarchy</li>
<li class="hierarchy squashed">Arrange in squashed hierarchy</li>
<li class="hierarchy horizontal">Arrange in horizontal hierarchy</li>
<li class="hierarchy radial">Arrange in radial hierarchy</li>
<li class="hierarchy biradial">Arrange in biradial hierarchy</li>
</ul>
</li>
<li class="search">Search
<ul class="submenu">
<li><input class="searchbox"></li>
Expand All @@ -26,7 +30,8 @@ function _itemcluster_extend_contextmenu() {
</li>
<!--<li class="hierarchy radial stepped">Stepped radial hierarchy</li>-->
`, this.rootdiv, undefined, chk);
this.rootcontextMenu.querySelector(".pastebtn").addEventListener("click", (e) => {
_itemcluster_extend_contextmenu_orbit.apply(this);
this.rootContextMenu.querySelector(".pastebtn").addEventListener("click", (e) => {
if (polymorph_core.shared.itemclusterCopyElement) {
let coords = this.mapPageToSvgCoords(e.pageX, e.pageY);
polymorph_core.shared.itemclusterCopyElement.forEach((v) => {
Expand All @@ -45,10 +50,10 @@ function _itemcluster_extend_contextmenu() {
for (let i in polymorph_core.items) {
this.arrangeItem(i);
}
this.rootcontextMenu.style.display = "none";
this.rootContextMenu.style.display = "none";
}
})
this.rootcontextMenu.querySelector(".collect").addEventListener("click", (e) => {
this.rootContextMenu.querySelector(".collect").addEventListener("click", (e) => {
let rect = this.itemSpace.getBoundingClientRect();
for (let i in polymorph_core.items) {
if (polymorph_core.items[i].itemcluster && polymorph_core.items[i].itemcluster.viewData && polymorph_core.items[i].itemcluster.viewData[this.settings.currentViewName]) {
Expand Down Expand Up @@ -594,7 +599,7 @@ function _itemcluster_extend_contextmenu() {
}
}

this.rootcontextMenu.addEventListener("click", (e) => {
this.rootContextMenu.addEventListener("click", (e) => {
if (!e.target.classList.contains("hierarchy")) return;
let visibleItems = generateHierarchy();
//visible items looks like this:
Expand Down Expand Up @@ -632,9 +637,9 @@ function _itemcluster_extend_contextmenu() {
let focusSearchItem = (index) => {
let id = this.searchArray[index];
if (!id) {
this.rootcontextMenu.querySelector(".searchNextResult").style.background = "palevioletred";
this.rootContextMenu.querySelector(".searchNextResult").style.background = "palevioletred";
} else {
this.rootcontextMenu.querySelector(".searchNextResult").style.background = "white";
this.rootContextMenu.querySelector(".searchNextResult").style.background = "white";
let ic = polymorph_core.items[this.settings.currentViewName].itemcluster;
ic.scale = 1;
ic.cx = polymorph_core.items[id].itemcluster.viewData[this.settings.currentViewName].x * ic.XZoomFactor;
Expand All @@ -643,20 +648,20 @@ function _itemcluster_extend_contextmenu() {
this.viewGrid();
}
}
this.rootcontextMenu.querySelector(".search input").addEventListener("input", () => {
this.rootContextMenu.querySelector(".search input").addEventListener("input", () => {
//create the search array
this.searchArray = [];
for (let id in polymorph_core.items) {
if (this.itemIsOurs(id)) {
if (polymorph_core.items[id][this.settings.textProp] && polymorph_core.items[id][this.settings.textProp].includes(this.rootcontextMenu.querySelector(".search input").value)) {
if (polymorph_core.items[id][this.settings.textProp] && polymorph_core.items[id][this.settings.textProp].includes(this.rootContextMenu.querySelector(".search input").value)) {
this.searchArray.push(id);
}
}
}
if (searchArrayIndex > this.searchArray.length) searchArrayIndex = 0;
focusSearchItem(searchArrayIndex);
});
this.rootcontextMenu.querySelector(".searchNextResult").addEventListener("click", () => {
this.rootContextMenu.querySelector(".searchNextResult").addEventListener("click", () => {
searchArrayIndex++;
if (searchArrayIndex > this.searchArray.length) {
searchArrayIndex = 0;
Expand Down
1 change: 0 additions & 1 deletion operators/itemcluster.js → operators/itemcluster/itemcluster.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ polymorph_core.registerOperator("itemcluster2", {
}
})


////////////////////////////////////////Handle polymorph_core item updates//////////////////

this.itemRelevant = (id) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ecd0bd1

Please sign in to comment.