unpoly-rails 1.0.3 → 2.0.0.pre.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (344) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +43 -25
  4. data/README.md +5 -6
  5. data/README_RAILS.md +295 -14
  6. data/dist/unpoly-bootstrap3.css +9 -14
  7. data/dist/unpoly-bootstrap3.js +4 -18
  8. data/dist/unpoly-bootstrap3.min.css +1 -1
  9. data/dist/unpoly-bootstrap3.min.js +1 -1
  10. data/dist/unpoly-bootstrap4.css +9 -0
  11. data/dist/unpoly-bootstrap4.js +16 -0
  12. data/dist/unpoly-bootstrap4.min.css +1 -0
  13. data/dist/unpoly-bootstrap4.min.js +1 -0
  14. data/dist/unpoly-bootstrap5.css +9 -0
  15. data/dist/unpoly-bootstrap5.js +14 -0
  16. data/dist/unpoly-bootstrap5.min.css +1 -0
  17. data/dist/unpoly-bootstrap5.min.js +1 -0
  18. data/dist/unpoly-migrate.js +1213 -0
  19. data/dist/unpoly-migrate.min.js +1 -0
  20. data/dist/unpoly.css +109 -140
  21. data/dist/unpoly.js +15376 -10484
  22. data/dist/unpoly.min.css +1 -1
  23. data/dist/unpoly.min.js +6 -4
  24. data/lib/unpoly/rails/change/cache.rb +26 -0
  25. data/lib/unpoly/rails/change/context.rb +80 -0
  26. data/lib/unpoly/rails/change/field.rb +117 -0
  27. data/lib/unpoly/rails/change/field_definition.rb +74 -0
  28. data/lib/unpoly/rails/change/layer.rb +60 -0
  29. data/lib/unpoly/rails/change.rb +372 -0
  30. data/lib/unpoly/rails/controller.rb +47 -0
  31. data/lib/unpoly/rails/error.rb +5 -0
  32. data/lib/unpoly/rails/request_echo_headers.rb +2 -2
  33. data/lib/unpoly/rails/version.rb +1 -1
  34. data/lib/unpoly/tasks.rb +45 -0
  35. data/lib/unpoly-rails.rb +9 -3
  36. metadata +42 -316
  37. data/.gitignore +0 -10
  38. data/.ruby-version +0 -1
  39. data/Gemfile +0 -7
  40. data/Gemfile.lock +0 -39
  41. data/Rakefile +0 -154
  42. data/bower.json +0 -27
  43. data/design/animation-ghosting.txt +0 -72
  44. data/design/design.txt +0 -34
  45. data/design/draft.html.erb +0 -48
  46. data/design/draft.rb +0 -9
  47. data/design/es6.js +0 -32
  48. data/design/ghost-debugging.txt +0 -118
  49. data/design/homepage.txt +0 -236
  50. data/design/ie11.txt +0 -9
  51. data/design/measure_import_node.js +0 -330
  52. data/design/measure_jquery/element_list.js +0 -41
  53. data/design/measure_jquery/up.on_vs_addEventListener.js +0 -56
  54. data/design/positioning.txt +0 -28
  55. data/design/query-params-in-form-actions/cases.html +0 -125
  56. data/design/rename.txt +0 -0
  57. data/design/test_rejected_promise.txt +0 -5
  58. data/design/unpoly errors.txt +0 -19
  59. data/lib/assets/javascripts/unpoly/browser.coffee.erb +0 -240
  60. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +0 -45
  61. data/lib/assets/javascripts/unpoly/classes/cache.coffee +0 -127
  62. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +0 -93
  63. data/lib/assets/javascripts/unpoly/classes/config.coffee +0 -9
  64. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +0 -118
  65. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +0 -39
  66. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +0 -116
  67. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +0 -86
  68. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +0 -111
  69. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +0 -80
  70. data/lib/assets/javascripts/unpoly/classes/focus_follower.coffee +0 -29
  71. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +0 -64
  72. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +0 -46
  73. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +0 -157
  74. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +0 -544
  75. data/lib/assets/javascripts/unpoly/classes/record.coffee +0 -22
  76. data/lib/assets/javascripts/unpoly/classes/rect.js +0 -21
  77. data/lib/assets/javascripts/unpoly/classes/request.coffee +0 -247
  78. data/lib/assets/javascripts/unpoly/classes/response.coffee +0 -157
  79. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +0 -102
  80. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +0 -67
  81. data/lib/assets/javascripts/unpoly/classes/selector.coffee +0 -60
  82. data/lib/assets/javascripts/unpoly/classes/store/memory.coffee +0 -26
  83. data/lib/assets/javascripts/unpoly/classes/store/session.coffee +0 -59
  84. data/lib/assets/javascripts/unpoly/classes/tether.coffee +0 -105
  85. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +0 -32
  86. data/lib/assets/javascripts/unpoly/cookie.coffee +0 -56
  87. data/lib/assets/javascripts/unpoly/element.coffee.erb +0 -1129
  88. data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -445
  89. data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
  90. data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1084
  91. data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -928
  92. data/lib/assets/javascripts/unpoly/framework.coffee +0 -65
  93. data/lib/assets/javascripts/unpoly/history.coffee +0 -268
  94. data/lib/assets/javascripts/unpoly/legacy.coffee +0 -60
  95. data/lib/assets/javascripts/unpoly/link.coffee.erb +0 -622
  96. data/lib/assets/javascripts/unpoly/log.coffee +0 -253
  97. data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -827
  98. data/lib/assets/javascripts/unpoly/motion.coffee.erb +0 -668
  99. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  100. data/lib/assets/javascripts/unpoly/popup.coffee.erb +0 -515
  101. data/lib/assets/javascripts/unpoly/protocol.coffee +0 -300
  102. data/lib/assets/javascripts/unpoly/proxy.coffee +0 -672
  103. data/lib/assets/javascripts/unpoly/radio.coffee +0 -60
  104. data/lib/assets/javascripts/unpoly/rails.coffee +0 -24
  105. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +0 -476
  106. data/lib/assets/javascripts/unpoly/toast.coffee +0 -67
  107. data/lib/assets/javascripts/unpoly/tooltip.coffee +0 -276
  108. data/lib/assets/javascripts/unpoly/util.coffee.erb +0 -1677
  109. data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -830
  110. data/lib/assets/javascripts/unpoly-bootstrap3/feedback-ext.coffee +0 -5
  111. data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.coffee +0 -1
  112. data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.coffee +0 -14
  113. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +0 -5
  114. data/lib/assets/javascripts/unpoly-bootstrap3.coffee +0 -2
  115. data/lib/assets/javascripts/unpoly.coffee +0 -28
  116. data/lib/assets/stylesheets/unpoly/close.sass +0 -2
  117. data/lib/assets/stylesheets/unpoly/dom.sass +0 -5
  118. data/lib/assets/stylesheets/unpoly/layout.sass +0 -2
  119. data/lib/assets/stylesheets/unpoly/link.sass +0 -2
  120. data/lib/assets/stylesheets/unpoly/modal.sass +0 -116
  121. data/lib/assets/stylesheets/unpoly/popup.sass +0 -7
  122. data/lib/assets/stylesheets/unpoly/toast.sass +0 -33
  123. data/lib/assets/stylesheets/unpoly/tooltip.sass +0 -62
  124. data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
  125. data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
  126. data/lib/assets/stylesheets/unpoly.sass +0 -1
  127. data/lib/unpoly/rails/inspector.rb +0 -149
  128. data/lib/unpoly/rails/inspector_accessor.rb +0 -30
  129. data/package.json +0 -38
  130. data/spec_app/.firefox-version +0 -1
  131. data/spec_app/.gitignore +0 -17
  132. data/spec_app/.rspec +0 -2
  133. data/spec_app/Gemfile +0 -29
  134. data/spec_app/Gemfile.lock +0 -223
  135. data/spec_app/README.rdoc +0 -28
  136. data/spec_app/Rakefile +0 -6
  137. data/spec_app/app/assets/images/.keep +0 -0
  138. data/spec_app/app/assets/images/favicon.png +0 -0
  139. data/spec_app/app/assets/images/grid.png +0 -0
  140. data/spec_app/app/assets/javascripts/bootstrap_manifest.coffee +0 -6
  141. data/spec_app/app/assets/javascripts/integration_test.coffee +0 -5
  142. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +0 -6
  143. data/spec_app/app/assets/stylesheets/_helpers.sass +0 -5
  144. data/spec_app/app/assets/stylesheets/bootstrap_manifest.sass +0 -2
  145. data/spec_app/app/assets/stylesheets/integration_test.sass +0 -88
  146. data/spec_app/app/assets/stylesheets/jasmine_specs.sass +0 -20
  147. data/spec_app/app/controllers/application_controller.rb +0 -14
  148. data/spec_app/app/controllers/binding_test_controller.rb +0 -51
  149. data/spec_app/app/controllers/boot_test_controller.rb +0 -31
  150. data/spec_app/app/controllers/compiler_test_controller.rb +0 -5
  151. data/spec_app/app/controllers/css_test_controller.rb +0 -5
  152. data/spec_app/app/controllers/error_test_controller.rb +0 -5
  153. data/spec_app/app/controllers/form_test/basics_controller.rb +0 -14
  154. data/spec_app/app/controllers/form_test/redirects_controller.rb +0 -17
  155. data/spec_app/app/controllers/form_test/uploads_controller.rb +0 -15
  156. data/spec_app/app/controllers/hash_test_controller.rb +0 -5
  157. data/spec_app/app/controllers/method_test_controller.rb +0 -16
  158. data/spec_app/app/controllers/motion_test_controller.rb +0 -5
  159. data/spec_app/app/controllers/pages_controller.rb +0 -17
  160. data/spec_app/app/controllers/replace_test_controller.rb +0 -5
  161. data/spec_app/app/controllers/reveal_test_controller.rb +0 -5
  162. data/spec_app/app/controllers/scroll_test_controller.rb +0 -5
  163. data/spec_app/app/helpers/application_helper.rb +0 -11
  164. data/spec_app/app/mailers/.keep +0 -0
  165. data/spec_app/app/models/concerns/.keep +0 -0
  166. data/spec_app/app/views/boot_test/defer.erb +0 -18
  167. data/spec_app/app/views/boot_test/module.erb +0 -18
  168. data/spec_app/app/views/boot_test/sync.erb +0 -17
  169. data/spec_app/app/views/compiler_test/timestamp.erb +0 -10
  170. data/spec_app/app/views/css_test/modal.erb +0 -47
  171. data/spec_app/app/views/css_test/modal_contents.erb +0 -5
  172. data/spec_app/app/views/css_test/modal_contents_wide.erb +0 -5
  173. data/spec_app/app/views/css_test/popup.erb +0 -81
  174. data/spec_app/app/views/css_test/popup_contents.erb +0 -5
  175. data/spec_app/app/views/css_test/tooltip.erb +0 -48
  176. data/spec_app/app/views/error_test/trigger.erb +0 -80
  177. data/spec_app/app/views/error_test/unexpected_response.erb +0 -3
  178. data/spec_app/app/views/form_test/basics/new.erb +0 -60
  179. data/spec_app/app/views/form_test/redirects/new.erb +0 -27
  180. data/spec_app/app/views/form_test/redirects/target.erb +0 -6
  181. data/spec_app/app/views/form_test/submission_result.erb +0 -30
  182. data/spec_app/app/views/form_test/uploads/new.erb +0 -44
  183. data/spec_app/app/views/hash_test/unpoly.erb +0 -30
  184. data/spec_app/app/views/hash_test/vanilla.erb +0 -13
  185. data/spec_app/app/views/layouts/integration_test.erb +0 -22
  186. data/spec_app/app/views/layouts/jasmine_rails/spec_runner.html.erb +0 -20
  187. data/spec_app/app/views/method_test/form_target.erb +0 -17
  188. data/spec_app/app/views/method_test/page1.erb +0 -11
  189. data/spec_app/app/views/method_test/page2.erb +0 -6
  190. data/spec_app/app/views/motion_test/animations.erb +0 -16
  191. data/spec_app/app/views/motion_test/transitions.erb +0 -13
  192. data/spec_app/app/views/pages/start.erb +0 -82
  193. data/spec_app/app/views/replace_test/_nav.erb +0 -6
  194. data/spec_app/app/views/replace_test/page1.erb +0 -14
  195. data/spec_app/app/views/replace_test/page2.erb +0 -14
  196. data/spec_app/app/views/replace_test/table.erb +0 -16
  197. data/spec_app/app/views/reveal_test/long1.erb +0 -17
  198. data/spec_app/app/views/reveal_test/long2.erb +0 -17
  199. data/spec_app/app/views/reveal_test/within_document_viewport.erb +0 -24
  200. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +0 -28
  201. data/spec_app/app/views/scroll_test/long1.erb +0 -30
  202. data/spec_app/bin/bundle +0 -3
  203. data/spec_app/bin/rails +0 -8
  204. data/spec_app/bin/rake +0 -8
  205. data/spec_app/bin/setup +0 -29
  206. data/spec_app/bin/spring +0 -18
  207. data/spec_app/config/application.rb +0 -28
  208. data/spec_app/config/boot.rb +0 -3
  209. data/spec_app/config/database.yml +0 -25
  210. data/spec_app/config/environment.rb +0 -5
  211. data/spec_app/config/environments/development.rb +0 -41
  212. data/spec_app/config/environments/production.rb +0 -79
  213. data/spec_app/config/environments/test.rb +0 -42
  214. data/spec_app/config/initializers/assets.rb +0 -19
  215. data/spec_app/config/initializers/backtrace_silencers.rb +0 -7
  216. data/spec_app/config/initializers/bower_rails.rb +0 -16
  217. data/spec_app/config/initializers/cookies_serializer.rb +0 -3
  218. data/spec_app/config/initializers/filter_parameter_logging.rb +0 -4
  219. data/spec_app/config/initializers/inflections.rb +0 -16
  220. data/spec_app/config/initializers/mime_types.rb +0 -4
  221. data/spec_app/config/initializers/session_store.rb +0 -3
  222. data/spec_app/config/initializers/wrap_parameters.rb +0 -14
  223. data/spec_app/config/locales/en.yml +0 -23
  224. data/spec_app/config/routes.rb +0 -33
  225. data/spec_app/config/secrets.yml +0 -22
  226. data/spec_app/config.ru +0 -4
  227. data/spec_app/db/schema.rb +0 -23
  228. data/spec_app/db/seeds.rb +0 -7
  229. data/spec_app/lib/assets/.keep +0 -0
  230. data/spec_app/lib/tasks/.keep +0 -0
  231. data/spec_app/lib/tasks/cucumber.rake +0 -65
  232. data/spec_app/log/.keep +0 -0
  233. data/spec_app/public/404.html +0 -67
  234. data/spec_app/public/422.html +0 -67
  235. data/spec_app/public/500.html +0 -66
  236. data/spec_app/public/favicon.ico +0 -0
  237. data/spec_app/public/robots.txt +0 -5
  238. data/spec_app/script/cucumber +0 -10
  239. data/spec_app/spec/controllers/binding_test_controller_spec.rb +0 -248
  240. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +0 -20
  241. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +0 -103
  242. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +0 -21
  243. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +0 -2
  244. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +0 -25
  245. data/spec_app/spec/javascripts/helpers/index.js.coffee +0 -1
  246. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +0 -1
  247. data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -69
  248. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +0 -25
  249. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +0 -8
  250. data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +0 -2
  251. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +0 -24
  252. data/spec_app/spec/javascripts/helpers/promise_state.js +0 -18
  253. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +0 -12
  254. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +0 -8
  255. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +0 -23
  256. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +0 -2
  257. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +0 -25
  258. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +0 -5
  259. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +0 -12
  260. data/spec_app/spec/javascripts/helpers/spec_util.coffee +0 -47
  261. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +0 -8
  262. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +0 -5
  263. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +0 -9
  264. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +0 -8
  265. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +0 -9
  266. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +0 -8
  267. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +0 -8
  268. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +0 -8
  269. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +0 -8
  270. data/spec_app/spec/javascripts/helpers/to_be_jquery.js.coffee +0 -5
  271. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +0 -8
  272. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +0 -8
  273. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +0 -11
  274. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +0 -9
  275. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +0 -8
  276. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +0 -11
  277. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +0 -8
  278. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +0 -7
  279. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +0 -7
  280. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +0 -10
  281. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +0 -10
  282. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +0 -8
  283. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +0 -15
  284. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +0 -8
  285. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +0 -16
  286. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +0 -9
  287. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -18
  288. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +0 -14
  289. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +0 -8
  290. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +0 -13
  291. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +0 -14
  292. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +0 -200
  293. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +0 -5
  294. data/spec_app/spec/javascripts/support/jasmine.yml +0 -51
  295. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +0 -150
  296. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +0 -82
  297. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +0 -24
  298. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +0 -45
  299. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +0 -34
  300. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +0 -557
  301. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +0 -50
  302. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +0 -51
  303. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +0 -70
  304. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +0 -114
  305. data/spec_app/spec/javascripts/up/element_spec.coffee +0 -897
  306. data/spec_app/spec/javascripts/up/event_spec.js.coffee +0 -530
  307. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +0 -401
  308. data/spec_app/spec/javascripts/up/form_spec.js.coffee +0 -1527
  309. data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +0 -2624
  310. data/spec_app/spec/javascripts/up/history_spec.js.coffee +0 -340
  311. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +0 -4
  312. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +0 -27
  313. data/spec_app/spec/javascripts/up/link_spec.js.coffee +0 -1098
  314. data/spec_app/spec/javascripts/up/log_spec.js.coffee +0 -119
  315. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +0 -939
  316. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +0 -582
  317. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +0 -508
  318. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +0 -39
  319. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +0 -1145
  320. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +0 -212
  321. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +0 -118
  322. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +0 -9
  323. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +0 -304
  324. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +0 -37
  325. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +0 -163
  326. data/spec_app/spec/javascripts/up/util_spec.js.coffee +0 -1434
  327. data/spec_app/spec/javascripts/up/viewport_spec.js.coffee +0 -655
  328. data/spec_app/spec/spec_helper.rb +0 -62
  329. data/spec_app/test/controllers/.keep +0 -0
  330. data/spec_app/test/fixtures/.keep +0 -0
  331. data/spec_app/test/helpers/.keep +0 -0
  332. data/spec_app/test/integration/.keep +0 -0
  333. data/spec_app/test/mailers/.keep +0 -0
  334. data/spec_app/test/models/.keep +0 -0
  335. data/spec_app/test/test_helper.rb +0 -10
  336. data/spec_app/vendor/asset-libs/es6-promise-4.1.6/es6-promise.auto.js +0 -1159
  337. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.bower.json +0 -43
  338. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +0 -6
  339. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +0 -10
  340. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +0 -6
  341. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +0 -56
  342. data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js +0 -790
  343. data/spec_app/vendor/assets/.keep +0 -0
  344. data/unpoly-rails.gemspec +0 -24
