-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilepicker_controller.js
52 lines (47 loc) · 1.43 KB
/
filepicker_controller.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
(function () {
'use strict';
EmberInkFilepicker.FilepickerController = Ember.ObjectController.extend({
textServices: ['BOX', 'COMPUTER', 'DROPBOX', 'EVERNOTE', 'FTP', 'GITHUB', 'GOOGLE_DRIVE', 'SKYDRIVE', 'WEBDAV', 'GMAIL', 'URL'],
textTypes: ['text/plain'],
imageServices: ['COMPUTER', 'FACEBOOK', 'GMAIL', 'BOX', 'DROPBOX', 'FLICKR', 'PICASA', 'INSTAGRAM'],
imageTypes: ['image/*'],
pick: function (serviceType) {
var _this = this;
serviceType = serviceType || 'image';
filepicker.pick(
{
container: 'window',
mimetypes: this.get(serviceType + 'Types'),
services: this.get(serviceType + 'Services')
},
function (InkBlob) {
_this.get('content').imageReceived(InkBlob);
// get image's width and height, then add to controller's content
filepicker.stat(InkBlob,
{width: true, height: true},
function (metadata) {
var pendingImage = _this.get('content');
pendingImage.sizeReceived(metadata);
pendingImage.set('ready', true);
_this.destroy();
},
function (FPError) {
// unless dialog closed by user
if (FPError.code !== 101) {
_this.get('errors').pushObject(FPError.toString());
}
_this.destroy();
}
);
},
function (FPError) {
// unless dialog closed by user
if (FPError.code !== 101) {
_this.get('errors').pushObject(FPError.toString());
}
_this.destroy();
}
);
}
});
})();