Add additional code documentation.
Showing
1 changed file
with
10 additions
and
2 deletions
... | @@ -3,9 +3,14 @@ | ... | @@ -3,9 +3,14 @@ |
3 | # author : Michael Richards | 3 | # author : Michael Richards |
4 | # license : MIT | 4 | # license : MIT |
5 | 5 | ||
6 | # The Rivets namespace. | ||
6 | Rivets = {} | 7 | Rivets = {} |
7 | 8 | ||
9 | # A single binding between a model attribute and a DOM element. | ||
8 | class Rivets.Binding | 10 | class Rivets.Binding |
11 | # All information about the binding is passed into the constructor; the DOM | ||
12 | # element, the type of binding, the context object and the keypath at which to | ||
13 | # listed to for changes. | ||
9 | constructor: (@el, @type, @context, @keypath) -> | 14 | constructor: (@el, @type, @context, @keypath) -> |
10 | @routine = Rivets.bindings[@type] || attributeBinding @type | 15 | @routine = Rivets.bindings[@type] || attributeBinding @type |
11 | 16 | ||
... | @@ -76,16 +81,19 @@ Rivets.bindings = | ... | @@ -76,16 +81,19 @@ Rivets.bindings = |
76 | Rivets.config = | 81 | Rivets.config = |
77 | preloadData: true | 82 | preloadData: true |
78 | 83 | ||
79 | # The rivets module exposes `register` and `bind` functions to register new | 84 | # The rivets module. This is the public interface that gets exported. |
80 | # binding routines and bind contexts to DOM elements. | ||
81 | rivets = | 85 | rivets = |
86 | # Used to set configuration options and the adapter interface. | ||
82 | configure: (options={}) -> | 87 | configure: (options={}) -> |
83 | for property, value of options | 88 | for property, value of options |
84 | Rivets.config[property] = value | 89 | Rivets.config[property] = value |
85 | 90 | ||
91 | # Registers a new binding routine function that can be used immediately in the | ||
92 | # view. This is what is used to add custom data bindings. | ||
86 | register: (routine, routineFunction) -> | 93 | register: (routine, routineFunction) -> |
87 | Rivets.bindings[routine] = routineFunction | 94 | Rivets.bindings[routine] = routineFunction |
88 | 95 | ||
96 | # Binds a set of context objects to the specified DOM element. | ||
89 | bind: (el, contexts = {}) -> | 97 | bind: (el, contexts = {}) -> |
90 | bindings = [] | 98 | bindings = [] |
91 | 99 | ... | ... |
-
Please register or sign in to post a comment