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

File: fix #2042

parent 3e715d53
var Tableview = Class.extend({
init: function(FileBase) {
init: function (FileBase) {
"use strict";
this.FileBase = FileBase;
this.instance = FileBase.instance;
this.mainContainer = null;
this.type = "Table";
this.template = null;
this.fileContentContainer = FileBase.view.fileContentContainer;
},
render: function() {
render: function () {
"use strict";
var self = this;
this.instance.getTemplate("html/table.html", function(error, template, dfd) {
this.instance.getTemplate("html/table.html", function (error, template) {
// self.fileContentContainer.append(template);
self.template = template;
if (self.FileBase.workflow.data === null) {
......@@ -23,7 +22,7 @@ var Tableview = Class.extend({
});
},
setContent: function(data) {
setContent: function (data) {
"use strict";
var self = this;
// this._super();
......@@ -36,28 +35,27 @@ var Tableview = Class.extend({
// render the content
$(".file-list", this.fileContentContainer).render(data.filelist,
this.FileBase.view.directives);
this.FileBase.view.directives);
// set icon size
self.setIconSize();
// resize header of table, also when browser is resized
self.resizeHeader();
$(window).resize(function() {
$(window).resize(function () {
self.resizeHeader();
});
// make edit buttons clickable, only when display is no touch display
if (vispa.device.hasTouch) {
$(".file-list", this.fileContentContainer).toggleClass("edit-tools-hidden", true);
}
else {
} else {
self.makeEditButtonsClickable();
}
// make select-all-checkbox clickable
$(".select-all", self.fileContentContainer).click(function() {
setTimeout(function() {
$(".select-all", self.fileContentContainer).click(function () {
setTimeout(function () {
$(this).prop("checked", $(this).prop("checked") ? "" : "checked");
if ($(this).prop("checked")) {
self.FileBase.selections.selectAll();
......@@ -69,19 +67,19 @@ var Tableview = Class.extend({
// call function for sorting carets
var firstRowName = $(".name", ".file-table-head");
firstRowName.click(function() {
firstRowName.click(function () {
self.FileBase.sorting.changeSort("name");
self.toggleSortCarets("name");
});
var firstRowLastChanged = $(".time", ".file-table-head");
firstRowLastChanged.click(function() {
firstRowLastChanged.click(function () {
self.FileBase.sorting.changeSort("time");
self.toggleSortCarets("time");
});
var firstRowSize = $(".size", ".file-table-head");
firstRowSize.click(function() {
firstRowSize.click(function () {
self.FileBase.sorting.changeSort("size");
self.toggleSortCarets("size");
});
......@@ -89,10 +87,10 @@ var Tableview = Class.extend({
this.toggleSortCarets();
},
toggleSortCarets: function(type, reverse) {
toggleSortCarets: function (type, reverse) {
"use strict";
type = type === undefined ? this.FileBase.sorting.currentSort : type;
reverse = reverse === undefined ? this.FileBase.sorting.currentReverse : reverse;
type = type === undefined ? this.FileBase.workflow.sort : type;
reverse = reverse === undefined ? this.FileBase.workflow.reverse : reverse;
var sortGlyphicons = ["name", "time", "size"];
var sortMenu = $(".file-table-head", this.FileBase.view.fileContentContainer);
for (var i = 0; i < sortGlyphicons.length; i++) {
......@@ -103,7 +101,7 @@ var Tableview = Class.extend({
glyph.addClass("glyphicon glyphicon-sort");
} else {
var glyphClass = sortGlyphicons[i] == "name" ? "glyphicon glyphicon-sort-by-alphabet" :
"glyphicon glyphicon-sort-by-order";
"glyphicon glyphicon-sort-by-order";
if (sortGlyphicons[i] == "time") {
glyphClass = !reverse ? glyphClass + "-alt" : glyphClass;
} else {
......@@ -115,16 +113,16 @@ var Tableview = Class.extend({
}
},
setIconSize: function() {
setIconSize: function () {
"use strict";
var iconSize = this.FileBase.instance.getPreference("IconSize");
var $table = $(".file-view-table", this.fileContentContainer);
["tiny", "small", "medium", "large"].forEach(function(size) {
["tiny", "small", "medium", "large"].forEach(function (size) {
$table.toggleClass("row-" + size, size == iconSize);
});
},
resizeHeader: function() {
resizeHeader: function () {
"use strict";
var $firstNode = $(".file-list .node:first-child", this.fileContentContainer);
var nameColumnWidth = $(".name", $firstNode).width();
......@@ -134,11 +132,11 @@ var Tableview = Class.extend({
$(".file-table-head .name", this.fileContentContainer).css("width", nameColumnWidth);
},
makeEditButtonsClickable: function() {
makeEditButtonsClickable: function () {
"use strict";
var self = this;
$(".edit-rename", this.fileContentContainer).click(function(event) {
$(".edit-rename", this.fileContentContainer).click(function (event) {
event.stopPropagation();
event.preventDefault();
var node = $(event.currentTarget.parentElement.parentElement);
......@@ -147,7 +145,7 @@ var Tableview = Class.extend({
self.inlineRename(node);
});
$(".edit-download", this.fileContentContainer).click(function(event) {
$(".edit-download", this.fileContentContainer).click(function (event) {
event.stopPropagation();
event.preventDefault();
var node = $(event.currentTarget.parentElement.parentElement);
......@@ -157,7 +155,7 @@ var Tableview = Class.extend({
});
// sharing not yet implemented
$(".edit-share", this.fileContentContainer).click(function(event) {
$(".edit-share", this.fileContentContainer).click(function (event) {
event.stopPropagation();
event.preventDefault();
var node = $(event.currentTarget.parentElement.parentElement);
......@@ -166,7 +164,7 @@ var Tableview = Class.extend({
self.FileBase.instance.alert("Sharing not yet implemented.");
});
$(".edit-remove", this.fileContentContainer).click(function(event) {
$(".edit-remove", this.fileContentContainer).click(function (event) {
event.stopPropagation();
event.preventDefault();
var node = $(event.currentTarget.parentElement.parentElement);
......@@ -176,7 +174,7 @@ var Tableview = Class.extend({
});
},
inlineRename: function(node) {
inlineRename: function (node) {
"use strict";
var self = this;
// stop drag and drop for better in line renaming
......@@ -210,12 +208,12 @@ var Tableview = Class.extend({
replaceWith.focus();
// when clicking in input filed, do not open folder or file
replaceWith.click(function(event) {
replaceWith.click(function (event) {
event.stopPropagation();
});
// rename on blur
replaceWith.blur(function() {
replaceWith.blur(function () {
var path = self.FileBase.workflow.path;
var name = node.data("data").name;
var newName = replaceWith.val();
......@@ -232,7 +230,7 @@ var Tableview = Class.extend({
$(".edit-tools", node).removeClass("file-table-hidden");
});
// rename when pressing enter
replaceWith.keypress(function(event) {
replaceWith.keypress(function (event) {
if (event.which == 13) {
this.blur();
}
......
Markdown is supported
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