Commit 18587a20 authored by Martin Urban's avatar Martin Urban
Browse files

File: sorting in different browser, fix #2032, fix #2000. Several updates to...

File: sorting in different browser, fix #2032, fix #2000. Several updates to our coding conventions, removing unneeded variables
parent 1f15ee0c
......@@ -8,6 +8,8 @@ server.pid
conf/*.ini
var
.settings
.idea
.jshintrc
.project
.pydevproject
.metadata
......
.file-view-symbol{position:absolute;top:40px;left:0;bottom:0;overflow:auto;-webkit-user-select:none}.file-view-symbol.icon-tiny .file-node{margin:5px}.file-view-symbol.icon-tiny .file-node{width:80px;height:68px}.file-view-symbol.icon-tiny .symbol-icon-p{margin-top:-35px;display:inline-block;text-align:center;z-index:-1;padding:0;-webkit-user-select:none;font-size:24px;width:80px}.file-view-symbol.icon-tiny .symbol-name{width:80px}.file-view-symbol.icon-tiny .file-selection-box{left:12px}.file-view-symbol.icon-tiny .file-properties{margin-top:-9px;top:10px}.file-view-symbol.icon-small .file-node{margin:2px 4px 2px 4px}.file-view-symbol.icon-small .file-node{width:100px;height:85px}.file-view-symbol.icon-small .symbol-icon-p{margin-top:-35px;display:inline-block;text-align:center;z-index:-1;padding:0;-webkit-user-select:none;font-size:30px;width:100px}.file-view-symbol.icon-small .symbol-name{width:100px}.file-view-symbol.icon-small .file-selection-box{left:20px}.file-view-symbol.icon-small .file-properties{margin-top:1px;top:0}.file-view-symbol.icon-medium .file-node{margin:8px}.file-view-symbol.icon-medium .file-node{width:110px;height:90px}.file-view-symbol.icon-medium .symbol-icon-p{margin-top:-23px;display:inline-block;text-align:center;z-index:-1;padding:0;-webkit-user-select:none;font-size:38px;width:110px}.file-view-symbol.icon-medium .symbol-name{width:110px}.file-view-symbol.icon-medium .file-selection-box{left:20px}.file-view-symbol.icon-medium .file-properties{margin-top:1px;top:0}.file-view-symbol.icon-large .file-node{margin:12px}.file-view-symbol.icon-large .file-node{width:116px;height:100px}.file-view-symbol.icon-large .symbol-icon-p{margin-top:-24px;display:inline-block;text-align:center;z-index:-1;padding:0;-webkit-user-select:none;font-size:46px;width:116px}.file-view-symbol.icon-large .symbol-name{width:116px}.file-view-symbol.icon-large .file-selection-box{left:20px}.file-view-symbol.icon-large .file-properties{margin-top:1px;top:0}.file-view-symbol .file-node{border-radius:5px;float:left;-webkit-user-select:none}.file-view-symbol .file-node[draggable=true]{cursor:move;-khtml-user-drag:element}.file-view-symbol .file-node:hover{background-color:#f5f5f5;cursor:pointer}.file-view-symbol .file-node:hover>.file-properties{visibility:visible}.file-view-symbol .file-node[selected]{background-color:#d2d2d2;color:white}.file-view-symbol .file-node[selected]>.file-properties{visibility:visible}.file-view-symbol .file-node.dragstart{opacity:.4}.file-view-symbol .file-node.dragover{background-color:rgba(92,184,92,0.5) !important}.file-view-symbol .file-selection-p{display:inherit;margin:0 0 0 4px;position:relative;visibility:visible;-webkit-user-select:none}.file-view-symbol .symbol-name{-webkit-hyphens:auto;-moz-hyphens:auto;display:inline-block;font-family:'Trebuchet MS',Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;margin-top:-5px;overflow:hidden;text-align:center;word-wrap:break-word;-webkit-user-select:none}.file-view-symbol .file-selection-box{position:absolute;top:2px;visibility:hidden;-webkit-user-select:none;content:''}.file-view-symbol .file-selection-box span{background:url("../../../../img/white_plus.png");background-color:green;background-position:center;background-repeat:no-repeat;border-radius:8px;display:block;height:16px;width:16px;-webkit-user-select:none}.file-view-symbol .file-selection-box input{display:none}.file-view-symbol .file-selection-box input:checked+span{background:url("../../../../img/white_minus.png");background-color:red;background-position:center;background-repeat:no-repeat}.file-view-symbol .file-properties{visibility:hidden;float:right;margin-right:3px;-webkit-user-select:none}
\ No newline at end of file
.file-view-symbol {
position: absolute;
top: 40px;
left: 0;
bottom: 0;
overflow: auto;
-webkit-user-select: none;
}
.file-view-symbol.icon-tiny .file-node {
margin: 5px;
}
.file-view-symbol.icon-tiny .file-node {
width: 80px;
height: 68px;
}
.file-view-symbol.icon-tiny .symbol-icon-p {
margin-top: -35px;
display: inline-block;
text-align: center;
z-index: -1;
padding: 0;
-webkit-user-select: none;
font-size: 24px;
width: 80px;
}
.file-view-symbol.icon-tiny .symbol-name {
width: 80px;
}
.file-view-symbol.icon-tiny .file-selection-box {
left: 12px;
}
.file-view-symbol.icon-tiny .file-properties {
margin-top: -9px;
top: 10px;
}
.file-view-symbol.icon-small .file-node {
margin: 2px 4px 2px 4px;
}
.file-view-symbol.icon-small .file-node {
width: 100px;
height: 85px;
}
.file-view-symbol.icon-small .symbol-icon-p {
margin-top: -35px;
display: inline-block;
text-align: center;
z-index: -1;
padding: 0;
-webkit-user-select: none;
font-size: 30px;
width: 100px;
}
.file-view-symbol.icon-small .symbol-name {
width: 100px;
}
.file-view-symbol.icon-small .file-selection-box {
left: 20px;
}
.file-view-symbol.icon-small .file-properties {
margin-top: 1px;
top: 0px;
}
.file-view-symbol.icon-medium .file-node {
margin: 8px;
}
.file-view-symbol.icon-medium .file-node {
width: 110px;
height: 90px;
}
.file-view-symbol.icon-medium .symbol-icon-p {
margin-top: -23px;
display: inline-block;
text-align: center;
z-index: -1;
padding: 0;
-webkit-user-select: none;
font-size: 38px;
width: 110px;
}
.file-view-symbol.icon-medium .symbol-name {
width: 110px;
}
.file-view-symbol.icon-medium .file-selection-box {
left: 20px;
}
.file-view-symbol.icon-medium .file-properties {
margin-top: 1px;
top: 0px;
}
.file-view-symbol.icon-large .file-node {
margin: 12px;
}
.file-view-symbol.icon-large .file-node {
width: 116px;
height: 100px;
}
.file-view-symbol.icon-large .symbol-icon-p {
margin-top: -24px;
display: inline-block;
text-align: center;
z-index: -1;
padding: 0;
-webkit-user-select: none;
font-size: 46px;
width: 116px;
}
.file-view-symbol.icon-large .symbol-name {
width: 116px;
}
.file-view-symbol.icon-large .file-selection-box {
left: 20px;
}
.file-view-symbol.icon-large .file-properties {
margin-top: 1px;
top: 0px;
}
.file-view-symbol .file-node {
border-radius: 5px;
float: left;
-webkit-user-select: none;
}
.file-view-symbol .file-node[draggable=true] {
cursor: move;
-khtml-user-drag: element;
}
.file-view-symbol .file-node:hover {
background-color: #f5f5f5;
cursor: pointer;
}
.file-view-symbol .file-node:hover > .file-properties {
visibility: visible;
}
.file-view-symbol .file-node[selected] {
background-color: #D2D2D2;
color: white;
}
.file-view-symbol .file-node[selected] > .file-properties {
visibility: visible;
}
.file-view-symbol .file-node.dragstart {
opacity: 0.4;
}
.file-view-symbol .file-node.dragover {
background-color: rgba(92, 184, 92, 0.5) !important;
}
.file-view-symbol .file-selection-p {
display: inherit;
margin: 0 0 0 4px;
position: relative;
visibility: visible;
-webkit-user-select: none;
}
.file-view-symbol .symbol-name {
-webkit-hyphens: auto;
-moz-hyphens: auto;
display: inline-block;
font-family: 'Trebuchet MS', Helvetica, Arial, sans-serif;
font-size: 13px;
font-weight: normal;
margin-top: -5px;
overflow: hidden;
text-align: center;
word-wrap: break-word;
-webkit-user-select: none;
}
.file-view-symbol .file-selection-box {
position: absolute;
top: 2px;
visibility: hidden;
-webkit-user-select: none;
content: '';
}
.file-view-symbol .file-selection-box span {
background: green url("../../../../img/white_plus.png") no-repeat center;
border-radius: 8px;
display: block;
height: 16px;
width: 16px;
-webkit-user-select: none;
}
.file-view-symbol .file-selection-box input {
display: none;
}
.file-view-symbol .file-selection-box input:checked + span {
background: red url("../../../../img/white_minus.png") no-repeat center;
}
.file-view-symbol .file-properties {
visibility: hidden;
float: right;
margin-right: 3px;
-webkit-user-select: none;
}
......@@ -32,13 +32,14 @@
.file-node {
width: @@node-width;
height: @@node-height;
// order: 1;
}
.symbol-icon-p {
margin-top: @@margin-top;
display: inline-block;
text-align: center;
z-index: -1;
padding: 0px;
padding: 0;
-webkit-user-select: none;
font-size: @@font-size;
width: @@node-width;
......@@ -62,8 +63,10 @@
.file-view-symbol {
position: absolute;
top: 40px;
left: 0px;
bottom: 0px;
left: 0;
// display: flex;
// flex-wrap: wrap;
bottom: 0;
overflow: auto;
-webkit-user-select: none;
&.icon-tiny {
......@@ -132,7 +135,7 @@
}
.file-selection-p {
display: inherit;
margin: 0px 0px 0px 4px;
margin: 0 0 0 4px;
position: relative;
visibility: visible;
-webkit-user-select: none;
......@@ -157,10 +160,7 @@
-webkit-user-select: none;
content: '';
span {
background: url("../../../../img/white_plus.png");
background-color: green;
background-position: center;
background-repeat: no-repeat;
background: green url("../../../../img/white_plus.png") no-repeat center;
border-radius: 8px;
display: block;
height: 16px;
......@@ -170,10 +170,7 @@
input {
display: none;
&:checked + span {
background: url("../../../../img/white_minus.png");
background-color: red;
background-position: center;
background-repeat: no-repeat;
background: red url("../../../../img/white_minus.png") no-repeat center;
}
}
}
......
......@@ -252,7 +252,7 @@ var FileBaseActions = Class.extend({
style: "display:none;"
}).appendTo("body");
}
return;
},
compress: function() {
......
......@@ -21,12 +21,12 @@ var FileBase = Class.extend({
currentView: null,
data: null,
selectmode: false,
sort: ["name", "type"],
reverse: [false, false],
sort: "name",
reverse: false,
lastRefresh: null,
updateState: 0, // 0: idle, >0: last request, -1: running,
// -2: done & requested again, -3: running & requested again
lazyUpdate: false,
lazyUpdate: false
};
// Get the default view from the preferences
......@@ -62,7 +62,7 @@ var FileBase = Class.extend({
this.instance.pushPreferences();
// add the view to the center pane of the main container
var viewContainer = this.workflow.currentView.render();
this.workflow.currentView.render();
},
updateView: function(additionalDelay) {
......@@ -110,7 +110,7 @@ var FileBase = Class.extend({
}
self.refresh(content);
self.workflow.updateState++;
}).fail(function(err) {
}).fail(function() {
self.instance.setLoading(false);
self.workflow.updateState++;
});
......@@ -118,7 +118,6 @@ var FileBase = Class.extend({
},
refresh: function(content, sort, reverse, filter) {
var self = this;
if (!content) {
return;
}
......@@ -130,19 +129,6 @@ var FileBase = Class.extend({
if (!filter) {
this.workflow.data = content;
}
this.workflow.sort = sort instanceof Array ? sort : [sort];
var nElements = this.workflow.sort.length;
if (reverse.length == nElements) {
this.workflow.reverse = reverse;
} else {
if (reverse instanceof Array) {
reverse = reverse[0];
}
this.workflow.reverse = [];
for (var i = 0; i < nElements; i++) {
this.workflow.reverse.push(reverse);
}
}
this.helper.sortItems(content, sort, reverse);
this.workflow.currentView.setContent(content);
this.pathBar.render();
......
......@@ -311,7 +311,7 @@ var Bookmark = Class.extend({
replaceWith.blur(function(event) {
event.preventDefault();
//check for ascii
var ascii = /^[ -~]+$/
var ascii = /^[ -~]+$/;
if (!ascii.test(String(replaceWith.val()))) {
replaceWith.remove();
bookmark.show();
......
......@@ -89,7 +89,7 @@ var FileBaseEvents = Class.extend({
.entries).length > 0) {
self.FileBase.selections.unselectAll();
self.FileBase.menuitems.hideMenu();
return;
} else {
self.FileBase.selections.unselectAll();
self.FileBase.selections.changeSelection(node, true);
......
......@@ -9,60 +9,81 @@ var FileBaseHelper = Class.extend({
// Sort function for the different sorting types of the file extension
sortItems: function(content, type, reverse) {
var self = this;
reverse = reverse === undefined ? false : reverse;
if (reverse instanceof Array) {
if (type instanceof Array) {
$.each(type, function(i, elem) {
return self.sortItems(content, elem, reverse[i]);
});
var directories = [];
var files = [];
var len = content.filelist.length;
for (var i = 0; i < len; i++) {
var elem = content.filelist[i];
if (elem.type == "d") {
directories.push(elem);
} else {
return;
}
} else {
if (type instanceof Array) {
$.each(type, function(i, elem) {
return self.sortItems(content, elem, reverse);
});
files.push(elem);
}
}
if (type === undefined || type == "name") {
$.LocaleSorter(content.filelist, function(item) {
return item.name;
});
if (reverse) {
content.filelist.reverse();
}
} else if (type == "type") {
content.filelist.sort(function(a, b) {
if (a.type == b.type) {
return 0;
} else {
return a.type == "d" ? -1 : +1;
}
});
directories = self.sortByName(directories, reverse);
files = self.sortByName(files, reverse);
} else if (type == "time") {
content.filelist.sort(function(a, b) {
return !reverse ? b.mtime - a.mtime : a.mtime - b.mtime;
});
directories = self.sortByTime(directories, reverse);
files = self.sortByTime(files, reverse);
} else if (type == "ext") {
$.LocaleSorter(content.filelist, function(item) {
var a = self.strExtension(item.name);
return a === null ? "" : a;
});
if (reverse) {
content.filelist.reverse();
}
directories = self.sortByName(directories, false);
self.sortByExt(files, reverse);
} else if (type == "size") {
content.filelist.sort(function(a, b) {
if (a.size == b.size) {
return 0;
} else {
return a.size > b.size;
}
});
if (reverse) {
content.filelist.reverse();
directories = self.sortByName(directories, false);
self.sortBySize(files, reverse);
}
content.filelist = directories.concat(files);
},
sortByName: function(arr, reverse) {
$.LocaleSorter(arr, function(item) {
return item.name;
});
return reverse ? arr.reverse() : arr;
},
sortByTime: function(arr, reverse) {
var self = this;
arr.sort(function(a, b) {
if (b.mtime === a.mtime) {
var help_arr = [a, b];
self.sortByName(help_arr, false);
return help_arr[0].name == a.name ? -1 : 1;
} else {
return !reverse ? b.mtime - a.mtime : a.mtime - b.mtime;
}
});
return arr;
},
sortByExt: function(arr, reverse) {
var self = this;
arr.sort(function(a, b) {
if (a.ext == b.ext) {
var help_arr = [a, b];
self.sortByName(help_arr, false);
return help_arr[0].name == a.name ? -1 : 1;
} else {
return a.ext < b.ext ? -1 : 1;
}
});
return reverse ? arr.reverse() : arr;
},
sortBySize: function(arr, reverse) {
var self = this;
arr.sort(function(a, b) {
if (a.size == b.size) {
var help_arr = [a, b];
self.sortByName(help_arr, false);
return help_arr[0].name == a.name ? -1 : 1;
} else {
return a.size > b.size;
}
});
if (reverse) {
arr.reverse();
}
},
......
......@@ -7,34 +7,34 @@ var FileBaseSorting = Class.extend({
// shortcuts for the different sortings
this.currentSort = "name";
this.currentReverse = false;
this.sortArray = {
"name": ["name", "type"],
"time": ["name", "time", "type"],
"size": ["name", "size", "type"],
"ext": ["name", "ext", "type"]
};
this.defaultSorting = {
"name": [false, true],
"time": [false, false, true],
"size": [false, false, true],
"ext": [false, false, true],
};
// this.sortArray = {
// "name": ["name", "type"],
// "time": ["name", "time", "type"],
// "size": ["name", "size", "type"],
// "ext": ["name", "ext", "type"]
// };
// this.defaultSorting = {
// "name": [false, true],
// "time": [false, false, true],
// "size": [false, false, true],
// "ext": [false, false, true],
// };
},
setReverseSorting: function(type) {
if (type == "time") {
this.wf.reverse[1] = !this.wf.reverse[1];
} else if (type == "size") {
this.wf.reverse[0] = !this.wf.reverse[0];
this.wf.reverse[1] = !this.wf.reverse[1];
} else if (type == "name") {
this.wf.reverse[0] = !this.wf.reverse[0];
} else if (type == "ext") {
this.wf.reverse[0] = !this.wf.reverse[0];
this.wf.reverse[1] = !this.wf.reverse[1];
this.wf.reverse[2] = false;
}
},
// setReverseSorting: function(type) {
// if (type == "time") {
// this.wf.reverse[1] = !this.wf.reverse[1];
// } else if (type == "size") {
// this.wf.reverse[0] = !this.wf.reverse[0];
// this.wf.reverse[1] = !this.wf.reverse[1];
// } else if (type == "name") {
// this.wf.reverse[0] = !this.wf.reverse[0];
// } else if (type == "ext") {
// this.wf.reverse[0] = !this.wf.reverse[0];
// this.wf.reverse[1] = !this.wf.reverse[1];
// this.wf.reverse[2] = false;
// }
// },
toggleSortButtons: function(type, reverse) {
type = type === undefined ? this.currentSort : type;
......@@ -71,15 +71,15 @@ var FileBaseSorting = Class.extend({
this.wf = this.FileBase.workflow;
type = type === undefined ? "name" : type;
if (this.currentSort != type) {
this.wf.reverse = this.defaultSorting[type];
this.wf.reverse = false;
this.currentReverse = false;
this.toggleSortButtons(type, false);
} else {
this.setReverseSorting(type);
this.wf.reverse = !this.wf.reverse;
this.currentReverse = !this.currentReverse;
this.toggleSortButtons(type, this.currentReverse);
}
this.currentSort = type;
this.FileBase.refresh(this.wf.data, this.sortArray[type], this.wf.reverse);
this.FileBase.refresh(this.wf.data, type);
}
});
......@@ -6,7 +6,6 @@ var FileBaseView = Class.extend({
this.instance = FileBase.instance;
this.fileContentContainer = null;
this.filterField = null;
this.masterNode = null;
this.previewBoxID = null;
// directives for rendering, needed for all views
this.directives = {
......@@ -19,6 +18,7 @@ var FileBaseView = Class.extend({
"data": {
"data": function(nodeObj) {
var node = $(nodeObj.element);
// node.css("order", nodeObj.index);
node.data("data", this);