lady_josephine 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/fonts/lady_josephine/icons/icons.eot +0 -0
  5. data/app/assets/fonts/lady_josephine/icons/icons.svg +215 -0
  6. data/app/assets/fonts/lady_josephine/icons/icons.ttf +0 -0
  7. data/app/assets/fonts/lady_josephine/icons/icons.woff +0 -0
  8. data/app/assets/javascripts/lady_josephine/blocks/facebook.js +25 -0
  9. data/app/assets/javascripts/lady_josephine/blocks/instagram.js +22 -0
  10. data/app/assets/javascripts/lady_josephine/blocks/soundcloud.js +24 -0
  11. data/app/assets/javascripts/lady_josephine/blocks/twitter.js +25 -0
  12. data/app/assets/javascripts/lady_josephine/blocks/vimeo.js +55 -0
  13. data/app/assets/javascripts/lady_josephine/blocks/youtube.js +64 -0
  14. data/app/assets/javascripts/lady_josephine/editor.js +40 -0
  15. data/app/assets/javascripts/lady_josephine/lady_josephine.js +4 -0
  16. data/app/assets/javascripts/lady_josephine/lady_josephine_view.js +6 -0
  17. data/app/assets/stylesheets/lady_josephine/content.sass +33 -0
  18. data/app/assets/stylesheets/lady_josephine/icons.sass +175 -0
  19. data/app/assets/stylesheets/lady_josephine/lady_josephine.sass +6 -0
  20. data/app/assets/stylesheets/lady_josephine/sir_trevor.sass +619 -0
  21. data/app/assets/stylesheets/lady_josephine/vars.sass +36 -0
  22. data/app/controllers/lady_josephine/application_controller.rb +4 -0
  23. data/app/controllers/lady_josephine/editor_controller.rb +40 -0
  24. data/app/controllers/lady_josephine/images_controller.rb +26 -0
  25. data/app/helpers/lady_josephine/helper.rb +25 -0
  26. data/app/helpers/lady_josephine/sir_trevor_helper.rb +172 -0
  27. data/app/models/lady_josephine/concerns/model.rb +29 -0
  28. data/app/models/lady_josephine/concerns/pingable.rb +28 -0
  29. data/app/models/lady_josephine/concerns/server_uuid.rb +24 -0
  30. data/app/models/lady_josephine/concerns/sir_trevor_images.rb +38 -0
  31. data/app/models/lady_josephine/image.rb +41 -0
  32. data/app/uploader/lady_josephine/base_uploader.rb +47 -0
  33. data/app/uploader/lady_josephine/image_uploader.rb +149 -0
  34. data/app/views/lady_josephine/blocks/_audio_block.haml +2 -0
  35. data/app/views/lady_josephine/blocks/_definition_block.haml +4 -0
  36. data/app/views/lady_josephine/blocks/_divider_block.haml +2 -0
  37. data/app/views/lady_josephine/blocks/_extended_image_block.haml +63 -0
  38. data/app/views/lady_josephine/blocks/_extended_quote_block.haml +5 -0
  39. data/app/views/lady_josephine/blocks/_extended_tweet_block.haml +2 -0
  40. data/app/views/lady_josephine/blocks/_facebook_post_block.haml +2 -0
  41. data/app/views/lady_josephine/blocks/_heading_block.haml +2 -0
  42. data/app/views/lady_josephine/blocks/_html_block.haml +1 -0
  43. data/app/views/lady_josephine/blocks/_instagram_block.haml +2 -0
  44. data/app/views/lady_josephine/blocks/_list_block.haml +3 -0
  45. data/app/views/lady_josephine/blocks/_quote_block.haml +5 -0
  46. data/app/views/lady_josephine/blocks/_text_block.html.haml +2 -0
  47. data/app/views/lady_josephine/blocks/_video_block.haml +9 -0
  48. data/config/routes.rb +9 -0
  49. data/db/migrate/20160222151500_lady_josephine_image.rb +18 -0
  50. data/lib/generators/lady_josephine_migration/USAGE +9 -0
  51. data/lib/generators/lady_josephine_migration/lady_josephine_migration_generator.rb +17 -0
  52. data/lib/generators/lady_josephine_migration/templates/migration.rb +9 -0
  53. data/lib/lady_josephine.rb +18 -0
  54. data/lib/lady_josephine/engine.rb +18 -0
  55. data/lib/lady_josephine/redcarpet/custom_markdown_formatter.rb +63 -0
  56. data/lib/lady_josephine/renderer/sir_trevor_renderer.rb +16 -0
  57. data/lib/lady_josephine/version.rb +3 -0
  58. data/lib/lady_josephine/whitelist.rb +26 -0
  59. data/lib/tasks/lady_josephine_tasks.rake +4 -0
  60. data/spec/controllers/lady_josephine/editor_controller_spec.rb +58 -0
  61. data/spec/dummy/README.rdoc +28 -0
  62. data/spec/dummy/Rakefile +6 -0
  63. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  64. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  65. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  66. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  67. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/spec/dummy/bin/bundle +3 -0
  69. data/spec/dummy/bin/rails +4 -0
  70. data/spec/dummy/bin/rake +4 -0
  71. data/spec/dummy/bin/setup +29 -0
  72. data/spec/dummy/config.ru +4 -0
  73. data/spec/dummy/config/application.rb +26 -0
  74. data/spec/dummy/config/boot.rb +5 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +41 -0
  78. data/spec/dummy/config/environments/production.rb +79 -0
  79. data/spec/dummy/config/environments/test.rb +42 -0
  80. data/spec/dummy/config/initializers/assets.rb +11 -0
  81. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  82. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  83. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  84. data/spec/dummy/config/initializers/inflections.rb +16 -0
  85. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  86. data/spec/dummy/config/initializers/session_store.rb +3 -0
  87. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  88. data/spec/dummy/config/locales/en.yml +23 -0
  89. data/spec/dummy/config/routes.rb +4 -0
  90. data/spec/dummy/config/secrets.yml +22 -0
  91. data/spec/dummy/db/development.sqlite3 +0 -0
  92. data/spec/dummy/db/schema.rb +16 -0
  93. data/spec/dummy/db/test.sqlite3 +0 -0
  94. data/spec/dummy/log/bla +0 -0
  95. data/spec/dummy/public/404.html +67 -0
  96. data/spec/dummy/public/422.html +67 -0
  97. data/spec/dummy/public/500.html +66 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/spec_helper.rb +17 -0
  100. data/vendor/assets/components/Eventable/README.md +12 -0
  101. data/vendor/assets/components/Eventable/bower.json +10 -0
  102. data/vendor/assets/components/Eventable/component.json +11 -0
  103. data/vendor/assets/components/Eventable/eventable.js +207 -0
  104. data/vendor/assets/components/Eventable/package.json +15 -0
  105. data/vendor/assets/components/jquery-autosize/bower.json +30 -0
  106. data/vendor/assets/components/jquery-autosize/demo.html +36 -0
  107. data/vendor/assets/components/jquery-autosize/jquery.autosize.js +273 -0
  108. data/vendor/assets/components/jquery-autosize/jquery.autosize.min.js +6 -0
  109. data/vendor/assets/components/jquery-autosize/package.json +32 -0
  110. data/vendor/assets/components/jquery-autosize/readme.md +216 -0
  111. data/vendor/assets/components/jquery/AUTHORS.txt +163 -0
  112. data/vendor/assets/components/jquery/CONTRIBUTING.md +216 -0
  113. data/vendor/assets/components/jquery/Gruntfile.js +496 -0
  114. data/vendor/assets/components/jquery/MIT-LICENSE.txt +21 -0
  115. data/vendor/assets/components/jquery/README.md +415 -0
  116. data/vendor/assets/components/jquery/build/release-notes.js +59 -0
  117. data/vendor/assets/components/jquery/build/release.js +246 -0
  118. data/vendor/assets/components/jquery/component.json +13 -0
  119. data/vendor/assets/components/jquery/composer.json +35 -0
  120. data/vendor/assets/components/jquery/jquery-migrate.js +496 -0
  121. data/vendor/assets/components/jquery/jquery-migrate.min.js +3 -0
  122. data/vendor/assets/components/jquery/jquery.js +9597 -0
  123. data/vendor/assets/components/jquery/jquery.min.js +5 -0
  124. data/vendor/assets/components/jquery/jquery.min.map +1 -0
  125. data/vendor/assets/components/jquery/package.json +39 -0
  126. data/vendor/assets/components/jquery/speed/benchmark.js +15 -0
  127. data/vendor/assets/components/jquery/speed/benchmarker.css +65 -0
  128. data/vendor/assets/components/jquery/speed/benchmarker.js +181 -0
  129. data/vendor/assets/components/jquery/speed/closest.html +39 -0
  130. data/vendor/assets/components/jquery/speed/css.html +82 -0
  131. data/vendor/assets/components/jquery/speed/event.html +58 -0
  132. data/vendor/assets/components/jquery/speed/filter.html +183 -0
  133. data/vendor/assets/components/jquery/speed/find.html +179 -0
  134. data/vendor/assets/components/jquery/speed/index.html +72 -0
  135. data/vendor/assets/components/jquery/speed/jquery-basis.js +6238 -0
  136. data/vendor/assets/components/jquery/speed/slice.vs.concat.html +47 -0
  137. data/vendor/assets/components/jquery/src/ajax.js +851 -0
  138. data/vendor/assets/components/jquery/src/ajax/jsonp.js +80 -0
  139. data/vendor/assets/components/jquery/src/ajax/script.js +86 -0
  140. data/vendor/assets/components/jquery/src/ajax/xhr.js +207 -0
  141. data/vendor/assets/components/jquery/src/attributes.js +661 -0
  142. data/vendor/assets/components/jquery/src/callbacks.js +196 -0
  143. data/vendor/assets/components/jquery/src/core.js +949 -0
  144. data/vendor/assets/components/jquery/src/css.js +679 -0
  145. data/vendor/assets/components/jquery/src/data.js +340 -0
  146. data/vendor/assets/components/jquery/src/deferred.js +141 -0
  147. data/vendor/assets/components/jquery/src/deprecated.js +4 -0
  148. data/vendor/assets/components/jquery/src/dimensions.js +41 -0
  149. data/vendor/assets/components/jquery/src/effects.js +730 -0
  150. data/vendor/assets/components/jquery/src/event-alias.js +15 -0
  151. data/vendor/assets/components/jquery/src/event.js +991 -0
  152. data/vendor/assets/components/jquery/src/exports.js +18 -0
  153. data/vendor/assets/components/jquery/src/intro.js +20 -0
  154. data/vendor/assets/components/jquery/src/manipulation.js +796 -0
  155. data/vendor/assets/components/jquery/src/offset.js +169 -0
  156. data/vendor/assets/components/jquery/src/outro.js +2 -0
  157. data/vendor/assets/components/jquery/src/queue.js +147 -0
  158. data/vendor/assets/components/jquery/src/serialize.js +99 -0
  159. data/vendor/assets/components/jquery/src/sizzle-jquery.js +9 -0
  160. data/vendor/assets/components/jquery/src/support.js +241 -0
  161. data/vendor/assets/components/jquery/src/traversing.js +275 -0
  162. data/vendor/assets/components/jquery/test/csp.php +16 -0
  163. data/vendor/assets/components/jquery/test/data/1x1.jpg +0 -0
  164. data/vendor/assets/components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
  165. data/vendor/assets/components/jquery/test/data/atom+xml.php +4 -0
  166. data/vendor/assets/components/jquery/test/data/badcall.js +1 -0
  167. data/vendor/assets/components/jquery/test/data/badjson.js +1 -0
  168. data/vendor/assets/components/jquery/test/data/cleanScript.html +10 -0
  169. data/vendor/assets/components/jquery/test/data/core/cc_on.html +22 -0
  170. data/vendor/assets/components/jquery/test/data/dashboard.xml +11 -0
  171. data/vendor/assets/components/jquery/test/data/dimensions/documentLarge.html +17 -0
  172. data/vendor/assets/components/jquery/test/data/dimensions/documentSmall.html +21 -0
  173. data/vendor/assets/components/jquery/test/data/echoData.php +1 -0
  174. data/vendor/assets/components/jquery/test/data/echoQuery.php +1 -0
  175. data/vendor/assets/components/jquery/test/data/errorWithText.php +5 -0
  176. data/vendor/assets/components/jquery/test/data/etag.php +21 -0
  177. data/vendor/assets/components/jquery/test/data/evalScript.php +1 -0
  178. data/vendor/assets/components/jquery/test/data/event/longLoadScript.php +4 -0
  179. data/vendor/assets/components/jquery/test/data/event/promiseReady.html +17 -0
  180. data/vendor/assets/components/jquery/test/data/event/syncReady.html +23 -0
  181. data/vendor/assets/components/jquery/test/data/headers.php +18 -0
  182. data/vendor/assets/components/jquery/test/data/if_modified_since.php +20 -0
  183. data/vendor/assets/components/jquery/test/data/iframe.html +8 -0
  184. data/vendor/assets/components/jquery/test/data/jquery-1.8.2.ajax_xhr.min.js +2 -0
  185. data/vendor/assets/components/jquery/test/data/json.php +13 -0
  186. data/vendor/assets/components/jquery/test/data/json_obj.js +1 -0
  187. data/vendor/assets/components/jquery/test/data/jsonp.php +14 -0
  188. data/vendor/assets/components/jquery/test/data/manipulation/iframe-denied.html +36 -0
  189. data/vendor/assets/components/jquery/test/data/name.html +1 -0
  190. data/vendor/assets/components/jquery/test/data/name.php +24 -0
  191. data/vendor/assets/components/jquery/test/data/nocontent.php +5 -0
  192. data/vendor/assets/components/jquery/test/data/offset/absolute.html +41 -0
  193. data/vendor/assets/components/jquery/test/data/offset/body.html +26 -0
  194. data/vendor/assets/components/jquery/test/data/offset/fixed.html +34 -0
  195. data/vendor/assets/components/jquery/test/data/offset/relative.html +31 -0
  196. data/vendor/assets/components/jquery/test/data/offset/scroll.html +39 -0
  197. data/vendor/assets/components/jquery/test/data/offset/static.html +31 -0
  198. data/vendor/assets/components/jquery/test/data/offset/table.html +43 -0
  199. data/vendor/assets/components/jquery/test/data/params_html.php +12 -0
  200. data/vendor/assets/components/jquery/test/data/readywaitasset.js +1 -0
  201. data/vendor/assets/components/jquery/test/data/readywaitloader.js +25 -0
  202. data/vendor/assets/components/jquery/test/data/script.php +11 -0
  203. data/vendor/assets/components/jquery/test/data/selector/html5_selector.html +114 -0
  204. data/vendor/assets/components/jquery/test/data/selector/sizzle_cache.html +21 -0
  205. data/vendor/assets/components/jquery/test/data/statusText.php +5 -0
  206. data/vendor/assets/components/jquery/test/data/support/bodyBackground.html +28 -0
  207. data/vendor/assets/components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
  208. data/vendor/assets/components/jquery/test/data/support/testElementCrash.html +17 -0
  209. data/vendor/assets/components/jquery/test/data/test.html +7 -0
  210. data/vendor/assets/components/jquery/test/data/test.js +3 -0
  211. data/vendor/assets/components/jquery/test/data/test.php +7 -0
  212. data/vendor/assets/components/jquery/test/data/test2.html +5 -0
  213. data/vendor/assets/components/jquery/test/data/test3.html +3 -0
  214. data/vendor/assets/components/jquery/test/data/testinit.js +269 -0
  215. data/vendor/assets/components/jquery/test/data/testrunner.js +368 -0
  216. data/vendor/assets/components/jquery/test/data/testsuite.css +155 -0
  217. data/vendor/assets/components/jquery/test/data/text.php +12 -0
  218. data/vendor/assets/components/jquery/test/data/ua.txt +272 -0
  219. data/vendor/assets/components/jquery/test/data/with_fries.xml +25 -0
  220. data/vendor/assets/components/jquery/test/data/with_fries_over_jsonp.php +7 -0
  221. data/vendor/assets/components/jquery/test/delegatetest.html +228 -0
  222. data/vendor/assets/components/jquery/test/hovertest.html +158 -0
  223. data/vendor/assets/components/jquery/test/index.html +330 -0
  224. data/vendor/assets/components/jquery/test/localfile.html +75 -0
  225. data/vendor/assets/components/jquery/test/networkerror.html +84 -0
  226. data/vendor/assets/components/jquery/test/polluted.php +110 -0
  227. data/vendor/assets/components/jquery/test/readywait.html +70 -0
  228. data/vendor/assets/components/jquery/test/unit/ajax.js +1971 -0
  229. data/vendor/assets/components/jquery/test/unit/attributes.js +1332 -0
  230. data/vendor/assets/components/jquery/test/unit/callbacks.js +326 -0
  231. data/vendor/assets/components/jquery/test/unit/core.js +1332 -0
  232. data/vendor/assets/components/jquery/test/unit/css.js +1036 -0
  233. data/vendor/assets/components/jquery/test/unit/data.js +636 -0
  234. data/vendor/assets/components/jquery/test/unit/deferred.js +440 -0
  235. data/vendor/assets/components/jquery/test/unit/deprecated.js +1 -0
  236. data/vendor/assets/components/jquery/test/unit/dimensions.js +461 -0
  237. data/vendor/assets/components/jquery/test/unit/effects.js +2050 -0
  238. data/vendor/assets/components/jquery/test/unit/event.js +2690 -0
  239. data/vendor/assets/components/jquery/test/unit/exports.js +7 -0
  240. data/vendor/assets/components/jquery/test/unit/manipulation.js +2242 -0
  241. data/vendor/assets/components/jquery/test/unit/offset.js +549 -0
  242. data/vendor/assets/components/jquery/test/unit/queue.js +316 -0
  243. data/vendor/assets/components/jquery/test/unit/selector.js +185 -0
  244. data/vendor/assets/components/jquery/test/unit/serialize.js +146 -0
  245. data/vendor/assets/components/jquery/test/unit/support.js +384 -0
  246. data/vendor/assets/components/jquery/test/unit/traversing.js +667 -0
  247. data/vendor/assets/components/jquery/test/xhtml.php +5 -0
  248. data/vendor/assets/components/sir-trevor-js/CHANGELOG.md +44 -0
  249. data/vendor/assets/components/sir-trevor-js/Gemfile +3 -0
  250. data/vendor/assets/components/sir-trevor-js/Gemfile.lock +10 -0
  251. data/vendor/assets/components/sir-trevor-js/Gruntfile.js +109 -0
  252. data/vendor/assets/components/sir-trevor-js/MIT-LICENCE +20 -0
  253. data/vendor/assets/components/sir-trevor-js/Readme.md +84 -0
  254. data/vendor/assets/components/sir-trevor-js/bower.json +21 -0
  255. data/vendor/assets/components/sir-trevor-js/component.json +42 -0
  256. data/vendor/assets/components/sir-trevor-js/contributing.md +74 -0
  257. data/vendor/assets/components/sir-trevor-js/examples-component/component.json +14 -0
  258. data/vendor/assets/components/sir-trevor-js/examples-component/index.html +33 -0
  259. data/vendor/assets/components/sir-trevor-js/examples-component/index.js +29 -0
  260. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/example_block.js +203 -0
  261. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/limit_chars.js +46 -0
  262. data/vendor/assets/components/sir-trevor-js/examples-component/sir-trevor.gif +0 -0
  263. data/vendor/assets/components/sir-trevor-js/locales/cn.js +51 -0
  264. data/vendor/assets/components/sir-trevor-js/locales/de.js +51 -0
  265. data/vendor/assets/components/sir-trevor-js/locales/es.js +51 -0
  266. data/vendor/assets/components/sir-trevor-js/locales/fi.js +51 -0
  267. data/vendor/assets/components/sir-trevor-js/locales/fr.js +51 -0
  268. data/vendor/assets/components/sir-trevor-js/locales/pt.js +52 -0
  269. data/vendor/assets/components/sir-trevor-js/package.json +23 -0
  270. data/vendor/assets/components/sir-trevor-js/sir-trevor-icons.css +6 -0
  271. data/vendor/assets/components/sir-trevor-js/sir-trevor.css +393 -0
  272. data/vendor/assets/components/sir-trevor-js/sir-trevor.css.map +7 -0
  273. data/vendor/assets/components/sir-trevor-js/sir-trevor.js +5481 -0
  274. data/vendor/assets/components/sir-trevor-js/sir-trevor.min.js +13 -0
  275. data/vendor/assets/components/underscore/CNAME +1 -0
  276. data/vendor/assets/components/underscore/CONTRIBUTING.md +9 -0
  277. data/vendor/assets/components/underscore/LICENSE +22 -0
  278. data/vendor/assets/components/underscore/README.md +19 -0
  279. data/vendor/assets/components/underscore/Rakefile +10 -0
  280. data/vendor/assets/components/underscore/docs/docco.css +192 -0
  281. data/vendor/assets/components/underscore/docs/favicon.ico +0 -0
  282. data/vendor/assets/components/underscore/docs/images/background.png +0 -0
  283. data/vendor/assets/components/underscore/docs/images/underscore.png +0 -0
  284. data/vendor/assets/components/underscore/docs/underscore.html +823 -0
  285. data/vendor/assets/components/underscore/favicon.ico +0 -0
  286. data/vendor/assets/components/underscore/index.html +2467 -0
  287. data/vendor/assets/components/underscore/index.js +1 -0
  288. data/vendor/assets/components/underscore/package.json +16 -0
  289. data/vendor/assets/components/underscore/test/arrays.js +200 -0
  290. data/vendor/assets/components/underscore/test/chaining.js +59 -0
  291. data/vendor/assets/components/underscore/test/collections.js +453 -0
  292. data/vendor/assets/components/underscore/test/functions.js +265 -0
  293. data/vendor/assets/components/underscore/test/index.html +44 -0
  294. data/vendor/assets/components/underscore/test/objects.js +570 -0
  295. data/vendor/assets/components/underscore/test/speed.js +75 -0
  296. data/vendor/assets/components/underscore/test/utility.js +266 -0
  297. data/vendor/assets/components/underscore/test/vendor/jquery.js +9404 -0
  298. data/vendor/assets/components/underscore/test/vendor/jslitmus.js +670 -0
  299. data/vendor/assets/components/underscore/test/vendor/qunit.css +235 -0
  300. data/vendor/assets/components/underscore/test/vendor/qunit.js +1977 -0
  301. data/vendor/assets/components/underscore/test/vendor/runner.js +98 -0
  302. data/vendor/assets/components/underscore/underscore-min.js +1 -0
  303. data/vendor/assets/components/underscore/underscore.js +1226 -0
  304. metadata +473 -0
