mirror of
https://github.com/zombieFox/nightTab.git
synced 2025-01-10 16:08:12 +01:00
[refactor] improve group name when left empty
This commit is contained in:
parent
887864e55c
commit
08335dfdee
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nightTab",
|
"name": "nightTab",
|
||||||
"version": "5.8.0",
|
"version": "5.9.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nightTab",
|
"name": "nightTab",
|
||||||
"version": "5.8.0",
|
"version": "5.9.0",
|
||||||
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -232,31 +232,14 @@ var bookmarks = (function() {
|
|||||||
mod.all[data.position.destination.group].items.splice(data.position.destination.item, 0, data.link);
|
mod.all[data.position.destination.group].items.splice(data.position.destination.item, 0, data.link);
|
||||||
},
|
},
|
||||||
group: function(data) {
|
group: function(data) {
|
||||||
var makeName = function() {
|
|
||||||
var count = get().length + 1;
|
|
||||||
return "Group " + count;
|
|
||||||
};
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data.group.name.text == null) {
|
if (data.group.name.text == null) {
|
||||||
data.group.name.text = makeName();
|
data.group.name.text = "";
|
||||||
} else if (typeof data.group.name.text == "string") {
|
|
||||||
data.group.name.text = data.group.name.text.trim();
|
|
||||||
if (data.group.name.text == "") {
|
|
||||||
data.group.name.text = makeName();
|
|
||||||
};
|
};
|
||||||
|
if (typeof data.group.name.text == "string") {
|
||||||
|
data.group.name.text = data.group.name.text.trim();
|
||||||
};
|
};
|
||||||
mod.all.splice(data.position.destination, 0, data.group);
|
mod.all.splice(data.position.destination, 0, data.group);
|
||||||
} else {
|
|
||||||
mod.all.push({
|
|
||||||
name: {
|
|
||||||
text: makeName(),
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
openAll: {
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
items: []
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,13 +20,13 @@ var control = (function() {
|
|||||||
menu.open();
|
menu.open();
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
element: ".control-link-add",
|
element: ".control-add-link",
|
||||||
type: "button",
|
type: "button",
|
||||||
func: function() {
|
func: function() {
|
||||||
link.add.item.open();
|
link.add.item.open();
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
element: ".control-group-add",
|
element: ".control-add-group",
|
||||||
type: "button",
|
type: "button",
|
||||||
func: function() {
|
func: function() {
|
||||||
link.add.group.open();
|
link.add.group.open();
|
||||||
|
@ -383,12 +383,12 @@ var header = (function() {
|
|||||||
controlAddToggle.appendChild(controlAddToggleText);
|
controlAddToggle.appendChild(controlAddToggleText);
|
||||||
var formDropdownMenu = helper.node("ul|class:list-unstyled form-dropdown-menu");
|
var formDropdownMenu = helper.node("ul|class:list-unstyled form-dropdown-menu");
|
||||||
var controlGroupAddLi = helper.node("li");
|
var controlGroupAddLi = helper.node("li");
|
||||||
var controlGroupAdd = helper.node("button|class:button button-block text-left form-dropdown-menu-item control-group-add,tabindex:1");
|
var controlGroupAdd = helper.node("button|class:button button-block text-left form-dropdown-menu-item control-add-group,tabindex:1");
|
||||||
var controlGroupAddText = helper.node("span:New Group|class:button-text");
|
var controlGroupAddText = helper.node("span:New Group|class:button-text");
|
||||||
controlGroupAdd.appendChild(controlGroupAddText);
|
controlGroupAdd.appendChild(controlGroupAddText);
|
||||||
controlGroupAddLi.appendChild(controlGroupAdd);
|
controlGroupAddLi.appendChild(controlGroupAdd);
|
||||||
var controlLinkAddLi = helper.node("li");
|
var controlLinkAddLi = helper.node("li");
|
||||||
var controlLinkAdd = helper.node("button|class:button button-block text-left form-dropdown-menu-item control-link-add,tabindex:1");
|
var controlLinkAdd = helper.node("button|class:button button-block text-left form-dropdown-menu-item control-add-link,tabindex:1");
|
||||||
var controlLinkAddText = helper.node("span:New Bookmark|class:button-text");
|
var controlLinkAddText = helper.node("span:New Bookmark|class:button-text");
|
||||||
controlLinkAdd.appendChild(controlLinkAddText);
|
controlLinkAdd.appendChild(controlLinkAddText);
|
||||||
controlLinkAddLi.appendChild(controlLinkAdd);
|
controlLinkAddLi.appendChild(controlLinkAdd);
|
||||||
|
@ -1047,12 +1047,18 @@ var link = (function() {
|
|||||||
var makeGroupOptions = function() {
|
var makeGroupOptions = function() {
|
||||||
if (bookmarks.get().length > 0) {
|
if (bookmarks.get().length > 0) {
|
||||||
bookmarks.get().forEach(function(arrayItem, index) {
|
bookmarks.get().forEach(function(arrayItem, index) {
|
||||||
|
var name;
|
||||||
|
if (arrayItem.name.text == null || arrayItem.name.text == "") {
|
||||||
|
name = "Unnamed group " + (index + 1);
|
||||||
|
} else {
|
||||||
|
name = arrayItem.name.text;
|
||||||
|
};
|
||||||
var option = helper.makeNode({
|
var option = helper.makeNode({
|
||||||
tag: "option",
|
tag: "option",
|
||||||
text: arrayItem.name.text,
|
text: name,
|
||||||
attr: [{
|
attr: [{
|
||||||
key: "value",
|
key: "value",
|
||||||
value: arrayItem.name.text
|
value: name
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
groupExistingGroup.appendChild(option);
|
groupExistingGroup.appendChild(option);
|
||||||
@ -1413,7 +1419,7 @@ var link = (function() {
|
|||||||
groupBody.appendChild(linkEmpty);
|
groupBody.appendChild(linkEmpty);
|
||||||
group.appendChild(groupBody);
|
group.appendChild(groupBody);
|
||||||
addButton.addEventListener("click", function(event) {
|
addButton.addEventListener("click", function(event) {
|
||||||
link.add.item.open();
|
add.item.open();
|
||||||
}, false);
|
}, false);
|
||||||
return group;
|
return group;
|
||||||
},
|
},
|
||||||
@ -1424,8 +1430,8 @@ var link = (function() {
|
|||||||
linkEmpty.appendChild(para);
|
linkEmpty.appendChild(para);
|
||||||
linkEmpty.appendChild(addButton);
|
linkEmpty.appendChild(addButton);
|
||||||
addButton.addEventListener("click", function(event) {
|
addButton.addEventListener("click", function(event) {
|
||||||
link.add.item.open();
|
add.item.open();
|
||||||
link.add.item.selectGroup(groupIndex);
|
add.item.selectGroup(groupIndex);
|
||||||
}, false);
|
}, false);
|
||||||
return linkEmpty;
|
return linkEmpty;
|
||||||
},
|
},
|
||||||
@ -1636,6 +1642,7 @@ var link = (function() {
|
|||||||
pagelock.unlock();
|
pagelock.unlock();
|
||||||
},
|
},
|
||||||
selectGroup: function(groupIndex) {
|
selectGroup: function(groupIndex) {
|
||||||
|
stagedGroup.init();
|
||||||
stagedLink.position.destination.group = groupIndex;
|
stagedLink.position.destination.group = groupIndex;
|
||||||
stagedLink.position.destination.item = 0;
|
stagedLink.position.destination.item = 0;
|
||||||
helper.e(".link-form-select-group").selectedIndex = stagedLink.position.destination.group;
|
helper.e(".link-form-select-group").selectedIndex = stagedLink.position.destination.group;
|
||||||
@ -1750,7 +1757,12 @@ var link = (function() {
|
|||||||
var form = render.group.form({
|
var form = render.group.form({
|
||||||
useStagedGroup: true
|
useStagedGroup: true
|
||||||
});
|
});
|
||||||
var heading = "Edit " + stagedGroup.group.name.text;
|
var heading;
|
||||||
|
if (stagedGroup.group.name.text == null || stagedGroup.group.name.text == "") {
|
||||||
|
heading = "Edit unnamed group " + (stagedGroup.position.origin + 1);
|
||||||
|
} else {
|
||||||
|
heading = "Edit " + stagedGroup.group.name.text;
|
||||||
|
};
|
||||||
var successAction = function() {
|
var successAction = function() {
|
||||||
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
||||||
bookmarks.mod.edit.group(copyStagedGroup);
|
bookmarks.mod.edit.group(copyStagedGroup);
|
||||||
@ -1844,10 +1856,10 @@ var link = (function() {
|
|||||||
stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group));
|
stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group));
|
||||||
stagedGroup.position = JSON.parse(JSON.stringify(copyStagedGroup.position));
|
stagedGroup.position = JSON.parse(JSON.stringify(copyStagedGroup.position));
|
||||||
var heading;
|
var heading;
|
||||||
if (stagedGroup.group.name.text != null && stagedGroup.group.name.text != "") {
|
if (stagedGroup.group.name.text == null || stagedGroup.group.name.text == "") {
|
||||||
heading = "Remove " + stagedGroup.group.name.text;
|
heading = "Remove unnamed group " + (stagedGroup.position.origin + 1);
|
||||||
} else {
|
} else {
|
||||||
heading = "Remove unnamed group";
|
heading = "Remove " + stagedGroup.group.name.text;
|
||||||
};
|
};
|
||||||
var successAction = function() {
|
var successAction = function() {
|
||||||
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var version = (function() {
|
var version = (function() {
|
||||||
|
|
||||||
var current = "5.8.0";
|
var current = "5.9.0";
|
||||||
|
|
||||||
var name = "Zonked Tarsier";
|
var name = "Zonked Tarsier";
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "nightTab",
|
"name": "nightTab",
|
||||||
"short_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.",
|
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
|
||||||
"version": "5.8.0",
|
"version": "5.9.0",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"chrome_url_overrides": {
|
"chrome_url_overrides": {
|
||||||
"newtab": "index.html"
|
"newtab": "index.html"
|
||||||
|
Loading…
Reference in New Issue
Block a user