webshims-rails 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/lib/webshims-rails.rb +1 -1
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/readme.textile +5 -3
  4. data/vendor/assets/javascripts/webshims/dev/extras/custom-validity.js +261 -0
  5. data/vendor/assets/javascripts/webshims/dev/extras/modernizr-custom.js +535 -0
  6. data/vendor/assets/javascripts/webshims/dev/extras/mousepress.js +60 -0
  7. data/vendor/assets/javascripts/webshims/dev/polyfiller.js +1171 -0
  8. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/README +62 -0
  9. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/canvas2png.js +42 -0
  10. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/flashcanvas.js +28 -0
  11. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/flashcanvas.swf +0 -0
  12. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/proxy.php +73 -0
  13. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvas/save.php +49 -0
  14. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/README +82 -0
  15. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/canvas2png.js +42 -0
  16. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/flash10canvas.swf +0 -0
  17. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/flash9canvas.swf +0 -0
  18. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/flashcanvas.js +31 -0
  19. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/proxy.php +73 -0
  20. data/vendor/assets/javascripts/webshims/dev/shims/FlashCanvasPro/save.php +49 -0
  21. data/vendor/assets/javascripts/webshims/dev/shims/combos/1.js +1710 -0
  22. data/vendor/assets/javascripts/webshims/dev/shims/combos/10.js +3317 -0
  23. data/vendor/assets/javascripts/webshims/dev/shims/combos/11.js +1585 -0
  24. data/vendor/assets/javascripts/webshims/dev/shims/combos/12.js +1587 -0
  25. data/vendor/assets/javascripts/webshims/dev/shims/combos/13.js +1054 -0
  26. data/vendor/assets/javascripts/webshims/dev/shims/combos/14.js +476 -0
  27. data/vendor/assets/javascripts/webshims/dev/shims/combos/15.js +314 -0
  28. data/vendor/assets/javascripts/webshims/dev/shims/combos/16.js +2101 -0
  29. data/vendor/assets/javascripts/webshims/dev/shims/combos/17.js +2264 -0
  30. data/vendor/assets/javascripts/webshims/dev/shims/combos/18.js +2161 -0
  31. data/vendor/assets/javascripts/webshims/dev/shims/combos/19.js +2244 -0
  32. data/vendor/assets/javascripts/webshims/dev/shims/combos/2.js +2294 -0
  33. data/vendor/assets/javascripts/webshims/dev/shims/combos/20.js +1607 -0
  34. data/vendor/assets/javascripts/webshims/dev/shims/combos/21.js +1635 -0
  35. data/vendor/assets/javascripts/webshims/dev/shims/combos/22.js +2409 -0
  36. data/vendor/assets/javascripts/webshims/dev/shims/combos/23.js +2168 -0
  37. data/vendor/assets/javascripts/webshims/dev/shims/combos/24.js +2777 -0
  38. data/vendor/assets/javascripts/webshims/dev/shims/combos/25.js +2204 -0
  39. data/vendor/assets/javascripts/webshims/dev/shims/combos/26.js +2863 -0
  40. data/vendor/assets/javascripts/webshims/dev/shims/combos/27.js +4079 -0
  41. data/vendor/assets/javascripts/webshims/dev/shims/combos/3.js +2971 -0
  42. data/vendor/assets/javascripts/webshims/dev/shims/combos/4.js +823 -0
  43. data/vendor/assets/javascripts/webshims/dev/shims/combos/5.js +1078 -0
  44. data/vendor/assets/javascripts/webshims/dev/shims/combos/59.js +1754 -0
  45. data/vendor/assets/javascripts/webshims/dev/shims/combos/6.js +1230 -0
  46. data/vendor/assets/javascripts/webshims/dev/shims/combos/7.js +1485 -0
  47. data/vendor/assets/javascripts/webshims/dev/shims/combos/8.js +1442 -0
  48. data/vendor/assets/javascripts/webshims/dev/shims/combos/9.js +2515 -0
  49. data/vendor/assets/javascripts/webshims/dev/shims/details.js +146 -0
  50. data/vendor/assets/javascripts/webshims/dev/shims/dom-extend.js +908 -0
  51. data/vendor/assets/javascripts/webshims/dev/shims/es5.js +802 -0
  52. data/vendor/assets/javascripts/webshims/dev/shims/excanvas.js +924 -0
  53. data/vendor/assets/javascripts/webshims/dev/shims/form-core.js +660 -0
  54. data/vendor/assets/javascripts/webshims/dev/shims/form-datalist.js +677 -0
  55. data/vendor/assets/javascripts/webshims/dev/shims/form-message.js +164 -0
  56. data/vendor/assets/javascripts/webshims/dev/shims/form-native-extend.js +256 -0
  57. data/vendor/assets/javascripts/webshims/dev/shims/form-native-fix.js +261 -0
  58. data/vendor/assets/javascripts/webshims/dev/shims/form-number-date-api.js +384 -0
  59. data/vendor/assets/javascripts/webshims/dev/shims/form-number-date-ui.js +847 -0
  60. data/vendor/assets/javascripts/webshims/dev/shims/form-shim-extend.js +1472 -0
  61. data/vendor/assets/javascripts/webshims/dev/shims/geolocation.js +168 -0
  62. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-ar.js +32 -0
  63. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-ch-ZN.js +32 -0
  64. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-de.txt +33 -0
  65. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-el.js +32 -0
  66. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-en.txt +34 -0
  67. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-es.js +32 -0
  68. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-fr.js +32 -0
  69. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-he.js +32 -0
  70. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-hi.js +32 -0
  71. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-hu.js +32 -0
  72. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-it.js +32 -0
  73. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-ja.js +32 -0
  74. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-nl.js +32 -0
  75. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-pt-PT.js +32 -0
  76. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-ru.js +32 -0
  77. data/vendor/assets/javascripts/webshims/dev/shims/i18n/errormessages-sv.js +32 -0
  78. data/vendor/assets/javascripts/webshims/dev/shims/json-storage.js +308 -0
  79. data/vendor/assets/javascripts/webshims/dev/shims/jwplayer/license.txt +1 -0
  80. data/vendor/assets/javascripts/webshims/dev/shims/jwplayer/player.swf +0 -0
  81. data/vendor/assets/javascripts/webshims/dev/shims/jwplayer/readme.html +87 -0
  82. data/vendor/assets/javascripts/webshims/dev/shims/mediaelement-core.js +534 -0
  83. data/vendor/assets/javascripts/webshims/dev/shims/mediaelement-native-fix.js +99 -0
  84. data/vendor/assets/javascripts/webshims/dev/shims/mediaelement-swf.js +1074 -0
  85. data/vendor/assets/javascripts/webshims/dev/shims/mediaelement-yt.js +543 -0
  86. data/vendor/assets/javascripts/webshims/dev/shims/styles/details-arrows.png +0 -0
  87. data/vendor/assets/javascripts/webshims/dev/shims/styles/forms.png +0 -0
  88. data/vendor/assets/javascripts/webshims/dev/shims/styles/polyfill-loader.gif +0 -0
  89. data/vendor/assets/javascripts/webshims/dev/shims/styles/shim.css +677 -0
  90. data/vendor/assets/javascripts/webshims/dev/shims/swf/jwwebshims.swf +0 -0
  91. data/vendor/assets/javascripts/webshims/dev/shims/swf/localStorage.swf +0 -0
  92. data/vendor/assets/javascripts/webshims/dev/shims/track-ui.js +292 -0
  93. data/vendor/assets/javascripts/webshims/dev/shims/track.js +763 -0
  94. data/vendor/assets/javascripts/webshims/minified/extras/modernizr-custom.js +20 -20
  95. data/vendor/assets/javascripts/webshims/minified/polyfiller.js +29 -29
  96. data/vendor/assets/javascripts/webshims/minified/shims/combos/1.js +37 -33
  97. data/vendor/assets/javascripts/webshims/minified/shims/combos/10.js +83 -76
  98. data/vendor/assets/javascripts/webshims/minified/shims/combos/11.js +44 -42
  99. data/vendor/assets/javascripts/webshims/minified/shims/combos/12.js +43 -38
  100. data/vendor/assets/javascripts/webshims/minified/shims/combos/13.js +27 -25
  101. data/vendor/assets/javascripts/webshims/minified/shims/combos/16.js +60 -55
  102. data/vendor/assets/javascripts/webshims/minified/shims/combos/17.js +68 -64
  103. data/vendor/assets/javascripts/webshims/minified/shims/combos/18.js +60 -59
  104. data/vendor/assets/javascripts/webshims/minified/shims/combos/19.js +66 -64
  105. data/vendor/assets/javascripts/webshims/minified/shims/combos/2.js +74 -69
  106. data/vendor/assets/javascripts/webshims/minified/shims/combos/20.js +46 -43
  107. data/vendor/assets/javascripts/webshims/minified/shims/combos/21.js +52 -47
  108. data/vendor/assets/javascripts/webshims/minified/shims/combos/22.js +61 -57
  109. data/vendor/assets/javascripts/webshims/minified/shims/combos/23.js +68 -60
  110. data/vendor/assets/javascripts/webshims/minified/shims/combos/24.js +82 -77
  111. data/vendor/assets/javascripts/webshims/minified/shims/combos/25.js +58 -0
  112. data/vendor/assets/javascripts/webshims/minified/shims/combos/26.js +80 -0
  113. data/vendor/assets/javascripts/webshims/minified/shims/combos/27.js +103 -0
  114. data/vendor/assets/javascripts/webshims/minified/shims/combos/3.js +96 -91
  115. data/vendor/assets/javascripts/webshims/minified/shims/combos/4.js +30 -31
  116. data/vendor/assets/javascripts/webshims/minified/shims/combos/5.js +37 -39
  117. data/vendor/assets/javascripts/webshims/minified/shims/combos/59.js +59 -61
  118. data/vendor/assets/javascripts/webshims/minified/shims/combos/6.js +31 -29
  119. data/vendor/assets/javascripts/webshims/minified/shims/combos/7.js +38 -37
  120. data/vendor/assets/javascripts/webshims/minified/shims/combos/8.js +38 -33
  121. data/vendor/assets/javascripts/webshims/minified/shims/combos/9.js +68 -63
  122. data/vendor/assets/javascripts/webshims/minified/shims/dom-extend.js +22 -20
  123. data/vendor/assets/javascripts/webshims/minified/shims/es5.js +15 -14
  124. data/vendor/assets/javascripts/webshims/minified/shims/form-core.js +22 -22
  125. data/vendor/assets/javascripts/webshims/minified/shims/form-datalist.js +22 -22
  126. data/vendor/assets/javascripts/webshims/minified/shims/form-message.js +8 -9
  127. data/vendor/assets/javascripts/webshims/minified/shims/form-native-extend.js +7 -8
  128. data/vendor/assets/javascripts/webshims/minified/shims/form-number-date-ui.js +23 -21
  129. data/vendor/assets/javascripts/webshims/minified/shims/form-shim-extend.js +44 -33
  130. data/vendor/assets/javascripts/webshims/minified/shims/i18n/errormessages-sv.js +3 -0
  131. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/player.swf +0 -0
  132. data/vendor/assets/javascripts/webshims/minified/shims/jwplayer/readme.html +86 -86
  133. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-core.js +16 -13
  134. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-swf.js +30 -30
  135. data/vendor/assets/javascripts/webshims/minified/shims/mediaelement-yt.js +14 -0
  136. data/vendor/assets/javascripts/webshims/minified/shims/styles/shim.css +71 -10
  137. data/vendor/assets/javascripts/webshims/minified/shims/track-ui.js +9 -0
  138. data/vendor/assets/javascripts/webshims/minified/shims/track.js +20 -0
  139. metadata +101 -5
  140. data/vendor/assets/javascripts/webshims/minified/shims/form-output.js +0 -5
