-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathupload.js
More file actions
49 lines (45 loc) · 1.57 KB
/
Copy pathupload.js
File metadata and controls
49 lines (45 loc) · 1.57 KB
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
import $ from "jquery";
import _ from "underscore";
import PopoverView from "../../../../core/ui/views/popover";
import Upload from "../../../upload/upload--implementation";
export default PopoverView.extend({
className: "popover upload",
title: _.template('<%- _t("Upload files") %>'),
content: _.template(
'<input type="text" name="upload" style="display:none" />' +
'<div class="uploadify-me"></div>'
),
initialize(options) {
this.app = options.app;
PopoverView.prototype.initialize.apply(this, [options]);
this.currentPathData = null;
$("body").on("context-info-loaded", (event, data) => {
this.currentPathData = data;
});
},
render() {
PopoverView.prototype.render.call(this);
var options = this.app.options.upload;
options.success = () => {
this.app.collection.fetch();
};
options.currentPath = this.app.getCurrentPath();
options.allowPathSelection = false;
this.upload = new Upload(
this.$(".uploadify-me").addClass("pat-upload"),
options
);
return this;
},
toggle(button, e) {
/* we need to be able to change the current default upload directory */
PopoverView.prototype.toggle.apply(this, [button, e]);
if (!this.opened) {
return;
}
var currentPath = this.app.getCurrentPath();
if (this.currentPathData && currentPath !== this.upload.currentPath) {
this.upload.setPath(currentPath);
}
},
});