You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-36Lines changed: 53 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,31 @@ PNotify is a JavaScript notification plugin. PNotify can provide [desktop notifi
11
11
12
12
Unless you're an alpha tester, **none of this README applies to you!** You want to check out the **[README on the master branch](https://github.com/sciactive/pnotify/blob/master/README.md)**.
13
13
14
-
This README is for **PNotify v4**. v4 is only in alpha stage, but it's got some huge changes:
14
+
This README is for **PNotify 4**. v4 is only in alpha stage, but it's got some huge changes:
15
15
16
16
* jQuery is no longer required. v4 doesn't require any libraries, actually.
17
17
* It's built using [Svelte](http://svelte.technology), which means it compiles down to vanilla JS.
18
18
* PNotify now has an ES6 module build.
19
-
*`text_escape` and `title_escape` have been replaced by `trust_text` and `trust_title`, and the default behavior changed.
19
+
* All options are now in camelCase instead of snake_case.
20
+
*`text_escape` and `title_escape` have been replaced by `textTrusted` and `titleTrusted`, and the default behavior changed.
20
21
*`insert_brs` option has gone away. (Text and title now have `white-space: pre-line;`.)
21
22
* The default width was raised from 300px to 360px.
23
+
* There is a Compat module available to allow you to run PNotify 3 code with PNotify 4.
24
+
25
+
## Running PNotify 3 Code with the Compat Module
26
+
27
+
You can require `PNotifyCompat` instead of `PNotify` in order to run PNotify 3 code. Check out `index-compat.html` for more examples.
Or you can manually create a new notice (but, why would you?):
127
+
Or you can manually create a new notice:
111
128
112
129
```js
113
130
newPNotify({
@@ -122,24 +139,24 @@ new PNotify({
122
139
# Options
123
140
124
141
*`title: false` - The notice's title.
125
-
*`trust_title: false` - Whether to trust the title or escape its contents. (Not allow HTML.)
142
+
*`titleTrusted: false` - Whether to trust the title or escape its contents. (Not allow HTML.)
126
143
*`text: false` - The notice's text.
127
-
*`trust_text: false` - Whether to trust the text or escape its contents. (Not allow HTML.)
144
+
*`textTrusted: false` - Whether to trust the text or escape its contents. (Not allow HTML.)
128
145
*`styling: "brighttheme"` - What styling classes to use. (Can be "brighttheme", "bootstrap3", "bootstrap4", or a styling object. See the source in PNotifyStyleMaterial.html for the properties in a style object.)
129
146
*`icons: "brighttheme"` - What icons classes to use (Can be "brighttheme", "bootstrap3", "fontawesome4", "fontawesome5", or an icon object. See the source in PNotifyStyleMaterial.html for the properties in an icon object.)
130
-
*`addclass: ""` - Additional classes to be added to the notice. (For custom styling.)
131
-
*`cornerclass: ""` - Class to be added to the notice for corner styling.
132
-
*`auto_display: true` - Display the notice when it is created. Turn this off to add notifications to the history without displaying them.
147
+
*`addClass: ""` - Additional classes to be added to the notice. (For custom styling.)
148
+
*`cornerClass: ""` - Class to be added to the notice for corner styling.
149
+
*`autoDisplay: true` - Display the notice when it is created. Turn this off to add notifications to the history without displaying them.
133
150
*`width: "360px"` - Width of the notice.
134
-
*`min_height: "16px"` - Minimum height of the notice. It will expand to fit content.
151
+
*`minHeight: "16px"` - Minimum height of the notice. It will expand to fit content.
135
152
*`type: "notice"` - Type of the notice. "notice", "info", "success", or "error".
136
153
*`icon: true` - Set icon to true to use the default icon for the selected style/type, false for no icon, or a string for your own icon class.
137
154
*`animation: "fade"` - The animation to use when displaying and hiding the notice. "none" and "fade" are supported through CSS. Others are supported through the Animate module and Animate.css.
138
-
*`animate_speed: "normal"` - Speed at which the notice animates in and out. "slow", "normal", or "fast". Respectively, 400ms, 250ms, 100ms.
155
+
*`animateSpeed: "normal"` - Speed at which the notice animates in and out. "slow", "normal", or "fast". Respectively, 400ms, 250ms, 100ms.
139
156
*`shadow: true` - Display a drop shadow.
140
157
*`hide: true` - After a delay, close the notice.
141
158
*`delay: 8000` - Delay in milliseconds before the notice is closed.
142
-
*`mouse_reset: true` - Reset the hide timer if the mouse moves over the notice.
159
+
*`mouseReset: true` - Reset the hide timer if the mouse moves over the notice.
143
160
*`remove: true` - Remove the notice's elements from the DOM after it is closed.
144
161
*`destroy: true` - Whether to remove the notice from the global array when it is closed.
145
162
*`stack: PNotify.defaultStack` - The stack on which the notices will be placed. Also controls the direction the notices stack.
@@ -170,12 +187,12 @@ Changing a default option for modules can be done in a couple ways.
170
187
171
188
```js
172
189
// This will change the default for every notice and is the recommended way.
173
-
PNotify.modules.History.defaults.max_in_stack=10;
190
+
PNotify.modules.History.defaults.maxInStack=10;
174
191
175
192
// This will change the default only for notices that don't specify any module options.
*`closer: true` - Provide a button for the user to manually close the notice.
200
-
*`closer_hover: true` - Only show the closer button on hover.
217
+
*`closerHover: true` - Only show the closer button on hover.
201
218
*`sticker: true` - Provide a button for the user to manually stick the notice.
202
-
*`sticker_hover: true` - Only show the sticker button on hover.
203
-
*`show_on_nonblock: false` - Show the buttons even when the nonblock module is in use.
219
+
*`stickerHover: true` - Only show the sticker button on hover.
220
+
*`showOnNonblock: false` - Show the buttons even when the nonblock module is in use.
204
221
*`labels: {close: "Close", stick: "Stick", unstick: "Unstick"}` - Lets you change the displayed text, facilitating internationalization.
205
-
*`classes: {closer: null, pin_up: null, pin_down: null}` - The classes to use for button icons. Leave them null to use the classes from the styling you're using.
222
+
*`classes: {closer: null, pinUp: null, pinDown: null}` - The classes to use for button icons. Leave them null to use the classes from the styling you're using.
206
223
207
224
`}`
208
225
@@ -216,7 +233,7 @@ PNotify.defaults.modules = {
216
233
## Mobile Module
217
234
218
235
`Mobile: {`
219
-
*`swipe_dismiss: true` - Let the user swipe the notice away.
236
+
*`swipeDismiss: true` - Let the user swipe the notice away.
220
237
*`styling: true` - Styles the notice to look good on mobile.
221
238
222
239
`}`
@@ -227,8 +244,8 @@ The Animate module requires you to include [Animate.css](https://daneden.github.
227
244
228
245
`Animate: {`
229
246
*`animate: false` - Use animate.css to animate the notice.
230
-
*`in_class: ""` - The class to use to animate the notice in.
231
-
*`out_class: ""` - The class to use to animate the notice out.
247
+
*`inClass: ""` - The class to use to animate the notice in.
248
+
*`outClass: ""` - The class to use to animate the notice out.
232
249
233
250
`}`
234
251
@@ -239,16 +256,16 @@ The Animate module also creates a method, `attention`, on notices which accepts
239
256
`Confirm: {`
240
257
*`confirm: false` - Make a confirmation box.
241
258
*`prompt: false` - Make a prompt.
242
-
*`prompt_class: ""` - Classes to add to the input element of the prompt.
243
-
*`prompt_value: ""` - The value of the prompt. (Note that this is two-way bound to the input.)
244
-
*`prompt_multi_line: false` - Whether the prompt should accept multiple lines of text.
259
+
*`promptClass: ""` - Classes to add to the input element of the prompt.
260
+
*`promptValue: ""` - The value of the prompt. (Note that this is two-way bound to the input.)
261
+
*`promptMultiLine: false` - Whether the prompt should accept multiple lines of text.
245
262
*`align: "right"` - Where to align the buttons. (right, center, left, justify)
246
263
247
264
```js
248
265
buttons: [
249
266
{
250
267
text:"Ok",
251
-
trustText:false,
268
+
textTrusted:false,
252
269
addClass:"",
253
270
primary:true,
254
271
promptTrigger:true,
@@ -259,7 +276,7 @@ buttons: [
259
276
},
260
277
{
261
278
text:"Cancel",
262
-
trustText:false,
279
+
textTrusted:false,
263
280
addClass:"",
264
281
click: (notice) => {
265
282
notice.close();
@@ -293,7 +310,7 @@ PNotify.alert({
293
310
294
311
`History: {`
295
312
*`history: true` - Place the notice in the history.
296
-
*`max_in_stack: Infinity` - Maximum number of notices to have open in its stack.
313
+
*`maxInStack: Infinity` - Maximum number of notices to have open in its stack.
297
314
298
315
`}`
299
316
@@ -306,15 +323,15 @@ In PNotify v3, the history module could make a dropdown which had these function
306
323
307
324
## Callbacks Module
308
325
309
-
The callback options all expect one argument, a function, which will be called when that event occurs. If the function returns false on the "before_open" or "before_close" callback, that event will be canceled.
326
+
The callback options all expect one argument, a function, which will be called when that event occurs. If the function returns false on the "beforeOpen" or "beforeClose" callback, that event will be canceled. `beforeInit` and `afterInit` will only work for notices created with the helper functions.
310
327
311
328
`Callbacks: {`
312
-
*`before_init` - This option is called before the notice has been initialized. It accepts one argument, the options object.
313
-
*`after_init` - This option is called after the notice has been initialized. It accepts one argument, the notice object.
314
-
*`before_open` - This option is called before the notice has been displayed. It accepts one argument, the notice object.
315
-
*`after_open` - This option is called after the notice has been displayed. It accepts one argument, the notice object.
316
-
*`before_close` - This option is called before the notice closes. It accepts one argument, the notice object.
317
-
*`after_close` - This option is called after the notice closes. It accepts one argument, the notice object.
329
+
*`beforeInit` - This option is called before the notice has been initialized. It accepts one argument, the options object.
330
+
*`afterInit` - This option is called after the notice has been initialized. It accepts one argument, the notice object.
331
+
*`beforeOpen` - This option is called before the notice has been displayed. It accepts one argument, the notice object.
332
+
*`afterOpen` - This option is called after the notice has been displayed. It accepts one argument, the notice object.
333
+
*`beforeClose` - This option is called before the notice closes. It accepts one argument, the notice object.
334
+
*`afterClose` - This option is called after the notice closes. It accepts one argument, the notice object.
318
335
319
336
`}`
320
337
@@ -390,7 +407,7 @@ A stack is an object which PNotify uses to determine where to position notices.
390
407
391
408
You can set a stack as modal by setting the `modal` property to true. A modal stack creates an overlay behind it when any of its notices are open. When the last notice within it is closed, the overlay is removed.
392
409
393
-
If the `overlay_close` property is set to true, then clicking the overlay will close all of the notices in that stack.
410
+
If the `overlayClose` property is set to true, then clicking the overlay will close all of the notices in that stack.
394
411
395
412
## Example Stacks
396
413
@@ -420,7 +437,7 @@ const stack_modal = {
420
437
"firstpos1":25,
421
438
"push":"top",
422
439
"modal":true,
423
-
"overlay_close":true
440
+
"overlayClose":true
424
441
};
425
442
conststack_bar_top= {
426
443
"dir1":"down",
@@ -470,7 +487,7 @@ This will create a notice that is positioned 90px from the top edge and 90px fro
470
487
* Notification types: notice, info, success, and error.
471
488
* Stacks allow notices to position together or independently.
472
489
* Control stack direction and push to top or bottom.
473
-
*Full RTL language support.
490
+
* RTL language support.
474
491
* Feature rich API.
475
492
* Desktop notifications based on the Web Notifications standard.
0 commit comments