Skip to content

Instantly share code, notes, and snippets.

@maxkatz
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxkatz/8410f5ba72627e2aca56 to your computer and use it in GitHub Desktop.
Save maxkatz/8410f5ba72627e2aca56 to your computer and use it in GitHub Desktop.
cordova.define("nl.xservices.plugins.Toast", function(require, exports, module) {
function Toast() {}
Toast.prototype.show = function(message, duration, position, successCallback, errorCallback) {
cordova.exec(successCallback, errorCallback, "Toast", "show", [message, duration, position]);
};
Toast.prototype.showShortTop = function(message, successCallback, errorCallback) {
this.show(message, "short", "top", successCallback, errorCallback);
};
Toast.prototype.showShortCenter = function(message, successCallback, errorCallback) {
this.show(message, "short", "center", successCallback, errorCallback);
};
Toast.prototype.showShortBottom = function(message, successCallback, errorCallback) {
this.show(message, "short", "bottom", successCallback, errorCallback);
};
Toast.prototype.showLongTop = function(message, successCallback, errorCallback) {
this.show(message, "long", "top", successCallback, errorCallback);
};
Toast.prototype.showLongCenter = function(message, successCallback, errorCallback) {
this.show(message, "long", "center", successCallback, errorCallback);
};
Toast.prototype.showLongBottom = function(message, successCallback, errorCallback) {
this.show(message, "long", "bottom", successCallback, errorCallback);
};
Toast.install = function() {
if (!window.plugins) {
window.plugins = {};
}
window.plugins.toast = new Toast();
return window.plugins.toast;
};
cordova.addConstructor(Toast.install);
var toast = new Toast();
module.exports = toast;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment