forked from enome-components/angular-file-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
96 lines (68 loc) · 2.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
require('webfont');
var mod = window.angular.module('file-manager', [
require('angular-safe-apply'),
require('angular-enter-directive'),
require('angular-droparea'),
require('./js/breadcrumbs'),
require('./js/extra-events'),
require('./js/directories'),
require('./js/files')
]);
mod.run(function ($templateCache) {
window.WebFont.load({ google: { families: ['Roboto Condensed:300'] } });
});
mod.directive('fileManager', function () {
return {
restrict: 'E',
template: require('./template'),
replace: true,
scope: { url: '=', selected: '=selected' },
controller: function ($scope, $timeout) {
if (typeof $scope.selected === 'undefined') {
$scope.selected = [];
}
$scope.path = '/';
$scope.link = function (path) {
$scope.path = path;
};
$scope.select = function (item, checked) {
if (checked) {
return $scope.selected.push(item.path);
}
$scope.selected.splice($scope.selected.indexOf(item.path), 1);
};
$scope.update_selected = function (old_path, new_path) {
if ($scope.selected.some(function (path) { return path === old_path; })) {
$scope.selected.splice($scope.selected.indexOf(old_path), 1, new_path);
}
};
$scope.remove_selected = function (path) {
var i;
var re = new RegExp('^' + path.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") + '($|/)');
for (i = $scope.selected.length - 1; i >= 0; i -= 1) {
if (re.test($scope.selected[i])) {
$scope.selected.splice(i, 1);
}
}
};
$scope.enableRead = function (i) {
if (i.readonly === '') {
return;
}
if (typeof i.stos === 'undefined') {
i.stos = [];
}
i.stos.push($timeout(function () {
i.readonly = '';
}, 250, true));
};
$scope.enableReadonly = function (i) {
i.readonly = 'readonly';
};
$scope.unfocus = function (e) {
e.target.blur();
};
}
};
});
module.exports = 'file-manager';