-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
560 lines (427 loc) · 49.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
<style>body{
font-family: Arial;
background: #ddd;
padding:20px;
margin-left: 300px;
}
.menu{
position:fixed;
top:0;
left:0;
bottom:0;
overflow-y: scroll;
width: 300px;
padding:5px;
background: white;
}
.menu a{
display: block;
padding:5px;
color: #333;
text-decoration: none;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
border-left: solid 1px #999;
padding-left: 10px;
margin-left: 5px;
}
.menu div{
padding-left:10px;
position: relative;
}
.menu a + div:before{
content:"";
position: absolute;
left: 5px;
top: 0;
border: solid 5px #999;
border-bottom-color: transparent;
border-left-color: transparent;
}
.menu a + div:after{
content:"";
position: absolute;
left: 6px;
top: 0;
border: solid 5px white;
border-bottom-color: transparent;
border-left-color: transparent;
}
pre{
margin:10px;
border:solid 1px #ccc;
padding: 20px;
background: white;
box-shadow: 5px 5px 20px rgba(0,0,0,0.3);
margin-bottom:30px;
}
code{
padding: 5px;
display: block;
line-height: 12px;
overflow: auto;
}
h1{
font-size: 36px;
padding:0 20px;
}
h2{
color: #555;
margin-top:30px 0;
border-bottom: solid 3px #ccc;
}
h3, h4{
color: #888;
margin:10px;
padding:5px 10px;
}
p{
margin:10px 0;
padding:0 10px;
}
section{
margin-left: 20px;
}
.docyacode-block{
margin: 20px 0;
padding: 10px 20px;
background-color: rgba(255,255,255,0.3);
}</style><script>// window.addEventListener('load', function(){
// var docSections = document.querySelectorAll('[data-blockname]'),
// menu = document.createElement('div');
// menu.className = 'menu';
// for(var i = 0; i < docSections.length; i++) {
// var section = docSections[i],
// sectionAnchor = document.createElement('a'),
// sectionName = section.getAttribute('data-blockname');
// section.insertBefore(sectionAnchor, section.firstChild);
// var menuItem = document.createElement('a');
// menuItem.innerText = sectionName;
// menuItem.setAttribute('href', '#' + sectionName);
// sectionAnchor.setAttribute('name', sectionName);
// sectionAnchor.className = 'sectionAnchor';
// menu.appendChild(menuItem);
// }
// document.body.insertBefore(menu, document.body.firstChild);
// });</script><div class="menu"><a href="#gaffa.js">gaffa.js</a><div><a href="#ViewItem">ViewItem</a><div><a href="#.actions">.actions</a><a href="#.path">.path</a></div><a href="#View">View</a><a href="#ContainerView">ContainerView</a><a href="#The gaffa instance">The gaffa instance</a><div><a href="#.addDefaultStyle">.addDefaultStyle</a><a href="#.createSpec">.createSpec</a><a href="#.jsonConverter">.jsonConverter</a><a href="#.initialiseViewItem">.initialiseViewItem</a><a href="#.events">.events</a><div><a href="#.on">.on</a></div><a href="#.model">.model</a><div><a href="#.get(path, viewItem, scope, asTokens)">.get(path, viewItem, scope, asTokens)</a><a href="#.set(path, value, viewItem, dirty)">.set(path, value, viewItem, dirty)</a><a href="#.remove(path, viewItem, dirty)">.remove(path, viewItem, dirty)</a><a href="#.bind(path, callback, viewItem)">.bind(path, callback, viewItem)</a><a href="#.debind(viewItem)">.debind(viewItem)</a><a href="#.isDirty(path, viewItem)">.isDirty(path, viewItem)</a><a href="#.setDirtyState(path, value, viewItem)">.setDirtyState(path, value, viewItem)</a></div><a href="#.views">.views</a><div><a href="#.renderTarget">.renderTarget</a><a href="#.add(View/viewModel, insertIndex)">.add(View/viewModel, insertIndex)</a><a href="#.remove(view/views)">.remove(view/views)</a><a href="#.empty()">.empty()</a><a href="#.constructors">.constructors</a></div><a href="#.namedViews">.namedViews</a><a href="#.actions">.actions</a><div><a href="#.trigger(actions, parent, scope, event)">.trigger(actions, parent, scope, event)</a><a href="#.constructors">.constructors</a></div><a href="#.behaviours">.behaviours</a><div><a href="#.add(behaviour)">.add(behaviour)</a><a href="#.constructors">.constructors</a></div><a href="#Navigate">Navigate</a></div></div><a href="#License">License</a></div><div class="docyacode-block" data-blockname="gaffa.js"><a name="gaffa.js"></a><h1>gaffa.js</h1>
<p><img src="logosmall.png" alt="logo"></p>
<h2>Example</h2>
<p><a href="http://korynunn.github.io/gaffa-todo/">Gaffa-ToDo</a></p>
<h2>Quick n easy setup</h2>
<pre><code>npm install gaffa-boilerplate</code></pre>
<p>Then make a folder for your test project.</p>
<pre><code>gaffa-boilerplate</code></pre>
<p>This will copy some boilerplate files and start a file watcher that browserifys app.js, in the scripts folder.</p>
<h2>Overview</h2>
<p>Gaffa attempts to speed up the development of complicated UI's by providing a rich binding layer between arbitrary data and your UI.</p>
<p>Writing UI's using gaffa is unlike most other MVC/MVVM/etc frameworks for a number of different reasons. (Although, others share some of the below points)</p>
<ul>
<li><p>ASAP databinding - model change events are instantaneous</p>
</li>
<li><p>Extremely powerful model bindings - use complex expressions to bind to data</p>
</li>
<li><p>UI by transform - Use transforms over data to affect how data is displated, rather than modifying the data to suite the UI.</p>
</li>
<li><p>NO HTML! - Javascript to DOM, no pointless middleman.</p>
</li>
<li><p>Serialise to JSON - An entire application can be serialised to JSON, by design.</p>
</li>
<li><p>No lock-in - Push your views to the edge of Gaffa's capabilities, and break out whenever you need.</p>
</li>
</ul>
<h3>Dependencies</h3>
<p>Gaffa must be compiled with browserify <a href="https://github.com/substack/node-browserify">browserify</a></p>
<h3>Minimal usage</h3>
<pre><code>var Gaffa = require('gaffa'),
gaffa = new Gaffa();</code></pre>
<h3>The Bits..</h3>
<p>A Gaffa application consists of 2 high-level bits:</p>
<ul>
<li><p>Many ViewItems</p>
</li>
<li><p>One model</p>
</li>
</ul>
<h3>ViewItems</h3>
<p>ViewItems can be <strong>Views</strong>, <strong>Actions</strong>, or <strong>Behaviours</strong>.</p>
<p>ViewItems represent and can affect the model, they are combined to create a UI.</p>
<p>a View is a ViewItem that has a renderedElement, be it some DOM, or any other abstract UI element, such as a google maps pin object.</p>
<p>To use a view, you must first load the constructor for that view. For example, to use a label, and a textbox, the label.js and textbox.js files must be required(). Every viewItem must be added to its appropriate constructors object in gaffa, eg:</p>
<pre><code>// Add viewItem constructors to gaffa. Only use what you need.
// Views
gaffa.views.constructors = {
label: require('gaffa/views/label'),
textbox: require('gaffa/views/textbox'),
button: require('gaffa/views/button')
};
// Actions
gaffa.actions.constructors = {
remove: require('gaffa/actions/remove')
};
// Behaviours
gaffa.actions.constructors = {
pageLoad: require('gaffa/behaviours/pageLoad')
};</code></pre>
<p>For ease of development, the constructors are usually assigned to a variable:</p>
<pre><code>// Cache the view constructors object to easy access later.
var views = gaffa.views.constructors;</code></pre>
<p>viewItems can then be instantiated:</p>
<pre><code>// New up a label
var nameLabel = new views.label(),
firstNameBox = new views.textbox(),
surnameBox = new views.textbox(),
removeUserButton = new views.button();</code></pre>
<p>an Action is a non-visual entity which performs some action when executed. For example, an action could be assigned to be triggered when a button is clicked, and it could set a value into the model, or remove an item from an array.</p>
<pre><code>var removeUser = new actions.remove();</code></pre>
<p>To assign actions to a view:</p>
<pre><code>removeUserButton.actions.click = [removeUser];</code></pre>
<p>Gaffa will automatically use the actions.<em>whatever</em> propertyName as a DOM event name, and trigger any actions assigned when that event occurs.</p>
<p>a Behaviour is a non-visual entity that triggers actions. For example, a modelChange behaviour could be created to watch a property in the model, and assigned actions to perform when the value of that property changes.</p>
<h3>The Model</h3>
<p>The Model is just a Javascript object. If you can serialize it to JSON, and it inherrits from Object, it is a valid gaffa model, and it can be bound to. Unlike most similar frameworks, Gaffa focuses on keeping the model pure. If you add an object to the model, that exact object is used throughout the whole lifecycle, with no extra attributes like "Observable" etc. It's just a plain old object.</p>
<p>These are valid models:</p>
<pre><code>{};
new Date();
[];</code></pre>
<p>However usually a model would look something like this:</p>
<pre><code>var model = {
users:[
{
firstName: "John",
surname: "Smith",
age: 30,
lastVisit: (a date object)
}
]
};</code></pre>
<p>This can be set as the applications model by:</p>
<pre><code>gaffa.model.set(model);</code></pre>
<p>You can also set parts of the model using paths.</p>
<pre><code>gaffa.model.set('[users/0/firstName]', 'Bob');</code></pre>
<p>This will cause properties bound to this value to update.</p>
<p>You would very rarely use this syntax to affect the model, but rather use bound viewItem properties to change model data. This method of affecting the model is mostly used for debugging.</p>
<p>You can bind ViewItems properties to parts of the model using paths, eg:</p>
<pre><code>// Bind the firstName box to the users first name in the model
firstNameBox.value.binding = '[user/firstName]';
// Bind the surname box to the users surname in the model
surnameBox.value.binding = '[user/surname]';
// Bind the nameLabel to an expression that joins both names together.
nameLabel.text.binding = '(join " " [user/firstName] [user/surname])';</code></pre>
<p>Once you have set up your viewItems, you can add them to the application.</p>
<p>Calling gaffa.views.add(viewItem) on a viewItem binds and renders the view. No properties will be bound to the model untill this has occured.</p>
<pre><code>// Add the views to gaffa
gaffa.views.add([
nameLabel,
firstNameBox,
surnameBox
]);</code></pre>
<h3>Expressions</h3>
<p>Gaffa uses Gedi as its model, and as such, uses Gedi's expressions.</p>
<p>Expressions in gaffa are used to address the model in some way.</p>
<p>For a more in-depth explanation of expressions, checkout the gedi readme: <a href="https://github.com/gaffa-tape/gedi">Gedi</a></p>
<section><div class="docyacode-block" data-blockname="ViewItem"><a name="ViewItem"></a><h2>ViewItem</h2>
<p>The base constructor for all gaffa ViewItems.</p>
<p>Views, Behaviours, and Actions inherrit from ViewItem.</p>
<section><div class="docyacode-block" data-blockname=".actions"><a name=".actions"></a><h2>.actions</h2>
<p>All ViewItems have an actions object which can be overriden.</p>
<p>The actions object looks like this:</p>
<pre><code>viewItem.actions = {
click: [action1, action2],
hover: [action3, action4]
}</code></pre>
<p>eg:</p>
<pre><code>// Some ViewItems
var someButton = new views.button(),
removeItem = new actions.remove();
// Set removeItem as a child of someButton.
someButton.actions.click = [removeItem];</code></pre>
<p>If a Views action.[name] matches a DOM event name, it will be automatically bound.</p>
<pre><code>myView.actions.click = [
// actions to trigger when a 'click' event is raised by the views renderedElement
];</code></pre>
</div><div class="docyacode-block" data-blockname=".path"><a name=".path"></a><h2>.path</h2>
<p>the base path for a viewItem.</p>
<p>Any bindings on a ViewItem will recursivly resolve through the ViewItems parent's paths.</p>
<p>Eg:</p>
<pre><code>// Some ViewItems
var viewItem1 = new views.button(),
viewItem2 = new actions.set();
// Give viewItem1 a path.
viewItem1.path = '[things]';
// Set viewItem2 as a child of viewItem1.
viewItem1.actions.click = [viewItem2];
// Give viewItem2 a path.
viewItem2.path = '[stuff]';
// Set viewItem2s target binding.
viewItem2.target.binding = '[majigger]';</code></pre>
<p>viewItem2.target.binding will resolve to:</p>
<pre><code>'[/things/stuff/majigger]'</code></pre>
</div></section></div><div class="docyacode-block" data-blockname="View"><a name="View"></a><h2>View</h2>
<p>A base constructor for gaffa Views that have content view.</p>
<p>All Views that inherit from ContainerView will have:</p>
<pre><code>someView.views.content</code></pre>
</div><div class="docyacode-block" data-blockname="ContainerView"><a name="ContainerView"></a><h2>ContainerView</h2>
<p>A base constructor for gaffa Views that have content view.</p>
<p>All Views that inherit from ContainerView will have:</p>
<pre><code>someView.views.content</code></pre>
</div><div class="docyacode-block" data-blockname="The gaffa instance"><a name="The gaffa instance"></a><h2>The gaffa instance</h2>
<p>Instance of Gaffa</p>
<pre><code>var gaffa = new Gaffa();</code></pre>
<section><div class="docyacode-block" data-blockname=".addDefaultStyle"><a name=".addDefaultStyle"></a><h3>.addDefaultStyle</h3>
<p>used to add default syling for a view to the application, eg:</p>
<pre><code>MyView.prototype.render = function(){
//render code...
gaffa.addDefaultStyle(css);
};</code></pre>
<p>Gaffa encourages style-free Views, however sometimes views require minimal css to add functionality.</p>
<p>addDefaultStyle allows encaptulation of css within the View's .js file, and allows the style to be easily overriden.</p>
</div><div class="docyacode-block" data-blockname=".createSpec"><a name=".createSpec"></a><h3>.createSpec</h3>
<pre><code>function myConstructor(){}
myConstructor = gaffa.createSpec(myConstructor, inheritedConstructor);</code></pre>
<p>npm module: <a href="https://npmjs.org/package/spec-js">spec-js</a></p>
</div><div class="docyacode-block" data-blockname=".jsonConverter"><a name=".jsonConverter"></a><h3>.jsonConverter</h3>
<p>default jsonification for ViewItems</p>
</div><div class="docyacode-block" data-blockname=".initialiseViewItem"><a name=".initialiseViewItem"></a><h3>.initialiseViewItem</h3>
<p>takes the plain old object representation of a viewItem and returns an instance of ViewItem with all the settings applied.</p>
<p>Also recurses through the ViewItem's tree and inflates children.</p>
</div><div class="docyacode-block" data-blockname=".events"><a name=".events"></a><h3>.events</h3>
<p>used throughout gaffa for binding DOM events.</p>
<section><div class="docyacode-block" data-blockname=".on"><a name=".on"></a><h3>.on</h3>
<p>usage:</p>
<pre><code>gaffa.events.on('eventname', target, callback);</code></pre>
</div></section></div><div class="docyacode-block" data-blockname=".model"><a name=".model"></a><h2>.model</h2>
<p>access to the applications model</p>
<section><div class="docyacode-block" data-blockname=".get(path, viewItem, scope, asTokens)"><a name=".get(path, viewItem, scope, asTokens)"></a><h3>.get(path, viewItem, scope, asTokens)</h3>
<p>used to get data from the model.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.get('[someProp]', parentViewItem);</code></pre>
</div><div class="docyacode-block" data-blockname=".set(path, value, viewItem, dirty)"><a name=".set(path, value, viewItem, dirty)"></a><h3>.set(path, value, viewItem, dirty)</h3>
<p>used to set data into the model.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.set('[someProp]', 'hello', parentViewItem);</code></pre>
</div><div class="docyacode-block" data-blockname=".remove(path, viewItem, dirty)"><a name=".remove(path, viewItem, dirty)"></a><h3>.remove(path, viewItem, dirty)</h3>
<p>used to remove data from the model.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.remove('[someProp]', parentViewItem);</code></pre>
</div><div class="docyacode-block" data-blockname=".bind(path, callback, viewItem)"><a name=".bind(path, callback, viewItem)"></a><h3>.bind(path, callback, viewItem)</h3>
<p>used to bind callbacks to changes in the model.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.bind('[someProp]', function(){
//do something when '[someProp]' changes.
}, viewItem);</code></pre>
</div><div class="docyacode-block" data-blockname=".debind(viewItem)"><a name=".debind(viewItem)"></a><h3>.debind(viewItem)</h3>
<p>remove all callbacks assigned to a viewItem.</p>
<pre><code>gaffa.model.debind('[someProp]', function(){
//do something when '[someProp]' changes.
});</code></pre>
</div><div class="docyacode-block" data-blockname=".isDirty(path, viewItem)"><a name=".isDirty(path, viewItem)"></a><h3>.isDirty(path, viewItem)</h3>
<p>check if a part of the model is dirty.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.isDirty('[someProp]', viewItem); // true/false?</code></pre>
</div><div class="docyacode-block" data-blockname=".setDirtyState(path, value, viewItem)"><a name=".setDirtyState(path, value, viewItem)"></a><h3>.setDirtyState(path, value, viewItem)</h3>
<p>set a part of the model to be dirty or not.</p>
<p>path is relative to the viewItems path.</p>
<pre><code>gaffa.model.setDirtyState('[someProp]', true, viewItem);</code></pre>
</div></section></div><div class="docyacode-block" data-blockname=".views"><a name=".views"></a><h2>.views</h2>
<pre><code>gaffa.views //Object.</code></pre>
<p>contains functions and properties for manipulating the application's views.</p>
<section><div class="docyacode-block" data-blockname=".renderTarget"><a name=".renderTarget"></a><h3>.renderTarget</h3>
<p>Overrideable DOM selector that top level view items will be inserted into.</p>
<pre><code>gaffa.views.renderTarget = 'body';</code></pre>
</div><div class="docyacode-block" data-blockname=".add(View/viewModel, insertIndex)"><a name=".add(View/viewModel, insertIndex)"></a><h3>.add(View/viewModel, insertIndex)</h3>
<p>Add a view or views to the root list of viewModels.</p>
<p>When a view is added, it will be rendered bound, and inserted into the DOM.</p>
<pre><code>gaffa.views.add(myView);</code></pre>
<p>Or:</p>
<pre><code>gaffa.views.add([
myView1,
myView1,
myView1
]);</code></pre>
</div><div class="docyacode-block" data-blockname=".remove(view/views)"><a name=".remove(view/views)"></a><h3>.remove(view/views)</h3>
<p>Remove a view or views from anywhere in the application.</p>
<pre><code>gaffa.views.remove(myView);</code></pre>
</div><div class="docyacode-block" data-blockname=".empty()"><a name=".empty()"></a><h3>.empty()</h3>
<p>empty the application of all views.</p>
<pre><code>gaffa.views.empty();</code></pre>
</div><div class="docyacode-block" data-blockname=".constructors"><a name=".constructors"></a><h3>.constructors</h3>
<p>An overridable object used by Gaffa to instantiate views.</p>
<p>The constructors for any views your application requires should be added to this object.</p>
<p>Either:</p>
<pre><code>gaffa.views.constructors.textbox = require('gaffa/views/textbox');
gaffa.views.constructors.label = require('gaffa/views/label');
// etc...</code></pre>
<p>Or:</p>
<pre><code>gaffa.views.constructors = {
textbox: require('gaffa/views/textbox'),
label: require('gaffa/views/label')
}
// etc...</code></pre>
</div></section></div><div class="docyacode-block" data-blockname=".namedViews"><a name=".namedViews"></a><h3>.namedViews</h3>
<p>Storage for named views.</p>
<p>Any views with a .name property will be put here, with the name as the key.</p>
<p>This is used for navigation, where you can specify a view to navigate into.</p>
<p>See gaffa.navitate();</p>
</div><div class="docyacode-block" data-blockname=".actions"><a name=".actions"></a><h2>.actions</h2>
<pre><code>gaffa.actions //Object.</code></pre>
<p>contains functions and properties for manipulating the application's actions.</p>
<section><div class="docyacode-block" data-blockname=".trigger(actions, parent, scope, event)"><a name=".trigger(actions, parent, scope, event)"></a><h3>.trigger(actions, parent, scope, event)</h3>
<p>trigger a gaffa action where:</p>
<ul>
<li><p>actions is an array of actions to trigger.</p>
</li>
<li><p>parent is an instance of ViewItem that the action is on.</p>
</li>
<li><p>scope is an arbitrary object to be passed in as scope to all expressions in the action</p>
</li>
<li><p>event is an arbitrary event object that may have triggered the action, such as a DOM event.</p>
</li>
</ul>
</div><div class="docyacode-block" data-blockname=".constructors"><a name=".constructors"></a><h3>.constructors</h3>
<p>An overridable object used by Gaffa to instantiate actions.</p>
<p>The constructors for any actions your application requires should be added to this object.</p>
<p>Either:</p>
<pre><code>gaffa.actions.constructors.set = require('gaffa/actions/set');
gaffa.actions.constructors.remove = require('gaffa/actions/remove');
// etc...</code></pre>
<p>Or:</p>
<pre><code>gaffa.actions.constructors = {
set: require('gaffa/views/set'),
remove: require('gaffa/views/remove')
}
// etc...</code></pre>
</div></section></div><div class="docyacode-block" data-blockname=".behaviours"><a name=".behaviours"></a><h2>.behaviours</h2>
<pre><code>gaffa.behaviours //Object.</code></pre>
<p>contains functions and properties for manipulating the application's behaviours.</p>
<section><div class="docyacode-block" data-blockname=".add(behaviour)"><a name=".add(behaviour)"></a><h3>.add(behaviour)</h3>
<p>add a behaviour to the root of the appliaction</p>
<pre><code>gaffa.behaviours.add(someBehaviour);</code></pre>
</div><div class="docyacode-block" data-blockname=".constructors"><a name=".constructors"></a><h3>.constructors</h3>
<p>An overridable object used by Gaffa to instantiate behaviours.</p>
<p>The constructors for any behaviours your application requires should be added to this object.</p>
<p>Either:</p>
<pre><code>gaffa.behaviours.constructors.pageLoad = require('gaffa/behaviours/pageLoad');
gaffa.behaviours.constructors.modelChange = require('gaffa/behaviours/modelChange');
// etc...</code></pre>
<p>Or:</p>
<pre><code>gaffa.behaviours.constructors = {
pageLoad: require('gaffa/views/pageLoad'),
modelChange: require('gaffa/views/modelChange')
}
// etc...</code></pre>
</div></section></div><div class="docyacode-block" data-blockname="Navigate"><a name="Navigate"></a><h2>Navigate</h2>
<p>Navigates the app to a gaffa-app endpoint</p>
<pre><code>gaffa.navigate(url);</code></pre>
<p>To navigate into a named view:</p>
<pre><code>gaffa.navigate(url, target);</code></pre>
<p>Where target is: [viewName].[viewContainerName], eg:</p>
<pre><code>gaffa.navigate('/someroute', 'myPageContainer.content');</code></pre>
<p>myPageContainer would be a named ContainerView and content is the viewContainer on the view to target.</p>
</div></section></div></section></div><div class="docyacode-block" data-blockname="License"><a name="License"></a><h2>License</h2>
<p>(The MIT License)</p>
<p>Copyright (C) 2012 Kory Nunn, Matt Ginty & Maurice Butler</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
</div>