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",
|
||||
"version": "5.8.0",
|
||||
"version": "5.9.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -232,31 +232,14 @@ var bookmarks = (function() {
|
||||
mod.all[data.position.destination.group].items.splice(data.position.destination.item, 0, data.link);
|
||||
},
|
||||
group: function(data) {
|
||||
var makeName = function() {
|
||||
var count = get().length + 1;
|
||||
return "Group " + count;
|
||||
};
|
||||
if (data) {
|
||||
if (data.group.name.text == null) {
|
||||
data.group.name.text = makeName();
|
||||
} 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();
|
||||
data.group.name.text = "";
|
||||
};
|
||||
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);
|
||||
} else {
|
||||
mod.all.push({
|
||||
name: {
|
||||
text: makeName(),
|
||||
show: true
|
||||
},
|
||||
openAll: {
|
||||
show: true
|
||||
},
|
||||
items: []
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@ -20,13 +20,13 @@ var control = (function() {
|
||||
menu.open();
|
||||
},
|
||||
}, {
|
||||
element: ".control-link-add",
|
||||
element: ".control-add-link",
|
||||
type: "button",
|
||||
func: function() {
|
||||
link.add.item.open();
|
||||
}
|
||||
}, {
|
||||
element: ".control-group-add",
|
||||
element: ".control-add-group",
|
||||
type: "button",
|
||||
func: function() {
|
||||
link.add.group.open();
|
||||
|
@ -383,12 +383,12 @@ var header = (function() {
|
||||
controlAddToggle.appendChild(controlAddToggleText);
|
||||
var formDropdownMenu = helper.node("ul|class:list-unstyled form-dropdown-menu");
|
||||
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");
|
||||
controlGroupAdd.appendChild(controlGroupAddText);
|
||||
controlGroupAddLi.appendChild(controlGroupAdd);
|
||||
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");
|
||||
controlLinkAdd.appendChild(controlLinkAddText);
|
||||
controlLinkAddLi.appendChild(controlLinkAdd);
|
||||
|
@ -1047,12 +1047,18 @@ var link = (function() {
|
||||
var makeGroupOptions = function() {
|
||||
if (bookmarks.get().length > 0) {
|
||||
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({
|
||||
tag: "option",
|
||||
text: arrayItem.name.text,
|
||||
text: name,
|
||||
attr: [{
|
||||
key: "value",
|
||||
value: arrayItem.name.text
|
||||
value: name
|
||||
}]
|
||||
});
|
||||
groupExistingGroup.appendChild(option);
|
||||
@ -1413,7 +1419,7 @@ var link = (function() {
|
||||
groupBody.appendChild(linkEmpty);
|
||||
group.appendChild(groupBody);
|
||||
addButton.addEventListener("click", function(event) {
|
||||
link.add.item.open();
|
||||
add.item.open();
|
||||
}, false);
|
||||
return group;
|
||||
},
|
||||
@ -1424,8 +1430,8 @@ var link = (function() {
|
||||
linkEmpty.appendChild(para);
|
||||
linkEmpty.appendChild(addButton);
|
||||
addButton.addEventListener("click", function(event) {
|
||||
link.add.item.open();
|
||||
link.add.item.selectGroup(groupIndex);
|
||||
add.item.open();
|
||||
add.item.selectGroup(groupIndex);
|
||||
}, false);
|
||||
return linkEmpty;
|
||||
},
|
||||
@ -1636,6 +1642,7 @@ var link = (function() {
|
||||
pagelock.unlock();
|
||||
},
|
||||
selectGroup: function(groupIndex) {
|
||||
stagedGroup.init();
|
||||
stagedLink.position.destination.group = groupIndex;
|
||||
stagedLink.position.destination.item = 0;
|
||||
helper.e(".link-form-select-group").selectedIndex = stagedLink.position.destination.group;
|
||||
@ -1750,7 +1757,12 @@ var link = (function() {
|
||||
var form = render.group.form({
|
||||
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 copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
||||
bookmarks.mod.edit.group(copyStagedGroup);
|
||||
@ -1844,10 +1856,10 @@ var link = (function() {
|
||||
stagedGroup.group = JSON.parse(JSON.stringify(copyStagedGroup.group));
|
||||
stagedGroup.position = JSON.parse(JSON.stringify(copyStagedGroup.position));
|
||||
var heading;
|
||||
if (stagedGroup.group.name.text != null && stagedGroup.group.name.text != "") {
|
||||
heading = "Remove " + stagedGroup.group.name.text;
|
||||
if (stagedGroup.group.name.text == null || stagedGroup.group.name.text == "") {
|
||||
heading = "Remove unnamed group " + (stagedGroup.position.origin + 1);
|
||||
} else {
|
||||
heading = "Remove unnamed group";
|
||||
heading = "Remove " + stagedGroup.group.name.text;
|
||||
};
|
||||
var successAction = function() {
|
||||
var copyStagedGroup = JSON.parse(JSON.stringify(stagedGroup));
|
||||
|
@ -1,6 +1,6 @@
|
||||
var version = (function() {
|
||||
|
||||
var current = "5.8.0";
|
||||
var current = "5.9.0";
|
||||
|
||||
var name = "Zonked Tarsier";
|
||||
|
||||
|
@ -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": "5.8.0",
|
||||
"version": "5.9.0",
|
||||
"manifest_version": 2,
|
||||
"chrome_url_overrides": {
|
||||
"newtab": "index.html"
|
||||
|
Loading…
Reference in New Issue
Block a user