|
32 | 32 | }); |
33 | 33 | self.requesting = false; |
34 | 34 | self.buildTree(path); |
35 | | - |
36 | 35 | if (data.error) { |
37 | 36 | self.error = data.error; |
38 | 37 | return typeof error === 'function' && error(data); |
|
46 | 45 |
|
47 | 46 | FileNavigator.prototype.buildTree = function(path) { |
48 | 47 | var self = this; |
49 | | - function recursive(parent, file, path) { |
50 | | - var absName = path ? (path + '/' + file.name) : file.name; |
| 48 | + function recursive(parent, item, path) { |
| 49 | + var absName = path ? (path + '/' + item.model.name) : item.model.name; |
51 | 50 | if (parent.name.trim() && path.trim().indexOf(parent.name) !== 0) { |
52 | 51 | parent.nodes = []; |
53 | 52 | } |
54 | 53 | if (parent.name !== path) { |
55 | 54 | for (var i in parent.nodes) { |
56 | | - recursive(parent.nodes[i], file, path); |
| 55 | + recursive(parent.nodes[i], item, path); |
57 | 56 | } |
58 | 57 | } else { |
59 | 58 | for (var e in parent.nodes) { |
60 | 59 | if (parent.nodes[e].name === absName) { |
61 | 60 | return; |
62 | 61 | } |
63 | 62 | } |
64 | | - parent.nodes.push({name: absName, nodes: []}); |
| 63 | + parent.nodes.push({item: item, name: absName, nodes: []}); |
65 | 64 | } |
66 | 65 | parent.nodes = parent.nodes.sort(function(a, b) { |
67 | 66 | return a.name < b.name ? -1 : a.name === b.name ? 0 : 1; |
|
71 | 70 | !self.history.length && self.history.push({name: path, nodes: []}); |
72 | 71 | for (var o in self.fileList) { |
73 | 72 | var item = self.fileList[o]; |
74 | | - item.isFolder() && recursive(self.history[0], item.model, path); |
| 73 | + item.isFolder() && recursive(self.history[0], item, path); |
75 | 74 | } |
76 | 75 | }; |
77 | 76 |
|
78 | | - FileNavigator.prototype.folderClickByName = function(fullPath) { |
79 | | - var self = this; |
80 | | - fullPath = fullPath.replace(/^\/*/g, '').split('/'); |
81 | | - self.currentPath = fullPath && fullPath[0] === "" ? [] : fullPath; |
82 | | - self.refresh(); |
83 | | - }; |
84 | | - |
85 | 77 | FileNavigator.prototype.folderClick = function(item) { |
86 | 78 | var self = this; |
87 | | - if (item && item.model.type === 'dir') { |
88 | | - self.currentPath.push(item.model.name); |
89 | | - self.refresh(); |
| 79 | + self.currentPath = []; |
| 80 | + if (item && item.isFolder()) { |
| 81 | + self.currentPath = item.model.fullPath().split('/').splice(1); |
| 82 | + //self.currentPath.push(item.model.name); |
90 | 83 | } |
| 84 | + self.refresh(); |
91 | 85 | }; |
92 | 86 |
|
93 | 87 | FileNavigator.prototype.upDir = function() { |
|
0 commit comments