mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-06-26 12:31:47 +02:00
[bug] fix link edit when searching not working as expected
This commit is contained in:
parent
c26956812e
commit
bf617c2393
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nighttab",
|
||||
"version": "4.19.1",
|
||||
"version": "4.19.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nighttab",
|
||||
"version": "4.19.1",
|
||||
"version": "4.19.2",
|
||||
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -55,6 +55,14 @@ input[type="submit"]:active {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
button.disabled,
|
||||
button.disabled:hover,
|
||||
button.disabled:focus,
|
||||
button.disabled:active,
|
||||
.button.disabled,
|
||||
.button.disabled:hover,
|
||||
.button.disabled:focus,
|
||||
.button.disabled:active,
|
||||
button:disabled,
|
||||
button:disabled:hover,
|
||||
button:disabled:focus,
|
||||
@ -109,6 +117,14 @@ input[type="submit"]:active:after {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
button.disabled:after,
|
||||
.button.disabled:after,
|
||||
button.disabled:hover:after,
|
||||
.button.disabled:hover:after,
|
||||
button.disabled:focus:after,
|
||||
.button.disabled:focus:after,
|
||||
button.disabled:active:after,
|
||||
.button.disabled:active:after,
|
||||
button:disabled:after,
|
||||
.button:disabled:after,
|
||||
button:disabled:hover:after,
|
||||
@ -196,12 +212,15 @@ button [class*=" button-"]:last-child,
|
||||
color: rgb(var(--button-link-text-active));
|
||||
}
|
||||
|
||||
.button-link.disabled,
|
||||
.button-link:disabled {
|
||||
background-color: transparent;
|
||||
color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.button-link.disabled:hover,
|
||||
.button-link.disabled:focus,
|
||||
.button-link:hover:disabled,
|
||||
.button-link:focus:disabled {
|
||||
background-color: transparent;
|
||||
|
@ -763,7 +763,6 @@
|
||||
margin-bottom: 0;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: rgb(var(--theme-color-02));
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
@ -771,6 +770,11 @@
|
||||
content: none;
|
||||
}
|
||||
|
||||
.link-control-item.disabled,
|
||||
.link-control-item:disabled {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.is-link-style-list .link-control-item {
|
||||
flex-basis: inherit;
|
||||
}
|
||||
@ -787,6 +791,16 @@
|
||||
color: rgb(var(--theme-white));
|
||||
}
|
||||
|
||||
.link-text-dark .link-control-item.disabled,
|
||||
.link-text-dark .link-control-item:disabled {
|
||||
color: rgba(var(--theme-black), 0.25);
|
||||
}
|
||||
|
||||
.link-text-light .link-control-item.disabled,
|
||||
.link-text-light .link-control-item:disabled {
|
||||
color: rgba(var(--theme-white), 0.25);
|
||||
}
|
||||
|
||||
.is-link-orientation-top.is-link-style-list .link-control-item:nth-child(1) {
|
||||
border-top-left-radius: var(--theme-radius);
|
||||
}
|
||||
@ -831,6 +845,22 @@
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.link-text-dark .link-control-item.disabled:focus,
|
||||
.link-text-dark .link-control-item.disabled:hover,
|
||||
.link-text-dark .link-control-item:disabled:focus,
|
||||
.link-text-dark .link-control-item:disabled:hover {
|
||||
color: rgba(var(--theme-black), 0.25);
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.link-text-light .link-control-item.disabled:focus,
|
||||
.link-text-light .link-control-item.disabled:hover,
|
||||
.link-text-light .link-control-item:disabled:focus,
|
||||
.link-text-light .link-control-item:disabled:hover {
|
||||
color: rgba(var(--theme-white), 0.25);
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.link-text-dark .link-control-item:active {
|
||||
color: rgb(var(--theme-black));
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
|
@ -22,6 +22,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453104010
|
||||
}, {
|
||||
display: "letter",
|
||||
@ -41,6 +42,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453107633
|
||||
}, {
|
||||
display: "letter",
|
||||
@ -60,6 +62,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453110265
|
||||
}, {
|
||||
display: "icon",
|
||||
@ -79,6 +82,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453111491
|
||||
}, {
|
||||
display: "icon",
|
||||
@ -98,6 +102,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453104460
|
||||
}, {
|
||||
display: "letter",
|
||||
@ -117,6 +122,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453111953
|
||||
}]
|
||||
}, {
|
||||
@ -139,6 +145,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453101749
|
||||
}, {
|
||||
display: "icon",
|
||||
@ -158,6 +165,7 @@ var bookmarks = (function() {
|
||||
b: null
|
||||
}
|
||||
},
|
||||
searchMatch: false,
|
||||
timeStamp: 1546453108926
|
||||
}]
|
||||
}];
|
||||
|
107
src/js/link.js
107
src/js/link.js
@ -56,7 +56,8 @@ var link = (function() {
|
||||
b: null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
searchMatch: null
|
||||
};
|
||||
|
||||
stagedLink.init = function() {
|
||||
@ -67,6 +68,7 @@ var link = (function() {
|
||||
stagedLink.position.group.new = false;
|
||||
stagedLink.link.display = "letter";
|
||||
stagedLink.link.accent.override = false;
|
||||
stagedLink.link.searchMatch = false;
|
||||
};
|
||||
|
||||
stagedLink.reset = function() {
|
||||
@ -88,6 +90,7 @@ var link = (function() {
|
||||
stagedLink.link.accent.color.r = null;
|
||||
stagedLink.link.accent.color.g = null;
|
||||
stagedLink.link.accent.color.b = null;
|
||||
stagedLink.link.searchMatch = null;
|
||||
};
|
||||
|
||||
var mod = {};
|
||||
@ -292,7 +295,9 @@ var link = (function() {
|
||||
bookmarks.mod.move.group(stagedGroup);
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.group.previous.up(copyStagedGroup);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.group.previous.up(copyStagedGroup);
|
||||
};
|
||||
},
|
||||
down: function(copyStagedGroup) {
|
||||
stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group));
|
||||
@ -301,7 +306,9 @@ var link = (function() {
|
||||
bookmarks.mod.move.group(stagedGroup);
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.group.next.down(copyStagedGroup);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.group.next.down(copyStagedGroup);
|
||||
};
|
||||
}
|
||||
},
|
||||
item: {
|
||||
@ -315,7 +322,9 @@ var link = (function() {
|
||||
bookmarks.mod.move.link(JSON.parse(JSON.stringify(stagedLink)));
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.item.previous.left(copyStagedLink);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.item.previous.left(copyStagedLink);
|
||||
};
|
||||
},
|
||||
right: function(copyStagedLink) {
|
||||
stagedLink.link = JSON.parse(JSON.stringify(copyStagedLink.link));
|
||||
@ -324,7 +333,9 @@ var link = (function() {
|
||||
bookmarks.mod.move.link(JSON.parse(JSON.stringify(stagedLink)));
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.item.next.right(copyStagedLink);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.item.next.right(copyStagedLink);
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -402,6 +413,12 @@ var link = (function() {
|
||||
itemGroupControlItemRemove.appendChild(itemGroupControlItemRemoveIcon);
|
||||
groupControl.appendChild(itemGroupControlItemRemove);
|
||||
|
||||
if (state.get.current().search) {
|
||||
itemGroupControlItemUp.disabled = true;
|
||||
helper.addClass(itemGroupControlItemHandle, "disabled");
|
||||
itemGroupControlItemDown.disabled = true;
|
||||
};
|
||||
|
||||
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
||||
|
||||
itemGroupControlItemUp.addEventListener("click", function(event) {
|
||||
@ -654,6 +671,12 @@ var link = (function() {
|
||||
linkItem.appendChild(linkPanelFront);
|
||||
linkItem.appendChild(linkPanelBack);
|
||||
|
||||
if (state.get.current().search) {
|
||||
linkLeft.disabled = true;
|
||||
helper.addClass(linkHandle, "disabled");
|
||||
linkRight.disabled = true;
|
||||
};
|
||||
|
||||
var copyStagedLink = JSON.parse(JSON.stringify(stagedLink));
|
||||
|
||||
linkLeft.addEventListener("click", function() {
|
||||
@ -1135,15 +1158,9 @@ var link = (function() {
|
||||
|
||||
render.all = function() {
|
||||
var linkSection = helper.e(".link");
|
||||
var bookmarksToRender = false;
|
||||
if (state.get.current().search) {
|
||||
bookmarksToRender = search.get();
|
||||
} else {
|
||||
bookmarksToRender = bookmarks.get();
|
||||
};
|
||||
var make = {
|
||||
bookmarks: function(data) {
|
||||
data.forEach(function(arrayItem, index) {
|
||||
bookmarks: function() {
|
||||
bookmarks.get().forEach(function(arrayItem, index) {
|
||||
stagedGroup.position.origin = index;
|
||||
stagedGroup.position.destination = index;
|
||||
stagedGroup.position.origin = index;
|
||||
@ -1158,12 +1175,24 @@ var link = (function() {
|
||||
stagedLink.position.destination.item = index;
|
||||
stagedLink.position.group.new = null;
|
||||
stagedLink.position.group.name = null;
|
||||
group.querySelector(".group-body").appendChild(render.item.link());
|
||||
if (state.get.current().search) {
|
||||
if (stagedLink.link.searchMatch) {
|
||||
group.querySelector(".group-body").appendChild(render.item.link());
|
||||
};
|
||||
} else {
|
||||
group.querySelector(".group-body").appendChild(render.item.link());
|
||||
};
|
||||
});
|
||||
} else {
|
||||
group.querySelector(".group-body").appendChild(render.empty.item(stagedGroup.position.destination));
|
||||
};
|
||||
linkSection.appendChild(group);
|
||||
if (state.get.current().search) {
|
||||
if (search.mod.searching.count.group(index) > 0) {
|
||||
linkSection.appendChild(group);
|
||||
};
|
||||
} else {
|
||||
linkSection.appendChild(group);
|
||||
};
|
||||
stagedGroup.reset();
|
||||
stagedLink.reset();
|
||||
});
|
||||
@ -1177,21 +1206,23 @@ var link = (function() {
|
||||
}
|
||||
}
|
||||
};
|
||||
// if searching
|
||||
if (state.get.current().search) {
|
||||
// if bookmarks exist to be searched
|
||||
if (bookmarksToRender.total > 0) {
|
||||
make.bookmarks(bookmarksToRender.matching);
|
||||
// if bookmarks exist
|
||||
if (bookmarks.get().length > 0) {
|
||||
// if searching
|
||||
if (state.get.current().search) {
|
||||
search.mod.searching.get();
|
||||
// if matching results found
|
||||
if (search.mod.searching.count.all() > 0) {
|
||||
make.bookmarks();
|
||||
} else {
|
||||
make.empty.search();
|
||||
};
|
||||
} else {
|
||||
make.empty.search();
|
||||
search.mod.searching.clear();
|
||||
make.bookmarks();
|
||||
};
|
||||
} else {
|
||||
// if bookmarks exist
|
||||
if (bookmarksToRender.length > 0) {
|
||||
make.bookmarks(bookmarksToRender);
|
||||
} else {
|
||||
make.empty.bookmarks();
|
||||
};
|
||||
make.empty.bookmarks();
|
||||
};
|
||||
};
|
||||
|
||||
@ -1504,7 +1535,9 @@ var link = (function() {
|
||||
edit.item.close();
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.item.current.edit(copyStagedLink);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.item.current.edit(copyStagedLink);
|
||||
};
|
||||
autoSuggest.close();
|
||||
shade.close();
|
||||
pagelock.unlock();
|
||||
@ -1549,7 +1582,9 @@ var link = (function() {
|
||||
edit.group.close();
|
||||
data.save();
|
||||
groupAndItems();
|
||||
render.focus.group.current.edit(copyStagedGroup);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.group.current.edit(copyStagedGroup);
|
||||
};
|
||||
autoSuggest.close();
|
||||
shade.close();
|
||||
pagelock.unlock();
|
||||
@ -1600,7 +1635,9 @@ var link = (function() {
|
||||
groupAndItems();
|
||||
control.render.dependents();
|
||||
control.render.class();
|
||||
render.focus.item.previous.remove(copyStagedLink);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.item.previous.remove(copyStagedLink);
|
||||
};
|
||||
shade.close();
|
||||
pagelock.unlock();
|
||||
};
|
||||
@ -1644,7 +1681,9 @@ var link = (function() {
|
||||
groupAndItems();
|
||||
control.render.dependents();
|
||||
control.render.class();
|
||||
render.focus.group.previous.remove(copyStagedGroup);
|
||||
if (!state.get.current().search) {
|
||||
render.focus.group.previous.remove(copyStagedGroup);
|
||||
};
|
||||
shade.close();
|
||||
pagelock.unlock();
|
||||
};
|
||||
@ -1767,8 +1806,10 @@ var link = (function() {
|
||||
render.all();
|
||||
render.group.tabindex();
|
||||
render.item.tabindex();
|
||||
bind.sort.group();
|
||||
bind.sort.item();
|
||||
if (!state.get.current().search) {
|
||||
bind.sort.group();
|
||||
bind.sort.item();
|
||||
};
|
||||
};
|
||||
|
||||
var init = function() {
|
||||
|
@ -36,40 +36,54 @@ var search = (function() {
|
||||
path: "search",
|
||||
newValue: false
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var get = function() {
|
||||
var searchInput = helper.e(".search-input");
|
||||
var string = searchInput.value.toLowerCase().replace(/\s/g, "");
|
||||
if (state.get.current().search) {
|
||||
var searchedBookmarks = {
|
||||
total: 0,
|
||||
matching: []
|
||||
},
|
||||
get: function() {
|
||||
var searchInput = helper.e(".search-input");
|
||||
var string = searchInput.value.toLowerCase().replace(/\s/g, "");
|
||||
if (state.get.current().search) {
|
||||
bookmarks.get().forEach(function(arrayItem, index) {
|
||||
arrayItem.items.forEach(function(arrayItem, index) {
|
||||
var matchUrl = (arrayItem.url != null) && (arrayItem.url.replace(/^https?\:\/\//i, "").replace(/\/$/, "").toLowerCase().includes(string));
|
||||
var matchName = (arrayItem.name != null) && (arrayItem.name.toLowerCase().replace(/\s/g, "").includes(string));
|
||||
arrayItem.searchMatch = false;
|
||||
if (matchUrl || matchName) {
|
||||
arrayItem.searchMatch = true;
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
searchedBookmarks.total = bookmarks.get().length;
|
||||
},
|
||||
clear: function() {
|
||||
bookmarks.get().forEach(function(arrayItem, index) {
|
||||
var currentGroup = JSON.parse(JSON.stringify(arrayItem));
|
||||
var matchingItems = [];
|
||||
currentGroup.items.forEach(function(arrayItem, index) {
|
||||
var matchUrl = (arrayItem.url != null) && (arrayItem.url.replace(/^https?\:\/\//i, "").replace(/\/$/, "").toLowerCase().includes(string));
|
||||
var matchName = (arrayItem.name != null) && (arrayItem.name.toLowerCase().replace(/\s/g, "").includes(string));
|
||||
if (matchUrl || matchName) {
|
||||
matchingItems.push(JSON.parse(JSON.stringify(arrayItem)));
|
||||
};
|
||||
arrayItem.items.forEach(function(arrayItem, index) {
|
||||
arrayItem.searchMatch = false;
|
||||
});
|
||||
if (matchingItems.length > 0) {
|
||||
currentGroup.items = matchingItems;
|
||||
searchedBookmarks.matching.push(currentGroup);
|
||||
};
|
||||
var count = 0;
|
||||
searchedBookmarks.matching.forEach(function(arrayItem, index) {
|
||||
count = count + arrayItem.items.length
|
||||
});
|
||||
searchedBookmarks.total = count;
|
||||
});
|
||||
return searchedBookmarks;
|
||||
};
|
||||
},
|
||||
count: {
|
||||
all: function() {
|
||||
var searchResultCount = 0;
|
||||
bookmarks.get().forEach(function(arrayItem, index) {
|
||||
arrayItem.items.forEach(function(arrayItem, index) {
|
||||
if (arrayItem.searchMatch) {
|
||||
searchResultCount = searchResultCount + 1;
|
||||
};
|
||||
});
|
||||
});
|
||||
return searchResultCount;
|
||||
},
|
||||
group: function(index) {
|
||||
var searchResultCount = 0;
|
||||
if (bookmarks.get()[index]) {
|
||||
bookmarks.get()[index].items.forEach(function(arrayItem, index) {
|
||||
if (arrayItem.searchMatch) {
|
||||
searchResultCount = searchResultCount + 1;
|
||||
};
|
||||
});
|
||||
};
|
||||
return searchResultCount;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var render = {};
|
||||
@ -142,6 +156,7 @@ var search = (function() {
|
||||
bind.input();
|
||||
bind.clear();
|
||||
mod.searching.close();
|
||||
mod.searching.clear();
|
||||
render.engine();
|
||||
render.focus();
|
||||
render.searching();
|
||||
@ -150,7 +165,7 @@ var search = (function() {
|
||||
// exposed methods
|
||||
return {
|
||||
init: init,
|
||||
get: get,
|
||||
mod: mod,
|
||||
render: render,
|
||||
check: check
|
||||
};
|
||||
|
@ -365,8 +365,8 @@ var update = (function() {
|
||||
return data;
|
||||
},
|
||||
"2.22.0": function(data) {
|
||||
data.bookmarks.forEach(function(item, index) {
|
||||
item.accent = {
|
||||
data.bookmarks.forEach(function(arrayItem, index) {
|
||||
arrayItem.accent = {
|
||||
override: false,
|
||||
color: {
|
||||
r: null,
|
||||
@ -378,9 +378,9 @@ var update = (function() {
|
||||
return data;
|
||||
},
|
||||
"3.0.0": function(data) {
|
||||
data.bookmarks.forEach(function(item, index) {
|
||||
item.display = "letter";
|
||||
item.icon = {
|
||||
data.bookmarks.forEach(function(arrayItem, index) {
|
||||
arrayItem.display = "letter";
|
||||
arrayItem.icon = {
|
||||
name: null,
|
||||
prefix: null,
|
||||
label: null
|
||||
@ -775,6 +775,14 @@ var update = (function() {
|
||||
data.state.theme.accent.rgb = data.state.theme.accent.current;
|
||||
delete data.state.theme.accent.current;
|
||||
return data;
|
||||
},
|
||||
"4.19.2": function(data) {
|
||||
data.bookmarks.forEach(function(arrayItem, index) {
|
||||
arrayItem.items.forEach(function(arrayItem, index) {
|
||||
arrayItem.searchMatch = false;
|
||||
});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
var version = (function() {
|
||||
|
||||
var current = "4.19.1";
|
||||
var current = "4.19.2";
|
||||
|
||||
var name = "Naughty Goose";
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
"name": "nightTab",
|
||||
"short_name": "nightTab",
|
||||
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
||||
"version": "4.19.1",
|
||||
"version": "4.19.2",
|
||||
"manifest_version": 2,
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "index.html"
|
||||
|
Loading…
x
Reference in New Issue
Block a user