Last active
August 29, 2015 13:57
-
-
Save ds0nt/9681362 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var camOpen = function(source) { | |
var camoptions = { | |
limit: 1, | |
destinationType: Camera.DestinationType.FILE_URI, | |
targetWidth: 512, | |
targetHeight: 512, | |
sourceType: (source == 1) ? Camera.PictureSourceType.CAMERA : Camera.PictureSourceType.PHOTOLIBRARY | |
}; | |
navigator.camera.getPicture(function onSuccess(file) { | |
api.upload_head_pic(file, function onSuccess(result) { | |
var data = JSON.parse(result.response); | |
if (!data.success) { | |
app.alertError('Could not upload your photo.'); | |
return; | |
} | |
p.profile_view.imageholder.change(data.portrait_url); | |
sidemenu.updatePhoto(data.portrait_url); | |
app.data.user.portrait_url = data.portrait_url; | |
navigator.camera.cleanup(); | |
}, | |
function onError(error) { | |
app.alertError('Could not upload your photo.'); | |
console.log(error); | |
navigator.camera.cleanup(); | |
}); | |
}, | |
function onError(error) { | |
app.alertError('Could not access that file.'); | |
console.error(error); | |
}, camoptions); | |
}; | |
this.container.onTap('#edit-profile', function() { | |
app.openChild(p.profile_edit); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment