turbograft 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98e3fe31660e162654524c5def92b11c1b5b5b8d
4
- data.tar.gz: 4d8eb07bed2d1a13dcc75807d2e90c73785b6fa5
3
+ metadata.gz: fdfceb6ad8b2e34e8d9ce6d0a69349ba600b1345
4
+ data.tar.gz: 42e22d98b1307ebbd2e48ae1ce872e3bdc06a388
5
5
  SHA512:
6
- metadata.gz: 0de1bb1cba44e48c36c012e9083ea257d2588f67b9419e2f5e986e4f2878ff9fc2c23dbd8f769fe2be496f5b072a0fca6e63f98332547c599fb44d6139f338fc
7
- data.tar.gz: 84cabcbb7e4754fffaa0dc986c197262f161c6deebb473bfa39d860e1e518ae8a50660e9a4cfabc0077482210cbf209b713d92666979ff11cbdf5e4c3d07e3e7
6
+ metadata.gz: 2871b128d1379d4944ede546d25a2e563eafcfe4faab8090742b75679a88dd27710a224b092976845d3e0716e0d5a9e93a43379eb0f316ee05176dbdb3c1002c
7
+ data.tar.gz: 179aaf1e7a524cb56af76b06e002f7ae8556541589b1b9ebc32a68058931f1f46e4b2e595f112cf99e7b9a2207f88d44e9729ba13daef7ce6aaee290ea8a4d91
@@ -4,24 +4,8 @@ hasClass = (node, search) ->
4
4
  nodeIsDisabled = (node) ->
5
5
  node.getAttribute('disabled') || hasClass(node, 'disabled')
6
6
 
7
- TurboGraft.handlers.partialGraftClickHandler = (ev) ->
8
- target = ev.target
9
- partialGraft = target.getAttribute("partial-graft")
10
- return unless partialGraft?
11
- ev.preventDefault()
12
- href = target.getAttribute("href")
13
- refresh = target.getAttribute("refresh")
14
- throw new Error("TurboGraft developer error: href is not defined on node #{target}") unless href?
15
- throw new Error("TurboGraft developer error: refresh is not defined on node #{target}") unless refresh?
16
-
17
- keys = refresh.trim().split(" ")
18
-
19
- Page.refresh
20
- url: href,
21
- onlyKeys: keys
22
-
23
7
  TurboGraft.handlers.remoteMethodHandler = (ev) ->
24
- target = ev.target
8
+ target = ev.clickTarget
25
9
  httpRequestType = target.getAttribute('tg-remote')
26
10
  return unless httpRequestType
27
11
  ev.preventDefault()
@@ -66,12 +50,18 @@ documentListenerForButtons = (eventType, handler, useCapture = false) ->
66
50
  document.addEventListener eventType, (ev) ->
67
51
  target = ev.target
68
52
  return if !target
69
- isNodeDisabled = nodeIsDisabled(target)
70
- ev.preventDefault() if isNodeDisabled
71
- return if !(target.nodeName == "A" || target.nodeName == "BUTTON") || isNodeDisabled
72
- handler(ev)
73
53
 
74
- documentListenerForButtons('click', TurboGraft.handlers.partialGraftClickHandler, true)
54
+ while target != document && (typeof target != "undefined")
55
+ if target.nodeName == "A" || target.nodeName == "BUTTON"
56
+ isNodeDisabled = nodeIsDisabled(target)
57
+ ev.preventDefault() if isNodeDisabled
58
+ unless isNodeDisabled
59
+ ev.clickTarget = target
60
+ handler(ev)
61
+ return
62
+
63
+ target = target.parentNode
64
+
75
65
  documentListenerForButtons('click', TurboGraft.handlers.remoteMethodHandler, true)
76
66
 
77
67
  document.addEventListener "submit", (ev) ->
@@ -17,8 +17,7 @@ class TurboGraft.Remote
17
17
  xhr.setRequestHeader('Accept', 'text/html, application/xhtml+xml, application/xml')
18
18
  xhr.setRequestHeader("Content-Type", @contentType) if @contentType
19
19
 
20
- csrfTokenNode = document.querySelector('meta[name="X-CSRF-Token"]')
21
- csrfToken = csrfTokenNode?.getAttribute('content')
20
+ csrfToken = CSRFToken.get().token
22
21
  xhr.setRequestHeader('X-CSRF-Token', csrfToken) if csrfToken
23
22
 
24
23
  triggerEventFor('turbograft:remote:init', @initiator, {xhr: xhr, initiator: @initiator})
@@ -1,3 +1,3 @@
1
1
  module TurboGraft
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbograft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Plettenberg-Dussault
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-12-09 00:00:00.000000000 Z
16
+ date: 2014-12-10 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: coffee-rails