@@ -0,0 +1,49 @@
1
+ <?php
2
+
3
+ /**
4
+ * Save the input as a PNG file
5
+ *
6
+ * PHP versions 4 and 5
7
+ *
8
+ * Copyright (c) 2010-2011 Shinya Muramatsu
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a
11
+ * copy of this software and associated documentation files (the "Software"),
12
+ * to deal in the Software without restriction, including without limitation
13
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
+ * and/or sell copies of the Software, and to permit persons to whom the
15
+ * Software is furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in
18
+ * all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
+ * DEALINGS IN THE SOFTWARE.
27
+ *
28
+ * @author Shinya Muramatsu <revulon@gmail.com>
29
+ * @copyright 2010-2011 Shinya Muramatsu
30
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
31
+ * @link http://flashcanvas.net/
32
+ * @link http://code.google.com/p/flashcanvas/
33
+ */
34
+
35
+ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
36
+ // Force download
37
+ header('Content-Type: application/octet-stream');
38
+ header('Content-Disposition: attachment; filename="canvas.png"');
39
+
40
+ if (isset($_POST['dataurl'])) {
41
+ // Decode the base64-encoded data
42
+ $data = $_POST['dataurl'];
43
+ $data = substr($data, strpos($data, ',') + 1);
44
+ echo base64_decode($data);
45
+ } else {
46
+ // Output the raw data
47
+ readfile('php://input');
48
+ }
49
+ }
@@ -0,0 +1,1710 @@
1
+ // vim: ts=4 sts=4 sw=4 expandtab
2
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
3
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
4
+ // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
5
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
6
+ // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
7
+ // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
8
+ // -- kossnocorp Sasha Koss XXX TODO License or CLA
9
+ // -- bryanforbes Bryan Forbes XXX TODO License or CLA
10
+ // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
11
+ // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
12
+ // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
13
+ // -- bbqsrc Brendan Molloy XXX TODO License or CLA
14
+ // -- iwyg XXX TODO License or CLA
15
+ // -- DomenicDenicola Domenic Denicola XXX TODO License or CLA
16
+ // -- xavierm02 Montillet Xavier XXX TODO License or CLA
17
+ // -- Raynos Raynos XXX TODO License or CLA
18
+ // -- samsonjs Sami Samhuri XXX TODO License or CLA
19
+ // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
20
+ // -- lexer Alexey Zakharov XXX TODO License or CLA
21
+
22
+ /*!
23
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
24
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
25
+ */
26
+
27
+ (function (undefined) {
28
+
29
+ /**
30
+ * Brings an environment as close to ECMAScript 5 compliance
31
+ * as is possible with the facilities of erstwhile engines.
32
+ *
33
+ * ES5 Draft
34
+ * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
35
+ *
36
+ * NOTE: this is a draft, and as such, the URL is subject to change. If the
37
+ * link is broken, check in the parent directory for the latest TC39 PDF.
38
+ * http://www.ecma-international.org/publications/files/drafts/
39
+ *
40
+ * Previous ES5 Draft
41
+ * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
42
+ * This is a broken link to the previous draft of ES5 on which most of the
43
+ * numbered specification references and quotes herein were taken. Updating
44
+ * these references and quotes to reflect the new document would be a welcome
45
+ * volunteer project.
46
+ *
47
+ * @module
48
+ */
49
+
50
+ /*whatsupdoc*/
51
+
52
+ // Shortcut to an often accessed properties, in order to avoid multiple
53
+ // dereference that costs universally.
54
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
55
+ // us it in defining shortcuts.
56
+ var call = Function.prototype.call;
57
+ var prototypeOfArray = Array.prototype;
58
+ var prototypeOfObject = Object.prototype;
59
+ var slice = prototypeOfArray.slice;
60
+ var owns;
61
+ var toString;
62
+
63
+ // ES-5 15.3.4.5
64
+ // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
65
+
66
+ if (!Function.prototype.bind) {
67
+ Function.prototype.bind = function (that) { // .length is 1
68
+ // 1. Let Target be the this value.
69
+ var target = this;
70
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
71
+ if (typeof target != "function")
72
+ throw new TypeError(); // TODO message
73
+ // 3. Let A be a new (possibly empty) internal list of all of the
74
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
75
+ // XXX slicedArgs will stand in for "A" if used
76
+ var args = slice.call(arguments, 1); // for normal call
77
+ // 4. Let F be a new native ECMAScript object.
78
+ // 9. Set the [[Prototype]] internal property of F to the standard
79
+ // built-in Function prototype object as specified in 15.3.3.1.
80
+ // 10. Set the [[Call]] internal property of F as described in
81
+ // 15.3.4.5.1.
82
+ // 11. Set the [[Construct]] internal property of F as described in
83
+ // 15.3.4.5.2.
84
+ // 12. Set the [[HasInstance]] internal property of F as described in
85
+ // 15.3.4.5.3.
86
+ // 13. The [[Scope]] internal property of F is unused and need not
87
+ // exist.
88
+ var bound = function () {
89
+
90
+ if (this instanceof bound) {
91
+ // 15.3.4.5.2 [[Construct]]
92
+ // When the [[Construct]] internal method of a function object,
93
+ // F that was created using the bind function is called with a
94
+ // list of arguments ExtraArgs the following steps are taken:
95
+ // 1. Let target be the value of F's [[TargetFunction]]
96
+ // internal property.
97
+ // 2. If target has no [[Construct]] internal method, a
98
+ // TypeError exception is thrown.
99
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
100
+ // property.
101
+ // 4. Let args be a new list containing the same values as the
102
+ // list boundArgs in the same order followed by the same
103
+ // values as the list ExtraArgs in the same order.
104
+
105
+ var F = function(){};
106
+ F.prototype = target.prototype;
107
+ var self = new F;
108
+
109
+ var result = target.apply(
110
+ self,
111
+ args.concat(slice.call(arguments))
112
+ );
113
+ if (result !== null && Object(result) === result)
114
+ return result;
115
+ return self;
116
+
117
+ } else {
118
+ // 15.3.4.5.1 [[Call]]
119
+ // When the [[Call]] internal method of a function object, F,
120
+ // which was created using the bind function is called with a
121
+ // this value and a list of arguments ExtraArgs the following
122
+ // steps are taken:
123
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
124
+ // property.
125
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
126
+ // property.
127
+ // 3. Let target be the value of F's [[TargetFunction]] internal
128
+ // property.
129
+ // 4. Let args be a new list containing the same values as the list
130
+ // boundArgs in the same order followed by the same values as
131
+ // the list ExtraArgs in the same order. 5. Return the
132
+ // result of calling the [[Call]] internal method of target
133
+ // providing boundThis as the this value and providing args
134
+ // as the arguments.
135
+
136
+ // equiv: target.call(this, ...boundArgs, ...args)
137
+ return target.apply(
138
+ that,
139
+ args.concat(slice.call(arguments))
140
+ );
141
+
142
+ }
143
+
144
+ };
145
+ // XXX bound.length is never writable, so don't even try
146
+ //
147
+ // 16. The length own property of F is given attributes as specified in
148
+ // 15.3.5.1.
149
+ // TODO
150
+ // 17. Set the [[Extensible]] internal property of F to true.
151
+ // TODO
152
+ // 18. Call the [[DefineOwnProperty]] internal method of F with
153
+ // arguments "caller", PropertyDescriptor {[[Value]]: null,
154
+ // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
155
+ // false}, and false.
156
+ // TODO
157
+ // 19. Call the [[DefineOwnProperty]] internal method of F with
158
+ // arguments "arguments", PropertyDescriptor {[[Value]]: null,
159
+ // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
160
+ // false}, and false.
161
+ // TODO
162
+ // NOTE Function objects created using Function.prototype.bind do not
163
+ // have a prototype property.
164
+ // XXX can't delete it in pure-js.
165
+ return bound;
166
+ };
167
+ }
168
+
169
+ toString = call.bind(prototypeOfObject.toString);
170
+ owns = call.bind(prototypeOfObject.hasOwnProperty);
171
+
172
+
173
+ //
174
+ // Array
175
+ // =====
176
+ //
177
+
178
+ // ES5 15.4.3.2
179
+ if (!Array.isArray) {
180
+ Array.isArray = function (obj) {
181
+ return toString(obj) == "[object Array]";
182
+ };
183
+ }
184
+
185
+ // The IsCallable() check in the Array functions
186
+ // has been replaced with a strict check on the
187
+ // internal class of the object to trap cases where
188
+ // the provided function was actually a regular
189
+ // expression literal, which in V8 and
190
+ // JavaScriptCore is a typeof "function". Only in
191
+ // V8 are regular expression literals permitted as
192
+ // reduce parameters, so it is desirable in the
193
+ // general case for the shim to match the more
194
+ // strict and common behavior of rejecting regular
195
+ // expressions.
196
+
197
+ // ES5 15.4.4.18
198
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
199
+ if (!Array.prototype.forEach) {
200
+ Array.prototype.forEach = function (fun /*, thisp*/) {
201
+ var self = toObject(this),
202
+ thisp = arguments[1],
203
+ i = 0,
204
+ length = self.length >>> 0;
205
+
206
+ // If no callback function or if callback is not a callable function
207
+ if (toString(fun) != "[object Function]") {
208
+ throw new TypeError(); // TODO message
209
+ }
210
+
211
+ while (i < length) {
212
+ if (i in self) {
213
+ // Invoke the callback function with call, passing arguments:
214
+ // context, property value, property key, thisArg object context
215
+ fun.call(thisp, self[i], i, self);
216
+ }
217
+ i++;
218
+ }
219
+ };
220
+ }
221
+
222
+ // ES5 15.4.4.19
223
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
224
+ if (!Array.prototype.map) {
225
+ Array.prototype.map = function (fun /*, thisp*/) {
226
+ var self = toObject(this),
227
+ length = self.length >>> 0,
228
+ result = Array(length),
229
+ thisp = arguments[1];
230
+
231
+ // If no callback function or if callback is not a callable function
232
+ if (toString(fun) != "[object Function]") {
233
+ throw new TypeError(); // TODO message
234
+ }
235
+
236
+ for (var i = 0; i < length; i++) {
237
+ if (i in self)
238
+ result[i] = fun.call(thisp, self[i], i, self);
239
+ }
240
+ return result;
241
+ };
242
+ }
243
+
244
+ // ES5 15.4.4.20
245
+ if (!Array.prototype.filter) {
246
+ Array.prototype.filter = function (fun /*, thisp */) {
247
+ var self = toObject(this),
248
+ length = self.length >>> 0,
249
+ result = [],
250
+ thisp = arguments[1];
251
+
252
+ // If no callback function or if callback is not a callable function
253
+ if (toString(fun) != "[object Function]") {
254
+ throw new TypeError(); // TODO message
255
+ }
256
+
257
+ for (var i = 0; i < length; i++) {
258
+ if (i in self && fun.call(thisp, self[i], i, self))
259
+ result.push(self[i]);
260
+ }
261
+ return result;
262
+ };
263
+ }
264
+
265
+ // ES5 15.4.4.16
266
+ if (!Array.prototype.every) {
267
+ Array.prototype.every = function (fun /*, thisp */) {
268
+ var self = toObject(this),
269
+ length = self.length >>> 0,
270
+ thisp = arguments[1];
271
+
272
+ // If no callback function or if callback is not a callable function
273
+ if (toString(fun) != "[object Function]") {
274
+ throw new TypeError(); // TODO message
275
+ }
276
+
277
+ for (var i = 0; i < length; i++) {
278
+ if (i in self && !fun.call(thisp, self[i], i, self))
279
+ return false;
280
+ }
281
+ return true;
282
+ };
283
+ }
284
+
285
+ // ES5 15.4.4.17
286
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
287
+ if (!Array.prototype.some) {
288
+ Array.prototype.some = function (fun /*, thisp */) {
289
+ var self = toObject(this),
290
+ length = self.length >>> 0,
291
+ thisp = arguments[1];
292
+
293
+ // If no callback function or if callback is not a callable function
294
+ if (toString(fun) != "[object Function]") {
295
+ throw new TypeError(); // TODO message
296
+ }
297
+
298
+ for (var i = 0; i < length; i++) {
299
+ if (i in self && fun.call(thisp, self[i], i, self))
300
+ return true;
301
+ }
302
+ return false;
303
+ };
304
+ }
305
+
306
+ // ES5 15.4.4.21
307
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
308
+ if (!Array.prototype.reduce) {
309
+ Array.prototype.reduce = function (fun /*, initial*/) {
310
+ var self = toObject(this),
311
+ length = self.length >>> 0;
312
+
313
+ // If no callback function or if callback is not a callable function
314
+ if (toString(fun) != "[object Function]") {
315
+ throw new TypeError(); // TODO message
316
+ }
317
+
318
+ // no value to return if no initial value and an empty array
319
+ if (!length && arguments.length == 1)
320
+ throw new TypeError(); // TODO message
321
+
322
+ var i = 0;
323
+ var result;
324
+ if (arguments.length >= 2) {
325
+ result = arguments[1];
326
+ } else {
327
+ do {
328
+ if (i in self) {
329
+ result = self[i++];
330
+ break;
331
+ }
332
+
333
+ // if array contains no values, no initial value to return
334
+ if (++i >= length)
335
+ throw new TypeError(); // TODO message
336
+ } while (true);
337
+ }
338
+
339
+ for (; i < length; i++) {
340
+ if (i in self)
341
+ result = fun.call(void 0, result, self[i], i, self);
342
+ }
343
+
344
+ return result;
345
+ };
346
+ }
347
+
348
+ // ES5 15.4.4.22
349
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
350
+ if (!Array.prototype.reduceRight) {
351
+ Array.prototype.reduceRight = function (fun /*, initial*/) {
352
+ var self = toObject(this),
353
+ length = self.length >>> 0;
354
+
355
+ // If no callback function or if callback is not a callable function
356
+ if (toString(fun) != "[object Function]") {
357
+ throw new TypeError(); // TODO message
358
+ }
359
+
360
+ // no value to return if no initial value, empty array
361
+ if (!length && arguments.length == 1)
362
+ throw new TypeError(); // TODO message
363
+
364
+ var result, i = length - 1;
365
+ if (arguments.length >= 2) {
366
+ result = arguments[1];
367
+ } else {
368
+ do {
369
+ if (i in self) {
370
+ result = self[i--];
371
+ break;
372
+ }
373
+
374
+ // if array contains no values, no initial value to return
375
+ if (--i < 0)
376
+ throw new TypeError(); // TODO message
377
+ } while (true);
378
+ }
379
+
380
+ do {
381
+ if (i in this)
382
+ result = fun.call(void 0, result, self[i], i, self);
383
+ } while (i--);
384
+
385
+ return result;
386
+ };
387
+ }
388
+
389
+ // ES5 15.4.4.14
390
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
391
+ if (!Array.prototype.indexOf) {
392
+ Array.prototype.indexOf = function (sought /*, fromIndex */ ) {
393
+ var self = toObject(this),
394
+ length = self.length >>> 0;
395
+
396
+ if (!length)
397
+ return -1;
398
+
399
+ var i = 0;
400
+ if (arguments.length > 1)
401
+ i = toInteger(arguments[1]);
402
+
403
+ // handle negative indices
404
+ i = i >= 0 ? i : length - Math.abs(i);
405
+ for (; i < length; i++) {
406
+ if (i in self && self[i] === sought) {
407
+ return i;
408
+ }
409
+ }
410
+ return -1;
411
+ };
412
+ }
413
+
414
+ // ES5 15.4.4.15
415
+ if (!Array.prototype.lastIndexOf) {
416
+ Array.prototype.lastIndexOf = function (sought /*, fromIndex */) {
417
+ var self = toObject(this),
418
+ length = self.length >>> 0;
419
+
420
+ if (!length)
421
+ return -1;
422
+ var i = length - 1;
423
+ if (arguments.length > 1)
424
+ i = toInteger(arguments[1]);
425
+ // handle negative indices
426
+ i = i >= 0 ? i : length - Math.abs(i);
427
+ for (; i >= 0; i--) {
428
+ if (i in self && sought === self[i])
429
+ return i;
430
+ }
431
+ return -1;
432
+ };
433
+ }
434
+
435
+ //
436
+ // Array
437
+ // =====
438
+ //
439
+
440
+ // ES5 15.4.4.12
441
+ // http://es5.github.com/#x15.4.4.12
442
+ // Default value for second param
443
+ // [bugfix, ielt9, old browsers]
444
+ // IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
445
+ if([1,2].splice(0).length != 2) {
446
+ var _origArraySplice = Array.prototype.splice;
447
+
448
+ Array.prototype.splice = function(start, deleteCount) {
449
+ if(!arguments.length)return [];
450
+
451
+ return _origArraySplice.apply(this, [
452
+ start === void 0 ? 0 : start,
453
+ deleteCount === void 0 ? (this.length - start) : deleteCount
454
+ ].concat(slice.call(arguments, 2)))
455
+ };
456
+ }
457
+
458
+ //
459
+ // Object
460
+ // ======
461
+ //
462
+
463
+
464
+ // ES5 15.2.3.14
465
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
466
+ if (!Object.keys) {
467
+
468
+ var hasDontEnumBug = true,
469
+ dontEnums = [
470
+ "toString",
471
+ "toLocaleString",
472
+ "valueOf",
473
+ "hasOwnProperty",
474
+ "isPrototypeOf",
475
+ "propertyIsEnumerable",
476
+ "constructor"
477
+ ],
478
+ dontEnumsLength = dontEnums.length;
479
+
480
+ for (var key in {"toString": null})
481
+ hasDontEnumBug = false;
482
+
483
+ Object.keys = function keys(object) {
484
+
485
+ if ((typeof object != "object" && typeof object != "function") || object === null)
486
+ throw new TypeError("Object.keys called on a non-object");
487
+
488
+ var keys = [];
489
+ for (var name in object) {
490
+ if (owns(object, name)) {
491
+ keys.push(name);
492
+ }
493
+ }
494
+
495
+ if (hasDontEnumBug) {
496
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
497
+ var dontEnum = dontEnums[i];
498
+ if (owns(object, dontEnum)) {
499
+ keys.push(dontEnum);
500
+ }
501
+ }
502
+ }
503
+
504
+ return keys;
505
+ };
506
+
507
+ }
508
+
509
+ //
510
+ // Date
511
+ // ====
512
+ //
513
+
514
+ // ES5 15.9.5.43
515
+ // Format a Date object as a string according to a simplified subset of the ISO 8601
516
+ // standard as defined in 15.9.1.15.
517
+ if (!Date.prototype.toISOString) {
518
+ Date.prototype.toISOString = function toISOString() {
519
+ var result, length, value;
520
+ if (!isFinite(this))
521
+ throw new RangeError;
522
+
523
+ // the date time string format is specified in 15.9.1.15.
524
+ result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
525
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
526
+
527
+ length = result.length;
528
+ while (length--) {
529
+ value = result[length];
530
+ // pad months, days, hours, minutes, and seconds to have two digits.
531
+ if (value < 10)
532
+ result[length] = "0" + value;
533
+ }
534
+ // pad milliseconds to have three digits.
535
+ return result.slice(0, 3).join("-") + "T" + result.slice(3).join(":") + "." +
536
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
537
+ }
538
+ }
539
+
540
+ // ES5 15.9.4.4
541
+ if (!Date.now) {
542
+ Date.now = function now() {
543
+ return new Date().getTime();
544
+ };
545
+ }
546
+
547
+ // ES5 15.9.5.44
548
+ if (!Date.prototype.toJSON) {
549
+ Date.prototype.toJSON = function toJSON(key) {
550
+ // This function provides a String representation of a Date object for
551
+ // use by JSON.stringify (15.12.3). When the toJSON method is called
552
+ // with argument key, the following steps are taken:
553
+
554
+ // 1. Let O be the result of calling ToObject, giving it the this
555
+ // value as its argument.
556
+ // 2. Let tv be ToPrimitive(O, hint Number).
557
+ // 3. If tv is a Number and is not finite, return null.
558
+ // XXX
559
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
560
+ // O with argument "toISOString".
561
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
562
+ if (typeof this.toISOString != "function")
563
+ throw new TypeError(); // TODO message
564
+ // 6. Return the result of calling the [[Call]] internal method of
565
+ // toISO with O as the this value and an empty argument list.
566
+ return this.toISOString();
567
+
568
+ // NOTE 1 The argument is ignored.
569
+
570
+ // NOTE 2 The toJSON function is intentionally generic; it does not
571
+ // require that its this value be a Date object. Therefore, it can be
572
+ // transferred to other kinds of objects for use as a method. However,
573
+ // it does require that any such object have a toISOString method. An
574
+ // object is free to use the argument key to filter its
575
+ // stringification.
576
+ };
577
+ }
578
+
579
+
580
+ //
581
+ // String
582
+ // ======
583
+ //
584
+
585
+ // ES5 15.5.4.20
586
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
587
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
588
+ "\u2029\uFEFF";
589
+ if (!String.prototype.trim || ws.trim()) {
590
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
591
+ // http://perfectionkills.com/whitespace-deviations/
592
+ ws = "[" + ws + "]";
593
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
594
+ trimEndRegexp = new RegExp(ws + ws + "*$");
595
+ String.prototype.trim = function trim() {
596
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
597
+ };
598
+ }
599
+
600
+ // ES5 15.5.4.14
601
+ // http://es5.github.com/#x15.5.4.14
602
+ // [bugfix, chrome]
603
+ // If separator is undefined, then the result array contains just one String, which is the this value (converted to a String). If limit is not undefined, then the output array is truncated so that it contains no more than limit elements.
604
+ // "0".split(undefined, 0) -> []
605
+ if("0".split(void 0, 0).length) {
606
+ var oldSplit = String.prototype.split;
607
+ String.prototype.split = function(separator, limit) {
608
+ if(separator === void 0 && limit === 0)return [];
609
+ return oldSplit.apply(this, arguments);
610
+ }
611
+ }
612
+
613
+ // ECMA-262, 3rd B.2.3
614
+ // Note an ECMAScript standart, although ECMAScript 3rd Edition has a non-normative section suggesting uniform semantics
615
+ // and it should be normalized across all browsers
616
+ // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
617
+ if("".substr && "0b".substr(-1) !== "b") {
618
+ var oldSubstr = String.prototype.substr;
619
+ /**
620
+ * Get the substring of a string
621
+ * @param {integer} start where to start the substring
622
+ * @param {integer} length how many characters to return
623
+ * @return {string}
624
+ */
625
+ String.prototype.substr = function(start, length) {
626
+ return oldSubstr.call(this, start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, length);
627
+ }
628
+ }
629
+
630
+ //
631
+ // Util
632
+ // ======
633
+ //
634
+
635
+ // http://jsperf.com/to-integer
636
+ var toInteger = function (n) {
637
+ n = +n;
638
+ if (n !== n) // isNaN
639
+ n = -1;
640
+ else if (n !== 0 && n !== (1/0) && n !== -(1/0))
641
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
642
+ return n;
643
+ };
644
+
645
+ var prepareString = "a"[0] != "a",
646
+ // ES5 9.9
647
+ toObject = function (o) {
648
+ if (o == null) { // this matches both null and undefined
649
+ throw new TypeError(); // TODO message
650
+ }
651
+ // If the implementation doesn't support by-index access of
652
+ // string characters (ex. IE < 7), split the string
653
+ if (prepareString && typeof o == "string" && o) {
654
+ return o.split("");
655
+ }
656
+ return Object(o);
657
+ };
658
+
659
+ })();
660
+
661
+
662
+
663
+ (function($, shims){
664
+ var defineProperty = 'defineProperty';
665
+ var advancedObjectProperties = !!(Object.create && Object.defineProperties && Object.getOwnPropertyDescriptor);
666
+ //safari5 has defineProperty-interface, but it can't be used on dom-object
667
+ //only do this test in non-IE browsers, because this hurts dhtml-behavior in some IE8 versions
668
+ if (advancedObjectProperties && !$.browser.msie && Object[defineProperty] && Object.prototype.__defineGetter__) {
669
+ (function(){
670
+ try {
671
+ var foo = document.createElement('foo');
672
+ Object[defineProperty](foo, 'bar', {
673
+ get: function(){
674
+ return true;
675
+ }
676
+ });
677
+ advancedObjectProperties = !!foo.bar;
678
+ }
679
+ catch (e) {
680
+ advancedObjectProperties = false;
681
+ }
682
+ foo = null;
683
+ })();
684
+ }
685
+
686
+ Modernizr.objectAccessor = !!((advancedObjectProperties || (Object.prototype.__defineGetter__ && Object.prototype.__lookupSetter__)) && (!$.browser.opera || shims.browserVersion >= 11));
687
+ Modernizr.advancedObjectProperties = advancedObjectProperties;
688
+
689
+ if((!advancedObjectProperties || !Object.create || !Object.defineProperties || !Object.getOwnPropertyDescriptor || !Object.defineProperty)){
690
+ var call = Function.prototype.call;
691
+ var prototypeOfObject = Object.prototype;
692
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
693
+
694
+ shims.objectCreate = function(proto, props, opts, no__proto__){
695
+ var o;
696
+ var f = function(){};
697
+
698
+ f.prototype = proto;
699
+ o = new f();
700
+
701
+ if(!no__proto__ && !('__proto__' in o) && !Modernizr.objectAccessor){
702
+ o.__proto__ = proto;
703
+ }
704
+
705
+ if(props){
706
+ shims.defineProperties(o, props);
707
+ }
708
+
709
+ if(opts){
710
+ o.options = jQuery.extend(true, {}, o.options || {}, opts);
711
+ opts = o.options;
712
+ }
713
+
714
+ if(o._create && jQuery.isFunction(o._create)){
715
+ o._create(opts);
716
+ }
717
+ return o;
718
+ };
719
+
720
+ shims.defineProperties = function(object, props){
721
+ for (var name in props) {
722
+ if (owns(props, name)) {
723
+ shims.defineProperty(object, name, props[name]);
724
+ }
725
+ }
726
+ return object;
727
+ };
728
+
729
+ var descProps = ['configurable', 'enumerable', 'writable'];
730
+ shims.defineProperty = function(proto, property, descriptor){
731
+ if(typeof descriptor != "object" || descriptor === null){return proto;}
732
+
733
+ if(owns(descriptor, "value")){
734
+ proto[property] = descriptor.value;
735
+ return proto;
736
+ }
737
+
738
+ if(proto.__defineGetter__){
739
+ if (typeof descriptor.get == "function") {
740
+ proto.__defineGetter__(property, descriptor.get);
741
+ }
742
+ if (typeof descriptor.set == "function"){
743
+ proto.__defineSetter__(property, descriptor.set);
744
+ }
745
+ }
746
+ return proto;
747
+ };
748
+
749
+ shims.getPrototypeOf = function (object) {
750
+ return Object.getPrototypeOf && Object.getPrototypeOf(object) || object.__proto__ || object.constructor && object.constructor.prototype;
751
+ };
752
+
753
+ //based on http://www.refactory.org/s/object_getownpropertydescriptor/view/latest
754
+ shims.getOwnPropertyDescriptor = function(obj, prop){
755
+ if (typeof obj !== "object" && typeof obj !== "function" || obj === null){
756
+ throw new TypeError("Object.getOwnPropertyDescriptor called on a non-object");
757
+ }
758
+ var descriptor;
759
+ if(Object.defineProperty && Object.getOwnPropertyDescriptor){
760
+ try{
761
+ descriptor = Object.getOwnPropertyDescriptor(obj, prop);
762
+ return descriptor;
763
+ } catch(e){}
764
+ }
765
+ descriptor = {
766
+ configurable: true,
767
+ enumerable: true,
768
+ writable: true,
769
+ value: undefined
770
+ };
771
+ var getter = obj.__lookupGetter__ && obj.__lookupGetter__(prop),
772
+ setter = obj.__lookupSetter__ && obj.__lookupSetter__(prop)
773
+ ;
774
+
775
+ if (!getter && !setter) { // not an accessor so return prop
776
+ if(!owns(obj, prop)){
777
+ return;
778
+ }
779
+ descriptor.value = obj[prop];
780
+ return descriptor;
781
+ }
782
+
783
+ // there is an accessor, remove descriptor.writable; populate descriptor.get and descriptor.set
784
+ delete descriptor.writable;
785
+ delete descriptor.value;
786
+ descriptor.get = descriptor.set = undefined;
787
+
788
+ if(getter){
789
+ descriptor.get = getter;
790
+ }
791
+
792
+ if(setter){
793
+ descriptor.set = setter;
794
+ }
795
+
796
+ return descriptor;
797
+ };
798
+
799
+ }
800
+ })(jQuery, jQuery.webshims);
801
+
802
+
803
+ //DOM-Extension helper
804
+ jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
805
+ "use strict";
806
+ //shortcus
807
+ var modules = webshims.modules;
808
+ var listReg = /\s*,\s*/;
809
+
810
+ //proxying attribute
811
+ var olds = {};
812
+ var havePolyfill = {};
813
+ var extendedProps = {};
814
+ var extendQ = {};
815
+ var modifyProps = {};
816
+
817
+ var oldVal = $.fn.val;
818
+ var singleVal = function(elem, name, val, pass, _argless){
819
+ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
820
+ };
821
+ $.fn.val = function(val){
822
+ var elem = this[0];
823
+ if(arguments.length && val == null){
824
+ val = '';
825
+ }
826
+ if(!arguments.length){
827
+ if(!elem || elem.nodeType !== 1){return oldVal.call(this);}
828
+ return $.prop(elem, 'value', val, 'val', true);
829
+ }
830
+ if($.isArray(val)){
831
+ return oldVal.apply(this, arguments);
832
+ }
833
+ var isFunction = $.isFunction(val);
834
+ return this.each(function(i){
835
+ elem = this;
836
+ if(elem.nodeType === 1){
837
+ if(isFunction){
838
+ var genVal = val.call( elem, i, $.prop(elem, 'value', undefined, 'val', true));
839
+ if(genVal == null){
840
+ genVal = '';
841
+ }
842
+ $.prop(elem, 'value', genVal, 'val') ;
843
+ } else {
844
+ $.prop(elem, 'value', val, 'val');
845
+ }
846
+ }
847
+ });
848
+ };
849
+
850
+ var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
851
+ var elementData = function(elem, key, val){
852
+ elem = elem.jquery ? elem[0] : elem;
853
+ if(!elem){return val || {};}
854
+ var data = $.data(elem, dataID);
855
+ if(val !== undefined){
856
+ if(!data){
857
+ data = $.data(elem, dataID, {});
858
+ }
859
+ if(key){
860
+ data[key] = val;
861
+ }
862
+ }
863
+
864
+ return key ? data && data[key] : data;
865
+ };
866
+
867
+
868
+ [{name: 'getNativeElement', prop: 'nativeElement'}, {name: 'getShadowElement', prop: 'shadowElement'}, {name: 'getShadowFocusElement', prop: 'shadowFocusElement'}].forEach(function(data){
869
+ $.fn[data.name] = function(){
870
+ return this.map(function(){
871
+ var shadowData = elementData(this, 'shadowData');
872
+ return shadowData && shadowData[data.prop] || this;
873
+ });
874
+ };
875
+ });
876
+
877
+
878
+ ['removeAttr', 'prop', 'attr'].forEach(function(type){
879
+ olds[type] = $[type];
880
+ $[type] = function(elem, name, value, pass, _argless){
881
+ var isVal = (pass == 'val');
882
+ var oldMethod = !isVal ? olds[type] : singleVal;
883
+ if( !elem || !havePolyfill[name] || elem.nodeType !== 1 || (!isVal && pass && type == 'attr' && $.attrFn[name]) ){
884
+ return oldMethod(elem, name, value, pass, _argless);
885
+ }
886
+
887
+ var nodeName = (elem.nodeName || '').toLowerCase();
888
+ var desc = extendedProps[nodeName];
889
+ var curType = (type == 'attr' && (value === false || value === null)) ? 'removeAttr' : type;
890
+ var propMethod;
891
+ var oldValMethod;
892
+ var ret;
893
+
894
+
895
+ if(!desc){
896
+ desc = extendedProps['*'];
897
+ }
898
+ if(desc){
899
+ desc = desc[name];
900
+ }
901
+
902
+ if(desc){
903
+ propMethod = desc[curType];
904
+ }
905
+
906
+ if(propMethod){
907
+ if(name == 'value'){
908
+ oldValMethod = propMethod.isVal;
909
+ propMethod.isVal = isVal;
910
+ }
911
+ if(curType === 'removeAttr'){
912
+ return propMethod.value.call(elem);
913
+ } else if(value === undefined){
914
+ return (propMethod.get) ?
915
+ propMethod.get.call(elem) :
916
+ propMethod.value
917
+ ;
918
+ } else if(propMethod.set) {
919
+ if(type == 'attr' && value === true){
920
+ value = name;
921
+ }
922
+
923
+ ret = propMethod.set.call(elem, value);
924
+ }
925
+ if(name == 'value'){
926
+ propMethod.isVal = oldValMethod;
927
+ }
928
+ } else {
929
+ ret = oldMethod(elem, name, value, pass, _argless);
930
+ }
931
+ if((value !== undefined || curType === 'removeAttr') && modifyProps[nodeName] && modifyProps[nodeName][name]){
932
+
933
+ var boolValue;
934
+ if(curType == 'removeAttr'){
935
+ boolValue = false;
936
+ } else if(curType == 'prop'){
937
+ boolValue = !!(value);
938
+ } else {
939
+ boolValue = true;
940
+ }
941
+
942
+ modifyProps[nodeName][name].forEach(function(fn){
943
+ if(!fn.only || (fn.only = 'prop' && type == 'prop') || (fn.only == 'attr' && type != 'prop')){
944
+ fn.call(elem, value, boolValue, (isVal) ? 'val' : curType, type);
945
+ }
946
+ });
947
+ }
948
+ return ret;
949
+ };
950
+
951
+ extendQ[type] = function(nodeName, prop, desc){
952
+
953
+ if(!extendedProps[nodeName]){
954
+ extendedProps[nodeName] = {};
955
+ }
956
+ if(!extendedProps[nodeName][prop]){
957
+ extendedProps[nodeName][prop] = {};
958
+ }
959
+ var oldDesc = extendedProps[nodeName][prop][type];
960
+ var getSup = function(propType, descriptor, oDesc){
961
+ if(descriptor && descriptor[propType]){
962
+ return descriptor[propType];
963
+ }
964
+ if(oDesc && oDesc[propType]){
965
+ return oDesc[propType];
966
+ }
967
+ if(type == 'prop' && prop == 'value'){
968
+ return function(value){
969
+ var elem = this;
970
+ return (desc.isVal) ?
971
+ singleVal(elem, prop, value, false, (arguments.length === 0)) :
972
+ olds[type](elem, prop, value)
973
+ ;
974
+ };
975
+ }
976
+ if(type == 'prop' && propType == 'value' && desc.value.apply){
977
+ return function(value){
978
+ var sup = olds[type](this, prop);
979
+ if(sup && sup.apply){
980
+ sup = sup.apply(this, arguments);
981
+ }
982
+ return sup;
983
+ };
984
+ }
985
+ return function(value){
986
+ return olds[type](this, prop, value);
987
+ };
988
+ };
989
+ extendedProps[nodeName][prop][type] = desc;
990
+ if(desc.value === undefined){
991
+ if(!desc.set){
992
+ desc.set = desc.writeable ?
993
+ getSup('set', desc, oldDesc) :
994
+ (webshims.cfg.useStrict && prop == 'prop') ?
995
+ function(){throw(prop +' is readonly on '+ nodeName);} :
996
+ $.noop
997
+ ;
998
+ }
999
+ if(!desc.get){
1000
+ desc.get = getSup('get', desc, oldDesc);
1001
+ }
1002
+
1003
+ }
1004
+
1005
+ ['value', 'get', 'set'].forEach(function(descProp){
1006
+ if(desc[descProp]){
1007
+ desc['_sup'+descProp] = getSup(descProp, oldDesc);
1008
+ }
1009
+ });
1010
+ };
1011
+
1012
+ });
1013
+
1014
+ //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
1015
+ var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
1016
+ var extendNativeValue = (function(){
1017
+ var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
1018
+ var has = Object.prototype.hasOwnProperty;
1019
+ return function(nodeName, prop, desc){
1020
+ var elem = document.createElement(nodeName);
1021
+ var elemProto = webshims.getPrototypeOf(elem);
1022
+ if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
1023
+ var sup = elem[prop];
1024
+ desc._supvalue = function(){
1025
+ if(sup && sup.apply){
1026
+ return sup.apply(this, arguments);
1027
+ }
1028
+ return sup;
1029
+ };
1030
+ elemProto[prop] = desc.value;
1031
+ } else {
1032
+ desc._supvalue = function(){
1033
+ var data = elementData(this, 'propValue');
1034
+ if(data && data[prop] && data[prop].apply){
1035
+ return data[prop].apply(this, arguments);
1036
+ }
1037
+ return data && data[prop];
1038
+ };
1039
+ initProp.extendValue(nodeName, prop, desc.value);
1040
+ }
1041
+ desc.value._supvalue = desc._supvalue;
1042
+ };
1043
+ })();
1044
+
1045
+ var initProp = (function(){
1046
+
1047
+ var initProps = {};
1048
+
1049
+ webshims.addReady(function(context, contextElem){
1050
+ var nodeNameCache = {};
1051
+ var getElementsByName = function(name){
1052
+ if(!nodeNameCache[name]){
1053
+ nodeNameCache[name] = $(context.getElementsByTagName(name));
1054
+ if(contextElem[0] && $.nodeName(contextElem[0], name)){
1055
+ nodeNameCache[name] = nodeNameCache[name].add(contextElem);
1056
+ }
1057
+ }
1058
+ };
1059
+
1060
+
1061
+ $.each(initProps, function(name, fns){
1062
+ getElementsByName(name);
1063
+ if(!fns || !fns.forEach){
1064
+ webshims.warn('Error: with '+ name +'-property. methods: '+ fns);
1065
+ return;
1066
+ }
1067
+ fns.forEach(function(fn){
1068
+ nodeNameCache[name].each(fn);
1069
+ });
1070
+ });
1071
+ nodeNameCache = null;
1072
+ });
1073
+
1074
+ var tempCache;
1075
+ var emptyQ = $([]);
1076
+ var createNodeNameInit = function(nodeName, fn){
1077
+ if(!initProps[nodeName]){
1078
+ initProps[nodeName] = [fn];
1079
+ } else {
1080
+ initProps[nodeName].push(fn);
1081
+ }
1082
+ if($.isDOMReady){
1083
+ (tempCache || $( document.getElementsByTagName(nodeName) )).each(fn);
1084
+ }
1085
+ };
1086
+
1087
+ var elementExtends = {};
1088
+ return {
1089
+ createTmpCache: function(nodeName){
1090
+ if($.isDOMReady){
1091
+ tempCache = tempCache || $( document.getElementsByTagName(nodeName) );
1092
+ }
1093
+ return tempCache || emptyQ;
1094
+ },
1095
+ flushTmpCache: function(){
1096
+ tempCache = null;
1097
+ },
1098
+ content: function(nodeName, prop){
1099
+ createNodeNameInit(nodeName, function(){
1100
+ var val = $.attr(this, prop);
1101
+ if(val != null){
1102
+ $.attr(this, prop, val);
1103
+ }
1104
+ });
1105
+ },
1106
+ createElement: function(nodeName, fn){
1107
+ createNodeNameInit(nodeName, fn);
1108
+ },
1109
+ extendValue: function(nodeName, prop, value){
1110
+ createNodeNameInit(nodeName, function(){
1111
+ $(this).each(function(){
1112
+ var data = elementData(this, 'propValue', {});
1113
+ data[prop] = this[prop];
1114
+ this[prop] = value;
1115
+ });
1116
+ });
1117
+ }
1118
+ };
1119
+ })();
1120
+
1121
+ var createPropDefault = function(descs, removeType){
1122
+ if(descs.defaultValue === undefined){
1123
+ descs.defaultValue = '';
1124
+ }
1125
+ if(!descs.removeAttr){
1126
+ descs.removeAttr = {
1127
+ value: function(){
1128
+ descs[removeType || 'prop'].set.call(this, descs.defaultValue);
1129
+ descs.removeAttr._supvalue.call(this);
1130
+ }
1131
+ };
1132
+ }
1133
+ if(!descs.attr){
1134
+ descs.attr = {};
1135
+ }
1136
+ };
1137
+
1138
+ $.extend(webshims, {
1139
+
1140
+ getID: (function(){
1141
+ var ID = new Date().getTime();
1142
+ return function(elem){
1143
+ elem = $(elem);
1144
+ var id = elem.attr('id');
1145
+ if(!id){
1146
+ ID++;
1147
+ id = 'ID-'+ ID;
1148
+ elem.attr('id', id);
1149
+ }
1150
+ return id;
1151
+ };
1152
+ })(),
1153
+ extendUNDEFProp: function(obj, props){
1154
+ $.each(props, function(name, prop){
1155
+ if( !(name in obj) ){
1156
+ obj[name] = prop;
1157
+ }
1158
+ });
1159
+ },
1160
+ //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect
1161
+ createPropDefault: createPropDefault,
1162
+ data: elementData,
1163
+ moveToFirstEvent: (function(){
1164
+ var getData = $._data ? '_data' : 'data';
1165
+ return function(elem, eventType, bindType){
1166
+ var events = ($[getData](elem, 'events') || {})[eventType];
1167
+ var fn;
1168
+
1169
+ if(events && events.length > 1){
1170
+ fn = events.pop();
1171
+ if(!bindType){
1172
+ bindType = 'bind';
1173
+ }
1174
+ if(bindType == 'bind' && events.delegateCount){
1175
+ events.splice( events.delegateCount, 0, fn);
1176
+ } else {
1177
+ events.unshift( fn );
1178
+ }
1179
+
1180
+
1181
+ }
1182
+ elem = null;
1183
+ };
1184
+ })(),
1185
+ addShadowDom: (function(){
1186
+ var resizeTimer;
1187
+ var lastHeight;
1188
+ var lastWidth;
1189
+ var handler;
1190
+ var docObserve = {
1191
+ init: false,
1192
+ start: function(){
1193
+ if(!this.init){
1194
+ this.init = true;
1195
+ this.height = $(document).height();
1196
+ this.width = $(document).width();
1197
+ setInterval(function(){
1198
+ var height = $(document).height();
1199
+ var width = $(document).width();
1200
+ if(height != docObserve.height || width != docObserve.width){
1201
+ docObserve.height = height;
1202
+ docObserve.width = width;
1203
+ handler({type: 'docresize'});
1204
+ }
1205
+ }, 400);
1206
+ }
1207
+ }
1208
+ };
1209
+
1210
+ handler = function(e){
1211
+ clearTimeout(resizeTimer);
1212
+ resizeTimer = setTimeout(function(){
1213
+ if(e.type == 'resize'){
1214
+ var width = $(window).width();
1215
+ var height = $(window).width();
1216
+ if(height == lastHeight && width == lastWidth){
1217
+ return;
1218
+ }
1219
+ lastHeight = height;
1220
+ lastWidth = width;
1221
+ docObserve.height = $(document).height();
1222
+ docObserve.width = $(document).width();
1223
+ }
1224
+ $.event.trigger('updateshadowdom');
1225
+ }, 40);
1226
+ };
1227
+ $(window).bind('resize', handler);
1228
+
1229
+ $.event.customEvent.updateshadowdom = true;
1230
+
1231
+ return function(nativeElem, shadowElem, opts){
1232
+ opts = opts || {};
1233
+ if(nativeElem.jquery){
1234
+ nativeElem = nativeElem[0];
1235
+ }
1236
+ if(shadowElem.jquery){
1237
+ shadowElem = shadowElem[0];
1238
+ }
1239
+ var nativeData = $.data(nativeElem, dataID) || $.data(nativeElem, dataID, {});
1240
+ var shadowData = $.data(shadowElem, dataID) || $.data(shadowElem, dataID, {});
1241
+ var shadowFocusElementData = {};
1242
+ if(!opts.shadowFocusElement){
1243
+ opts.shadowFocusElement = shadowElem;
1244
+ } else if(opts.shadowFocusElement){
1245
+ if(opts.shadowFocusElement.jquery){
1246
+ opts.shadowFocusElement = opts.shadowFocusElement[0];
1247
+ }
1248
+ shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1249
+ }
1250
+
1251
+ nativeData.hasShadow = shadowElem;
1252
+ shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1253
+ shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
1254
+ nativeElement: nativeElem,
1255
+ shadowElement: shadowElem,
1256
+ shadowFocusElement: opts.shadowFocusElement
1257
+ };
1258
+ if(opts.shadowChilds){
1259
+ opts.shadowChilds.each(function(){
1260
+ elementData(this, 'shadowData', shadowData.shadowData);
1261
+ });
1262
+ }
1263
+
1264
+ if(opts.data){
1265
+ shadowFocusElementData.shadowData.data = shadowData.shadowData.data = nativeData.shadowData.data = opts.data;
1266
+ }
1267
+ opts = null;
1268
+ docObserve.start();
1269
+ }
1270
+ })(),
1271
+ propTypes: {
1272
+ standard: function(descs, name){
1273
+ createPropDefault(descs);
1274
+ if(descs.prop){return;}
1275
+ descs.prop = {
1276
+ set: function(val){
1277
+ descs.attr.set.call(this, ''+val);
1278
+ },
1279
+ get: function(){
1280
+ return descs.attr.get.call(this) || descs.defaultValue;
1281
+ }
1282
+ };
1283
+
1284
+ },
1285
+ "boolean": function(descs, name){
1286
+
1287
+ createPropDefault(descs);
1288
+ if(descs.prop){return;}
1289
+ descs.prop = {
1290
+ set: function(val){
1291
+ if(val){
1292
+ descs.attr.set.call(this, "");
1293
+ } else {
1294
+ descs.removeAttr.value.call(this);
1295
+ }
1296
+ },
1297
+ get: function(){
1298
+ return descs.attr.get.call(this) != null;
1299
+ }
1300
+ };
1301
+ },
1302
+ "src": (function(){
1303
+ var anchor = document.createElement('a');
1304
+ anchor.style.display = "none";
1305
+ return function(descs, name){
1306
+
1307
+ createPropDefault(descs);
1308
+ if(descs.prop){return;}
1309
+ descs.prop = {
1310
+ set: function(val){
1311
+ descs.attr.set.call(this, val);
1312
+ },
1313
+ get: function(){
1314
+ var href = this.getAttribute(name);
1315
+ var ret;
1316
+ if(href == null){return '';}
1317
+
1318
+ anchor.setAttribute('href', href+'' );
1319
+
1320
+ if(!$.support.hrefNormalized){
1321
+ try {
1322
+ $(anchor).insertAfter(this);
1323
+ ret = anchor.getAttribute('href', 4);
1324
+ } catch(er){
1325
+ ret = anchor.getAttribute('href', 4);
1326
+ }
1327
+ $(anchor).detach();
1328
+ }
1329
+ return ret || anchor.href;
1330
+ }
1331
+ };
1332
+ };
1333
+ })(),
1334
+ enumarated: function(descs, name){
1335
+
1336
+ createPropDefault(descs);
1337
+ if(descs.prop){return;}
1338
+ descs.prop = {
1339
+ set: function(val){
1340
+ descs.attr.set.call(this, val);
1341
+ },
1342
+ get: function(){
1343
+ var val = (descs.attr.get.call(this) || '').toLowerCase();
1344
+ if(!val || descs.limitedTo.indexOf(val) == -1){
1345
+ val = descs.defaultValue;
1346
+ }
1347
+ return val;
1348
+ }
1349
+ };
1350
+ }
1351
+
1352
+ // ,unsignedLong: $.noop
1353
+ // ,"doubble": $.noop
1354
+ // ,"long": $.noop
1355
+ // ,tokenlist: $.noop
1356
+ // ,settableTokenlist: $.noop
1357
+ },
1358
+ reflectProperties: function(nodeNames, props){
1359
+ if(typeof props == 'string'){
1360
+ props = props.split(listReg);
1361
+ }
1362
+ props.forEach(function(prop){
1363
+ webshims.defineNodeNamesProperty(nodeNames, prop, {
1364
+ prop: {
1365
+ set: function(val){
1366
+ $.attr(this, prop, val);
1367
+ },
1368
+ get: function(){
1369
+ return $.attr(this, prop) || '';
1370
+ }
1371
+ }
1372
+ });
1373
+ });
1374
+ },
1375
+ defineNodeNameProperty: function(nodeName, prop, descs){
1376
+ havePolyfill[prop] = true;
1377
+
1378
+ if(descs.reflect){
1379
+ webshims.propTypes[descs.propType || 'standard'](descs, prop);
1380
+ }
1381
+
1382
+ ['prop', 'attr', 'removeAttr'].forEach(function(type){
1383
+ var desc = descs[type];
1384
+ if(desc){
1385
+ if(type === 'prop'){
1386
+ desc = $.extend({writeable: true}, desc);
1387
+ } else {
1388
+ desc = $.extend({}, desc, {writeable: true});
1389
+ }
1390
+
1391
+ extendQ[type](nodeName, prop, desc);
1392
+ if(nodeName != '*' && webshims.cfg.extendNative && type == 'prop' && desc.value && $.isFunction(desc.value)){
1393
+ extendNativeValue(nodeName, prop, desc);
1394
+ }
1395
+ descs[type] = desc;
1396
+ }
1397
+ });
1398
+ if(descs.initAttr){
1399
+ initProp.content(nodeName, prop);
1400
+ }
1401
+ return descs;
1402
+ },
1403
+
1404
+ defineNodeNameProperties: function(name, descs, propType, _noTmpCache){
1405
+ var olddesc;
1406
+ for(var prop in descs){
1407
+ if(!_noTmpCache && descs[prop].initAttr){
1408
+ initProp.createTmpCache(name);
1409
+ }
1410
+ if(propType){
1411
+ if(descs[prop][propType]){
1412
+ webshims.log('override: '+ name +'['+prop +'] for '+ propType);
1413
+ } else {
1414
+ descs[prop][propType] = {};
1415
+ ['value', 'set', 'get'].forEach(function(copyProp){
1416
+ if(copyProp in descs[prop]){
1417
+ descs[prop][propType][copyProp] = descs[prop][copyProp];
1418
+ delete descs[prop][copyProp];
1419
+ }
1420
+ });
1421
+ }
1422
+ }
1423
+ descs[prop] = webshims.defineNodeNameProperty(name, prop, descs[prop]);
1424
+ }
1425
+ if(!_noTmpCache){
1426
+ initProp.flushTmpCache();
1427
+ }
1428
+ return descs;
1429
+ },
1430
+
1431
+ createElement: function(nodeName, create, descs){
1432
+ var ret;
1433
+ if($.isFunction(create)){
1434
+ create = {
1435
+ after: create
1436
+ };
1437
+ }
1438
+ initProp.createTmpCache(nodeName);
1439
+ if(create.before){
1440
+ initProp.createElement(nodeName, create.before);
1441
+ }
1442
+ if(descs){
1443
+ ret = webshims.defineNodeNameProperties(nodeName, descs, false, true);
1444
+ }
1445
+ if(create.after){
1446
+ initProp.createElement(nodeName, create.after);
1447
+ }
1448
+ initProp.flushTmpCache();
1449
+ return ret;
1450
+ },
1451
+ onNodeNamesPropertyModify: function(nodeNames, props, desc, only){
1452
+ if(typeof nodeNames == 'string'){
1453
+ nodeNames = nodeNames.split(listReg);
1454
+ }
1455
+ if($.isFunction(desc)){
1456
+ desc = {set: desc};
1457
+ }
1458
+
1459
+ nodeNames.forEach(function(name){
1460
+ if(!modifyProps[name]){
1461
+ modifyProps[name] = {};
1462
+ }
1463
+ if(typeof props == 'string'){
1464
+ props = props.split(listReg);
1465
+ }
1466
+ if(desc.initAttr){
1467
+ initProp.createTmpCache(name);
1468
+ }
1469
+ props.forEach(function(prop){
1470
+ if(!modifyProps[name][prop]){
1471
+ modifyProps[name][prop] = [];
1472
+ havePolyfill[prop] = true;
1473
+ }
1474
+ if(desc.set){
1475
+ if(only){
1476
+ desc.set.only = only;
1477
+ }
1478
+ modifyProps[name][prop].push(desc.set);
1479
+ }
1480
+
1481
+ if(desc.initAttr){
1482
+ initProp.content(name, prop);
1483
+ }
1484
+ });
1485
+ initProp.flushTmpCache();
1486
+
1487
+ });
1488
+ },
1489
+ defineNodeNamesBooleanProperty: function(elementNames, prop, descs){
1490
+ if(!descs){
1491
+ descs = {};
1492
+ }
1493
+ if($.isFunction(descs)){
1494
+ descs.set = descs;
1495
+ }
1496
+ webshims.defineNodeNamesProperty(elementNames, prop, {
1497
+ attr: {
1498
+ set: function(val){
1499
+ this.setAttribute(prop, val);
1500
+ if(descs.set){
1501
+ descs.set.call(this, true);
1502
+ }
1503
+ },
1504
+ get: function(){
1505
+ var ret = this.getAttribute(prop);
1506
+ return (ret == null) ? undefined : prop;
1507
+ }
1508
+ },
1509
+ removeAttr: {
1510
+ value: function(){
1511
+ this.removeAttribute(prop);
1512
+ if(descs.set){
1513
+ descs.set.call(this, false);
1514
+ }
1515
+ }
1516
+ },
1517
+ reflect: true,
1518
+ propType: 'boolean',
1519
+ initAttr: descs.initAttr || false
1520
+ });
1521
+ },
1522
+ contentAttr: function(elem, name, val){
1523
+ if(!elem.nodeName){return;}
1524
+ var attr;
1525
+ if(val === undefined){
1526
+ attr = (elem.attributes[name] || {});
1527
+ val = attr.specified ? attr.value : null;
1528
+ return (val == null) ? undefined : val;
1529
+ }
1530
+
1531
+ if(typeof val == 'boolean'){
1532
+ if(!val){
1533
+ elem.removeAttribute(name);
1534
+ } else {
1535
+ elem.setAttribute(name, name);
1536
+ }
1537
+ } else {
1538
+ elem.setAttribute(name, val);
1539
+ }
1540
+ },
1541
+
1542
+ // set current Lang:
1543
+ // - webshims.activeLang(lang:string);
1544
+ // get current lang
1545
+ // - webshims.activeLang();
1546
+ // get current lang
1547
+ // webshims.activeLang({
1548
+ // register: moduleName:string,
1549
+ // callback: callback:function
1550
+ // });
1551
+ // get/set including removeLang
1552
+ // - webshims.activeLang({
1553
+ // module: moduleName:string,
1554
+ // callback: callback:function,
1555
+ // langObj: languageObj:array/object
1556
+ // });
1557
+ activeLang: (function(){
1558
+ var callbacks = [];
1559
+ var registeredCallbacks = {};
1560
+ var currentLang;
1561
+ var shortLang;
1562
+ var notLocal = /:\/\/|^\.*\//;
1563
+ var loadRemoteLang = function(data, lang, options){
1564
+ var langSrc;
1565
+ if(lang && options && $.inArray(lang, options.availabeLangs || []) !== -1){
1566
+ data.loading = true;
1567
+ langSrc = options.langSrc;
1568
+ if(!notLocal.test(langSrc)){
1569
+ langSrc = webshims.cfg.basePath+langSrc;
1570
+ }
1571
+ webshims.loader.loadScript(langSrc+lang+'.js', function(){
1572
+ if(data.langObj[lang]){
1573
+ data.loading = false;
1574
+ callLang(data, true);
1575
+ } else {
1576
+ $(function(){
1577
+ if(data.langObj[lang]){
1578
+ callLang(data, true);
1579
+ }
1580
+ data.loading = false;
1581
+ });
1582
+ }
1583
+ });
1584
+ return true;
1585
+ }
1586
+ return false;
1587
+ };
1588
+ var callRegister = function(module){
1589
+ if(registeredCallbacks[module]){
1590
+ registeredCallbacks[module].forEach(function(data){
1591
+ data.callback();
1592
+ });
1593
+ }
1594
+ };
1595
+ var callLang = function(data, _noLoop){
1596
+ if(data.activeLang != currentLang && data.activeLang !== shortLang){
1597
+ var options = modules[data.module].options;
1598
+ if( data.langObj[currentLang] || (shortLang && data.langObj[shortLang]) ){
1599
+ data.activeLang = currentLang;
1600
+ data.callback(data.langObj[currentLang] || data.langObj[shortLang], currentLang);
1601
+ callRegister(data.module);
1602
+ } else if( !_noLoop &&
1603
+ !loadRemoteLang(data, currentLang, options) &&
1604
+ !loadRemoteLang(data, shortLang, options) &&
1605
+ data.langObj[''] && data.activeLang !== '' ) {
1606
+ data.activeLang = '';
1607
+ data.callback(data.langObj[''], currentLang);
1608
+ callRegister(data.module);
1609
+ }
1610
+ }
1611
+ };
1612
+
1613
+
1614
+ var activeLang = function(lang){
1615
+
1616
+ if(typeof lang == 'string' && lang !== currentLang){
1617
+ currentLang = lang;
1618
+ shortLang = currentLang.split('-')[0];
1619
+ if(currentLang == shortLang){
1620
+ shortLang = false;
1621
+ }
1622
+ $.each(callbacks, function(i, data){
1623
+ callLang(data);
1624
+ });
1625
+ } else if(typeof lang == 'object'){
1626
+
1627
+ if(lang.register){
1628
+ if(!registeredCallbacks[lang.register]){
1629
+ registeredCallbacks[lang.register] = [];
1630
+ }
1631
+ registeredCallbacks[lang.register].push(lang);
1632
+ lang.callback();
1633
+ } else {
1634
+ if(!lang.activeLang){
1635
+ lang.activeLang = '';
1636
+ }
1637
+ callbacks.push(lang);
1638
+ callLang(lang);
1639
+ }
1640
+ }
1641
+ return currentLang;
1642
+ };
1643
+
1644
+ return activeLang;
1645
+ })()
1646
+ });
1647
+
1648
+ $.each({
1649
+ defineNodeNamesProperty: 'defineNodeNameProperty',
1650
+ defineNodeNamesProperties: 'defineNodeNameProperties',
1651
+ createElements: 'createElement'
1652
+ }, function(name, baseMethod){
1653
+ webshims[name] = function(names, a, b, c){
1654
+ if(typeof names == 'string'){
1655
+ names = names.split(listReg);
1656
+ }
1657
+ var retDesc = {};
1658
+ names.forEach(function(nodeName){
1659
+ retDesc[nodeName] = webshims[baseMethod](nodeName, a, b, c);
1660
+ });
1661
+ return retDesc;
1662
+ };
1663
+ });
1664
+
1665
+ webshims.isReady('webshimLocalization', true);
1666
+ });
1667
+ //html5a11y
1668
+ (function($, document){
1669
+ var browserVersion = $.webshims.browserVersion;
1670
+ if($.browser.mozilla && browserVersion > 5){return;}
1671
+ if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
1672
+ var elemMappings = {
1673
+ article: "article",
1674
+ aside: "complementary",
1675
+ section: "region",
1676
+ nav: "navigation",
1677
+ address: "contentinfo"
1678
+ };
1679
+ var addRole = function(elem, role){
1680
+ var hasRole = elem.getAttribute('role');
1681
+ if (!hasRole) {
1682
+ elem.setAttribute('role', role);
1683
+ }
1684
+ };
1685
+
1686
+ $.webshims.addReady(function(context, contextElem){
1687
+ $.each(elemMappings, function(name, role){
1688
+ var elems = $(name, context).add(contextElem.filter(name));
1689
+ for (var i = 0, len = elems.length; i < len; i++) {
1690
+ addRole(elems[i], role);
1691
+ }
1692
+ });
1693
+ if (context === document) {
1694
+ var header = document.getElementsByTagName('header')[0];
1695
+ var footers = document.getElementsByTagName('footer');
1696
+ var footerLen = footers.length;
1697
+ if (header && !$(header).closest('section, article')[0]) {
1698
+ addRole(header, 'banner');
1699
+ }
1700
+ if (!footerLen) {
1701
+ return;
1702
+ }
1703
+ var footer = footers[footerLen - 1];
1704
+ if (!$(footer).closest('section, article')[0]) {
1705
+ addRole(footer, 'contentinfo');
1706
+ }
1707
+ }
1708
+ });
1709
+ }
1710
+ })(jQuery, document);