Skip to content

Commit cad6343

Browse files
committed
Implements dismiss
1 parent fa74676 commit cad6343

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ See the [Notify Options](#notify-options) or the [code documentation](postette.j
155155
| `success` | response, alternative | Convenience method for "success" level notification. |
156156
| `spinner` | response, alternative | Convenience method for "persist" level notification (indefinite). |
157157
| `done` | response, alternative | Convenience method for "update" level notification (stops spinner with message). |
158+
| `dismiss` | none | Remotely ends a current notification without message (same result as click-to-close or click-away). |
158159
| `setCustomLevel` | name | Adds a level of notification message ([CSS overrides](#advanced-usage) will be required for styling). |
159160
| `setComputeFactor` | value | Sets a per-character multiplier for computing pause-enough for a message to be read. The default is `100` (milliseconds). |
160161
| `setClickAway` | boolean | When true, `globalClickHandler();` will quit messages and close the log upon firing. |

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postette-example",
3-
"version": "0.1.0",
3+
"version": "0.3.0",
44
"description": "Sample implementation demonstrating Postette for the management and execution of notifications to a person interacting with a web client application.",
55
"main": "postette.html",
66
"repository": "https://github.com/ptrdo/postette.git",

example/postette.html

+22-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="revised" content="2019/01/07">
6+
<meta name="revised" content="2019/06/18">
77
<title>Postette: Example</title>
88
<style>
99
@import url(//fonts.googleapis.com/css?family=Roboto:400,700);
@@ -107,6 +107,21 @@
107107
background: darkorange;
108108
color: white;
109109
}
110+
form[action=demo] input[type=reset]:active,
111+
form[action=demo] input[type=submit]:active {
112+
background: saddlebrown;
113+
color: silver;
114+
}
115+
form[action=demo] input[type=button] {
116+
cursor: pointer;
117+
background: lightgoldenrodyellow;
118+
color: darkorange;
119+
}
120+
form[action=demo] input[type=button]:active {
121+
cursor: pointer;
122+
background: goldenrod;
123+
color: whitesmoke;
124+
}
110125
form[action=demo] input[type=checkbox] {
111126
display: inline;
112127
width: auto;
@@ -180,6 +195,7 @@
180195
<label><input type="checkbox" name="persist"/>Infinity (spinner)</label>
181196
<hr/>
182197
<input type="submit" value="Notify!" title="Send a Message" tabindex="0">
198+
<input type="button" value="Dismiss" title="End a Message" tabindex="0">
183199
<input type="reset" value="Reset" title="Reset This Form" tabindex="0">
184200
</fieldset>
185201
</form>
@@ -266,6 +282,11 @@
266282
Postette.log();
267283
});
268284
$("form[action=demo]").on("submit", notify);
285+
$("form input[value=Dismiss]").on("click", function(event){
286+
event.preventDefault();
287+
event.stopPropagation();
288+
Postette.dismiss();
289+
});
269290

270291
$("form").on("click", function(event) {
271292
event.stopPropagation();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postette",
3-
"version": "v0.2.0",
3+
"version": "v0.3.0",
44
"description": "A zero-dependency gadget for the management and execution of notifications to a person interacting with a web client application.",
55
"homepage": "https://github.com/ptrdo/postette#readme",
66
"main": "",

postette.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
* @property {Element} clickerElement // the currently rendered BUTTON (to dismiss).
7676
*/
7777

78-
var version = "0.2.0",
78+
var version = "0.3.0",
7979
identity = "postette",
8080
markupId = identity + Date.now(),
8181
queue = [],
@@ -396,6 +396,7 @@
396396
clearClassList(element, STATE.active);
397397

398398
timerDone = setTimeout(function () {
399+
clearClassList(element, STATE);
399400
try {
400401
if (queue.length > 0) {
401402
execute(queue.pop());
@@ -1409,6 +1410,14 @@
14091410
toaster(response, alternative, STATE.persist);
14101411
},
14111412

1413+
/**
1414+
* dismiss remotely triggers the click event, essentially dismissing the current message.
1415+
* any queued messages will display as would be expected.
1416+
*
1417+
* @public
1418+
*/
1419+
dismiss: clickHandler,
1420+
14121421
/**
14131422
* update (or done) is a convenience method to create a toast of state:update.
14141423
* defaults will be applied for all customizable options. No callback allowed.

0 commit comments

Comments
 (0)