-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.built.js
8058 lines (6565 loc) · 233 KB
/
browser.built.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){
function getListenerMethod(emitter, methodNames){
if(typeof methodNames === 'string'){
methodNames = methodNames.split(' ');
}
for(var i = 0; i < methodNames.length; i++){
if(methodNames[i] in emitter){
return methodNames[i];
}
}
}
function Consuela(){
this._trackedListeners = [];
if(getListenerMethod(this, this._onNames)){
this._watch(this);
}
}
Consuela.init = function(instance){
// If passed a constructor
if(typeof instance === 'function'){
var Constructor = new Function("instance", "Consuela", "return function " + instance.name + "(){Consuela.call(this);return instance.apply(this, arguments);}")(instance, Consuela);
Constructor.prototype = Object.create(instance.prototype);
Constructor.prototype.constructor = Constructor;
Constructor.name = instance.name;
console.log(Constructor.name);
for(var key in Consuela.prototype){
Constructor.prototype[key] = Consuela.prototype[key];
}
return Constructor;
}
// Otherwise, if passed an instance
for(var key in Consuela.prototype){
instance[key] = Consuela.prototype[key];
}
Consuela.call(instance);
};
Consuela.prototype._onNames = 'on addListener addEventListener';
Consuela.prototype._offNames = 'off removeListener removeEventListener';
Consuela.prototype._on = function(emitter, args, offName){
this._trackedListeners.push({
emitter: emitter,
args: args,
offName: offName
});
};
Consuela.prototype._cleanup = function(){
while(this._trackedListeners.length){
var info = this._trackedListeners.pop(),
emitter = info.emitter,
offNames = this._offNames;
if(info.offName){
offNames = [info.offName];
}
emitter[getListenerMethod(info.emitter, offNames)]
.apply(emitter, info.args);
}
};
Consuela.prototype._watch = function(emitter, onName, offName){
var consuela = this,
onNames = this._onNames;
if(onName){
onNames = [onName];
}
var method = getListenerMethod(emitter, onNames),
oldOn = emitter[method];
emitter[method] = function(){
consuela._on(emitter, arguments, offName);
oldOn.apply(emitter, arguments);
};
};
module.exports = Consuela;
},{}],2:[function(require,module,exports){
//Copyright (C) 2012 Kory Nunn
//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.
/*
This code is not formatted for readability, but rather run-speed and to assist compilers.
However, the code's intention should be transparent.
*** IE SUPPORT ***
If you require this library to work in IE7, add the following after declaring crel.
var testDiv = document.createElement('div'),
testLabel = document.createElement('label');
testDiv.setAttribute('class', 'a');
testDiv['className'] !== 'a' ? crel.attrMap['class'] = 'className':undefined;
testDiv.setAttribute('name','a');
testDiv['name'] !== 'a' ? crel.attrMap['name'] = function(element, value){
element.id = value;
}:undefined;
testLabel.setAttribute('for', 'a');
testLabel['htmlFor'] !== 'a' ? crel.attrMap['for'] = 'htmlFor':undefined;
*/
// if the module has no dependencies, the above pattern can be simplified to
(function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
root.crel = factory();
}
}(this, function () {
// based on http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
var isNode = typeof Node === 'object'
? function (object) { return object instanceof Node }
: function (object) {
return object
&& typeof object === 'object'
&& typeof object.nodeType === 'number'
&& typeof object.nodeName === 'string';
};
function crel(){
var document = window.document,
args = arguments, //Note: assigned to a variable to assist compilers. Saves about 40 bytes in closure compiler. Has negligable effect on performance.
element = document.createElement(args[0]),
child,
settings = args[1],
childIndex = 2,
argumentsLength = args.length,
attributeMap = crel.attrMap;
// shortcut
if(argumentsLength === 1){
return element;
}
if(typeof settings !== 'object' || isNode(settings)) {
--childIndex;
settings = null;
}
// shortcut if there is only one child that is a string
if((argumentsLength - childIndex) === 1 && typeof args[childIndex] === 'string' && element.textContent !== undefined){
element.textContent = args[childIndex];
}else{
for(; childIndex < argumentsLength; ++childIndex){
child = args[childIndex];
if(child == null){
continue;
}
if(!isNode(child)){
child = document.createTextNode(child);
}
element.appendChild(child);
}
}
for(var key in settings){
if(!attributeMap[key]){
element.setAttribute(key, settings[key]);
}else{
var attr = crel.attrMap[key];
if(typeof attr === 'function'){
attr(element, settings[key]);
}else{
element.setAttribute(attr, settings[key]);
}
}
}
return element;
}
// Used for mapping one kind of attribute to the supported version of that in bad browsers.
// String referenced so that compilers maintain the property name.
crel['attrMap'] = {};
// String referenced so that compilers maintain the property name.
crel["isNode"] = isNode;
return crel;
}));
},{}],3:[function(require,module,exports){
var pSlice = Array.prototype.slice;
var Object_keys = typeof Object.keys === 'function'
? Object.keys
: function (obj) {
var keys = [];
for (var key in obj) keys.push(key);
return keys;
}
;
var deepEqual = module.exports = function (actual, expected) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (typeof actual != 'object' && typeof expected != 'object') {
return actual == expected;
// 7.4. For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected);
}
}
function isUndefinedOrNull(value) {
return value === null || value === undefined;
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b) {
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return deepEqual(a, b);
}
try {
var ka = Object_keys(a),
kb = Object_keys(b),
key, i;
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!deepEqual(a[key], b[key])) return false;
}
return true;
}
},{}],4:[function(require,module,exports){
var doc = {
document: typeof document !== 'undefined' ? document : null,
setDocument: function(d){
this.document = d;
}
};
var arrayProto = [],
isList = require('./isList');
getTargets = require('./getTargets')(doc.document),
getTarget = require('./getTarget')(doc.document),
space = ' ';
///[README.md]
function isIn(array, item){
for(var i = 0; i < array.length; i++) {
if(item === array[i]){
return true;
}
}
}
/**
## .find
finds elements that match the query within the scope of target
//fluent
doc(target).find(query);
//legacy
doc.find(target, query);
*/
function find(target, query){
target = getTargets(target);
if(query == null){
return target;
}
if(isList(target)){
var results = [];
for (var i = 0; i < target.length; i++) {
var subResults = doc.find(target[i], query);
for(var j = 0; j < subResults.length; j++) {
if(!isIn(results, subResults[j])){
results.push(subResults[j]);
}
}
}
return results;
}
return target ? target.querySelectorAll(query) : [];
};
/**
## .findOne
finds the first element that matches the query within the scope of target
//fluent
doc(target).findOne(query);
//legacy
doc.findOne(target, query);
*/
function findOne(target, query){
target = getTarget(target);
if(query == null){
return target;
}
if(isList(target)){
var result;
for (var i = 0; i < target.length; i++) {
result = findOne(target[i], query);
if(result){
break;
}
}
return result;
}
return target ? target.querySelector(query) : null;
};
/**
## .closest
recurses up the DOM from the target node, checking if the current element matches the query
//fluent
doc(target).closest(query);
//legacy
doc.closest(target, query);
*/
function closest(target, query){
target = getTarget(target);
if(isList(target)){
target = target[0];
}
while(
target &&
target.ownerDocument &&
!is(target, query)
){
target = target.parentNode;
}
return target === doc.document && target !== query ? null : target;
};
/**
## .is
returns true if the target element matches the query
//fluent
doc(target).is(query);
//legacy
doc.is(target, query);
*/
function is(target, query){
target = getTarget(target);
if(isList(target)){
target = target[0];
}
if(!target.ownerDocument || typeof query !== 'string'){
return target === query;
}
return target === query || arrayProto.indexOf.call(find(target.parentNode, query), target) >= 0;
};
/**
## .addClass
adds classes to the target
//fluent
doc(target).addClass(query);
//legacy
doc.addClass(target, query);
*/
function addClass(target, classes){
target = getTargets(target);
if(isList(target)){
for (var i = 0; i < target.length; i++) {
addClass(target[i], classes);
}
return this;
}
if(!classes){
return this;
}
var classes = classes.split(space),
currentClasses = target.classList ? null : target.className.split(space);
for(var i = 0; i < classes.length; i++){
var classToAdd = classes[i];
if(!classToAdd || classToAdd === space){
continue;
}
if(target.classList){
target.classList.add(classToAdd);
} else if(!currentClasses.indexOf(classToAdd)>=0){
currentClasses.push(classToAdd);
}
}
if(!target.classList){
target.className = currentClasses.join(space);
}
return this;
};
/**
## .removeClass
removes classes from the target
//fluent
doc(target).removeClass(query);
//legacy
doc.removeClass(target, query);
*/
function removeClass(target, classes){
target = getTargets(target);
if(isList(target)){
for (var i = 0; i < target.length; i++) {
removeClass(target[i], classes);
}
return this;
}
if(!classes){
return this;
}
var classes = classes.split(space),
currentClasses = target.classList ? null : target.className.split(space);
for(var i = 0; i < classes.length; i++){
var classToRemove = classes[i];
if(!classToRemove || classToRemove === space){
continue;
}
if(target.classList){
target.classList.remove(classToRemove);
continue;
}
var removeIndex = currentClasses.indexOf(classToRemove);
if(removeIndex >= 0){
currentClasses.splice(removeIndex, 1);
}
}
if(!target.classList){
target.className = currentClasses.join(space);
}
return this;
};
function addEvent(settings){
var target = getTarget(settings.target);
if(target){
target.addEventListener(settings.event, settings.callback, false);
}else{
console.warn('No elements matched the selector, so no events were bound.');
}
}
/**
## .on
binds a callback to a target when a DOM event is raised.
//fluent
doc(target/proxy).on(events, target[optional], callback);
note: if a target is passed to the .on function, doc's target will be used as the proxy.
//legacy
doc.on(events, target, query, proxy[optional]);
*/
function on(events, target, callback, proxy){
proxy = getTargets(proxy);
if(!proxy){
target = getTargets(target);
// handles multiple targets
if(isList(target)){
var multiRemoveCallbacks = [];
for (var i = 0; i < target.length; i++) {
multiRemoveCallbacks.push(on(events, target[i], callback, proxy));
}
return function(){
while(multiRemoveCallbacks.length){
multiRemoveCallbacks.pop();
}
};
}
}
// handles multiple proxies
// Already handles multiple proxies and targets,
// because the target loop calls this loop.
if(isList(proxy)){
var multiRemoveCallbacks = [];
for (var i = 0; i < proxy.length; i++) {
multiRemoveCallbacks.push(on(events, target, callback, proxy[i]));
}
return function(){
while(multiRemoveCallbacks.length){
multiRemoveCallbacks.pop();
}
};
}
var removeCallbacks = [];
if(typeof events === 'string'){
events = events.split(space);
}
for(var i = 0; i < events.length; i++){
var eventSettings = {};
if(proxy){
if(proxy === true){
proxy = doc.document;
}
eventSettings.target = proxy;
eventSettings.callback = function(event){
var closestTarget = closest(event.target, target);
if(closestTarget){
callback(event, closestTarget);
}
};
}else{
eventSettings.target = target;
eventSettings.callback = callback;
}
eventSettings.event = events[i];
addEvent(eventSettings);
removeCallbacks.push(eventSettings);
}
return function(){
while(removeCallbacks.length){
var removeCallback = removeCallbacks.pop();
getTarget(removeCallback.target).removeEventListener(removeCallback.event, removeCallback.callback);
}
}
};
/**
## .off
removes events assigned to a target.
//fluent
doc(target/proxy).off(events, target[optional], callback);
note: if a target is passed to the .on function, doc's target will be used as the proxy.
//legacy
doc.off(events, target, callback, proxy);
*/
function off(events, target, callback, proxy){
if(isList(target)){
for (var i = 0; i < target.length; i++) {
off(events, target[i], callback, proxy);
}
return this;
}
if(proxy instanceof Array){
for (var i = 0; i < proxy.length; i++) {
off(events, target, callback, proxy[i]);
}
return this;
}
if(typeof events === 'string'){
events = events.split(space);
}
if(typeof callback !== 'function'){
proxy = callback;
callback = null;
}
proxy = proxy ? getTarget(proxy) : doc.document;
var targets = typeof target === 'string' ? find(target, proxy) : [target];
for(var targetIndex = 0; targetIndex < targets.length; targetIndex++){
var currentTarget = targets[targetIndex];
for(var i = 0; i < events.length; i++){
currentTarget.removeEventListener(events[i], callback);
}
}
return this;
};
/**
## .append
adds elements to a target
//fluent
doc(target).append(children);
//legacy
doc.append(target, children);
*/
function append(target, children){
var target = getTarget(target),
children = getTarget(children);
if(isList(target)){
target = target[0];
}
if(isList(children)){
for (var i = 0; i < children.length; i++) {
append(target, children[i]);
}
return;
}
target.appendChild(children);
};
/**
## .prepend
adds elements to the front of a target
//fluent
doc(target).prepend(children);
//legacy
doc.prepend(target, children);
*/
function prepend(target, children){
var target = getTarget(target),
children = getTarget(children);
if(isList(target)){
target = target[0];
}
if(isList(children)){
//reversed because otherwise the would get put in in the wrong order.
for (var i = children.length -1; i; i--) {
prepend(target, children[i]);
}
return;
}
target.insertBefore(children, target.firstChild);
};
/**
## .isVisible
checks if an element or any of its parents display properties are set to 'none'
//fluent
doc(target).isVisible();
//legacy
doc.isVisible(target);
*/
function isVisible(target){
var target = getTarget(target);
if(!target){
return;
}
if(isList(target)){
var i = -1;
while (target[i++] && isVisible(target[i])) {}
return target.length >= i;
}
while(target.parentNode && target.style.display !== 'none'){
target = target.parentNode;
}
return target === doc.document;
};
/**
## .ready
call a callback when the document is ready.
//fluent
doc().ready(callback);
//legacy
doc.ready(callback);
*/
function ready(target, callback){
if(typeof target === 'function' && !callback){
callback = target;
}
if(doc.document.body){
callback();
}else{
doc.on('load', window, function(){
callback();
});
}
};
doc.find = find;
doc.findOne = findOne;
doc.closest = closest;
doc.is = is;
doc.addClass = addClass;
doc.removeClass = removeClass;
doc.off = off;
doc.on = on;
doc.append = append;
doc.prepend = prepend;
doc.isVisible = isVisible;
doc.ready = ready;
module.exports = doc;
},{"./getTarget":6,"./getTargets":7,"./isList":8}],5:[function(require,module,exports){
var doc = require('./doc'),
isList = require('./isList'),
getTargets = require('./getTargets')(doc.document),
flocProto = [];
function Floc(items){
this.push.apply(this, items);
}
Floc.prototype = flocProto;
flocProto.constructor = Floc;
function floc(target){
var instance = getTargets(target);
if(!isList(instance)){
if(instance){
instance = [instance];
}else{
instance = [];
}
}
return new Floc(instance);
}
for(var key in doc){
if(typeof doc[key] === 'function'){
floc[key] = doc[key];
flocProto[key] = (function(key){
// This is also extremely dodgy and fast
return function(a,b,c,d,e,f){
var result = doc[key](this, a,b,c,d,e,f);
if(result !== doc && isList(result)){
return floc(result);
}
return result;
};
}(key));
}
}
flocProto.on = function(events, target, callback){
var proxy = this;
if(typeof target === 'function'){
callback = target;
target = this;
proxy = null;
}
doc.on(events, target, callback, proxy);
return this;
};
flocProto.off = function(events, target, callback){
var reference = this;
if(typeof target === 'function'){
callback = target;
target = this;
reference = null;
}
doc.off(events, target, callback, reference);
return this;
};
module.exports = floc;
},{"./doc":4,"./getTargets":7,"./isList":8}],6:[function(require,module,exports){
var singleId = /^#\w+$/;
module.exports = function(document){
return function getTarget(target){
if(typeof target === 'string'){
if(singleId.exec(target)){
return document.getElementById(target.slice(1));
}
return document.querySelector(target);
}
return target;
};
};
},{}],7:[function(require,module,exports){
var singleClass = /^\.\w+$/,
singleId = /^#\w+$/,
singleTag = /^\w+$/;
module.exports = function(document){
return function getTargets(target){
if(typeof target === 'string'){
if(singleId.exec(target)){
// If you have more than 1 of the same id in your page,
// thats your own stupid fault.
return [document.getElementById(target.slice(1))];
}
if(singleTag.exec(target)){
return document.getElementsByTagName(target);
}
if(singleClass.exec(target)){
return document.getElementsByClassName(target.slice(1));
}
return document.querySelectorAll(target);
}
return target;
};
};
},{}],8:[function(require,module,exports){
module.exports = function isList(object){
return object !== window && (
object instanceof Array ||
(typeof HTMLCollection !== 'undefined' && object instanceof HTMLCollection) ||
(typeof NodeList !== 'undefined' && object instanceof NodeList) ||
Array.isArray(object)
);
}
},{}],9:[function(require,module,exports){
function fastEach(items, callback) {
for (var i = 0; i < items.length && !callback(items[i], i, items);i++) {}
return items;
}
module.exports = fastEach;
},{}],10:[function(require,module,exports){
var Gaffa = require('gaffa');
function Container(){}
Container = Gaffa.createSpec(Container, Gaffa.ContainerView);
Container.prototype.type = 'container';
Container.prototype.render = function(){
this.views.content.element =
this.renderedElement =
document.createElement(this.tagName || 'div');
};
module.exports = Container;
},{"gaffa":26}],11:[function(require,module,exports){
var Gaffa = require('gaffa'),
crel = require('crel'),
doc = require('doc-js');
function setValue(event){
var input = event.target,
view = input.viewModel;
view.value.set(input.value);
}
function FormElement(){}
FormElement = Gaffa.createSpec(FormElement, Gaffa.View);
FormElement.prototype._type = 'formElement';
FormElement.prototype.render = function(){
var renderedElement = this.renderedElement = this.renderedElement || crel('input'),
formElement = this.formElement = this.formElement || renderedElement,
updateEventNames = (this.updateEventName || "change").split(' ');
this._watch(formElement);
this.gaffa.events.on(this.updateEventName || "change", formElement, setValue);
};
FormElement.prototype.value = new Gaffa.Property(function(view, value){
value = value || '';
var element = view.formElement,
caretPosition = 0,
hasCaret = element === document.activeElement; //this is only necissary because IE10 is a pile of crap (i know what a surprise)
// Skip if the text hasnt changed
if(value === element.value){
return;
}
// Inspiration taken from http://stackoverflow.com/questions/2897155/get-caret-position-within-an-text-input-field
// but WOW is that some horrendous code!
if(hasCaret){
if (window.document.selection) {
var selection = window.document.selection.createRange();
selection.moveStart('character', -element.value.length);