wiselinks 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -51,7 +51,7 @@ Wiselinks works in all major browsers including browsers that do not support HTM
51
51
  <td><strong>Yes</strong></td>
52
52
  </tr>
53
53
  <tr>
54
- <td>Asset change detection</td>
54
+ <td>Assets change detection</td>
55
55
  <td>Yes, by parsing document head on every request.</td>
56
56
  <td><strong>Yes</strong>, by calculating assets MD5 hash on boot.</td>
57
57
  </tr>
@@ -70,6 +70,8 @@ Then do:
70
70
 
71
71
  bundle install
72
72
 
73
+ Restart your server and you're now using wiselinks!
74
+
73
75
  ## How does it work?
74
76
 
75
77
  Modify your `application.js.coffee` file to use Wiselinks object:
@@ -188,18 +190,24 @@ $(document).ready ->
188
190
  # start loading animation
189
191
  )
190
192
 
193
+ $(document).off('page:complete').on(
194
+ 'page:complete'
195
+ (event, xhr, settings) ->
196
+ console.log("Wiselinks page loading completed")
197
+ # stop loading animation
198
+ )
199
+
191
200
  $(document).off('page:success').on(
192
201
  'page:success'
193
202
  (event, data, status) ->
194
203
  console.log("Wiselinks status: '#{status}'")
195
- # stop loading animation
196
204
  )
197
205
 
198
206
  $(document).off('page:error').on(
199
207
  'page:error'
200
208
  (event, data, status) ->
201
209
  console.log("Wiselinks status: '#{status}'")
202
- # stop loading animation and show error message
210
+ # show error message
203
211
  )
204
212
  ```
205
213
 
@@ -245,6 +253,22 @@ Method returns `true` if current request is initiated by Wiselinks and client wa
245
253
  ### #wiselinks_partial? ###
246
254
  Method returns `true` if current request is initiated by Wiselinks and client want to render partial, `false` otherwise.
247
255
 
256
+ ## Assets change detection
257
+
258
+ You can enable assets change detection with Wiselinks. To do this you have to enable assets digests by adding this to you environment file:
259
+
260
+ ```ruby
261
+ config.assets.digest = true
262
+ ```
263
+
264
+ Then you should append your layout by adding this to head section:
265
+
266
+ ```erb
267
+ <%= wiselinks_meta_tag %>
268
+ ```
269
+
270
+ Now Wiselinks will track changes of your assets and if anything will change, your page will be reloaded completely.
271
+
248
272
  ## Title handling
249
273
 
250
274
  Wiselinks handles page titles by passing `X-Title` header with response. To do this you can use `wiselinks_title` helper.
@@ -262,7 +286,7 @@ Of course you can use `wiselinks_title` helper in your own helpers too.
262
286
 
263
287
  ##Example
264
288
 
265
- We crafted small example application that uses Wiselinks so you can see it in action.
289
+ We crafted example application that uses nearly all features of Wiselinks so you can see it in action.
266
290
 
267
291
  * GitHub Repository: [https://github.com/igor-alexandrov/wiselinks_example](https://github.com/igor-alexandrov/wiselinks_example)
268
292
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.2
@@ -0,0 +1,76 @@
1
+ /**
2
+ * History.js jQuery Adapter
3
+ * @author Benjamin Arthur Lupton <contact@balupton.com>
4
+ * @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
5
+ * @license New BSD License <http://creativecommons.org/licenses/BSD/>
6
+ */
7
+
8
+ // Closure
9
+ (function(window,undefined){
10
+ "use strict";
11
+
12
+ // Localise Globals
13
+ var
14
+ History = window.History = window.History||{},
15
+ jQuery = window.jQuery;
16
+
17
+ // Check Existence
18
+ if ( typeof History.Adapter !== 'undefined' ) {
19
+ throw new Error('History.js Adapter has already been loaded...');
20
+ }
21
+
22
+ // Add the Adapter
23
+ History.Adapter = {
24
+ /**
25
+ * History.Adapter.bind(el,event,callback)
26
+ * @param {Element|string} el
27
+ * @param {string} event - custom and standard events
28
+ * @param {function} callback
29
+ * @return {void}
30
+ */
31
+ bind: function(el,event,callback){
32
+ jQuery(el).bind(event,callback);
33
+ },
34
+
35
+ /**
36
+ * History.Adapter.trigger(el,event)
37
+ * @param {Element|string} el
38
+ * @param {string} event - custom and standard events
39
+ * @param {Object=} extra - a object of extra event data (optional)
40
+ * @return {void}
41
+ */
42
+ trigger: function(el,event,extra){
43
+ jQuery(el).trigger(event,extra);
44
+ },
45
+
46
+ /**
47
+ * History.Adapter.extractEventData(key,event,extra)
48
+ * @param {string} key - key for the event data to extract
49
+ * @param {string} event - custom and standard events
50
+ * @param {Object=} extra - a object of extra event data (optional)
51
+ * @return {mixed}
52
+ */
53
+ extractEventData: function(key,event,extra){
54
+ // jQuery Native then jQuery Custom
55
+ var result = (event && event.originalEvent && event.originalEvent[key]) || (extra && extra[key]) || undefined;
56
+
57
+ // Return
58
+ return result;
59
+ },
60
+
61
+ /**
62
+ * History.Adapter.onDomLoad(callback)
63
+ * @param {function} callback
64
+ * @return {void}
65
+ */
66
+ onDomLoad: function(callback) {
67
+ jQuery(callback);
68
+ }
69
+ };
70
+
71
+ // Try and Initialise History
72
+ if ( typeof History.init !== 'undefined' ) {
73
+ History.init();
74
+ }
75
+
76
+ })(window);