wiselinks 0.3.4 → 0.3.5

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
@@ -86,7 +86,18 @@ $(document).ready ->
86
86
  window.wiselinks = new Wiselinks()
87
87
  ```
88
88
 
89
- You can add some options, if you want:
89
+ You can disable HTML4 browsers support easily:
90
+
91
+ ```coffeescript
92
+ #= require jquery
93
+ #= require wiselinks
94
+
95
+ $(document).ready ->
96
+ window.wiselinks = new Wiselinks($('body'), html4: true )
97
+ ```
98
+
99
+
100
+ Or you can add some more options, if you want:
90
101
 
91
102
  ```coffeescript
92
103
  #= require jquery
@@ -221,7 +232,7 @@ The idea of Wiselinks is that you should render only content that you need in cu
221
232
 
222
233
  While using Wiselinks you **can rely** on `DOMContentLoaded` or `jQuery.ready()` to trigger your JavaScript code, but Wiselinks gives you some additional useful event to deal with the lifecycle of the page:
223
234
 
224
- #### page:loading (url, target, render = 'template')
235
+ **page:loading (url, target, render = 'template')**
225
236
 
226
237
  Event is triggered before the `XMLHttpRequest` is initialised and performed.
227
238
  * *url* - URL of the request that will be performed;
@@ -230,14 +241,14 @@ Event is triggered before the `XMLHttpRequest` is initialised and performed.
230
241
 
231
242
  * *render = 'template'* – what should be rendered; can be 'template' or 'partial';
232
243
 
233
- #### page:success (data, status) ###
244
+ **page:success (data, status)**
234
245
 
235
246
  Event is triggered if the request succeeds.
236
247
  * *data* – the data returned from the server;
237
248
 
238
249
  * *status* – a string describing the status;
239
250
 
240
- #### page:error (status, error) ###
251
+ **page:error (status, error)**
241
252
 
242
253
  Event is triggered if the request fails.
243
254
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -8,51 +8,55 @@ String.prototype.ends_with = (suffix) ->
8
8
  class Wiselinks
9
9
  constructor: (@$target = $('body'), @options = {}) ->
10
10
  # Check that JQuery is available
11
- throw "Load JQuery to use Wiselinks" unless window.jQuery?
11
+ throw "Load jQuery to use Wiselinks" unless window.jQuery?
12
12
 
13
13
  self = this
14
14
 
15
15
  @options = jQuery.extend(self._defaults(), @options);
16
16
 
17
- if History.emulated.pushState && @options.html4 == true
18
- if window.location.href.indexOf('#!') == -1 && window.location.pathname != '/'
19
- window.location.href = "#{window.location.protocol}//#{window.location.host}/#!#{window.location.pathname}"
17
+ if self.enabled()
18
+ @assets_digest = $("meta[name='assets-digest']").attr("content")
19
+
20
+ if History.emulated.pushState && @options.html4 == true
21
+ if window.location.href.indexOf('#!') == -1 && window.location.pathname != '/'
22
+ window.location.href = "#{window.location.protocol}//#{window.location.host}/#!#{window.location.pathname}"
23
+
24
+ if window.location.hash.indexOf('#!') != -1
25
+ self._call(window.location.hash.substring(2))
26
+
27
+ History.Adapter.bind(
28
+ window,
29
+ "statechange"
30
+ (event, data) ->
31
+ return false if (!History.ready)
32
+
33
+ state = History.getState()
34
+ self._call(state.url, state.data.target, state.data.render)
35
+ )
20
36
 
21
- if window.location.hash.indexOf('#!') != -1
22
- self._call(window.location.hash.substring(2))
23
-
24
- History.Adapter.bind(
25
- window,
26
- "statechange"
27
- (event, data) ->
28
- return false if (!History.ready)
29
-
30
- state = History.getState()
31
- self._call(state.url, state.data.target, state.data.render)
32
- )
37
+ $(document).on(
38
+ "submit", "form[data-push], form[data-replace]"
39
+ (event) ->
40
+ self._process_form($(this))
41
+
42
+ event.preventDefault()
43
+ return false
44
+ )
33
45
 
34
- $(document).on(
35
- "submit", "form[data-push], form[data-replace]"
36
- (event) ->
37
- self._process_form($(this))
38
-
39
- event.preventDefault()
40
- return false
41
- )
42
-
43
- $(document).on(
44
- "click", "a[data-push], a[data-replace]"
45
- (event) ->
46
- if self._cross_origin_link(event.target) || self._non_standard_click(event)
47
- return true;
48
- self._process_link($(this))
49
-
50
- event.preventDefault()
51
- return false
52
- )
53
-
54
- @assets_digest = $("meta[name='assets-digest']").attr("content")
46
+ $(document).on(
47
+ "click", "a[data-push], a[data-replace]"
48
+ (event) ->
49
+ if self._cross_origin_link(event.target) || self._non_standard_click(event)
50
+ return true;
51
+ self._process_link($(this))
52
+
53
+ event.preventDefault()
54
+ return false
55
+ )
55
56
 
57
+ enabled: ->
58
+ !History.emulated.pushState || @options.html4 == true
59
+
56
60
  load: (url, target, render = 'template') ->
57
61
  History.ready = true
58
62
  History.pushState({ timestamp: (new Date().getTime()), render: render, target: target }, document.title, url )
@@ -135,7 +139,8 @@ class Wiselinks
135
139
  self.load($link.attr("href"), $link.attr("data-target"), type)
136
140
 
137
141
  _cross_origin_link: (link) ->
138
- (location.protocol != link.protocol) || (location.host != link.host)
142
+ # we split host because IE returns host with port and other browsers not
143
+ (location.protocol != link.protocol) || (location.host.split(':')[0] != link.host.split(':')[0])
139
144
 
140
145
  _non_standard_click: (event) ->
141
146
  event.metaKey || event.ctrlKey || event.shiftKey || event.altKey
data/wiselinks.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wiselinks"
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Igor Alexandrov", "Alexey Solilin", "Julia Egorova"]
12
- s.date = "2012-12-27"
12
+ s.date = "2012-12-28"
13
13
  s.email = "igor.alexandrov@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wiselinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-12-27 00:00:00.000000000 Z
14
+ date: 2012-12-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: shoulda
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  segments:
170
170
  - 0
171
- hash: -2015874679609909460
171
+ hash: -1607414637639133094
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements: