This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
composition.html
490 lines (310 loc) · 16.3 KB
/
composition.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
<!DOCTYPE html>
<html>
<head>
<title>composition.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="chaplin.html">
chaplin.coffee
</a>
<a class="source" href="application.html">
application.coffee
</a>
<a class="source" href="composer.html">
composer.coffee
</a>
<a class="source" href="controller.html">
controller.coffee
</a>
<a class="source" href="dispatcher.html">
dispatcher.coffee
</a>
<a class="source" href="composition.html">
composition.coffee
</a>
<a class="source" href="event_broker.html">
event_broker.coffee
</a>
<a class="source" href="history.html">
history.coffee
</a>
<a class="source" href="route.html">
route.coffee
</a>
<a class="source" href="router.html">
router.coffee
</a>
<a class="source" href="support.html">
support.coffee
</a>
<a class="source" href="sync_machine.html">
sync_machine.coffee
</a>
<a class="source" href="utils.html">
utils.coffee
</a>
<a class="source" href="mediator.html">
mediator.coffee
</a>
<a class="source" href="collection.html">
collection.coffee
</a>
<a class="source" href="model.html">
model.coffee
</a>
<a class="source" href="collection_view.html">
collection_view.coffee
</a>
<a class="source" href="layout.html">
layout.coffee
</a>
<a class="source" href="view.html">
view.coffee
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>composition.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre><span class="string">'use strict'</span>
_ = <span class="built_in">require</span> <span class="string">'underscore'</span>
Backbone = <span class="built_in">require</span> <span class="string">'backbone'</span>
EventBroker = <span class="built_in">require</span> <span class="string">'chaplin/lib/event_broker'</span>
has = <span class="attribute">Object</span>::hasOwnProperty</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<h2 id="composition">Composition</h2>
</div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p>A utility class that is meant as a simple proxied version of a
controller that is used internally to inflate simple
calls to !composer:compose and may be extended and used to have complete
control over the composition process.</p>
</div>
<div class="content"><div class='highlight'><pre>module.<span class="built_in">exports</span> = <span class="class"><span class="keyword">class</span> <span class="title">Composition</span></span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p>Borrow the static extend method from Backbone.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="property">@extend</span> = Backbone.Model.extend</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>Mixin Backbone events and EventBroker.</p>
</div>
<div class="content"><div class='highlight'><pre> _.extend <span class="property">@prototype</span>, Backbone.Events
_.extend <span class="property">@prototype</span>, EventBroker</pre></div></div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">¶</a>
</div>
<p>The item that is composed; this is by default a reference to this.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">item</span>: <span class="literal">null</span></pre></div></div>
</li>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">¶</a>
</div>
<p>The options that this composition was constructed with.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">options</span>: <span class="literal">null</span></pre></div></div>
</li>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">¶</a>
</div>
<p>Whether this composition is currently stale.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">_stale</span>: <span class="literal">false</span>
<span class="attribute">constructor</span>: <span class="function"><span class="params">(options)</span> -></span>
<span class="property">@options</span> = _.extend {}, options <span class="keyword">if</span> options?
<span class="property">@item</span> = <span class="keyword">this</span>
<span class="property">@initialize</span> <span class="property">@options</span>
<span class="attribute">initialize</span>:<span class="function"> -></span></pre></div></div>
</li>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">¶</a>
</div>
<p>Empty per default.</p>
<p>The compose method is called when this composition is to be composed.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">compose</span>:<span class="function"> -></span></pre></div></div>
</li>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">¶</a>
</div>
<p>Empty per default.</p>
<p>The check method is called when this composition is asked to be
composed again. The passed options are the newly passed options.
If this returns false then the composition is re-composed.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">check</span>: <span class="function"><span class="params">(options)</span> -></span>
_.isEqual <span class="property">@options</span>, options</pre></div></div>
</li>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">¶</a>
</div>
<p>Marks all applicable items as stale.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">stale</span>: <span class="function"><span class="params">(value)</span> -></span></pre></div></div>
</li>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">¶</a>
</div>
<p>Return the current property if not requesting a change.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="keyword">return</span> <span class="property">@_stale</span> <span class="keyword">unless</span> value?</pre></div></div>
</li>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">¶</a>
</div>
<p>Sets the stale property for every item in the composition that has it.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="property">@_stale</span> = value
<span class="keyword">for</span> name, item <span class="keyword">of</span> <span class="keyword">this</span> <span class="keyword">when</span> (
item <span class="keyword">and</span> item <span class="keyword">isnt</span> <span class="keyword">this</span> <span class="keyword">and</span>
<span class="keyword">typeof</span> item <span class="keyword">is</span> <span class="string">'object'</span> <span class="keyword">and</span> has.call(item, <span class="string">'stale'</span>)
)
item.stale = value</pre></div></div>
</li>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">¶</a>
</div>
<p>Return nothing.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="keyword">return</span></pre></div></div>
</li>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">¶</a>
</div>
<h2 id="disposal">Disposal</h2>
</div>
</li>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre> <span class="attribute">disposed</span>: <span class="literal">false</span>
<span class="attribute">dispose</span>:<span class="function"> -></span>
<span class="keyword">return</span> <span class="keyword">if</span> <span class="property">@disposed</span></pre></div></div>
</li>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">¶</a>
</div>
<p>Dispose and delete all members which are disposable.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="keyword">for</span> own prop, obj <span class="keyword">of</span> <span class="keyword">this</span> <span class="keyword">when</span> obj <span class="keyword">and</span> <span class="keyword">typeof</span> obj.dispose <span class="keyword">is</span> <span class="string">'function'</span>
<span class="keyword">unless</span> obj <span class="keyword">is</span> <span class="keyword">this</span>
obj.dispose()
<span class="keyword">delete</span> <span class="keyword">this</span>[prop]</pre></div></div>
</li>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">¶</a>
</div>
<p>Unbind handlers of global events.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="property">@unsubscribeAllEvents</span>()</pre></div></div>
</li>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">¶</a>
</div>
<p>Unbind all referenced handlers.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="property">@stopListening</span>()</pre></div></div>
</li>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">¶</a>
</div>
<p>Remove properties which are not disposable.</p>
</div>
<div class="content"><div class='highlight'><pre> properties = [<span class="string">'redirected'</span>]
<span class="keyword">delete</span> <span class="keyword">this</span>[prop] <span class="keyword">for</span> prop <span class="keyword">in</span> properties</pre></div></div>
</li>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">¶</a>
</div>
<p>Finished.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="property">@disposed</span> = <span class="literal">true</span></pre></div></div>
</li>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">¶</a>
</div>
<p>You're frozen when your heart’s not open.</p>
</div>
<div class="content"><div class='highlight'><pre> Object.freeze? <span class="keyword">this</span></pre></div></div>
</li>
</ul>
</div>
</body>
</html>