-
Notifications
You must be signed in to change notification settings - Fork 79
/
utils.html
597 lines (591 loc) · 17.1 KB
/
utils.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
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>CoffeeScript API Documentation</title>
<link rel='stylesheet' href='../../assets/codo.css' type='text/css'>
<script src='../../assets/codo.js'></script>
<script src='../../assets/search_data.js'></script>
</head>
<body>
<div id='base' data-path='../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../class_index.html' title='Index'>Index</a>
»
<a href='../../classes/kb.html' title='kb'>kb</a>
»
<span class='title'>utils</span>
<nav>
<ul>
<li class='noframes'>
(<a class='noframes' href='#'>no frames</a>)
</li>
</ul>
</nav>
<div id='search'>
<a id='class_list_link' href='../../class_list.html'>Classes</a>
<a id='method_list_link' href='../../method_list.html'>Methods</a>
<a id='extra_list_link' href='../../extra_list.html'>Extras</a>
</div>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>Ctrl-T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
In frame mode you can toggle the list naviation frame on the left side:
</p>
<ul>
<li>
<span>Ctrl-L</span>
Toggle list view
</li>
</ul>
<p>
You can focus a list in frame mode or toggle a tab in frameless mode:
</p>
<ul>
<li>
<span>Ctrl-C</span>
Class list
</li>
<li>
<span>Ctrl-I</span>
Mixin list
</li>
<li>
<span>Ctrl-F</span>
File list
</li>
<li>
<span>Ctrl-M</span>
Method list
</li>
<li>
<span>Ctrl-E</span>
Extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>Ctrl-S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
<p>
In frameless mode you can close the list tab:
</p>
<ul>
<li>
<span>Esc</span>
Close list tab
</li>
</ul>
</div>
</div>
<div id='content'>
<h1>
Class:
kb.utils
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>src/knockback-core/knockback-utils.coffee</td>
</tr>
</table>
<h2>Overview</h2>
<div class='docstring'>
<p>Library of general-purpose utilities </p>
</div>
<div class='tags'>
</div>
<h2>Class Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#wrappedObservable-class'>
+ (void) <strong>wrappedObservable</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing the observable on an instance that returns a ko.observable instead of 'this'.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedObject-class'>
+ (void) <strong>wrappedObject</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing the Model or Collection on an owner.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedModel-class'>
+ (void) <strong>wrappedModel</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing the Model on a ViewModel.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedStore-class'>
+ (void) <strong>wrappedStore</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing a kb.Store on an owner.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedFactory-class'>
+ (void) <strong>wrappedFactory</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing a kb.Factory on an owner.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedModelWatcher-class'>
+ (void) <strong>wrappedModelWatcher</strong>(obj, value)
</a>
</span>
<span class='desc'>
Dual-purpose getter/setter for retrieving and storing a kb.ModelWatcher on an owner.
</span>
</li>
<li>
<span class='signature'>
<a href='#wrappedDestroy-class'>
+ (void) <strong>wrappedDestroy</strong>(obj)
</a>
</span>
<span class='desc'>
Clean up function that releases all of the wrapped values on an owner.
</span>
</li>
<li>
<span class='signature'>
<a href='#valueType-class'>
+ (void) <strong>valueType</strong>(observable)
</a>
</span>
<span class='desc'>
Retrieves the value stored in a ko.observable.
</span>
</li>
<li>
<span class='signature'>
<a href='#pathJoin-class'>
+ (void) <strong>pathJoin</strong>(path1, path2)
</a>
</span>
<span class='desc'>
Helper to join a dot-deliminated path.
</span>
</li>
<li>
<span class='signature'>
<a href='#optionsPathJoin-class'>
+ (void) <strong>optionsPathJoin</strong>(options, path)
</a>
</span>
<span class='desc'>
Helper to join a dot-deliminated path with the path on options and returns a new options object with the result.
</span>
</li>
<li>
<span class='signature'>
<a href='#inferCreator-class'>
+ (void) <strong>inferCreator</strong>(value, factory, path, owner, key)
</a>
</span>
<span class='desc'>
Helper to find the creator constructor or function from a factory or Backbone.RelationalModel or by the value's type.
</span>
</li>
<li>
<span class='signature'>
<a href='#createFromDefaultCreator-class'>
+ (void) <strong>createFromDefaultCreator</strong>(obj, options)
</a>
</span>
<span class='desc'>
Creates an observable based on a value's type.
</span>
</li>
<li deprecated>
<span class='signature'>
<a href='#release-class'>
+ (void) <strong>release</strong>(obj)
</a>
</span>
<span class='deprecated note title'>Deprecated</span>
<span class='desc'>
<strong>Deprecated.</strong>
please use kb.release instead
</span>
</li>
</ul>
<h2>Class Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='wrappedObservable-class'>
+ (void) <strong>wrappedObservable</strong>(obj, value)
</p>
<div class='docstring'>
<p>Dual-purpose getter/setter for retrieving and storing the observable on an instance that returns a ko.observable instead of 'this'. Relevant for: </p> <ul> <li><a href="'classes/kb/CollectionObservable.html'">kb.CollectionObservable</a></li> <li><a href="'classes/kb/Observable.html'">kb.Observable</a></li> <li><a href="'classes/kb/DefaultObservable.html'">kb.DefaultObservable</a></li> <li><a href="'classes/kb/FormattedObservable.html'">kb.FormattedObservable</a></li> <li><a href="'classes/kb/LocalizedObservable.html'">kb.LocalizedObservable</a></li> <li><a href="'classes/kb/TriggeredObservable.html'">kb.TriggeredObservable</a></li> </ul>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>var ShortDateLocalizer = kb.LocalizedObservable.extend({
constructor: function(value, options, view_model) {
kb.LocalizedObservable.prototype.constructor.apply(this, arguments);
return kb.utils.wrappedObservable(this);
}
});
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>instance</span>
<span class='type'>
(<tt>Instance</tt>)
</span>
—
<span class='desc'>the instance owning the ko.observable.</span>
</li>
<li>
<span class='name'>observable</span>
<span class='type'>
(<tt>ko.observable</tt>)
</span>
—
<span class='desc'>if provided, sets the observable; otherwise, gets the observable.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedObject-class'>
+ (void) <strong>wrappedObject</strong>(obj, value)
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
this is almost the same as <a href='../../classes/kb/utils.html#wrappedModel-class'>kb.utils.wrappedModel</a> except that if the Model doesn't exist, it returns null.
</div>
<p>Dual-purpose getter/setter for retrieving and storing the Model or Collection on an owner. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>var model = kb.utils.wrappedObject(view_model);
var collection = kb.utils.wrappedObject(collection_observable);
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>owner</span>
<span class='type'>
(<tt>Object|kb.ViewModel|kb.CollectionObservable</tt>)
</span>
—
<span class='desc'>the ViewModel/CollectionObservable owning the Backbone.Model or Backbone.Collection.</span>
</li>
<li>
<span class='name'>model/collection</span>
<span class='type'>
(<tt>Backbone.Model|Backbone.Collection</tt>)
</span>
—
<span class='desc'>if provided, sets the Model/Collection; otherwise, gets the Model/Collection.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedModel-class'>
+ (void) <strong>wrappedModel</strong>(obj, value)
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
this is almost the same as <a href='../../classes/kb/utils.html#wrappedObject-class'>kb.utils.wrappedObject</a> except that if the Model doesn't exist, it returns the ViewModel itself (which is useful behaviour for sorting).
</div>
<p>Dual-purpose getter/setter for retrieving and storing the Model on a ViewModel. </p>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>view_model</span>
<span class='type'>
(<tt>Object|kb.ViewModel</tt>)
</span>
—
<span class='desc'>the ViewModel owning the Backbone.Model.</span>
</li>
<li>
<span class='name'>model</span>
<span class='type'>
(<tt>Backbone.Model</tt>)
</span>
—
<span class='desc'>if provided, sets the Model; otherwise, gets the Model or ViewModel itself if there is no Model.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedStore-class'>
+ (void) <strong>wrappedStore</strong>(obj, value)
</p>
<div class='docstring'>
<p>Dual-purpose getter/setter for retrieving and storing a kb.Store on an owner. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>var co = kb.collectionObservable(new Backbone.Collection());
var co_selected_options = kb.collectionObservable(new Backbone.Collection(), {
store: kb.utils.wrappedStore(co)
});
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>owner</span>
<span class='type'>
(<tt>Any</tt>)
</span>
—
<span class='desc'>the kb.Store owner.</span>
</li>
<li>
<span class='name'>store</span>
<span class='type'>
(<tt><a href='../../classes/kb/Store.html'>kb.Store</a></tt>)
</span>
—
<span class='desc'>if provided, sets the store; otherwise, gets the store.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedFactory-class'>
+ (void) <strong>wrappedFactory</strong>(obj, value)
</p>
<div class='docstring'>
<p>Dual-purpose getter/setter for retrieving and storing a kb.Factory on an owner. </p>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>owner</span>
<span class='type'>
(<tt>Any</tt>)
</span>
—
<span class='desc'>the kb.Factory owner.</span>
</li>
<li>
<span class='name'>factory</span>
<span class='type'>
(<tt><a href='../../classes/kb/Factory.html'>kb.Factory</a></tt>)
</span>
—
<span class='desc'>if provided, sets the factory; otherwise, gets the factory.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedModelWatcher-class'>
+ (void) <strong>wrappedModelWatcher</strong>(obj, value)
</p>
<div class='docstring'>
<p>Dual-purpose getter/setter for retrieving and storing a kb.ModelWatcher on an owner. </p>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>owner</span>
<span class='type'>
(<tt>Any</tt>)
</span>
—
<span class='desc'>the kb.ModelWatcher owner.</span>
</li>
<li>
<span class='name'>model_watcher</span>
<span class='type'>
(<tt><a href='../../classes/kb/ModelWatcher.html'>kb.ModelWatcher</a></tt>)
</span>
—
<span class='desc'>if provided, sets the model watcher; otherwise, gets the model watcher.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='wrappedDestroy-class'>
+ (void) <strong>wrappedDestroy</strong>(obj)
</p>
<div class='docstring'>
<p>Clean up function that releases all of the wrapped values on an owner. </p>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='valueType-class'>
+ (void) <strong>valueType</strong>(observable)
</p>
<div class='docstring'>
<p>Retrieves the value stored in a ko.observable. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>var view_model = kb.viewModel(new Backbone.Model({simple_attr: null, model_attr: null}), {factories: {model_attr: kb.ViewModel});
kb.utils.valueType(view_model.simple_attr); // kb.TYPE_SIMPLE
kb.utils.valueType(view_model.model_attr); // kb.TYPE_MODEL
</code></pre>
</div>
</div>
<div class='tags'>
<h3>See also:</h3>
<ul class='see'>
<li>
kb.Observable.valueType
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='pathJoin-class'>
+ (void) <strong>pathJoin</strong>(path1, path2)
</p>
<div class='docstring'>
<p>Helper to join a dot-deliminated path. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>kb.utils.pathJoin('models', 'name'); // 'models.name'
</code></pre>
</div>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='optionsPathJoin-class'>
+ (void) <strong>optionsPathJoin</strong>(options, path)
</p>
<div class='docstring'>
<p>Helper to join a dot-deliminated path with the path on options and returns a new options object with the result. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>this.friends = kb.collectionObservable(model.get('friends'), kb.utils.optionsPathJoin(options, 'friends'));
</code></pre>
</div>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='inferCreator-class'>
+ (void) <strong>inferCreator</strong>(value, factory, path, owner, key)
</p>
<div class='docstring'>
<p>Helper to find the creator constructor or function from a factory or Backbone.RelationalModel or by the value's type. </p>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='createFromDefaultCreator-class'>
+ (void) <strong>createFromDefaultCreator</strong>(obj, options)
</p>
<div class='docstring'>
<p>Creates an observable based on a value's type. </p>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='release-class'>
+ (void) <strong>release</strong>(obj)
</p>
<div class='docstring'>
<div class='deprecated note'>
<strong>Deprecated.</strong>
please use kb.release instead
</div>
<p>Releases any type of view model or observable or items in an array using the conventions of release(), destroy(), dispose(). </p>
</div>
<div class='tags'>
</div>
</div>
</div>
</div>
<div id='footer'>
Generated on
Thu Sep 06 2012 17:22:43 GMT+0900 (JST)
by
<a href='https://github.com/netzpirat/codo' title='CoffeeScript API documentation generator'>Codo</a>
v1.3.0
(Node.js v0.8.7).
✲
Press Ctrl-h to see the keyboard shortcuts
✲
<a href='http://twitter.com/#!/netzpirat'>@netzpirat</a>
✲
<a href='https://mksoft.ch'>mksoft.ch</a>
</div>
</body>
</html>