Skip to content

Commit

Permalink
Removed prototype of object that will only ever have one instance.
Browse files Browse the repository at this point in the history
No need to name the object, create a constructor function, modify it's prototype, or call new ...
  • Loading branch information
purplecabbage committed Sep 12, 2013
1 parent ec8582f commit e1b69fb
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions www/Canvas2ImagePlugin.js
Expand Up @@ -7,24 +7,21 @@
// MIT Licensed
//


function Canvas2ImagePlugin() {}

Canvas2ImagePlugin.prototype.saveImageDataToLibrary = function(successCallback, failureCallback, canvasId) {
// successCallback required
if (typeof successCallback != "function") {
console.log("Canvas2ImagePlugin Error: successCallback is not a function");
return;
module.exports = {

saveImageDataToLibrary:function(successCallback, failureCallback, canvasId) {
// successCallback required
if (typeof successCallback != "function") {
console.log("Canvas2ImagePlugin Error: successCallback is not a function");
}
else if (typeof failureCallback != "function") {
console.log("Canvas2ImagePlugin Error: failureCallback is not a function");
}
else {
var canvas = (typeof canvasId === "string") ? document.getElementById(canvasId) : canvasId;
var imageData = canvas.toDataURL().replace(/data:image\/png;base64,/,'');
return cordova.exec(successCallback, failureCallback, "Canvas2ImagePlugin","saveImageDataToLibrary",[imageData]);
}
}
if (typeof failureCallback != "function") {
console.log("Canvas2ImagePlugin Error: failureCallback is not a function");
return;
}
var canvas = (typeof canvasId === "string") ? document.getElementById(canvasId) : canvasId;
var imageData = canvas.toDataURL().replace(/data:image\/png;base64,/,'');
return cordova.exec(successCallback, failureCallback, "Canvas2ImagePlugin","saveImageDataToLibrary",[imageData]);
};

var canvas2ImagePlugin = new Canvas2ImagePlugin();
module.exports = canvas2ImagePlugin;

0 comments on commit e1b69fb

Please sign in to comment.