├── README.md ├── heyoffline.coffee └── heyoffline.js /README.md: -------------------------------------------------------------------------------- 1 | # Heyoffline.js (actually Heyoffline.coffee) 2 | Warn your users when their network goes down. Make sure they don't lose anything. 3 | 4 | See a **[list of apps and websites using Heyoffline.js](https://github.com/oskarkrawczyk/heyoffline.js/wiki/Apps-&-websites-using-Heyoffline.js)** 5 | 6 | ## Demo 7 | See **[demo](http://oskarkrawczyk.github.com/heyoffline.js/)**. 8 | 9 | ## Setup 10 | 11 | ### CoffeeScript 12 | ```coffeescript 13 | new Heyoffline 14 | monitorFields: true 15 | elements: ['.monitoredFields'] 16 | ``` 17 | 18 | ### JavaScript 19 | ```javascript 20 | new Heyoffline({ 21 | monitorFields: true, 22 | elements: ['.monitoredFields'] 23 | }); 24 | ``` 25 | ## Options 26 | 27 |
| Name | 30 |Type | 31 |Default | 32 |Description | 33 |
|---|---|---|---|
| monitorFields | 36 |boolean | 37 |false | 38 |If this option is enabled, message on network error will be shown only if a input/textarea/select/etc on the page was modified | 39 |
| prefix | 42 |string | 43 |heyoffline | 44 |Class prefix for generated elements | 45 |
| noStyles | 48 |boolean | 49 |false | 50 |Don't use the default CSS (generated by JS) | 51 |
| disableDimiss | 54 |boolean | 55 |false | 56 |By default the user can dimiss the warning. With this option you can hide the dismiss button. | 57 |
| elements | 60 |array | 61 |['input', 'select', 'textarea', '*[contenteditable]'] |
62 | Field elements that will be monitored for changes - see monitorFields option. |
63 |
| text.title | 66 |string | 67 |You're currently offline | 68 |Heading of the modal window | 69 |
| text.content | 72 |string | 73 |Seems like you've became offline,
74 | you might want to wait until your network comes back before continuing. 75 | This message will self-destruct once you're online again. |
76 | Body message of the modal window | 77 |
| text.button | 80 |string | 81 |Relax, I know what I'm doing | 82 |Dimissal button of the modal window | 83 |
| Name | 90 |Provides | 91 |Description | 92 |
|---|---|---|
| onOnline | 95 |96 | | Fires then the network becomes available | 97 |
| onOffline | 100 |101 | | Fires when the network disappears | 102 |