colorgy_style 0.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +41 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +10 -0
  7. data/README.md +36 -0
  8. data/Rakefile +11 -0
  9. data/assets/fonts/colorgy/.keep +0 -0
  10. data/assets/images/colorgy/.keep +0 -0
  11. data/assets/javascripts/colorgy.js +1 -0
  12. data/assets/javascripts/colorgy/main.js +7 -0
  13. data/assets/javascripts/colorgy/modernizr.js +7 -0
  14. data/assets/javascripts/colorgy/modernizr/classifier.coffee +14 -0
  15. data/assets/javascripts/vendor/es5-shim.js +1432 -0
  16. data/assets/javascripts/vendor/modernizr.js +1406 -0
  17. data/assets/javascripts/vendor/modernizr/feature-detects/a-download.js +8 -0
  18. data/assets/javascripts/vendor/modernizr/feature-detects/audio-audiodata-api.js +4 -0
  19. data/assets/javascripts/vendor/modernizr/feature-detects/audio-webaudio-api.js +4 -0
  20. data/assets/javascripts/vendor/modernizr/feature-detects/battery-api.js +8 -0
  21. data/assets/javascripts/vendor/modernizr/feature-detects/battery-level.js +11 -0
  22. data/assets/javascripts/vendor/modernizr/feature-detects/blob-constructor.js +10 -0
  23. data/assets/javascripts/vendor/modernizr/feature-detects/canvas-todataurl-type.js +28 -0
  24. data/assets/javascripts/vendor/modernizr/feature-detects/contenteditable.js +9 -0
  25. data/assets/javascripts/vendor/modernizr/feature-detects/contentsecuritypolicy.js +10 -0
  26. data/assets/javascripts/vendor/modernizr/feature-detects/contextmenu.js +11 -0
  27. data/assets/javascripts/vendor/modernizr/feature-detects/cookies.js +15 -0
  28. data/assets/javascripts/vendor/modernizr/feature-detects/cors.js +3 -0
  29. data/assets/javascripts/vendor/modernizr/feature-detects/css-backgroundposition-shorthand.js +19 -0
  30. data/assets/javascripts/vendor/modernizr/feature-detects/css-backgroundposition-xy.js +15 -0
  31. data/assets/javascripts/vendor/modernizr/feature-detects/css-backgroundrepeat.js +31 -0
  32. data/assets/javascripts/vendor/modernizr/feature-detects/css-backgroundsizecover.js +10 -0
  33. data/assets/javascripts/vendor/modernizr/feature-detects/css-boxsizing.js +9 -0
  34. data/assets/javascripts/vendor/modernizr/feature-detects/css-calc.js +12 -0
  35. data/assets/javascripts/vendor/modernizr/feature-detects/css-cubicbezierrange.js +8 -0
  36. data/assets/javascripts/vendor/modernizr/feature-detects/css-displayrunin.js +18 -0
  37. data/assets/javascripts/vendor/modernizr/feature-detects/css-displaytable.js +27 -0
  38. data/assets/javascripts/vendor/modernizr/feature-detects/css-filters.js +7 -0
  39. data/assets/javascripts/vendor/modernizr/feature-detects/css-hyphens.js +205 -0
  40. data/assets/javascripts/vendor/modernizr/feature-detects/css-lastchild.js +11 -0
  41. data/assets/javascripts/vendor/modernizr/feature-detects/css-mask.js +12 -0
  42. data/assets/javascripts/vendor/modernizr/feature-detects/css-mediaqueries.js +3 -0
  43. data/assets/javascripts/vendor/modernizr/feature-detects/css-objectfit.js +6 -0
  44. data/assets/javascripts/vendor/modernizr/feature-detects/css-overflow-scrolling.js +9 -0
  45. data/assets/javascripts/vendor/modernizr/feature-detects/css-pointerevents.js +25 -0
  46. data/assets/javascripts/vendor/modernizr/feature-detects/css-positionsticky.js +13 -0
  47. data/assets/javascripts/vendor/modernizr/feature-detects/css-regions.js +55 -0
  48. data/assets/javascripts/vendor/modernizr/feature-detects/css-remunit.js +19 -0
  49. data/assets/javascripts/vendor/modernizr/feature-detects/css-resize.js +8 -0
  50. data/assets/javascripts/vendor/modernizr/feature-detects/css-scrollbars.js +19 -0
  51. data/assets/javascripts/vendor/modernizr/feature-detects/css-shapes.js +4 -0
  52. data/assets/javascripts/vendor/modernizr/feature-detects/css-subpixelfont.js +23 -0
  53. data/assets/javascripts/vendor/modernizr/feature-detects/css-supports.js +6 -0
  54. data/assets/javascripts/vendor/modernizr/feature-detects/css-userselect.js +10 -0
  55. data/assets/javascripts/vendor/modernizr/feature-detects/css-vhunit.js +14 -0
  56. data/assets/javascripts/vendor/modernizr/feature-detects/css-vmaxunit.js +14 -0
  57. data/assets/javascripts/vendor/modernizr/feature-detects/css-vminunit.js +14 -0
  58. data/assets/javascripts/vendor/modernizr/feature-detects/css-vwunit.js +14 -0
  59. data/assets/javascripts/vendor/modernizr/feature-detects/custom-protocol-handler.js +10 -0
  60. data/assets/javascripts/vendor/modernizr/feature-detects/dart.js +6 -0
  61. data/assets/javascripts/vendor/modernizr/feature-detects/dataview-api.js +4 -0
  62. data/assets/javascripts/vendor/modernizr/feature-detects/dom-classlist.js +4 -0
  63. data/assets/javascripts/vendor/modernizr/feature-detects/dom-createElement-attrs.js +11 -0
  64. data/assets/javascripts/vendor/modernizr/feature-detects/dom-dataset.js +9 -0
  65. data/assets/javascripts/vendor/modernizr/feature-detects/dom-microdata.js +4 -0
  66. data/assets/javascripts/vendor/modernizr/feature-detects/elem-datalist.js +12 -0
  67. data/assets/javascripts/vendor/modernizr/feature-detects/elem-details.js +25 -0
  68. data/assets/javascripts/vendor/modernizr/feature-detects/elem-output.js +4 -0
  69. data/assets/javascripts/vendor/modernizr/feature-detects/elem-progress-meter.js +11 -0
  70. data/assets/javascripts/vendor/modernizr/feature-detects/elem-ruby.js +53 -0
  71. data/assets/javascripts/vendor/modernizr/feature-detects/elem-time.js +4 -0
  72. data/assets/javascripts/vendor/modernizr/feature-detects/elem-track.js +11 -0
  73. data/assets/javascripts/vendor/modernizr/feature-detects/emoji.js +11 -0
  74. data/assets/javascripts/vendor/modernizr/feature-detects/es5-strictmode.js +7 -0
  75. data/assets/javascripts/vendor/modernizr/feature-detects/event-deviceorientation-motion.js +11 -0
  76. data/assets/javascripts/vendor/modernizr/feature-detects/exif-orientation.js +32 -0
  77. data/assets/javascripts/vendor/modernizr/feature-detects/file-api.js +12 -0
  78. data/assets/javascripts/vendor/modernizr/feature-detects/file-filesystem.js +9 -0
  79. data/assets/javascripts/vendor/modernizr/feature-detects/forms-fileinput.js +13 -0
  80. data/assets/javascripts/vendor/modernizr/feature-detects/forms-formattribute.js +29 -0
  81. data/assets/javascripts/vendor/modernizr/feature-detects/forms-inputnumber-l10n.js +32 -0
  82. data/assets/javascripts/vendor/modernizr/feature-detects/forms-placeholder.js +10 -0
  83. data/assets/javascripts/vendor/modernizr/feature-detects/forms-speechinput.js +19 -0
  84. data/assets/javascripts/vendor/modernizr/feature-detects/forms-validation.js +62 -0
  85. data/assets/javascripts/vendor/modernizr/feature-detects/fullscreen-api.js +10 -0
  86. data/assets/javascripts/vendor/modernizr/feature-detects/gamepad.js +12 -0
  87. data/assets/javascripts/vendor/modernizr/feature-detects/getusermedia.js +5 -0
  88. data/assets/javascripts/vendor/modernizr/feature-detects/ie8compat.js +12 -0
  89. data/assets/javascripts/vendor/modernizr/feature-detects/iframe-sandbox.js +5 -0
  90. data/assets/javascripts/vendor/modernizr/feature-detects/iframe-seamless.js +5 -0
  91. data/assets/javascripts/vendor/modernizr/feature-detects/iframe-srcdoc.js +5 -0
  92. data/assets/javascripts/vendor/modernizr/feature-detects/img-apng.js +26 -0
  93. data/assets/javascripts/vendor/modernizr/feature-detects/img-webp.js +20 -0
  94. data/assets/javascripts/vendor/modernizr/feature-detects/json.js +7 -0
  95. data/assets/javascripts/vendor/modernizr/feature-detects/lists-reversed.js +6 -0
  96. data/assets/javascripts/vendor/modernizr/feature-detects/mathml.js +23 -0
  97. data/assets/javascripts/vendor/modernizr/feature-detects/network-connection.js +22 -0
  98. data/assets/javascripts/vendor/modernizr/feature-detects/network-eventsource.js +5 -0
  99. data/assets/javascripts/vendor/modernizr/feature-detects/network-xhr2.js +13 -0
  100. data/assets/javascripts/vendor/modernizr/feature-detects/notification.js +10 -0
  101. data/assets/javascripts/vendor/modernizr/feature-detects/performance.js +5 -0
  102. data/assets/javascripts/vendor/modernizr/feature-detects/pointerlock-api.js +4 -0
  103. data/assets/javascripts/vendor/modernizr/feature-detects/quota-management-api.js +11 -0
  104. data/assets/javascripts/vendor/modernizr/feature-detects/requestanimationframe.js +7 -0
  105. data/assets/javascripts/vendor/modernizr/feature-detects/script-async.js +3 -0
  106. data/assets/javascripts/vendor/modernizr/feature-detects/script-defer.js +3 -0
  107. data/assets/javascripts/vendor/modernizr/feature-detects/style-scoped.js +6 -0
  108. data/assets/javascripts/vendor/modernizr/feature-detects/svg-filters.js +13 -0
  109. data/assets/javascripts/vendor/modernizr/feature-detects/unicode.js +32 -0
  110. data/assets/javascripts/vendor/modernizr/feature-detects/url-data-uri.js +26 -0
  111. data/assets/javascripts/vendor/modernizr/feature-detects/userdata.js +7 -0
  112. data/assets/javascripts/vendor/modernizr/feature-detects/vibration.js +4 -0
  113. data/assets/javascripts/vendor/modernizr/feature-detects/web-intents.js +6 -0
  114. data/assets/javascripts/vendor/modernizr/feature-detects/webgl-extensions.js +42 -0
  115. data/assets/javascripts/vendor/modernizr/feature-detects/websockets-binary.js +20 -0
  116. data/assets/javascripts/vendor/modernizr/feature-detects/window-framed.js +8 -0
  117. data/assets/javascripts/vendor/modernizr/feature-detects/workers-blobworkers.js +66 -0
  118. data/assets/javascripts/vendor/modernizr/feature-detects/workers-dataworkers.js +34 -0
  119. data/assets/javascripts/vendor/modernizr/feature-detects/workers-sharedworkers.js +3 -0
  120. data/assets/stylesheets/colorgy.scss +1 -0
  121. data/assets/stylesheets/colorgy/components/.keep +0 -0
  122. data/assets/stylesheets/colorgy/components/_button.scss +18 -0
  123. data/assets/stylesheets/colorgy/core/_base.scss +12 -0
  124. data/assets/stylesheets/colorgy/core/_config.scss +8 -0
  125. data/assets/stylesheets/colorgy/core/_fonts.scss +8 -0
  126. data/assets/stylesheets/colorgy/core/_grid.scss +8 -0
  127. data/assets/stylesheets/colorgy/core/_helpers.scss +44 -0
  128. data/assets/stylesheets/colorgy/layouts/.keep +0 -0
  129. data/assets/stylesheets/colorgy/main.scss +63 -0
  130. data/assets/stylesheets/colorgy/structures/.keep +0 -0
  131. data/bin/console +14 -0
  132. data/bin/server +3 -0
  133. data/bin/setup +7 -0
  134. data/colorgy_style.gemspec +52 -0
  135. data/config.rb +63 -0
  136. data/lib/colorgy_style.rb +74 -0
  137. data/lib/colorgy_style/rails.rb +13 -0
  138. data/lib/colorgy_style/version.rb +3 -0
  139. data/styleguide/index.html.haml +7 -0
  140. data/styleguide/javascripts/body.js +5 -0
  141. data/styleguide/javascripts/head.js +2 -0
  142. data/styleguide/javascripts/styleguide/kss.js +40 -0
  143. data/styleguide/javascripts/styleguide/prism.js +6 -0
  144. data/styleguide/layouts/default.erb +5 -0
  145. data/styleguide/layouts/layout.erb +20 -0
  146. data/styleguide/styleblocks/.keep +0 -0
  147. data/styleguide/styleblocks/_button.html.erb +23 -0
  148. data/styleguide/stylesheets/all.css +4 -0
  149. data/styleguide/stylesheets/styleguide/_prism.css +107 -0
  150. data/styleguide/stylesheets/styleguide/styles.scss +97 -0
  151. metadata +402 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a889347654f52f2c823775dd5f5d94132f1adfe6
