Commit b7c01014 authored by Fabian Heidemann's avatar Fabian Heidemann
Browse files

Bookmark bar fix #1929, fix #1930, fix #1931, fix #1932 and fix #1935

parent ca5735c1
......@@ -5,12 +5,14 @@
}
.bookmarks {
overflow: scroll;
overflow: auto;
white-space: nowrap;
border-bottom: 1px solid #b8b8b8;
}
.bookmark {
margin: 1% 1% 1% 1%;
padding: 3px 8px;
margin: 0%;
cursor: pointer;
}
......@@ -24,7 +26,7 @@
}
.bookmark-button {
margin: 1% 1% 1% 1%;
margin: 3px 8px;
background-color: #ffffff;
border-top: 1px solid #b8b8b8;
border-right: 1px solid #b8b8b8;
......
<div class="bookmark-container">
<button class="bookmark-button">
<button class="bookmark-button btn btn-sm">
<i class="glyphicon glyphicon-bookmark"></i>
Add bookmark
<span>Add bookmark</span>
</button>
<div class="bookmarks">
<p class="bookmark">
......
......@@ -40,6 +40,10 @@ var BookmarkContainer = Class.extend({
// split into arrays
self.names = names.content.split(":");
self.pathes = pathes.content.split(":");
if (self.names.join() == "") {
self.names = [];
self.pathes = [];
}
}
if (self.names.length !== self.pathes.length) {
self.names = [];
......@@ -55,6 +59,13 @@ var BookmarkContainer = Class.extend({
}
};
$(".bookmarks", self.parentnode).render(self.names, directives);
// invisible if empty
if (self.names.length == 0) $(".bookmarks", self.parentnode).css({
"visibility": "hidden"
});
else $(".bookmarks", self.parentnode).css({
"visibility": "visible"
});
// add clicks
var clicktype = vispa.device.hasTouch ? "tap" : "click";
......@@ -96,17 +107,7 @@ var BookmarkContainer = Class.extend({
// add data
self.pathes[self.pathes.length] = self.FileBase.workflow.path;
self.names[self.names.length] = self.FileBase.helper.filenameFromPath(self.pathes[self.pathes.length - 1]);
// check for already existing name
var twice = false;
for (var i = 0; i < self.names.length - 1; i++) {
if (self.names[i] == self.names[self.names.length - 1]) twice = true;
}
if (twice) {
self.names.splice(self.names.length - 1, 1);
self.pathes.splice(self.pathes.length - 1, 1);
self.instance.alert("Bookmark name \"" + self.names[self.names.length - 1] + "\" already exists.");
return;
}
if (self.names[self.names.length - 1] == "") self.names[self.names.length - 1] = "New bookmark";
// set new data to ini and update view
var promise1 = self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
......@@ -121,7 +122,8 @@ var BookmarkContainer = Class.extend({
});
promise2.done(function(res2) {
if (res1.success && res2.success) {
self.FileBase.updateView();
self.setContent();
self.editBookmark(self.names.length - 1);
} else {
self.instance.alert("Couldn't add bookmark.");
self.names.splice(self.names.length - 1, 1);
......@@ -146,55 +148,67 @@ var BookmarkContainer = Class.extend({
var self = this;
var name = self.names[index];
var path = self.pathes[index];
self.names.splice(index, 1);
self.pathes.splice(index, 1);
// set new data to ini and update view
var promise1 = self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "names",
"value": self.names.join(":")
});
promise1.done(function(res1) {
var promise2 = self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "pathes",
"value": self.pathes.join(":")
});
promise2.done(function(res2) {
if (res1.success && res2.success) {
self.FileBase.updateView();
} else {
self.instance.alert("Couldn't remove bookmark.");
self.names.splice(index, 0, name);
self.pathes.splice(index, 0, path);
self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
self.instance.confirm(
"Do you want to delete bookmark \"" + name + "\"?",
function(confirmed) {
if (confirmed) {
self.names.splice(index, 1);
self.pathes.splice(index, 1);
// set new data to ini and update view
var promise1 = self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "names",
"value": self.names.join(":")
});
self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "pathes",
"value": self.pathes.join(":")
promise1.done(function(res1) {
var promise2 = self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "pathes",
"value": self.pathes.join(":")
});
promise2.done(function(res2) {
if (res1.success && res2.success) {
self.setContent();
} else {
self.instance.alert("Couldn't remove bookmark.");
self.names.splice(index, 0, name);
self.pathes.splice(index, 0, path);
self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "names",
"value": self.names.join(":")
});
self.instance.POST("/ajax/fs/set_to_private_workspaceini", {
"section": "Bookmarks",
"option": "pathes",
"value": self.pathes.join(":")
});
}
});
});
} else {
return;
}
});
});
},
editBookmark: function(index) {
var self = this;
// prompt for new data
self.instance.prompt(
"Enter: new position + \":\" + new name",
"Enter: position + \":\" + name",
function(newdata) {
var newindex = parseInt(newdata.split(":")[0], 10);
var newname = newdata.split(":")[1];
// check for wrong format
if (newdata.split(":").length != 2 || newindex < 1 || self.names.length < newindex || isNaN(newindex)) {
if (newdata.split(":").length != 2) {
self.instance.alert("Wrong format inserted!");
return;
}
if (newindex < 1 || self.names.length < newindex || isNaN(newindex)) {
self.instance.alert("New index out of boundaries.");
return;
}
// change position and name
newindex--;
var oldname = self.names[index];
......@@ -219,7 +233,7 @@ var BookmarkContainer = Class.extend({
});
promise2.done(function(res2) {
if (res1.success && res2.success) {
self.FileBase.updateView();
self.setContent();
} else {
self.instance.alert("Couldn't edit bookmark.");
self.names.splice(newindex, 1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment