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,1677 +0,0 @@
1
- ###**
2
- Utility functions
3
- =================
4
-
5
- The `up.util` module contains functions to facilitate the work with basic JavaScript
6
- values like lists, strings or functions.
7
-
8
- You will recognize many functions form other utility libraries like [Lodash](https://lodash.com/).
9
- While feature parity with Lodash is not a goal of `up.util`, you might find it sufficient
10
- to not include another library in your asset bundle.
11
-
12
- @module up.util
13
- ###
14
- up.util = do ->
15
-
16
- ###**
17
- A function that does nothing.
18
-
19
- @function up.util.noop
20
- @experimental
21
- ###
22
- noop = (->)
23
-
24
- ###**
25
- A function that returns a resolved promise.
26
-
27
- @function up.util.asyncNoop
28
- @internal
29
- ###
30
- asyncNoop = -> Promise.resolve()
31
-
32
- ###**
33
- Ensures that the given function can only be called a single time.
34
- Subsequent calls will return the return value of the first call.
35
-
36
- Note that this is a simple implementation that
37
- doesn't distinguish between argument lists.
38
-
39
- @function up.util.memoize
40
- @internal
41
- ###
42
- memoize = (func) ->
43
- cachedValue = undefined
44
- cached = false
45
- (args...) ->
46
- if cached
47
- cachedValue
48
- else
49
- cached = true
50
- cachedValue = func(args...)
51
-
52
- ###**
53
- Returns if the given port is the default port for the given protocol.
54
-
55
- @function up.util.isStandardPort
56
- @internal
57
- ###
58
- isStandardPort = (protocol, port) ->
59
- port = port.toString()
60
- ((port == "" || port == "80") && protocol == 'http:') || (port == "443" && protocol == 'https:')
61
-
62
- ###**
63
- Normalizes relative paths and absolute paths to a full URL
64
- that can be checked for equality with other normalized URLs.
65
-
66
- By default hashes are ignored, search queries are included.
67
-
68
- @function up.util.normalizeUrl
69
- @param {boolean} [options.hash=false]
70
- Whether to include an `#hash` anchor in the normalized URL
71
- @param {boolean} [options.search=true]
72
- Whether to include a `?query` string in the normalized URL
73
- @param {boolean} [options.stripTrailingSlash=false]
74
- Whether to strip a trailing slash from the pathname
75
- @internal
76
- ###
77
- normalizeUrl = (urlOrAnchor, options) ->
78
- parts = parseUrl(urlOrAnchor)
79
- normalized = parts.protocol + "//" + parts.hostname
80
- normalized += ":#{parts.port}" unless isStandardPort(parts.protocol, parts.port)
81
- pathname = parts.pathname
82
- pathname = pathname.replace(/\/$/, '') if options?.stripTrailingSlash == true
83
- normalized += pathname
84
- normalized += parts.search unless options?.search == false
85
- normalized += parts.hash if options?.hash == true
86
- normalized
87
-
88
- isCrossDomain = (targetUrl) ->
89
- currentUrl = parseUrl(location.href)
90
- targetUrl = parseUrl(targetUrl)
91
- currentUrl.protocol != targetUrl.protocol || currentUrl.hostname != targetUrl.hostname
92
-
93
- ###**
94
- Parses the given URL into components such as hostname and path.
95
-
96
- If the given URL is not fully qualified, it is assumed to be relative
97
- to the current page.
98
-
99
- @function up.util.parseUrl
100
- @return {Object}
101
- The parsed URL as an object with
102
- `protocol`, `hostname`, `port`, `pathname`, `search` and `hash`
103
- properties.
104
- @stable
105
- ###
106
- parseUrl = (urlOrLink) ->
107
- if isJQuery(urlOrLink)
108
- # In case someone passed us a $link, unwrap it
109
- link = up.element.get(urlOrLink)
110
- else if urlOrLink.pathname
111
- # If we are handed a parsed URL, just return it
112
- link = urlOrLink
113
- else
114
- link = document.createElement('a')
115
- link.href = urlOrLink
116
-
117
- # In IE11 the #hostname and #port properties of unqualified URLs are empty strings.
118
- # We can fix this by setting the link's { href } on the link itself.
119
- unless link.hostname
120
- link.href = link.href
121
-
122
- # Some IEs don't include a leading slash in the #pathname property.
123
- # We have confirmed this in IE11 and earlier.
124
- unless link.pathname[0] == '/'
125
- # Only copy the link into an object when we need to (to change a property).
126
- # Note that we're parsing a lot of URLs for [up-active].
127
- link = only(link, 'protocol', 'hostname', 'port', 'pathname', 'search', 'hash')
128
- link.pathname = '/' + link.pathname
129
-
130
- link
131
-
132
- ###**
133
- @function up.util.normalizeMethod
134
- @internal
135
- ###
136
- normalizeMethod = (method) ->
137
- if method
138
- method.toUpperCase()
139
- else
140
- 'GET'
141
-
142
- ###**
143
- @function up.util.methodAllowsPayload
144
- @internal
145
- ###
146
- methodAllowsPayload = (method) ->
147
- method != 'GET' && method != 'HEAD'
148
-
149
- assignPolyfill = (target, sources...) ->
150
- for source in sources
151
- for own key, value of source
152
- target[key] = value
153
- target
154
-
155
- ###**
156
- Merge the own properties of one or more `sources` into the `target` object.
157
-
158
- @function up.util.assign
159
- @param {Object} target
160
- @param {Array<Object>} sources...
161
- @stable
162
- ###
163
- assign = Object.assign || assignPolyfill
164
-
165
- valuesPolyfill = (object) ->
166
- value for key, value of object
167
-
168
- ###**
169
- Returns an array of values of the given object.
170
-
171
- @function up.util.values
172
- @param {Object} object
173
- @return {Array<string>}
174
- @stable
175
- ###
176
- objectValues = Object.values || valuesPolyfill
177
-
178
- iteratee = (block) ->
179
- if isString(block)
180
- (item) -> item[block]
181
- else
182
- block
183
-
184
- ###**
185
- Translate all items in an array to new array of items.
186
-
187
- @function up.util.map
188
- @param {Array} array
189
- @param {Function(element, index): any|String} block
190
- A function that will be called with each element and (optional) iteration index.
191
-
192
- You can also pass a property name as a String,
193
- which will be collected from each item in the array.
194
- @return {Array}
195
- A new array containing the result of each function call.
196
- @stable
197
- ###
198
- map = (array, block) ->
199
- return [] if array.length == 0
200
- block = iteratee(block)
201
- for item, index in array
202
- block(item, index)
203
-
204
- ###**
205
- @function up.util.mapObject
206
- @internal
207
- ###
208
- mapObject = (array, pairer) ->
209
- merger = (object, pair) ->
210
- object[pair[0]] = pair[1]
211
- return object
212
- map(array, pairer).reduce(merger, {})
213
-
214
- ###**
215
- Calls the given function for each element (and, optional, index)
216
- of the given array.
217
-
218
- @function up.util.each
219
- @param {Array} array
220
- @param {Function(element, index)} block
221
- A function that will be called with each element and (optional) iteration index.
222
- @stable
223
- ###
224
- each = map # note that the native Array.forEach is very slow (https://jsperf.com/fast-array-foreach)
225
-
226
- eachIterator = (iterator, callback) ->
227
- while (entry = iterator.next()) && !entry.done
228
- callback(entry.value)
229
-
230
- ###**
231
- Calls the given function for the given number of times.
232
-
233
- @function up.util.times
234
- @param {number} count
235
- @param {Function()} block
236
- @stable
237
- ###
238
- times = (count, block) ->
239
- block(iteration) for iteration in [0..(count - 1)]
240
-
241
- ###**
242
- Returns whether the given argument is `null`.
243
-
244
- @function up.util.isNull
245
- @param object
246
- @return {boolean}
247
- @stable
248
- ###
249
- isNull = (object) ->
250
- object == null
251
-
252
- ###**
253
- Returns whether the given argument is `undefined`.
254
-
255
- @function up.util.isUndefined
256
- @param object
257
- @return {boolean}
258
- @stable
259
- ###
260
- isUndefined = (object) ->
261
- object == undefined
262
-
263
- ###**
264
- Returns whether the given argument is not `undefined`.
265
-
266
- @function up.util.isDefined
267
- @param object
268
- @return {boolean}
269
- @stable
270
- ###
271
- isDefined = (object) ->
272
- !isUndefined(object)
273
-
274
- ###**
275
- Returns whether the given argument is either `undefined` or `null`.
276
-
277
- Note that empty strings or zero are *not* considered to be "missing".
278
-
279
- For the opposite of `up.util.isMissing()` see [`up.util.isGiven()`](/up.util.isGiven).
280
-
281
- @function up.util.isMissing
282
- @param object
283
- @return {boolean}
284
- @stable
285
- ###
286
- isMissing = (object) ->
287
- isUndefined(object) || isNull(object)
288
-
289
- ###**
290
- Returns whether the given argument is neither `undefined` nor `null`.
291
-
292
- Note that empty strings or zero *are* considered to be "given".
293
-
294
- For the opposite of `up.util.isGiven()` see [`up.util.isMissing()`](/up.util.isMissing).
295
-
296
- @function up.util.isGiven
297
- @param object
298
- @return {boolean}
299
- @stable
300
- ###
301
- isGiven = (object) ->
302
- !isMissing(object)
303
-
304
- # isNan = (object) ->
305
- # isNumber(value) && value != +value
306
-
307
- ###**
308
- Return whether the given argument is considered to be blank.
309
-
310
- By default, this function returns `true` for:
311
-
312
- - `undefined`
313
- - `null`
314
- - Empty strings
315
- - Empty arrays
316
- - A plain object without own enumerable properties
317
-
318
- All other arguments return `false`.
319
-
320
- To check implement blank-ness checks for user-defined classes,
321
- see `up.util.isBlank.key`.
322
-
323
- @function up.util.isBlank
324
- @param value
325
- The value is to check.
326
- @return {boolean}
327
- Whether the value is blank.
328
- @stable
329
- ###
330
- isBlank = (value) ->
331
- if isMissing(value)
332
- return true
333
- if isObject(value) && value[isBlank.key]
334
- return value[isBlank.key]()
335
- if isString(value) || isList(value)
336
- return value.length == 0
337
- if isOptions(value)
338
- return Object.keys(value).length == 0
339
- return false
340
-
341
- ###**
342
- This property contains the name of a method that user-defined classes
343
- may implement to hook into the `up.util.isBlank()` protocol.
344
-
345
- \#\#\# Example
346
-
347
- We have a user-defined `Account` class that we want to use with `up.util.isBlank()`:
348
-
349
- ```
350
- class Account {
351
- constructor(email) {
352
- this.email = email
353
- }
354
-
355
- [up.util.isBlank.key]() {
356
- return up.util.isBlank(this.email)
357
- }
358
- }
359
- ```
360
-
361
- Note that the protocol method is not actually named `'up.util.isBlank.key'`.
362
- Instead it is named after the *value* of the `up.util.isBlank.key` property.
363
- To do so, the code sample above is using a
364
- [computed property name](https://medium.com/front-end-weekly/javascript-object-creation-356e504173a8)
365
- in square brackets.
366
-
367
- We may now use `Account` instances with `up.util.isBlank()`:
368
-
369
- ```
370
- foo = new Account('foo@foo.com')
371
- bar = new Account('')
372
-
373
- console.log(up.util.isBlank(foo)) // prints false
374
- console.log(up.util.isBlank(bar)) // prints true
375
- ```
376
-
377
- @property up.util.isBlank.key
378
- @experimental
379
- ###
380
- isBlank.key = 'up.util.isBlank'
381
-
382
- ###**
383
- Returns the given argument if the argument is [present](/up.util.isPresent),
384
- otherwise returns `undefined`.
385
-
386
- @function up.util.presence
387
- @param value
388
- @param {Function(value): boolean} [tester=up.util.isPresent]
389
- The function that will be used to test whether the argument is present.
390
- @return {any|undefined}
391
- @stable
392
- ###
393
- presence = (value, tester = isPresent) ->
394
- if tester(value) then value else undefined
395
-
396
- ###**
397
- Returns whether the given argument is not [blank](/up.util.isBlank).
398
-
399
- @function up.util.isPresent
400
- @param object
401
- @return {boolean}
402
- @stable
403
- ###
404
- isPresent = (object) ->
405
- !isBlank(object)
406
-
407
- ###**
408
- Returns whether the given argument is a function.
409
-
410
- @function up.util.isFunction
411
- @param object
412
- @return {boolean}
413
- @stable
414
- ###
415
- isFunction = (object) ->
416
- typeof(object) == 'function'
417
-
418
- ###**
419
- Returns whether the given argument is a string.
420
-
421
- @function up.util.isString
422
- @param object
423
- @return {boolean}
424
- @stable
425
- ###
426
- isString = (object) ->
427
- typeof(object) == 'string' || object instanceof String
428
-
429
- ###**
430
- Returns whether the given argument is a boolean value.
431
-
432
- @function up.util.isBoolean
433
- @param object
434
- @return {boolean}
435
- @stable
436
- ###
437
- isBoolean = (object) ->
438
- typeof(object) == 'boolean' || object instanceof Boolean
439
-
440
- ###**
441
- Returns whether the given argument is a number.
442
-
443
- Note that this will check the argument's *type*.
444
- It will return `false` for a string like `"123"`.
445
-
446
- @function up.util.isNumber
447
- @param object
448
- @return {boolean}
449
- @stable
450
- ###
451
- isNumber = (object) ->
452
- typeof(object) == 'number' || object instanceof Number
453
-
454
- ###**
455
- Returns whether the given argument is an options hash,
456
-
457
- Differently from [`up.util.isObject()`], this returns false for
458
- functions, jQuery collections, promises, `FormData` instances and arrays.
459
-
460
- @function up.util.isOptions
461
- @param object
462
- @return {boolean}
463
- @internal
464
- ###
465
- isOptions = (object) ->
466
- typeof(object) == 'object' && !isNull(object) && (isUndefined(object.constructor) || object.constructor == Object)
467
-
468
- ###**
469
- Returns whether the given argument is an object.
470
-
471
- This also returns `true` for functions, which may behave like objects in JavaScript.
472
-
473
- @function up.util.isObject
474
- @param object
475
- @return {boolean}
476
- @stable
477
- ###
478
- isObject = (object) ->
479
- typeOfResult = typeof(object)
480
- (typeOfResult == 'object' && !isNull(object)) || typeOfResult == 'function'
481
-
482
- ###**
483
- Returns whether the given argument is a [DOM element](https://developer.mozilla.org/de/docs/Web/API/Element).
484
-
485
- @function up.util.isElement
486
- @param object
487
- @return {boolean}
488
- @stable
489
- ###
490
- isElement = (object) ->
491
- object instanceof Element
492
-
493
- ###**
494
- Returns whether the given argument is a [jQuery collection](https://learn.jquery.com/using-jquery-core/jquery-object/).
495
-
496
- @function up.util.isJQuery
497
- @param object
498
- @return {boolean}
499
- @stable
500
- ###
501
- isJQuery = (object) ->
502
- # We cannot do `object instanceof jQuery` since window.jQuery might not be set
503
- !!object?.jquery
504
-
505
- ###**
506
- Returns whether the given argument is an object with a `then` method.
507
-
508
- @function up.util.isPromise
509
- @param object
510
- @return {boolean}
511
- @stable
512
- ###
513
- isPromise = (object) ->
514
- isObject(object) && isFunction(object.then)
515
-
516
- ###**
517
- Returns whether the given argument is an array.
518
-
519
- @function up.util.isArray
520
- @param object
521
- @return {boolean}
522
- @stable
523
- ###
524
- # https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
525
- isArray = Array.isArray
526
-
527
- ###**
528
- Returns whether the given argument is a `FormData` instance.
529
-
530
- Always returns `false` in browsers that don't support `FormData`.
531
-
532
- @function up.util.isFormData
533
- @param object
534
- @return {boolean}
535
- @internal
536
- ###
537
- isFormData = (object) ->
538
- object instanceof FormData
539
-
540
- ###**
541
- Converts the given [array-like value](/up.util.isList) into an array.
542
-
543
- If the given value is already an array, it is returned unchanged.
544
-
545
- @function up.util.toArray
546
- @param object
547
- @return {Array}
548
- @stable
549
- ###
550
- toArray = (value) ->
551
- if isArray(value)
552
- value
553
- else
554
- Array.prototype.slice.call(value)
555
-
556
- ###***
557
- Returns whether the given argument is an array-like value.
558
-
559
- Return true for `Array`, a
560
- [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList),
561
- the [arguments object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments)
562
- or a jQuery collection.
563
-
564
- Use [`up.util.isArray()`](/up.util.isArray) to test whether a value is an actual `Array`.
565
-
566
- @function up.util.isList
567
- @param value
568
- @return {Boolean}
569
- @experimental
570
- ###
571
- isList = (value) ->
572
- isArray(value) ||
573
- isNodeList(value) ||
574
- isArguments(value) ||
575
- isJQuery(value) ||
576
- isHTMLCollection(value)
577
-
578
- ###**
579
- Returns whether the given value is a [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList).
580
-
581
- `NodeLists` are array-like objects returned by [`document.querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll).
582
-
583
- @function up.util.isNodeList
584
- @param value
585
- @return {Boolean}
586
- @internal
587
- ###
588
- isNodeList = (value) ->
589
- value instanceof NodeList
590
-
591
- isHTMLCollection = (value) ->
592
- value instanceof HTMLCollection
593
-
594
- # ###**
595
- # Returns whether the given value is an [`HTMLCollection`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection).
596
- #
597
- # @function up.util.isHtmlCollection
598
- # @param value
599
- # @return {Boolean}
600
- # @experimental
601
- # ###
602
- # isHtmlCollection = (value) ->
603
- # value instanceof HTMLCollection
604
-
605
- ###**
606
- Returns whether the given value is an [arguments object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments).
607
-
608
- @function up.util.isArguments
609
- @param value
610
- @return {Boolean}
611
- @internal
612
- ###
613
- isArguments = (value) ->
614
- Object.prototype.toString.call(value) == '[object Arguments]'
615
-
616
- ###**
617
- @function up.util.wrapList
618
- @return {Array|NodeList|jQuery}
619
- @internal
620
- ###
621
- wrapList = (value) ->
622
- if isList(value)
623
- value
624
- else if isMissing(value)
625
- []
626
- else
627
- [value]
628
-
629
- ###**
630
- Returns a shallow copy of the given value.
631
-
632
- \#\#\# Copying protocol
633
-
634
- - By default `up.util.copy()` can copy [array-like values](/up.util.isList),
635
- plain objects and `Date` instances.
636
- - Array-like objects are copied into new arrays.
637
- - Unsupported types of values are returned unchanged.
638
- - To make the copying protocol work with user-defined class,
639
- see `up.util.copy.key`.
640
- - Immutable objects, like strings or numbers, do not need to be copied.
641
-
642
- @function up.util.copy
643
- @param {any} object
644
- @return {any}
645
- @stable
646
- ###
647
- copy = (value, deep) ->
648
- if isObject(value) && value[copy.key]
649
- value = value[copy.key]()
650
- else if isList(value)
651
- value = Array.prototype.slice.call(value)
652
- copied = true
653
- else if isOptions(value)
654
- value = assign({}, value)
655
- copied = true
656
- if copied && deep
657
- for k, v of value
658
- value[k] = copy(v, true)
659
- value
660
-
661
- ###**
662
- This property contains the name of a method that user-defined classes
663
- may implement to hook into the `up.util.copy()` protocol.
664
-
665
- \#\#\# Example
666
-
667
- We have a user-defined `Account` class that we want to use with `up.util.copy()`:
668
-
669
- ```
670
- class Account {
671
- constructor(email) {
672
- this.email = email
673
- }
674
-
675
- [up.util.copy.key]() {
676
- return new Account(this.email)
677
- }
678
- }
679
- ```
680
-
681
- Note that the protocol method is not actually named `'up.util.copy.key'`.
682
- Instead it is named after the *value* of the `up.util.copy.key` property.
683
- To do so, the code sample above is using a
684
- [computed property name](https://medium.com/front-end-weekly/javascript-object-creation-356e504173a8)
685
- in square brackets.
686
-
687
- We may now use `Account` instances with `up.util.copy()`:
688
-
689
- ```
690
- original = new User('foo@foo.com')
691
-
692
- copy = up.util.copy(original)
693
- console.log(copy.email) // prints 'foo@foo.com'
694
-
695
- original.email = 'bar@bar.com' // change the original
696
- console.log(copy.email) // still prints 'foo@foo.com'
697
- ```
698
-
699
- @property up.util.copy.key
700
- @param {string} key
701
- @experimental
702
- ###
703
- copy.key = 'up.util.copy'
704
-
705
- # Implement up.util.copy protocol for Date
706
- Date.prototype[copy.key] = -> new Date(+@)
707
-
708
- ###**
709
- Returns a deep copy of the given array or object.
710
-
711
- @function up.util.deepCopy
712
- @param {Object|Array} object
713
- @return {Object|Array}
714
- @internal
715
- ###
716
- deepCopy = (object) ->
717
- copy(object, true)
718
-
719
- ###**
720
- Creates a new object by merging together the properties from the given objects.
721
-
722
- @function up.util.merge
723
- @param {Array<Object>} sources...
724
- @return Object
725
- @stable
726
- ###
727
- merge = (sources...) ->
728
- assign({}, sources...)
729
-
730
- # ###**
731
- # Creates a new object by recursively merging together the properties from the given objects.
732
- #
733
- # @function up.util.deepMerge
734
- # @param {Array<Object>} sources...
735
- # @return Object
736
- #
737
- # @internal
738
- # ###
739
- # deepMerge = (sources...) ->
740
- # deepAssign({}, sources...)
741
- #
742
- # ###**
743
- # @function up.util.deepAssign
744
- # @param {Array<Object>} sources...
745
- # @return Object
746
- # ###
747
- # deepAssign = (target, sources...) ->
748
- # for source in sources
749
- # for key, newValue of source
750
- # if isOptions(newValue)
751
- # oldValue = target[key]
752
- # if isOptions(oldValue)
753
- # newValue = deepMerge(oldValue, newValue)
754
- # target[key] = newValue
755
- # target
756
-
757
- ###**
758
- Creates an options hash from the given argument and some defaults.
759
-
760
- The semantics of this function are confusing.
761
- We want to get rid of this in the future.
762
-
763
- @function up.util.options
764
- @param {Object} object
765
- @param {Object} [defaults]
766
- @return {Object}
767
- @internal
768
- ###
769
- newOptions = (object, defaults) ->
770
- if defaults
771
- merge(defaults, object)
772
- else if object
773
- copy(object)
774
- else
775
- {}
776
-
777
- ###**
778
- Passes each element in the given [array-like value](/up.util.isList) to the given function.
779
- Returns the first element for which the function returns a truthy value.
780
-
781
- If no object matches, returns `undefined`.
782
-
783
- @function up.util.find
784
- @param {List<T>} list
785
- @param {Function(value): boolean} tester
786
- @return {T|undefined}
787
- @stable
788
- ###
789
- findInList = (list, tester) ->
790
- match = undefined
791
- for element in list
792
- if tester(element)
793
- match = element
794
- break
795
- match
796
-
797
- ###**
798
- Returns whether the given function returns a truthy value
799
- for any element in the given [array-like value](/up.util.isList).
800
-
801
- @function up.util.some
802
- @param {List} list
803
- @param {Function(value, index): boolean} tester
804
- A function that will be called with each element and (optional) iteration index.
805
-
806
- @return {boolean}
807
- @stable
808
- ###
809
- some = (list, tester) ->
810
- !!findResult(list, tester)
811
-
812
- ###**
813
- Consecutively calls the given function which each element
814
- in the given array. Returns the first truthy return value.
815
-
816
- Returned `undefined` iff the function does not return a truthy
817
- value for any element in the array.
818
-
819
- @function up.util.findResult
820
- @param {Array} array
821
- @param {Function(element): any} tester
822
- A function that will be called with each element and (optional) iteration index.
823
-
824
- @return {any|undefined}
825
- @experimental
826
- ###
827
- findResult = (array, tester) ->
828
- tester = iteratee(tester)
829
- for element, index in array
830
- if result = tester(element, index)
831
- return result
832
- return undefined
833
-
834
- ###**
835
- Returns whether the given function returns a truthy value
836
- for all elements in the given [array-like value](/up.util.isList).
837
-
838
- @function up.util.every
839
- @param {List} list
840
- @param {Function(element, index): boolean} tester
841
- A function that will be called with each element and (optional) iteration index.
842
-
843
- @return {boolean}
844
- @experimental
845
- ###
846
- every = (list, tester) ->
847
- tester = iteratee(tester)
848
- match = true
849
- for element, index in list
850
- unless tester(element, index)
851
- match = false
852
- break
853
- match
854
-
855
- ###**
856
- Returns all elements from the given array that are
857
- neither `null` or `undefined`.
858
-
859
- @function up.util.compact
860
- @param {Array<T>} array
861
- @return {Array<T>}
862
- @stable
863
- ###
864
- compact = (array) ->
865
- filterList array, isGiven
866
-
867
- ###**
868
- Returns the given array without duplicates.
869
-
870
- @function up.util.uniq
871
- @param {Array<T>} array
872
- @return {Array<T>}
873
- @stable
874
- ###
875
- uniq = (array) ->
876
- return array if array.length < 2
877
- setToArray(arrayToSet(array))
878
-
879
- ###**
880
- This function is like [`uniq`](/up.util.uniq), accept that
881
- the given function is invoked for each element to generate the value
882
- for which uniquness is computed.
883
-
884
- @function up.util.uniqBy
885
- @param {Array} array
886
- @param {Function(value): any} array
887
- @return {Array}
888
- @experimental
889
- ###
890
- uniqBy = (array, mapper) ->
891
- return array if array.length < 2
892
- mapper = iteratee(mapper)
893
- set = new Set()
894
- filterList array, (elem, index) ->
895
- mapped = mapper(elem, index)
896
- if set.has(mapped)
897
- false
898
- else
899
- set.add(mapped)
900
- true
901
-
902
- ###**
903
- @function up.util.setToArray
904
- @internal
905
- ###
906
- setToArray = (set) ->
907
- array = []
908
- set.forEach (elem) -> array.push(elem)
909
- array
910
-
911
- ###**
912
- @function up.util.arrayToSet
913
- @internal
914
- ###
915
- arrayToSet = (array) ->
916
- set = new Set()
917
- array.forEach (elem) -> set.add(elem)
918
- set
919
-
920
- ###**
921
- Returns all elements from the given [array-like value](/up.util.isList) that return
922
- a truthy value when passed to the given function.
923
-
924
- @function up.util.filter
925
- @param {List} list
926
- @param {Function(value, index): boolean} tester
927
- @return {Array}
928
- @stable
929
- ###
930
- filterList = (list, tester) ->
931
- tester = iteratee(tester)
932
- matches = []
933
- each list, (element, index) ->
934
- if tester(element, index)
935
- matches.push(element)
936
- matches
937
-
938
- ###**
939
- Returns all elements from the given [array-like value](/up.util.isList) that do not return
940
- a truthy value when passed to the given function.
941
-
942
- @function up.util.reject
943
- @param {List} list
944
- @param {Function(element, index): boolean} tester
945
- @return {Array}
946
- @stable
947
- ###
948
- reject = (list, tester) ->
949
- tester = iteratee(tester)
950
- filterList(list, (element, index) -> !tester(element, index))
951
-
952
- ###**
953
- Returns the intersection of the given two arrays.
954
-
955
- Implementation is not optimized. Don't use it for large arrays.
956
-
957
- @function up.util.intersect
958
- @internal
959
- ###
960
- intersect = (array1, array2) ->
961
- filterList array1, (element) ->
962
- contains(array2, element)
963
-
964
- ###**
965
- Waits for the given number of milliseconds, the runs the given callback.
966
-
967
- Instead of `up.util.timer(0, fn)` you can also use [`up.util.task(fn)`](/up.util.task).
968
-
969
- @function up.util.timer
970
- @param {number} millis
971
- @param {Function()} callback
972
- @stable
973
- ###
974
- scheduleTimer = (millis, callback) ->
975
- setTimeout(callback, millis)
976
-
977
- ###**
978
- Pushes the given function to the [JavaScript task queue](https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/) (also "macrotask queue").
979
-
980
- Equivalent to calling `setTimeout(fn, 0)`.
981
-
982
- Also see `up.util.microtask()`.
983
-
984
- @function up.util.task
985
- @param {Function()} block
986
- @stable
987
- ###
988
- queueTask = (block) ->
989
- setTimeout(block, 0)
990
-
991
- ###**
992
- Pushes the given function to the [JavaScript microtask queue](https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/).
993
-
994
- @function up.util.microtask
995
- @param {Function()} task
996
- @return {Promise}
997
- @experimental
998
- ###
999
- queueMicrotask = (task) ->
1000
- Promise.resolve().then(task)
1001
-
1002
- ###**
1003
- Returns the last element of the given array.
1004
-
1005
- @function up.util.last
1006
- @param {Array<T>} array
1007
- @return {T}
1008
- ###
1009
- last = (array) ->
1010
- array[array.length - 1]
1011
-
1012
- ###**
1013
- Returns whether the given keyboard event involved the ESC key.
1014
-
1015
- @function up.util.escapePressed
1016
- @internal
1017
- ###
1018
- escapePressed = (event) ->
1019
- key = event.key
1020
- key == 'Escape' || key == 'Esc'
1021
-
1022
- ###**
1023
- Returns whether the given array or string contains the given element or substring.
1024
-
1025
- @function up.util.contains
1026
- @param {Array|string} arrayOrString
1027
- @param elementOrSubstring
1028
- @stable
1029
- ###
1030
- contains = (arrayOrString, elementOrSubstring) ->
1031
- arrayOrString.indexOf(elementOrSubstring) >= 0
1032
-
1033
- ###**
1034
- Returns a copy of the given object that only contains
1035
- the given properties.
1036
-
1037
- @function up.util.only
1038
- @param {Object} object
1039
- @param {Array} keys...
1040
- @stable
1041
- ###
1042
- only = (object, properties...) ->
1043
- filtered = {}
1044
- for property in properties
1045
- if property of object
1046
- filtered[property] = object[property]
1047
- filtered
1048
-
1049
- ###**
1050
- Returns a copy of the given object that contains all except
1051
- the given properties.
1052
-
1053
- @function up.util.except
1054
- @param {Object} object
1055
- @param {Array} keys...
1056
- @stable
1057
- ###
1058
- except = (object, properties...) ->
1059
- filtered = copy(object)
1060
- for property in properties
1061
- delete filtered[property]
1062
- filtered
1063
-
1064
- # pickBy = (obj, predicate) ->
1065
- # result = {}
1066
- # for k, v of obj
1067
- # if predicate(v, k)
1068
- # result[k] = v
1069
- # result
1070
-
1071
- ###**
1072
- @function up.util.isUnmodifiedKeyEvent
1073
- @internal
1074
- ###
1075
- isUnmodifiedKeyEvent = (event) ->
1076
- not (event.metaKey or event.shiftKey or event.ctrlKey)
1077
-
1078
- ###**
1079
- @function up.util.isUnmodifiedMouseEvent
1080
- @internal
1081
- ###
1082
- isUnmodifiedMouseEvent = (event) ->
1083
- isLeftButton = isUndefined(event.button) || event.button == 0
1084
- isLeftButton && isUnmodifiedKeyEvent(event)
1085
-
1086
- ###**
1087
- Returns a promise that will never be resolved.
1088
-
1089
- @function up.util.unresolvablePromise
1090
- @internal
1091
- ###
1092
- unresolvablePromise = ->
1093
- new Promise(noop)
1094
-
1095
- ###**
1096
- Removes the given element from the given array.
1097
-
1098
- This changes the given array.
1099
-
1100
- @function up.util.remove
1101
- @param {Array<T>} array
1102
- @param {T} element
1103
- @stable
1104
- ###
1105
- remove = (array, element) ->
1106
- index = array.indexOf(element)
1107
- if index >= 0
1108
- array.splice(index, 1)
1109
- element
1110
-
1111
- ###**
1112
- If the given `value` is a function, calls the function with the given `args`.
1113
- Otherwise it just returns `value`.
1114
-
1115
- @function up.util.evalOption
1116
- @internal
1117
- ###
1118
- evalOption = (value, args...) ->
1119
- if isFunction(value)
1120
- value(args...)
1121
- else
1122
- value
1123
-
1124
- ###**
1125
- Throws a [JavaScript error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
1126
- with the given message.
1127
-
1128
- The message will also be printed to the [error log](/up.log.error). Also a notification will be shown at the bottom of the screen.
1129
-
1130
- The message may contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).
1131
-
1132
- \#\#\# Examples
1133
-
1134
- up.fail('Division by zero')
1135
- up.fail('Unexpected result %o', result)
1136
-
1137
- @function up.fail
1138
- @param {string} message
1139
- A message with details about the error.
1140
-
1141
- The message can contain [substitution marks](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions)
1142
- like `%s` or `%o`.
1143
- @param {Array<string>} vars...
1144
- A list of variables to replace any substitution marks in the error message.
1145
- @experimental
1146
- ###
1147
- fail = (args...) ->
1148
- if isArray(args[0])
1149
- messageArgs = args[0]
1150
- toastOptions = args[1] || {}
1151
- else
1152
- messageArgs = args
1153
- toastOptions = {}
1154
-
1155
- up.log.error(messageArgs...)
1156
-
1157
- up.event.onReady(-> up.toast.open(messageArgs, toastOptions))
1158
-
1159
- asString = up.log.sprintf(messageArgs...)
1160
- throw new Error(asString)
1161
-
1162
- ESCAPE_HTML_ENTITY_MAP =
1163
- "&": "&amp;"
1164
- "<": "&lt;"
1165
- ">": "&gt;"
1166
- '"': '&quot;'
1167
- "'": '&#x27;'
1168
-
1169
- ###**
1170
- Escapes the given string of HTML by replacing control chars with their HTML entities.
1171
-
1172
- @function up.util.escapeHtml
1173
- @param {string} string
1174
- The text that should be escaped
1175
- @stable
1176
- ###
1177
- escapeHtml = (string) ->
1178
- string.replace /[&<>"']/g, (char) -> ESCAPE_HTML_ENTITY_MAP[char]
1179
-
1180
- ###**
1181
- @function up.util.escapeRegexp
1182
- @internal
1183
- ###
1184
- escapeRegexp = (string) ->
1185
- # From https://github.com/benjamingr/RegExp.escape
1186
- string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&')
1187
-
1188
- pluckKey = (object, key) ->
1189
- value = object[key]
1190
- delete object[key]
1191
- value
1192
-
1193
- renameKey = (object, oldKey, newKey) ->
1194
- object[newKey] = pluckKey(object, oldKey)
1195
-
1196
- extractLastArg = (args, tester) ->
1197
- lastArg = last(args)
1198
- if tester(lastArg)
1199
- return args.pop()
1200
-
1201
- # extractFirstArg = (args, tester) ->
1202
- # firstArg = args[0]
1203
- # if tester(firstArg)
1204
- # return args.shift()
1205
-
1206
- extractCallback = (args) ->
1207
- extractLastArg(args, isFunction)
1208
-
1209
- extractOptions = (args) ->
1210
- extractLastArg(args, isOptions) || {}
1211
-
1212
- partial = (fn, fixedArgs...) ->
1213
- return (callArgs...) ->
1214
- fn.apply(this, fixedArgs.concat(callArgs))
1215
-
1216
- #function throttle(callback, limit) { // From https://jsfiddle.net/jonathansampson/m7G64/
1217
- # var wait = false // Initially, we're not waiting
1218
- # return function () { // We return a throttled function
1219
- # if (!wait) { // If we're not waiting
1220
- # callback.call() // Execute users function
1221
- # wait = true // Prevent future invocations
1222
- # setTimeout(function () { // After a period of time
1223
- # wait = false // And allow future invocations
1224
- # }, limit)
1225
- # }
1226
- # }
1227
- #}
1228
-
1229
- identity = (arg) -> arg
1230
-
1231
- # ###**
1232
- # ###
1233
- # parsePath = (input) ->
1234
- # path = []
1235
- # pattern = /([^\.\[\]\"\']+)|\[\'([^\']+?)\'\]|\[\"([^\"]+?)\"\]|\[([^\]]+?)\]/g
1236
- # while match = pattern.exec(input)
1237
- # path.push(match[1] || match[2] || match[3] || match[4])
1238
- # path
1239
-
1240
- ###**
1241
- Given a function that will return a promise, returns a proxy function
1242
- with an additional `.promise` attribute.
1243
-
1244
- When the proxy is called, the inner function is called.
1245
- The proxy's `.promise` attribute is available even before the function is called
1246
- and will resolve when the inner function's returned promise resolves.
1247
-
1248
- If the inner function does not return a promise, the proxy's `.promise` attribute
1249
- will resolve as soon as the inner function returns.
1250
-
1251
- @function up.util.previewable
1252
- @internal
1253
- ###
1254
- previewable = (fun) ->
1255
- deferred = newDeferred()
1256
- preview = (args...) ->
1257
- funValue = fun(args...)
1258
- # If funValue is again a Promise, it will defer resolution of `deferred`
1259
- # until `funValue` is resolved.
1260
- deferred.resolve(funValue)
1261
- funValue
1262
- preview.promise = deferred.promise()
1263
- preview
1264
-
1265
- ###**
1266
- @function up.util.sequence
1267
- @param {Array<Function()>} functions
1268
- @return {Function()}
1269
- A function that will call all `functions` if called.
1270
-
1271
- @internal
1272
- ###
1273
- sequence = (functions) ->
1274
- if functions.length == 1
1275
- return functions[0]
1276
- else
1277
- return -> map(functions, (f) -> f())
1278
-
1279
- # ###**
1280
- # @function up.util.race
1281
- # @internal
1282
- # ###
1283
- # race = (promises...) ->
1284
- # raceDone = newDeferred()
1285
- # each promises, (promise) ->
1286
- # promise.then -> raceDone.resolve()
1287
- # raceDone.promise()
1288
-
1289
- ###**
1290
- Returns `'left'` if the center of the given element is in the left 50% of the screen.
1291
- Otherwise returns `'right'`.
1292
-
1293
- @function up.util.horizontalScreenHalf
1294
- @internal
1295
- ###
1296
- horizontalScreenHalf = (element) ->
1297
- elementDims = element.getBoundingClientRect()
1298
- elementMid = elementDims.left + 0.5 * elementDims.width
1299
- screenMid = 0.5 * up.viewport.rootWidth()
1300
- if elementMid < screenMid
1301
- 'left'
1302
- else
1303
- 'right'
1304
-
1305
- ###**
1306
- Flattens the given `array` a single level deep.
1307
-
1308
- @function up.util.flatten
1309
- @param {Array} array
1310
- An array which might contain other arrays
1311
- @return {Array}
1312
- The flattened array
1313
- @experimental
1314
- ###
1315
- flatten = (array) ->
1316
- flattened = []
1317
- for object in array
1318
- if isList(object)
1319
- flattened.push(object...)
1320
- else
1321
- flattened.push(object)
1322
- flattened
1323
-
1324
- ###**
1325
- Maps each element using a mapping function,
1326
- then flattens the result into a new array.
1327
-
1328
- @function up.util.flatMap
1329
- @param {Array} array
1330
- @param {Function(element)} mapping
1331
- @return {Array}
1332
- @experimental
1333
- ###
1334
- flatMap = (array, block) ->
1335
- flatten map(array, block)
1336
-
1337
- ###**
1338
- Returns whether the given value is truthy.
1339
-
1340
- @function up.util.isTruthy
1341
- @internal
1342
- ###
1343
- isTruthy = (object) ->
1344
- !!object
1345
-
1346
- ###**
1347
- Sets the given callback as both fulfillment and rejection handler for the given promise.
1348
-
1349
- @function up.util.always
1350
- @internal
1351
- ###
1352
- always = (promise, callback) ->
1353
- promise.then(callback, callback)
1354
-
1355
- ###**
1356
- # Registers an empty rejection handler with the given promise.
1357
- # This prevents browsers from printing "Uncaught (in promise)" to the error
1358
- # console when the promise is rejection.
1359
- #
1360
- # This is helpful for event handlers where it is clear that no rejection
1361
- # handler will be registered:
1362
- #
1363
- # up.on('submit', 'form[up-target]', (event, $form) => {
1364
- # promise = up.submit($form)
1365
- # up.util.muteRejection(promise)
1366
- # })
1367
- #
1368
- # Does nothing if passed a missing value.
1369
- #
1370
- # @function up.util.muteRejection
1371
- # @param {Promise|undefined|null} promise
1372
- # @return {Promise}
1373
- ###
1374
- muteRejection = (promise) ->
1375
- promise?.catch(noop)
1376
-
1377
- ###**
1378
- @function up.util.newDeferred
1379
- @internal
1380
- ###
1381
- ###**
1382
- @function up.util.newDeferred
1383
- @internal
1384
- ###
1385
- newDeferred = ->
1386
- resolveFn = undefined
1387
- rejectFn = undefined
1388
- nativePromise = new Promise (givenResolve, givenReject) ->
1389
- resolveFn = givenResolve
1390
- rejectFn = givenReject
1391
- nativePromise.resolve = resolveFn
1392
- nativePromise.reject = rejectFn
1393
- nativePromise.promise = -> nativePromise # just return self
1394
- nativePromise
1395
-
1396
- ###**
1397
- Calls the given block. If the block throws an exception,
1398
- a rejected promise is returned instead.
1399
-
1400
- @function up.util.rejectOnError
1401
- @internal
1402
- ###
1403
- rejectOnError = (block) ->
1404
- try
1405
- block()
1406
- catch error
1407
- Promise.reject(error)
1408
-
1409
- sum = (list, block) ->
1410
- block = iteratee(block)
1411
- totalValue = 0
1412
- for entry in list
1413
- entryValue = block(entry)
1414
- if isGiven(entryValue) # ignore undefined/null, like SQL would do
1415
- totalValue += entryValue
1416
- totalValue
1417
-
1418
- isBasicObjectProperty = (k) ->
1419
- Object.prototype.hasOwnProperty(k)
1420
-
1421
- ###**
1422
- Returns whether the two arguments are equal by value.
1423
-
1424
- \#\#\# Comparison protocol
1425
-
1426
- - By default `up.util.isEqual()` can compare strings, numbers,
1427
- [array-like values](/up.util.isList), plain objects and `Date` objects.
1428
- - To make the copying protocol work with user-defined classes,
1429
- see `up.util.isEqual.key`.
1430
- - Objects without a defined comparison protocol are
1431
- defined by reference (`===`).
1432
-
1433
- @function up.util.isEqual
1434
- @param {any} a
1435
- @param {any} b
1436
- @return {boolean}
1437
- Whether the arguments are equal by value.
1438
- @experimental
1439
- ###
1440
- isEqual = (a, b) ->
1441
- a = a.valueOf() if a?.valueOf # Date, String objects, Number objects
1442
- b = b.valueOf() if b?.valueOf # Date, String objects, Number objects
1443
- if typeof(a) != typeof(b)
1444
- false
1445
- else if isList(a) && isList(b)
1446
- isEqualList(a, b)
1447
- else if isObject(a) && a[isEqual.key]
1448
- a[isEqual.key](b)
1449
- else if isOptions(a) && isOptions(b)
1450
- aKeys = Object.keys(a)
1451
- bKeys = Object.keys(b)
1452
- if isEqualList(aKeys, bKeys)
1453
- every aKeys, (aKey) -> isEqual(a[aKey], b[aKey])
1454
- else
1455
- false
1456
- else
1457
- a == b
1458
-
1459
- ###**
1460
- This property contains the name of a method that user-defined classes
1461
- may implement to hook into the `up.util.isEqual()` protocol.
1462
-
1463
- \#\#\# Example
1464
-
1465
- We have a user-defined `Account` class that we want to use with `up.util.isEqual()`:
1466
-
1467
- ```
1468
- class Account {
1469
- constructor(email) {
1470
- this.email = email
1471
- }
1472
-
1473
- [up.util.isEqual.key](other) {
1474
- return this.email === other.email;
1475
- }
1476
- }
1477
- ```
1478
-
1479
- Note that the protocol method is not actually named `'up.util.isEqual.key'`.
1480
- Instead it is named after the *value* of the `up.util.isEqual.key` property.
1481
- To do so, the code sample above is using a
1482
- [computed property name](https://medium.com/front-end-weekly/javascript-object-creation-356e504173a8)
1483
- in square brackets.
1484
-
1485
- We may now use `Account` instances with `up.util.isEqual()`:
1486
-
1487
- ```
1488
- one = new User('foo@foo.com')
1489
- two = new User('foo@foo.com')
1490
- three = new User('bar@bar.com')
1491
-
1492
- isEqual = up.util.isEqual(one, two)
1493
- // isEqual is now true
1494
-
1495
- isEqual = up.util.isEqual(one, three)
1496
- // isEqual is now false
1497
- ```
1498
-
1499
- @property up.util.isEqual.key
1500
- @param {string} key
1501
- @experimental
1502
- ###
1503
- isEqual.key = 'up.util.isEqual'
1504
-
1505
- isEqualList = (a, b) ->
1506
- a.length == b.length && every(a, (elem, index) -> isEqual(elem, b[index]))
1507
-
1508
- splitValues = (value, separator = ' ') ->
1509
- values = value.split(separator)
1510
- values = map values, (v) -> v.trim()
1511
- values = filterList(values, isPresent)
1512
- values
1513
-
1514
- endsWith = (string, search) ->
1515
- if search.length > string.length
1516
- false
1517
- else
1518
- string.substring(string.length - search.length) == search
1519
-
1520
- simpleEase = (x) ->
1521
- # easing: http://fooplot.com/?lang=de#W3sidHlwZSI6MCwiZXEiOiJ4PDAuNT8yKngqeDp4Kig0LXgqMiktMSIsImNvbG9yIjoiIzEzRjIxNyJ9LHsidHlwZSI6MCwiZXEiOiJzaW4oKHheMC43LTAuNSkqcGkpKjAuNSswLjUiLCJjb2xvciI6IiMxQTUyRUQifSx7InR5cGUiOjEwMDAsIndpbmRvdyI6WyItMS40NyIsIjEuNzgiLCItMC41NSIsIjEuNDUiXX1d
1522
- # easing nice: sin((x^0.7-0.5)*pi)*0.5+0.5
1523
- # easing performant: x < 0.5 ? 2*x*x : x*(4 - x*2)-1
1524
- # https://jsperf.com/easings/1
1525
- # Math.sin((Math.pow(x, 0.7) - 0.5) * Math.PI) * 0.5 + 0.5
1526
- if x < 0.5
1527
- 2*x*x
1528
- else
1529
- x*(4 - x*2)-1
1530
-
1531
- wrapValue = (object, constructor) ->
1532
- if object instanceof constructor
1533
- # This object has gone through instantiation and normalization before.
1534
- object
1535
- else
1536
- new constructor(object)
1537
-
1538
- # wrapArray = (objOrArray) ->
1539
- # if isUndefined(objOrArray)
1540
- # []
1541
- # else if isArray(objOrArray)
1542
- # objOrArray
1543
- # else
1544
- # [objOrArray]
1545
-
1546
- nextUid = 0
1547
-
1548
- uid = ->
1549
- nextUid++
1550
-
1551
- <% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
1552
- parseUrl: parseUrl
1553
- normalizeUrl: normalizeUrl
1554
- normalizeMethod: normalizeMethod
1555
- methodAllowsPayload: methodAllowsPayload
1556
- # isGoodSelector: isGoodSelector
1557
- assign: assign
1558
- assignPolyfill: assignPolyfill
1559
- copy: copy
1560
- deepCopy: deepCopy
1561
- merge: merge
1562
- # deepAssign: deepAssign
1563
- # deepMerge: deepMerge
1564
- options: newOptions
1565
- fail: fail
1566
- each: each
1567
- eachIterator: eachIterator
1568
- map: map
1569
- flatMap: flatMap
1570
- mapObject: mapObject
1571
- times: times
1572
- findResult: findResult
1573
- some: some
1574
- any: ->
1575
- up.legacy.warn('up.util.any() has been renamed to up.util.some()')
1576
- some.apply(null, arguments)
1577
- every: every
1578
- all: ->
1579
- up.legacy.warn('up.util.all() has been renamed to up.util.every()')
1580
- every.apply(null, arguments)
1581
- detect: ->
1582
- up.legacy.warn('up.util.find() has been renamed to up.util.find()')
1583
- findInList.apply(null, arguments)
1584
- find: findInList
1585
- select: ->
1586
- up.legacy.warn('up.util.select() has been renamed to up.util.filter()')
1587
- filterList.apply(null, arguments)
1588
- filter: filterList
1589
- reject: reject
1590
- intersect: intersect
1591
- compact: compact
1592
- uniq: uniq
1593
- uniqBy: uniqBy
1594
- last: last
1595
- isNull: isNull
1596
- isDefined: isDefined
1597
- isUndefined: isUndefined
1598
- isGiven: isGiven
1599
- isMissing: isMissing
1600
- isPresent: isPresent
1601
- isBlank: isBlank
1602
- presence: presence
1603
- isObject: isObject
1604
- isFunction: isFunction
1605
- isString: isString
1606
- isBoolean: isBoolean
1607
- isNumber: isNumber
1608
- isElement: isElement
1609
- isJQuery: isJQuery
1610
- isPromise: isPromise
1611
- isOptions: isOptions
1612
- isArray: isArray
1613
- isFormData: isFormData
1614
- isNodeList: isNodeList
1615
- isArguments: isArguments
1616
- isList: isList
1617
- isUnmodifiedKeyEvent: isUnmodifiedKeyEvent
1618
- isUnmodifiedMouseEvent: isUnmodifiedMouseEvent
1619
- timer: scheduleTimer
1620
- setTimer: ->
1621
- up.legacy.warn('up.util.setTimer() has been renamed to up.util.timer()')
1622
- scheduleTimer.apply(null, arguments)
1623
- escapePressed: escapePressed
1624
- contains: contains
1625
- toArray: toArray
1626
- only: only
1627
- except: except
1628
- # pickBy: pickBy
1629
- unresolvablePromise: unresolvablePromise
1630
- remove: remove
1631
- memoize: memoize
1632
- error: fail
1633
- pluckKey: pluckKey
1634
- renameKey: renameKey
1635
- extractOptions: extractOptions
1636
- extractCallback: extractCallback
1637
- noop: noop
1638
- asyncNoop: asyncNoop
1639
- identity: identity
1640
- escapeHtml: escapeHtml
1641
- escapeRegexp: escapeRegexp
1642
- sequence: sequence
1643
- previewable: previewable
1644
- # parsePath: parsePath
1645
- evalOption: evalOption
1646
- horizontalScreenHalf: horizontalScreenHalf
1647
- flatten: flatten
1648
- isTruthy: isTruthy
1649
- newDeferred: newDeferred
1650
- always: always
1651
- muteRejection: muteRejection
1652
- rejectOnError: rejectOnError
1653
- isBasicObjectProperty: isBasicObjectProperty
1654
- isCrossDomain: isCrossDomain
1655
- selectorForElement: ->
1656
- up.legacy.warn('up.util.selectorForElement() has been renamed to up.element.toSelector()')
1657
- up.element.toSelector.apply(null, arguments)
1658
- nextFrame: ->
1659
- up.legacy.warn('up.util.nextFrame() has been renamed to up.util.task()')
1660
- queueTask.apply(null, arguments)
1661
- task: queueTask
1662
- microtask: queueMicrotask
1663
- isEqual: isEqual
1664
- splitValues : splitValues
1665
- endsWith: endsWith
1666
- sum: sum
1667
- # wrapArray: wrapArray
1668
- wrapList: wrapList
1669
- wrapValue: wrapValue
1670
- simpleEase: simpleEase
1671
- values: objectValues
1672
- partial: partial
1673
- arrayToSet: arrayToSet
1674
- setToArray: setToArray
1675
- uid: uid
1676
-
1677
- up.fail = up.util.fail