@@ -1,1159 +0,0 @@
1
- /*!
2
- * @overview es6-promise - a tiny implementation of Promises/A+.
3
- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
4
- * @license Licensed under MIT license
5
- * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
6
- * @version 4.1.0+f046478d
7
- */
8
-
9
- (function (global, factory) {
10
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
11
- typeof define === 'function' && define.amd ? define(factory) :
12
- (global.ES6Promise = factory());
13
- }(this, (function () { 'use strict';
14
-
15
- function objectOrFunction(x) {
16
- var type = typeof x;
17
- return x !== null && (type === 'object' || type === 'function');
18
- }
19
-
20
- function isFunction(x) {
21
- return typeof x === 'function';
22
- }
23
-
24
- var _isArray = undefined;
25
- if (Array.isArray) {
26
- _isArray = Array.isArray;
27
- } else {
28
- _isArray = function (x) {
29
- return Object.prototype.toString.call(x) === '[object Array]';
30
- };
31
- }
32
-
33
- var isArray = _isArray;
34
-
35
- var len = 0;
36
- var vertxNext = undefined;
37
- var customSchedulerFn = undefined;
38
-
39
- var asap = function asap(callback, arg) {
40
- queue[len] = callback;
41
- queue[len + 1] = arg;
42
- len += 2;
43
- if (len === 2) {
44
- // If len is 2, that means that we need to schedule an async flush.
45
- // If additional callbacks are queued before the queue is flushed, they
46
- // will be processed by this flush that we are scheduling.
47
- if (customSchedulerFn) {
48
- customSchedulerFn(flush);
49
- } else {
50
- scheduleFlush();
51
- }
52
- }
53
- };
54
-
55
- function setScheduler(scheduleFn) {
56
- customSchedulerFn = scheduleFn;
57
- }
58
-
59
- function setAsap(asapFn) {
60
- asap = asapFn;
61
- }
62
-
63
- var browserWindow = typeof window !== 'undefined' ? window : undefined;
64
- var browserGlobal = browserWindow || {};
65
- var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
66
- var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
67
-
68
- // test for web worker but not in IE10
69
- var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
70
-
71
- // node
72
- function useNextTick() {
73
- // node version 0.10.x displays a deprecation warning when nextTick is used recursively
74
- // see https://github.com/cujojs/when/issues/410 for details
75
- return function () {
76
- return process.nextTick(flush);
77
- };
78
- }
79
-
80
- // vertx
81
- function useVertxTimer() {
82
- if (typeof vertxNext !== 'undefined') {
83
- return function () {
84
- vertxNext(flush);
85
- };
86
- }
87
-
88
- return useSetTimeout();
89
- }
90
-
91
- function useMutationObserver() {
92
- var iterations = 0;
93
- var observer = new BrowserMutationObserver(flush);
94
- var node = document.createTextNode('');
95
- observer.observe(node, { characterData: true });
96
-
97
- return function () {
98
- node.data = iterations = ++iterations % 2;
99
- };
100
- }
101
-
102
- // web worker
103
- function useMessageChannel() {
104
- var channel = new MessageChannel();
105
- channel.port1.onmessage = flush;
106
- return function () {
107
- return channel.port2.postMessage(0);
108
- };
109
- }
110
-
111
- function useSetTimeout() {
112
- // Store setTimeout reference so es6-promise will be unaffected by
113
- // other code modifying setTimeout (like sinon.useFakeTimers())
114
- var globalSetTimeout = setTimeout;
115
- return function () {
116
- return globalSetTimeout(flush, 1);
117
- };
118
- }
119
-
120
- var queue = new Array(1000);
121
- function flush() {
122
- for (var i = 0; i < len; i += 2) {
123
- var callback = queue[i];
124
- var arg = queue[i + 1];
125
-
126
- callback(arg);
127
-
128
- queue[i] = undefined;
129
- queue[i + 1] = undefined;
130
- }
131
-
132
- len = 0;
133
- }
134
-
135
- function attemptVertx() {
136
- try {
137
- var r = require;
138
- var vertx = r('vertx');
139
- vertxNext = vertx.runOnLoop || vertx.runOnContext;
140
- return useVertxTimer();
141
- } catch (e) {
142
- return useSetTimeout();
143
- }
144
- }
145
-
146
- var scheduleFlush = undefined;
147
- // Decide what async method to use to triggering processing of queued callbacks:
148
- if (isNode) {
149
- scheduleFlush = useNextTick();
150
- } else if (BrowserMutationObserver) {
151
- scheduleFlush = useMutationObserver();
152
- } else if (isWorker) {
153
- scheduleFlush = useMessageChannel();
154
- } else if (browserWindow === undefined && typeof require === 'function') {
155
- scheduleFlush = attemptVertx();
156
- } else {
157
- scheduleFlush = useSetTimeout();
158
- }
159
-
160
- function then(onFulfillment, onRejection) {
161
- var _arguments = arguments;
162
-
163
- var parent = this;
164
-
165
- var child = new this.constructor(noop);
166
-
167
- if (child[PROMISE_ID] === undefined) {
168
- makePromise(child);
169
- }
170
-
171
- var _state = parent._state;
172
-
173
- if (_state) {
174
- (function () {
175
- var callback = _arguments[_state - 1];
176
- asap(function () {
177
- return invokeCallback(_state, child, callback, parent._result);
178
- });
179
- })();
180
- } else {
181
- subscribe(parent, child, onFulfillment, onRejection);
182
- }
183
-
184
- return child;
185
- }
186
-
187
- /**
188
- `Promise.resolve` returns a promise that will become resolved with the
189
- passed `value`. It is shorthand for the following:
190
-
191
- ```javascript
192
- let promise = new Promise(function(resolve, reject){
193
- resolve(1);
194
- });
195
-
196
- promise.then(function(value){
197
- // value === 1
198
- });
199
- ```
200
-
201
- Instead of writing the above, your code now simply becomes the following:
202
-
203
- ```javascript
204
- let promise = Promise.resolve(1);
205
-
206
- promise.then(function(value){
207
- // value === 1
208
- });
209
- ```
210
-
211
- @method resolve
212
- @static
213
- @param {Any} value value that the returned promise will be resolved with
214
- Useful for tooling.
215
- @return {Promise} a promise that will become fulfilled with the given
216
- `value`
217
- */
218
- function resolve$1(object) {
219
- /*jshint validthis:true */
220
- var Constructor = this;
221
-
222
- if (object && typeof object === 'object' && object.constructor === Constructor) {
223
- return object;
224
- }
225
-
226
- var promise = new Constructor(noop);
227
- resolve(promise, object);
228
- return promise;
229
- }
230
-
231
- var PROMISE_ID = Math.random().toString(36).substring(16);
232
-
233
- function noop() {}
234
-
235
- var PENDING = void 0;
236
- var FULFILLED = 1;
237
- var REJECTED = 2;
238
-
239
- var GET_THEN_ERROR = new ErrorObject();
240
-
241
- function selfFulfillment() {
242
- return new TypeError("You cannot resolve a promise with itself");
243
- }
244
-
245
- function cannotReturnOwn() {
246
- return new TypeError('A promises callback cannot return that same promise.');
247
- }
248
-
249
- function getThen(promise) {
250
- try {
251
- return promise.then;
252
- } catch (error) {
253
- GET_THEN_ERROR.error = error;
254
- return GET_THEN_ERROR;
255
- }
256
- }
257
-
258
- function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
259
- try {
260
- then$$1.call(value, fulfillmentHandler, rejectionHandler);
261
- } catch (e) {
262
- return e;
263
- }
264
- }
265
-
266
- function handleForeignThenable(promise, thenable, then$$1) {
267
- asap(function (promise) {
268
- var sealed = false;
269
- var error = tryThen(then$$1, thenable, function (value) {
270
- if (sealed) {
271
- return;
272
- }
273
- sealed = true;
274
- if (thenable !== value) {
275
- resolve(promise, value);
276
- } else {
277
- fulfill(promise, value);
278
- }
279
- }, function (reason) {
280
- if (sealed) {
281
- return;
282
- }
283
- sealed = true;
284
-
285
- reject(promise, reason);
286
- }, 'Settle: ' + (promise._label || ' unknown promise'));
287
-
288
- if (!sealed && error) {
289
- sealed = true;
290
- reject(promise, error);
291
- }
292
- }, promise);
293
- }
294
-
295
- function handleOwnThenable(promise, thenable) {
296
- if (thenable._state === FULFILLED) {
297
- fulfill(promise, thenable._result);
298
- } else if (thenable._state === REJECTED) {
299
- reject(promise, thenable._result);
300
- } else {
301
- subscribe(thenable, undefined, function (value) {
302
- return resolve(promise, value);
303
- }, function (reason) {
304
- return reject(promise, reason);
305
- });
306
- }
307
- }
308
-
309
- function handleMaybeThenable(promise, maybeThenable, then$$1) {
310
- if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
311
- handleOwnThenable(promise, maybeThenable);
312
- } else {
313
- if (then$$1 === GET_THEN_ERROR) {
314
- reject(promise, GET_THEN_ERROR.error);
315
- GET_THEN_ERROR.error = null;
316
- } else if (then$$1 === undefined) {
317
- fulfill(promise, maybeThenable);
318
- } else if (isFunction(then$$1)) {
319
- handleForeignThenable(promise, maybeThenable, then$$1);
320
- } else {
321
- fulfill(promise, maybeThenable);
322
- }
323
- }
324
- }
325
-
326
- function resolve(promise, value) {
327
- if (promise === value) {
328
- reject(promise, selfFulfillment());
329
- } else if (objectOrFunction(value)) {
330
- handleMaybeThenable(promise, value, getThen(value));
331
- } else {
332
- fulfill(promise, value);
333
- }
334
- }
335
-
336
- function publishRejection(promise) {
337
- if (promise._onerror) {
338
- promise._onerror(promise._result);
339
- }
340
-
341
- publish(promise);
342
- }
343
-
344
- function fulfill(promise, value) {
345
- if (promise._state !== PENDING) {
346
- return;
347
- }
348
-
349
- promise._result = value;
350
- promise._state = FULFILLED;
351
-
352
- if (promise._subscribers.length !== 0) {
353
- asap(publish, promise);
354
- }
355
- }
356
-
357
- function reject(promise, reason) {
358
- if (promise._state !== PENDING) {
359
- return;
360
- }
361
- promise._state = REJECTED;
362
- promise._result = reason;
363
-
364
- asap(publishRejection, promise);
365
- }
366
-
367
- function subscribe(parent, child, onFulfillment, onRejection) {
368
- var _subscribers = parent._subscribers;
369
- var length = _subscribers.length;
370
-
371
- parent._onerror = null;
372
-
373
- _subscribers[length] = child;
374
- _subscribers[length + FULFILLED] = onFulfillment;
375
- _subscribers[length + REJECTED] = onRejection;
376
-
377
- if (length === 0 && parent._state) {
378
- asap(publish, parent);
379
- }
380
- }
381
-
382
- function publish(promise) {
383
- var subscribers = promise._subscribers;
384
- var settled = promise._state;
385
-
386
- if (subscribers.length === 0) {
387
- return;
388
- }
389
-
390
- var child = undefined,
391
- callback = undefined,
392
- detail = promise._result;
393
-
394
- for (var i = 0; i < subscribers.length; i += 3) {
395
- child = subscribers[i];
396
- callback = subscribers[i + settled];
397
-
398
- if (child) {
399
- invokeCallback(settled, child, callback, detail);
400
- } else {
401
- callback(detail);
402
- }
403
- }
404
-
405
- promise._subscribers.length = 0;
406
- }
407
-
408
- function ErrorObject() {
409
- this.error = null;
410
- }
411
-
412
- var TRY_CATCH_ERROR = new ErrorObject();
413
-
414
- function tryCatch(callback, detail) {
415
- try {
416
- return callback(detail);
417
- } catch (e) {
418
- TRY_CATCH_ERROR.error = e;
419
- return TRY_CATCH_ERROR;
420
- }
421
- }
422
-
423
- function invokeCallback(settled, promise, callback, detail) {
424
- var hasCallback = isFunction(callback),
425
- value = undefined,
426
- error = undefined,
427
- succeeded = undefined,
428
- failed = undefined;
429
-
430
- if (hasCallback) {
431
- value = tryCatch(callback, detail);
432
-
433
- if (value === TRY_CATCH_ERROR) {
434
- failed = true;
435
- error = value.error;
436
- value.error = null;
437
- } else {
438
- succeeded = true;
439
- }
440
-
441
- if (promise === value) {
442
- reject(promise, cannotReturnOwn());
443
- return;
444
- }
445
- } else {
446
- value = detail;
447
- succeeded = true;
448
- }
449
-
450
- if (promise._state !== PENDING) {
451
- // noop
452
- } else if (hasCallback && succeeded) {
453
- resolve(promise, value);
454
- } else if (failed) {
455
- reject(promise, error);
456
- } else if (settled === FULFILLED) {
457
- fulfill(promise, value);
458
- } else if (settled === REJECTED) {
459
- reject(promise, value);
460
- }
461
- }
462
-
463
- function initializePromise(promise, resolver) {
464
- try {
465
- resolver(function resolvePromise(value) {
466
- resolve(promise, value);
467
- }, function rejectPromise(reason) {
468
- reject(promise, reason);
469
- });
470
- } catch (e) {
471
- reject(promise, e);
472
- }
473
- }
474
-
475
- var id = 0;
476
- function nextId() {
477
- return id++;
478
- }
479
-
480
- function makePromise(promise) {
481
- promise[PROMISE_ID] = id++;
482
- promise._state = undefined;
483
- promise._result = undefined;
484
- promise._subscribers = [];
485
- }
486
-
487
- function Enumerator$1(Constructor, input) {
488
- this._instanceConstructor = Constructor;
489
- this.promise = new Constructor(noop);
490
-
491
- if (!this.promise[PROMISE_ID]) {
492
- makePromise(this.promise);
493
- }
494
-
495
- if (isArray(input)) {
496
- this.length = input.length;
497
- this._remaining = input.length;
498
-
499
- this._result = new Array(this.length);
500
-
501
- if (this.length === 0) {
502
- fulfill(this.promise, this._result);
503
- } else {
504
- this.length = this.length || 0;
505
- this._enumerate(input);
506
- if (this._remaining === 0) {
507
- fulfill(this.promise, this._result);
508
- }
509
- }
510
- } else {
511
- reject(this.promise, validationError());
512
- }
513
- }
514
-
515
- function validationError() {
516
- return new Error('Array Methods must be provided an Array');
517
- }
518
-
519
- Enumerator$1.prototype._enumerate = function (input) {
520
- for (var i = 0; this._state === PENDING && i < input.length; i++) {
521
- this._eachEntry(input[i], i);
522
- }
523
- };
524
-
525
- Enumerator$1.prototype._eachEntry = function (entry, i) {
526
- var c = this._instanceConstructor;
527
- var resolve$$1 = c.resolve;
528
-
529
- if (resolve$$1 === resolve$1) {
530
- var _then = getThen(entry);
531
-
532
- if (_then === then && entry._state !== PENDING) {
533
- this._settledAt(entry._state, i, entry._result);
534
- } else if (typeof _then !== 'function') {
535
- this._remaining--;
536
- this._result[i] = entry;
537
- } else if (c === Promise$3) {
538
- var promise = new c(noop);
539
- handleMaybeThenable(promise, entry, _then);
540
- this._willSettleAt(promise, i);
541
- } else {
542
- this._willSettleAt(new c(function (resolve$$1) {
543
- return resolve$$1(entry);
544
- }), i);
545
- }
546
- } else {
547
- this._willSettleAt(resolve$$1(entry), i);
548
- }
549
- };
550
-
551
- Enumerator$1.prototype._settledAt = function (state, i, value) {
552
- var promise = this.promise;
553
-
554
- if (promise._state === PENDING) {
555
- this._remaining--;
556
-
557
- if (state === REJECTED) {
558
- reject(promise, value);
559
- } else {
560
- this._result[i] = value;
561
- }
562
- }
563
-
564
- if (this._remaining === 0) {
565
- fulfill(promise, this._result);
566
- }
567
- };
568
-
569
- Enumerator$1.prototype._willSettleAt = function (promise, i) {
570
- var enumerator = this;
571
-
572
- subscribe(promise, undefined, function (value) {
573
- return enumerator._settledAt(FULFILLED, i, value);
574
- }, function (reason) {
575
- return enumerator._settledAt(REJECTED, i, reason);
576
- });
577
- };
578
-
579
- /**
580
- `Promise.all` accepts an array of promises, and returns a new promise which
581
- is fulfilled with an array of fulfillment values for the passed promises, or
582
- rejected with the reason of the first passed promise to be rejected. It casts all
583
- elements of the passed iterable to promises as it runs this algorithm.
584
-
585
- Example:
586
-
587
- ```javascript
588
- let promise1 = resolve(1);
589
- let promise2 = resolve(2);
590
- let promise3 = resolve(3);
591
- let promises = [ promise1, promise2, promise3 ];
592
-
593
- Promise.all(promises).then(function(array){
594
- // The array here would be [ 1, 2, 3 ];
595
- });
596
- ```
597
-
598
- If any of the `promises` given to `all` are rejected, the first promise
599
- that is rejected will be given as an argument to the returned promises's
600
- rejection handler. For example:
601
-
602
- Example:
603
-
604
- ```javascript
605
- let promise1 = resolve(1);
606
- let promise2 = reject(new Error("2"));
607
- let promise3 = reject(new Error("3"));
608
- let promises = [ promise1, promise2, promise3 ];
609
-
610
- Promise.all(promises).then(function(array){
611
- // Code here never runs because there are rejected promises!
612
- }, function(error) {
613
- // error.message === "2"
614
- });
615
- ```
616
-
617
- @method all
618
- @static
619
- @param {Array} entries array of promises
620
- @param {String} label optional string for labeling the promise.
621
- Useful for tooling.
622
- @return {Promise} promise that is fulfilled when all `promises` have been
623
- fulfilled, or rejected if any of them become rejected.
624
- @static
625
- */
626
- function all$1(entries) {
627
- return new Enumerator$1(this, entries).promise;
628
- }
629
-
630
- /**
631
- `Promise.race` returns a new promise which is settled in the same way as the
632
- first passed promise to settle.
633
-
634
- Example:
635
-
636
- ```javascript
637
- let promise1 = new Promise(function(resolve, reject){
638
- setTimeout(function(){
639
- resolve('promise 1');
640
- }, 200);
641
- });
642
-
643
- let promise2 = new Promise(function(resolve, reject){
644
- setTimeout(function(){
645
- resolve('promise 2');
646
- }, 100);
647
- });
648
-
649
- Promise.race([promise1, promise2]).then(function(result){
650
- // result === 'promise 2' because it was resolved before promise1
651
- // was resolved.
652
- });
653
- ```
654
-
655
- `Promise.race` is deterministic in that only the state of the first
656
- settled promise matters. For example, even if other promises given to the
657
- `promises` array argument are resolved, but the first settled promise has
658
- become rejected before the other promises became fulfilled, the returned
659
- promise will become rejected:
660
-
661
- ```javascript
662
- let promise1 = new Promise(function(resolve, reject){
663
- setTimeout(function(){
664
- resolve('promise 1');
665
- }, 200);
666
- });
667
-
668
- let promise2 = new Promise(function(resolve, reject){
669
- setTimeout(function(){
670
- reject(new Error('promise 2'));
671
- }, 100);
672
- });
673
-
674
- Promise.race([promise1, promise2]).then(function(result){
675
- // Code here never runs
676
- }, function(reason){
677
- // reason.message === 'promise 2' because promise 2 became rejected before
678
- // promise 1 became fulfilled
679
- });
680
- ```
681
-
682
- An example real-world use case is implementing timeouts:
683
-
684
- ```javascript
685
- Promise.race([ajax('foo.json'), timeout(5000)])
686
- ```
687
-
688
- @method race
689
- @static
690
- @param {Array} promises array of promises to observe
691
- Useful for tooling.
692
- @return {Promise} a promise which settles in the same way as the first passed
693
- promise to settle.
694
- */
695
- function race$1(entries) {
696
- /*jshint validthis:true */
697
- var Constructor = this;
698
-
699
- if (!isArray(entries)) {
700
- return new Constructor(function (_, reject) {
701
- return reject(new TypeError('You must pass an array to race.'));
702
- });
703
- } else {
704
- return new Constructor(function (resolve, reject) {
705
- var length = entries.length;
706
- for (var i = 0; i < length; i++) {
707
- Constructor.resolve(entries[i]).then(resolve, reject);
708
- }
709
- });
710
- }
711
- }
712
-
713
- /**
714
- `Promise.reject` returns a promise rejected with the passed `reason`.
715
- It is shorthand for the following:
716
-
717
- ```javascript
718
- let promise = new Promise(function(resolve, reject){
719
- reject(new Error('WHOOPS'));
720
- });
721
-
722
- promise.then(function(value){
723
- // Code here doesn't run because the promise is rejected!
724
- }, function(reason){
725
- // reason.message === 'WHOOPS'
726
- });
727
- ```
728
-
729
- Instead of writing the above, your code now simply becomes the following:
730
-
731
- ```javascript
732
- let promise = Promise.reject(new Error('WHOOPS'));
733
-
734
- promise.then(function(value){
735
- // Code here doesn't run because the promise is rejected!
736
- }, function(reason){
737
- // reason.message === 'WHOOPS'
738
- });
739
- ```
740
-
741
- @method reject
742
- @static
743
- @param {Any} reason value that the returned promise will be rejected with.
744
- Useful for tooling.
745
- @return {Promise} a promise rejected with the given `reason`.
746
- */
747
- function reject$1(reason) {
748
- /*jshint validthis:true */
749
- var Constructor = this;
750
- var promise = new Constructor(noop);
751
- reject(promise, reason);
752
- return promise;
753
- }
754
-
755
- function needsResolver() {
756
- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
757
- }
758
-
759
- function needsNew() {
760
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
761
- }
762
-
763
- /**
764
- Promise objects represent the eventual result of an asynchronous operation. The
765
- primary way of interacting with a promise is through its `then` method, which
766
- registers callbacks to receive either a promise's eventual value or the reason
767
- why the promise cannot be fulfilled.
768
-
769
- Terminology
770
- -----------
771
-
772
- - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
773
- - `thenable` is an object or function that defines a `then` method.
774
- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
775
- - `exception` is a value that is thrown using the throw statement.
776
- - `reason` is a value that indicates why a promise was rejected.
777
- - `settled` the final resting state of a promise, fulfilled or rejected.
778
-
779
- A promise can be in one of three states: pending, fulfilled, or rejected.
780
-
781
- Promises that are fulfilled have a fulfillment value and are in the fulfilled
782
- state. Promises that are rejected have a rejection reason and are in the
783
- rejected state. A fulfillment value is never a thenable.
784
-
785
- Promises can also be said to *resolve* a value. If this value is also a
786
- promise, then the original promise's settled state will match the value's
787
- settled state. So a promise that *resolves* a promise that rejects will
788
- itself reject, and a promise that *resolves* a promise that fulfills will
789
- itself fulfill.
790
-
791
-
792
- Basic Usage:
793
- ------------
794
-
795
- ```js
796
- let promise = new Promise(function(resolve, reject) {
797
- // on success
798
- resolve(value);
799
-
800
- // on failure
801
- reject(reason);
802
- });
803
-
804
- promise.then(function(value) {
805
- // on fulfillment
806
- }, function(reason) {
807
- // on rejection
808
- });
809
- ```
810
-
811
- Advanced Usage:
812
- ---------------
813
-
814
- Promises shine when abstracting away asynchronous interactions such as
815
- `XMLHttpRequest`s.
816
-
817
- ```js
818
- function getJSON(url) {
819
- return new Promise(function(resolve, reject){
820
- let xhr = new XMLHttpRequest();
821
-
822
- xhr.open('GET', url);
823
- xhr.onreadystatechange = handler;
824
- xhr.responseType = 'json';
825
- xhr.setRequestHeader('Accept', 'application/json');
826
- xhr.send();
827
-
828
- function handler() {
829
- if (this.readyState === this.DONE) {
830
- if (this.status === 200) {
831
- resolve(this.response);
832
- } else {
833
- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
834
- }
835
- }
836
- };
837
- });
838
- }
839
-
840
- getJSON('/posts.json').then(function(json) {
841
- // on fulfillment
842
- }, function(reason) {
843
- // on rejection
844
- });
845
- ```
846
-
847
- Unlike callbacks, promises are great composable primitives.
848
-
849
- ```js
850
- Promise.all([
851
- getJSON('/posts'),
852
- getJSON('/comments')
853
- ]).then(function(values){
854
- values[0] // => postsJSON
855
- values[1] // => commentsJSON
856
-
857
- return values;
858
- });
859
- ```
860
-
861
- @class Promise
862
- @param {function} resolver
863
- Useful for tooling.
864
- @constructor
865
- */
866
- function Promise$3(resolver) {
867
- this[PROMISE_ID] = nextId();
868
- this._result = this._state = undefined;
869
- this._subscribers = [];
870
-
871
- if (noop !== resolver) {
872
- typeof resolver !== 'function' && needsResolver();
873
- this instanceof Promise$3 ? initializePromise(this, resolver) : needsNew();
874
- }
875
- }
876
-
877
- Promise$3.all = all$1;
878
- Promise$3.race = race$1;
879
- Promise$3.resolve = resolve$1;
880
- Promise$3.reject = reject$1;
881
- Promise$3._setScheduler = setScheduler;
882
- Promise$3._setAsap = setAsap;
883
- Promise$3._asap = asap;
884
-
885
- Promise$3.prototype = {
886
- constructor: Promise$3,
887
-
888
- /**
889
- The primary way of interacting with a promise is through its `then` method,
890
- which registers callbacks to receive either a promise's eventual value or the
891
- reason why the promise cannot be fulfilled.
892
-
893
- ```js
894
- findUser().then(function(user){
895
- // user is available
896
- }, function(reason){
897
- // user is unavailable, and you are given the reason why
898
- });
899
- ```
900
-
901
- Chaining
902
- --------
903
-
904
- The return value of `then` is itself a promise. This second, 'downstream'
905
- promise is resolved with the return value of the first promise's fulfillment
906
- or rejection handler, or rejected if the handler throws an exception.
907
-
908
- ```js
909
- findUser().then(function (user) {
910
- return user.name;
911
- }, function (reason) {
912
- return 'default name';
913
- }).then(function (userName) {
914
- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
915
- // will be `'default name'`
916
- });
917
-
918
- findUser().then(function (user) {
919
- throw new Error('Found user, but still unhappy');
920
- }, function (reason) {
921
- throw new Error('`findUser` rejected and we're unhappy');
922
- }).then(function (value) {
923
- // never reached
924
- }, function (reason) {
925
- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
926
- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
927
- });
928
- ```
929
- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
930
-
931
- ```js
932
- findUser().then(function (user) {
933
- throw new PedagogicalException('Upstream error');
934
- }).then(function (value) {
935
- // never reached
936
- }).then(function (value) {
937
- // never reached
938
- }, function (reason) {
939
- // The `PedgagocialException` is propagated all the way down to here
940
- });
941
- ```
942
-
943
- Assimilation
944
- ------------
945
-
946
- Sometimes the value you want to propagate to a downstream promise can only be
947
- retrieved asynchronously. This can be achieved by returning a promise in the
948
- fulfillment or rejection handler. The downstream promise will then be pending
949
- until the returned promise is settled. This is called *assimilation*.
950
-
951
- ```js
952
- findUser().then(function (user) {
953
- return findCommentsByAuthor(user);
954
- }).then(function (comments) {
955
- // The user's comments are now available
956
- });
957
- ```
958
-
959
- If the assimliated promise rejects, then the downstream promise will also reject.
960
-
961
- ```js
962
- findUser().then(function (user) {
963
- return findCommentsByAuthor(user);
964
- }).then(function (comments) {
965
- // If `findCommentsByAuthor` fulfills, we'll have the value here
966
- }, function (reason) {
967
- // If `findCommentsByAuthor` rejects, we'll have the reason here
968
- });
969
- ```
970
-
971
- Simple Example
972
- --------------
973
-
974
- Synchronous Example
975
-
976
- ```javascript
977
- let result;
978
-
979
- try {
980
- result = findResult();
981
- // success
982
- } catch(reason) {
983
- // failure
984
- }
985
- ```
986
-
987
- Errback Example
988
-
989
- ```js
990
- findResult(function(result, err){
991
- if (err) {
992
- // failure
993
- } else {
994
- // success
995
- }
996
- });
997
- ```
998
-
999
- Promise Example;
1000
-
1001
- ```javascript
1002
- findResult().then(function(result){
1003
- // success
1004
- }, function(reason){
1005
- // failure
1006
- });
1007
- ```
1008
-
1009
- Advanced Example
1010
- --------------
1011
-
1012
- Synchronous Example
1013
-
1014
- ```javascript
1015
- let author, books;
1016
-
1017
- try {
1018
- author = findAuthor();
1019
- books = findBooksByAuthor(author);
1020
- // success
1021
- } catch(reason) {
1022
- // failure
1023
- }
1024
- ```
1025
-
1026
- Errback Example
1027
-
1028
- ```js
1029
-
1030
- function foundBooks(books) {
1031
-
1032
- }
1033
-
1034
- function failure(reason) {
1035
-
1036
- }
1037
-
1038
- findAuthor(function(author, err){
1039
- if (err) {
1040
- failure(err);
1041
- // failure
1042
- } else {
1043
- try {
1044
- findBoooksByAuthor(author, function(books, err) {
1045
- if (err) {
1046
- failure(err);
1047
- } else {
1048
- try {
1049
- foundBooks(books);
1050
- } catch(reason) {
1051
- failure(reason);
1052
- }
1053
- }
1054
- });
1055
- } catch(error) {
1056
- failure(err);
1057
- }
1058
- // success
1059
- }
1060
- });
1061
- ```
1062
-
1063
- Promise Example;
1064
-
1065
- ```javascript
1066
- findAuthor().
1067
- then(findBooksByAuthor).
1068
- then(function(books){
1069
- // found books
1070
- }).catch(function(reason){
1071
- // something went wrong
1072
- });
1073
- ```
1074
-
1075
- @method then
1076
- @param {Function} onFulfilled
1077
- @param {Function} onRejected
1078
- Useful for tooling.
1079
- @return {Promise}
1080
- */
1081
- then: then,
1082
-
1083
- /**
1084
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
1085
- as the catch block of a try/catch statement.
1086
-
1087
- ```js
1088
- function findAuthor(){
1089
- throw new Error('couldn't find that author');
1090
- }
1091
-
1092
- // synchronous
1093
- try {
1094
- findAuthor();
1095
- } catch(reason) {
1096
- // something went wrong
1097
- }
1098
-
1099
- // async with promises
1100
- findAuthor().catch(function(reason){
1101
- // something went wrong
1102
- });
1103
- ```
1104
-
1105
- @method catch
1106
- @param {Function} onRejection
1107
- Useful for tooling.
1108
- @return {Promise}
1109
- */
1110
- 'catch': function _catch(onRejection) {
1111
- return this.then(null, onRejection);
1112
- }
1113
- };
1114
-
1115
- /*global self*/
1116
- function polyfill$1() {
1117
- var local = undefined;
1118
-
1119
- if (typeof global !== 'undefined') {
1120
- local = global;
1121
- } else if (typeof self !== 'undefined') {
1122
- local = self;
1123
- } else {
1124
- try {
1125
- local = Function('return this')();
1126
- } catch (e) {
1127
- throw new Error('polyfill failed because global object is unavailable in this environment');
1128
- }
1129
- }
1130
-
1131
- var P = local.Promise;
1132
-
1133
- if (P) {
1134
- var promiseToString = null;
1135
- try {
1136
- promiseToString = Object.prototype.toString.call(P.resolve());
1137
- } catch (e) {
1138
- // silently ignored
1139
- }
1140
-
1141
- if (promiseToString === '[object Promise]' && !P.cast) {
1142
- return;
1143
- }
1144
- }
1145
-
1146
- local.Promise = Promise$3;
1147
- }
1148
-
1149
- // Strange compat..
1150
- Promise$3.polyfill = polyfill$1;
1151
- Promise$3.Promise = Promise$3;
1152
-
1153
- Promise$3.polyfill();
1154
-
1155
- return Promise$3;
1156
-
1157
- })));
1158
-
1159
- //# sourceMappingURL=es6-promise.auto.map