4
+ data.tar.gz: ddf46065430ee88112d7758cad5cdbc56ae6735d
5
+ SHA512:
6
+ metadata.gz: 0b49a28205d83ed9a893aaaac1b62d6d8a3bd507c84f0a3d7d6304d3ede15d6936be96ee8d102491bafac2f396968c1e9028f0dd887d9138cc0944212dc4457f
7
+ data.tar.gz: b7a7905c49a617d5e77783cd111bd0c02b91528e6a8b7267d60d9f603256bb4ade28319de2ab2dac887a35566aefe3f63b9f49aa098b4e33c68046c67657dbb7
@@ -0,0 +1,41 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # http://EditorConfig.org
4
+
5
+ # top-most EditorConfig file
6
+ root = true
7
+
8
+ # Unix-style newlines with a newline ending every file
9
+ [*]
10
+ charset = utf-8
11
+ end_of_line = lf
12
+ insert_final_newline = true
13
+
14
+ # 2 space indentation by default
15
+ [*]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ # Tab indentation for stylesheets (no size specified)
20
+ [**.css]
21
+ indent_style = tab
22
+ indent_size = 4
23
+ tab_size = 4
24
+
25
+ [**.scss]
26
+ indent_style = tab
27
+ indent_size = 4
28
+ tab_size = 4
29
+
30
+ # Don't trim trailing whitespace for markdown files
31
+ [**.md]
32
+ trim_trailing_whitespace = false
33
+
34
+ [**.markdown]
35
+ trim_trailing_whitespace = false
36
+
37
+ [**.slim]
38
+ trim_trailing_whitespace = false
39
+
40
+ [**.erb]
41
+ trim_trailing_whitespace = false
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /build
11
+ /.sass-cache
12
+ /.cache
13
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ before_install: gem install bundler -v 1.10.2
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in colorgy_style.gemspec
4
+ gemspec
5
+
6
+ # Load Middleman-related gems here, their versions are specified in colorgy_style.gemspec
7
+ gem "middleman"
8
+ gem "middleman-kss"
9
+ gem "middleman-livereload"
10
+ gem "middleman-deploy"
@@ -0,0 +1,36 @@
1
+ # ColorgyStyle
2
+
3
+ The front-end bundle and style guide for Colorgy.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'colorgy_style'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install colorgy_style
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then run `bin/server` to fire up the development server, or run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ To deploy the builded style guide to GitHub Pages, simply run `bundle exec rake deploy` and the source will be builded and pushed to `gh-pages` of the origin repo.
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/colorgy/Style.
36
+
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :deploy do
9
+ puts "Deploying to GitHub"
10
+ system "bundle exec middleman deploy"
11
+ end
File without changes
File without changes
@@ -0,0 +1 @@
1
+ //= require ./colorgy/main
@@ -0,0 +1,7 @@
1
+ // This is a manifest file, which will include all the files listed below.
2
+ //
3
+ //= require vendor/es5-shim
4
+ //= require jquery
5
+ //= require jquery_ujs
6
+
7
+ console.log('Hello World!');
@@ -0,0 +1,7 @@
1
+ // Custom modernizr with additional features for colorgy
2
+ //
3
+ //= require vendor/modernizr.js
4
+ //= require vendor/modernizr/feature-detects/css-vwunit.js
5
+ //= require vendor/modernizr/feature-detects/css-vhunit.js
6
+ //= require vendor/modernizr/feature-detects/css-calc.js
7
+ //= require ./modernizr/classifier
@@ -0,0 +1,14 @@
1
+ html = document.getElementsByTagName('html')[0]
2
+
3
+ if window.chrome
4
+ html.className += ' chrome'
5
+ if Modernizr.touch
6
+ html.className += ' touch'
7
+ else
8
+ html.className += ' non-touch'
9
+ if navigator.platform.toUpperCase().indexOf('MAC')>=0
10
+ html.className += ' mac'
11
+ if navigator.platform.match(/(iPhone|iPod|iPad)/i)
12
+ html.className += ' ios'
13
+ if navigator.appVersion.match(/(Win)/i)
14
+ html.className += ' windows'
@@ -0,0 +1,1432 @@
1
+ /*!
2
+ * https://github.com/es-shims/es5-shim
3
+ * @license es5-shim Copyright 2009-2014 by contributors, MIT License
4
+ * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
5
+ */
6
+
7
+ // vim: ts=4 sts=4 sw=4 expandtab
8
+
9
+ // Add semicolon to prevent IIFE from being passed as argument to concatenated code.
10
+ ;
11
+
12
+ // UMD (Universal Module Definition)
13
+ // see https://github.com/umdjs/umd/blob/master/returnExports.js
14
+ (function (root, factory) {
15
+ 'use strict';
16
+ /*global define, exports, module */
17
+ if (typeof define === 'function' && define.amd) {
18
+ // AMD. Register as an anonymous module.
19
+ define(factory);
20
+ } else if (typeof exports === 'object') {
21
+ // Node. Does not work with strict CommonJS, but
22
+ // only CommonJS-like enviroments that support module.exports,
23
+ // like Node.
24
+ module.exports = factory();
25
+ } else {
26
+ // Browser globals (root is window)
27
+ root.returnExports = factory();
28
+ }
29
+ }(this, function () {
30
+
31
+ /**
32
+ * Brings an environment as close to ECMAScript 5 compliance
33
+ * as is possible with the facilities of erstwhile engines.
34
+ *
35
+ * Annotated ES5: http://es5.github.com/ (specific links below)
36
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
37
+ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
38
+ */
39
+
40
+ // Shortcut to an often accessed properties, in order to avoid multiple
41
+ // dereference that costs universally.
42
+ var ArrayPrototype = Array.prototype;
43
+ var ObjectPrototype = Object.prototype;
44
+ var FunctionPrototype = Function.prototype;
45
+ var StringPrototype = String.prototype;
46
+ var NumberPrototype = Number.prototype;
47
+ var array_slice = ArrayPrototype.slice;
48
+ var array_splice = ArrayPrototype.splice;
49
+ var array_push = ArrayPrototype.push;
50
+ var array_unshift = ArrayPrototype.unshift;
51
+ var call = FunctionPrototype.call;
52
+
53
+ // Having a toString local variable name breaks in Opera so use to_string.
54
+ var to_string = ObjectPrototype.toString;
55
+
56
+ var isFunction = function (val) {
57
+ return to_string.call(val) === '[object Function]';
58
+ };
59
+ var isRegex = function (val) {
60
+ return to_string.call(val) === '[object RegExp]';
61
+ };
62
+ var isArray = function isArray(obj) {
63
+ return to_string.call(obj) === '[object Array]';
64
+ };
65
+ var isString = function isString(obj) {
66
+ return to_string.call(obj) === '[object String]';
67
+ };
68
+ var isArguments = function isArguments(value) {
69
+ var str = to_string.call(value);
70
+ var isArgs = str === '[object Arguments]';
71
+ if (!isArgs) {
72
+ isArgs = !isArray(value) &&
73
+ value !== null &&
74
+ typeof value === 'object' &&
75
+ typeof value.length === 'number' &&
76
+ value.length >= 0 &&
77
+ isFunction(value.callee);
78
+ }
79
+ return isArgs;
80
+ };
81
+
82
+ var supportsDescriptors = Object.defineProperty && (function () {
83
+ try {
84
+ Object.defineProperty({}, 'x', {});
85
+ return true;
86
+ } catch (e) { /* this is ES3 */
87
+ return false;
88
+ }
89
+ }());
90
+
91
+ // Define configurable, writable and non-enumerable props
92
+ // if they don't exist.
93
+ var defineProperty;
94
+ if (supportsDescriptors) {
95
+ defineProperty = function (object, name, method, forceAssign) {
96
+ if (!forceAssign && (name in object)) { return; }
97
+ Object.defineProperty(object, name, {
98
+ configurable: true,
99
+ enumerable: false,
100
+ writable: true,
101
+ value: method
102
+ });
103
+ };
104
+ } else {
105
+ defineProperty = function (object, name, method, forceAssign) {
106
+ if (!forceAssign && (name in object)) { return; }
107
+ object[name] = method;
108
+ };
109
+ }
110
+ var defineProperties = function (object, map, forceAssign) {
111
+ for (var name in map) {
112
+ if (ObjectPrototype.hasOwnProperty.call(map, name)) {
113
+ defineProperty(object, name, map[name], forceAssign);
114
+ }
115
+ }
116
+ };
117
+
118
+ //
119
+ // Util
120
+ // ======
121
+ //
122
+
123
+ // ES5 9.4
124
+ // http://es5.github.com/#x9.4
125
+ // http://jsperf.com/to-integer
126
+
127
+ function toInteger(num) {
128
+ var n = +num;
129
+ if (n !== n) { // isNaN
130
+ n = 0;
131
+ } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
132
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
133
+ }
134
+ return n;
135
+ }
136
+
137
+ function isPrimitive(input) {
138
+ var type = typeof input;
139
+ return input === null ||
140
+ type === 'undefined' ||
141
+ type === 'boolean' ||
142
+ type === 'number' ||
143
+ type === 'string';
144
+ }
145
+
146
+ function toPrimitive(input) {
147
+ var val, valueOf, toStr;
148
+ if (isPrimitive(input)) {
149
+ return input;
150
+ }
151
+ valueOf = input.valueOf;
152
+ if (isFunction(valueOf)) {
153
+ val = valueOf.call(input);
154
+ if (isPrimitive(val)) {
155
+ return val;
156
+ }
157
+ }
158
+ toStr = input.toString;
159
+ if (isFunction(toStr)) {
160
+ val = toStr.call(input);
161
+ if (isPrimitive(val)) {
162
+ return val;
163
+ }
164
+ }
165
+ throw new TypeError();
166
+ }
167
+
168
+ var ES = {
169
+ // ES5 9.9
170
+ // http://es5.github.com/#x9.9
171
+ ToObject: function (o) {
172
+ /*jshint eqnull: true */
173
+ if (o == null) { // this matches both null and undefined
174
+ throw new TypeError("can't convert " + o + ' to object');
175
+ }
176
+ return Object(o);
177
+ },
178
+ ToUint32: function ToUint32(x) {
179
+ return x >>> 0;
180
+ }
181
+ };
182
+
183
+ //
184
+ // Function
185
+ // ========
186
+ //
187
+
188
+ // ES-5 15.3.4.5
189
+ // http://es5.github.com/#x15.3.4.5
190
+
191
+ var Empty = function Empty() {};
192
+
193
+ defineProperties(FunctionPrototype, {
194
+ bind: function bind(that) { // .length is 1
195
+ // 1. Let Target be the this value.
196
+ var target = this;
197
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
198
+ if (!isFunction(target)) {
199
+ throw new TypeError('Function.prototype.bind called on incompatible ' + target);
200
+ }
201
+ // 3. Let A be a new (possibly empty) internal list of all of the
202
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
203
+ // XXX slicedArgs will stand in for "A" if used
204
+ var args = array_slice.call(arguments, 1); // for normal call
205
+ // 4. Let F be a new native ECMAScript object.
206
+ // 11. Set the [[Prototype]] internal property of F to the standard
207
+ // built-in Function prototype object as specified in 15.3.3.1.
208
+ // 12. Set the [[Call]] internal property of F as described in
209
+ // 15.3.4.5.1.
210
+ // 13. Set the [[Construct]] internal property of F as described in
211
+ // 15.3.4.5.2.
212
+ // 14. Set the [[HasInstance]] internal property of F as described in
213
+ // 15.3.4.5.3.
214
+ var bound;
215
+ var binder = function () {
216
+
217
+ if (this instanceof bound) {
218
+ // 15.3.4.5.2 [[Construct]]
219
+ // When the [[Construct]] internal method of a function object,
220
+ // F that was created using the bind function is called with a
221
+ // list of arguments ExtraArgs, the following steps are taken:
222
+ // 1. Let target be the value of F's [[TargetFunction]]
223
+ // internal property.
224
+ // 2. If target has no [[Construct]] internal method, a
225
+ // TypeError exception is thrown.
226
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
227
+ // property.
228
+ // 4. Let args be a new list containing the same values as the
229
+ // list boundArgs in the same order followed by the same
230
+ // values as the list ExtraArgs in the same order.
231
+ // 5. Return the result of calling the [[Construct]] internal
232
+ // method of target providing args as the arguments.
233
+
234
+ var result = target.apply(
235
+ this,
236
+ args.concat(array_slice.call(arguments))
237
+ );
238
+ if (Object(result) === result) {
239
+ return result;
240
+ }
241
+ return this;
242
+
243
+ } else {
244
+ // 15.3.4.5.1 [[Call]]
245
+ // When the [[Call]] internal method of a function object, F,
246
+ // which was created using the bind function is called with a
247
+ // this value and a list of arguments ExtraArgs, the following
248
+ // steps are taken:
249
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
250
+ // property.
251
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
252
+ // property.
253
+ // 3. Let target be the value of F's [[TargetFunction]] internal
254
+ // property.
255
+ // 4. Let args be a new list containing the same values as the
256
+ // list boundArgs in the same order followed by the same
257
+ // values as the list ExtraArgs in the same order.
258
+ // 5. Return the result of calling the [[Call]] internal method
259
+ // of target providing boundThis as the this value and
260
+ // providing args as the arguments.
261
+
262
+ // equiv: target.call(this, ...boundArgs, ...args)
263
+ return target.apply(
264
+ that,
265
+ args.concat(array_slice.call(arguments))
266
+ );
267
+
268
+ }
269
+
270
+ };
271
+
272
+ // 15. If the [[Class]] internal property of Target is "Function", then
273
+ // a. Let L be the length property of Target minus the length of A.
274
+ // b. Set the length own property of F to either 0 or L, whichever is
275
+ // larger.
276
+ // 16. Else set the length own property of F to 0.
277
+
278
+ var boundLength = Math.max(0, target.length - args.length);
279
+
280
+ // 17. Set the attributes of the length own property of F to the values
281
+ // specified in 15.3.5.1.
282
+ var boundArgs = [];
283
+ for (var i = 0; i < boundLength; i++) {
284
+ boundArgs.push('$' + i);
285
+ }
286
+
287
+ // XXX Build a dynamic function with desired amount of arguments is the only
288
+ // way to set the length property of a function.
289
+ // In environments where Content Security Policies enabled (Chrome extensions,
290
+ // for ex.) all use of eval or Function costructor throws an exception.
291
+ // However in all of these environments Function.prototype.bind exists
292
+ // and so this code will never be executed.
293
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
294
+
295
+ if (target.prototype) {
296
+ Empty.prototype = target.prototype;
297
+ bound.prototype = new Empty();
298
+ // Clean up dangling references.
299
+ Empty.prototype = null;
300
+ }
301
+
302
+ // TODO
303
+ // 18. Set the [[Extensible]] internal property of F to true.
304
+
305
+ // TODO
306
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
307
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
308
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
309
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
310
+ // false.
311
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
312
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
313
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
314
+ // and false.
315
+
316
+ // TODO
317
+ // NOTE Function objects created using Function.prototype.bind do not
318
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
319
+ // [[Scope]] internal properties.
320
+ // XXX can't delete prototype in pure-js.
321
+
322
+ // 22. Return F.
323
+ return bound;
324
+ }
325
+ });
326
+
327
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
328
+ // us it in defining shortcuts.
329
+ var owns = call.bind(ObjectPrototype.hasOwnProperty);
330
+
331
+ //
332
+ // Array
333
+ // =====
334
+ //
335
+
336
+ // ES5 15.4.4.12
337
+ // http://es5.github.com/#x15.4.4.12
338
+ var spliceNoopReturnsEmptyArray = (function () {
339
+ var a = [1, 2];
340
+ var result = a.splice();
341
+ return a.length === 2 && isArray(result) && result.length === 0;
342
+ }());
343
+ defineProperties(ArrayPrototype, {
344
+ // Safari 5.0 bug where .splice() returns undefined
345
+ splice: function splice(start, deleteCount) {
346
+ if (arguments.length === 0) {
347
+ return [];
348
+ } else {
349
+ return array_splice.apply(this, arguments);
350
+ }
351
+ }
352
+ }, !spliceNoopReturnsEmptyArray);
353
+
354
+ var spliceWorksWithEmptyObject = (function () {
355
+ var obj = {};
356
+ ArrayPrototype.splice.call(obj, 0, 0, 1);
357
+ return obj.length === 1;
358
+ }());
359
+ defineProperties(ArrayPrototype, {
360
+ splice: function splice(start, deleteCount) {
361
+ if (arguments.length === 0) { return []; }
362
+ var args = arguments;
363
+ this.length = Math.max(toInteger(this.length), 0);
364
+ if (arguments.length > 0 && typeof deleteCount !== 'number') {
365
+ args = array_slice.call(arguments);
366
+ if (args.length < 2) {
367
+ args.push(this.length - start);
368
+ } else {
369
+ args[1] = toInteger(deleteCount);
370
+ }
371
+ }
372
+ return array_splice.apply(this, args);
373
+ }
374
+ }, !spliceWorksWithEmptyObject);
375
+
376
+ // ES5 15.4.4.12
377
+ // http://es5.github.com/#x15.4.4.13
378
+ // Return len+argCount.
379
+ // [bugfix, ielt8]
380
+ // IE < 8 bug: [].unshift(0) === undefined but should be "1"
381
+ var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
382
+ defineProperties(ArrayPrototype, {
383
+ unshift: function () {
384
+ array_unshift.apply(this, arguments);
385
+ return this.length;
386
+ }
387
+ }, hasUnshiftReturnValueBug);
388
+
389
+ // ES5 15.4.3.2
390
+ // http://es5.github.com/#x15.4.3.2
391
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
392
+ defineProperties(Array, { isArray: isArray });
393
+
394
+ // The IsCallable() check in the Array functions
395
+ // has been replaced with a strict check on the
396
+ // internal class of the object to trap cases where
397
+ // the provided function was actually a regular
398
+ // expression literal, which in V8 and
399
+ // JavaScriptCore is a typeof "function". Only in
400
+ // V8 are regular expression literals permitted as
401
+ // reduce parameters, so it is desirable in the
402
+ // general case for the shim to match the more
403
+ // strict and common behavior of rejecting regular
404
+ // expressions.
405
+
406
+ // ES5 15.4.4.18
407
+ // http://es5.github.com/#x15.4.4.18
408
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
409
+
410
+ // Check failure of by-index access of string characters (IE < 9)
411
+ // and failure of `0 in boxedString` (Rhino)
412
+ var boxedString = Object('a');
413
+ var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
414
+
415
+ var properlyBoxesContext = function properlyBoxed(method) {
416
+ // Check node 0.6.21 bug where third parameter is not boxed
417
+ var properlyBoxesNonStrict = true;
418
+ var properlyBoxesStrict = true;
419
+ if (method) {
420
+ method.call('foo', function (_, __, context) {
421
+ if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
422
+ });
423
+
424
+ method.call([1], function () {
425
+ 'use strict';
426
+ properlyBoxesStrict = typeof this === 'string';
427
+ }, 'x');
428
+ }
429
+ return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
430
+ };
431
+
432
+ defineProperties(ArrayPrototype, {
433
+ forEach: function forEach(fun /*, thisp*/) {
434
+ var object = ES.ToObject(this),
435
+ self = splitString && isString(this) ? this.split('') : object,
436
+ thisp = arguments[1],
437
+ i = -1,
438
+ length = self.length >>> 0;
439
+
440
+ // If no callback function or if callback is not a callable function
441
+ if (!isFunction(fun)) {
442
+ throw new TypeError(); // TODO message
443
+ }
444
+
445
+ while (++i < length) {
446
+ if (i in self) {
447
+ // Invoke the callback function with call, passing arguments:
448
+ // context, property value, property key, thisArg object
449
+ // context
450
+ fun.call(thisp, self[i], i, object);
451
+ }
452
+ }
453
+ }
454
+ }, !properlyBoxesContext(ArrayPrototype.forEach));
455
+
456
+ // ES5 15.4.4.19
457
+ // http://es5.github.com/#x15.4.4.19
458
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
459
+ defineProperties(ArrayPrototype, {
460
+ map: function map(fun /*, thisp*/) {
461
+ var object = ES.ToObject(this),
462
+ self = splitString && isString(this) ? this.split('') : object,
463
+ length = self.length >>> 0,
464
+ result = Array(length),
465
+ thisp = arguments[1];
466
+
467
+ // If no callback function or if callback is not a callable function
468
+ if (!isFunction(fun)) {
469
+ throw new TypeError(fun + ' is not a function');
470
+ }
471
+
472
+ for (var i = 0; i < length; i++) {
473
+ if (i in self) {
474
+ result[i] = fun.call(thisp, self[i], i, object);
475
+ }
476
+ }
477
+ return result;
478
+ }
479
+ }, !properlyBoxesContext(ArrayPrototype.map));
480
+
481
+ // ES5 15.4.4.20
482
+ // http://es5.github.com/#x15.4.4.20
483
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
484
+ defineProperties(ArrayPrototype, {
485
+ filter: function filter(fun /*, thisp */) {
486
+ var object = ES.ToObject(this),
487
+ self = splitString && isString(this) ? this.split('') : object,
488
+ length = self.length >>> 0,
489
+ result = [],
490
+ value,
491
+ thisp = arguments[1];
492
+
493
+ // If no callback function or if callback is not a callable function
494
+ if (!isFunction(fun)) {
495
+ throw new TypeError(fun + ' is not a function');
496
+ }
497
+
498
+ for (var i = 0; i < length; i++) {
499
+ if (i in self) {
500
+ value = self[i];
501
+ if (fun.call(thisp, value, i, object)) {
502
+ result.push(value);
503
+ }
504
+ }
505
+ }
506
+ return result;
507
+ }
508
+ }, !properlyBoxesContext(ArrayPrototype.filter));
509
+
510
+ // ES5 15.4.4.16
511
+ // http://es5.github.com/#x15.4.4.16
512
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
513
+ defineProperties(ArrayPrototype, {
514
+ every: function every(fun /*, thisp */) {
515
+ var object = ES.ToObject(this),
516
+ self = splitString && isString(this) ? this.split('') : object,
517
+ length = self.length >>> 0,
518
+ thisp = arguments[1];
519
+
520
+ // If no callback function or if callback is not a callable function
521
+ if (!isFunction(fun)) {
522
+ throw new TypeError(fun + ' is not a function');
523
+ }
524
+
525
+ for (var i = 0; i < length; i++) {
526
+ if (i in self && !fun.call(thisp, self[i], i, object)) {
527
+ return false;
528
+ }
529
+ }
530
+ return true;
531
+ }
532
+ }, !properlyBoxesContext(ArrayPrototype.every));
533
+
534
+ // ES5 15.4.4.17
535
+ // http://es5.github.com/#x15.4.4.17
536
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
537
+ defineProperties(ArrayPrototype, {
538
+ some: function some(fun /*, thisp */) {
539
+ var object = ES.ToObject(this),
540
+ self = splitString && isString(this) ? this.split('') : object,
541
+ length = self.length >>> 0,
542
+ thisp = arguments[1];
543
+
544
+ // If no callback function or if callback is not a callable function
545
+ if (!isFunction(fun)) {
546
+ throw new TypeError(fun + ' is not a function');
547
+ }
548
+
549
+ for (var i = 0; i < length; i++) {
550
+ if (i in self && fun.call(thisp, self[i], i, object)) {
551
+ return true;
552
+ }
553
+ }
554
+ return false;
555
+ }
556
+ }, !properlyBoxesContext(ArrayPrototype.some));
557
+
558
+ // ES5 15.4.4.21
559
+ // http://es5.github.com/#x15.4.4.21
560
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
561
+ var reduceCoercesToObject = false;
562
+ if (ArrayPrototype.reduce) {
563
+ reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
564
+ }
565
+ defineProperties(ArrayPrototype, {
566
+ reduce: function reduce(fun /*, initial*/) {
567
+ var object = ES.ToObject(this),
568
+ self = splitString && isString(this) ? this.split('') : object,
569
+ length = self.length >>> 0;
570
+
571
+ // If no callback function or if callback is not a callable function
572
+ if (!isFunction(fun)) {
573
+ throw new TypeError(fun + ' is not a function');
574
+ }
575
+
576
+ // no value to return if no initial value and an empty array
577
+ if (!length && arguments.length === 1) {
578
+ throw new TypeError('reduce of empty array with no initial value');
579
+ }
580
+
581
+ var i = 0;
582
+ var result;
583
+ if (arguments.length >= 2) {
584
+ result = arguments[1];
585
+ } else {
586
+ do {
587
+ if (i in self) {
588
+ result = self[i++];
589
+ break;
590
+ }
591
+
592
+ // if array contains no values, no initial value to return
593
+ if (++i >= length) {
594
+ throw new TypeError('reduce of empty array with no initial value');
595
+ }
596
+ } while (true);
597
+ }
598
+
599
+ for (; i < length; i++) {
600
+ if (i in self) {
601
+ result = fun.call(void 0, result, self[i], i, object);
602
+ }
603
+ }
604
+
605
+ return result;
606
+ }
607
+ }, !reduceCoercesToObject);
608
+
609
+ // ES5 15.4.4.22
610
+ // http://es5.github.com/#x15.4.4.22
611
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
612
+ var reduceRightCoercesToObject = false;
613
+ if (ArrayPrototype.reduceRight) {
614
+ reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
615
+ }
616
+ defineProperties(ArrayPrototype, {
617
+ reduceRight: function reduceRight(fun /*, initial*/) {
618
+ var object = ES.ToObject(this),
619
+ self = splitString && isString(this) ? this.split('') : object,
620
+ length = self.length >>> 0;
621
+
622
+ // If no callback function or if callback is not a callable function
623
+ if (!isFunction(fun)) {
624
+ throw new TypeError(fun + ' is not a function');
625
+ }
626
+
627
+ // no value to return if no initial value, empty array
628
+ if (!length && arguments.length === 1) {
629
+ throw new TypeError('reduceRight of empty array with no initial value');
630
+ }
631
+
632
+ var result, i = length - 1;
633
+ if (arguments.length >= 2) {
634
+ result = arguments[1];
635
+ } else {
636
+ do {
637
+ if (i in self) {
638
+ result = self[i--];
639
+ break;
640
+ }
641
+
642
+ // if array contains no values, no initial value to return
643
+ if (--i < 0) {
644
+ throw new TypeError('reduceRight of empty array with no initial value');
645
+ }
646
+ } while (true);
647
+ }
648
+
649
+ if (i < 0) {
650
+ return result;
651
+ }
652
+
653
+ do {
654
+ if (i in self) {
655
+ result = fun.call(void 0, result, self[i], i, object);
656
+ }
657
+ } while (i--);
658
+
659
+ return result;
660
+ }
661
+ }, !reduceRightCoercesToObject);
662
+
663
+ // ES5 15.4.4.14
664
+ // http://es5.github.com/#x15.4.4.14
665
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
666
+ var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
667
+ defineProperties(ArrayPrototype, {
668
+ indexOf: function indexOf(sought /*, fromIndex */) {
669
+ var self = splitString && isString(this) ? this.split('') : ES.ToObject(this),
670
+ length = self.length >>> 0;
671
+
672
+ if (!length) {
673
+ return -1;
674
+ }
675
+
676
+ var i = 0;
677
+ if (arguments.length > 1) {
678
+ i = toInteger(arguments[1]);
679
+ }
680
+
681
+ // handle negative indices
682
+ i = i >= 0 ? i : Math.max(0, length + i);
683
+ for (; i < length; i++) {
684
+ if (i in self && self[i] === sought) {
685
+ return i;
686
+ }
687
+ }
688
+ return -1;
689
+ }
690
+ }, hasFirefox2IndexOfBug);
691
+
692
+ // ES5 15.4.4.15
693
+ // http://es5.github.com/#x15.4.4.15
694
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
695
+ var hasFirefox2LastIndexOfBug = Array.prototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
696
+ defineProperties(ArrayPrototype, {
697
+ lastIndexOf: function lastIndexOf(sought /*, fromIndex */) {
698
+ var self = splitString && isString(this) ? this.split('') : ES.ToObject(this),
699
+ length = self.length >>> 0;
700
+
701
+ if (!length) {
702
+ return -1;
703
+ }
704
+ var i = length - 1;
705
+ if (arguments.length > 1) {
706
+ i = Math.min(i, toInteger(arguments[1]));
707
+ }
708
+ // handle negative indices
709
+ i = i >= 0 ? i : length - Math.abs(i);
710
+ for (; i >= 0; i--) {
711
+ if (i in self && sought === self[i]) {
712
+ return i;
713
+ }
714
+ }
715
+ return -1;
716
+ }
717
+ }, hasFirefox2LastIndexOfBug);
718
+
719
+ //
720
+ // Object
721
+ // ======
722
+ //
723
+
724
+ // ES5 15.2.3.14
725
+ // http://es5.github.com/#x15.2.3.14
726
+
727
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
728
+ var hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
729
+ hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype'),
730
+ hasStringEnumBug = !owns('x', '0'),
731
+ dontEnums = [
732
+ 'toString',
733
+ 'toLocaleString',
734
+ 'valueOf',
735
+ 'hasOwnProperty',
736
+ 'isPrototypeOf',
737
+ 'propertyIsEnumerable',
738
+ 'constructor'
739
+ ],
740
+ dontEnumsLength = dontEnums.length;
741
+
742
+ defineProperties(Object, {
743
+ keys: function keys(object) {
744
+ var isFn = isFunction(object),
745
+ isArgs = isArguments(object),
746
+ isObject = object !== null && typeof object === 'object',
747
+ isStr = isObject && isString(object);
748
+
749
+ if (!isObject && !isFn && !isArgs) {
750
+ throw new TypeError('Object.keys called on a non-object');
751
+ }
752
+
753
+ var theKeys = [];
754
+ var skipProto = hasProtoEnumBug && isFn;
755
+ if ((isStr && hasStringEnumBug) || isArgs) {
756
+ for (var i = 0; i < object.length; ++i) {
757
+ theKeys.push(String(i));
758
+ }
759
+ }
760
+
761
+ if (!isArgs) {
762
+ for (var name in object) {
763
+ if (!(skipProto && name === 'prototype') && owns(object, name)) {
764
+ theKeys.push(String(name));
765
+ }
766
+ }
767
+ }
768
+
769
+ if (hasDontEnumBug) {
770
+ var ctor = object.constructor,
771
+ skipConstructor = ctor && ctor.prototype === object;
772
+ for (var j = 0; j < dontEnumsLength; j++) {
773
+ var dontEnum = dontEnums[j];
774
+ if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
775
+ theKeys.push(dontEnum);
776
+ }
777
+ }
778
+ }
779
+ return theKeys;
780
+ }
781
+ });
782
+
783
+ var keysWorksWithArguments = Object.keys && (function () {
784
+ // Safari 5.0 bug
785
+ return Object.keys(arguments).length === 2;
786
+ }(1, 2));
787
+ var originalKeys = Object.keys;
788
+ defineProperties(Object, {
789
+ keys: function keys(object) {
790
+ if (isArguments(object)) {
791
+ return originalKeys(ArrayPrototype.slice.call(object));
792
+ } else {
793
+ return originalKeys(object);
794
+ }
795
+ }
796
+ }, !keysWorksWithArguments);
797
+
798
+ //
799
+ // Date
800
+ // ====
801
+ //
802
+
803
+ // ES5 15.9.5.43
804
+ // http://es5.github.com/#x15.9.5.43
805
+ // This function returns a String value represent the instance in time
806
+ // represented by this Date object. The format of the String is the Date Time
807
+ // string format defined in 15.9.1.15. All fields are present in the String.
808
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
809
+ // this object is not a finite Number a RangeError exception is thrown.
810
+ var negativeDate = -62198755200000;
811
+ var negativeYearString = '-000001';
812
+ var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
813
+
814
+ defineProperties(Date.prototype, {
815
+ toISOString: function toISOString() {
816
+ var result, length, value, year, month;
817
+ if (!isFinite(this)) {
818
+ throw new RangeError('Date.prototype.toISOString called on non-finite value.');
819
+ }
820
+
821
+ year = this.getUTCFullYear();
822
+
823
+ month = this.getUTCMonth();
824
+ // see https://github.com/es-shims/es5-shim/issues/111
825
+ year += Math.floor(month / 12);
826
+ month = (month % 12 + 12) % 12;
827
+
828
+ // the date time string format is specified in 15.9.1.15.
829
+ result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
830
+ year = (
831
+ (year < 0 ? '-' : (year > 9999 ? '+' : '')) +
832
+ ('00000' + Math.abs(year)).slice((0 <= year && year <= 9999) ? -4 : -6)
833
+ );
834
+
835
+ length = result.length;
836
+ while (length--) {
837
+ value = result[length];
838
+ // pad months, days, hours, minutes, and seconds to have two
839
+ // digits.
840
+ if (value < 10) {
841
+ result[length] = '0' + value;
842
+ }
843
+ }
844
+ // pad milliseconds to have three digits.
845
+ return (
846
+ year + '-' + result.slice(0, 2).join('-') +
847
+ 'T' + result.slice(2).join(':') + '.' +
848
+ ('000' + this.getUTCMilliseconds()).slice(-3) + 'Z'
849
+ );
850
+ }
851
+ }, hasNegativeDateBug);
852
+
853
+
854
+ // ES5 15.9.5.44
855
+ // http://es5.github.com/#x15.9.5.44
856
+ // This function provides a String representation of a Date object for use by
857
+ // JSON.stringify (15.12.3).
858
+ var dateToJSONIsSupported = false;
859
+ try {
860
+ dateToJSONIsSupported = (
861
+ Date.prototype.toJSON &&
862
+ new Date(NaN).toJSON() === null &&
863
+ new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
864
+ Date.prototype.toJSON.call({ // generic
865
+ toISOString: function () {
866
+ return true;
867
+ }
868
+ })
869
+ );
870
+ } catch (e) {
871
+ }
872
+ if (!dateToJSONIsSupported) {
873
+ Date.prototype.toJSON = function toJSON(key) {
874
+ // When the toJSON method is called with argument key, the following
875
+ // steps are taken:
876
+
877
+ // 1. Let O be the result of calling ToObject, giving it the this
878
+ // value as its argument.
879
+ // 2. Let tv be toPrimitive(O, hint Number).
880
+ var o = Object(this),
881
+ tv = toPrimitive(o),
882
+ toISO;
883
+ // 3. If tv is a Number and is not finite, return null.
884
+ if (typeof tv === 'number' && !isFinite(tv)) {
885
+ return null;
886
+ }
887
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
888
+ // O with argument "toISOString".
889
+ toISO = o.toISOString;
890
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
891
+ if (typeof toISO !== 'function') {
892
+ throw new TypeError('toISOString property is not callable');
893
+ }
894
+ // 6. Return the result of calling the [[Call]] internal method of
895
+ // toISO with O as the this value and an empty argument list.
896
+ return toISO.call(o);
897
+
898
+ // NOTE 1 The argument is ignored.
899
+
900
+ // NOTE 2 The toJSON function is intentionally generic; it does not
901
+ // require that its this value be a Date object. Therefore, it can be
902
+ // transferred to other kinds of objects for use as a method. However,
903
+ // it does require that any such object have a toISOString method. An
904
+ // object is free to use the argument key to filter its
905
+ // stringification.
906
+ };
907
+ }
908
+
909
+ // ES5 15.9.4.2
910
+ // http://es5.github.com/#x15.9.4.2
911
+ // based on work shared by Daniel Friesen (dantman)
912
+ // http://gist.github.com/303249
913
+ var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
914
+ var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z'));
915
+ var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
916
+ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
917
+ // XXX global assignment won't work in embeddings that use
918
+ // an alternate object for the context.
919
+ /*global Date: true */
920
+ /*eslint-disable no-undef*/
921
+ Date = (function (NativeDate) {
922
+ /*eslint-enable no-undef*/
923
+ // Date.length === 7
924
+ function Date(Y, M, D, h, m, s, ms) {
925
+ var length = arguments.length;
926
+ if (this instanceof NativeDate) {
927
+ var date = length === 1 && String(Y) === Y ? // isString(Y)
928
+ // We explicitly pass it through parse:
929
+ new NativeDate(Date.parse(Y)) :
930
+ // We have to manually make calls depending on argument
931
+ // length here
932
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
933
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
934
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
935
+ length >= 4 ? new NativeDate(Y, M, D, h) :
936
+ length >= 3 ? new NativeDate(Y, M, D) :
937
+ length >= 2 ? new NativeDate(Y, M) :
938
+ length >= 1 ? new NativeDate(Y) :
939
+ new NativeDate();
940
+ // Prevent mixups with unfixed Date object
941
+ date.constructor = Date;
942
+ return date;
943
+ }
944
+ return NativeDate.apply(this, arguments);
945
+ }
946
+
947
+ // 15.9.1.15 Date Time String Format.
948
+ var isoDateExpression = new RegExp('^' +
949
+ '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
950
+ // 6-digit extended year
951
+ '(?:-(\\d{2})' + // optional month capture
952
+ '(?:-(\\d{2})' + // optional day capture
953
+ '(?:' + // capture hours:minutes:seconds.milliseconds
954
+ 'T(\\d{2})' + // hours capture
955
+ ':(\\d{2})' + // minutes capture
956
+ '(?:' + // optional :seconds.milliseconds
957
+ ':(\\d{2})' + // seconds capture
958
+ '(?:(\\.\\d{1,}))?' + // milliseconds capture
959
+ ')?' +
960
+ '(' + // capture UTC offset component
961
+ 'Z|' + // UTC capture
962
+ '(?:' + // offset specifier +/-hours:minutes
963
+ '([-+])' + // sign capture
964
+ '(\\d{2})' + // hours offset capture
965
+ ':(\\d{2})' + // minutes offset capture
966
+ ')' +
967
+ ')?)?)?)?' +
968
+ '$');
969
+
970
+ var months = [
971
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
972
+ ];
973
+
974
+ function dayFromMonth(year, month) {
975
+ var t = month > 1 ? 1 : 0;
976
+ return (
977
+ months[month] +
978
+ Math.floor((year - 1969 + t) / 4) -
979
+ Math.floor((year - 1901 + t) / 100) +
980
+ Math.floor((year - 1601 + t) / 400) +
981
+ 365 * (year - 1970)
982
+ );
983
+ }
984
+
985
+ function toUTC(t) {
986
+ return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
987
+ }
988
+
989
+ // Copy any custom methods a 3rd party library may have added
990
+ for (var key in NativeDate) {
991
+ Date[key] = NativeDate[key];
992
+ }
993
+
994
+ // Copy "native" methods explicitly; they may be non-enumerable
995
+ Date.now = NativeDate.now;
996
+ Date.UTC = NativeDate.UTC;
997
+ Date.prototype = NativeDate.prototype;
998
+ Date.prototype.constructor = Date;
999
+
1000
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
1001
+ Date.parse = function parse(string) {
1002
+ var match = isoDateExpression.exec(string);
1003
+ if (match) {
1004
+ // parse months, days, hours, minutes, seconds, and milliseconds
1005
+ // provide default values if necessary
1006
+ // parse the UTC offset component
1007
+ var year = Number(match[1]),
1008
+ month = Number(match[2] || 1) - 1,
1009
+ day = Number(match[3] || 1) - 1,
1010
+ hour = Number(match[4] || 0),
1011
+ minute = Number(match[5] || 0),
1012
+ second = Number(match[6] || 0),
1013
+ millisecond = Math.floor(Number(match[7] || 0) * 1000),
1014
+ // When time zone is missed, local offset should be used
1015
+ // (ES 5.1 bug)
1016
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=112
1017
+ isLocalTime = Boolean(match[4] && !match[8]),
1018
+ signOffset = match[9] === '-' ? 1 : -1,
1019
+ hourOffset = Number(match[10] || 0),
1020
+ minuteOffset = Number(match[11] || 0),
1021
+ result;
1022
+ if (
1023
+ hour < (
1024
+ minute > 0 || second > 0 || millisecond > 0 ?
1025
+ 24 : 25
1026
+ ) &&
1027
+ minute < 60 && second < 60 && millisecond < 1000 &&
1028
+ month > -1 && month < 12 && hourOffset < 24 &&
1029
+ minuteOffset < 60 && // detect invalid offsets
1030
+ day > -1 &&
1031
+ day < (
1032
+ dayFromMonth(year, month + 1) -
1033
+ dayFromMonth(year, month)
1034
+ )
1035
+ ) {
1036
+ result = (
1037
+ (dayFromMonth(year, month) + day) * 24 +
1038
+ hour +
1039
+ hourOffset * signOffset
1040
+ ) * 60;
1041
+ result = (
1042
+ (result + minute + minuteOffset * signOffset) * 60 +
1043
+ second
1044
+ ) * 1000 + millisecond;
1045
+ if (isLocalTime) {
1046
+ result = toUTC(result);
1047
+ }
1048
+ if (-8.64e15 <= result && result <= 8.64e15) {
1049
+ return result;
1050
+ }
1051
+ }
1052
+ return NaN;
1053
+ }
1054
+ return NativeDate.parse.apply(this, arguments);
1055
+ };
1056
+
1057
+ return Date;
1058
+ }(Date));
1059
+ /*global Date: false */
1060
+ }
1061
+
1062
+ // ES5 15.9.4.4
1063
+ // http://es5.github.com/#x15.9.4.4
1064
+ if (!Date.now) {
1065
+ Date.now = function now() {
1066
+ return new Date().getTime();
1067
+ };
1068
+ }
1069
+
1070
+
1071
+ //
1072
+ // Number
1073
+ // ======
1074
+ //
1075
+
1076
+ // ES5.1 15.7.4.5
1077
+ // http://es5.github.com/#x15.7.4.5
1078
+ var hasToFixedBugs = NumberPrototype.toFixed && (
1079
+ (0.00008).toFixed(3) !== '0.000' ||
1080
+ (0.9).toFixed(0) !== '1' ||
1081
+ (1.255).toFixed(2) !== '1.25' ||
1082
+ (1000000000000000128).toFixed(0) !== '1000000000000000128'
1083
+ );
1084
+
1085
+ var toFixedHelpers = {
1086
+ base: 1e7,
1087
+ size: 6,
1088
+ data: [0, 0, 0, 0, 0, 0],
1089
+ multiply: function multiply(n, c) {
1090
+ var i = -1;
1091
+ while (++i < toFixedHelpers.size) {
1092
+ c += n * toFixedHelpers.data[i];
1093
+ toFixedHelpers.data[i] = c % toFixedHelpers.base;
1094
+ c = Math.floor(c / toFixedHelpers.base);
1095
+ }
1096
+ },
1097
+ divide: function divide(n) {
1098
+ var i = toFixedHelpers.size, c = 0;
1099
+ while (--i >= 0) {
1100
+ c += toFixedHelpers.data[i];
1101
+ toFixedHelpers.data[i] = Math.floor(c / n);
1102
+ c = (c % n) * toFixedHelpers.base;
1103
+ }
1104
+ },
1105
+ numToString: function numToString() {
1106
+ var i = toFixedHelpers.size;
1107
+ var s = '';
1108
+ while (--i >= 0) {
1109
+ if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
1110
+ var t = String(toFixedHelpers.data[i]);
1111
+ if (s === '') {
1112
+ s = t;
1113
+ } else {
1114
+ s += '0000000'.slice(0, 7 - t.length) + t;
1115
+ }
1116
+ }
1117
+ }
1118
+ return s;
1119
+ },
1120
+ pow: function pow(x, n, acc) {
1121
+ return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
1122
+ },
1123
+ log: function log(x) {
1124
+ var n = 0;
1125
+ while (x >= 4096) {
1126
+ n += 12;
1127
+ x /= 4096;
1128
+ }
1129
+ while (x >= 2) {
1130
+ n += 1;
1131
+ x /= 2;
1132
+ }
1133
+ return n;
1134
+ }
1135
+ };
1136
+
1137
+ defineProperties(NumberPrototype, {
1138
+ toFixed: function toFixed(fractionDigits) {
1139
+ var f, x, s, m, e, z, j, k;
1140
+
1141
+ // Test for NaN and round fractionDigits down
1142
+ f = Number(fractionDigits);
1143
+ f = f !== f ? 0 : Math.floor(f);
1144
+
1145
+ if (f < 0 || f > 20) {
1146
+ throw new RangeError('Number.toFixed called with invalid number of decimals');
1147
+ }
1148
+
1149
+ x = Number(this);
1150
+
1151
+ // Test for NaN
1152
+ if (x !== x) {
1153
+ return 'NaN';
1154
+ }
1155
+
1156
+ // If it is too big or small, return the string value of the number
1157
+ if (x <= -1e21 || x >= 1e21) {
1158
+ return String(x);
1159
+ }
1160
+
1161
+ s = '';
1162
+
1163
+ if (x < 0) {
1164
+ s = '-';
1165
+ x = -x;
1166
+ }
1167
+
1168
+ m = '0';
1169
+
1170
+ if (x > 1e-21) {
1171
+ // 1e-21 < x < 1e21
1172
+ // -70 < log2(x) < 70
1173
+ e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
1174
+ z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
1175
+ z *= 0x10000000000000; // Math.pow(2, 52);
1176
+ e = 52 - e;
1177
+
1178
+ // -18 < e < 122
1179
+ // x = z / 2 ^ e
1180
+ if (e > 0) {
1181
+ toFixedHelpers.multiply(0, z);
1182
+ j = f;
1183
+
1184
+ while (j >= 7) {
1185
+ toFixedHelpers.multiply(1e7, 0);
1186
+ j -= 7;
1187
+ }
1188
+
1189
+ toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
1190
+ j = e - 1;
1191
+
1192
+ while (j >= 23) {
1193
+ toFixedHelpers.divide(1 << 23);
1194
+ j -= 23;
1195
+ }
1196
+
1197
+ toFixedHelpers.divide(1 << j);
1198
+ toFixedHelpers.multiply(1, 1);
1199
+ toFixedHelpers.divide(2);
1200
+ m = toFixedHelpers.numToString();
1201
+ } else {
1202
+ toFixedHelpers.multiply(0, z);
1203
+ toFixedHelpers.multiply(1 << (-e), 0);
1204
+ m = toFixedHelpers.numToString() + '0.00000000000000000000'.slice(2, 2 + f);
1205
+ }
1206
+ }
1207
+
1208
+ if (f > 0) {
1209
+ k = m.length;
1210
+
1211
+ if (k <= f) {
1212
+ m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
1213
+ } else {
1214
+ m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
1215
+ }
1216
+ } else {
1217
+ m = s + m;
1218
+ }
1219
+
1220
+ return m;
1221
+ }
1222
+ }, hasToFixedBugs);
1223
+
1224
+
1225
+ //
1226
+ // String
1227
+ // ======
1228
+ //
1229
+
1230
+ // ES5 15.5.4.14
1231
+ // http://es5.github.com/#x15.5.4.14
1232
+
1233
+ // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
1234
+ // Many browsers do not split properly with regular expressions or they
1235
+ // do not perform the split correctly under obscure conditions.
1236
+ // See http://blog.stevenlevithan.com/archives/cross-browser-split
1237
+ // I've tested in many browsers and this seems to cover the deviant ones:
1238
+ // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
1239
+ // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
1240
+ // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
1241
+ // [undefined, "t", undefined, "e", ...]
1242
+ // ''.split(/.?/) should be [], not [""]
1243
+ // '.'.split(/()()/) should be ["."], not ["", "", "."]
1244
+
1245
+ var string_split = StringPrototype.split;
1246
+ if (
1247
+ 'ab'.split(/(?:ab)*/).length !== 2 ||
1248
+ '.'.split(/(.?)(.?)/).length !== 4 ||
1249
+ 'tesst'.split(/(s)*/)[1] === 't' ||
1250
+ 'test'.split(/(?:)/, -1).length !== 4 ||
1251
+ ''.split(/.?/).length ||
1252
+ '.'.split(/()()/).length > 1
1253
+ ) {
1254
+ (function () {
1255
+ var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
1256
+
1257
+ StringPrototype.split = function (separator, limit) {
1258
+ var string = this;
1259
+ if (typeof separator === 'undefined' && limit === 0) {
1260
+ return [];
1261
+ }
1262
+
1263
+ // If `separator` is not a regex, use native split
1264
+ if (to_string.call(separator) !== '[object RegExp]') {
1265
+ return string_split.call(this, separator, limit);
1266
+ }
1267
+
1268
+ var output = [],
1269
+ flags = (separator.ignoreCase ? 'i' : '') +
1270
+ (separator.multiline ? 'm' : '') +
1271
+ (separator.extended ? 'x' : '') + // Proposed for ES6
1272
+ (separator.sticky ? 'y' : ''), // Firefox 3+
1273
+ lastLastIndex = 0,
1274
+ // Make `global` and avoid `lastIndex` issues by working with a copy
1275
+ separator2, match, lastIndex, lastLength;
1276
+ separator = new RegExp(separator.source, flags + 'g');
1277
+ string += ''; // Type-convert
1278
+ if (!compliantExecNpcg) {
1279
+ // Doesn't need flags gy, but they don't hurt
1280
+ separator2 = new RegExp('^' + separator.source + '$(?!\\s)', flags);
1281
+ }
1282
+ /* Values for `limit`, per the spec:
1283
+ * If undefined: 4294967295 // Math.pow(2, 32) - 1
1284
+ * If 0, Infinity, or NaN: 0
1285
+ * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
1286
+ * If negative number: 4294967296 - Math.floor(Math.abs(limit))
1287
+ * If other: Type-convert, then use the above rules
1288
+ */
1289
+ limit = typeof limit === 'undefined' ?
1290
+ -1 >>> 0 : // Math.pow(2, 32) - 1
1291
+ ES.ToUint32(limit);
1292
+ match = separator.exec(string);
1293
+ while (match) {
1294
+ // `separator.lastIndex` is not reliable cross-browser
1295
+ lastIndex = match.index + match[0].length;
1296
+ if (lastIndex > lastLastIndex) {
1297
+ output.push(string.slice(lastLastIndex, match.index));
1298
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
1299
+ // nonparticipating capturing groups
1300
+ if (!compliantExecNpcg && match.length > 1) {
1301
+ /*eslint-disable no-loop-func */
1302
+ match[0].replace(separator2, function () {
1303
+ for (var i = 1; i < arguments.length - 2; i++) {
1304
+ if (typeof arguments[i] === 'undefined') {
1305
+ match[i] = void 0;
1306
+ }
1307
+ }
1308
+ });
1309
+ /*eslint-enable no-loop-func */
1310
+ }
1311
+ if (match.length > 1 && match.index < string.length) {
1312
+ array_push.apply(output, match.slice(1));
1313
+ }
1314
+ lastLength = match[0].length;
1315
+ lastLastIndex = lastIndex;
1316
+ if (output.length >= limit) {
1317
+ break;
1318
+ }
1319
+ }
1320
+ if (separator.lastIndex === match.index) {
1321
+ separator.lastIndex++; // Avoid an infinite loop
1322
+ }
1323
+ match = separator.exec(string);
1324
+ }
1325
+ if (lastLastIndex === string.length) {
1326
+ if (lastLength || !separator.test('')) {
1327
+ output.push('');
1328
+ }
1329
+ } else {
1330
+ output.push(string.slice(lastLastIndex));
1331
+ }
1332
+ return output.length > limit ? output.slice(0, limit) : output;
1333
+ };
1334
+ }());
1335
+
1336
+ // [bugfix, chrome]
1337
+ // If separator is undefined, then the result array contains just one String,
1338
+ // which is the this value (converted to a String). If limit is not undefined,
1339
+ // then the output array is truncated so that it contains no more than limit
1340
+ // elements.
1341
+ // "0".split(undefined, 0) -> []
1342
+ } else if ('0'.split(void 0, 0).length) {
1343
+ StringPrototype.split = function split(separator, limit) {
1344
+ if (typeof separator === 'undefined' && limit === 0) { return []; }
1345
+ return string_split.call(this, separator, limit);
1346
+ };
1347
+ }
1348
+
1349
+ var str_replace = StringPrototype.replace;
1350
+ var replaceReportsGroupsCorrectly = (function () {
1351
+ var groups = [];
1352
+ 'x'.replace(/x(.)?/g, function (match, group) {
1353
+ groups.push(group);
1354
+ });
1355
+ return groups.length === 1 && typeof groups[0] === 'undefined';
1356
+ }());
1357
+
1358
+ if (!replaceReportsGroupsCorrectly) {
1359
+ StringPrototype.replace = function replace(searchValue, replaceValue) {
1360
+ var isFn = isFunction(replaceValue);
1361
+ var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
1362
+ if (!isFn || !hasCapturingGroups) {
1363
+ return str_replace.call(this, searchValue, replaceValue);
1364
+ } else {
1365
+ var wrappedReplaceValue = function (match) {
1366
+ var length = arguments.length;
1367
+ var originalLastIndex = searchValue.lastIndex;
1368
+ searchValue.lastIndex = 0;
1369
+ var args = searchValue.exec(match) || [];
1370
+ searchValue.lastIndex = originalLastIndex;
1371
+ args.push(arguments[length - 2], arguments[length - 1]);
1372
+ return replaceValue.apply(this, args);
1373
+ };
1374
+ return str_replace.call(this, searchValue, wrappedReplaceValue);
1375
+ }
1376
+ };
1377
+ }
1378
+
1379
+ // ECMA-262, 3rd B.2.3
1380
+ // Not an ECMAScript standard, although ECMAScript 3rd Edition has a
1381
+ // non-normative section suggesting uniform semantics and it should be
1382
+ // normalized across all browsers
1383
+ // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
1384
+ var string_substr = StringPrototype.substr;
1385
+ var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
1386
+ defineProperties(StringPrototype, {
1387
+ substr: function substr(start, length) {
1388
+ return string_substr.call(
1389
+ this,
1390
+ start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
1391
+ length
1392
+ );
1393
+ }
1394
+ }, hasNegativeSubstrBug);
1395
+
1396
+ // ES5 15.5.4.20
1397
+ // whitespace from: http://es5.github.io/#x15.5.4.20
1398
+ var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
1399
+ '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
1400
+ '\u2029\uFEFF';
1401
+ var zeroWidth = '\u200b';
1402
+ var wsRegexChars = '[' + ws + ']';
1403
+ var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
1404
+ var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$');
1405
+ var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
1406
+ defineProperties(StringPrototype, {
1407
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1408
+ // http://perfectionkills.com/whitespace-deviations/
1409
+ trim: function trim() {
1410
+ if (typeof this === 'undefined' || this === null) {
1411
+ throw new TypeError("can't convert " + this + ' to object');
1412
+ }
1413
+ return String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
1414
+ }
1415
+ }, hasTrimWhitespaceBug);
1416
+
1417
+ // ES-5 15.1.2.2
1418
+ if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
1419
+ /*global parseInt: true */
1420
+ parseInt = (function (origParseInt) {
1421
+ var hexRegex = /^0[xX]/;
1422
+ return function parseIntES5(str, radix) {
1423
+ str = String(str).trim();
1424
+ if (!Number(radix)) {
1425
+ radix = hexRegex.test(str) ? 16 : 10;
1426
+ }
1427
+ return origParseInt(str, radix);
1428
+ };
1429
+ }(parseInt));
1430
+ }
1431
+
1432
+ }));