twine-rails 0.0.10 → 0.0.11
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.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/assets/javascripts/twine.js.coffee +16 -0
- data/lib/twine-rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55515a506ecc1a1780a71b29f1111fc896034c04
|
|
4
|
+
data.tar.gz: 86c1632f836bcc24228b2301a95732f9846d8235
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e58ae67469d132145d679934d8c00efd2f1a299f0b53d2af1bc956e2058afa55b4f07d198d397d5e2c491d58147759fe67b4075016700146deacf7c297caf45e
|
|
7
|
+
data.tar.gz: 0236d9b19ccb73a0778f06166bfd82e1211149fc0ac2d9ab4283c1863c4a40fb0e25922a051f01cbc438c24243a853a4137af6339dbc887cfa0d872d153c8bc7
|
data/README.md
CHANGED
|
@@ -95,6 +95,26 @@ $(document).ajaxComplete ->
|
|
|
95
95
|
Twine.refresh()
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
## Twine.register
|
|
99
|
+
|
|
100
|
+
Registers a function to be called when the currently binding node and its children have finished binding.
|
|
101
|
+
|
|
102
|
+
Example:
|
|
103
|
+
|
|
104
|
+
```coffee
|
|
105
|
+
class Foo
|
|
106
|
+
constructor: ->
|
|
107
|
+
Twine.register ->
|
|
108
|
+
console.log("done")
|
|
109
|
+
|
|
110
|
+
# other methods needed in the context
|
|
111
|
+
# ...
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<div context='bar' define='{bar: new Foo}'></div>
|
|
116
|
+
```
|
|
117
|
+
|
|
98
118
|
## Contributing
|
|
99
119
|
|
|
100
120
|
1. Clone the repo: `git clone git@github.com:Shopify/twine`
|
|
@@ -15,6 +15,8 @@ keypathRegex = /^[a-z]\w*(\.[a-z]\w*|\[\d+\])*$/i # Tests if a string is a pure
|
|
|
15
15
|
refreshQueued = false
|
|
16
16
|
rootNode = null
|
|
17
17
|
|
|
18
|
+
currentBindingCallbacks = null
|
|
19
|
+
|
|
18
20
|
# Cleans up all existing bindings and sets the root node and context.
|
|
19
21
|
Twine.reset = (newContext, node = document.documentElement) ->
|
|
20
22
|
for key of elements
|
|
@@ -32,7 +34,14 @@ Twine.reset = (newContext, node = document.documentElement) ->
|
|
|
32
34
|
Twine.bind = (node = rootNode, context = Twine.context(node)) ->
|
|
33
35
|
bind(context, node, true)
|
|
34
36
|
|
|
37
|
+
Twine.register = (callback) ->
|
|
38
|
+
if currentBindingCallbacks
|
|
39
|
+
currentBindingCallbacks.push(callback)
|
|
40
|
+
else
|
|
41
|
+
callback()
|
|
42
|
+
|
|
35
43
|
bind = (context, node, forceSaveContext) ->
|
|
44
|
+
currentBindingCallbacks = []
|
|
36
45
|
if node.bindingId
|
|
37
46
|
Twine.unbind(node)
|
|
38
47
|
|
|
@@ -52,6 +61,8 @@ bind = (context, node, forceSaveContext) ->
|
|
|
52
61
|
(element ?= {}).childContext = context
|
|
53
62
|
elements[node.bindingId ?= ++nodeCount] = element
|
|
54
63
|
|
|
64
|
+
callbacks = currentBindingCallbacks
|
|
65
|
+
|
|
55
66
|
# IE and Safari don't support node.children for DocumentFragment and SVGElement nodes.
|
|
56
67
|
# If the element supports children we continue to traverse the children, otherwise
|
|
57
68
|
# we stop traversing that subtree.
|
|
@@ -59,6 +70,11 @@ bind = (context, node, forceSaveContext) ->
|
|
|
59
70
|
# As a result, Twine are unsupported within DocumentFragment and SVGElement nodes.
|
|
60
71
|
bind(context, childNode) for childNode in (node.children || [])
|
|
61
72
|
Twine.count = nodeCount
|
|
73
|
+
|
|
74
|
+
for callback in callbacks || []
|
|
75
|
+
callback()
|
|
76
|
+
currentBindingCallbacks = null
|
|
77
|
+
|
|
62
78
|
Twine
|
|
63
79
|
|
|
64
80
|
# Queues a refresh of the DOM, batching up calls for the current synchronous block.
|
data/lib/twine-rails/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twine-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Li
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: coffee-rails
|