Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 113 lines (102 sloc) 3.043 kb
20a935e @oskarkrawczyk The is more accurate
authored
1 # Heyoffline.js (actually Heyoffline.coffee)
afce4ef @akatz Update README.md
akatz authored
2 Warn your users when their network goes down. Make sure they don't lose anything.
8e569d9 @oskarkrawczyk Added Readme
authored
3
0401f28 @oskarkrawczyk Updated README
authored
4 ## Demo
5 See **[demo](http://oskarkrawczyk.github.com/heyoffline.js/)**.
6
7 ## Setup
8
e23b76b @oskarkrawczyk Bower instructions
authored
9 You can install Heyoffline via Bower with `bower install Heyoffline` or download `heyoffline.js` and include it the old-fashined way.
10
0401f28 @oskarkrawczyk Updated README
authored
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 <table>
28 <tr>
29 <th class="name">Name</th>
30 <th class="type">Type</th>
31 <th class="default">Default</th>
32 <th class="desc">Description</th>
33 </tr>
34 <tr>
35 <td>monitorFields</td>
36 <td>boolean</td>
37 <td>false</td>
38 <td class="desc">If this option is enabled, message on network error will be shown only if a input/textarea/select/etc on the page was modified</td>
39 </tr>
40 <tr>
41 <td>prefix</td>
42 <td>string</td>
43 <td>heyoffline</td>
44 <td class="desc">Class prefix for generated elements</td>
45 </tr>
46 <tr>
47 <td>noStyles</td>
48 <td>boolean</td>
49 <td>false</td>
50 <td class="desc">Don't use the default CSS (generated by JS)</td>
51 </tr>
52 <tr>
53 <td>disableDimiss</td>
54 <td>boolean</td>
55 <td>false</td>
56 <td class="desc">By default the user can dimiss the warning. With this option you can hide the dismiss button.</td>
57 </tr>
58 <tr>
59 <td>elements</td>
60 <td>array</td>
61 <td><code>['input', 'select', 'textarea', '*[contenteditable]']</code></td>
62 <td class="desc">Field elements that will be monitored for changes - see <code>monitorFields</code> option.</td>
63 </tr>
64 <tr>
65 <td>text.title</td>
66 <td>string</td>
67 <td>You're currently offline</td>
68 <td class="desc">Heading of the modal window</td>
69 </tr>
70 <tr>
71 <td>text.content</td>
72 <td>string</td>
73 <td>Seems like you've became offline,
74 you might want to wait until your network comes back before continuing.<br /><br />
75 This message will self-destruct once you're online again.</td>
76 <td class="desc">Body message of the modal window</td>
77 </tr>
78 <tr>
79 <td>text.button</td>
80 <td>string</td>
81 <td>Relax, I know what I'm doing</td>
82 <td class="desc">Dimissal button of the modal window</td>
83 </tr>
84 </table>
85
86 ## Events
87 <table>
88 <tr>
89 <th class="name">Name</th>
90 <th class="type">Provides</th>
91 <th class="desc">Description</th>
92 </tr>
93 <tr>
94 <td>onOnline</td>
95 <td></td>
96 <td>Fires then the network becomes available</td>
97 </tr>
98 <tr>
99 <td>onOffline</td>
100 <td></td>
101 <td>Fires when the network disappears</td>
102 </tr>
103 </table>
104
105 ## Requirements
106 Heyoffline.js is **framework-agnostic**. No need for jQuery. It's written in **CoffeeScript**, and compiled into JavaScript.
107
108 ## Source code
109 All efforts have been made to keep the source as clean and readable as possible.
110
111 ## Requirements
112 Heyoffline.js is released under an MIT License, so do with it what you will.
Something went wrong with that request. Please try again.