@@ -0,0 +1,47 @@
1
+ <script type="text/javascript">
2
+ (function(){
3
+ // Conclusions:
4
+ // slice() is a little faster than concat() except on Chrome
5
+ // This clone() is slower on FF & IE but takes 50% on Safari & Chrome
6
+
7
+ var SIZE = 1e4,
8
+ LOOPS = 500;
9
+
10
+ var arr = new Array(SIZE);
11
+ for ( var i=arr.length-1; i >= 0; --i )
12
+ arr[i] = 0;
13
+
14
+ var t = new Date;
15
+ for ( i=0; i < LOOPS; i++ )
16
+ arr.slice(0);
17
+ var tslice = new Date - t;
18
+
19
+ t = new Date;
20
+ for ( i=0; i < LOOPS; i++ )
21
+ arr.concat();
22
+ var tconcat = new Date - t;
23
+
24
+ // clone() is just to see how fast built-ins are
25
+ t = new Date;
26
+ for ( i=0; i < LOOPS; i++ )
27
+ clone(arr);
28
+ var tclone = new Date - t;
29
+
30
+ alert([
31
+ 'slice:'+tslice,
32
+ 'concat:'+tconcat,
33
+ 'clone:'+tclone
34
+ ].join('\n'));
35
+
36
+
37
+ function clone(arr){
38
+ var i = arr.length,
39
+ copy = new Array(i);
40
+
41
+ while (i--)
42
+ copy[i] = arr[i];
43
+
44
+ return copy;
45
+ }
46
+ })();
47
+ </script>
@@ -0,0 +1,851 @@
1
+ var
2
+ // Document location
3
+ ajaxLocParts,
4
+ ajaxLocation,
5
+ ajax_nonce = jQuery.now(),
6
+
7
+ ajax_rquery = /\?/,
8
+ rhash = /#.*$/,
9
+ rts = /([?&])_=[^&]*/,
10
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
11
+ // #7653, #8125, #8152: local protocol detection
12
+ rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
13
+ rnoContent = /^(?:GET|HEAD)$/,
14
+ rprotocol = /^\/\//,
15
+ rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
16
+
17
+ // Keep a copy of the old load method
18
+ _load = jQuery.fn.load,
19
+
20
+ /* Prefilters
21
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
22
+ * 2) These are called:
23
+ * - BEFORE asking for a transport
24
+ * - AFTER param serialization (s.data is a string if s.processData is true)
25
+ * 3) key is the dataType
26
+ * 4) the catchall symbol "*" can be used
27
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
28
+ */
29
+ prefilters = {},
30
+
31
+ /* Transports bindings
32
+ * 1) key is the dataType
33
+ * 2) the catchall symbol "*" can be used
34
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
35
+ */
36
+ transports = {},
37
+
38
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
39
+ allTypes = "*/".concat("*");
40
+
41
+ // #8138, IE may throw an exception when accessing
42
+ // a field from window.location if document.domain has been set
43
+ try {
44
+ ajaxLocation = location.href;
45
+ } catch( e ) {
46
+ // Use the href attribute of an A element
47
+ // since IE will modify it given document.location
48
+ ajaxLocation = document.createElement( "a" );
49
+ ajaxLocation.href = "";
50
+ ajaxLocation = ajaxLocation.href;
51
+ }
52
+
53
+ // Segment location into parts
54
+ ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
55
+
56
+ // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
57
+ function addToPrefiltersOrTransports( structure ) {
58
+
59
+ // dataTypeExpression is optional and defaults to "*"
60
+ return function( dataTypeExpression, func ) {
61
+
62
+ if ( typeof dataTypeExpression !== "string" ) {
63
+ func = dataTypeExpression;
64
+ dataTypeExpression = "*";
65
+ }
66
+
67
+ var dataType,
68
+ i = 0,
69
+ dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
70
+
71
+ if ( jQuery.isFunction( func ) ) {
72
+ // For each dataType in the dataTypeExpression
73
+ while ( (dataType = dataTypes[i++]) ) {
74
+ // Prepend if requested
75
+ if ( dataType[0] === "+" ) {
76
+ dataType = dataType.slice( 1 ) || "*";
77
+ (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
78
+
79
+ // Otherwise append
80
+ } else {
81
+ (structure[ dataType ] = structure[ dataType ] || []).push( func );
82
+ }
83
+ }
84
+ }
85
+ };
86
+ }
87
+
88
+ // Base inspection function for prefilters and transports
89
+ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
90
+
91
+ var inspected = {},
92
+ seekingTransport = ( structure === transports );
93
+
94
+ function inspect( dataType ) {
95
+ var selected;
96
+ inspected[ dataType ] = true;
97
+ jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
98
+ var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
99
+ if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
100
+ options.dataTypes.unshift( dataTypeOrTransport );
101
+ inspect( dataTypeOrTransport );
102
+ return false;
103
+ } else if ( seekingTransport ) {
104
+ return !( selected = dataTypeOrTransport );
105
+ }
106
+ });
107
+ return selected;
108
+ }
109
+
110
+ return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
111
+ }
112
+
113
+ // A special extend for ajax options
114
+ // that takes "flat" options (not to be deep extended)
115
+ // Fixes #9887
116
+ function ajaxExtend( target, src ) {
117
+ var deep, key,
118
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
119
+
120
+ for ( key in src ) {
121
+ if ( src[ key ] !== undefined ) {
122
+ ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
123
+ }
124
+ }
125
+ if ( deep ) {
126
+ jQuery.extend( true, target, deep );
127
+ }
128
+
129
+ return target;
130
+ }
131
+
132
+ jQuery.fn.load = function( url, params, callback ) {
133
+ if ( typeof url !== "string" && _load ) {
134
+ return _load.apply( this, arguments );
135
+ }
136
+
137
+ var selector, response, type,
138
+ self = this,
139
+ off = url.indexOf(" ");
140
+
141
+ if ( off >= 0 ) {
142
+ selector = url.slice( off, url.length );
143
+ url = url.slice( 0, off );
144
+ }
145
+
146
+ // If it's a function
147
+ if ( jQuery.isFunction( params ) ) {
148
+
149
+ // We assume that it's the callback
150
+ callback = params;
151
+ params = undefined;
152
+
153
+ // Otherwise, build a param string
154
+ } else if ( params && typeof params === "object" ) {
155
+ type = "POST";
156
+ }
157
+
158
+ // If we have elements to modify, make the request
159
+ if ( self.length > 0 ) {
160
+ jQuery.ajax({
161
+ url: url,
162
+
163
+ // if "type" variable is undefined, then "GET" method will be used
164
+ type: type,
165
+ dataType: "html",
166
+ data: params
167
+ }).done(function( responseText ) {
168
+
169
+ // Save response for use in complete callback
170
+ response = arguments;
171
+
172
+ self.html( selector ?
173
+
174
+ // If a selector was specified, locate the right elements in a dummy div
175
+ // Exclude scripts to avoid IE 'Permission Denied' errors
176
+ jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
177
+
178
+ // Otherwise use the full result
179
+ responseText );
180
+
181
+ }).complete( callback && function( jqXHR, status ) {
182
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
183
+ });
184
+ }
185
+
186
+ return this;
187
+ };
188
+
189
+ // Attach a bunch of functions for handling common AJAX events
190
+ jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
191
+ jQuery.fn[ type ] = function( fn ){
192
+ return this.on( type, fn );
193
+ };
194
+ });
195
+
196
+ jQuery.each( [ "get", "post" ], function( i, method ) {
197
+ jQuery[ method ] = function( url, data, callback, type ) {
198
+ // shift arguments if data argument was omitted
199
+ if ( jQuery.isFunction( data ) ) {
200
+ type = type || callback;
201
+ callback = data;
202
+ data = undefined;
203
+ }
204
+
205
+ return jQuery.ajax({
206
+ url: url,
207
+ type: method,
208
+ dataType: type,
209
+ data: data,
210
+ success: callback
211
+ });
212
+ };
213
+ });
214
+
215
+ jQuery.extend({
216
+
217
+ // Counter for holding the number of active queries
218
+ active: 0,
219
+
220
+ // Last-Modified header cache for next request
221
+ lastModified: {},
222
+ etag: {},
223
+
224
+ ajaxSettings: {
225
+ url: ajaxLocation,
226
+ type: "GET",
227
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
228
+ global: true,
229
+ processData: true,
230
+ async: true,
231
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
232
+ /*
233
+ timeout: 0,
234
+ data: null,
235
+ dataType: null,
236
+ username: null,
237
+ password: null,
238
+ cache: null,
239
+ throws: false,
240
+ traditional: false,
241
+ headers: {},
242
+ */
243
+
244
+ accepts: {
245
+ "*": allTypes,
246
+ text: "text/plain",
247
+ html: "text/html",
248
+ xml: "application/xml, text/xml",
249
+ json: "application/json, text/javascript"
250
+ },
251
+
252
+ contents: {
253
+ xml: /xml/,
254
+ html: /html/,
255
+ json: /json/
256
+ },
257
+
258
+ responseFields: {
259
+ xml: "responseXML",
260
+ text: "responseText"
261
+ },
262
+
263
+ // Data converters
264
+ // Keys separate source (or catchall "*") and destination types with a single space
265
+ converters: {
266
+
267
+ // Convert anything to text
268
+ "* text": window.String,
269
+
270
+ // Text to html (true = no transformation)
271
+ "text html": true,
272
+
273
+ // Evaluate text as a json expression
274
+ "text json": jQuery.parseJSON,
275
+
276
+ // Parse text as xml
277
+ "text xml": jQuery.parseXML
278
+ },
279
+
280
+ // For options that shouldn't be deep extended:
281
+ // you can add your own custom options here if
282
+ // and when you create one that shouldn't be
283
+ // deep extended (see ajaxExtend)
284
+ flatOptions: {
285
+ url: true,
286
+ context: true
287
+ }
288
+ },
289
+
290
+ // Creates a full fledged settings object into target
291
+ // with both ajaxSettings and settings fields.
292
+ // If target is omitted, writes into ajaxSettings.
293
+ ajaxSetup: function( target, settings ) {
294
+ return settings ?
295
+
296
+ // Building a settings object
297
+ ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
298
+
299
+ // Extending ajaxSettings
300
+ ajaxExtend( jQuery.ajaxSettings, target );
301
+ },
302
+
303
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
304
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
305
+
306
+ // Main method
307
+ ajax: function( url, options ) {
308
+
309
+ // If url is an object, simulate pre-1.5 signature
310
+ if ( typeof url === "object" ) {
311
+ options = url;
312
+ url = undefined;
313
+ }
314
+
315
+ // Force options to be an object
316
+ options = options || {};
317
+
318
+ var // Cross-domain detection vars
319
+ parts,
320
+ // Loop variable
321
+ i,
322
+ // URL without anti-cache param
323
+ cacheURL,
324
+ // Response headers as string
325
+ responseHeadersString,
326
+ // timeout handle
327
+ timeoutTimer,
328
+
329
+ // To know if global events are to be dispatched
330
+ fireGlobals,
331
+
332
+ transport,
333
+ // Response headers
334
+ responseHeaders,
335
+ // Create the final options object
336
+ s = jQuery.ajaxSetup( {}, options ),
337
+ // Callbacks context
338
+ callbackContext = s.context || s,
339
+ // Context for global events is callbackContext if it is a DOM node or jQuery collection
340
+ globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
341
+ jQuery( callbackContext ) :
342
+ jQuery.event,
343
+ // Deferreds
344
+ deferred = jQuery.Deferred(),
345
+ completeDeferred = jQuery.Callbacks("once memory"),
346
+ // Status-dependent callbacks
347
+ statusCode = s.statusCode || {},
348
+ // Headers (they are sent all at once)
349
+ requestHeaders = {},
350
+ requestHeadersNames = {},
351
+ // The jqXHR state
352
+ state = 0,
353
+ // Default abort message
354
+ strAbort = "canceled",
355
+ // Fake xhr
356
+ jqXHR = {
357
+ readyState: 0,
358
+
359
+ // Builds headers hashtable if needed
360
+ getResponseHeader: function( key ) {
361
+ var match;
362
+ if ( state === 2 ) {
363
+ if ( !responseHeaders ) {
364
+ responseHeaders = {};
365
+ while ( (match = rheaders.exec( responseHeadersString )) ) {
366
+ responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
367
+ }
368
+ }
369
+ match = responseHeaders[ key.toLowerCase() ];
370
+ }
371
+ return match == null ? null : match;
372
+ },
373
+
374
+ // Raw string
375
+ getAllResponseHeaders: function() {
376
+ return state === 2 ? responseHeadersString : null;
377
+ },
378
+
379
+ // Caches the header
380
+ setRequestHeader: function( name, value ) {
381
+ var lname = name.toLowerCase();
382
+ if ( !state ) {
383
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
384
+ requestHeaders[ name ] = value;
385
+ }
386
+ return this;
387
+ },
388
+
389
+ // Overrides response content-type header
390
+ overrideMimeType: function( type ) {
391
+ if ( !state ) {
392
+ s.mimeType = type;
393
+ }
394
+ return this;
395
+ },
396
+
397
+ // Status-dependent callbacks
398
+ statusCode: function( map ) {
399
+ var code;
400
+ if ( map ) {
401
+ if ( state < 2 ) {
402
+ for ( code in map ) {
403
+ // Lazy-add the new callback in a way that preserves old ones
404
+ statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
405
+ }
406
+ } else {
407
+ // Execute the appropriate callbacks
408
+ jqXHR.always( map[ jqXHR.status ] );
409
+ }
410
+ }
411
+ return this;
412
+ },
413
+
414
+ // Cancel the request
415
+ abort: function( statusText ) {
416
+ var finalText = statusText || strAbort;
417
+ if ( transport ) {
418
+ transport.abort( finalText );
419
+ }
420
+ done( 0, finalText );
421
+ return this;
422
+ }
423
+ };
424
+
425
+ // Attach deferreds
426
+ deferred.promise( jqXHR ).complete = completeDeferred.add;
427
+ jqXHR.success = jqXHR.done;
428
+ jqXHR.error = jqXHR.fail;
429
+
430
+ // Remove hash character (#7531: and string promotion)
431
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
432
+ // Handle falsy url in the settings object (#10093: consistency with old signature)
433
+ // We also use the url parameter if available
434
+ s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
435
+
436
+ // Alias method option to type as per ticket #12004
437
+ s.type = options.method || options.type || s.method || s.type;
438
+
439
+ // Extract dataTypes list
440
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
441
+
442
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
443
+ if ( s.crossDomain == null ) {
444
+ parts = rurl.exec( s.url.toLowerCase() );
445
+ s.crossDomain = !!( parts &&
446
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
447
+ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
448
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
449
+ );
450
+ }
451
+
452
+ // Convert data if not already a string
453
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
454
+ s.data = jQuery.param( s.data, s.traditional );
455
+ }
456
+
457
+ // Apply prefilters
458
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
459
+
460
+ // If request was aborted inside a prefilter, stop there
461
+ if ( state === 2 ) {
462
+ return jqXHR;
463
+ }
464
+
465
+ // We can fire global events as of now if asked to
466
+ fireGlobals = s.global;
467
+
468
+ // Watch for a new set of requests
469
+ if ( fireGlobals && jQuery.active++ === 0 ) {
470
+ jQuery.event.trigger("ajaxStart");
471
+ }
472
+
473
+ // Uppercase the type
474
+ s.type = s.type.toUpperCase();
475
+
476
+ // Determine if request has content
477
+ s.hasContent = !rnoContent.test( s.type );
478
+
479
+ // Save the URL in case we're toying with the If-Modified-Since
480
+ // and/or If-None-Match header later on
481
+ cacheURL = s.url;
482
+
483
+ // More options handling for requests with no content
484
+ if ( !s.hasContent ) {
485
+
486
+ // If data is available, append data to url
487
+ if ( s.data ) {
488
+ cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
489
+ // #9682: remove data so that it's not used in an eventual retry
490
+ delete s.data;
491
+ }
492
+
493
+ // Add anti-cache in url if needed
494
+ if ( s.cache === false ) {
495
+ s.url = rts.test( cacheURL ) ?
496
+
497
+ // If there is already a '_' parameter, set its value
498
+ cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
499
+
500
+ // Otherwise add one to the end
501
+ cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
502
+ }
503
+ }
504
+
505
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
506
+ if ( s.ifModified ) {
507
+ if ( jQuery.lastModified[ cacheURL ] ) {
508
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
509
+ }
510
+ if ( jQuery.etag[ cacheURL ] ) {
511
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
512
+ }
513
+ }
514
+
515
+ // Set the correct header, if data is being sent
516
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
517
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
518
+ }
519
+
520
+ // Set the Accepts header for the server, depending on the dataType
521
+ jqXHR.setRequestHeader(
522
+ "Accept",
523
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
524
+ s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
525
+ s.accepts[ "*" ]
526
+ );
527
+
528
+ // Check for headers option
529
+ for ( i in s.headers ) {
530
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
531
+ }
532
+
533
+ // Allow custom headers/mimetypes and early abort
534
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
535
+ // Abort if not done already and return
536
+ return jqXHR.abort();
537
+ }
538
+
539
+ // aborting is no longer a cancellation
540
+ strAbort = "abort";
541
+
542
+ // Install callbacks on deferreds
543
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
544
+ jqXHR[ i ]( s[ i ] );
545
+ }
546
+
547
+ // Get transport
548
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
549
+
550
+ // If no transport, we auto-abort
551
+ if ( !transport ) {
552
+ done( -1, "No Transport" );
553
+ } else {
554
+ jqXHR.readyState = 1;
555
+
556
+ // Send global event
557
+ if ( fireGlobals ) {
558
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
559
+ }
560
+ // Timeout
561
+ if ( s.async && s.timeout > 0 ) {
562
+ timeoutTimer = setTimeout(function() {
563
+ jqXHR.abort("timeout");
564
+ }, s.timeout );
565
+ }
566
+
567
+ try {
568
+ state = 1;
569
+ transport.send( requestHeaders, done );
570
+ } catch ( e ) {
571
+ // Propagate exception as error if not done
572
+ if ( state < 2 ) {
573
+ done( -1, e );
574
+ // Simply rethrow otherwise
575
+ } else {
576
+ throw e;
577
+ }
578
+ }
579
+ }
580
+
581
+ // Callback for when everything is done
582
+ function done( status, nativeStatusText, responses, headers ) {
583
+ var isSuccess, success, error, response, modified,
584
+ statusText = nativeStatusText;
585
+
586
+ // Called once
587
+ if ( state === 2 ) {
588
+ return;
589
+ }
590
+
591
+ // State is "done" now
592
+ state = 2;
593
+
594
+ // Clear timeout if it exists
595
+ if ( timeoutTimer ) {
596
+ clearTimeout( timeoutTimer );
597
+ }
598
+
599
+ // Dereference transport for early garbage collection
600
+ // (no matter how long the jqXHR object will be used)
601
+ transport = undefined;
602
+
603
+ // Cache response headers
604
+ responseHeadersString = headers || "";
605
+
606
+ // Set readyState
607
+ jqXHR.readyState = status > 0 ? 4 : 0;
608
+
609
+ // Get response data
610
+ if ( responses ) {
611
+ response = ajaxHandleResponses( s, jqXHR, responses );
612
+ }
613
+
614
+ // If successful, handle type chaining
615
+ if ( status >= 200 && status < 300 || status === 304 ) {
616
+
617
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
618
+ if ( s.ifModified ) {
619
+ modified = jqXHR.getResponseHeader("Last-Modified");
620
+ if ( modified ) {
621
+ jQuery.lastModified[ cacheURL ] = modified;
622
+ }
623
+ modified = jqXHR.getResponseHeader("etag");
624
+ if ( modified ) {
625
+ jQuery.etag[ cacheURL ] = modified;
626
+ }
627
+ }
628
+
629
+ // if no content
630
+ if ( status === 204 ) {
631
+ isSuccess = true;
632
+ statusText = "nocontent";
633
+
634
+ // if not modified
635
+ } else if ( status === 304 ) {
636
+ isSuccess = true;
637
+ statusText = "notmodified";
638
+
639
+ // If we have data, let's convert it
640
+ } else {
641
+ isSuccess = ajaxConvert( s, response );
642
+ statusText = isSuccess.state;
643
+ success = isSuccess.data;
644
+ error = isSuccess.error;
645
+ isSuccess = !error;
646
+ }
647
+ } else {
648
+ // We extract error from statusText
649
+ // then normalize statusText and status for non-aborts
650
+ error = statusText;
651
+ if ( status || !statusText ) {
652
+ statusText = "error";
653
+ if ( status < 0 ) {
654
+ status = 0;
655
+ }
656
+ }
657
+ }
658
+
659
+ // Set data for the fake xhr object
660
+ jqXHR.status = status;
661
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
662
+
663
+ // Success/Error
664
+ if ( isSuccess ) {
665
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
666
+ } else {
667
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
668
+ }
669
+
670
+ // Status-dependent callbacks
671
+ jqXHR.statusCode( statusCode );
672
+ statusCode = undefined;
673
+
674
+ if ( fireGlobals ) {
675
+ globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
676
+ [ jqXHR, s, isSuccess ? success : error ] );
677
+ }
678
+
679
+ // Complete
680
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
681
+
682
+ if ( fireGlobals ) {
683
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
684
+ // Handle the global AJAX counter
685
+ if ( !( --jQuery.active ) ) {
686
+ jQuery.event.trigger("ajaxStop");
687
+ }
688
+ }
689
+ }
690
+
691
+ return jqXHR;
692
+ },
693
+
694
+ getScript: function( url, callback ) {
695
+ return jQuery.get( url, undefined, callback, "script" );
696
+ },
697
+
698
+ getJSON: function( url, data, callback ) {
699
+ return jQuery.get( url, data, callback, "json" );
700
+ }
701
+ });
702
+
703
+ /* Handles responses to an ajax request:
704
+ * - sets all responseXXX fields accordingly
705
+ * - finds the right dataType (mediates between content-type and expected dataType)
706
+ * - returns the corresponding response
707
+ */
708
+ function ajaxHandleResponses( s, jqXHR, responses ) {
709
+ var firstDataType, ct, finalDataType, type,
710
+ contents = s.contents,
711
+ dataTypes = s.dataTypes,
712
+ responseFields = s.responseFields;
713
+
714
+ // Fill responseXXX fields
715
+ for ( type in responseFields ) {
716
+ if ( type in responses ) {
717
+ jqXHR[ responseFields[type] ] = responses[ type ];
718
+ }
719
+ }
720
+
721
+ // Remove auto dataType and get content-type in the process
722
+ while( dataTypes[ 0 ] === "*" ) {
723
+ dataTypes.shift();
724
+ if ( ct === undefined ) {
725
+ ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
726
+ }
727
+ }
728
+
729
+ // Check if we're dealing with a known content-type
730
+ if ( ct ) {
731
+ for ( type in contents ) {
732
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
733
+ dataTypes.unshift( type );
734
+ break;
735
+ }
736
+ }
737
+ }
738
+
739
+ // Check to see if we have a response for the expected dataType
740
+ if ( dataTypes[ 0 ] in responses ) {
741
+ finalDataType = dataTypes[ 0 ];
742
+ } else {
743
+ // Try convertible dataTypes
744
+ for ( type in responses ) {
745
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
746
+ finalDataType = type;
747
+ break;
748
+ }
749
+ if ( !firstDataType ) {
750
+ firstDataType = type;
751
+ }
752
+ }
753
+ // Or just use first one
754
+ finalDataType = finalDataType || firstDataType;
755
+ }
756
+
757
+ // If we found a dataType
758
+ // We add the dataType to the list if needed
759
+ // and return the corresponding response
760
+ if ( finalDataType ) {
761
+ if ( finalDataType !== dataTypes[ 0 ] ) {
762
+ dataTypes.unshift( finalDataType );
763
+ }
764
+ return responses[ finalDataType ];
765
+ }
766
+ }
767
+
768
+ // Chain conversions given the request and the original response
769
+ function ajaxConvert( s, response ) {
770
+ var conv2, current, conv, tmp,
771
+ converters = {},
772
+ i = 0,
773
+ // Work with a copy of dataTypes in case we need to modify it for conversion
774
+ dataTypes = s.dataTypes.slice(),
775
+ prev = dataTypes[ 0 ];
776
+
777
+ // Apply the dataFilter if provided
778
+ if ( s.dataFilter ) {
779
+ response = s.dataFilter( response, s.dataType );
780
+ }
781
+
782
+ // Create converters map with lowercased keys
783
+ if ( dataTypes[ 1 ] ) {
784
+ for ( conv in s.converters ) {
785
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
786
+ }
787
+ }
788
+
789
+ // Convert to each sequential dataType, tolerating list modification
790
+ for ( ; (current = dataTypes[++i]); ) {
791
+
792
+ // There's only work to do if current dataType is non-auto
793
+ if ( current !== "*" ) {
794
+
795
+ // Convert response if prev dataType is non-auto and differs from current
796
+ if ( prev !== "*" && prev !== current ) {
797
+
798
+ // Seek a direct converter
799
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
800
+
801
+ // If none found, seek a pair
802
+ if ( !conv ) {
803
+ for ( conv2 in converters ) {
804
+
805
+ // If conv2 outputs current
806
+ tmp = conv2.split(" ");
807
+ if ( tmp[ 1 ] === current ) {
808
+
809
+ // If prev can be converted to accepted input
810
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
811
+ converters[ "* " + tmp[ 0 ] ];
812
+ if ( conv ) {
813
+ // Condense equivalence converters
814
+ if ( conv === true ) {
815
+ conv = converters[ conv2 ];
816
+
817
+ // Otherwise, insert the intermediate dataType
818
+ } else if ( converters[ conv2 ] !== true ) {
819
+ current = tmp[ 0 ];
820
+ dataTypes.splice( i--, 0, current );
821
+ }
822
+
823
+ break;
824
+ }
825
+ }
826
+ }
827
+ }
828
+
829
+ // Apply converter (if not an equivalence)
830
+ if ( conv !== true ) {
831
+
832
+ // Unless errors are allowed to bubble, catch and return them
833
+ if ( conv && s["throws"] ) {
834
+ response = conv( response );
835
+ } else {
836
+ try {
837
+ response = conv( response );
838
+ } catch ( e ) {
839
+ return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
840
+ }
841
+ }
842
+ }
843
+ }
844
+
845
+ // Update prev for next iteration
846
+ prev = current;
847
+ }
848
+ }
849
+
850
+ return { state: "success", data: response };
851
+ }