Commit e55b7b07 authored by Martin Urban's avatar Martin Urban
Browse files

File: First step towards touch, add menu entries for FileSelector

parent 7a49e0d5
......@@ -2,6 +2,7 @@
margin-top: 4px;
overflow: auto;
height: 100%;
-webkit-user-select: none;
}
.symbol-item {
......@@ -10,6 +11,7 @@
border-radius: 5px;
width: 120px;
float: left;
-webkit-user-select: none;
}
.symbol-item:hover {
......@@ -29,6 +31,7 @@
position: relative;
vertical-align: middle;
visibility: visible;
-webkit-user-select: none;
}
......@@ -38,6 +41,7 @@
text-align: center;
z-index: -1;
padding 0px
-webkit-user-select: none;
}
.symbol-name {
......@@ -53,6 +57,7 @@
width: 120px;
word-wrap: break-word;
/*height 10px*/
-webkit-user-select: none;
}
.file-selection-box {
......@@ -62,6 +67,7 @@
bottom: 0px
right: 0px;
visibility: hidden;
-webkit-user-select: none;
}
.file-selection-box:after {
......@@ -73,6 +79,7 @@
right: -10px;
/*border: 1px solid silver;*/
border-radius: 18px;
-webkit-user-select: none;
}
.file-selection-box input {
......@@ -88,6 +95,7 @@
display: block;
height: 16px;
width: 16px;
-webkit-user-select: none;
/*margin-left: 20px;*/
/*margin-top: 4px;*/
}
......@@ -108,6 +116,7 @@
.file-warning{
background-color: red; text-align: center;
-webkit-user-select: none;
}
......@@ -124,6 +133,7 @@
.file-opt {
visibility: hidden;
margin-left: 70px;
-webkit-user-select: none;
}
.file-opt:after {
......
......@@ -22,7 +22,7 @@ var FileBase = Class.extend({
};
// Get the default view from the preferences
viewstring = this.instance.getPreference("View");
viewstring = vispa.device.hasTouch ? "Table" : this.instance.getPreference("View");
this.workflow.currentView = viewstring == "Symbol" ? Symbolview : Tableview;
},
......
......@@ -30,7 +30,8 @@ var FileBaseEvents = Class.extend({
var self = this;
// ####################################################################
// click on the node itself
node.on("contextmenu", function(event) {
var menuOpenString = vispa.device.hasTouch ? "taphold" : "contextmenu";
node.on(menuOpenString, function(event) {
event.stopPropagation();
var abspath = self.FileBase.helper.abspath(data.name);
var inselection = self.FileBase.selections.entries[abspath];
......@@ -66,6 +67,9 @@ var FileBaseEvents = Class.extend({
var self = this;
var openstring = this.FileBase.instance.getPreference("Open");
openstring = openstring == "single" ? "click" : "dblclick";
// For touch devices there exists no dbltap, thus everything has
// to be switched to tap (=single) events
openstring = vispa.device.hasTouch ? "tap" : openstring;
node.on(openstring, function(event) {
event.preventDefault();
event.stopPropagation();
......@@ -130,21 +134,12 @@ var FileBaseEvents = Class.extend({
self.FileBase.selections.unselectAll();
$(".actionmenu").hide();
});
nodeBkg.on("contextmenu", function(event) {
event.preventDefault();
// event.stopPropagation();
self.FileBase.menuitems.showMenu(event, "b");
});
// var selectkey = this.FileBase.instance.getPreference("SingleSelect");
// $(window).on("keydown", function(event) {
// if (event.keyCode == 17 /*ctrl*/) {
// console.log("CTRL was pressed");
// }
// });
// $(window).on("keyup", function(event){
// if (event.keyCode == 17 /*ctrl*/) {
// console.log("CTRL was released");
// };
// })
// Don't use hold menus on touch
if (!vispa.device.hasTouch) {
nodeBkg.on("contextmenu", function(event) {
event.preventDefault();
self.FileBase.menuitems.showMenu(event, "b");
});
}
}
});
\ No newline at end of file
......@@ -81,6 +81,11 @@ var FileBaseMenuItems = Class.extend({
menuPostion.x = 2 * event.clientX - event.pageX;
menuPostion.y = event.clientY - offset;
if (vispa.device.hasTouch) {
menuPostion.x += 5;
menuPostion.y += 5;
};
// Check if the side borders are reached
if (menuPostion.x + menuDimension.x > fCC.width()) {
menuPostion.x = fCC.width() - menuDimension.x;
......
......@@ -12,7 +12,7 @@ var FileBaseSelections = Class.extend({
})
this.entries = {};
this.lastSelectedNode = null;
if (this.FileBase.instance.getPreference("Open") == "double") {
if (this.FileBase.instance.getPreference("Open") == "double" && !vispa.device.hasTouch) {
$(".file-selection-box").css("visibility", "hidden");
}
},
......@@ -28,7 +28,8 @@ var FileBaseSelections = Class.extend({
unselect: function(path) {
delete this.entries[path];
if ($.isEmptyObject(this.entries) && this.FileBase.instance.getPreference("Open") == "double") {
if ($.isEmptyObject(this.entries) && !vispa.device.hasTouch && this.FileBase.instance.getPreference(
"Open") == "double") {
$(".file-selection-box").css("visibility", "hidden");
}
},
......
......@@ -29,11 +29,14 @@ var Symbolview = Class.extend({
this.fileContentContainer.empty();
this.fileContentContainer.html(this.template);
if (this.FileBase.instance.getPreference("Open") == "single") {
if (this.FileBase.instance.getPreference("Open") == "single" || vispa.device.hasTouch) {
$(".file-selection-box").css("visibility", "visible");
} else {
$(".file-selection-box").css("visibility", "hidden");
};
if (vispa.device.hasTouch) {
$(".file-properties").css("visibility", "visible")
};
// Set the right path
this.FileBase.workflow.parentpath = data.parentpath;
......
......@@ -113,6 +113,7 @@ var FileBrowserView = vispa.ExtensionView.Center.extend({
this.path = args.path || this.getPreference("OpenPath");
// Add the menu items
var fileMenuEntries = getFileMenuEntries();
$.each(fileMenuEntries, function(key, obj) {
self.addMenuEntry(key, obj);
});
......@@ -215,6 +216,11 @@ var FileSelectorView = vispa.ExtensionView.Dialog.extend({
init: function(preferences, shortcuts) {
this._super(preferences, shortcuts);
// Add the menu items
var fileMenuEntries = getFileMenuEntries();
$.each(fileMenuEntries, function(key, obj) {
self.addMenuEntry(key, obj);
});
var args = Array.prototype.slice.call(arguments, 2)[0] || {};
this.path = args.path || this.getPreference("OpenPath");
......@@ -326,6 +332,7 @@ var FileSelectorView = vispa.ExtensionView.Dialog.extend({
$(function() {
vispa.extensions.registerExtension(FileExtension);
// register a callback to easily allow developpers to access the FileSelector
// vispa.callbacks.emit("openFileSelector", workspaceId (e.g. 1), args as described in selector.js)
vispa.callbacks.on("openFileSelector", function(workspaceId, args) {
var ext = vispa.extensions.getExtension("file");
ext.createInstance(workspaceId, FileSelectorView, args);
......
var fileMenuEntries = [
// "myIdKey": {
// label: "My ID",
// iconClass: "glyphicon glyphicon-info-sign",
// buttonClass: "btn-primary",
// childrenStyle: "group, split, basic"
// callback: function() {
// console.log(this);
// this.alert("My ID is: " + this.getId());
// },
// },
{
id: "Up",
label: "Go up",
iconClass: "glyphicon glyphicon-arrow-up",
buttonClass: "btn-default",
callback: function() {
this.fb.workflow.path = this.fb.workflow.parentpath;
this.fb.updateView();
}
}, {
id: "Views",
label: "Change View",
iconClass: "glyphicon glyphicon-picture",
buttonClass: "btn-default",
childrenStyle: "group",
children: [{
id: "Symbol",
label: "Symbol",
iconClass: "glyphicon glyphicon-picture",
function getFileMenuEntries() {
var fileMenuEntries = [
// "myIdKey": {
// label: "My ID",
// iconClass: "glyphicon glyphicon-info-sign",
// buttonClass: "btn-primary",
// childrenStyle: "group, split, basic"
// callback: function() {
// console.log(this);
// this.alert("My ID is: " + this.getId());
// },
// },
{
id: "Up",
label: "Go up",
iconClass: "glyphicon glyphicon-arrow-up",
buttonClass: "btn-default",
callback: function() {
this.fb.changeView(Symbolview);
this.fb.workflow.path = this.fb.workflow.parentpath;
this.fb.updateView();
}
}, {
id: "Table",
label: "Table",
iconClass: "glyphicon glyphicon-list",
id: "Views",
label: "Change View",
iconClass: "glyphicon glyphicon-picture",
buttonClass: "btn-default",
callback: function() {
this.fb.changeView(Tableview);
}
}]
}, {
id: "Upload",
label: "Upload",
iconClass: "glyphicon glyphicon-upload",
buttonClass: "btn-default",
callback: function() {
this.fb.actions.upload();
}
},
{
id: "Refresh",
label: "Refresh",
iconClass: "glyphicon glyphicon-repeat",
buttonClass: "btn-default",
callback: function() {
// this.fb.refresh(this.fb.workflow.data);
this.fb.updateView();
}
},
{
id: "Sort",
label: "Sort",
buttonClass: "btn-default",
childrenStyle: "group",
children: [{
id: "name",
label: "name",
iconClass: "glyphicon glyphicon-sort-by-alphabet",
buttonClass: "btn-default active",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("name") && !~this.wf.sort.indexOf("ext")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["name", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["name", "type"], [false, false]);
childrenStyle: "group",
children: [{
id: "Symbol",
label: "Symbol",
iconClass: "glyphicon glyphicon-picture",
buttonClass: "btn-default",
callback: function() {
this.fb.changeView(Symbolview);
}
this.fb.helper.changeSortButtons("name", this.wf.reverse[0]);
}
}, {
id: "Table",
label: "Table",
iconClass: "glyphicon glyphicon-list",
buttonClass: "btn-default",
callback: function() {
this.fb.changeView(Tableview);
}
}]
}, {
id: "size",
label: "size",
iconClass: "glyphicon glyphicon-sort",
id: "Upload",
label: "Upload",
iconClass: "glyphicon glyphicon-upload",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("size")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["size", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["size", "type"], [false, false]);
}
this.fb.helper.changeSortButtons("size", this.wf.reverse[0]);
this.fb.actions.upload();
}
}, {
id: "last-changed",
label: "last changed",
iconClass: "glyphicon glyphicon-sort",
},
{
id: "Refresh",
label: "Refresh",
iconClass: "glyphicon glyphicon-repeat",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("time")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["time", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["time", "type"], [false, false]);
}
this.fb.helper.changeSortButtons("last-changed", this.wf.reverse[0]);
// this.fb.refresh(this.fb.workflow.data);
this.fb.updateView();
}
}, {
id: "type",
label: "type",
iconClass: "glyphicon glyphicon-sort",
},
{
id: "Sort",
label: "Sort",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("ext")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.wf.reverse[1] = !this.wf.reverse[1];
this.wf.reverse[2] = false;
this.fb.refresh(this.wf.data, ["name", "ext", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["name", "ext", "type"], [false, false, false]);
childrenStyle: "group",
children: [{
id: "name",
label: "name",
iconClass: "glyphicon glyphicon-sort-by-alphabet",
buttonClass: "btn-default active",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("name") && !~this.wf.sort.indexOf("ext")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["name", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["name", "type"], [false, false]);
}
this.fb.helper.changeSortButtons("name", this.wf.reverse[0]);
}
}, {
id: "size",
label: "size",
iconClass: "glyphicon glyphicon-sort",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("size")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["size", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["size", "type"], [false, false]);
}
this.fb.helper.changeSortButtons("size", this.wf.reverse[0]);
}
}, {
id: "last-changed",
label: "last changed",
iconClass: "glyphicon glyphicon-sort",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("time")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.fb.refresh(this.wf.data, ["time", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["time", "type"], [false, false]);
}
this.fb.helper.changeSortButtons("last-changed", this.wf.reverse[0]);
}
}, {
id: "type",
label: "type",
iconClass: "glyphicon glyphicon-sort",
buttonClass: "btn-default",
callback: function() {
this.wf = this.fb.workflow;
if (~this.wf.sort.indexOf("ext")) {
this.wf.reverse[0] = !this.wf.reverse[0];
this.wf.reverse[1] = !this.wf.reverse[1];
this.wf.reverse[2] = false;
this.fb.refresh(this.wf.data, ["name", "ext", "type"], this.wf.reverse);
} else {
this.fb.refresh(this.wf.data, ["name", "ext", "type"], [false, false, false]);
}
this.fb.helper.changeSortButtons("type", this.wf.reverse[1]);
}
}
this.fb.helper.changeSortButtons("type", this.wf.reverse[1]);
}
}
]
},
]
},
];
\ No newline at end of file
];
if (vispa.device.hasTouch) {fileMenuEntries.splice(1,1);};
return fileMenuEntries;
}
\ No newline at end of file
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