From 31bc7c1f3e543a6a765d96662311696ab62c4ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 1 Oct 2015 10:08:24 +0200 Subject: [PATCH] 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. --- src/octoprint/static/js/app/main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index f2a7b11d..30b3d5d1 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -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