Skip to content

Commit 02554b6

Browse files
committed
Update content for v5 pre-alpha.
1 parent d668b83 commit 02554b6

File tree

6 files changed

+71
-137
lines changed

6 files changed

+71
-137
lines changed

MIGRATING.md

+12-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1-
# Migrating from PNotify 3
2-
3-
**PNotify 4** came along with some huge changes:
4-
5-
* **jQuery is no longer required.** v4 doesn't require any libraries, actually.
6-
* It's built using [Svelte](http://svelte.technology), which means it compiles down to vanilla JS.
7-
* Has an ES module build.
8-
* Options are in camelCase instead of snake_case.
9-
* `text_escape`/`title_escape` replaced by `textTrusted`/`titleTrusted`, and default behavior changed.
10-
* `insert_brs` went away. (Now uses `white-space: pre-line;`.)
11-
* Default width raised to 360px.
12-
* NonBlock module spun off into its own project, [NonBlock.js](https://github.com/sciactive/nonblockjs).
13-
* There is a Compat module available to allow you to run PNotify 3 code with PNotify 4.
14-
15-
## Running PNotify 3 Code with PNotifyCompat
16-
17-
You can use `PNotifyCompat` instead of `PNotify` in order to run PNotify 3 code. Check out `demo/compat-*.html` for more examples.
18-
19-
```js
20-
import PNotify from 'pnotify/dist/es/PNotifyCompat';
21-
22-
new PNotify({
23-
title: 'Regular Notice',
24-
text: 'Check me out! I\'m a notice.',
25-
text_escape: true // <-- old options work
26-
});
27-
```
1+
# Migrating from PNotify 4
2+
3+
**PNotify 5** has some breaking changes:
4+
5+
* It's built using [Svelte](http://svelte.technology) 3, which has a slightly different component API than Svelte 2.
6+
* Methods are no longer chainable.
7+
* The deprecated `remove()`, `removeAll()`, `cancelRemove()`, etc. methods have been removed.
8+
* The deprecated NonBlock module has been removed.
9+
* There is no longer a Compat module for running PNotify 3 code.
10+
* `notice.get()` is no longer available.
11+
* `PNotify.styling` renamed to `PNotify.styles`. (Only relevant for creating modules.)
12+
* In v5, using the factory functions is required. Using the `new` keyword will break your notice.

README.md

+14-49
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PNotify is a vanilla JavaScript notification and [confirmation/prompt](http://sc
1111

1212
<!-- TOC START min:1 max:3 link:true asterisk:false update:true -->
1313
- [Getting Started](#getting-started)
14-
- [Migrating from PNotify 3](#migrating-from-pnotify-3)
14+
- [Migrating from PNotify 4](#migrating-from-pnotify-4)
1515
- [Installation](#installation)
1616
- [Svelte](#svelte)
1717
- [React](#react)
@@ -32,7 +32,6 @@ PNotify is a vanilla JavaScript notification and [confirmation/prompt](http://sc
3232
- [Module Options](#module-options)
3333
- [Desktop Module](#desktop-module)
3434
- [Buttons Module](#buttons-module)
35-
- [NonBlock Module](#nonblock-module)
3635
- [Mobile Module](#mobile-module)
3736
- [Animate Module](#animate-module)
3837
- [Confirm Module](#confirm-module)
@@ -61,7 +60,7 @@ npm install --save material-design-icons
6160
# If you plan to use the Animate module:
6261
npm install --save animate.css
6362

64-
# If you plan to use the NonBlock module:
63+
# If you plan to use NonBlock.js for non-blocking notices:
6564
npm install --save nonblockjs
6665
```
6766

@@ -76,7 +75,7 @@ Inside the pnotify module directory:
7675
* `dist/umd` compressed UMD modules.liz
7776
* `dist/iife` compressed IIFE scripts.
7877

79-
## [Migrating from PNotify 3](MIGRATING.md)
78+
## [Migrating from PNotify 4](MIGRATING.md)
8079

8180
# Installation
8281

@@ -273,7 +272,7 @@ PNotify.defaults.icons = 'fontawesome5'; // Font Awesome 5
273272

274273
# Creating Notices
275274

276-
To make a notice, use the helper functions:
275+
To make a notice, use the factory functions:
277276

278277
```js
279278
// Manually set the type.
@@ -297,18 +296,6 @@ PNotify.error({
297296
});
298297
```
299298

300-
Or you can manually create a new notice with Svelte's component API (if you know what you're doing):
301-
302-
```js
303-
new PNotify({
304-
target: document.body,
305-
data: {
306-
text: "I'm an alert.",
307-
type: 'notice'
308-
}
309-
});
310-
```
311-
312299
# Options
313300

314301
PNotify options and default values.
@@ -438,20 +425,6 @@ PNotify.defaults.modules = {
438425

439426
`}`
440427

441-
> :information_source: In v4, it's no longer possible to show closer/sticker buttons when the notice is nonblocking.
442-
443-
## NonBlock Module
444-
445-
Requires [NonBlock.js](https://github.com/sciactive/nonblockjs) 1.0.8 or higher.
446-
447-
**It is also deprecated and unnecessary in v4.** All it does is add the 'nonblock' class to your notice. You can do the same yourself with `addClass: 'nonblock'`.
448-
449-
`NonBlock: {`
450-
* `nonblock: false`<br>
451-
Use NonBlock.js to create a non-blocking notice. It lets the user click elements underneath it.
452-
453-
`}`
454-
455428
## Mobile Module
456429

457430
`Mobile: {`
@@ -600,12 +573,8 @@ The callback options all expect the value to be a callback function. If the func
600573
Create a notice with 'error' type.
601574
* `PNotify.closeAll()`<br>
602575
Close all notices.
603-
* `PNotify.removeAll()`<br>
604-
Alias for closeAll(). (Deprecated)
605576
* `PNotify.closeStack(stack)`<br>
606577
Close all the notices in a stack.
607-
* `PNotify.removeStack(stack)`<br>
608-
Alias for closeStack(stack). (Deprecated)
609578
* `PNotify.positionAll()`<br>
610579
Reposition all notices.
611580
* `PNotify.VERSION`<br>
@@ -617,18 +586,18 @@ The callback options all expect the value to be a callback function. If the func
617586
* `PNotify.notices`<br>
618587
An array of all active notices.
619588
* `PNotify.modules`<br>
620-
This object holds all the PNotify modules.
621-
* `PNotify.styling`<br>
622-
Styling objects.
589+
This object holds all the PNotify module constructors.
590+
* `PNotify.styles`<br>
591+
Styles objects.
592+
* `PNotify.icons`<br>
593+
Icons objects.
623594

624595
# Instance Methods and Properties
625596

626597
* `notice.open()`<br>
627598
Open the notice.
628599
* `notice.close()`<br>
629600
Close the notice.
630-
* `notice.remove()`<br>
631-
Alias for close(). (Deprecated)
632601
* `notice.update(options)`<br>
633602
Update the notice with new options.
634603
* `notice.addModuleClass(...classNames)`<br>
@@ -650,19 +619,15 @@ The callback options all expect the value to be a callback function. If the func
650619

651620
## From the [Svelte Component API](https://svelte.technology/guide#component-api)
652621

653-
* `notice.get(option)`<br>
654-
Get the value of an option.
655-
* `notice.set(options)`<br>
656-
You probably want to use `update(options)` instead. It has some special PNotify secret sauce to make sure your notice doesn't break.
657-
* `notice.observe(key, callback[, options])`<br>
658-
Observe an option. See the Svelte docs for more info.
659-
* `notice.destroy()`<br>
660-
Removes the component from the DOM and any observers/event listeners. You probably want to use `close()` instead. It will animate the notice out and you can open it again. Once you destroy it, you can't open it again.
622+
* `notice.$set(options)`<br>
623+
You probably want to use `update(options)` instead. The Svelte API may change.
624+
* `notice.$destroy()`<br>
625+
Removes the component from the DOM and any observers/event listeners. You probably want to use `close()` with `destroy: true` instead. It will animate the notice out.
661626

662627
## Events
663628

664629
* `notice.on(eventName, callback)`<br>
665-
Assign a callback to an event. Callback receives an `event` argument.
630+
Assign a callback to an event. Callback receives an `event` argument with a `detail` prop.
666631
* `notice.fire(eventName, event)`<br>
667632
Fire an event.
668633

devnote.css

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
.dev-note {
22
display: block !important;
3-
position: fixed;
4-
z-index: -1;
5-
bottom: 20px;
6-
left: 20px;
7-
opacity: .4;
83
}

index.html

+43-54
Original file line numberDiff line numberDiff line change
@@ -121,36 +121,36 @@
121121
<script type="text/javascript">
122122
/* eslint-env browser, jquery */
123123
/* globals PNotify */
124-
// $(function () {
125-
// // ---
126-
// // Notice that opens when the page opens.
127-
// // ---
128-
// PNotify.notice({
129-
// title: 'PNotify',
130-
// text: "Welcome. Try hovering over me. You can click things behind me, because I'm non-blocking.",
131-
// delay: 12000,
132-
// addClass: 'nonblock',
133-
// modules: {
134-
// Callbacks: {
135-
// beforeClose: function (notice) {
136-
// // You can access the notice's options like this.
137-
// // notice.get('text');
138-
//
139-
// // You can change the notice's options like this:
140-
// // notice.update({
141-
// // title: notice.get('title') + ' - Enjoy your Stay',
142-
// // modules: {
143-
// // Callbacks: {}
144-
// // }
145-
// // });
146-
//
147-
// // notice.queueClose();
148-
// // return false;
149-
// }
150-
// }
151-
// }
152-
// });
153-
// });
124+
$(function () {
125+
// ---
126+
// Notice that opens when the page opens.
127+
// ---
128+
PNotify.notice({
129+
title: 'PNotify',
130+
text: "Welcome. Try hovering over me. You can click things behind me, because I'm non-blocking.",
131+
delay: 12000,
132+
addClass: 'nonblock',
133+
modules: {
134+
Callbacks: {
135+
beforeClose: function (notice) {
136+
// You can access the notice's options like this.
137+
// notice.get('text');
138+
139+
// You can change the notice's options like this:
140+
// notice.update({
141+
// title: notice.get('title') + ' - Enjoy your Stay',
142+
// modules: {
143+
// Callbacks: {}
144+
// }
145+
// });
146+
147+
// notice.queueClose();
148+
// return false;
149+
}
150+
}
151+
}
152+
});
153+
});
154154
</script>
155155
</head>
156156
<body id="page" data-spy="scroll" data-target=".navbar" data-offset="0" style="position: relative;">
@@ -246,8 +246,11 @@
246246
</div>
247247

248248
<section class="container page-banner">
249-
<h1>PNotify</h1>
249+
<h1>PNotify <small>v5 pre-alpha</small></h1>
250250
<p id="description">Beautiful <a href="demo/nodependencies.html" target="_blank">dependency free</a> notifications and prompts.</p>
251+
<p class="dev-note" style="display: none;">
252+
You probably want to go to the <a href="https://sciactive.com/pnotify/">production site</a>, cause nearly everything here is broken.
253+
</p>
251254
<div class="row align-items-stretch">
252255
<div class="col-md-4 my-3">
253256
<div class="card" style="height: 100%;">
@@ -280,7 +283,7 @@ <h5 class="card-header"><i class="fas fa-gift"></i> Open Source</h5>
280283
<div class="text-md-right">
281284
<a class="btn btn-primary btn-lg" href="https://github.com/sciactive/pnotify/blob/master/README.md#getting-started">Get Started with PNotify</a>
282285
</div>
283-
<div class="dev-note" style="display: none;">
286+
<div class="dev-note" style="display: none; position: fixed; z-index: -1; bottom: 20px; left: 20px; opacity: .4;">
284287
<div class="alert alert-danger">
285288
<h5 style="margin-top: 0;"><i class="fas fa-exclamation-triangle"></i> Caution warning danger attention!</h5>
286289
<p class="mb-0">This is the development site. It demos bleeding edge features that may not work.</p>
@@ -399,6 +402,14 @@ <h5 class="card-header">PNotify Core</h5>
399402
});
400403
">No Icon</button>
401404
<hr />
405+
<button class="btn btn-outline-dark my-1 source" onclick="
406+
PNotify.notice({
407+
title: 'Non-Blocking Notice',
408+
text: 'I\'m a special kind of notice called &quot;non-blocking&quot;. When you hover over me I\'ll fade to show the elements underneath. Feel free to click any of them just like I wasn\'t even here.\n\nNote: HTML links don\'t trigger in some very old browsers, due to security settings.',
409+
addClass: 'nonblock'
410+
});
411+
">Using NonBlock.js</button> <small>(Click through to things underneath the notice.)</small>
412+
<hr />
402413
<button class="btn btn-outline-dark my-1 source" onclick="
403414
PNotify.notice({
404415
title: 'See Through Notice',
@@ -993,28 +1004,6 @@ <h5 class="card-header">Buttons Module <small>Sticker and a closer buttons.</sma
9931004
">Close Permanotice</button>
9941005
</div>
9951006

996-
<h5 class="card-header">NonBlock Module (Deprecated, Replaced with <a href="https://github.com/sciactive/nonblockjs" target="_blank">NonBlock.js</a>) <small>Click through to things underneath the notice.</small></h5>
997-
<div class="card-body">
998-
<button class="btn btn-outline-dark my-1 source" onclick="
999-
PNotify.notice({
1000-
title: 'Non-Blocking Notice with Class',
1001-
text: 'You can still use the NonBlock module, but all it does is add the &quot;nonblock&quot; class for you. You can do that yourself with &quot;addClass: \'nonblock\'&quot;.',
1002-
addClass: 'nonblock'
1003-
});
1004-
">Easier Now That NonBlock.js is a Thing</button>
1005-
<button class="btn btn-outline-dark my-1 source" onclick="
1006-
PNotify.notice({
1007-
title: 'Non-Blocking Notice',
1008-
text: 'I\'m a special kind of notice called &quot;non-blocking&quot;. When you hover over me I\'ll fade to show the elements underneath. Feel free to click any of them just like I wasn\'t even here.\n\nNote: HTML links don\'t trigger in some browsers, due to security settings.',
1009-
modules: {
1010-
NonBlock: {
1011-
nonblock: true
1012-
}
1013-
}
1014-
});
1015-
">Non-Blocking (The Old Way)</button>
1016-
</div>
1017-
10181007
<h5 class="card-header">Mobile Module <small>Notices on mobile phones and tablets.</small></h5>
10191008
<div class="card-body">
10201009
<div class="alert alert-info">Since the Mobile module provides support by default, most of the demos on this page work on mobile.</div>

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pnotify",
3-
"version": "4.0.0",
3+
"version": "5.0.0-dev",
44
"description": "Beautiful dependency free notifications and prompts.",
55
"keywords": [
66
"notice",

0 commit comments

Comments
 (0)