41 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2014-01-25 13:40:53 +01:00
function Toast() {
2014-01-25 10:46:46 +01:00
}
2014-01-25 16:47:02 +01:00
Toast.prototype.show = function (message, duration, position, successCallback, errorCallback) {
2014-01-25 13:40:53 +01:00
cordova.exec(successCallback, errorCallback, "Toast", "show", [message, duration, position]);
};
2014-01-25 10:46:46 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showShortTop = function (message, successCallback, errorCallback) {
this.show(message, "short", "top", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 10:46:46 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showShortCenter = function (message, successCallback, errorCallback) {
this.show(message, "short", "center", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 10:46:46 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showShortBottom = function (message, successCallback, errorCallback) {
this.show(message, "short", "bottom", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 13:22:40 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showLongTop = function (message, successCallback, errorCallback) {
this.show(message, "long", "top", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 13:22:40 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showLongCenter = function (message, successCallback, errorCallback) {
this.show(message, "long", "center", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 13:22:40 +01:00
2014-01-25 16:47:02 +01:00
Toast.prototype.showLongBottom = function (message, successCallback, errorCallback) {
this.show(message, "long", "bottom", successCallback, errorCallback);
2014-01-25 13:40:53 +01:00
};
2014-01-25 13:22:40 +01:00
2014-01-25 13:40:53 +01:00
Toast.install = function () {
if (!window.plugins) {
window.plugins = {};
}
2014-01-25 13:22:40 +01:00
2014-01-25 13:40:53 +01:00
window.plugins.toast = new Toast();
return window.plugins.toast;
};
2014-01-25 13:22:40 +01:00
2014-01-25 13:40:53 +01:00
cordova.addConstructor(Toast.install);