-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.js
11859 lines (11140 loc) · 336 KB
/
bundle.js
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var pr = require('./pjax-ractive');
pr.init();
},{"./pjax-ractive":6}],2:[function(require,module,exports){
/*
Ractive - v0.3.9-317-d23e408 - 2014-03-21
==============================================================
Next-generation DOM manipulation - http://ractivejs.org
Follow @RactiveJS for updates
--------------------------------------------------------------
Copyright 2014 Rich Harris and contributors
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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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.
*/
( function( global ) {
var noConflict = global.Ractive;
var legacy = undefined;
var config_initOptions = function( legacy ) {
var defaults, initOptions;
defaults = {
el: null,
template: '',
complete: null,
preserveWhitespace: false,
append: false,
twoway: true,
modifyArrays: true,
lazy: false,
debug: false,
noIntro: false,
transitionsEnabled: true,
magic: false,
noCssTransform: false,
adapt: [],
sanitize: false,
stripComments: true,
isolated: false,
delimiters: [
'{{',
'}}'
],
tripleDelimiters: [
'{{{',
'}}}'
]
};
initOptions = {
keys: Object.keys( defaults ),
defaults: defaults
};
return initOptions;
}( legacy );
var config_svg = function() {
if ( typeof document === 'undefined' ) {
return;
}
return document && document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1' );
}();
var config_namespaces = {
html: 'http://www.w3.org/1999/xhtml',
mathml: 'http://www.w3.org/1998/Math/MathML',
svg: 'http://www.w3.org/2000/svg',
xlink: 'http://www.w3.org/1999/xlink',
xml: 'http://www.w3.org/XML/1998/namespace',
xmlns: 'http://www.w3.org/2000/xmlns/'
};
var utils_createElement = function( svg, namespaces ) {
if ( !svg ) {
return function( type, ns ) {
if ( ns && ns !== namespaces.html ) {
throw 'This browser does not support namespaces other than http://www.w3.org/1999/xhtml. The most likely cause of this error is that you\'re trying to render SVG in an older browser. See http://docs.ractivejs.org/latest/svg-and-older-browsers for more information';
}
return document.createElement( type );
};
} else {
return function( type, ns ) {
if ( !ns ) {
return document.createElement( type );
}
return document.createElementNS( ns, type );
};
}
}( config_svg, config_namespaces );
var config_isClient = typeof document === 'object';
var utils_defineProperty = function( isClient ) {
try {
Object.defineProperty( {}, 'test', {
value: 0
} );
if ( isClient ) {
Object.defineProperty( document.createElement( 'div' ), 'test', {
value: 0
} );
}
return Object.defineProperty;
} catch ( err ) {
return function( obj, prop, desc ) {
obj[ prop ] = desc.value;
};
}
}( config_isClient );
var utils_defineProperties = function( createElement, defineProperty, isClient ) {
try {
try {
Object.defineProperties( {}, {
test: {
value: 0
}
} );
} catch ( err ) {
throw err;
}
if ( isClient ) {
Object.defineProperties( createElement( 'div' ), {
test: {
value: 0
}
} );
}
return Object.defineProperties;
} catch ( err ) {
return function( obj, props ) {
var prop;
for ( prop in props ) {
if ( props.hasOwnProperty( prop ) ) {
defineProperty( obj, prop, props[ prop ] );
}
}
};
}
}( utils_createElement, utils_defineProperty, config_isClient );
var utils_isNumeric = function( thing ) {
return !isNaN( parseFloat( thing ) ) && isFinite( thing );
};
var Ractive_prototype_shared_add = function( isNumeric ) {
return function( root, keypath, d ) {
var value;
if ( typeof keypath !== 'string' || !isNumeric( d ) ) {
throw new Error( 'Bad arguments' );
}
value = +root.get( keypath ) || 0;
if ( !isNumeric( value ) ) {
throw new Error( 'Cannot add to a non-numeric value' );
}
return root.set( keypath, value + d );
};
}( utils_isNumeric );
var Ractive_prototype_add = function( add ) {
return function( keypath, d ) {
return add( this, keypath, d === undefined ? 1 : +d );
};
}( Ractive_prototype_shared_add );
var utils_isEqual = function( a, b ) {
if ( a === null && b === null ) {
return true;
}
if ( typeof a === 'object' || typeof b === 'object' ) {
return false;
}
return a === b;
};
var utils_Promise = function() {
var Promise, PENDING = {}, FULFILLED = {}, REJECTED = {};
Promise = function( callback ) {
var fulfilledHandlers = [],
rejectedHandlers = [],
state = PENDING,
result, dispatchHandlers, makeResolver, fulfil, reject, promise;
makeResolver = function( newState ) {
return function( value ) {
if ( state !== PENDING ) {
return;
}
result = value;
state = newState;
dispatchHandlers = makeDispatcher( state === FULFILLED ? fulfilledHandlers : rejectedHandlers, result );
wait( dispatchHandlers );
};
};
fulfil = makeResolver( FULFILLED );
reject = makeResolver( REJECTED );
callback( fulfil, reject );
promise = {
then: function( onFulfilled, onRejected ) {
var promise2 = new Promise( function( fulfil, reject ) {
var processResolutionHandler = function( handler, handlers, forward ) {
if ( typeof handler === 'function' ) {
handlers.push( function( p1result ) {
var x;
try {
x = handler( p1result );
resolve( promise2, x, fulfil, reject );
} catch ( err ) {
reject( err );
}
} );
} else {
handlers.push( forward );
}
};
processResolutionHandler( onFulfilled, fulfilledHandlers, fulfil );
processResolutionHandler( onRejected, rejectedHandlers, reject );
if ( state !== PENDING ) {
wait( dispatchHandlers );
}
} );
return promise2;
}
};
promise[ 'catch' ] = function( onRejected ) {
return this.then( null, onRejected );
};
return promise;
};
Promise.all = function( promises ) {
return new Promise( function( fulfil, reject ) {
var result = [],
pending, i, processPromise;
if ( !promises.length ) {
fulfil( result );
return;
}
processPromise = function( i ) {
promises[ i ].then( function( value ) {
result[ i ] = value;
if ( !--pending ) {
fulfil( result );
}
}, reject );
};
pending = i = promises.length;
while ( i-- ) {
processPromise( i );
}
} );
};
Promise.resolve = function( value ) {
return new Promise( function( fulfil ) {
fulfil( value );
} );
};
Promise.reject = function( reason ) {
return new Promise( function( fulfil, reject ) {
reject( reason );
} );
};
return Promise;
function wait( callback ) {
setTimeout( callback, 0 );
}
function makeDispatcher( handlers, result ) {
return function() {
var handler;
while ( handler = handlers.shift() ) {
handler( result );
}
};
}
function resolve( promise, x, fulfil, reject ) {
var then;
if ( x === promise ) {
throw new TypeError( 'A promise\'s fulfillment handler cannot return the same promise' );
}
if ( x instanceof Promise ) {
x.then( fulfil, reject );
} else if ( x && ( typeof x === 'object' || typeof x === 'function' ) ) {
try {
then = x.then;
} catch ( e ) {
reject( e );
return;
}
if ( typeof then === 'function' ) {
var called, resolvePromise, rejectPromise;
resolvePromise = function( y ) {
if ( called ) {
return;
}
called = true;
resolve( promise, y, fulfil, reject );
};
rejectPromise = function( r ) {
if ( called ) {
return;
}
called = true;
reject( r );
};
try {
then.call( x, resolvePromise, rejectPromise );
} catch ( e ) {
if ( !called ) {
reject( e );
called = true;
return;
}
}
} else {
fulfil( x );
}
} else {
fulfil( x );
}
}
}();
var utils_normaliseKeypath = function() {
var regex = /\[\s*(\*|[0-9]|[1-9][0-9]+)\s*\]/g;
return function normaliseKeypath( keypath ) {
return ( keypath || '' ).replace( regex, '.$1' );
};
}();
var config_vendors = [
'o',
'ms',
'moz',
'webkit'
];
var utils_requestAnimationFrame = function( vendors ) {
if ( typeof window === 'undefined' ) {
return;
}
( function( vendors, lastTime, window ) {
var x, setTimeout;
if ( window.requestAnimationFrame ) {
return;
}
for ( x = 0; x < vendors.length && !window.requestAnimationFrame; ++x ) {
window.requestAnimationFrame = window[ vendors[ x ] + 'RequestAnimationFrame' ];
}
if ( !window.requestAnimationFrame ) {
setTimeout = window.setTimeout;
window.requestAnimationFrame = function( callback ) {
var currTime, timeToCall, id;
currTime = Date.now();
timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
id = setTimeout( function() {
callback( currTime + timeToCall );
}, timeToCall );
lastTime = currTime + timeToCall;
return id;
};
}
}( vendors, 0, window ) );
return window.requestAnimationFrame;
}( config_vendors );
var utils_getTime = function() {
if ( typeof window !== 'undefined' && window.performance && typeof window.performance.now === 'function' ) {
return function() {
return window.performance.now();
};
} else {
return function() {
return Date.now();
};
}
}();
// This module provides a place to store a) circular dependencies and
// b) the callback functions that require those circular dependencies
var circular = [];
var utils_removeFromArray = function( array, member ) {
var index = array.indexOf( member );
if ( index !== -1 ) {
array.splice( index, 1 );
}
};
var global_css = function( circular, isClient, removeFromArray ) {
var runloop, styleElement, head, styleSheet, inDom, prefix = '/* Ractive.js component styles */\n',
componentsInPage = {}, styles = [];
if ( !isClient ) {
return;
}
circular.push( function() {
runloop = circular.runloop;
} );
styleElement = document.createElement( 'style' );
styleElement.type = 'text/css';
head = document.getElementsByTagName( 'head' )[ 0 ];
inDom = false;
styleSheet = styleElement.styleSheet;
return {
add: function( Component ) {
if ( !Component.css ) {
return;
}
if ( !componentsInPage[ Component._guid ] ) {
componentsInPage[ Component._guid ] = 0;
styles.push( Component.css );
runloop.scheduleCssUpdate();
}
componentsInPage[ Component._guid ] += 1;
},
remove: function( Component ) {
if ( !Component.css ) {
return;
}
componentsInPage[ Component._guid ] -= 1;
if ( !componentsInPage[ Component._guid ] ) {
removeFromArray( styles, Component.css );
runloop.scheduleCssUpdate();
}
},
update: function() {
var css;
if ( styles.length ) {
css = prefix + styles.join( ' ' );
if ( styleSheet ) {
styleSheet.cssText = css;
} else {
styleElement.innerHTML = css;
}
if ( !inDom ) {
head.appendChild( styleElement );
}
} else if ( inDom ) {
head.removeChild( styleElement );
}
}
};
}( circular, config_isClient, utils_removeFromArray );
var shared_getValueFromCheckboxes = function( ractive, keypath ) {
var value, checkboxes, checkbox, len, i, rootEl;
value = [];
rootEl = ractive._rendering ? ractive.fragment.docFrag : ractive.el;
checkboxes = rootEl.querySelectorAll( 'input[type="checkbox"][name="{{' + keypath + '}}"]' );
len = checkboxes.length;
for ( i = 0; i < len; i += 1 ) {
checkbox = checkboxes[ i ];
if ( checkbox.hasAttribute( 'checked' ) || checkbox.checked ) {
value.push( checkbox._ractive.value );
}
}
return value;
};
var utils_hasOwnProperty = Object.prototype.hasOwnProperty;
var shared_getInnerContext = function( fragment ) {
do {
if ( fragment.context ) {
return fragment.context;
}
} while ( fragment = fragment.parent );
return '';
};
var shared_resolveRef = function( circular, normaliseKeypath, hasOwnProperty, getInnerContext ) {
var get, ancestorErrorMessage = 'Could not resolve reference - too many "../" prefixes';
circular.push( function() {
get = circular.get;
} );
return function resolveRef( ractive, ref, fragment ) {
var context, contextKeys, keys, lastKey, postfix, parentKeypath, parentValue, wrapped;
ref = normaliseKeypath( ref );
if ( ref === '.' ) {
return getInnerContext( fragment );
}
if ( ref.charAt( 0 ) === '.' ) {
context = getInnerContext( fragment );
contextKeys = context ? context.split( '.' ) : [];
if ( ref.substr( 0, 3 ) === '../' ) {
while ( ref.substr( 0, 3 ) === '../' ) {
if ( !contextKeys.length ) {
throw new Error( ancestorErrorMessage );
}
contextKeys.pop();
ref = ref.substring( 3 );
}
contextKeys.push( ref );
return contextKeys.join( '.' );
}
if ( !context ) {
return ref.substring( 1 );
}
return context + ref;
}
keys = ref.split( '.' );
lastKey = keys.pop();
postfix = keys.length ? '.' + keys.join( '.' ) : '';
do {
context = fragment.context;
if ( !context ) {
continue;
}
parentKeypath = context + postfix;
parentValue = get( ractive, parentKeypath );
if ( wrapped = ractive._wrapped[ parentKeypath ] ) {
parentValue = wrapped.get();
}
if ( parentValue && ( typeof parentValue === 'object' || typeof parentValue === 'function' ) && lastKey in parentValue ) {
return context + '.' + ref;
}
} while ( fragment = fragment.parent );
if ( hasOwnProperty.call( ractive.data, ref ) ) {
return ref;
} else if ( get( ractive, ref ) !== undefined ) {
return ref;
}
};
}( circular, utils_normaliseKeypath, utils_hasOwnProperty, shared_getInnerContext );
var shared_getUpstreamChanges = function getUpstreamChanges( changes ) {
var upstreamChanges = [ '' ],
i, keypath, keys, upstreamKeypath;
i = changes.length;
while ( i-- ) {
keypath = changes[ i ];
keys = keypath.split( '.' );
while ( keys.length > 1 ) {
keys.pop();
upstreamKeypath = keys.join( '.' );
if ( upstreamChanges[ upstreamKeypath ] !== true ) {
upstreamChanges.push( upstreamKeypath );
upstreamChanges[ upstreamKeypath ] = true;
}
}
}
return upstreamChanges;
};
var shared_notifyDependants = function() {
var lastKey, starMaps = {};
lastKey = /[^\.]+$/;
function notifyDependants( ractive, keypath, onlyDirect ) {
var i;
if ( ractive._patternObservers.length ) {
notifyPatternObservers( ractive, keypath, keypath, onlyDirect, true );
}
for ( i = 0; i < ractive._deps.length; i += 1 ) {
notifyDependantsAtPriority( ractive, keypath, i, onlyDirect );
}
}
notifyDependants.multiple = function notifyMultipleDependants( ractive, keypaths, onlyDirect ) {
var i, j, len;
len = keypaths.length;
if ( ractive._patternObservers.length ) {
i = len;
while ( i-- ) {
notifyPatternObservers( ractive, keypaths[ i ], keypaths[ i ], onlyDirect, true );
}
}
for ( i = 0; i < ractive._deps.length; i += 1 ) {
if ( ractive._deps[ i ] ) {
j = len;
while ( j-- ) {
notifyDependantsAtPriority( ractive, keypaths[ j ], i, onlyDirect );
}
}
}
};
return notifyDependants;
function notifyDependantsAtPriority( ractive, keypath, priority, onlyDirect ) {
var depsByKeypath = ractive._deps[ priority ];
if ( !depsByKeypath ) {
return;
}
updateAll( depsByKeypath[ keypath ] );
if ( onlyDirect ) {
return;
}
cascade( ractive._depsMap[ keypath ], ractive, priority );
}
function updateAll( deps ) {
var i, len;
if ( deps ) {
len = deps.length;
for ( i = 0; i < len; i += 1 ) {
deps[ i ].update();
}
}
}
function cascade( childDeps, ractive, priority, onlyDirect ) {
var i;
if ( childDeps ) {
i = childDeps.length;
while ( i-- ) {
notifyDependantsAtPriority( ractive, childDeps[ i ], priority, onlyDirect );
}
}
}
function notifyPatternObservers( ractive, registeredKeypath, actualKeypath, isParentOfChangedKeypath, isTopLevelCall ) {
var i, patternObserver, children, child, key, childActualKeypath, potentialWildcardMatches, cascade;
i = ractive._patternObservers.length;
while ( i-- ) {
patternObserver = ractive._patternObservers[ i ];
if ( patternObserver.regex.test( actualKeypath ) ) {
patternObserver.update( actualKeypath );
}
}
if ( isParentOfChangedKeypath ) {
return;
}
cascade = function( keypath ) {
if ( children = ractive._depsMap[ keypath ] ) {
i = children.length;
while ( i-- ) {
child = children[ i ];
key = lastKey.exec( child )[ 0 ];
childActualKeypath = actualKeypath + '.' + key;
notifyPatternObservers( ractive, child, childActualKeypath );
}
}
};
if ( isTopLevelCall ) {
potentialWildcardMatches = getPotentialWildcardMatches( actualKeypath );
potentialWildcardMatches.forEach( cascade );
} else {
cascade( registeredKeypath );
}
}
function getPotentialWildcardMatches( keypath ) {
var keys, starMap, mapper, i, result, wildcardKeypath;
keys = keypath.split( '.' );
starMap = getStarMap( keys.length );
result = [];
mapper = function( star, i ) {
return star ? '*' : keys[ i ];
};
i = starMap.length;
while ( i-- ) {
wildcardKeypath = starMap[ i ].map( mapper ).join( '.' );
if ( !result[ wildcardKeypath ] ) {
result.push( wildcardKeypath );
result[ wildcardKeypath ] = true;
}
}
return result;
}
function getStarMap( num ) {
var ones = '',
max, binary, starMap, mapper, i;
if ( !starMaps[ num ] ) {
starMap = [];
while ( ones.length < num ) {
ones += 1;
}
max = parseInt( ones, 2 );
mapper = function( digit ) {
return digit === '1';
};
for ( i = 0; i <= max; i += 1 ) {
binary = i.toString( 2 );
while ( binary.length < num ) {
binary = '0' + binary;
}
starMap[ i ] = Array.prototype.map.call( binary, mapper );
}
starMaps[ num ] = starMap;
}
return starMaps[ num ];
}
}();
var shared_makeTransitionManager = function( removeFromArray ) {
var makeTransitionManager, checkComplete, remove, init;
makeTransitionManager = function( callback, previous ) {
var transitionManager = [];
transitionManager.detachQueue = [];
transitionManager.remove = remove;
transitionManager.init = init;
transitionManager._check = checkComplete;
transitionManager._callback = callback;
transitionManager._previous = previous;
if ( previous ) {
previous.push( transitionManager );
}
return transitionManager;
};
checkComplete = function() {
var element;
if ( this._ready && !this.length ) {
while ( element = this.detachQueue.pop() ) {
element.detach();
}
if ( typeof this._callback === 'function' ) {
this._callback();
}
if ( this._previous ) {
this._previous.remove( this );
}
}
};
remove = function( transition ) {
removeFromArray( this, transition );
this._check();
};
init = function() {
this._ready = true;
this._check();
};
return makeTransitionManager;
}( utils_removeFromArray );
var global_runloop = function( circular, css, removeFromArray, getValueFromCheckboxes, resolveRef, getUpstreamChanges, notifyDependants, makeTransitionManager ) {
circular.push( function() {
get = circular.get;
set = circular.set;
} );
var runloop, get, set, dirty = false,
flushing = false,
pendingCssChanges, inFlight = 0,
toFocus = null,
liveQueries = [],
decorators = [],
transitions = [],
observers = [],
attributes = [],
evaluators = [],
selectValues = [],
checkboxKeypaths = {}, checkboxes = [],
radios = [],
unresolved = [],
instances = [],
transitionManager;
runloop = {
start: function( instance, callback ) {
if ( instance && !instances[ instance._guid ] ) {
instances.push( instance );
instances[ instances._guid ] = true;
}
if ( !flushing ) {
inFlight += 1;
transitionManager = makeTransitionManager( callback, transitionManager );
}
},
end: function() {
if ( flushing ) {
attemptKeypathResolution();
return;
}
if ( !--inFlight ) {
flushing = true;
flushChanges();
flushing = false;
land();
}
transitionManager.init();
transitionManager = transitionManager._previous;
},
trigger: function() {
if ( inFlight || flushing ) {
attemptKeypathResolution();
return;
}
flushing = true;
flushChanges();
flushing = false;
land();
},
focus: function( node ) {
toFocus = node;
},
addLiveQuery: function( query ) {
liveQueries.push( query );
},
addDecorator: function( decorator ) {
decorators.push( decorator );
},
addTransition: function( transition ) {
transition._manager = transitionManager;
transitionManager.push( transition );
transitions.push( transition );
},
addObserver: function( observer ) {
observers.push( observer );
},
addAttribute: function( attribute ) {
attributes.push( attribute );
},
scheduleCssUpdate: function() {
if ( !inFlight && !flushing ) {
css.update();
} else {
pendingCssChanges = true;
}
},
addEvaluator: function( evaluator ) {
dirty = true;
evaluators.push( evaluator );
},
addSelectValue: function( selectValue ) {
dirty = true;
selectValues.push( selectValue );
},
addCheckbox: function( checkbox ) {
if ( !checkboxKeypaths[ checkbox.keypath ] ) {
dirty = true;
checkboxes.push( checkbox );
}
},
addRadio: function( radio ) {
dirty = true;
radios.push( radio );
},
addUnresolved: function( thing ) {
dirty = true;
unresolved.push( thing );
},
removeUnresolved: function( thing ) {
removeFromArray( unresolved, thing );
},
detachWhenReady: function( thing ) {
transitionManager.detachQueue.push( thing );
}
};
circular.runloop = runloop;
return runloop;
function land() {
var thing, changedKeypath, changeHash;
if ( toFocus ) {
toFocus.focus();
toFocus = null;
}
while ( thing = attributes.pop() ) {
thing.update().deferred = false;
}
while ( thing = liveQueries.pop() ) {
thing._sort();
}
while ( thing = decorators.pop() ) {
thing.init();
}
while ( thing = transitions.pop() ) {
thing.init();
}
while ( thing = observers.pop() ) {
thing.update();
}
while ( thing = instances.pop() ) {
instances[ thing._guid ] = false;
if ( thing._changes.length ) {
changeHash = {};
while ( changedKeypath = thing._changes.pop() ) {
changeHash[ changedKeypath ] = get( thing, changedKeypath );
}
thing.fire( 'change', changeHash );
}
}
if ( pendingCssChanges ) {
css.update();
pendingCssChanges = false;
}
}
function flushChanges() {
var thing, upstreamChanges, i;
i = instances.length;
while ( i-- ) {
thing = instances[ i ];
if ( thing._changes.length ) {
upstreamChanges = getUpstreamChanges( thing._changes );
notifyDependants.multiple( thing, upstreamChanges, true );
}
}
attemptKeypathResolution();
while ( dirty ) {
dirty = false;
while ( thing = evaluators.pop() ) {
thing.update().deferred = false;
}
while ( thing = selectValues.pop() ) {
thing.deferredUpdate();
}
while ( thing = checkboxes.pop() ) {
set( thing.root, thing.keypath, getValueFromCheckboxes( thing.root, thing.keypath ) );
}
while ( thing = radios.pop() ) {
thing.update();
}
}
}
function attemptKeypathResolution() {
var array, thing, keypath;
if ( !unresolved.length ) {
return;
}
array = unresolved.splice( 0, unresolved.length );
while ( thing = array.pop() ) {
if ( thing.keypath ) {
continue;
}
keypath = resolveRef( thing.root, thing.ref, thing.parentFragment );
if ( keypath !== undefined ) {
thing.resolve( keypath );
} else {
unresolved.push( thing );
}
}
}
}( circular, global_css, utils_removeFromArray, shared_getValueFromCheckboxes, shared_resolveRef, shared_getUpstreamChanges, shared_notifyDependants, shared_makeTransitionManager );
var shared_animations = function( rAF, getTime, runloop ) {
var queue = [];
var animations = {
tick: function() {
var i, animation, now;
now = getTime();
runloop.start();
for ( i = 0; i < queue.length; i += 1 ) {
animation = queue[ i ];
if ( !animation.tick( now ) ) {
queue.splice( i--, 1 );
}
}
runloop.end();
if ( queue.length ) {
rAF( animations.tick );
} else {
animations.running = false;
}
},
add: function( animation ) {
queue.push( animation );
if ( !animations.running ) {
animations.running = true;
rAF( animations.tick );
}
},
abort: function( keypath, root ) {
var i = queue.length,
animation;
while ( i-- ) {
animation = queue[ i ];