-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCloudImage.js
More file actions
74 lines (63 loc) · 1.8 KB
/
CloudImage.js
File metadata and controls
74 lines (63 loc) · 1.8 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
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
/**
* Dependencies
*/
var ACS = require('ti.cloud');
/**
* CloudImage Definition
*/
var CloudImage = function(_args) {
_args = _args || {};
var API = Ti.UI.createImageView({
height: _args.height || Ti.UI.SIZE,
width: _args.width || Ti.UI.SIZE,
});
API.PHOTO_SIZE = {
THUMB : 'thumb_100',
SQUARE : 'square_75',
SMALL : 'small_240',
MEDIUM500: 'medium_500',
MEDIUM640: 'medium_640',
LARGE : 'large_1024',
ORIGINAL: 'original'
};
API.defaultSize = _args.size || API.PHOTO_SIZE.SQUARE;
API.defaultIcon = _args.defaultIcon || null;
/**
* updateImage
* Downloads the urls associated with the image, and assigns the correct url to the image parameter
* of the UIIMageView based on the size requirement
*
* @param _id : ACS ID of Photo
* @param _size : One of the designated PHOTO_SIZE options for the Photo (optional)
*/
API.updateImage = function(_id, _size){
//Default to class default size if no size param is specified
_size = _size || API.defaultSize;
ACS.Photos.show({photo_id: _id}, function(e){
if(e.success && e.photos.length) {
API.urls = e.photos[0].urls;
Ti.API.info(API.urls[_size]);
API.image = API.urls[_size];
}
else {
}
});
};
/**
* updateImageSize
* Updates the image with a particular size by setting the image param of the UIImageView
* to the corresponding url
*
* @param _size : One of the designated PHOTO_SIZE options for the Photo (optional)
*/
API.updateImageSize = function(_size) {
//Default to class default size if no size param is specified
_size = _size || API.defaultSize;
if(API.urls) {
API.image = API.urls[_size];
}
};
API.updateImage(_args.id)
return API;
}; /* end CloudImage */
module.exports = CloudImage;