-
Notifications
You must be signed in to change notification settings - Fork 16
/
a.ie8.js
2444 lines (2038 loc) · 84.5 KB
/
a.ie8.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
/** @license ES6/DOM4 polyfill for IE8 | @version 0.7 final | MIT License | github.com/termi */
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @warning_level VERBOSE
// @jscomp_warning missingProperties
// @output_file_name a.ie8.js
// @check_types
// ==/ClosureCompiler==
/**
* ES5 and DOM shim for IE < 8
* @version 0.7 alpha-3
* TODO::
* 1. http://www.positioniseverything.net/explorer.html
*/
// [[[|||---=== GCC DEFINES START ===---|||]]]
/** @define {boolean} */
var __GCC__IS_DEBUG__ = false;
//IF __GCC____GCC__IS_DEBUG____ == true [
//0. Some errors in console
//1. Fix console From https://github.com/theshock/console-cap/blob/master/console.js
//]
/** @define {boolean} */
var __GCC__NODE_CONSTRUCTOR_AS_ACTIVX__ = true;
/** @define {boolean} */
var __GCC__NODE_CONSTRUCTOR_AS_DOM_ELEMENT__ = false;
/** @define {boolean} */
var __GCC__INCLUDE_DOMPARSER_SHIM__ = false;
/** @define {boolean} */
var __GCC__UNSTABLE_FUNCTIONS__ = false;
/** @define {boolean} */
var __GCC__FIX_OBJECT_DEFINE_PROPERTY_SET_VALUE_NOT_IGNORING_SETTER__ = true;
//IF __GCC____GCC__UNSTABLE_FUNCTIONS____ == true [
//]
// [[[|||---=== GCC DEFINES END ===---|||]]]
;(function(global, _append) {
/** Browser sniffing
* GCC W U NO SUPPORT @cc ?
* @type {boolean} */
var _browser_msie = window.eval && eval("/*@cc_on 1;@*/") && +((/msie (\d+)/i.exec(navigator.userAgent) || [])[1] || 0) || void 0;
if(!(_browser_msie < 9))return;
/** @const @type {boolean} */
var DEBUG = __GCC__IS_DEBUG__;
if(!global["Element"])((global["Element"] =
//Reprisent ActiveXObject as Node, Element and HTMLElement so `<element> instanceof Node` is working (!!!But no in IE9 with in "compatible mode")
__GCC__NODE_CONSTRUCTOR_AS_ACTIVX__ ? ActiveXObject : __GCC__NODE_CONSTRUCTOR_AS_DOM_ELEMENT__ ? document.createTextNode("") : {}
).prototype)["ie"] = true;//fake prototype for IE < 8
if(!global["HTMLElement"])global["HTMLElement"] = global["Element"];//IE8
if(!global["Node"])global["Node"] = global["Element"];//IE8
var _temoObj;
//Not sure if it wrong. TODO:: tests for this
if(!global["DocumentFragment"]) {
global["DocumentFragment"] =
global["Document"] || global["HTMLDocument"] ||//For IE8
(_temoObj = function(){}, _temoObj.prototype = {}, _temoObj);//For IE < 8
}
if(!global["Document"])global["Document"] = global["DocumentFragment"];
global["_"] = {
"ielt9shims" : [],
"orig_" : global["_"]//Save original "_" - we will restore it in a.js
};
var _ = global["_"]["ielt9shims"]//"_" - container for shims what should be use in a.js
/** @const */
, document_createDocumentFragment = document.createDocumentFragment
/** @const */
, document_createElement = document.createElement
/** @const */
, document_createTextNode = document.createTextNode
/** @const */
, _document_documentElement = document.documentElement
/** @const */
, _throw = function(errStr) {
throw errStr instanceof Error ? errStr : new Error(errStr);
}
/** @const */
, _throwDOMException = function(errStr) {
var ex = Object.create(DOMException.prototype);
ex.code = DOMException[errStr];
ex.message = errStr +': DOM Exception ' + ex.code;
throw ex;
}
/** @const */
, _recursivelyWalk = function (nodes, cb) {
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i],
ret = cb(node);
if (ret) {
return ret;
}
if (node.childNodes && node.childNodes.length > 0) {
ret = _recursivelyWalk(node.childNodes, cb);
if (ret) {
return ret;
}
}
}
}
/** @const */
, _safeExtend = function(obj, extention) {
for(var key in extention)
if(_hasOwnProperty(extention, key) && obj[key] !== extention[key])
try {//prevent IE error "invalid argument."
obj[key] = extention[key];
}
catch(e) { }
return obj;
}
/**
* @const
* Use native and probably broken function or Quick and safety for large string but non-full-standard function
* For system use only
* More standart solution in a.js
*/
, _String_trim = String.prototype.trim || function () {//Cache origin trim function
var str = this.replace(RE_left_spaces, ''),
i = str.length;
while (RE_space.test(str.charAt(--i))){}
return str.slice(0, i + 1);
}
/** @const */
, _String_split = String.prototype.split
/** @const */
, _String_substr = String.prototype.substr
/** @const */
, _Array_slice = Array.prototype.slice
/** @const */
, _Function_apply = Function.prototype.apply
/** @const */
, _Function_call = Function.prototype.call
/** Use native "bind" or unsafe bind for service and performance needs
* @const
* @param {Object} object
* @param {...} var_args
* @return {Function} */
, _unSafeBind = Function.prototype.bind || function(object, var_args) {
var __method = this,
args = _Array_slice.call(arguments, 1);
return function () {
return _Function_apply.call(__method, object, args.concat(_Array_slice.call(arguments)));
}
}
/** @const */
, _hasOwnProperty = _unSafeBind.call(Function.prototype.call, Object.prototype.hasOwnProperty)
/** @type {Node} */
, _testElement = document.createElement('p')
, _txtTextElement
, _Node_prototype = global["Node"].prototype
, _Element_prototype = global["Element"].prototype
/** @const */
, _Node_contains = _testElement.contains || _Node_prototype.contains//TODO:: massive testing
/** @const */
, _Native_Date = Date
/** @const @type {RegExp} */
, RE_cloneElement_tagMatcher = /^\<([\w\:\-]*)[\>\ ]/i
/** @const @type {RegExp} */
, RE_left_spaces = /^\s+/
/** @const @type {RegExp} */
, RE_space = /\s/
/** @type {boolean} */
, _String_split_shim_isnonparticipating
/** @type {*} */
, _tmp_
/** @type {Function} */
, function_tmp
, nodeList_methods_fromArray = ["every", "filter", "forEach", "indexOf", "join", "lastIndexOf", "map", "reduce", "reduceRight", "reverse", "slice", "some", "toString"]
/** @const */
, RE_style_alpha_filter = /alpha\(opacity=([^\)]+)\)/
/** @const */
, STRING_FOR_RE_style_important = "\\s*:\\s*(\\S+)\\s*(?:[$;]|(?:(!important)\\s*[$;]))"
/** @type {Function}
* @this {Node} */
, style_getOpacityFromMSFilter = function() {
var val = (this.filter || "").match(RE_style_alpha_filter);
return val ? (parseInt(val[1]) / 100) + "" : "";//can't replace parseInt to '+(val[1])'
}
, _CSSStyleDeclaration_prototype_methods = {
/**
* @param {String} propertyName
* @return String
*/
"getPropertyValue" : function(propertyName) {
return this.getAttribute(propertyName);
}
/**
* @param {String} propertyName
* @return String
*/
, "removeProperty" : function(propertyName) {
this.removeAttribute(propertyName);
}
/**
* @param {String} propertyName
* @param {String} value
* @param {String} priority
* @return void
*/
, "setProperty" : function(propertyName, value, priority) {
if(priority != "important") {
this.setAttribute(propertyName, value);
}
else {
var reg = new RegExp(propertyName + STRING_FOR_RE_style_important, "i")
, val = ";" + propertyName + ":" + value + " !important;"
;
if(reg.test(this.cssText)) {
this.cssText = this.cssText.replace(reg, val)
}
else this.cssText = this.cssText + val;
}
}
/**
@param {String} propertyName
@return String
*/
, "getPropertyPriority" : function(propertyName) {
var reg = new RegExp(propertyName + STRING_FOR_RE_style_important, "i");
return ((this.cssText || "").match(reg) || [])[2] || "";
}
/**
@param {Number} index
@return String
*/
, "item" : function(index) {
//TODO::
}
}
, ATTRIBUTES_CUSTOM = {
'for': 'htmlFor',
'class': 'className',
'value': 'defaultValue'
}
// attribute referencing URI data values need special treatment in IE | From nwmatcher
, ATTRIBUTE_URIDATA = {
'action': null,
'cite': null,
'codebase': null,
'data': null,
'href': null,
'longdesc': null,
'lowsrc': null,
'src': null,
'usemap': null
}
, DEFAULT_ATTRIBUTES_MAP = {
'id': true,
'value': true,
'checked': true,
'disabled': true,
'ismap': true,
'multiple': true,
'readonly': true,
'selected': true
}
// ------------------------------ ================== Events ================== ------------------------------
, _ielt9_Event
/** @type {Object} */
, _EventInitFunctions
, _Event_prototype
/** @const @type {string} */
, _event_UUID_prop_name = "uuid"
/** @type {number} unique indentifier for event listener */
, _event_UUID = 1//MUST be more then 0 | 0 - using for DOM0 events
/** @const @type {string} */
, _event_handleUUID = "_h_9e2"
/** @const @type {string} */
, _event_eventsUUID = "_e_8vj"
/** @const @type {string} */
, _event_nativeEventPropName = "ietl9_event"
/** @const @type {Function */
, _event_emptyFunction = function(){}
/** @const @type {Object} */
, _event_needCapturing = {}
/** @type {boolean} */
, _event_globalIsCaptureIndicator = false
/** @type {Array.<Node>} */
, _event_captureHandlerNodes = []
, __is__DOMContentLoaded
// ------------------------------ ================== HTML5 shiv ================== ------------------------------
, html5_elements = 'abbr|article|aside|audio|canvas|command|datalist|details|figure|figcaption|footer|header|hgroup|keygen|mark|meter|nav|output|progress|section|source|summary|time|video'
, html5_elements_array = html5_elements.split('|')
/* Not all elements can be cloned in IE (this list can be shortend) **/
, ielt9_elements = /^<|^(?:a|b|button|code|div|fieldset|form|map|h1|h2|h3|h4|h5|h6|i|object|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul|optgroup)$/i
// feature detection: whether the browser supports unknown elements
/** @type {boolean}*/
, supportsUnknownElements
, safeFragment
/** @type {Node} */
, safeElement
, _nativeCloneNode
, _getScrollX
, _getScrollY
;
document.compatMode === "CSS1Compat" ?
((_getScrollX = function(){return _document_documentElement.scrollLeft}), (_getScrollY = function(){return _document_documentElement.scrollTop}))
:
((_getScrollX = function(){return document.body.scrollTop}), (_getScrollY = function(){return document.body.scrollLeft}))
;
/*
TODO:: http://code.jquery.com/jquery-1.7.2.js:1537
var support = {};
// Run tests that need a body at doc ready
document.addEventListener('DOMContentLoaded', function() {
var container, outer, inner, table, td, offsetSupport,
marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
paddingMarginBorderVisibility, paddingMarginBorder,
body = document.getElementsByTagName("body")[0];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
}
conMarginTop = 1;
paddingMarginBorder = "padding:0;margin:0;border:";
positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
"<table " + style + "' cellpadding='0' cellspacing='0'>" +
"<tr><td></td></tr></table>";
container = document.createElement("div");
container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
body.insertBefore( container, body.firstChild );
// Construct the test element
div = document.createElement("div");
container.appendChild( div );
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
// (only IE 8 fails this test)
div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
tds = div.getElementsByTagName( "td" );
isSupported = ( tds[ 0 ].offsetHeight === 0 );
tds[ 0 ].style.display = "";
tds[ 1 ].style.display = "none";
// Check if empty table cells still have offsetWidth/Height
// (IE <= 8 fail this test)
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. For more
// info see bug #3333
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
if ( window.getComputedStyle ) {
div.innerHTML = "";
marginDiv = document.createElement( "div" );
marginDiv.style.width = "0";
marginDiv.style.marginRight = "0";
div.style.width = "2px";
div.appendChild( marginDiv );
support.reliableMarginRight =
( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
}
if ( typeof div.style.zoom !== "undefined" ) {
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
// (IE < 8 does this)
div.innerHTML = "";
div.style.width = div.style.padding = "1px";
div.style.border = 0;
div.style.overflow = "hidden";
div.style.display = "inline";
div.style.zoom = 1;
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
// Check if elements with layout shrink-wrap their children
// (IE 6 does this)
div.style.display = "block";
div.style.overflow = "visible";
div.innerHTML = "<div style='width:5px;'></div>";
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
}
div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
div.innerHTML = html;
outer = div.firstChild;
inner = outer.firstChild;
td = outer.nextSibling.firstChild.firstChild;
offsetSupport = {
doesNotAddBorder: ( inner.offsetTop !== 5 ),
doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
};
inner.style.position = "fixed";
inner.style.top = "20px";
// safari subtracts parent border width here which is 5px
offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
inner.style.position = inner.style.top = "";
outer.style.overflow = "hidden";
outer.style.position = "relative";
offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
if ( window.getComputedStyle ) {
div.style.marginTop = "1%";
support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
}
if ( typeof container.style.zoom !== "undefined" ) {
container.style.zoom = 1;
}
body.removeChild( container );
marginDiv = div = container = null;
jQuery.extend( support, offsetSupport );
});
return support;
});
*/
//Emulating HEAD for ie < 9
document.head || (document.head = document.getElementsByTagName('head')[0]);
"defaultView" in document || (document.defaultView = document.parentWindow);
if(DEBUG) {
//test DOMElement is an ActiveXObject
if(!(_Function_call.call(document_createElement, document, "div") instanceof ActiveXObject))
console.error("DOMElement is not an ActiveXObject. Probably you in IE > 8 'compatible mode'. <element> instanceof [Node|Element|HTMLElement] wouldn't work");
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Function.prototype ================================== */
/* ======================================================================================= */
//Fix Function.prototype.apply to work with generic array-like object instead of an array
// test: (function(a,b){console.log(a,b)}).apply(null, {0:1,1:2,length:2})
_tmp_ = false;
try {
_tmp_ = isNaN.apply(null, {})
}
catch(e) { }
if(!_tmp_) {
Function.prototype.apply = function(contexts, args) {
try {
return args != void 0 ?
_Function_apply.call(this, contexts, args) :
_Function_apply.call(this, contexts);
}
catch (e) {
if(e["number"] != -2146823260 ||//"Function.prototype.apply: Arguments list has wrong type"
args.length === void 0 || //Not an iterable object
typeof args === "string"//Avoid using String
)
_throw(e);
return _Function_apply.call(this, contexts, Array["from"](args));
}
};
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Function.prototype ================================== */
/* ======================================================================================= */
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> String.prototype ================================== */
/* ======================================================================================= */
// String.prototype.substr shim
//[BUGFIX, IE lt 9] IE < 9 substr() with negative value not working in IE
if("ab".substr(-1) !== "b") {
//String.prototype._itlt9_substr_ = String.prototype.substr;
String.prototype.substr = function(start, length) {
return _String_substr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
}
}
/*
[BUGFIX, IE lt 9, old safari] http://blog.stevenlevithan.com/archives/cross-browser-split
More better solution:: http://xregexp.com/
*/
if('te'.split(/(s)*/)[1] != void 0 ||
'1_1'.split(/(_)/).length != 3) {
_String_split_shim_isnonparticipating = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
String.prototype.split = function (separator, limit) {
var str = this;
// if `separator` is not a regex, use the native `split`
if(!(separator instanceof RegExp)) {//if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
//http://es5.github.com/#x15.5.4.14
//If separator is undefined, then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined, then the output array is truncated so that it contains no more than limit elements.
if(separator === void 0 && limit === 0)return [];
return _String_split.call(str, separator, limit);
}
var output = [],
lastLastIndex = 0,
flags = (separator.ignoreCase ? "i" : "") +
(separator.multiline ? "m" : "") +
(separator.sticky ? "y" : ""),
separator1 = new RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues by working with a copy
separator2 = null, match, lastIndex, lastLength;
str = str + ""; // type conversion
if (!_String_split_shim_isnonparticipating) {
separator2 = new RegExp("^" + separator1.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt
}
/* behavior for `limit`: if it's...
- `undefined`: no limit.
- `NaN` or zero: return an empty array.
- a positive number: use `Math.floor(limit)`.
- a negative number: no limit.
- other: type-convert, then use the above rules. */
if (limit === void 0 || +limit < 0) {
limit = Infinity;
} else {
limit = Math.floor(+limit);
if (!limit) {
return [];
}
}
while (match = separator1.exec(str)) {
lastIndex = match.index + match[0].length; // `separator1.lastIndex` is not reliable cross-browser
if (lastIndex > lastLastIndex) {
output.push(str.slice(lastLastIndex, match.index));
// fix browsers whose `exec` methods don't consistently return `undefined` for nonparticipating capturing groups
// __ NOT WORKING __ !!!!
if (!_String_split_shim_isnonparticipating && match.length > 1) {
match[0].replace(separator2, function() {
for (var i = 1, a = arguments, l = a.length - 2; i < l; i++) {//for (var i = 1; i < arguments.length - 2; i++) {
if (a[i] === void 0) {
match[i] = void 0;
}
}
});
}
if (match.length > 1 && match.index < str.length) {
output.push.apply(output, match.slice(1));//Array.prototype.push.apply(output, match.slice(1));
}
lastLength = match[0].length;
lastLastIndex = lastIndex;
if (output.length >= limit) {
break;
}
}
if (separator1.lastIndex === match.index) {
separator1.lastIndex++; // avoid an infinite loop
}
}
if (lastLastIndex === str.length) {
if (lastLength || !separator1.test("")) {
output.push("");
}
} else {
output.push(str.slice(lastLastIndex));
}
return output.length > limit ? output.slice(0, limit) : output;
}
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> String.prototype ================================== */
/* ======================================================================================= */
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Exception ================================== */
/* ======================================================================================= */
if(!global["DOMException"]) {
_tmp_ = (global["DOMException"] = function() { }).prototype = new Error;
_tmp_.INDEX_SIZE_ERR = 1;
//p.DOMSTRING_SIZE_ERR = 2; // historical
_tmp_.HIERARCHY_REQUEST_ERR = 3;
_tmp_.WRONG_DOCUMENT_ERR = 4;
_tmp_.INVALID_CHARACTER_ERR = 5;
//p.NO_DATA_ALLOWED_ERR = 6; // historical
_tmp_.NO_MODIFICATION_ALLOWED_ERR = 7;
_tmp_.NOT_FOUND_ERR = 8;
_tmp_.NOT_SUPPORTED_ERR = 9;
//p.INUSE_ATTRIBUTE_ERR = 10; // historical
_tmp_.INVALID_STATE_ERR = 11;
_tmp_.SYNTAX_ERR = 12;
_tmp_.INVALID_MODIFICATION_ERR = 13;
_tmp_.NAMESPACE_ERR = 14;
_tmp_.INVALID_ACCESS_ERR = 15;
//p.VALIDATION_ERR = 16; // historical
_tmp_.TYPE_MISMATCH_ERR = 17;
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Exception ================================== */
/* ======================================================================================= */
/* ====================================================================================== */
/* ====================================== Window <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
//http://javascript.gakaa.com/window-scrollx-2-0-scrolly.aspx
if(!("pageXOffset" in global)) {
_.push(function() {
Object.defineProperty(global, "pageXOffset", {"get" : _getScrollX});
Object.defineProperty(global, "pageYOffset", {"get" : _getScrollY});
});
}
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Window ====================================== */
/* ====================================================================================== */
/* ====================================================================================== */
/* ====================================== Events <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
/** @constructor */
function_tmp = global["Event"] = function() {
//new operator for Event supported in a.js
_throw("");
};
_EventInitFunctions = {
/**
* @param {string=} _type
* @param {boolean=} _bubbles
* @param {boolean=} _cancelable
*/
"initEvent" : function(_type, _bubbles, _cancelable) {
if(_type == void 0 || _bubbles == void 0 || _cancelable == void 0) {
//WRONG_ARGUMENTS_ERR
_throw('WRONG_ARGUMENTS_ERR');
}
var thisObj = this;
thisObj.type = _type;
//this.cancelBubble = //TODO:: <-- testing | Need this ???
// !(this.bubbles = _bubbles);
thisObj.bubbles = _bubbles;
thisObj.cancelable = _cancelable;//https://developer.mozilla.org/en/DOM/event.cancelable
thisObj.isTrusted = false;
thisObj.target = null;
if(!thisObj.timeStamp)thisObj.timeStamp = +new _Native_Date();
}
,
"initCustomEvent" : function(_type, _bubbles, _cancelable, _detail) {
//https://developer.mozilla.org/en/DOM/CustomEvent
_EventInitFunctions["initEvent"].call(this, _type, _bubbles, _cancelable);
this.detail = _detail;
}
,
"initUIEvent" : function(_type, _bubbles, _cancelable, _view, _detail) {
//https://developer.mozilla.org/en/DOM/event.initUIEvent
_EventInitFunctions["initCustomEvent"].call(this, _type, _bubbles, _cancelable, _detail);
this.view = _view;
}
,
"initMouseEvent" : function(_type, _bubbles, _cancelable, _view,
_detail, _screenX, _screenY, _clientX, _clientY,
_ctrlKey, _altKey, _shiftKey, _metaKey,
_button, _relatedTarget) {
var thisObj = this;
//https://developer.mozilla.org/en/DOM/event.initMouseEvent
_EventInitFunctions["initUIEvent"].call(thisObj, _type, _bubbles, _cancelable, _view, _detail);
thisObj.screenX = _screenX;
thisObj.screenY = _screenY;
thisObj.clientX = _clientX;
thisObj.clientY = _clientY;
thisObj.ctrlKey = _ctrlKey;
thisObj.altKey = _altKey;
thisObj.shiftKey = _shiftKey;
thisObj.metaKey = _metaKey;
thisObj.button = _button;
thisObj.relatedTarget = _relatedTarget;
}
};
_Event_prototype = function_tmp.prototype = {
constructor : function_tmp,
/** @this {_ielt9_Event} @lends {function_tmp.prototype}*/
"preventDefault" : function() {
if(this.cancelable === false)return;
_ielt9_Event.getNativeEvent.call(this)["returnValue"] = this["returnValue"] = false;
_ielt9_Event.destroyLinkToNativeEvent.call(this);
this["defaultPrevented"] = true;
} ,
/** @this {_ielt9_Event} @lends {function_tmp.prototype} */
"stopPropagation" : function() {
_ielt9_Event.getNativeEvent.call(this)["cancelBubble"] = this["cancelBubble"] = true;
_ielt9_Event.destroyLinkToNativeEvent.call(this);
}
};
/** @this {_ielt9_Event} */
_Event_prototype["stopImmediatePropagation"] = function() {
this["__stopNow"] = true;
this.stopPropagation();
};
_Event_prototype["defaultPrevented"] = false;
for(_tmp_ in _EventInitFunctions)if(_hasOwnProperty(_EventInitFunctions, _tmp_)) {
_Event_prototype[_tmp_] = function() {
_EventInitFunctions[arguments.callee["name"]].apply(this, arguments);
_safeExtend(this[_event_nativeEventPropName], this);
};
_Event_prototype[_tmp_]["name"] = _tmp_;
}
/** @constructor Event constructor for document.createEvent and commonHandle */
_ielt9_Event = function(nativeEvent) {
this[_event_nativeEventPropName] = nativeEvent;
nativeEvent.returnValue = true;//default value
_safeExtend(this, nativeEvent);
};
/** @this {_ielt9_Event} */
_ielt9_Event.getNativeEvent = function() {
var nativeEvent = this[_event_nativeEventPropName];
if(nativeEvent === void 0) {
_throw("WRONG_THIS_ERR")
}
else if(nativeEvent === null) {
//_ielt9_Event.destroyLinkToNativeEvent was fired
nativeEvent = _ielt9_Event.getNativeEvent.fakeObject;
}
return nativeEvent;
};
_ielt9_Event.getNativeEvent.fakeObject = {};
/** @this {_ielt9_Event} */
_ielt9_Event.destroyLinkToNativeEvent = function() {
if(this[_event_nativeEventPropName]) {
this[_event_nativeEventPropName] = null;
}
};
//inherit _ielt9_Event from Event
/** @constructor */
function_tmp = function() { };
function_tmp.prototype = _Event_prototype;
function_tmp = new function_tmp;
function_tmp.constructor = _ielt9_Event;
_ielt9_Event.prototype = function_tmp;
//fix [add|remove]EventListener & dispatchEvent for IE < 9
// See: https://github.com/arexkun/Vine
// https://github.com/kbjr/Events.js
// Use this for tests: http://ie.microsoft.com/testdrive/HTML5/ComparingEventModels/Default.html
function fixEvent(event) {
if("__isFixed" in event)return;
var thisObj = this,
_button = ("button" in event) && event.button;
// один объект события может передаваться по цепочке разным обработчикам
// при этом кроссбраузерная обработка будет вызвана только 1 раз
// Снизу, в функции commonHandle,, мы должны проверять на !event["__isFixed"]
event["__isFixed"] = true;// пометить событие как обработанное
//http://javascript.gakaa.com/event-detail.aspx
//http://www.w3.org/TR/2011/WD-DOM-Level-3-Events-20110531/#event-type-click
//indicates the current click count; the attribute value must be 1 when the user begins this action and increments by 1 for each click.
if(event.type === "click" || event.type === "dblclick") {
if(event.detail === void 0)event.detail = event.type === "click" ? 1 : 2;
if(!event.button && fixEvent._clickButton !== void 0)_button = fixEvent._clickButton;
}
_append(event, _Event_prototype);
if(!event["defaultPrevented"])event["defaultPrevented"] = false;
if(!event.target)event.target = event.srcElement || document;// добавить target для IE
/*
if ( event.target && event.target.nodeType in {3 : void 0, 4 : void 0} ) {
event.target = event.target.parentNode;
}
*/
// добавить relatedTarget в IE, если это нужно
if(event.relatedTarget === void 0 && event.fromElement)
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
/*
event.relatedTarget = event.relatedTarget ||
event.type == 'mouseout' ? event.toElement :
event.type == 'mouseover' ? event.fromElement : null;
*/
// вычислить pageX/pageY для IE
if("clientX" in event && event.pageX == null) {
/*event.pageX = event.clientX + (_document_documentElement.scrollLeft || body && body.scrollLeft || 0) - (_document_documentElement.clientLeft || 0);
event.pageY = event.clientY + (_document_documentElement.scrollTop || body && body.scrollTop || 0) - (_document_documentElement.clientTop || 0);*/
//Новая вервия нуждающаяся в проверки
event.pageX = event.clientX + _getScrollX() - (_document_documentElement.clientLeft || 0);
event.pageY = event.clientY + _getScrollY() - (_document_documentElement.clientTop || 0);
}
//Add 'which' for click: 1 == left; 2 == middle; 3 == right
//Unfortunately the event.button property is not set for click events. It is however set for mouseup/down/move ... but not click | http://bugs.jquery.com/ticket/4164 <- It is fixing now
if(!event.which && _button)event.which = _button & 1 ? 1 : _button & 2 ? 3 : _button & 4 ? 2 : 0;
"timeStamp" in event || (event.timeStamp = +new _Native_Date());
"eventPhase" in event || (event.eventPhase = (event.target == thisObj) ? 2 : 3); // "AT_TARGET" = 2, "BUBBLING_PHASE" = 3
"currentTarget" in event || (event.currentTarget = thisObj);
// событие DOMAttrModified
// TODO:: недоделано
// TODO:: Привести event во всех случаях (для всех браузеров) в одинаковый вид с newValue, prevValue, propName и т.д.
if(!event.attrName && event.propertyName)event.attrName = _String_split.call(event.propertyName, '.')[0];//IE При изменении style.width в propertyName передаст именно style.width, а не style, как нам надо
return event;
}
if( __GCC__UNSTABLE_FUNCTIONS__ ) {
function windowCaptureHandler(nativeEvent) {
var i,
l = _event_captureHandlerNodes.length,
k,
_node;
if(l) {
_event_globalIsCaptureIndicator = true;
nativeEvent.eventPhase = 1;
for(k = l - 1 ; k >= 0 ; --k)commonHandler.call(_event_captureHandlerNodes[k], nativeEvent);
nativeEvent.eventPhase = 3;
for(i = 0 ; i < l ; ++i)commonHandler.call(_event_captureHandlerNodes[i], nativeEvent);
_event_globalIsCaptureIndicator = false;
_event_captureHandlerNodes = [];
}
}
}
// вспомогательный универсальный обработчик. Вызывается в контексте элемента всегда this = element
function commonHandler(nativeEvent) {
if(fixEvent === void 0) {//фильтруем редко возникающую ошибку, когда событие отрабатывает после unload'а страницы.
return;
}
var thisObj = this,
_ = thisObj["_"],
errors,
errorsMessages,
_event,
handlersKey;
if(_["__stop_events__"])return;
if( __GCC__UNSTABLE_FUNCTIONS__ && !_event_globalIsCaptureIndicator && nativeEvent.bubbles !== false && nativeEvent.type in _event_needCapturing && thisObj != global) {
_event_captureHandlerNodes.push(this);
_event = nativeEvent;
}
else {
errors = [];
errorsMessages = [];
handlersKey = _event_eventsUUID + (_event_globalIsCaptureIndicator ? "-" : "");
if((!_ || !_[handlersKey])) {
if(!("__dom0__" in nativeEvent))return;
else {
_ || (_ = {});
_[handlersKey] || (_[handlersKey] = {});
}
}
// получить объект события и проверить, подготавливали мы его для IE или нет
nativeEvent || (nativeEvent = window.event);
if("__custom_event" in nativeEvent) {
_event = nativeEvent;
}
else if(!(_event = nativeEvent["__customEvent__"])) {
if(nativeEvent.bubbles == void 0) {
nativeEvent.bubbles = true;
//TODO::
//nativeEvent.bubbles = bubbleEventMap[nativeEvent.type]
}
if(nativeEvent.cancelable == void 0) {
nativeEvent.cancelable = true;
//TODO::
//nativeEvent.bubbles = cancelableEventMap[nativeEvent.type]
}
// save event properties in fake 'event' object to allow store 'event' and use it in future
_event = nativeEvent["__customEvent__"] = new _ielt9_Event(nativeEvent);
_event.initEvent(nativeEvent.type, nativeEvent.bubbles, nativeEvent.cancelable);
fixEvent.call(this, _event);
_event.isTrusted = true;
_event["__custom_event"] = void 0;