Commit 874c26d1 authored by murban's avatar murban
Browse files

Implemented events and selections. Events are already connected to the right...

Implemented events and selections. Events are already connected to the right functions. Those functions have still to get functionality, at the moment they are just implementing jlogs()
parent 4bdde793
......@@ -8,6 +8,12 @@
width: 120px;
}
.file-item-hover, .folder-item-hover
{
color: red;
cursor: pointer;
}
.folder-item
{ background-color: blue; }
......
......@@ -4,12 +4,52 @@ var FileBaseActions = Class.extend({
},
openFolder: function(data) {
openFolder: function(data) {;
this.owner.workflow.path = data.path;
this.owner.updateView();
},
openFile: function(data) {
console.log("To be implemented by the browser or selector.");
},
rename: function(data) {
console.log("rename");
},
copy: function(data) {
console.log("copy");
},
cut: function(data) {
console.log("cut");
},
paste: function(data) {
console.log("paste");
},
remove: function(data) {
console.log("remove");
},
download: function(data) {
console.log("download");
},
compress: function(data) {
console.log("compress");
},
info: function(data) {
console.log("info");
},
createFile: function(data) {
console.log("createFile");
},
createFolder: function(data) {
console.log("createFolder");
}
});
\ No newline at end of file
......@@ -7,6 +7,7 @@ var FileBase = Class.extend({
this.events = new FileBaseEvents(this);
this.actions = new FileBaseActions(this);
this.selections = new FileBaseSelections(this);
this.menuitems = new FileBaseMenuItems(this);
// store the formatter
this.urlFormatter = urlFormatter || function(path) {
......
......@@ -4,32 +4,31 @@ var FileBaseEvents = Class.extend({
this.menu = null;
},
renderMenu: function(event) {
this.menu = $('<div/>')
.addClass("file-popupmenu")
.css('top', event.pageY)
.css('left', event.pageX);
return this.menu;
},
showMenu: function(item, event) {
var me = this;
dblClickFolder: function(event, data) {
event.stopPropagation();
event.preventDefault();
this.renderMenu(event);
$.each(item, function(i, itemvalue) {
var action = $('<p/>', {
text: itemvalue
})
me.menu.append(action)
})
return this.menu;
this.owner.actions.openFolder(data);
},
dblClickFolder: function(event, data) {
rightClickFolder: function(event, data) {
var _this = this;
event.stopPropagation();
event.preventDefault();
this.owner.actions.openFolder(data);
var items = [_this.owner.menuitems.openFolder(data),
_this.owner.menuitems.rename(data),
_this.owner.menuitems.copy(data),
_this.owner.menuitems.cut(data),
_this.owner.menuitems.remove(data),
_this.owner.menuitems.compress(data),
_this.owner.menuitems.info(data)];
var openCallback = Vispa.view.menuHandler.create("rightClickBkg", $('body'), items, {}, false, $('body'));
var offset = 2;
var position = {
at: $.Helpers.strFormat('left+{0} top+{1}', event.pageX + offset, event.pageY + offset),
my: 'left top',
of: $('body')
};
openCallback(position);
},
dblClickFile: function(event, data) {
......@@ -38,6 +37,28 @@ var FileBaseEvents = Class.extend({
this.owner.actions.openFile(data);
},
rightClickFile: function(event, data) {
var _this = this;
event.stopPropagation();
event.preventDefault();
var items = [_this.owner.menuitems.openFile(data),
_this.owner.menuitems.rename(data),
_this.owner.menuitems.copy(data),
_this.owner.menuitems.cut(data),
_this.owner.menuitems.remove(data),
_this.owner.menuitems.download(data),
_this.owner.menuitems.compress(data),
_this.owner.menuitems.info(data)];
var openCallback = Vispa.view.menuHandler.create("rightClickBkg", $('body'), items, {}, false, $('body'));
var offset = 2;
var position = {
at: $.Helpers.strFormat('left+{0} top+{1}', event.pageX + offset, event.pageY + offset),
my: 'left top',
of: $('body')
};
openCallback(position);
},
clickBkg: function(event, data) {
var _this = this;
event.stopPropagation();
......@@ -59,13 +80,47 @@ var FileBaseEvents = Class.extend({
this.owner.selections.unselectAll();
console.log(event);
console.log("test left");
},
rightClickBkg: function(event, data) {
var _this = this;
event.stopPropagation();
event.preventDefault();
console.log("test right");
var items = [_this.owner.menuitems.createFile(data),
_this.owner.menuitems.createFolder(data),
_this.owner.menuitems.paste(data, !this.owner.selections.copycutbool),
_this.owner.menuitems.info(data)];
var openCallback = Vispa.view.menuHandler.create("rightClickBkg", $('body'), items, {}, false, $('body'));
var offset = 2;
var position = {
at: $.Helpers.strFormat('left+{0} top+{1}', event.pageX + offset, event.pageY + offset),
my: 'left top',
of: $('body')
};
openCallback(position);
},
rightClickSelection: function (event, data) {
var _this = this;
event.stopPropagation();
event.preventDefault();
var items = [_this.owner.menuitems.copy(data),
_this.owner.menuitems.cut(data),
_this.owner.menuitems.remove(data),
_this.owner.menuitems.compress(data),
_this.owner.menuitems.info(data)];
var openCallback = Vispa.view.menuHandler.create("rightClickBkg", $('body'), items, {}, false, $('body'));
var offset = 2;
var position = {
at: $.Helpers.strFormat('left+{0} top+{1}', event.pageX + offset, event.pageY + offset),
my: 'left top',
of: $('body')
};
openCallback(position);
}
......
var FileBaseMenuItems = Class.extend({
init: function(owner) {
this.owner = owner;
},
openFolder: function(data) {
var _this = this;
var item = {
label: 'Open',
alt: 'Open',
icon: 'ui-icon-folder-open',
callback: function() {
_this.owner.actions.openFolder(data);
}
};
return item;
},
openFile: function(data) {
var _this = this;
return {
label: 'Open',
alt: 'Open',
icon: 'ui-icon-document-b',
callback: function() {
console.log("TODO");
}
};
},
rename: function(data) {
var _this = this;
return {
label: 'Rename',
alt: 'Rename',
icon: 'ui-icon-pencil',
callback: function() {
_this.owner.actions.rename(data);
}
};
},
copy: function(data) {
var _this = this;
return {
label: 'Copy',
alt: 'Copy',
icon: 'ui-icon-copy',
callback: function() {
_this.owner.actions.copy(data);
}
};
},
cut: function(data) {
var _this = this;
return {
label: 'Cut',
alt: 'Cut',
icon: 'ui-icon-scissors',
callback: function() {
_this.owner.actions.cut();
}
};
},
paste: function(data, active = false) {
var _this = this;
return {
label: 'Paste',
alt: 'Paste',
icon: 'ui-icon-eject',
disabled: active,
callback: function() {
_this.owner.actions.paste(data);
}
};
},
remove: function(data) {
var _this = this;
return {
label: 'Remove',
alt: 'Remove',
icon: 'ui-icon-trash',
callback: function() {
_this.owner.actions.remove(data);
}
};
},
download: function(data) {
var _this = this;
return {
label: 'Download',
alt: 'Download',
icon: 'ui-icon-arrowthick-1-s',
callback: function() {
_this.owner.actions.download(data);
}
};
},
compress: function(data) {
var _this = this;
return {
label: 'Compress...',
alt: 'Compress...',
icon: 'ui-icon-suitcase',
callback: function() {
_this.owner.actions.compress(data);
}
};
},
info: function(data) {
var _this = this;
return {
label: 'Info',
alt: 'Info',
icon: 'ui-icon-info',
callback: function() {
_this.owner.actions.info(data);
}
};
},
createFile: function(data) {
var _this = this;
return {
label: 'Create File',
alt: 'Create File',
icon: 'ui-icon-document',
callback: function() {
_this.owner.actions.createFile(data);
}
};
},
createFolder: function(data) {
var _this = this;
return {
label: 'Create Folder',
alt: 'Create Folder',
icon: 'ui-icon-folder-collapsed',
callback: function() {
_this.owner.actions.createFolder(data);
}
};
}
});
\ No newline at end of file
var FileBaseSelections = Class.extend({
init: function(owner) {
this.owner = owner;
this.selectbool = false;
this.entries = {};
},
unselectAll: function() {
$('.file-selection-box').removeAttr('checked');
this.entries = {};
this.selectbool = false;
},
unselect: function (path, node) {
......@@ -16,6 +18,7 @@ var FileBaseSelections = Class.extend({
addSelection: function(path, node)
{
this.selectbool = true;
this.entries[path] = node;
console.log(this.entries);
}
......
......@@ -61,6 +61,7 @@ var Symbolview = Class.extend({
var _this = this;
var icon = $("<div/>");
icon.data = data;
icon.selected = false;
if (data.type == "f") {
icon.addClass("file-item");
} else {
......@@ -84,14 +85,15 @@ var Symbolview = Class.extend({
.addClass("file-selection-box")
.appendTo(selectspan)
.change(function(event) {
event.stopPropagation();
if (selectbox.is(":checked")) {
_this.owner.selections.addSelection(data.name, icon);
} else {
_this.owner.selections.unselect(data.name);
};
});
event.stopPropagation();
if (selectbox.is(":checked")) {
_this.owner.selections.addSelection(data.name, icon);
icon.selected = true;
} else {
_this.owner.selections.unselect(data.name);
};
});
};
......@@ -119,28 +121,17 @@ var Symbolview = Class.extend({
},
title: data.name,
href: "", // document.URL.concat(data.name),
// click: function(event) {
// event.stopPropagation();
// if (data.type == "f") {
// alert(data.name)
// } else {
// _this.owner.workflow.path = data.path;
// _this.owner.updateView();
// console.log("click on upper div");
// };
// },
mouseenter: function(event) {
$(event.target).css("color", "red")
.css("cursor", "pointer");
},
mouseleave: function(event) {
$(event.target).css("color", "black")
.css("cursor", "auto");
}
});
name.on('click', function(event) {
// css
icon.hover(function(event) {
$(this).addClass("file-item-hover");
}, function(event) {
$(this).removeClass("file-item-hover");
});
// leftclick
icon.on('click', function(event) {
if (data.type == "f") {
_this.owner.events.dblClickFile(event, data);
......@@ -148,6 +139,20 @@ var Symbolview = Class.extend({
_this.owner.events.dblClickFolder(event, data);
};
});
// right click
icon.bind("contextmenu", function(event) {
if (icon.selected == true) {
_this.owner.events.rightClickSelection(event, data);
} else {
if (data.type == "f") {
_this.owner.events.rightClickFile(event, data);
} else {
_this.owner.events.rightClickFolder(event, data);
};
};
});
name.appendTo(icon);
return icon;
......
......@@ -567,6 +567,8 @@ var View = VispaModule.extend({
setupMenus: function() {
var mainItems = Vispa.menuItems('main');
console.log("tesdt");
console.log(mainItems);
var mainPosition = {
at: 'right bottom',
my: 'right top'
......
......@@ -75,6 +75,7 @@
"file/filebase/events.js",
"file/filebase/actions.js",
"file/filebase/selections.js",
"file/filebase/items.js",
"file/filebase/views/symbol/view.js",
"file/fileselector/fileselector.js"]
site_scripts = ["index.js",
......
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