webshims-rails 1.14.3 → 1.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/extras/modernizr-custom.js +4 -0
- data/vendor/assets/javascripts/webshims/polyfiller.js +141 -139
- data/vendor/assets/javascripts/webshims/shims/color-picker.js +1 -3
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +22 -33
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +76 -73
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +73 -61
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +37 -41
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +36 -40
- data/vendor/assets/javascripts/webshims/shims/combos/14.js +7 -7
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +23 -32
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +36 -57
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +73 -61
- data/vendor/assets/javascripts/webshims/shims/combos/18.js +611 -4604
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +27 -47
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +61 -31
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +24 -16
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +13 -25
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +40 -27
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +167 -166
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +11 -12
- data/vendor/assets/javascripts/webshims/shims/combos/29.js +5 -5
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +14 -22
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +16 -24
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +14 -22
- data/vendor/assets/javascripts/webshims/shims/combos/33.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/combos/34.js +27 -28
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +5 -14
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +78 -66
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +80 -68
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +29 -49
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +27 -47
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +78 -75
- data/vendor/assets/javascripts/webshims/shims/combos/97.js +42 -29
- data/vendor/assets/javascripts/webshims/shims/combos/98.js +116 -40
- data/vendor/assets/javascripts/webshims/shims/combos/99.js +112 -38
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +3 -12
- data/vendor/assets/javascripts/webshims/shims/es5.js +4 -4
- data/vendor/assets/javascripts/webshims/shims/es6.js +1887 -0
- data/vendor/assets/javascripts/webshims/shims/form-core.js +9 -8
- data/vendor/assets/javascripts/webshims/shims/form-datalist.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/form-inputmode.js +52 -0
- data/vendor/assets/javascripts/webshims/shims/form-message.js +2 -2
- data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +4 -5
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +73 -61
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +7 -8
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend2.js +164 -163
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +121 -144
- data/vendor/assets/javascripts/webshims/shims/jme/_icons.scss +3 -0
- data/vendor/assets/javascripts/webshims/shims/jme/alternate-media.js +184 -0
- data/vendor/assets/javascripts/webshims/shims/jme/{b.js → base.js} +38 -27
- data/vendor/assets/javascripts/webshims/shims/jme/controls.css +129 -39
- data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +145 -44
- data/vendor/assets/javascripts/webshims/shims/jme/jme.eot +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.svg +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.ttf +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/jme.woff +0 -0
- data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols-lazy.js +448 -90
- data/vendor/assets/javascripts/webshims/shims/jme/{c.js → mediacontrols.js} +74 -11
- data/vendor/assets/javascripts/webshims/shims/jme/{p.js → playlist.js} +4 -2
- data/vendor/assets/javascripts/webshims/shims/matchMedia.js +122 -0
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +12 -24
- data/vendor/assets/javascripts/webshims/shims/mediaelement-debug.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +37 -15
- data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +3 -3
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +4 -5
- data/vendor/assets/javascripts/webshims/shims/picture.js +13 -54
- data/vendor/assets/javascripts/webshims/shims/styles/forms-ext.css +13 -20
- data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-ext.scss +24 -18
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +32 -10
- data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +43 -47
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +30 -18
- data/vendor/assets/javascripts/webshims/shims/styles/transparent.png +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/widget.eot +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/widget.svg +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/widget.ttf +0 -0
- data/vendor/assets/javascripts/webshims/shims/styles/widget.woff +0 -0
- data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
- data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +4 -5
- data/vendor/assets/javascripts/webshims/shims/track.js +24 -16
- metadata +9 -8
- data/vendor/assets/javascripts/webshims/shims/combos/19.js +0 -4745
- data/vendor/assets/javascripts/webshims/shims/combos/20.js +0 -4522
- data/vendor/assets/javascripts/webshims/shims/combos/32.js +0 -2443
- data/vendor/assets/javascripts/webshims/shims/combos/comboinfo.json +0 -1
@@ -1,2443 +0,0 @@
|
|
1
|
-
// Copyright 2009-2012 by contributors, MIT License
|
2
|
-
// vim: ts=4 sts=4 sw=4 expandtab
|
3
|
-
|
4
|
-
(function () {
|
5
|
-
setTimeout(function(){
|
6
|
-
webshims.isReady('es5', true);
|
7
|
-
});
|
8
|
-
/**
|
9
|
-
* Brings an environment as close to ECMAScript 5 compliance
|
10
|
-
* as is possible with the facilities of erstwhile engines.
|
11
|
-
*
|
12
|
-
* Annotated ES5: http://es5.github.com/ (specific links below)
|
13
|
-
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
|
14
|
-
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
|
15
|
-
*/
|
16
|
-
|
17
|
-
// Shortcut to an often accessed properties, in order to avoid multiple
|
18
|
-
// dereference that costs universally.
|
19
|
-
var call = Function.prototype.call;
|
20
|
-
var prototypeOfArray = Array.prototype;
|
21
|
-
var prototypeOfObject = Object.prototype;
|
22
|
-
var _Array_slice_ = prototypeOfArray.slice;
|
23
|
-
var array_splice = Array.prototype.splice;
|
24
|
-
var array_push = Array.prototype.push;
|
25
|
-
var array_unshift = Array.prototype.unshift;
|
26
|
-
|
27
|
-
// Having a toString local variable name breaks in Opera so use _toString.
|
28
|
-
var _toString = prototypeOfObject.toString;
|
29
|
-
|
30
|
-
var isFunction = function (val) {
|
31
|
-
return prototypeOfObject.toString.call(val) === '[object Function]';
|
32
|
-
};
|
33
|
-
var isRegex = function (val) {
|
34
|
-
return prototypeOfObject.toString.call(val) === '[object RegExp]';
|
35
|
-
};
|
36
|
-
var isArray = function isArray(obj) {
|
37
|
-
return _toString.call(obj) === "[object Array]";
|
38
|
-
};
|
39
|
-
var isArguments = function isArguments(value) {
|
40
|
-
var str = _toString.call(value);
|
41
|
-
var isArgs = str === '[object Arguments]';
|
42
|
-
if (!isArgs) {
|
43
|
-
isArgs = !isArray(str)
|
44
|
-
&& value !== null
|
45
|
-
&& typeof value === 'object'
|
46
|
-
&& typeof value.length === 'number'
|
47
|
-
&& value.length >= 0
|
48
|
-
&& isFunction(value.callee);
|
49
|
-
}
|
50
|
-
return isArgs;
|
51
|
-
};
|
52
|
-
|
53
|
-
//
|
54
|
-
// Function
|
55
|
-
// ========
|
56
|
-
//
|
57
|
-
|
58
|
-
// ES-5 15.3.4.5
|
59
|
-
// http://es5.github.com/#x15.3.4.5
|
60
|
-
|
61
|
-
function Empty() {}
|
62
|
-
|
63
|
-
if (!Function.prototype.bind) {
|
64
|
-
Function.prototype.bind = function bind(that) { // .length is 1
|
65
|
-
// 1. Let Target be the this value.
|
66
|
-
var target = this;
|
67
|
-
// 2. If IsCallable(Target) is false, throw a TypeError exception.
|
68
|
-
if (!isFunction(target)) {
|
69
|
-
throw new TypeError("Function.prototype.bind called on incompatible " + target);
|
70
|
-
}
|
71
|
-
// 3. Let A be a new (possibly empty) internal list of all of the
|
72
|
-
// argument values provided after thisArg (arg1, arg2 etc), in order.
|
73
|
-
// XXX slicedArgs will stand in for "A" if used
|
74
|
-
var args = _Array_slice_.call(arguments, 1); // for normal call
|
75
|
-
// 4. Let F be a new native ECMAScript object.
|
76
|
-
// 11. Set the [[Prototype]] internal property of F to the standard
|
77
|
-
// built-in Function prototype object as specified in 15.3.3.1.
|
78
|
-
// 12. Set the [[Call]] internal property of F as described in
|
79
|
-
// 15.3.4.5.1.
|
80
|
-
// 13. Set the [[Construct]] internal property of F as described in
|
81
|
-
// 15.3.4.5.2.
|
82
|
-
// 14. Set the [[HasInstance]] internal property of F as described in
|
83
|
-
// 15.3.4.5.3.
|
84
|
-
var binder = function () {
|
85
|
-
|
86
|
-
if (this instanceof bound) {
|
87
|
-
// 15.3.4.5.2 [[Construct]]
|
88
|
-
// When the [[Construct]] internal method of a function object,
|
89
|
-
// F that was created using the bind function is called with a
|
90
|
-
// list of arguments ExtraArgs, the following steps are taken:
|
91
|
-
// 1. Let target be the value of F's [[TargetFunction]]
|
92
|
-
// internal property.
|
93
|
-
// 2. If target has no [[Construct]] internal method, a
|
94
|
-
// TypeError exception is thrown.
|
95
|
-
// 3. Let boundArgs be the value of F's [[BoundArgs]] internal
|
96
|
-
// property.
|
97
|
-
// 4. Let args be a new list containing the same values as the
|
98
|
-
// list boundArgs in the same order followed by the same
|
99
|
-
// values as the list ExtraArgs in the same order.
|
100
|
-
// 5. Return the result of calling the [[Construct]] internal
|
101
|
-
// method of target providing args as the arguments.
|
102
|
-
|
103
|
-
var result = target.apply(
|
104
|
-
this,
|
105
|
-
args.concat(_Array_slice_.call(arguments))
|
106
|
-
);
|
107
|
-
if (Object(result) === result) {
|
108
|
-
return result;
|
109
|
-
}
|
110
|
-
return this;
|
111
|
-
|
112
|
-
} else {
|
113
|
-
// 15.3.4.5.1 [[Call]]
|
114
|
-
// When the [[Call]] internal method of a function object, F,
|
115
|
-
// which was created using the bind function is called with a
|
116
|
-
// this value and a list of arguments ExtraArgs, the following
|
117
|
-
// steps are taken:
|
118
|
-
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
|
119
|
-
// property.
|
120
|
-
// 2. Let boundThis be the value of F's [[BoundThis]] internal
|
121
|
-
// property.
|
122
|
-
// 3. Let target be the value of F's [[TargetFunction]] internal
|
123
|
-
// property.
|
124
|
-
// 4. Let args be a new list containing the same values as the
|
125
|
-
// list boundArgs in the same order followed by the same
|
126
|
-
// values as the list ExtraArgs in the same order.
|
127
|
-
// 5. Return the result of calling the [[Call]] internal method
|
128
|
-
// of target providing boundThis as the this value and
|
129
|
-
// providing args as the arguments.
|
130
|
-
|
131
|
-
// equiv: target.call(this, ...boundArgs, ...args)
|
132
|
-
return target.apply(
|
133
|
-
that,
|
134
|
-
args.concat(_Array_slice_.call(arguments))
|
135
|
-
);
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
};
|
140
|
-
|
141
|
-
// 15. If the [[Class]] internal property of Target is "Function", then
|
142
|
-
// a. Let L be the length property of Target minus the length of A.
|
143
|
-
// b. Set the length own property of F to either 0 or L, whichever is
|
144
|
-
// larger.
|
145
|
-
// 16. Else set the length own property of F to 0.
|
146
|
-
|
147
|
-
var boundLength = Math.max(0, target.length - args.length);
|
148
|
-
|
149
|
-
// 17. Set the attributes of the length own property of F to the values
|
150
|
-
// specified in 15.3.5.1.
|
151
|
-
var boundArgs = [];
|
152
|
-
for (var i = 0; i < boundLength; i++) {
|
153
|
-
boundArgs.push("$" + i);
|
154
|
-
}
|
155
|
-
|
156
|
-
// XXX Build a dynamic function with desired amount of arguments is the only
|
157
|
-
// way to set the length property of a function.
|
158
|
-
// In environments where Content Security Policies enabled (Chrome extensions,
|
159
|
-
// for ex.) all use of eval or Function costructor throws an exception.
|
160
|
-
// However in all of these environments Function.prototype.bind exists
|
161
|
-
// and so this code will never be executed.
|
162
|
-
var bound = Function("binder", "return function (" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
|
163
|
-
|
164
|
-
if (target.prototype) {
|
165
|
-
Empty.prototype = target.prototype;
|
166
|
-
bound.prototype = new Empty();
|
167
|
-
// Clean up dangling references.
|
168
|
-
Empty.prototype = null;
|
169
|
-
}
|
170
|
-
|
171
|
-
// TODO
|
172
|
-
// 18. Set the [[Extensible]] internal property of F to true.
|
173
|
-
|
174
|
-
// TODO
|
175
|
-
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
|
176
|
-
// 20. Call the [[DefineOwnProperty]] internal method of F with
|
177
|
-
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
|
178
|
-
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
|
179
|
-
// false.
|
180
|
-
// 21. Call the [[DefineOwnProperty]] internal method of F with
|
181
|
-
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
|
182
|
-
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
|
183
|
-
// and false.
|
184
|
-
|
185
|
-
// TODO
|
186
|
-
// NOTE Function objects created using Function.prototype.bind do not
|
187
|
-
// have a prototype property or the [[Code]], [[FormalParameters]], and
|
188
|
-
// [[Scope]] internal properties.
|
189
|
-
// XXX can't delete prototype in pure-js.
|
190
|
-
|
191
|
-
// 22. Return F.
|
192
|
-
return bound;
|
193
|
-
};
|
194
|
-
}
|
195
|
-
|
196
|
-
// _Please note: Shortcuts are defined after `Function.prototype.bind` as we
|
197
|
-
// us it in defining shortcuts.
|
198
|
-
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
199
|
-
|
200
|
-
// If JS engine supports accessors creating shortcuts.
|
201
|
-
var defineGetter;
|
202
|
-
var defineSetter;
|
203
|
-
var lookupGetter;
|
204
|
-
var lookupSetter;
|
205
|
-
var supportsAccessors;
|
206
|
-
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
|
207
|
-
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
|
208
|
-
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
|
209
|
-
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
|
210
|
-
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
|
211
|
-
}
|
212
|
-
|
213
|
-
//
|
214
|
-
// Array
|
215
|
-
// =====
|
216
|
-
//
|
217
|
-
|
218
|
-
// ES5 15.4.4.12
|
219
|
-
// http://es5.github.com/#x15.4.4.12
|
220
|
-
var spliceWorksWithEmptyObject = (function () {
|
221
|
-
var obj = {};
|
222
|
-
Array.prototype.splice.call(obj, 0, 0, 1);
|
223
|
-
return obj.length === 1;
|
224
|
-
}());
|
225
|
-
var omittingSecondSpliceArgIsNoop = [1].splice(0).length === 0;
|
226
|
-
var spliceNoopReturnsEmptyArray = (function () {
|
227
|
-
var a = [1, 2];
|
228
|
-
var result = a.splice();
|
229
|
-
return a.length === 2 && isArray(result) && result.length === 0;
|
230
|
-
}());
|
231
|
-
if (spliceNoopReturnsEmptyArray) {
|
232
|
-
// Safari 5.0 bug where .split() returns undefined
|
233
|
-
Array.prototype.splice = function splice(start, deleteCount) {
|
234
|
-
if (arguments.length === 0) { return []; }
|
235
|
-
else { return array_splice.apply(this, arguments); }
|
236
|
-
};
|
237
|
-
}
|
238
|
-
if (!omittingSecondSpliceArgIsNoop || !spliceWorksWithEmptyObject) {
|
239
|
-
Array.prototype.splice = function splice(start, deleteCount) {
|
240
|
-
if (arguments.length === 0) { return []; }
|
241
|
-
var args = arguments;
|
242
|
-
this.length = Math.max(toInteger(this.length), 0);
|
243
|
-
if (arguments.length > 0 && typeof deleteCount !== 'number') {
|
244
|
-
args = _Array_slice_.call(arguments);
|
245
|
-
if (args.length < 2) { args.push(toInteger(deleteCount)); }
|
246
|
-
else { args[1] = toInteger(deleteCount); }
|
247
|
-
}
|
248
|
-
return array_splice.apply(this, args);
|
249
|
-
};
|
250
|
-
}
|
251
|
-
|
252
|
-
// ES5 15.4.4.12
|
253
|
-
// http://es5.github.com/#x15.4.4.13
|
254
|
-
// Return len+argCount.
|
255
|
-
// [bugfix, ielt8]
|
256
|
-
// IE < 8 bug: [].unshift(0) === undefined but should be "1"
|
257
|
-
if ([].unshift(0) !== 1) {
|
258
|
-
Array.prototype.unshift = function () {
|
259
|
-
array_unshift.apply(this, arguments);
|
260
|
-
return this.length;
|
261
|
-
};
|
262
|
-
}
|
263
|
-
|
264
|
-
// ES5 15.4.3.2
|
265
|
-
// http://es5.github.com/#x15.4.3.2
|
266
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
|
267
|
-
if (!Array.isArray) {
|
268
|
-
Array.isArray = isArray;
|
269
|
-
}
|
270
|
-
|
271
|
-
// The IsCallable() check in the Array functions
|
272
|
-
// has been replaced with a strict check on the
|
273
|
-
// internal class of the object to trap cases where
|
274
|
-
// the provided function was actually a regular
|
275
|
-
// expression literal, which in V8 and
|
276
|
-
// JavaScriptCore is a typeof "function". Only in
|
277
|
-
// V8 are regular expression literals permitted as
|
278
|
-
// reduce parameters, so it is desirable in the
|
279
|
-
// general case for the shim to match the more
|
280
|
-
// strict and common behavior of rejecting regular
|
281
|
-
// expressions.
|
282
|
-
|
283
|
-
// ES5 15.4.4.18
|
284
|
-
// http://es5.github.com/#x15.4.4.18
|
285
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
|
286
|
-
|
287
|
-
// Check failure of by-index access of string characters (IE < 9)
|
288
|
-
// and failure of `0 in boxedString` (Rhino)
|
289
|
-
var boxedString = Object("a");
|
290
|
-
var splitString = boxedString[0] !== "a" || !(0 in boxedString);
|
291
|
-
|
292
|
-
var properlyBoxesContext = function properlyBoxed(method) {
|
293
|
-
// Check node 0.6.21 bug where third parameter is not boxed
|
294
|
-
var properlyBoxesNonStrict = true;
|
295
|
-
var properlyBoxesStrict = true;
|
296
|
-
if (method) {
|
297
|
-
method.call('foo', function (_, __, context) {
|
298
|
-
if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
|
299
|
-
});
|
300
|
-
|
301
|
-
method.call([1], function () {
|
302
|
-
'use strict';
|
303
|
-
properlyBoxesStrict = typeof this === 'string';
|
304
|
-
}, 'x');
|
305
|
-
}
|
306
|
-
return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
|
307
|
-
};
|
308
|
-
|
309
|
-
if (!Array.prototype.forEach || !properlyBoxesContext(Array.prototype.forEach)) {
|
310
|
-
Array.prototype.forEach = function forEach(fun /*, thisp*/) {
|
311
|
-
var object = toObject(this),
|
312
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
313
|
-
this.split("") :
|
314
|
-
object,
|
315
|
-
thisp = arguments[1],
|
316
|
-
i = -1,
|
317
|
-
length = self.length >>> 0;
|
318
|
-
|
319
|
-
// If no callback function or if callback is not a callable function
|
320
|
-
if (!isFunction(fun)) {
|
321
|
-
throw new TypeError(); // TODO message
|
322
|
-
}
|
323
|
-
|
324
|
-
while (++i < length) {
|
325
|
-
if (i in self) {
|
326
|
-
// Invoke the callback function with call, passing arguments:
|
327
|
-
// context, property value, property key, thisArg object
|
328
|
-
// context
|
329
|
-
fun.call(thisp, self[i], i, object);
|
330
|
-
}
|
331
|
-
}
|
332
|
-
};
|
333
|
-
}
|
334
|
-
|
335
|
-
// ES5 15.4.4.19
|
336
|
-
// http://es5.github.com/#x15.4.4.19
|
337
|
-
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
|
338
|
-
if (!Array.prototype.map || !properlyBoxesContext(Array.prototype.map)) {
|
339
|
-
Array.prototype.map = function map(fun /*, thisp*/) {
|
340
|
-
var object = toObject(this),
|
341
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
342
|
-
this.split("") :
|
343
|
-
object,
|
344
|
-
length = self.length >>> 0,
|
345
|
-
result = Array(length),
|
346
|
-
thisp = arguments[1];
|
347
|
-
|
348
|
-
// If no callback function or if callback is not a callable function
|
349
|
-
if (!isFunction(fun)) {
|
350
|
-
throw new TypeError(fun + " is not a function");
|
351
|
-
}
|
352
|
-
|
353
|
-
for (var i = 0; i < length; i++) {
|
354
|
-
if (i in self) {
|
355
|
-
result[i] = fun.call(thisp, self[i], i, object);
|
356
|
-
}
|
357
|
-
}
|
358
|
-
return result;
|
359
|
-
};
|
360
|
-
}
|
361
|
-
|
362
|
-
// ES5 15.4.4.20
|
363
|
-
// http://es5.github.com/#x15.4.4.20
|
364
|
-
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
|
365
|
-
if (!Array.prototype.filter || !properlyBoxesContext(Array.prototype.filter)) {
|
366
|
-
Array.prototype.filter = function filter(fun /*, thisp */) {
|
367
|
-
var object = toObject(this),
|
368
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
369
|
-
this.split("") :
|
370
|
-
object,
|
371
|
-
length = self.length >>> 0,
|
372
|
-
result = [],
|
373
|
-
value,
|
374
|
-
thisp = arguments[1];
|
375
|
-
|
376
|
-
// If no callback function or if callback is not a callable function
|
377
|
-
if (!isFunction(fun)) {
|
378
|
-
throw new TypeError(fun + " is not a function");
|
379
|
-
}
|
380
|
-
|
381
|
-
for (var i = 0; i < length; i++) {
|
382
|
-
if (i in self) {
|
383
|
-
value = self[i];
|
384
|
-
if (fun.call(thisp, value, i, object)) {
|
385
|
-
result.push(value);
|
386
|
-
}
|
387
|
-
}
|
388
|
-
}
|
389
|
-
return result;
|
390
|
-
};
|
391
|
-
}
|
392
|
-
|
393
|
-
// ES5 15.4.4.16
|
394
|
-
// http://es5.github.com/#x15.4.4.16
|
395
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
|
396
|
-
if (!Array.prototype.every || !properlyBoxesContext(Array.prototype.every)) {
|
397
|
-
Array.prototype.every = function every(fun /*, thisp */) {
|
398
|
-
var object = toObject(this),
|
399
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
400
|
-
this.split("") :
|
401
|
-
object,
|
402
|
-
length = self.length >>> 0,
|
403
|
-
thisp = arguments[1];
|
404
|
-
|
405
|
-
// If no callback function or if callback is not a callable function
|
406
|
-
if (!isFunction(fun)) {
|
407
|
-
throw new TypeError(fun + " is not a function");
|
408
|
-
}
|
409
|
-
|
410
|
-
for (var i = 0; i < length; i++) {
|
411
|
-
if (i in self && !fun.call(thisp, self[i], i, object)) {
|
412
|
-
return false;
|
413
|
-
}
|
414
|
-
}
|
415
|
-
return true;
|
416
|
-
};
|
417
|
-
}
|
418
|
-
|
419
|
-
// ES5 15.4.4.17
|
420
|
-
// http://es5.github.com/#x15.4.4.17
|
421
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
|
422
|
-
if (!Array.prototype.some || !properlyBoxesContext(Array.prototype.some)) {
|
423
|
-
Array.prototype.some = function some(fun /*, thisp */) {
|
424
|
-
var object = toObject(this),
|
425
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
426
|
-
this.split("") :
|
427
|
-
object,
|
428
|
-
length = self.length >>> 0,
|
429
|
-
thisp = arguments[1];
|
430
|
-
|
431
|
-
// If no callback function or if callback is not a callable function
|
432
|
-
if (!isFunction(fun)) {
|
433
|
-
throw new TypeError(fun + " is not a function");
|
434
|
-
}
|
435
|
-
|
436
|
-
for (var i = 0; i < length; i++) {
|
437
|
-
if (i in self && fun.call(thisp, self[i], i, object)) {
|
438
|
-
return true;
|
439
|
-
}
|
440
|
-
}
|
441
|
-
return false;
|
442
|
-
};
|
443
|
-
}
|
444
|
-
|
445
|
-
// ES5 15.4.4.21
|
446
|
-
// http://es5.github.com/#x15.4.4.21
|
447
|
-
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
|
448
|
-
var reduceCoercesToObject = false;
|
449
|
-
if (Array.prototype.reduce) {
|
450
|
-
reduceCoercesToObject = typeof Array.prototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
451
|
-
}
|
452
|
-
if (!Array.prototype.reduce || !reduceCoercesToObject) {
|
453
|
-
Array.prototype.reduce = function reduce(fun /*, initial*/) {
|
454
|
-
var object = toObject(this),
|
455
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
456
|
-
this.split("") :
|
457
|
-
object,
|
458
|
-
length = self.length >>> 0;
|
459
|
-
|
460
|
-
// If no callback function or if callback is not a callable function
|
461
|
-
if (!isFunction(fun)) {
|
462
|
-
throw new TypeError(fun + " is not a function");
|
463
|
-
}
|
464
|
-
|
465
|
-
// no value to return if no initial value and an empty array
|
466
|
-
if (!length && arguments.length === 1) {
|
467
|
-
throw new TypeError("reduce of empty array with no initial value");
|
468
|
-
}
|
469
|
-
|
470
|
-
var i = 0;
|
471
|
-
var result;
|
472
|
-
if (arguments.length >= 2) {
|
473
|
-
result = arguments[1];
|
474
|
-
} else {
|
475
|
-
do {
|
476
|
-
if (i in self) {
|
477
|
-
result = self[i++];
|
478
|
-
break;
|
479
|
-
}
|
480
|
-
|
481
|
-
// if array contains no values, no initial value to return
|
482
|
-
if (++i >= length) {
|
483
|
-
throw new TypeError("reduce of empty array with no initial value");
|
484
|
-
}
|
485
|
-
} while (true);
|
486
|
-
}
|
487
|
-
|
488
|
-
for (; i < length; i++) {
|
489
|
-
if (i in self) {
|
490
|
-
result = fun.call(void 0, result, self[i], i, object);
|
491
|
-
}
|
492
|
-
}
|
493
|
-
|
494
|
-
return result;
|
495
|
-
};
|
496
|
-
}
|
497
|
-
|
498
|
-
// ES5 15.4.4.22
|
499
|
-
// http://es5.github.com/#x15.4.4.22
|
500
|
-
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
|
501
|
-
var reduceRightCoercesToObject = false;
|
502
|
-
if (Array.prototype.reduceRight) {
|
503
|
-
reduceRightCoercesToObject = typeof Array.prototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
|
504
|
-
}
|
505
|
-
if (!Array.prototype.reduceRight || !reduceRightCoercesToObject) {
|
506
|
-
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
|
507
|
-
var object = toObject(this),
|
508
|
-
self = splitString && _toString.call(this) === "[object String]" ?
|
509
|
-
this.split("") :
|
510
|
-
object,
|
511
|
-
length = self.length >>> 0;
|
512
|
-
|
513
|
-
// If no callback function or if callback is not a callable function
|
514
|
-
if (!isFunction(fun)) {
|
515
|
-
throw new TypeError(fun + " is not a function");
|
516
|
-
}
|
517
|
-
|
518
|
-
// no value to return if no initial value, empty array
|
519
|
-
if (!length && arguments.length === 1) {
|
520
|
-
throw new TypeError("reduceRight of empty array with no initial value");
|
521
|
-
}
|
522
|
-
|
523
|
-
var result, i = length - 1;
|
524
|
-
if (arguments.length >= 2) {
|
525
|
-
result = arguments[1];
|
526
|
-
} else {
|
527
|
-
do {
|
528
|
-
if (i in self) {
|
529
|
-
result = self[i--];
|
530
|
-
break;
|
531
|
-
}
|
532
|
-
|
533
|
-
// if array contains no values, no initial value to return
|
534
|
-
if (--i < 0) {
|
535
|
-
throw new TypeError("reduceRight of empty array with no initial value");
|
536
|
-
}
|
537
|
-
} while (true);
|
538
|
-
}
|
539
|
-
|
540
|
-
if (i < 0) {
|
541
|
-
return result;
|
542
|
-
}
|
543
|
-
|
544
|
-
do {
|
545
|
-
if (i in self) {
|
546
|
-
result = fun.call(void 0, result, self[i], i, object);
|
547
|
-
}
|
548
|
-
} while (i--);
|
549
|
-
|
550
|
-
return result;
|
551
|
-
};
|
552
|
-
}
|
553
|
-
|
554
|
-
// ES5 15.4.4.14
|
555
|
-
// http://es5.github.com/#x15.4.4.14
|
556
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
|
557
|
-
if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) !== -1)) {
|
558
|
-
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
|
559
|
-
var self = splitString && _toString.call(this) === "[object String]" ?
|
560
|
-
this.split("") :
|
561
|
-
toObject(this),
|
562
|
-
length = self.length >>> 0;
|
563
|
-
|
564
|
-
if (!length) {
|
565
|
-
return -1;
|
566
|
-
}
|
567
|
-
|
568
|
-
var i = 0;
|
569
|
-
if (arguments.length > 1) {
|
570
|
-
i = toInteger(arguments[1]);
|
571
|
-
}
|
572
|
-
|
573
|
-
// handle negative indices
|
574
|
-
i = i >= 0 ? i : Math.max(0, length + i);
|
575
|
-
for (; i < length; i++) {
|
576
|
-
if (i in self && self[i] === sought) {
|
577
|
-
return i;
|
578
|
-
}
|
579
|
-
}
|
580
|
-
return -1;
|
581
|
-
};
|
582
|
-
}
|
583
|
-
|
584
|
-
// ES5 15.4.4.15
|
585
|
-
// http://es5.github.com/#x15.4.4.15
|
586
|
-
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
|
587
|
-
if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) !== -1)) {
|
588
|
-
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
|
589
|
-
var self = splitString && _toString.call(this) === "[object String]" ?
|
590
|
-
this.split("") :
|
591
|
-
toObject(this),
|
592
|
-
length = self.length >>> 0;
|
593
|
-
|
594
|
-
if (!length) {
|
595
|
-
return -1;
|
596
|
-
}
|
597
|
-
var i = length - 1;
|
598
|
-
if (arguments.length > 1) {
|
599
|
-
i = Math.min(i, toInteger(arguments[1]));
|
600
|
-
}
|
601
|
-
// handle negative indices
|
602
|
-
i = i >= 0 ? i : length - Math.abs(i);
|
603
|
-
for (; i >= 0; i--) {
|
604
|
-
if (i in self && sought === self[i]) {
|
605
|
-
return i;
|
606
|
-
}
|
607
|
-
}
|
608
|
-
return -1;
|
609
|
-
};
|
610
|
-
}
|
611
|
-
|
612
|
-
//
|
613
|
-
// Object
|
614
|
-
// ======
|
615
|
-
//
|
616
|
-
|
617
|
-
// ES5 15.2.3.14
|
618
|
-
// http://es5.github.com/#x15.2.3.14
|
619
|
-
var keysWorksWithArguments = Object.keys && (function () {
|
620
|
-
return Object.keys(arguments).length === 2;
|
621
|
-
}(1, 2));
|
622
|
-
if (!Object.keys) {
|
623
|
-
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
|
624
|
-
var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
|
625
|
-
hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
|
626
|
-
dontEnums = [
|
627
|
-
"toString",
|
628
|
-
"toLocaleString",
|
629
|
-
"valueOf",
|
630
|
-
"hasOwnProperty",
|
631
|
-
"isPrototypeOf",
|
632
|
-
"propertyIsEnumerable",
|
633
|
-
"constructor"
|
634
|
-
],
|
635
|
-
dontEnumsLength = dontEnums.length;
|
636
|
-
|
637
|
-
Object.keys = function keys(object) {
|
638
|
-
var isFn = isFunction(object),
|
639
|
-
isArgs = isArguments(object),
|
640
|
-
isObject = object !== null && typeof object === 'object',
|
641
|
-
isString = isObject && _toString.call(object) === '[object String]';
|
642
|
-
|
643
|
-
if (!isObject && !isFn && !isArgs) {
|
644
|
-
throw new TypeError("Object.keys called on a non-object");
|
645
|
-
}
|
646
|
-
|
647
|
-
var theKeys = [];
|
648
|
-
var skipProto = hasProtoEnumBug && isFn;
|
649
|
-
if (isString || isArgs) {
|
650
|
-
for (var i = 0; i < object.length; ++i) {
|
651
|
-
theKeys.push(String(i));
|
652
|
-
}
|
653
|
-
} else {
|
654
|
-
for (var name in object) {
|
655
|
-
if (!(skipProto && name === 'prototype') && owns(object, name)) {
|
656
|
-
theKeys.push(String(name));
|
657
|
-
}
|
658
|
-
}
|
659
|
-
}
|
660
|
-
|
661
|
-
if (hasDontEnumBug) {
|
662
|
-
var ctor = object.constructor,
|
663
|
-
skipConstructor = ctor && ctor.prototype === object;
|
664
|
-
for (var j = 0; j < dontEnumsLength; j++) {
|
665
|
-
var dontEnum = dontEnums[j];
|
666
|
-
if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
|
667
|
-
theKeys.push(dontEnum);
|
668
|
-
}
|
669
|
-
}
|
670
|
-
}
|
671
|
-
return theKeys;
|
672
|
-
};
|
673
|
-
} else if (!keysWorksWithArguments) {
|
674
|
-
// Safari 5.0 bug
|
675
|
-
var originalKeys = Object.keys;
|
676
|
-
Object.keys = function keys(object) {
|
677
|
-
if (isArguments(object)) {
|
678
|
-
return originalKeys(Array.prototype.slice.call(object));
|
679
|
-
} else {
|
680
|
-
return originalKeys(object);
|
681
|
-
}
|
682
|
-
};
|
683
|
-
}
|
684
|
-
|
685
|
-
//
|
686
|
-
// Date
|
687
|
-
// ====
|
688
|
-
//
|
689
|
-
|
690
|
-
// ES5 15.9.5.43
|
691
|
-
// http://es5.github.com/#x15.9.5.43
|
692
|
-
// This function returns a String value represent the instance in time
|
693
|
-
// represented by this Date object. The format of the String is the Date Time
|
694
|
-
// string format defined in 15.9.1.15. All fields are present in the String.
|
695
|
-
// The time zone is always UTC, denoted by the suffix Z. If the time value of
|
696
|
-
// this object is not a finite Number a RangeError exception is thrown.
|
697
|
-
var negativeDate = -62198755200000,
|
698
|
-
negativeYearString = "-000001";
|
699
|
-
if (
|
700
|
-
!Date.prototype.toISOString ||
|
701
|
-
(new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
|
702
|
-
) {
|
703
|
-
Date.prototype.toISOString = function toISOString() {
|
704
|
-
var result, length, value, year, month;
|
705
|
-
if (!isFinite(this)) {
|
706
|
-
throw new RangeError("Date.prototype.toISOString called on non-finite value.");
|
707
|
-
}
|
708
|
-
|
709
|
-
year = this.getUTCFullYear();
|
710
|
-
|
711
|
-
month = this.getUTCMonth();
|
712
|
-
// see https://github.com/es-shims/es5-shim/issues/111
|
713
|
-
year += Math.floor(month / 12);
|
714
|
-
month = (month % 12 + 12) % 12;
|
715
|
-
|
716
|
-
// the date time string format is specified in 15.9.1.15.
|
717
|
-
result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
|
718
|
-
year = (
|
719
|
-
(year < 0 ? "-" : (year > 9999 ? "+" : "")) +
|
720
|
-
("00000" + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6)
|
721
|
-
);
|
722
|
-
|
723
|
-
length = result.length;
|
724
|
-
while (length--) {
|
725
|
-
value = result[length];
|
726
|
-
// pad months, days, hours, minutes, and seconds to have two
|
727
|
-
// digits.
|
728
|
-
if (value < 10) {
|
729
|
-
result[length] = "0" + value;
|
730
|
-
}
|
731
|
-
}
|
732
|
-
// pad milliseconds to have three digits.
|
733
|
-
return (
|
734
|
-
year + "-" + result.slice(0, 2).join("-") +
|
735
|
-
"T" + result.slice(2).join(":") + "." +
|
736
|
-
("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
|
737
|
-
);
|
738
|
-
};
|
739
|
-
}
|
740
|
-
|
741
|
-
|
742
|
-
// ES5 15.9.5.44
|
743
|
-
// http://es5.github.com/#x15.9.5.44
|
744
|
-
// This function provides a String representation of a Date object for use by
|
745
|
-
// JSON.stringify (15.12.3).
|
746
|
-
var dateToJSONIsSupported = false;
|
747
|
-
try {
|
748
|
-
dateToJSONIsSupported = (
|
749
|
-
Date.prototype.toJSON &&
|
750
|
-
new Date(NaN).toJSON() === null &&
|
751
|
-
new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
|
752
|
-
Date.prototype.toJSON.call({ // generic
|
753
|
-
toISOString: function () {
|
754
|
-
return true;
|
755
|
-
}
|
756
|
-
})
|
757
|
-
);
|
758
|
-
} catch (e) {
|
759
|
-
}
|
760
|
-
if (!dateToJSONIsSupported) {
|
761
|
-
Date.prototype.toJSON = function toJSON(key) {
|
762
|
-
// When the toJSON method is called with argument key, the following
|
763
|
-
// steps are taken:
|
764
|
-
|
765
|
-
// 1. Let O be the result of calling ToObject, giving it the this
|
766
|
-
// value as its argument.
|
767
|
-
// 2. Let tv be toPrimitive(O, hint Number).
|
768
|
-
var o = Object(this),
|
769
|
-
tv = toPrimitive(o),
|
770
|
-
toISO;
|
771
|
-
// 3. If tv is a Number and is not finite, return null.
|
772
|
-
if (typeof tv === "number" && !isFinite(tv)) {
|
773
|
-
return null;
|
774
|
-
}
|
775
|
-
// 4. Let toISO be the result of calling the [[Get]] internal method of
|
776
|
-
// O with argument "toISOString".
|
777
|
-
toISO = o.toISOString;
|
778
|
-
// 5. If IsCallable(toISO) is false, throw a TypeError exception.
|
779
|
-
if (typeof toISO !== "function") {
|
780
|
-
throw new TypeError("toISOString property is not callable");
|
781
|
-
}
|
782
|
-
// 6. Return the result of calling the [[Call]] internal method of
|
783
|
-
// toISO with O as the this value and an empty argument list.
|
784
|
-
return toISO.call(o);
|
785
|
-
|
786
|
-
// NOTE 1 The argument is ignored.
|
787
|
-
|
788
|
-
// NOTE 2 The toJSON function is intentionally generic; it does not
|
789
|
-
// require that its this value be a Date object. Therefore, it can be
|
790
|
-
// transferred to other kinds of objects for use as a method. However,
|
791
|
-
// it does require that any such object have a toISOString method. An
|
792
|
-
// object is free to use the argument key to filter its
|
793
|
-
// stringification.
|
794
|
-
};
|
795
|
-
}
|
796
|
-
|
797
|
-
// ES5 15.9.4.2
|
798
|
-
// http://es5.github.com/#x15.9.4.2
|
799
|
-
// based on work shared by Daniel Friesen (dantman)
|
800
|
-
// http://gist.github.com/303249
|
801
|
-
var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
|
802
|
-
var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z'));
|
803
|
-
var doesNotParseY2KNewYear = isNaN(Date.parse("2000-01-01T00:00:00.000Z"));
|
804
|
-
if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
|
805
|
-
// XXX global assignment won't work in embeddings that use
|
806
|
-
// an alternate object for the context.
|
807
|
-
Date = (function (NativeDate) {
|
808
|
-
|
809
|
-
// Date.length === 7
|
810
|
-
function Date(Y, M, D, h, m, s, ms) {
|
811
|
-
var length = arguments.length;
|
812
|
-
if (this instanceof NativeDate) {
|
813
|
-
var date = length === 1 && String(Y) === Y ? // isString(Y)
|
814
|
-
// We explicitly pass it through parse:
|
815
|
-
new NativeDate(Date.parse(Y)) :
|
816
|
-
// We have to manually make calls depending on argument
|
817
|
-
// length here
|
818
|
-
length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
|
819
|
-
length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
|
820
|
-
length >= 5 ? new NativeDate(Y, M, D, h, m) :
|
821
|
-
length >= 4 ? new NativeDate(Y, M, D, h) :
|
822
|
-
length >= 3 ? new NativeDate(Y, M, D) :
|
823
|
-
length >= 2 ? new NativeDate(Y, M) :
|
824
|
-
length >= 1 ? new NativeDate(Y) :
|
825
|
-
new NativeDate();
|
826
|
-
// Prevent mixups with unfixed Date object
|
827
|
-
date.constructor = Date;
|
828
|
-
return date;
|
829
|
-
}
|
830
|
-
return NativeDate.apply(this, arguments);
|
831
|
-
}
|
832
|
-
|
833
|
-
// 15.9.1.15 Date Time String Format.
|
834
|
-
var isoDateExpression = new RegExp("^" +
|
835
|
-
"(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
|
836
|
-
// 6-digit extended year
|
837
|
-
"(?:-(\\d{2})" + // optional month capture
|
838
|
-
"(?:-(\\d{2})" + // optional day capture
|
839
|
-
"(?:" + // capture hours:minutes:seconds.milliseconds
|
840
|
-
"T(\\d{2})" + // hours capture
|
841
|
-
":(\\d{2})" + // minutes capture
|
842
|
-
"(?:" + // optional :seconds.milliseconds
|
843
|
-
":(\\d{2})" + // seconds capture
|
844
|
-
"(?:(\\.\\d{1,}))?" + // milliseconds capture
|
845
|
-
")?" +
|
846
|
-
"(" + // capture UTC offset component
|
847
|
-
"Z|" + // UTC capture
|
848
|
-
"(?:" + // offset specifier +/-hours:minutes
|
849
|
-
"([-+])" + // sign capture
|
850
|
-
"(\\d{2})" + // hours offset capture
|
851
|
-
":(\\d{2})" + // minutes offset capture
|
852
|
-
")" +
|
853
|
-
")?)?)?)?" +
|
854
|
-
"$");
|
855
|
-
|
856
|
-
var months = [
|
857
|
-
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
|
858
|
-
];
|
859
|
-
|
860
|
-
function dayFromMonth(year, month) {
|
861
|
-
var t = month > 1 ? 1 : 0;
|
862
|
-
return (
|
863
|
-
months[month] +
|
864
|
-
Math.floor((year - 1969 + t) / 4) -
|
865
|
-
Math.floor((year - 1901 + t) / 100) +
|
866
|
-
Math.floor((year - 1601 + t) / 400) +
|
867
|
-
365 * (year - 1970)
|
868
|
-
);
|
869
|
-
}
|
870
|
-
|
871
|
-
function toUTC(t) {
|
872
|
-
return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
|
873
|
-
}
|
874
|
-
|
875
|
-
// Copy any custom methods a 3rd party library may have added
|
876
|
-
for (var key in NativeDate) {
|
877
|
-
Date[key] = NativeDate[key];
|
878
|
-
}
|
879
|
-
|
880
|
-
// Copy "native" methods explicitly; they may be non-enumerable
|
881
|
-
Date.now = NativeDate.now;
|
882
|
-
Date.UTC = NativeDate.UTC;
|
883
|
-
Date.prototype = NativeDate.prototype;
|
884
|
-
Date.prototype.constructor = Date;
|
885
|
-
|
886
|
-
// Upgrade Date.parse to handle simplified ISO 8601 strings
|
887
|
-
Date.parse = function parse(string) {
|
888
|
-
var match = isoDateExpression.exec(string);
|
889
|
-
if (match) {
|
890
|
-
// parse months, days, hours, minutes, seconds, and milliseconds
|
891
|
-
// provide default values if necessary
|
892
|
-
// parse the UTC offset component
|
893
|
-
var year = Number(match[1]),
|
894
|
-
month = Number(match[2] || 1) - 1,
|
895
|
-
day = Number(match[3] || 1) - 1,
|
896
|
-
hour = Number(match[4] || 0),
|
897
|
-
minute = Number(match[5] || 0),
|
898
|
-
second = Number(match[6] || 0),
|
899
|
-
millisecond = Math.floor(Number(match[7] || 0) * 1000),
|
900
|
-
// When time zone is missed, local offset should be used
|
901
|
-
// (ES 5.1 bug)
|
902
|
-
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
|
903
|
-
isLocalTime = Boolean(match[4] && !match[8]),
|
904
|
-
signOffset = match[9] === "-" ? 1 : -1,
|
905
|
-
hourOffset = Number(match[10] || 0),
|
906
|
-
minuteOffset = Number(match[11] || 0),
|
907
|
-
result;
|
908
|
-
if (
|
909
|
-
hour < (
|
910
|
-
minute > 0 || second > 0 || millisecond > 0 ?
|
911
|
-
24 : 25
|
912
|
-
) &&
|
913
|
-
minute < 60 && second < 60 && millisecond < 1000 &&
|
914
|
-
month > -1 && month < 12 && hourOffset < 24 &&
|
915
|
-
minuteOffset < 60 && // detect invalid offsets
|
916
|
-
day > -1 &&
|
917
|
-
day < (
|
918
|
-
dayFromMonth(year, month + 1) -
|
919
|
-
dayFromMonth(year, month)
|
920
|
-
)
|
921
|
-
) {
|
922
|
-
result = (
|
923
|
-
(dayFromMonth(year, month) + day) * 24 +
|
924
|
-
hour +
|
925
|
-
hourOffset * signOffset
|
926
|
-
) * 60;
|
927
|
-
result = (
|
928
|
-
(result + minute + minuteOffset * signOffset) * 60 +
|
929
|
-
second
|
930
|
-
) * 1000 + millisecond;
|
931
|
-
if (isLocalTime) {
|
932
|
-
result = toUTC(result);
|
933
|
-
}
|
934
|
-
if (-8.64e15 <= result && result <= 8.64e15) {
|
935
|
-
return result;
|
936
|
-
}
|
937
|
-
}
|
938
|
-
return NaN;
|
939
|
-
}
|
940
|
-
return NativeDate.parse.apply(this, arguments);
|
941
|
-
};
|
942
|
-
|
943
|
-
return Date;
|
944
|
-
})(Date);
|
945
|
-
}
|
946
|
-
|
947
|
-
// ES5 15.9.4.4
|
948
|
-
// http://es5.github.com/#x15.9.4.4
|
949
|
-
if (!Date.now) {
|
950
|
-
Date.now = function now() {
|
951
|
-
return new Date().getTime();
|
952
|
-
};
|
953
|
-
}
|
954
|
-
|
955
|
-
|
956
|
-
//
|
957
|
-
// Number
|
958
|
-
// ======
|
959
|
-
//
|
960
|
-
|
961
|
-
// ES5.1 15.7.4.5
|
962
|
-
// http://es5.github.com/#x15.7.4.5
|
963
|
-
if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
|
964
|
-
// Hide these variables and functions
|
965
|
-
(function () {
|
966
|
-
var base, size, data, i;
|
967
|
-
|
968
|
-
base = 1e7;
|
969
|
-
size = 6;
|
970
|
-
data = [0, 0, 0, 0, 0, 0];
|
971
|
-
|
972
|
-
function multiply(n, c) {
|
973
|
-
var i = -1;
|
974
|
-
while (++i < size) {
|
975
|
-
c += n * data[i];
|
976
|
-
data[i] = c % base;
|
977
|
-
c = Math.floor(c / base);
|
978
|
-
}
|
979
|
-
}
|
980
|
-
|
981
|
-
function divide(n) {
|
982
|
-
var i = size, c = 0;
|
983
|
-
while (--i >= 0) {
|
984
|
-
c += data[i];
|
985
|
-
data[i] = Math.floor(c / n);
|
986
|
-
c = (c % n) * base;
|
987
|
-
}
|
988
|
-
}
|
989
|
-
|
990
|
-
function numToString() {
|
991
|
-
var i = size;
|
992
|
-
var s = '';
|
993
|
-
while (--i >= 0) {
|
994
|
-
if (s !== '' || i === 0 || data[i] !== 0) {
|
995
|
-
var t = String(data[i]);
|
996
|
-
if (s === '') {
|
997
|
-
s = t;
|
998
|
-
} else {
|
999
|
-
s += '0000000'.slice(0, 7 - t.length) + t;
|
1000
|
-
}
|
1001
|
-
}
|
1002
|
-
}
|
1003
|
-
return s;
|
1004
|
-
}
|
1005
|
-
|
1006
|
-
function pow(x, n, acc) {
|
1007
|
-
return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
|
1008
|
-
}
|
1009
|
-
|
1010
|
-
function log(x) {
|
1011
|
-
var n = 0;
|
1012
|
-
while (x >= 4096) {
|
1013
|
-
n += 12;
|
1014
|
-
x /= 4096;
|
1015
|
-
}
|
1016
|
-
while (x >= 2) {
|
1017
|
-
n += 1;
|
1018
|
-
x /= 2;
|
1019
|
-
}
|
1020
|
-
return n;
|
1021
|
-
}
|
1022
|
-
|
1023
|
-
Number.prototype.toFixed = function toFixed(fractionDigits) {
|
1024
|
-
var f, x, s, m, e, z, j, k;
|
1025
|
-
|
1026
|
-
// Test for NaN and round fractionDigits down
|
1027
|
-
f = Number(fractionDigits);
|
1028
|
-
f = f !== f ? 0 : Math.floor(f);
|
1029
|
-
|
1030
|
-
if (f < 0 || f > 20) {
|
1031
|
-
throw new RangeError("Number.toFixed called with invalid number of decimals");
|
1032
|
-
}
|
1033
|
-
|
1034
|
-
x = Number(this);
|
1035
|
-
|
1036
|
-
// Test for NaN
|
1037
|
-
if (x !== x) {
|
1038
|
-
return "NaN";
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
// If it is too big or small, return the string value of the number
|
1042
|
-
if (x <= -1e21 || x >= 1e21) {
|
1043
|
-
return String(x);
|
1044
|
-
}
|
1045
|
-
|
1046
|
-
s = "";
|
1047
|
-
|
1048
|
-
if (x < 0) {
|
1049
|
-
s = "-";
|
1050
|
-
x = -x;
|
1051
|
-
}
|
1052
|
-
|
1053
|
-
m = "0";
|
1054
|
-
|
1055
|
-
if (x > 1e-21) {
|
1056
|
-
// 1e-21 < x < 1e21
|
1057
|
-
// -70 < log2(x) < 70
|
1058
|
-
e = log(x * pow(2, 69, 1)) - 69;
|
1059
|
-
z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
|
1060
|
-
z *= 0x10000000000000; // Math.pow(2, 52);
|
1061
|
-
e = 52 - e;
|
1062
|
-
|
1063
|
-
// -18 < e < 122
|
1064
|
-
// x = z / 2 ^ e
|
1065
|
-
if (e > 0) {
|
1066
|
-
multiply(0, z);
|
1067
|
-
j = f;
|
1068
|
-
|
1069
|
-
while (j >= 7) {
|
1070
|
-
multiply(1e7, 0);
|
1071
|
-
j -= 7;
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
multiply(pow(10, j, 1), 0);
|
1075
|
-
j = e - 1;
|
1076
|
-
|
1077
|
-
while (j >= 23) {
|
1078
|
-
divide(1 << 23);
|
1079
|
-
j -= 23;
|
1080
|
-
}
|
1081
|
-
|
1082
|
-
divide(1 << j);
|
1083
|
-
multiply(1, 1);
|
1084
|
-
divide(2);
|
1085
|
-
m = numToString();
|
1086
|
-
} else {
|
1087
|
-
multiply(0, z);
|
1088
|
-
multiply(1 << (-e), 0);
|
1089
|
-
m = numToString() + '0.00000000000000000000'.slice(2, 2 + f);
|
1090
|
-
}
|
1091
|
-
}
|
1092
|
-
|
1093
|
-
if (f > 0) {
|
1094
|
-
k = m.length;
|
1095
|
-
|
1096
|
-
if (k <= f) {
|
1097
|
-
m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
|
1098
|
-
} else {
|
1099
|
-
m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
|
1100
|
-
}
|
1101
|
-
} else {
|
1102
|
-
m = s + m;
|
1103
|
-
}
|
1104
|
-
|
1105
|
-
return m;
|
1106
|
-
};
|
1107
|
-
}());
|
1108
|
-
}
|
1109
|
-
|
1110
|
-
|
1111
|
-
//
|
1112
|
-
// String
|
1113
|
-
// ======
|
1114
|
-
//
|
1115
|
-
|
1116
|
-
// ES5 15.5.4.14
|
1117
|
-
// http://es5.github.com/#x15.5.4.14
|
1118
|
-
|
1119
|
-
// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
|
1120
|
-
// Many browsers do not split properly with regular expressions or they
|
1121
|
-
// do not perform the split correctly under obscure conditions.
|
1122
|
-
// See http://blog.stevenlevithan.com/archives/cross-browser-split
|
1123
|
-
// I've tested in many browsers and this seems to cover the deviant ones:
|
1124
|
-
// 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
|
1125
|
-
// '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
|
1126
|
-
// 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
|
1127
|
-
// [undefined, "t", undefined, "e", ...]
|
1128
|
-
// ''.split(/.?/) should be [], not [""]
|
1129
|
-
// '.'.split(/()()/) should be ["."], not ["", "", "."]
|
1130
|
-
|
1131
|
-
var string_split = String.prototype.split;
|
1132
|
-
if (
|
1133
|
-
'ab'.split(/(?:ab)*/).length !== 2 ||
|
1134
|
-
'.'.split(/(.?)(.?)/).length !== 4 ||
|
1135
|
-
'tesst'.split(/(s)*/)[1] === "t" ||
|
1136
|
-
'test'.split(/(?:)/, -1).length !== 4 ||
|
1137
|
-
''.split(/.?/).length ||
|
1138
|
-
'.'.split(/()()/).length > 1
|
1139
|
-
) {
|
1140
|
-
(function () {
|
1141
|
-
var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
|
1142
|
-
|
1143
|
-
String.prototype.split = function (separator, limit) {
|
1144
|
-
var string = this;
|
1145
|
-
if (separator === void 0 && limit === 0) {
|
1146
|
-
return [];
|
1147
|
-
}
|
1148
|
-
|
1149
|
-
// If `separator` is not a regex, use native split
|
1150
|
-
if (_toString.call(separator) !== "[object RegExp]") {
|
1151
|
-
return string_split.call(this, separator, limit);
|
1152
|
-
}
|
1153
|
-
|
1154
|
-
var output = [],
|
1155
|
-
flags = (separator.ignoreCase ? "i" : "") +
|
1156
|
-
(separator.multiline ? "m" : "") +
|
1157
|
-
(separator.extended ? "x" : "") + // Proposed for ES6
|
1158
|
-
(separator.sticky ? "y" : ""), // Firefox 3+
|
1159
|
-
lastLastIndex = 0,
|
1160
|
-
// Make `global` and avoid `lastIndex` issues by working with a copy
|
1161
|
-
separator2, match, lastIndex, lastLength;
|
1162
|
-
separator = new RegExp(separator.source, flags + "g");
|
1163
|
-
string += ""; // Type-convert
|
1164
|
-
if (!compliantExecNpcg) {
|
1165
|
-
// Doesn't need flags gy, but they don't hurt
|
1166
|
-
separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
|
1167
|
-
}
|
1168
|
-
/* Values for `limit`, per the spec:
|
1169
|
-
* If undefined: 4294967295 // Math.pow(2, 32) - 1
|
1170
|
-
* If 0, Infinity, or NaN: 0
|
1171
|
-
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
|
1172
|
-
* If negative number: 4294967296 - Math.floor(Math.abs(limit))
|
1173
|
-
* If other: Type-convert, then use the above rules
|
1174
|
-
*/
|
1175
|
-
limit = limit === void 0 ?
|
1176
|
-
-1 >>> 0 : // Math.pow(2, 32) - 1
|
1177
|
-
ToUint32(limit);
|
1178
|
-
while (match = separator.exec(string)) {
|
1179
|
-
// `separator.lastIndex` is not reliable cross-browser
|
1180
|
-
lastIndex = match.index + match[0].length;
|
1181
|
-
if (lastIndex > lastLastIndex) {
|
1182
|
-
output.push(string.slice(lastLastIndex, match.index));
|
1183
|
-
// Fix browsers whose `exec` methods don't consistently return `undefined` for
|
1184
|
-
// nonparticipating capturing groups
|
1185
|
-
if (!compliantExecNpcg && match.length > 1) {
|
1186
|
-
match[0].replace(separator2, function () {
|
1187
|
-
for (var i = 1; i < arguments.length - 2; i++) {
|
1188
|
-
if (arguments[i] === void 0) {
|
1189
|
-
match[i] = void 0;
|
1190
|
-
}
|
1191
|
-
}
|
1192
|
-
});
|
1193
|
-
}
|
1194
|
-
if (match.length > 1 && match.index < string.length) {
|
1195
|
-
Array.prototype.push.apply(output, match.slice(1));
|
1196
|
-
}
|
1197
|
-
lastLength = match[0].length;
|
1198
|
-
lastLastIndex = lastIndex;
|
1199
|
-
if (output.length >= limit) {
|
1200
|
-
break;
|
1201
|
-
}
|
1202
|
-
}
|
1203
|
-
if (separator.lastIndex === match.index) {
|
1204
|
-
separator.lastIndex++; // Avoid an infinite loop
|
1205
|
-
}
|
1206
|
-
}
|
1207
|
-
if (lastLastIndex === string.length) {
|
1208
|
-
if (lastLength || !separator.test("")) {
|
1209
|
-
output.push("");
|
1210
|
-
}
|
1211
|
-
} else {
|
1212
|
-
output.push(string.slice(lastLastIndex));
|
1213
|
-
}
|
1214
|
-
return output.length > limit ? output.slice(0, limit) : output;
|
1215
|
-
};
|
1216
|
-
}());
|
1217
|
-
|
1218
|
-
// [bugfix, chrome]
|
1219
|
-
// If separator is undefined, then the result array contains just one String,
|
1220
|
-
// which is the this value (converted to a String). If limit is not undefined,
|
1221
|
-
// then the output array is truncated so that it contains no more than limit
|
1222
|
-
// elements.
|
1223
|
-
// "0".split(undefined, 0) -> []
|
1224
|
-
} else if ("0".split(void 0, 0).length) {
|
1225
|
-
String.prototype.split = function split(separator, limit) {
|
1226
|
-
if (separator === void 0 && limit === 0) { return []; }
|
1227
|
-
return string_split.call(this, separator, limit);
|
1228
|
-
};
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
var str_replace = String.prototype.replace;
|
1232
|
-
var replaceReportsGroupsCorrectly = (function () {
|
1233
|
-
var groups = [];
|
1234
|
-
'x'.replace(/x(.)?/g, function (match, group) {
|
1235
|
-
groups.push(group);
|
1236
|
-
});
|
1237
|
-
return groups.length === 1 && typeof groups[0] === 'undefined';
|
1238
|
-
}());
|
1239
|
-
|
1240
|
-
if (!replaceReportsGroupsCorrectly) {
|
1241
|
-
String.prototype.replace = function replace(searchValue, replaceValue) {
|
1242
|
-
var isFn = isFunction(replaceValue);
|
1243
|
-
var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
|
1244
|
-
if (!isFn || !hasCapturingGroups) {
|
1245
|
-
return str_replace.call(this, searchValue, replaceValue);
|
1246
|
-
} else {
|
1247
|
-
var wrappedReplaceValue = function (match) {
|
1248
|
-
var length = arguments.length;
|
1249
|
-
var originalLastIndex = searchValue.lastIndex;
|
1250
|
-
searchValue.lastIndex = 0;
|
1251
|
-
var args = searchValue.exec(match);
|
1252
|
-
searchValue.lastIndex = originalLastIndex;
|
1253
|
-
args.push(arguments[length - 2], arguments[length - 1]);
|
1254
|
-
return replaceValue.apply(this, args);
|
1255
|
-
};
|
1256
|
-
return str_replace.call(this, searchValue, wrappedReplaceValue);
|
1257
|
-
}
|
1258
|
-
};
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
// ECMA-262, 3rd B.2.3
|
1262
|
-
// Not an ECMAScript standard, although ECMAScript 3rd Edition has a
|
1263
|
-
// non-normative section suggesting uniform semantics and it should be
|
1264
|
-
// normalized across all browsers
|
1265
|
-
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
|
1266
|
-
if ("".substr && "0b".substr(-1) !== "b") {
|
1267
|
-
var string_substr = String.prototype.substr;
|
1268
|
-
/**
|
1269
|
-
* Get the substring of a string
|
1270
|
-
* @param {integer} start where to start the substring
|
1271
|
-
* @param {integer} length how many characters to return
|
1272
|
-
* @return {string}
|
1273
|
-
*/
|
1274
|
-
String.prototype.substr = function substr(start, length) {
|
1275
|
-
return string_substr.call(
|
1276
|
-
this,
|
1277
|
-
start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
|
1278
|
-
length
|
1279
|
-
);
|
1280
|
-
};
|
1281
|
-
}
|
1282
|
-
|
1283
|
-
// ES5 15.5.4.20
|
1284
|
-
// whitespace from: http://es5.github.io/#x15.5.4.20
|
1285
|
-
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
|
1286
|
-
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
|
1287
|
-
"\u2029\uFEFF";
|
1288
|
-
var zeroWidth = '\u200b';
|
1289
|
-
if (!String.prototype.trim || ws.trim() || !zeroWidth.trim()) {
|
1290
|
-
// http://blog.stevenlevithan.com/archives/faster-trim-javascript
|
1291
|
-
// http://perfectionkills.com/whitespace-deviations/
|
1292
|
-
ws = "[" + ws + "]";
|
1293
|
-
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
|
1294
|
-
trimEndRegexp = new RegExp(ws + ws + "*$");
|
1295
|
-
String.prototype.trim = function trim() {
|
1296
|
-
if (this === void 0 || this === null) {
|
1297
|
-
throw new TypeError("can't convert " + this + " to object");
|
1298
|
-
}
|
1299
|
-
return String(this)
|
1300
|
-
.replace(trimBeginRegexp, "")
|
1301
|
-
.replace(trimEndRegexp, "");
|
1302
|
-
};
|
1303
|
-
}
|
1304
|
-
|
1305
|
-
// ES-5 15.1.2.2
|
1306
|
-
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
|
1307
|
-
parseInt = (function (origParseInt) {
|
1308
|
-
var hexRegex = /^0[xX]/;
|
1309
|
-
return function parseIntES5(str, radix) {
|
1310
|
-
str = String(str).trim();
|
1311
|
-
if (!Number(radix)) {
|
1312
|
-
radix = hexRegex.test(str) ? 16 : 10;
|
1313
|
-
}
|
1314
|
-
return origParseInt(str, radix);
|
1315
|
-
};
|
1316
|
-
}(parseInt));
|
1317
|
-
}
|
1318
|
-
|
1319
|
-
//
|
1320
|
-
// Util
|
1321
|
-
// ======
|
1322
|
-
//
|
1323
|
-
|
1324
|
-
// ES5 9.4
|
1325
|
-
// http://es5.github.com/#x9.4
|
1326
|
-
// http://jsperf.com/to-integer
|
1327
|
-
|
1328
|
-
function toInteger(n) {
|
1329
|
-
n = +n;
|
1330
|
-
if (n !== n) { // isNaN
|
1331
|
-
n = 0;
|
1332
|
-
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
1333
|
-
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
1334
|
-
}
|
1335
|
-
return n;
|
1336
|
-
}
|
1337
|
-
|
1338
|
-
function isPrimitive(input) {
|
1339
|
-
var type = typeof input;
|
1340
|
-
return (
|
1341
|
-
input === null ||
|
1342
|
-
type === "undefined" ||
|
1343
|
-
type === "boolean" ||
|
1344
|
-
type === "number" ||
|
1345
|
-
type === "string"
|
1346
|
-
);
|
1347
|
-
}
|
1348
|
-
|
1349
|
-
function toPrimitive(input) {
|
1350
|
-
var val, valueOf, toStr;
|
1351
|
-
if (isPrimitive(input)) {
|
1352
|
-
return input;
|
1353
|
-
}
|
1354
|
-
valueOf = input.valueOf;
|
1355
|
-
if (isFunction(valueOf)) {
|
1356
|
-
val = valueOf.call(input);
|
1357
|
-
if (isPrimitive(val)) {
|
1358
|
-
return val;
|
1359
|
-
}
|
1360
|
-
}
|
1361
|
-
toStr = input.toString;
|
1362
|
-
if (isFunction(toStr)) {
|
1363
|
-
val = toStr.call(input);
|
1364
|
-
if (isPrimitive(val)) {
|
1365
|
-
return val;
|
1366
|
-
}
|
1367
|
-
}
|
1368
|
-
throw new TypeError();
|
1369
|
-
}
|
1370
|
-
|
1371
|
-
// ES5 9.9
|
1372
|
-
// http://es5.github.com/#x9.9
|
1373
|
-
var toObject = function (o) {
|
1374
|
-
if (o == null) { // this matches both null and undefined
|
1375
|
-
throw new TypeError("can't convert " + o + " to object");
|
1376
|
-
}
|
1377
|
-
return Object(o);
|
1378
|
-
};
|
1379
|
-
|
1380
|
-
var ToUint32 = function ToUint32(x) {
|
1381
|
-
return x >>> 0;
|
1382
|
-
};
|
1383
|
-
|
1384
|
-
})();
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
(function($, shims){
|
1390
|
-
var defineProperty = 'defineProperty';
|
1391
|
-
var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
|
1392
|
-
//safari5 has defineProperty-interface, but it can't be used on dom-object
|
1393
|
-
//only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
|
1394
|
-
if (advancedObjectProperties && Object[defineProperty] && Object.prototype.__defineGetter__) {
|
1395
|
-
(function(){
|
1396
|
-
try {
|
1397
|
-
var foo = document.createElement('foo');
|
1398
|
-
Object[defineProperty](foo, 'bar', {
|
1399
|
-
get: function(){
|
1400
|
-
return true;
|
1401
|
-
}
|
1402
|
-
});
|
1403
|
-
advancedObjectProperties = !!foo.bar;
|
1404
|
-
}
|
1405
|
-
catch (e) {
|
1406
|
-
advancedObjectProperties = false;
|
1407
|
-
}
|
1408
|
-
foo = null;
|
1409
|
-
})();
|
1410
|
-
}
|
1411
|
-
|
1412
|
-
Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)));
|
1413
|
-
Modernizr.advancedObjectProperties = advancedObjectProperties;
|
1414
|
-
|
1415
|
-
if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
|
1416
|
-
var call = Function.prototype.call;
|
1417
|
-
var prototypeOfObject = Object.prototype;
|
1418
|
-
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
1419
|
-
|
1420
|
-
shims.objectCreate = function(proto, props, opts, no__proto__){
|
1421
|
-
var o;
|
1422
|
-
var f = function(){};
|
1423
|
-
|
1424
|
-
f.prototype = proto;
|
1425
|
-
o = new f();
|
1426
|
-
|
1427
|
-
if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
|
1428
|
-
o.__proto__ = proto;
|
1429
|
-
}
|
1430
|
-
|
1431
|
-
if(props){
|
1432
|
-
shims.defineProperties(o, props);
|
1433
|
-
}
|
1434
|
-
|
1435
|
-
if(opts){
|
1436
|
-
o.options = $.extend(true, {}, o.options || {}, opts);
|
1437
|
-
opts = o.options;
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
if(o._create && $.isFunction(o._create)){
|
1441
|
-
o._create(opts);
|
1442
|
-
}
|
1443
|
-
return o;
|
1444
|
-
};
|
1445
|
-
|
1446
|
-
shims.defineProperties = function(object, props){
|
1447
|
-
for (var name in props) {
|
1448
|
-
if (owns(props, name)) {
|
1449
|
-
shims.defineProperty(object, name, props[name]);
|
1450
|
-
}
|
1451
|
-
}
|
1452
|
-
return object;
|
1453
|
-
};
|
1454
|
-
|
1455
|
-
var descProps = ['configurable', 'enumerable', 'writable'];
|
1456
|
-
shims.defineProperty = function(proto, property, descriptor){
|
1457
|
-
if(typeof descriptor != "object" || descriptor === null){return proto;}
|
1458
|
-
|
1459
|
-
if(owns(descriptor, "value")){
|
1460
|
-
proto[property] = descriptor.value;
|
1461
|
-
return proto;
|
1462
|
-
}
|
1463
|
-
|
1464
|
-
if(proto.__defineGetter__){
|
1465
|
-
if (typeof descriptor.get == "function") {
|
1466
|
-
proto.__defineGetter__(property, descriptor.get);
|
1467
|
-
}
|
1468
|
-
if (typeof descriptor.set == "function"){
|
1469
|
-
proto.__defineSetter__(property, descriptor.set);
|
1470
|
-
}
|
1471
|
-
}
|
1472
|
-
return proto;
|
1473
|
-
};
|
1474
|
-
|
1475
|
-
shims.getPrototypeOf = function (object) {
|
1476
|
-
return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
|
1477
|
-
};
|
1478
|
-
|
1479
|
-
//based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
|
1480
|
-
shims.getOwnPropertyDescriptor = function(obj, prop){
|
1481
|
-
if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
|
1482
|
-
throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
|
1483
|
-
}
|
1484
|
-
var descriptor;
|
1485
|
-
if(Object.defineProperty && Object.getOwnPropertyDescriptor){
|
1486
|
-
try{
|
1487
|
-
descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
1488
|
-
return descriptor;
|
1489
|
-
} catch(e){}
|
1490
|
-
}
|
1491
|
-
descriptor = {
|
1492
|
-
configurable: true,
|
1493
|
-
enumerable: true,
|
1494
|
-
writable: true,
|
1495
|
-
value: undefined
|
1496
|
-
};
|
1497
|
-
var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
|
1498
|
-
setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
|
1499
|
-
;
|
1500
|
-
|
1501
|
-
if (!getter && !setter) { // not an accessor so return prop
|
1502
|
-
if(!owns(obj, prop)){
|
1503
|
-
return;
|
1504
|
-
}
|
1505
|
-
descriptor.value = obj[prop];
|
1506
|
-
return descriptor;
|
1507
|
-
}
|
1508
|
-
|
1509
|
-
// there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
|
1510
|
-
delete descriptor.writable;
|
1511
|
-
delete descriptor.value;
|
1512
|
-
descriptor.get = descriptor.set = undefined;
|
1513
|
-
|
1514
|
-
if(getter){
|
1515
|
-
descriptor.get = getter;
|
1516
|
-
}
|
1517
|
-
|
1518
|
-
if(setter){
|
1519
|
-
descriptor.set = setter;
|
1520
|
-
}
|
1521
|
-
|
1522
|
-
return descriptor;
|
1523
|
-
};
|
1524
|
-
|
1525
|
-
}
|
1526
|
-
webshims.isReady('es5', true);
|
1527
|
-
})(webshims.$, webshims);
|
1528
|
-
|
1529
|
-
|
1530
|
-
;webshims.register('form-number-date-api', function($, webshims, window, document, undefined, options){
|
1531
|
-
"use strict";
|
1532
|
-
if(!webshims.addInputType){
|
1533
|
-
webshims.error("you can not call forms-ext feature after calling forms feature. call both at once instead: $.webshims.polyfill('forms forms-ext')");
|
1534
|
-
}
|
1535
|
-
|
1536
|
-
if(!webshims.getStep){
|
1537
|
-
webshims.getStep = function(elem, type){
|
1538
|
-
var step = $.attr(elem, 'step');
|
1539
|
-
if(step === 'any'){
|
1540
|
-
return step;
|
1541
|
-
}
|
1542
|
-
type = type || getType(elem);
|
1543
|
-
if(!typeModels[type] || !typeModels[type].step){
|
1544
|
-
return step;
|
1545
|
-
}
|
1546
|
-
step = typeProtos.number.asNumber(step);
|
1547
|
-
return ((!isNaN(step) && step > 0) ? step : typeModels[type].step) * (typeModels[type].stepScaleFactor || 1);
|
1548
|
-
};
|
1549
|
-
}
|
1550
|
-
if(!webshims.addMinMaxNumberToCache){
|
1551
|
-
webshims.addMinMaxNumberToCache = function(attr, elem, cache){
|
1552
|
-
if (!(attr+'AsNumber' in cache)) {
|
1553
|
-
cache[attr+'AsNumber'] = typeModels[cache.type].asNumber(elem.attr(attr));
|
1554
|
-
if(isNaN(cache[attr+'AsNumber']) && (attr+'Default' in typeModels[cache.type])){
|
1555
|
-
cache[attr+'AsNumber'] = typeModels[cache.type][attr+'Default'];
|
1556
|
-
}
|
1557
|
-
}
|
1558
|
-
};
|
1559
|
-
}
|
1560
|
-
|
1561
|
-
var nan = parseInt('NaN', 10),
|
1562
|
-
doc = document,
|
1563
|
-
typeModels = webshims.inputTypes,
|
1564
|
-
isNumber = function(string){
|
1565
|
-
return (typeof string == 'number' || (string && string == string * 1));
|
1566
|
-
},
|
1567
|
-
supportsType = function(type){
|
1568
|
-
return ($('<input type="'+type+'" />').prop('type') === type);
|
1569
|
-
},
|
1570
|
-
getType = function(elem){
|
1571
|
-
return (elem.getAttribute('type') || '').toLowerCase();
|
1572
|
-
},
|
1573
|
-
isDateTimePart = function(string){
|
1574
|
-
return (string && !(isNaN(string * 1)));
|
1575
|
-
},
|
1576
|
-
addMinMaxNumberToCache = webshims.addMinMaxNumberToCache,
|
1577
|
-
addleadingZero = function(val, len){
|
1578
|
-
val = ''+val;
|
1579
|
-
len = len - val.length;
|
1580
|
-
for(var i = 0; i < len; i++){
|
1581
|
-
val = '0'+val;
|
1582
|
-
}
|
1583
|
-
return val;
|
1584
|
-
},
|
1585
|
-
EPS = 1e-7,
|
1586
|
-
typeBugs = webshims.bugs.bustedValidity
|
1587
|
-
;
|
1588
|
-
|
1589
|
-
webshims.addValidityRule('stepMismatch', function(input, val, cache, validityState){
|
1590
|
-
if(val === ''){return false;}
|
1591
|
-
if(!('type' in cache)){
|
1592
|
-
cache.type = getType(input[0]);
|
1593
|
-
}
|
1594
|
-
if(cache.type == 'week'){return false;}
|
1595
|
-
var base, attrVal;
|
1596
|
-
var ret = (validityState || {}).stepMismatch || false;
|
1597
|
-
if(typeModels[cache.type] && typeModels[cache.type].step){
|
1598
|
-
if( !('step' in cache) ){
|
1599
|
-
cache.step = webshims.getStep(input[0], cache.type);
|
1600
|
-
}
|
1601
|
-
|
1602
|
-
if(cache.step == 'any'){return false;}
|
1603
|
-
|
1604
|
-
if(!('valueAsNumber' in cache)){
|
1605
|
-
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
|
1606
|
-
}
|
1607
|
-
if(isNaN(cache.valueAsNumber)){return false;}
|
1608
|
-
|
1609
|
-
addMinMaxNumberToCache('min', input, cache);
|
1610
|
-
base = cache.minAsNumber;
|
1611
|
-
|
1612
|
-
if(isNaN(base) && (attrVal = input.prop('defaultValue'))){
|
1613
|
-
base = typeModels[cache.type].asNumber( attrVal );
|
1614
|
-
}
|
1615
|
-
|
1616
|
-
if(isNaN(base)){
|
1617
|
-
base = typeModels[cache.type].stepBase || 0;
|
1618
|
-
}
|
1619
|
-
|
1620
|
-
ret = Math.abs((cache.valueAsNumber - base) % cache.step);
|
1621
|
-
|
1622
|
-
ret = !( ret <= EPS || Math.abs(ret - cache.step) <= EPS );
|
1623
|
-
}
|
1624
|
-
return ret;
|
1625
|
-
});
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
[{name: 'rangeOverflow', attr: 'max', factor: 1}, {name: 'rangeUnderflow', attr: 'min', factor: -1}].forEach(function(data, i){
|
1630
|
-
webshims.addValidityRule(data.name, function(input, val, cache, validityState) {
|
1631
|
-
var ret = (validityState || {})[data.name] || false;
|
1632
|
-
if(val === ''){return ret;}
|
1633
|
-
if (!('type' in cache)) {
|
1634
|
-
cache.type = getType(input[0]);
|
1635
|
-
}
|
1636
|
-
if (typeModels[cache.type] && typeModels[cache.type].asNumber) {
|
1637
|
-
if(!('valueAsNumber' in cache)){
|
1638
|
-
cache.valueAsNumber = typeModels[cache.type].asNumber( val );
|
1639
|
-
}
|
1640
|
-
if(isNaN(cache.valueAsNumber)){
|
1641
|
-
return false;
|
1642
|
-
}
|
1643
|
-
|
1644
|
-
addMinMaxNumberToCache(data.attr, input, cache);
|
1645
|
-
|
1646
|
-
if(isNaN(cache[data.attr+'AsNumber'])){
|
1647
|
-
return ret;
|
1648
|
-
}
|
1649
|
-
ret = ( cache[data.attr+'AsNumber'] * data.factor < cache.valueAsNumber * data.factor - EPS );
|
1650
|
-
}
|
1651
|
-
return ret;
|
1652
|
-
});
|
1653
|
-
});
|
1654
|
-
|
1655
|
-
webshims.reflectProperties(['input'], ['max', 'min', 'step']);
|
1656
|
-
|
1657
|
-
|
1658
|
-
//IDLs and methods, that aren't part of constrain validation, but strongly tight to it
|
1659
|
-
var valueAsNumberDescriptor = webshims.defineNodeNameProperty('input', 'valueAsNumber', {
|
1660
|
-
prop: {
|
1661
|
-
get: function(){
|
1662
|
-
var elem = this;
|
1663
|
-
var type = getType(elem);
|
1664
|
-
var ret = (typeModels[type] && typeModels[type].asNumber) ?
|
1665
|
-
typeModels[type].asNumber($.prop(elem, 'value')) :
|
1666
|
-
(valueAsNumberDescriptor.prop._supget && valueAsNumberDescriptor.prop._supget.apply(elem, arguments));
|
1667
|
-
if(ret == null){
|
1668
|
-
ret = nan;
|
1669
|
-
}
|
1670
|
-
return ret;
|
1671
|
-
},
|
1672
|
-
set: function(val){
|
1673
|
-
var elem = this;
|
1674
|
-
var type = getType(elem);
|
1675
|
-
if(typeModels[type] && typeModels[type].numberToString){
|
1676
|
-
//is NaN a number?
|
1677
|
-
if(isNaN(val)){
|
1678
|
-
$.prop(elem, 'value', '');
|
1679
|
-
return;
|
1680
|
-
}
|
1681
|
-
var set = typeModels[type].numberToString(val);
|
1682
|
-
if(set !== false){
|
1683
|
-
$.prop(elem, 'value', set);
|
1684
|
-
} else {
|
1685
|
-
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
|
1686
|
-
}
|
1687
|
-
} else if(valueAsNumberDescriptor.prop._supset) {
|
1688
|
-
valueAsNumberDescriptor.prop._supset.apply(elem, arguments);
|
1689
|
-
}
|
1690
|
-
}
|
1691
|
-
}
|
1692
|
-
});
|
1693
|
-
|
1694
|
-
var valueAsDateDescriptor = webshims.defineNodeNameProperty('input', 'valueAsDate', {
|
1695
|
-
prop: {
|
1696
|
-
get: function(){
|
1697
|
-
var elem = this;
|
1698
|
-
var type = getType(elem);
|
1699
|
-
return (typeModels[type] && typeModels[type].asDate && !typeModels[type].noAsDate) ?
|
1700
|
-
typeModels[type].asDate($.prop(elem, 'value')) :
|
1701
|
-
valueAsDateDescriptor.prop._supget && valueAsDateDescriptor.prop._supget.call(elem) || null;
|
1702
|
-
},
|
1703
|
-
set: function(value){
|
1704
|
-
var elem = this;
|
1705
|
-
var type = getType(elem);
|
1706
|
-
if(typeModels[type] && typeModels[type].dateToString && !typeModels[type].noAsDate){
|
1707
|
-
|
1708
|
-
if(value === null){
|
1709
|
-
$.prop(elem, 'value', '');
|
1710
|
-
return '';
|
1711
|
-
}
|
1712
|
-
var set = typeModels[type].dateToString(value);
|
1713
|
-
if(set !== false){
|
1714
|
-
$.prop(elem, 'value', set);
|
1715
|
-
return set;
|
1716
|
-
} else {
|
1717
|
-
webshims.error('INVALID_STATE_ERR: DOM Exception 11');
|
1718
|
-
}
|
1719
|
-
} else {
|
1720
|
-
return valueAsDateDescriptor.prop._supset && valueAsDateDescriptor.prop._supset.apply(elem, arguments) || null;
|
1721
|
-
}
|
1722
|
-
}
|
1723
|
-
}
|
1724
|
-
});
|
1725
|
-
|
1726
|
-
$.each({stepUp: 1, stepDown: -1}, function(name, stepFactor){
|
1727
|
-
var stepDescriptor = webshims.defineNodeNameProperty('input', name, {
|
1728
|
-
prop: {
|
1729
|
-
value: function(factor){
|
1730
|
-
var step, val, valModStep, alignValue, cache, base, attrVal;
|
1731
|
-
var type = getType(this);
|
1732
|
-
if(typeModels[type] && typeModels[type].asNumber){
|
1733
|
-
cache = {type: type};
|
1734
|
-
if(!factor){
|
1735
|
-
factor = 1;
|
1736
|
-
webshims.warn("you should always use a factor for stepUp/stepDown");
|
1737
|
-
}
|
1738
|
-
factor *= stepFactor;
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
step = webshims.getStep(this, type);
|
1745
|
-
|
1746
|
-
if(step == 'any'){
|
1747
|
-
webshims.info("step is 'any' can't apply stepUp/stepDown");
|
1748
|
-
throw('invalid state error');
|
1749
|
-
}
|
1750
|
-
|
1751
|
-
webshims.addMinMaxNumberToCache('min', $(this), cache);
|
1752
|
-
webshims.addMinMaxNumberToCache('max', $(this), cache);
|
1753
|
-
|
1754
|
-
val = $.prop(this, 'valueAsNumber');
|
1755
|
-
|
1756
|
-
if(factor > 0 && !isNaN(cache.minAsNumber) && (isNaN(val) || cache.minAsNumber > val)){
|
1757
|
-
$.prop(this, 'valueAsNumber', cache.minAsNumber);
|
1758
|
-
return;
|
1759
|
-
} else if(factor < 0 && !isNaN(cache.maxAsNumber) && (isNaN(val) || cache.maxAsNumber < val)){
|
1760
|
-
$.prop(this, 'valueAsNumber', cache.maxAsNumber);
|
1761
|
-
return;
|
1762
|
-
}
|
1763
|
-
|
1764
|
-
if(isNaN(val)){
|
1765
|
-
val = 0;
|
1766
|
-
}
|
1767
|
-
|
1768
|
-
base = cache.minAsNumber;
|
1769
|
-
|
1770
|
-
if(isNaN(base) && (attrVal = $.prop(this, 'defaultValue'))){
|
1771
|
-
base = typeModels[type].asNumber( attrVal );
|
1772
|
-
}
|
1773
|
-
|
1774
|
-
if(!base){
|
1775
|
-
base = 0;
|
1776
|
-
}
|
1777
|
-
|
1778
|
-
step *= factor;
|
1779
|
-
|
1780
|
-
val = (val + step).toFixed(5) * 1;
|
1781
|
-
|
1782
|
-
valModStep = (val - base) % step;
|
1783
|
-
|
1784
|
-
if ( valModStep && (Math.abs(valModStep) > EPS) ) {
|
1785
|
-
alignValue = val - valModStep;
|
1786
|
-
alignValue += ( valModStep > 0 ) ? step : ( -step );
|
1787
|
-
val = alignValue.toFixed(5) * 1;
|
1788
|
-
}
|
1789
|
-
|
1790
|
-
if( (!isNaN(cache.maxAsNumber) && val > cache.maxAsNumber) || (!isNaN(cache.minAsNumber) && val < cache.minAsNumber) ){
|
1791
|
-
webshims.info("max/min overflow can't apply stepUp/stepDown");
|
1792
|
-
return;
|
1793
|
-
}
|
1794
|
-
|
1795
|
-
$.prop(this, 'valueAsNumber', val);
|
1796
|
-
|
1797
|
-
} else if(stepDescriptor.prop && stepDescriptor.prop._supvalue){
|
1798
|
-
return stepDescriptor.prop._supvalue.apply(this, arguments);
|
1799
|
-
} else {
|
1800
|
-
webshims.info("no step method for type: "+ type);
|
1801
|
-
throw('invalid state error');
|
1802
|
-
}
|
1803
|
-
}
|
1804
|
-
}
|
1805
|
-
});
|
1806
|
-
});
|
1807
|
-
|
1808
|
-
/*
|
1809
|
-
* ToDO: WEEK
|
1810
|
-
*/
|
1811
|
-
// var getWeek = function(date){
|
1812
|
-
// var time;
|
1813
|
-
// var checkDate = new Date(date.getTime());
|
1814
|
-
//
|
1815
|
-
// checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
|
1816
|
-
//
|
1817
|
-
// time = checkDate.getTime();
|
1818
|
-
// checkDate.setMonth(0);
|
1819
|
-
// checkDate.setDate(1);
|
1820
|
-
// return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
|
1821
|
-
// };
|
1822
|
-
//
|
1823
|
-
// var setWeek = function(year, week){
|
1824
|
-
// var date = new Date(year, 0, 1);
|
1825
|
-
//
|
1826
|
-
// week = (week - 1) * 86400000 * 7;
|
1827
|
-
// date = new Date(date.getTime() + week);
|
1828
|
-
// date.setDate(date.getDate() + 1 - (date.getDay() || 7));
|
1829
|
-
// return date;
|
1830
|
-
// };
|
1831
|
-
|
1832
|
-
var typeProtos = {
|
1833
|
-
|
1834
|
-
number: {
|
1835
|
-
bad: function(val){
|
1836
|
-
return !(isNumber(val));
|
1837
|
-
},
|
1838
|
-
step: 1,
|
1839
|
-
//stepBase: 0, 0 = default
|
1840
|
-
stepScaleFactor: 1,
|
1841
|
-
asNumber: function(str){
|
1842
|
-
return (isNumber(str)) ? str * 1 : nan;
|
1843
|
-
},
|
1844
|
-
numberToString: function(num){
|
1845
|
-
return (isNumber(num)) ? num : false;
|
1846
|
-
}
|
1847
|
-
},
|
1848
|
-
|
1849
|
-
range: {
|
1850
|
-
minDefault: 0,
|
1851
|
-
maxDefault: 100
|
1852
|
-
},
|
1853
|
-
color: {
|
1854
|
-
bad: (function(){
|
1855
|
-
var cReg = /^\u0023[a-f0-9]{6}$/;
|
1856
|
-
return function(val){
|
1857
|
-
return (!val || val.length != 7 || !(cReg.test(val)));
|
1858
|
-
};
|
1859
|
-
})()
|
1860
|
-
},
|
1861
|
-
date: {
|
1862
|
-
bad: function(val){
|
1863
|
-
if(!val || !val.split || !(/\d$/.test(val))){return true;}
|
1864
|
-
var i;
|
1865
|
-
var valA = val.split(/\u002D/);
|
1866
|
-
if(valA.length !== 3){return true;}
|
1867
|
-
var ret = false;
|
1868
|
-
|
1869
|
-
|
1870
|
-
if(valA[0].length < 4 || valA[1].length != 2 || valA[1] > 12 || valA[2].length != 2 || valA[2] > 33){
|
1871
|
-
ret = true;
|
1872
|
-
} else {
|
1873
|
-
for(i = 0; i < 3; i++){
|
1874
|
-
if(!isDateTimePart(valA[i])){
|
1875
|
-
ret = true;
|
1876
|
-
break;
|
1877
|
-
}
|
1878
|
-
}
|
1879
|
-
}
|
1880
|
-
|
1881
|
-
return ret || (val !== this.dateToString( this.asDate(val, true) ) );
|
1882
|
-
},
|
1883
|
-
step: 1,
|
1884
|
-
//stepBase: 0, 0 = default
|
1885
|
-
stepScaleFactor: 86400000,
|
1886
|
-
asDate: function(val, _noMismatch){
|
1887
|
-
if(!_noMismatch && this.bad(val)){
|
1888
|
-
return null;
|
1889
|
-
}
|
1890
|
-
return new Date(this.asNumber(val, true));
|
1891
|
-
},
|
1892
|
-
asNumber: function(str, _noMismatch){
|
1893
|
-
var ret = nan;
|
1894
|
-
if(_noMismatch || !this.bad(str)){
|
1895
|
-
str = str.split(/\u002D/);
|
1896
|
-
ret = Date.UTC(str[0], str[1] - 1, str[2]);
|
1897
|
-
}
|
1898
|
-
return ret;
|
1899
|
-
},
|
1900
|
-
numberToString: function(num){
|
1901
|
-
return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
|
1902
|
-
},
|
1903
|
-
dateToString: function(date){
|
1904
|
-
return (date && date.getFullYear) ? addleadingZero(date.getUTCFullYear(), 4) +'-'+ addleadingZero(date.getUTCMonth()+1, 2) +'-'+ addleadingZero(date.getUTCDate(), 2) : false;
|
1905
|
-
}
|
1906
|
-
},
|
1907
|
-
/*
|
1908
|
-
* ToDO: WEEK
|
1909
|
-
*/
|
1910
|
-
// week: {
|
1911
|
-
// bad: function(val){
|
1912
|
-
// if(!val || !val.split){return true;}
|
1913
|
-
// var valA = val.split('-W');
|
1914
|
-
// var ret = true;
|
1915
|
-
// if(valA.length == 2 && valA[0].length > 3 && valA.length == 2){
|
1916
|
-
// ret = this.dateToString(setWeek(valA[0], valA[1])) != val;
|
1917
|
-
// }
|
1918
|
-
// return ret;
|
1919
|
-
// },
|
1920
|
-
// step: 1,
|
1921
|
-
// stepScaleFactor: 604800000,
|
1922
|
-
// stepBase: -259200000,
|
1923
|
-
// asDate: function(str, _noMismatch){
|
1924
|
-
// var ret = null;
|
1925
|
-
// if(_noMismatch || !this.bad(str)){
|
1926
|
-
// ret = str.split('-W');
|
1927
|
-
// ret = setWeek(ret[0], ret[1]);
|
1928
|
-
// }
|
1929
|
-
// return ret;
|
1930
|
-
// },
|
1931
|
-
// asNumber: function(str, _noMismatch){
|
1932
|
-
// var ret = nan;
|
1933
|
-
// var date = this.asDate(str, _noMismatch);
|
1934
|
-
// if(date && date.getUTCFullYear){
|
1935
|
-
// ret = date.getTime();
|
1936
|
-
// }
|
1937
|
-
// return ret;
|
1938
|
-
// },
|
1939
|
-
// dateToString: function(date){
|
1940
|
-
// var week, checkDate;
|
1941
|
-
// var ret = false;
|
1942
|
-
// if(date && date.getFullYear){
|
1943
|
-
// week = getWeek(date);
|
1944
|
-
// if(week == 1){
|
1945
|
-
// checkDate = new Date(date.getTime());
|
1946
|
-
// checkDate.setDate(checkDate.getDate() + 7);
|
1947
|
-
// date.setUTCFullYear(checkDate.getUTCFullYear());
|
1948
|
-
// }
|
1949
|
-
// ret = addleadingZero(date.getUTCFullYear(), 4) +'-W'+addleadingZero(week, 2);
|
1950
|
-
// }
|
1951
|
-
// return ret;
|
1952
|
-
// },
|
1953
|
-
// numberToString: function(num){
|
1954
|
-
// return (isNumber(num)) ? this.dateToString(new Date( num * 1)) : false;
|
1955
|
-
// }
|
1956
|
-
// },
|
1957
|
-
time: {
|
1958
|
-
bad: function(val, _getParsed){
|
1959
|
-
if(!val || !val.split || !(/\d$/.test(val))){return true;}
|
1960
|
-
val = val.split(/\u003A/);
|
1961
|
-
if(val.length < 2 || val.length > 3){return true;}
|
1962
|
-
var ret = false,
|
1963
|
-
sFraction;
|
1964
|
-
if(val[2]){
|
1965
|
-
val[2] = val[2].split(/\u002E/);
|
1966
|
-
sFraction = parseInt(val[2][1], 10);
|
1967
|
-
val[2] = val[2][0];
|
1968
|
-
}
|
1969
|
-
$.each(val, function(i, part){
|
1970
|
-
if(!isDateTimePart(part) || part.length !== 2){
|
1971
|
-
ret = true;
|
1972
|
-
return false;
|
1973
|
-
}
|
1974
|
-
});
|
1975
|
-
if(ret){return true;}
|
1976
|
-
if(val[0] > 23 || val[0] < 0 || val[1] > 59 || val[1] < 0){
|
1977
|
-
return true;
|
1978
|
-
}
|
1979
|
-
if(val[2] && (val[2] > 59 || val[2] < 0 )){
|
1980
|
-
return true;
|
1981
|
-
}
|
1982
|
-
if(sFraction && isNaN(sFraction)){
|
1983
|
-
return true;
|
1984
|
-
}
|
1985
|
-
if(sFraction){
|
1986
|
-
if(sFraction < 100){
|
1987
|
-
sFraction *= 100;
|
1988
|
-
} else if(sFraction < 10){
|
1989
|
-
sFraction *= 10;
|
1990
|
-
}
|
1991
|
-
}
|
1992
|
-
return (_getParsed === true) ? [val, sFraction] : false;
|
1993
|
-
},
|
1994
|
-
step: 60,
|
1995
|
-
stepBase: 0,
|
1996
|
-
stepScaleFactor: 1000,
|
1997
|
-
asDate: function(val){
|
1998
|
-
val = new Date(this.asNumber(val));
|
1999
|
-
return (isNaN(val)) ? null : val;
|
2000
|
-
},
|
2001
|
-
asNumber: function(val){
|
2002
|
-
var ret = nan;
|
2003
|
-
val = this.bad(val, true);
|
2004
|
-
if(val !== true){
|
2005
|
-
ret = Date.UTC('1970', 0, 1, val[0][0], val[0][1], val[0][2] || 0);
|
2006
|
-
if(val[1]){
|
2007
|
-
ret += val[1];
|
2008
|
-
}
|
2009
|
-
}
|
2010
|
-
return ret;
|
2011
|
-
},
|
2012
|
-
dateToString: function(date){
|
2013
|
-
if(date && date.getUTCHours){
|
2014
|
-
var str = addleadingZero(date.getUTCHours(), 2) +':'+ addleadingZero(date.getUTCMinutes(), 2),
|
2015
|
-
tmp = date.getSeconds()
|
2016
|
-
;
|
2017
|
-
if(tmp != "0"){
|
2018
|
-
str += ':'+ addleadingZero(tmp, 2);
|
2019
|
-
}
|
2020
|
-
tmp = date.getUTCMilliseconds();
|
2021
|
-
if(tmp != "0"){
|
2022
|
-
str += '.'+ addleadingZero(tmp, 3);
|
2023
|
-
}
|
2024
|
-
return str;
|
2025
|
-
} else {
|
2026
|
-
return false;
|
2027
|
-
}
|
2028
|
-
}
|
2029
|
-
},
|
2030
|
-
month: {
|
2031
|
-
bad: function(val){
|
2032
|
-
return typeProtos.date.bad(val+'-01');
|
2033
|
-
},
|
2034
|
-
step: 1,
|
2035
|
-
stepScaleFactor: false,
|
2036
|
-
//stepBase: 0, 0 = default
|
2037
|
-
asDate: function(val){
|
2038
|
-
return new Date(typeProtos.date.asNumber(val+'-01'));
|
2039
|
-
},
|
2040
|
-
asNumber: function(val){
|
2041
|
-
//1970-01
|
2042
|
-
var ret = nan;
|
2043
|
-
if(val && !this.bad(val)){
|
2044
|
-
val = val.split(/\u002D/);
|
2045
|
-
val[0] = (val[0] * 1) - 1970;
|
2046
|
-
val[1] = (val[1] * 1) - 1;
|
2047
|
-
ret = (val[0] * 12) + val[1];
|
2048
|
-
}
|
2049
|
-
return ret;
|
2050
|
-
},
|
2051
|
-
numberToString: function(num){
|
2052
|
-
var mod;
|
2053
|
-
var ret = false;
|
2054
|
-
if(isNumber(num)){
|
2055
|
-
mod = (num % 12);
|
2056
|
-
num = ((num - mod) / 12) + 1970;
|
2057
|
-
mod += 1;
|
2058
|
-
if(mod < 1){
|
2059
|
-
num -= 1;
|
2060
|
-
mod += 12;
|
2061
|
-
}
|
2062
|
-
ret = addleadingZero(num, 4)+'-'+addleadingZero(mod, 2);
|
2063
|
-
|
2064
|
-
}
|
2065
|
-
|
2066
|
-
return ret;
|
2067
|
-
},
|
2068
|
-
dateToString: function(date){
|
2069
|
-
if(date && date.getUTCHours){
|
2070
|
-
var str = typeProtos.date.dateToString(date);
|
2071
|
-
return (str.split && (str = str.split(/\u002D/))) ? str[0]+'-'+str[1] : false;
|
2072
|
-
} else {
|
2073
|
-
return false;
|
2074
|
-
}
|
2075
|
-
}
|
2076
|
-
}
|
2077
|
-
,'datetime-local': {
|
2078
|
-
bad: function(val, _getParsed){
|
2079
|
-
if(!val || !val.split || (val+'special').split(/\u0054/).length !== 2){return true;}
|
2080
|
-
val = val.split(/\u0054/);
|
2081
|
-
return ( typeProtos.date.bad(val[0]) || typeProtos.time.bad(val[1], _getParsed) );
|
2082
|
-
},
|
2083
|
-
noAsDate: true,
|
2084
|
-
asDate: function(val){
|
2085
|
-
val = new Date(this.asNumber(val));
|
2086
|
-
|
2087
|
-
return (isNaN(val)) ? null : val;
|
2088
|
-
},
|
2089
|
-
asNumber: function(val){
|
2090
|
-
var ret = nan;
|
2091
|
-
var time = this.bad(val, true);
|
2092
|
-
if(time !== true){
|
2093
|
-
val = val.split(/\u0054/)[0].split(/\u002D/);
|
2094
|
-
|
2095
|
-
ret = Date.UTC(val[0], val[1] - 1, val[2], time[0][0], time[0][1], time[0][2] || 0);
|
2096
|
-
if(time[1]){
|
2097
|
-
ret += time[1];
|
2098
|
-
}
|
2099
|
-
}
|
2100
|
-
return ret;
|
2101
|
-
},
|
2102
|
-
dateToString: function(date, _getParsed){
|
2103
|
-
return typeProtos.date.dateToString(date) +'T'+ typeProtos.time.dateToString(date, _getParsed);
|
2104
|
-
}
|
2105
|
-
}
|
2106
|
-
};
|
2107
|
-
|
2108
|
-
if(typeBugs || !supportsType('range') || !supportsType('time') || !supportsType('month') || !supportsType('datetime-local')){
|
2109
|
-
typeProtos.range = $.extend({}, typeProtos.number, typeProtos.range);
|
2110
|
-
typeProtos.time = $.extend({}, typeProtos.date, typeProtos.time);
|
2111
|
-
typeProtos.month = $.extend({}, typeProtos.date, typeProtos.month);
|
2112
|
-
typeProtos['datetime-local'] = $.extend({}, typeProtos.date, typeProtos.time, typeProtos['datetime-local']);
|
2113
|
-
}
|
2114
|
-
|
2115
|
-
//
|
2116
|
-
['number', 'month', 'range', 'date', 'time', 'color', 'datetime-local'].forEach(function(type){
|
2117
|
-
if(typeBugs || !supportsType(type)){
|
2118
|
-
webshims.addInputType(type, typeProtos[type]);
|
2119
|
-
}
|
2120
|
-
});
|
2121
|
-
|
2122
|
-
if($('<input />').prop('labels') == null){
|
2123
|
-
webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
|
2124
|
-
prop: {
|
2125
|
-
get: function(){
|
2126
|
-
if(this.type == 'hidden'){return null;}
|
2127
|
-
var id = this.id;
|
2128
|
-
var labels = $(this)
|
2129
|
-
.closest('label')
|
2130
|
-
.filter(function(){
|
2131
|
-
var hFor = (this.attributes['for'] || {});
|
2132
|
-
return (!hFor.specified || hFor.value == id);
|
2133
|
-
})
|
2134
|
-
;
|
2135
|
-
|
2136
|
-
if(id) {
|
2137
|
-
labels = labels.add('label[for="'+ id +'"]');
|
2138
|
-
}
|
2139
|
-
return labels.get();
|
2140
|
-
},
|
2141
|
-
writeable: false
|
2142
|
-
}
|
2143
|
-
});
|
2144
|
-
}
|
2145
|
-
|
2146
|
-
});
|
2147
|
-
;webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
|
2148
|
-
"use strict";
|
2149
|
-
var lazyLoad = function(name){
|
2150
|
-
if(!name || typeof name != 'string'){
|
2151
|
-
name = 'DOM';
|
2152
|
-
}
|
2153
|
-
if(!lazyLoad[name+'Loaded']){
|
2154
|
-
lazyLoad[name+'Loaded'] = true;
|
2155
|
-
webshims.ready(name, function(){
|
2156
|
-
webshims.loader.loadList(['form-datalist-lazy']);
|
2157
|
-
});
|
2158
|
-
}
|
2159
|
-
};
|
2160
|
-
var noDatalistSupport = {
|
2161
|
-
submit: 1,
|
2162
|
-
button: 1,
|
2163
|
-
reset: 1,
|
2164
|
-
hidden: 1,
|
2165
|
-
|
2166
|
-
range: 1,
|
2167
|
-
date: 1,
|
2168
|
-
month: 1
|
2169
|
-
};
|
2170
|
-
if(webshims.modules["form-number-date-ui"].loaded){
|
2171
|
-
$.extend(noDatalistSupport, {
|
2172
|
-
number: 1,
|
2173
|
-
time: 1
|
2174
|
-
});
|
2175
|
-
}
|
2176
|
-
|
2177
|
-
|
2178
|
-
/*
|
2179
|
-
* implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
|
2180
|
-
*/
|
2181
|
-
webshims.propTypes.element = function(descs, name){
|
2182
|
-
webshims.createPropDefault(descs, 'attr');
|
2183
|
-
if(descs.prop){return;}
|
2184
|
-
descs.prop = {
|
2185
|
-
get: function(){
|
2186
|
-
var elem = $.attr(this, name);
|
2187
|
-
if(elem){
|
2188
|
-
elem = document.getElementById(elem);
|
2189
|
-
if(elem && descs.propNodeName && !$.nodeName(elem, descs.propNodeName)){
|
2190
|
-
elem = null;
|
2191
|
-
}
|
2192
|
-
}
|
2193
|
-
return elem || null;
|
2194
|
-
},
|
2195
|
-
writeable: false
|
2196
|
-
};
|
2197
|
-
};
|
2198
|
-
|
2199
|
-
|
2200
|
-
/*
|
2201
|
-
* Implements datalist element and list attribute
|
2202
|
-
*/
|
2203
|
-
|
2204
|
-
(function(){
|
2205
|
-
var formsCFG = $.webshims.cfg.forms;
|
2206
|
-
var listSupport = Modernizr.input.list;
|
2207
|
-
if(listSupport && !formsCFG.customDatalist){return;}
|
2208
|
-
|
2209
|
-
var initializeDatalist = function(){
|
2210
|
-
|
2211
|
-
var updateDatlistAndOptions = function(){
|
2212
|
-
var id;
|
2213
|
-
if(!$.data(this, 'datalistWidgetData') && (id = $.prop(this, 'id'))){
|
2214
|
-
$('input[list="'+ id +'"], input[data-wslist="'+ id +'"]').eq(0).attr('list', id);
|
2215
|
-
} else {
|
2216
|
-
$(this).triggerHandler('updateDatalist');
|
2217
|
-
}
|
2218
|
-
};
|
2219
|
-
|
2220
|
-
var inputListProto = {
|
2221
|
-
//override autocomplete
|
2222
|
-
autocomplete: {
|
2223
|
-
attr: {
|
2224
|
-
get: function(){
|
2225
|
-
var elem = this;
|
2226
|
-
var data = $.data(elem, 'datalistWidget');
|
2227
|
-
if(data){
|
2228
|
-
return data._autocomplete;
|
2229
|
-
}
|
2230
|
-
return ('autocomplete' in elem) ? elem.autocomplete : elem.getAttribute('autocomplete');
|
2231
|
-
},
|
2232
|
-
set: function(value){
|
2233
|
-
var elem = this;
|
2234
|
-
var data = $.data(elem, 'datalistWidget');
|
2235
|
-
if(data){
|
2236
|
-
data._autocomplete = value;
|
2237
|
-
if(value == 'off'){
|
2238
|
-
data.hideList();
|
2239
|
-
}
|
2240
|
-
} else {
|
2241
|
-
if('autocomplete' in elem){
|
2242
|
-
elem.autocomplete = value;
|
2243
|
-
} else {
|
2244
|
-
elem.setAttribute('autocomplete', value);
|
2245
|
-
}
|
2246
|
-
}
|
2247
|
-
}
|
2248
|
-
}
|
2249
|
-
}
|
2250
|
-
};
|
2251
|
-
|
2252
|
-
if(listSupport){
|
2253
|
-
//options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
|
2254
|
-
if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
|
2255
|
-
webshims.defineNodeNameProperty('datalist', 'options', {
|
2256
|
-
prop: {
|
2257
|
-
writeable: false,
|
2258
|
-
get: function(){
|
2259
|
-
var options = this.options || [];
|
2260
|
-
if(!options.length){
|
2261
|
-
var elem = this;
|
2262
|
-
var select = $('select', elem);
|
2263
|
-
if(select[0] && select[0].options && select[0].options.length){
|
2264
|
-
options = select[0].options;
|
2265
|
-
}
|
2266
|
-
}
|
2267
|
-
return options;
|
2268
|
-
}
|
2269
|
-
}
|
2270
|
-
});
|
2271
|
-
}
|
2272
|
-
inputListProto.list = {
|
2273
|
-
attr: {
|
2274
|
-
get: function(){
|
2275
|
-
var val = webshims.contentAttr(this, 'list');
|
2276
|
-
if(val != null){
|
2277
|
-
$.data(this, 'datalistListAttr', val);
|
2278
|
-
if(!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]){
|
2279
|
-
this.removeAttribute('list');
|
2280
|
-
}
|
2281
|
-
} else {
|
2282
|
-
val = $.data(this, 'datalistListAttr');
|
2283
|
-
}
|
2284
|
-
|
2285
|
-
return (val == null) ? undefined : val;
|
2286
|
-
},
|
2287
|
-
set: function(value){
|
2288
|
-
var elem = this;
|
2289
|
-
$.data(elem, 'datalistListAttr', value);
|
2290
|
-
if (!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]) {
|
2291
|
-
webshims.objectCreate(shadowListProto, undefined, {
|
2292
|
-
input: elem,
|
2293
|
-
id: value,
|
2294
|
-
datalist: $.prop(elem, 'list')
|
2295
|
-
});
|
2296
|
-
elem.setAttribute('data-wslist', value);
|
2297
|
-
} else {
|
2298
|
-
elem.setAttribute('list', value);
|
2299
|
-
}
|
2300
|
-
$(elem).triggerHandler('listdatalistchange');
|
2301
|
-
}
|
2302
|
-
},
|
2303
|
-
initAttr: true,
|
2304
|
-
reflect: true,
|
2305
|
-
propType: 'element',
|
2306
|
-
propNodeName: 'datalist'
|
2307
|
-
};
|
2308
|
-
} else {
|
2309
|
-
webshims.defineNodeNameProperties('input', {
|
2310
|
-
list: {
|
2311
|
-
attr: {
|
2312
|
-
get: function(){
|
2313
|
-
var val = webshims.contentAttr(this, 'list');
|
2314
|
-
return (val == null) ? undefined : val;
|
2315
|
-
},
|
2316
|
-
set: function(value){
|
2317
|
-
var elem = this;
|
2318
|
-
webshims.contentAttr(elem, 'list', value);
|
2319
|
-
webshims.objectCreate(options.shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
|
2320
|
-
$(elem).triggerHandler('listdatalistchange');
|
2321
|
-
}
|
2322
|
-
},
|
2323
|
-
initAttr: true,
|
2324
|
-
reflect: true,
|
2325
|
-
propType: 'element',
|
2326
|
-
propNodeName: 'datalist'
|
2327
|
-
}
|
2328
|
-
});
|
2329
|
-
}
|
2330
|
-
|
2331
|
-
webshims.defineNodeNameProperties('input', inputListProto);
|
2332
|
-
|
2333
|
-
webshims.addReady(function(context, contextElem){
|
2334
|
-
contextElem
|
2335
|
-
.filter('datalist > select, datalist, datalist > option, datalist > select > option')
|
2336
|
-
.closest('datalist')
|
2337
|
-
.each(updateDatlistAndOptions)
|
2338
|
-
;
|
2339
|
-
});
|
2340
|
-
};
|
2341
|
-
|
2342
|
-
|
2343
|
-
/*
|
2344
|
-
* ShadowList
|
2345
|
-
*/
|
2346
|
-
|
2347
|
-
var shadowListProto = {
|
2348
|
-
_create: function(opts){
|
2349
|
-
|
2350
|
-
if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
|
2351
|
-
var datalist = opts.datalist;
|
2352
|
-
var data = $.data(opts.input, 'datalistWidget');
|
2353
|
-
var that = this;
|
2354
|
-
if(datalist && data && data.datalist !== datalist){
|
2355
|
-
data.datalist = datalist;
|
2356
|
-
data.id = opts.id;
|
2357
|
-
|
2358
|
-
|
2359
|
-
$(data.datalist)
|
2360
|
-
.off('updateDatalist.datalistWidget')
|
2361
|
-
.on('updateDatalist.datalistWidget', $.proxy(data, '_resetListCached'))
|
2362
|
-
;
|
2363
|
-
|
2364
|
-
data._resetListCached();
|
2365
|
-
return;
|
2366
|
-
} else if(!datalist){
|
2367
|
-
if(data){
|
2368
|
-
data.destroy();
|
2369
|
-
}
|
2370
|
-
return;
|
2371
|
-
} else if(data && data.datalist === datalist){
|
2372
|
-
return;
|
2373
|
-
}
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2377
|
-
this.datalist = datalist;
|
2378
|
-
this.id = opts.id;
|
2379
|
-
this.hasViewableData = true;
|
2380
|
-
this._autocomplete = $.attr(opts.input, 'autocomplete');
|
2381
|
-
$.data(opts.input, 'datalistWidget', this);
|
2382
|
-
$.data(datalist, 'datalistWidgetData', this);
|
2383
|
-
|
2384
|
-
lazyLoad('WINDOWLOAD');
|
2385
|
-
|
2386
|
-
if(webshims.isReady('form-datalist-lazy')){
|
2387
|
-
if(window.QUnit){
|
2388
|
-
that._lazyCreate(opts);
|
2389
|
-
} else {
|
2390
|
-
setTimeout(function(){
|
2391
|
-
that._lazyCreate(opts);
|
2392
|
-
}, 9);
|
2393
|
-
}
|
2394
|
-
} else {
|
2395
|
-
$(opts.input).one('focus', lazyLoad);
|
2396
|
-
webshims.ready('form-datalist-lazy', function(){
|
2397
|
-
if(!that._destroyed){
|
2398
|
-
that._lazyCreate(opts);
|
2399
|
-
}
|
2400
|
-
});
|
2401
|
-
}
|
2402
|
-
},
|
2403
|
-
destroy: function(e){
|
2404
|
-
var input;
|
2405
|
-
var autocomplete = $.attr(this.input, 'autocomplete');
|
2406
|
-
$(this.input)
|
2407
|
-
.off('.datalistWidget')
|
2408
|
-
.removeData('datalistWidget')
|
2409
|
-
;
|
2410
|
-
this.shadowList.remove();
|
2411
|
-
$(document).off('.datalist'+this.id);
|
2412
|
-
$(window).off('.datalist'+this.id);
|
2413
|
-
if(this.input.form && this.input.id){
|
2414
|
-
$(this.input.form).off('submit.datalistWidget'+this.input.id);
|
2415
|
-
}
|
2416
|
-
this.input.removeAttribute('aria-haspopup');
|
2417
|
-
if(autocomplete === undefined){
|
2418
|
-
this.input.removeAttribute('autocomplete');
|
2419
|
-
} else {
|
2420
|
-
$(this.input).attr('autocomplete', autocomplete);
|
2421
|
-
}
|
2422
|
-
if(e && e.type == 'beforeunload'){
|
2423
|
-
input = this.input;
|
2424
|
-
setTimeout(function(){
|
2425
|
-
$.attr(input, 'list', $.attr(input, 'list'));
|
2426
|
-
}, 9);
|
2427
|
-
}
|
2428
|
-
this._destroyed = true;
|
2429
|
-
}
|
2430
|
-
};
|
2431
|
-
|
2432
|
-
webshims.loader.addModule('form-datalist-lazy', {
|
2433
|
-
noAutoCallback: true,
|
2434
|
-
options: $.extend(options, {shadowListProto: shadowListProto})
|
2435
|
-
});
|
2436
|
-
if(!options.list){
|
2437
|
-
options.list = {};
|
2438
|
-
}
|
2439
|
-
//init datalist update
|
2440
|
-
initializeDatalist();
|
2441
|
-
})();
|
2442
|
-
|
2443
|
-
});
|