Helper method for creating notifications with only one confirm button

PNotify always merges the default buttons and the ones provided. Just settings the default
to containing no buttons was no option since plugins might already depend on the so far
obligatory Cancel button being present. The helper allows to create one buttoned
notifications without touching the defaults.
This commit is contained in:
Gina Häußge 2015-10-01 10:08:24 +02:00
parent be79cf289e
commit 31bc7c1f3e

View file

@ -62,6 +62,22 @@ $(function() {
PNotify.prototype.options.styling = "bootstrap2";
PNotify.prototype.options.mouse_reset = false;
PNotify.singleButtonNotify = function(options) {
var autoDisplay = options.auto_display != false;
var params = $.extend(true, {}, options);
params.auto_display = false;
var notify = new PNotify(params);
notify.options.confirm.buttons = [notify.options.confirm.buttons[0]];
notify.modules.confirm.makeDialog(notify, notify.options.confirm);
if (autoDisplay) {
notify.open();
}
return notify;
};
//~~ Initialize view models
// the view model map is our basic look up table for dependencies that may be injected into other view models