I'm developing a cordova based mobile application using Backbone and Requirejs. I need to create a wrapper over the cordova's camera plugin. In my project I need a single camera instance so instead of returning a function I'm returning an object from the module as shown below.
define(['underscore', 'deferred'], function (_, Deferred) {
'use strict';
var defaultQuality = 50,
isEditAllowed = false,
saveToAlbum = false;
return {
getPicture: function (options) {
var deferred = Deferred(),
cameraOptions = _.extend({
quality: defaultQuality
}, options);
navigator.camera.getPicture(deferred.success, deferred.fail, cameraOptions);
return deferred.promise();
},
capturePicture: function (success, fail, allowEdit, saveToPhotoAlbum) {
return this.getPicture(success, fail, {
allowEdit: allowEdit || isEditAllowed,
saveToPhotoAlbum: saveToPhotoAlbum || saveToAlbum
});
},
getPictureFromAlbum: function (success, fail) {
return this.getPicture(success, fail, {
sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM
});
},
getPictureFromLibrary: function (success, fail) {
return this.getPicture(success, fail, {
sourceType: Camera.PictureSourceType.PHOTOLIBRARY
});
}
};
});
The above camera module has to be used in a backbone view.
define(['backbone', 'camera'], function(Backbone, ?) {
//...
});
As per the naming standards in Javascript, do I need to use camelCase (camera
) or PascalCase (Camera
) naming convention in the function parameter.