unpoly-rails 0.61.0 → 2.0.0.pre.rc3
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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +94 -1
- data/README.md +3 -11
- data/README_RAILS.md +295 -14
- data/dist/unpoly-bootstrap3.css +9 -14
- data/dist/unpoly-bootstrap3.js +4 -18
- data/dist/unpoly-bootstrap3.min.css +1 -1
- data/dist/unpoly-bootstrap3.min.js +1 -1
- data/dist/unpoly-bootstrap4.css +9 -0
- data/dist/unpoly-bootstrap4.js +16 -0
- data/dist/unpoly-bootstrap4.min.css +1 -0
- data/dist/unpoly-bootstrap4.min.js +1 -0
- data/dist/unpoly-bootstrap5.css +9 -0
- data/dist/unpoly-bootstrap5.js +14 -0
- data/dist/unpoly-bootstrap5.min.css +1 -0
- data/dist/unpoly-bootstrap5.min.js +1 -0
- data/dist/unpoly-migrate.js +1213 -0
- data/dist/unpoly-migrate.min.js +1 -0
- data/dist/unpoly.css +109 -140
- data/dist/unpoly.js +15439 -10434
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +6 -4
- data/lib/unpoly-rails.rb +9 -3
- data/lib/unpoly/rails/change.rb +372 -0
- data/lib/unpoly/rails/change/cache.rb +26 -0
- data/lib/unpoly/rails/change/context.rb +80 -0
- data/lib/unpoly/rails/change/field.rb +117 -0
- data/lib/unpoly/rails/change/field_definition.rb +74 -0
- data/lib/unpoly/rails/change/layer.rb +60 -0
- data/lib/unpoly/rails/controller.rb +47 -0
- data/lib/unpoly/rails/error.rb +5 -0
- data/lib/unpoly/rails/request_echo_headers.rb +2 -2
- data/lib/unpoly/rails/version.rb +1 -1
- data/lib/unpoly/tasks.rb +45 -0
- metadata +43 -314
- data/.gitignore +0 -10
- data/.ruby-version +0 -2
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -45
- data/Rakefile +0 -144
- data/bower.json +0 -27
- data/design/animation-ghosting.txt +0 -72
- data/design/design.txt +0 -34
- data/design/draft.html.erb +0 -48
- data/design/draft.rb +0 -9
- data/design/es6.js +0 -32
- data/design/ghost-debugging.txt +0 -118
- data/design/homepage.txt +0 -236
- data/design/ie11.txt +0 -9
- data/design/measure_import_node.js +0 -330
- data/design/measure_jquery/element_list.js +0 -41
- data/design/measure_jquery/up.on_vs_addEventListener.js +0 -56
- data/design/positioning.txt +0 -28
- data/design/query-params-in-form-actions/cases.html +0 -125
- data/design/rename.txt +0 -0
- data/design/test_rejected_promise.txt +0 -5
- data/design/unpoly errors.txt +0 -19
- data/lib/assets/javascripts/unpoly-bootstrap3.coffee +0 -2
- data/lib/assets/javascripts/unpoly-bootstrap3/feedback-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.coffee +0 -1
- data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.coffee +0 -14
- data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly.coffee +0 -28
- data/lib/assets/javascripts/unpoly/browser.coffee.erb +0 -236
- data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +0 -36
- data/lib/assets/javascripts/unpoly/classes/cache.coffee +0 -127
- data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +0 -93
- data/lib/assets/javascripts/unpoly/classes/config.coffee +0 -9
- data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +0 -118
- data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +0 -39
- data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +0 -116
- data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +0 -86
- data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +0 -111
- data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +0 -80
- data/lib/assets/javascripts/unpoly/classes/focus_follower.coffee +0 -29
- data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +0 -56
- data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +0 -46
- data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +0 -157
- data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +0 -543
- data/lib/assets/javascripts/unpoly/classes/record.coffee +0 -22
- data/lib/assets/javascripts/unpoly/classes/rect.js +0 -21
- data/lib/assets/javascripts/unpoly/classes/request.coffee +0 -246
- data/lib/assets/javascripts/unpoly/classes/response.coffee +0 -157
- data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +0 -102
- data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +0 -67
- data/lib/assets/javascripts/unpoly/classes/selector.coffee +0 -60
- data/lib/assets/javascripts/unpoly/classes/store/memory.coffee +0 -26
- data/lib/assets/javascripts/unpoly/classes/store/session.coffee +0 -59
- data/lib/assets/javascripts/unpoly/classes/tether.coffee +0 -105
- data/lib/assets/javascripts/unpoly/classes/url_set.coffee +0 -32
- data/lib/assets/javascripts/unpoly/cookie.coffee +0 -56
- data/lib/assets/javascripts/unpoly/element.coffee.erb +0 -1126
- data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -438
- data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
- data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1032
- data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -924
- data/lib/assets/javascripts/unpoly/framework.coffee +0 -67
- data/lib/assets/javascripts/unpoly/history.coffee +0 -268
- data/lib/assets/javascripts/unpoly/legacy.coffee +0 -60
- data/lib/assets/javascripts/unpoly/link.coffee.erb +0 -622
- data/lib/assets/javascripts/unpoly/log.coffee +0 -248
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -825
- data/lib/assets/javascripts/unpoly/motion.coffee.erb +0 -668
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
- data/lib/assets/javascripts/unpoly/popup.coffee.erb +0 -515
- data/lib/assets/javascripts/unpoly/protocol.coffee +0 -298
- data/lib/assets/javascripts/unpoly/proxy.coffee +0 -672
- data/lib/assets/javascripts/unpoly/radio.coffee +0 -60
- data/lib/assets/javascripts/unpoly/rails.coffee +0 -24
- data/lib/assets/javascripts/unpoly/syntax.coffee.erb +0 -477
- data/lib/assets/javascripts/unpoly/toast.coffee +0 -67
- data/lib/assets/javascripts/unpoly/tooltip.coffee +0 -276
- data/lib/assets/javascripts/unpoly/util.coffee.erb +0 -1676
- data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -806
- data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
- data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
- data/lib/assets/stylesheets/unpoly.sass +0 -1
- data/lib/assets/stylesheets/unpoly/close.sass +0 -2
- data/lib/assets/stylesheets/unpoly/dom.sass +0 -5
- data/lib/assets/stylesheets/unpoly/layout.sass +0 -2
- data/lib/assets/stylesheets/unpoly/link.sass +0 -2
- data/lib/assets/stylesheets/unpoly/modal.sass +0 -116
- data/lib/assets/stylesheets/unpoly/popup.sass +0 -7
- data/lib/assets/stylesheets/unpoly/toast.sass +0 -33
- data/lib/assets/stylesheets/unpoly/tooltip.sass +0 -62
- data/lib/unpoly/rails/inspector.rb +0 -149
- data/lib/unpoly/rails/inspector_accessor.rb +0 -30
- data/package.json +0 -38
- data/spec_app/.firefox-version +0 -1
- data/spec_app/.gitignore +0 -17
- data/spec_app/.rspec +0 -2
- data/spec_app/Gemfile +0 -32
- data/spec_app/Gemfile.lock +0 -233
- data/spec_app/README.rdoc +0 -28
- data/spec_app/Rakefile +0 -6
- data/spec_app/app/assets/images/.keep +0 -0
- data/spec_app/app/assets/images/favicon.png +0 -0
- data/spec_app/app/assets/images/grid.png +0 -0
- data/spec_app/app/assets/javascripts/bootstrap_manifest.coffee +0 -6
- data/spec_app/app/assets/javascripts/integration_test.coffee +0 -6
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +0 -6
- data/spec_app/app/assets/stylesheets/_helpers.sass +0 -5
- data/spec_app/app/assets/stylesheets/bootstrap_manifest.sass +0 -2
- data/spec_app/app/assets/stylesheets/integration_test.sass +0 -88
- data/spec_app/app/assets/stylesheets/jasmine_specs.sass +0 -20
- data/spec_app/app/controllers/application_controller.rb +0 -14
- data/spec_app/app/controllers/binding_test_controller.rb +0 -51
- data/spec_app/app/controllers/compiler_test_controller.rb +0 -5
- data/spec_app/app/controllers/css_test_controller.rb +0 -5
- data/spec_app/app/controllers/error_test_controller.rb +0 -5
- data/spec_app/app/controllers/form_test/basics_controller.rb +0 -14
- data/spec_app/app/controllers/form_test/redirects_controller.rb +0 -17
- data/spec_app/app/controllers/form_test/uploads_controller.rb +0 -15
- data/spec_app/app/controllers/hash_test_controller.rb +0 -5
- data/spec_app/app/controllers/method_test_controller.rb +0 -16
- data/spec_app/app/controllers/motion_test_controller.rb +0 -5
- data/spec_app/app/controllers/pages_controller.rb +0 -9
- data/spec_app/app/controllers/replace_test_controller.rb +0 -5
- data/spec_app/app/controllers/reveal_test_controller.rb +0 -5
- data/spec_app/app/controllers/scroll_test_controller.rb +0 -5
- data/spec_app/app/helpers/application_helper.rb +0 -2
- data/spec_app/app/mailers/.keep +0 -0
- data/spec_app/app/models/concerns/.keep +0 -0
- data/spec_app/app/views/compiler_test/timestamp.erb +0 -9
- data/spec_app/app/views/css_test/modal.erb +0 -47
- data/spec_app/app/views/css_test/modal_contents.erb +0 -5
- data/spec_app/app/views/css_test/modal_contents_wide.erb +0 -5
- data/spec_app/app/views/css_test/popup.erb +0 -81
- data/spec_app/app/views/css_test/popup_contents.erb +0 -5
- data/spec_app/app/views/css_test/tooltip.erb +0 -48
- data/spec_app/app/views/error_test/trigger.erb +0 -80
- data/spec_app/app/views/error_test/unexpected_response.erb +0 -3
- data/spec_app/app/views/form_test/basics/new.erb +0 -60
- data/spec_app/app/views/form_test/redirects/new.erb +0 -27
- data/spec_app/app/views/form_test/redirects/target.erb +0 -4
- data/spec_app/app/views/form_test/submission_result.erb +0 -30
- data/spec_app/app/views/form_test/uploads/new.erb +0 -44
- data/spec_app/app/views/hash_test/unpoly.erb +0 -30
- data/spec_app/app/views/hash_test/vanilla.erb +0 -13
- data/spec_app/app/views/layouts/integration_test.erb +0 -22
- data/spec_app/app/views/layouts/jasmine_rails/spec_runner.html.erb +0 -20
- data/spec_app/app/views/method_test/form_target.erb +0 -17
- data/spec_app/app/views/method_test/page1.erb +0 -11
- data/spec_app/app/views/method_test/page2.erb +0 -6
- data/spec_app/app/views/motion_test/animations.erb +0 -16
- data/spec_app/app/views/motion_test/transitions.erb +0 -13
- data/spec_app/app/views/pages/start.erb +0 -79
- data/spec_app/app/views/replace_test/_nav.erb +0 -6
- data/spec_app/app/views/replace_test/page1.erb +0 -14
- data/spec_app/app/views/replace_test/page2.erb +0 -14
- data/spec_app/app/views/replace_test/table.erb +0 -16
- data/spec_app/app/views/reveal_test/long1.erb +0 -17
- data/spec_app/app/views/reveal_test/long2.erb +0 -17
- data/spec_app/app/views/reveal_test/within_document_viewport.erb +0 -24
- data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +0 -28
- data/spec_app/app/views/scroll_test/long1.erb +0 -30
- data/spec_app/bin/bundle +0 -3
- data/spec_app/bin/rails +0 -8
- data/spec_app/bin/rake +0 -8
- data/spec_app/bin/setup +0 -29
- data/spec_app/bin/spring +0 -18
- data/spec_app/config.ru +0 -4
- data/spec_app/config/application.rb +0 -28
- data/spec_app/config/boot.rb +0 -3
- data/spec_app/config/database.yml +0 -25
- data/spec_app/config/environment.rb +0 -5
- data/spec_app/config/environments/development.rb +0 -41
- data/spec_app/config/environments/production.rb +0 -79
- data/spec_app/config/environments/test.rb +0 -42
- data/spec_app/config/initializers/assets.rb +0 -19
- data/spec_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec_app/config/initializers/bower_rails.rb +0 -16
- data/spec_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec_app/config/initializers/inflections.rb +0 -16
- data/spec_app/config/initializers/mime_types.rb +0 -4
- data/spec_app/config/initializers/session_store.rb +0 -3
- data/spec_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec_app/config/locales/en.yml +0 -23
- data/spec_app/config/routes.rb +0 -30
- data/spec_app/config/secrets.yml +0 -22
- data/spec_app/db/schema.rb +0 -23
- data/spec_app/db/seeds.rb +0 -7
- data/spec_app/lib/assets/.keep +0 -0
- data/spec_app/lib/tasks/.keep +0 -0
- data/spec_app/lib/tasks/cucumber.rake +0 -65
- data/spec_app/log/.keep +0 -0
- data/spec_app/public/404.html +0 -67
- data/spec_app/public/422.html +0 -67
- data/spec_app/public/500.html +0 -66
- data/spec_app/public/favicon.ico +0 -0
- data/spec_app/public/robots.txt +0 -5
- data/spec_app/script/cucumber +0 -10
- data/spec_app/spec/controllers/binding_test_controller_spec.rb +0 -248
- data/spec_app/spec/javascripts/helpers/agent_detector.coffee +0 -20
- data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +0 -103
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +0 -21
- data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/fixture.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/index.js.coffee +0 -1
- data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +0 -1
- data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -69
- data/spec_app/spec/javascripts/helpers/last_request.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +0 -24
- data/spec_app/spec/javascripts/helpers/promise_state.js +0 -18
- data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +0 -23
- data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/spec_util.coffee +0 -47
- data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_array.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_error.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_jquery.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +0 -15
- data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +0 -16
- data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -18
- data/spec_app/spec/javascripts/helpers/to_match_list.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +0 -13
- data/spec_app/spec/javascripts/helpers/to_match_url.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +0 -200
- data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +0 -5
- data/spec_app/spec/javascripts/support/jasmine.yml +0 -51
- data/spec_app/spec/javascripts/up/browser_spec.js.coffee +0 -150
- data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +0 -82
- data/spec_app/spec/javascripts/up/classes/config_spec.coffee +0 -24
- data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +0 -45
- data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +0 -34
- data/spec_app/spec/javascripts/up/classes/params_spec.coffee +0 -557
- data/spec_app/spec/javascripts/up/classes/request_spec.coffee +0 -50
- data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +0 -51
- data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +0 -70
- data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +0 -114
- data/spec_app/spec/javascripts/up/element_spec.coffee +0 -897
- data/spec_app/spec/javascripts/up/event_spec.js.coffee +0 -530
- data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +0 -401
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +0 -1488
- data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +0 -2589
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +0 -340
- data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +0 -4
- data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +0 -27
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +0 -1093
- data/spec_app/spec/javascripts/up/log_spec.js.coffee +0 -119
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +0 -917
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +0 -582
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +0 -507
- data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +0 -39
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +0 -1137
- data/spec_app/spec/javascripts/up/radio_spec.js.coffee +0 -212
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +0 -118
- data/spec_app/spec/javascripts/up/spec_spec.js.coffee +0 -9
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +0 -304
- data/spec_app/spec/javascripts/up/toast_spec.js.coffee +0 -37
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +0 -163
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +0 -1420
- data/spec_app/spec/javascripts/up/viewport_spec.js.coffee +0 -655
- data/spec_app/spec/spec_helper.rb +0 -62
- data/spec_app/test/controllers/.keep +0 -0
- data/spec_app/test/fixtures/.keep +0 -0
- data/spec_app/test/helpers/.keep +0 -0
- data/spec_app/test/integration/.keep +0 -0
- data/spec_app/test/mailers/.keep +0 -0
- data/spec_app/test/models/.keep +0 -0
- data/spec_app/test/test_helper.rb +0 -10
- data/spec_app/vendor/asset-libs/es6-promise-4.1.6/es6-promise.auto.js +0 -1159
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.bower.json +0 -43
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +0 -10
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +0 -56
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js +0 -790
- data/spec_app/vendor/assets/.keep +0 -0
- data/unpoly-rails.gemspec +0 -24
@@ -1,806 +0,0 @@
|
|
1
|
-
###**
|
2
|
-
Scrolling viewports
|
3
|
-
===================
|
4
|
-
|
5
|
-
The `up.viewport` module controls the scroll position of scrollable containers ("viewports").
|
6
|
-
|
7
|
-
The default viewport for any web application is the main document. An application may
|
8
|
-
define additional viewports by giving the CSS property `{ overflow-y: scroll }` to any `<div>`.
|
9
|
-
|
10
|
-
|
11
|
-
\#\#\# Revealing new content
|
12
|
-
|
13
|
-
When following a [link to a fragment](/a-up-target) Unpoly will automatically
|
14
|
-
scroll the document's viewport to [reveal](/up.viewport) the updated content.
|
15
|
-
|
16
|
-
You should [make Unpoly aware](/up.viewport.config#config.fixedTop) of fixed elements in your
|
17
|
-
layout, such as navigation bars or headers. Unpoly will respect these sticky
|
18
|
-
elements when [revealing updated fragments](/up.reveal).
|
19
|
-
|
20
|
-
You should also [tell Unpoly](/up.viewport.config#config.viewports) when your application has more than one viewport,
|
21
|
-
so Unpoly can pick the right viewport to scroll for each fragment update.
|
22
|
-
|
23
|
-
|
24
|
-
\#\#\# Bootstrap integration
|
25
|
-
|
26
|
-
When using Bootstrap integration (`unpoly-bootstrap3.js` and `unpoly-bootstrap3.css`)
|
27
|
-
Unpoly will automatically be aware of sticky Bootstrap components such as
|
28
|
-
[fixed navbar](https://getbootstrap.com/examples/navbar-fixed-top/).
|
29
|
-
|
30
|
-
@module up.viewport
|
31
|
-
###
|
32
|
-
up.viewport = do ->
|
33
|
-
|
34
|
-
u = up.util
|
35
|
-
e = up.element
|
36
|
-
|
37
|
-
###**
|
38
|
-
Configures the application layout.
|
39
|
-
|
40
|
-
@property up.viewport.config
|
41
|
-
@param {Array} [config.viewports]
|
42
|
-
An array of CSS selectors that find viewports
|
43
|
-
(containers that scroll their contents).
|
44
|
-
@param {Array} [config.fixedTop]
|
45
|
-
An array of CSS selectors that find elements fixed to the
|
46
|
-
top edge of the screen (using `position: fixed`).
|
47
|
-
See [`[up-fixed="top"]`](/up-fixed-top) for details.
|
48
|
-
@param {Array} [config.fixedBottom]
|
49
|
-
An array of CSS selectors that find elements fixed to the
|
50
|
-
bottom edge of the screen (using `position: fixed`).
|
51
|
-
See [`[up-fixed="bottom"]`](/up-fixed-bottom) for details.
|
52
|
-
@param {Array} [config.anchoredRight]
|
53
|
-
An array of CSS selectors that find elements anchored to the
|
54
|
-
right edge of the screen (using `right:0` with `position: fixed` or `position: absolute`).
|
55
|
-
See [`[up-anchored="right"]`](/up-anchored-right) for details.
|
56
|
-
@param {number} [config.revealSnap=50]
|
57
|
-
When [revealing](/up.reveal) elements, Unpoly will scroll an viewport
|
58
|
-
to the top when the revealed element is closer to the top than `config.revealSnap`.
|
59
|
-
@param {number} [config.revealPadding=0]
|
60
|
-
The desired padding between a [revealed](/up.reveal) element and the
|
61
|
-
closest [viewport](/up.viewport) edge (in pixels).
|
62
|
-
@param {number} [config.scrollSpeed=1]
|
63
|
-
The speed of the scrolling motion when [scrolling](/up.scroll) with `{ behavior: 'smooth' }`.
|
64
|
-
|
65
|
-
The default value (`1`) roughly corresponds to the speed of Chrome's
|
66
|
-
[native smooth scrolling](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions/behavior).
|
67
|
-
@stable
|
68
|
-
###
|
69
|
-
config = new up.Config
|
70
|
-
duration: 0
|
71
|
-
viewports: ['.up-modal-viewport', '[up-viewport]', '[up-fixed]']
|
72
|
-
fixedTop: ['[up-fixed~=top]']
|
73
|
-
fixedBottom: ['[up-fixed~=bottom]']
|
74
|
-
anchoredRight: ['[up-anchored~=right]', '[up-fixed~=top]', '[up-fixed~=bottom]', '[up-fixed~=right]']
|
75
|
-
revealSnap: 50
|
76
|
-
revealPadding: 0,
|
77
|
-
scrollSpeed: 1
|
78
|
-
|
79
|
-
# up.legacy.renamedProperty(config, 'snap', 'revealSnap')
|
80
|
-
# up.legacy.removedProperty(config, 'easing')
|
81
|
-
# up.legacy.removedProperty(config, 'duration')
|
82
|
-
|
83
|
-
lastScrollTops = new up.Cache
|
84
|
-
size: 30,
|
85
|
-
key: up.history.normalizeUrl
|
86
|
-
|
87
|
-
scrollingController = new up.MotionController('scrolling')
|
88
|
-
|
89
|
-
reset = ->
|
90
|
-
config.reset()
|
91
|
-
lastScrollTops.clear()
|
92
|
-
scrollingController.reset()
|
93
|
-
|
94
|
-
###**
|
95
|
-
Scrolls the given viewport to the given Y-position.
|
96
|
-
|
97
|
-
A "viewport" is an element that has scrollbars, e.g. `<body>` or
|
98
|
-
a container with `overflow-x: scroll`.
|
99
|
-
|
100
|
-
\#\#\# Example
|
101
|
-
|
102
|
-
This will scroll a `<div class="main">...</div>` to a Y-position of 100 pixels:
|
103
|
-
|
104
|
-
up.scroll('.main', 100)
|
105
|
-
|
106
|
-
\#\#\# Animating the scrolling motion
|
107
|
-
|
108
|
-
The scrolling can (optionally) be animated.
|
109
|
-
|
110
|
-
up.scroll('.main', 100, { behavior: 'smooth' })
|
111
|
-
|
112
|
-
If the given viewport is already in a scroll animation when `up.scroll()`
|
113
|
-
is called a second time, the previous animation will instantly jump to the
|
114
|
-
last frame before the next animation is started.
|
115
|
-
|
116
|
-
@function up.scroll
|
117
|
-
@param {string|Element|jQuery} viewport
|
118
|
-
The container element to scroll.
|
119
|
-
@param {number} scrollPos
|
120
|
-
The absolute number of pixels to set the scroll position to.
|
121
|
-
@param {string}[options.behavior='auto']
|
122
|
-
When set to `'auto'`, this will immediately scroll to the new position.
|
123
|
-
|
124
|
-
When set to `'smooth'`, this will scroll smoothly to the new position.
|
125
|
-
@param {number}[options.speed]
|
126
|
-
The speed of the scrolling motion when scrolling with `{ behavior: 'smooth' }`.
|
127
|
-
|
128
|
-
Defaults to `up.viewport.config.scrollSpeed`.
|
129
|
-
@return {Promise}
|
130
|
-
A promise that will be fulfilled when the scrolling ends.
|
131
|
-
@experimental
|
132
|
-
###
|
133
|
-
scroll = (viewport, scrollTop, options) ->
|
134
|
-
motion = new up.ScrollMotion(viewport, scrollTop, options)
|
135
|
-
scrollingController.startMotion(viewport, motion, options)
|
136
|
-
|
137
|
-
###**
|
138
|
-
Finishes scrolling animations in the given element, its ancestors or its descendants.
|
139
|
-
|
140
|
-
@function up.viewport.finishScrolling
|
141
|
-
@param {string|Element|jQuery}
|
142
|
-
@return {Promise}
|
143
|
-
@internal
|
144
|
-
###
|
145
|
-
finishScrolling = (element) ->
|
146
|
-
# Don't emit expensive events if no animation can be running anyway
|
147
|
-
return Promise.resolve() unless up.motion.isEnabled()
|
148
|
-
|
149
|
-
scrollable = closest(element)
|
150
|
-
scrollingController.finish(scrollable)
|
151
|
-
|
152
|
-
###**
|
153
|
-
@function up.viewport.anchoredRight
|
154
|
-
@internal
|
155
|
-
###
|
156
|
-
anchoredRight = ->
|
157
|
-
selector = config.anchoredRight.join(',')
|
158
|
-
e.all(selector)
|
159
|
-
|
160
|
-
###**
|
161
|
-
@function measureObstruction
|
162
|
-
@return {Object}
|
163
|
-
@internal
|
164
|
-
###
|
165
|
-
measureObstruction = (viewportHeight) ->
|
166
|
-
composeHeight = (obstructor, distanceFromEdgeProps) ->
|
167
|
-
distanceFromEdge = u.sum(distanceFromEdgeProps, (prop) -> e.styleNumber(obstructor, prop)) || 0
|
168
|
-
distanceFromEdge + obstructor.offsetHeight
|
169
|
-
|
170
|
-
measureTopObstructor = (obstructor) ->
|
171
|
-
composeHeight(obstructor, ['top', 'margin-top'])
|
172
|
-
|
173
|
-
measureBottomObstructor = (obstructor) ->
|
174
|
-
composeHeight(obstructor, ['bottom', 'margin-bottom'])
|
175
|
-
|
176
|
-
topObstructors = e.all(config.fixedTop.join(', '))
|
177
|
-
bottomObstructors = e.all(config.fixedBottom.join(', '))
|
178
|
-
|
179
|
-
topObstructions = u.map(topObstructors, measureTopObstructor)
|
180
|
-
bottomObstructions = u.map(bottomObstructors, measureBottomObstructor)
|
181
|
-
|
182
|
-
top: Math.max(0, topObstructions...)
|
183
|
-
bottom: Math.max(0, bottomObstructions...)
|
184
|
-
|
185
|
-
###**
|
186
|
-
Scroll's the given element's viewport so the first rows of the
|
187
|
-
element are visible for the user.
|
188
|
-
|
189
|
-
By default Unpoly will always reveal an element before
|
190
|
-
updating it with JavaScript functions like [`up.replace()`](/up.replace)
|
191
|
-
or UJS behavior like [`[up-target]`](/a-up-target).
|
192
|
-
|
193
|
-
\#\#\# How Unpoly finds the viewport
|
194
|
-
|
195
|
-
The viewport (the container that is going to be scrolled)
|
196
|
-
is the closest parent of the element that is either:
|
197
|
-
|
198
|
-
- the currently open [modal](/up.modal)
|
199
|
-
- an element with the attribute `[up-viewport]`
|
200
|
-
- the `<body>` element
|
201
|
-
- an element matching the selector you have configured using `up.viewport.config.viewports.push('my-custom-selector')`
|
202
|
-
|
203
|
-
\#\#\# Fixed elements obstruction the viewport
|
204
|
-
|
205
|
-
Many applications have a navigation bar fixed to the top or bottom,
|
206
|
-
obstructing the view on an element.
|
207
|
-
|
208
|
-
You can make `up.reveal()` aware of these fixed elements
|
209
|
-
so it can scroll the viewport far enough so the revealed element is fully visible.
|
210
|
-
To make `up.reveal()` aware fixed elements you can either:
|
211
|
-
|
212
|
-
- give the element an attribute [`up-fixed="top"`](/up-fixed-top) or [`up-fixed="bottom"`](up-fixed-bottom)
|
213
|
-
- [configure default options](/up.viewport.config) for `fixedTop` or `fixedBottom`
|
214
|
-
|
215
|
-
@function up.reveal
|
216
|
-
@param {string|Element|jQuery} element
|
217
|
-
@param {number} [options.speed]
|
218
|
-
@param {string} [options.snap]
|
219
|
-
@param {string|Element|jQuery} [options.viewport]
|
220
|
-
@param {boolean} [options.top=false]
|
221
|
-
Whether to scroll the viewport so that the first element row aligns
|
222
|
-
with the top edge of the viewport.
|
223
|
-
@param {string}[options.behavior='auto']
|
224
|
-
When set to `'auto'`, this will immediately scroll to the new position.
|
225
|
-
|
226
|
-
When set to `'smooth'`, this will scroll smoothly to the new position.
|
227
|
-
@param {number}[options.speed]
|
228
|
-
The speed of the scrolling motion when scrolling with `{ behavior: 'smooth' }`.
|
229
|
-
|
230
|
-
Defaults to `up.viewport.config.scrollSpeed`.
|
231
|
-
@param {number} [config.padding=0]
|
232
|
-
The desired padding between the revealed element and the
|
233
|
-
closest [viewport](/up.viewport) edge (in pixels).
|
234
|
-
@param {number|boolean} [config.snap]
|
235
|
-
Whether to snap to the top of the viewport if the new scroll position
|
236
|
-
after revealing the element is close to the top edge.
|
237
|
-
|
238
|
-
You may pass a maximum number of pixels under which to snap to the top.
|
239
|
-
|
240
|
-
Passing `false` will disable snapping.
|
241
|
-
|
242
|
-
Passing `true` will use the snap pixel value from `up.viewport.config.revealSnap`.
|
243
|
-
@return {Promise}
|
244
|
-
A promise that fulfills when the element is revealed.
|
245
|
-
@stable
|
246
|
-
###
|
247
|
-
reveal = (elementOrSelector, options) ->
|
248
|
-
element = e.get(elementOrSelector)
|
249
|
-
motion = new up.RevealMotion(element, options)
|
250
|
-
scrollingController.startMotion(element, motion, options)
|
251
|
-
|
252
|
-
###**
|
253
|
-
@function up.viewport.scrollAfterInsertFragment
|
254
|
-
@param {boolean|object} [options.restoreScroll]
|
255
|
-
@param {boolean|string|jQuery|Element} [options.reveal]
|
256
|
-
@param {boolean|string} [options.reveal]
|
257
|
-
@return {Promise}
|
258
|
-
A promise that is fulfilled when the scrolling has finished.
|
259
|
-
@internal
|
260
|
-
###
|
261
|
-
scrollAfterInsertFragment = (element, options = {}) ->
|
262
|
-
hashOpt = options.hash
|
263
|
-
revealOpt = options.reveal
|
264
|
-
restoreScrollOpt = options.restoreScroll
|
265
|
-
|
266
|
-
scrollOptions = u.only(options, 'scrollBehavior', 'scrollSpeed')
|
267
|
-
|
268
|
-
if restoreScrollOpt
|
269
|
-
# If options.restoreScroll is an object, its keys map viewport selectors
|
270
|
-
# to scroll positions. If it is just true, we leave the scrollTops option
|
271
|
-
# undefined and let restoreScroll() retrieve previous scrollTops from cache.
|
272
|
-
givenTops = u.presence(restoreScrollOpt, u.isObject)
|
273
|
-
return restoreScroll(around: element, scrollTops: givenTops)
|
274
|
-
|
275
|
-
else if hashOpt && revealOpt == true # hash revealing can be disabled with { reveal: false }
|
276
|
-
return revealHash(hashOpt, scrollOptions)
|
277
|
-
|
278
|
-
else if revealOpt
|
279
|
-
# We allow to pass another element as { reveal } option
|
280
|
-
if u.isElement(revealOpt) || u.isJQuery(revealOpt)
|
281
|
-
element = e.get(revealOpt)
|
282
|
-
|
283
|
-
# We allow to pass a selector as { reveal } option
|
284
|
-
else if u.isString(revealOpt)
|
285
|
-
selector = e.resolveSelector(revealOpt, options.origin)
|
286
|
-
element = up.fragment.first(selector)
|
287
|
-
|
288
|
-
else
|
289
|
-
# We reveal the given element
|
290
|
-
|
291
|
-
# If selectorOrElement was a CSS selector, don't blow up by calling reveal()
|
292
|
-
# with an empty jQuery collection. This might happen if a failed form submission
|
293
|
-
# reveals the first validation error message, but the error is shown in an
|
294
|
-
# unexpected element.
|
295
|
-
if element
|
296
|
-
return reveal(element, scrollOptions)
|
297
|
-
|
298
|
-
else
|
299
|
-
# If we didn't need to scroll above, just return a resolved promise
|
300
|
-
# to fulfill this function's signature.
|
301
|
-
return Promise.resolve()
|
302
|
-
|
303
|
-
###**
|
304
|
-
[Reveals](/up.reveal) an element matching the given `#hash` anchor.
|
305
|
-
|
306
|
-
Other than the default behavior found in browsers, `up.revealHash` works with
|
307
|
-
[multiple viewports](/up-viewport) and honors [fixed elements](/up-fixed-top) obstructing the user's
|
308
|
-
view of the viewport.
|
309
|
-
|
310
|
-
When the page loads initially, this function is automatically called with the hash from
|
311
|
-
the current URL.
|
312
|
-
|
313
|
-
If no element matches the given `#hash` anchor, a resolved promise is returned.
|
314
|
-
|
315
|
-
\#\#\# Example
|
316
|
-
|
317
|
-
up.revealHash('#chapter2')
|
318
|
-
|
319
|
-
@function up.viewport.revealHash
|
320
|
-
@param {string} hash
|
321
|
-
|
322
|
-
@return {Promise}
|
323
|
-
A promise that is fulfilled when scroll position has changed to match the location hash.
|
324
|
-
@experimental
|
325
|
-
###
|
326
|
-
revealHash = (hash) ->
|
327
|
-
if (hash) && (match = firstHashTarget(hash))
|
328
|
-
reveal(match, top: true)
|
329
|
-
else
|
330
|
-
Promise.resolve()
|
331
|
-
|
332
|
-
allSelector = ->
|
333
|
-
# On Edge the document viewport can be changed from CSS
|
334
|
-
[rootSelector(), config.viewports...].join(',')
|
335
|
-
|
336
|
-
###**
|
337
|
-
Returns the scrolling container for the given element.
|
338
|
-
|
339
|
-
Returns the [document's scrolling element](/up.viewport.root)
|
340
|
-
if no closer viewport exists.
|
341
|
-
|
342
|
-
@function up.viewport.closest
|
343
|
-
@param {string|Element|jQuery} selectorOrElement
|
344
|
-
@return {Element}
|
345
|
-
@experimental
|
346
|
-
###
|
347
|
-
closest = (selectorOrElement) ->
|
348
|
-
element = e.get(selectorOrElement)
|
349
|
-
e.closest(element, allSelector())
|
350
|
-
|
351
|
-
###**
|
352
|
-
Returns a jQuery collection of all the viewports contained within the
|
353
|
-
given selector or element.
|
354
|
-
|
355
|
-
@function up.viewport.subtree
|
356
|
-
@param {string|Element|jQuery} selectorOrElement
|
357
|
-
@return List<Element>
|
358
|
-
@internal
|
359
|
-
###
|
360
|
-
getSubtree = (selectorOrElement) ->
|
361
|
-
element = e.get(selectorOrElement)
|
362
|
-
e.subtree(element, allSelector())
|
363
|
-
|
364
|
-
getAround = (selectorOrElement) ->
|
365
|
-
element = e.get(selectorOrElement)
|
366
|
-
e.list(closest(element), getSubtree(element))
|
367
|
-
|
368
|
-
###**
|
369
|
-
Returns a list of all the viewports on the screen.
|
370
|
-
|
371
|
-
@function up.viewport.all
|
372
|
-
@internal
|
373
|
-
###
|
374
|
-
getAll = ->
|
375
|
-
e.all(allSelector())
|
376
|
-
|
377
|
-
rootSelector = ->
|
378
|
-
# The spec says this should be <html> in standards mode
|
379
|
-
# and <body> in quirks mode. However, it is currently (2018-07)
|
380
|
-
# always <body> in Webkit browsers (not Blink). Luckily Webkit
|
381
|
-
# also supports document.scrollingElement.
|
382
|
-
if element = document.scrollingElement
|
383
|
-
element.tagName
|
384
|
-
else
|
385
|
-
# IE11
|
386
|
-
'html'
|
387
|
-
|
388
|
-
###**
|
389
|
-
Return the [scrolling element](https://developer.mozilla.org/en-US/docs/Web/API/document/scrollingElement)
|
390
|
-
for the browser's main content area.
|
391
|
-
|
392
|
-
@function up.viewport.root
|
393
|
-
@return {Element}
|
394
|
-
@experimental
|
395
|
-
###
|
396
|
-
getRoot = ->
|
397
|
-
document.querySelector(rootSelector())
|
398
|
-
|
399
|
-
rootWidth = ->
|
400
|
-
# This should happen on the <html> element, regardless of document.scrollingElement
|
401
|
-
e.root().clientWidth
|
402
|
-
|
403
|
-
rootHeight = ->
|
404
|
-
# This should happen on the <html> element, regardless of document.scrollingElement
|
405
|
-
e.root().clientHeight
|
406
|
-
|
407
|
-
isRoot = (element) ->
|
408
|
-
e.matches(element, rootSelector())
|
409
|
-
|
410
|
-
###**
|
411
|
-
Returns whether the given element is currently showing a vertical scrollbar.
|
412
|
-
|
413
|
-
@function up.viewport.rootHasVerticalScrollbar
|
414
|
-
@internal
|
415
|
-
###
|
416
|
-
rootHasVerticalScrollbar = ->
|
417
|
-
# We could also check if scrollHeight > offsetHeight for the document viewport.
|
418
|
-
# However, we would also need to check overflow-y for that element.
|
419
|
-
# Also we have no control whether developers set the property on <body> or <html>.
|
420
|
-
# https://tylercipriani.com/blog/2014/07/12/crossbrowser-javascript-scrollbar-detection/
|
421
|
-
window.innerWidth > document.documentElement.offsetWidth
|
422
|
-
|
423
|
-
###**
|
424
|
-
Returns the element that controls the `overflow-y` behavior for the
|
425
|
-
[document viewport](/up.viewport.root()).
|
426
|
-
|
427
|
-
@function up.viewport.rootOverflowElement
|
428
|
-
@internal
|
429
|
-
###
|
430
|
-
rootOverflowElement = ->
|
431
|
-
body = document.body
|
432
|
-
html = document.documentElement
|
433
|
-
|
434
|
-
element = u.find([html, body], wasChosenAsOverflowingElement)
|
435
|
-
element || getRoot()
|
436
|
-
|
437
|
-
###**
|
438
|
-
Returns whether the given element was chosen as the overflowing
|
439
|
-
element by the developer.
|
440
|
-
|
441
|
-
We have no control whether developers set the property on <body> or
|
442
|
-
<html>. The developer also won't know what is going to be the
|
443
|
-
[scrolling element](/up.viewport.root()) on the user's brower.
|
444
|
-
|
445
|
-
@function wasChosenAsOverflowingElement
|
446
|
-
@internal
|
447
|
-
###
|
448
|
-
wasChosenAsOverflowingElement = (element) ->
|
449
|
-
overflowY = e.style(element, 'overflow-y')
|
450
|
-
overflowY == 'auto' || overflowY == 'scroll'
|
451
|
-
|
452
|
-
###**
|
453
|
-
Returns the width of a scrollbar.
|
454
|
-
|
455
|
-
This only runs once per page load.
|
456
|
-
|
457
|
-
@function up.viewport.scrollbarWidth
|
458
|
-
@internal
|
459
|
-
###
|
460
|
-
scrollbarWidth = u.memoize ->
|
461
|
-
# This is how Bootstrap does it also:
|
462
|
-
# https://github.com/twbs/bootstrap/blob/c591227602996c542b9fd0cb65cff3cc9519bdd5/dist/js/bootstrap.js#L1187
|
463
|
-
outerStyle =
|
464
|
-
position: 'absolute'
|
465
|
-
top: '0'
|
466
|
-
left: '0'
|
467
|
-
width: '100px'
|
468
|
-
height: '100px' # Firefox needs at least 100px to show a scrollbar
|
469
|
-
overflowY: 'scroll'
|
470
|
-
outer = up.element.affix(document.body, '[up-viewport]', { style: outerStyle })
|
471
|
-
width = outer.offsetWidth - outer.clientWidth
|
472
|
-
up.element.remove(outer)
|
473
|
-
width
|
474
|
-
|
475
|
-
scrollTopKey = (viewport) ->
|
476
|
-
e.toSelector(viewport)
|
477
|
-
|
478
|
-
###**
|
479
|
-
Returns a hash with scroll positions.
|
480
|
-
|
481
|
-
Each key in the hash is a viewport selector. The corresponding
|
482
|
-
value is the viewport's top scroll position:
|
483
|
-
|
484
|
-
up.viewport.scrollTops()
|
485
|
-
=> { '.main': 0, '.sidebar': 73 }
|
486
|
-
|
487
|
-
@function up.viewport.scrollTops
|
488
|
-
@return Object<string, number>
|
489
|
-
@internal
|
490
|
-
###
|
491
|
-
scrollTops = ->
|
492
|
-
u.mapObject getAll(), (viewport) ->
|
493
|
-
[scrollTopKey(viewport), viewport.scrollTop]
|
494
|
-
|
495
|
-
###**
|
496
|
-
@function up.viewport.fixedElements
|
497
|
-
@internal
|
498
|
-
###
|
499
|
-
fixedElements = (root = document) ->
|
500
|
-
queryParts = ['[up-fixed]'].concat(config.fixedTop).concat(config.fixedBottom)
|
501
|
-
root.querySelectorAll(queryParts.join(','))
|
502
|
-
|
503
|
-
###**
|
504
|
-
Saves the top scroll positions of all the
|
505
|
-
viewports configured in [`up.viewport.config.viewports`](/up.viewport.config).
|
506
|
-
|
507
|
-
The scroll positions will be associated with the current URL.
|
508
|
-
They can later be restored by calling [`up.viewport.restoreScroll()`](/up.viewport.restoreScroll)
|
509
|
-
at the same URL.
|
510
|
-
|
511
|
-
Unpoly automatically saves scroll positions whenever a fragment was updated on the page.
|
512
|
-
|
513
|
-
@function up.viewport.saveScroll
|
514
|
-
@param {string} [options.url]
|
515
|
-
@param {Object<string, number>} [options.tops]
|
516
|
-
@experimental
|
517
|
-
###
|
518
|
-
saveScroll = (options = {}) ->
|
519
|
-
url = options.url ? up.history.url()
|
520
|
-
tops = options.tops ? scrollTops()
|
521
|
-
lastScrollTops.set(url, tops)
|
522
|
-
|
523
|
-
###**
|
524
|
-
Restores [previously saved](/up.viewport.saveScroll) scroll positions of viewports
|
525
|
-
viewports configured in [`up.viewport.config.viewports`](/up.viewport.config).
|
526
|
-
|
527
|
-
Unpoly automatically restores scroll positions when the user presses the back button.
|
528
|
-
You can disable this behavior by setting [`up.history.config.restoreScroll = false`](/up.history.config).
|
529
|
-
|
530
|
-
@function up.viewport.restoreScroll
|
531
|
-
@param {Element} [options.around]
|
532
|
-
If set, only restores viewports that are either an ancestor
|
533
|
-
or descendant of the given element.
|
534
|
-
@return {Promise}
|
535
|
-
A promise that will be fulfilled once scroll positions have been restored.
|
536
|
-
@experimental
|
537
|
-
###
|
538
|
-
restoreScroll = (options = {}) ->
|
539
|
-
url = up.history.url()
|
540
|
-
viewports = if options.around then getAround(options.around) else getAll()
|
541
|
-
scrollTopsForUrl = options.scrollTops || lastScrollTops.get(url) || {}
|
542
|
-
|
543
|
-
up.log.group 'Restoring scroll positions for URL %s to %o', url, scrollTopsForUrl, ->
|
544
|
-
allScrollPromises = u.map viewports, (viewport) ->
|
545
|
-
key = scrollTopKey(viewport)
|
546
|
-
scrollTop = scrollTopsForUrl[key] || 0
|
547
|
-
scroll(viewport, scrollTop, duration: 0)
|
548
|
-
|
549
|
-
Promise.all(allScrollPromises)
|
550
|
-
|
551
|
-
###**
|
552
|
-
@internal
|
553
|
-
###
|
554
|
-
absolutize = (elementOrSelector, options = {}) ->
|
555
|
-
element = e.get(elementOrSelector)
|
556
|
-
viewport = up.viewport.closest(element)
|
557
|
-
|
558
|
-
viewportRect = viewport.getBoundingClientRect()
|
559
|
-
originalRect = element.getBoundingClientRect()
|
560
|
-
|
561
|
-
boundsRect = new up.Rect
|
562
|
-
left: originalRect.left - viewportRect.left
|
563
|
-
top: originalRect.top - viewportRect.top
|
564
|
-
width: originalRect.width
|
565
|
-
height: originalRect.height
|
566
|
-
|
567
|
-
# Allow the caller to run code before we start shifting elements around.
|
568
|
-
options.afterMeasure?()
|
569
|
-
|
570
|
-
e.setStyle element,
|
571
|
-
# If the element had a layout context before, make sure the
|
572
|
-
# ghost will have layout context as well (and vice versa).
|
573
|
-
position: if element.style.position == 'static' then 'static' else 'relative'
|
574
|
-
top: 'auto' # CSS default
|
575
|
-
right: 'auto' # CSS default
|
576
|
-
bottom: 'auto' # CSS default
|
577
|
-
left: 'auto' # CSS default
|
578
|
-
width: '100%' # stretch to the .up-bounds width we set below
|
579
|
-
height: '100%' # stretch to the .up-bounds height we set below
|
580
|
-
|
581
|
-
# Wrap the ghost in another container so its margin can expand
|
582
|
-
# freely. If we would position the element directly (old implementation),
|
583
|
-
# it would gain a layout context which cannot be crossed by margins.
|
584
|
-
bounds = e.createFromSelector('.up-bounds')
|
585
|
-
# Insert the bounds object before our element, then move element into it.
|
586
|
-
e.insertBefore(element, bounds)
|
587
|
-
bounds.appendChild(element)
|
588
|
-
|
589
|
-
moveBounds = (diffX, diffY) ->
|
590
|
-
boundsRect.left += diffX
|
591
|
-
boundsRect.top += diffY
|
592
|
-
e.setStyle(bounds, boundsRect)
|
593
|
-
|
594
|
-
# Position the bounds initially
|
595
|
-
moveBounds(0, 0)
|
596
|
-
|
597
|
-
# In theory, element should not have moved visually. However, element
|
598
|
-
# (or a child of element) might collapse its margin against a previous
|
599
|
-
# sibling element, and now that it is absolute it does not have the
|
600
|
-
# same sibling. So we manually correct element's top position so it aligns
|
601
|
-
# with the previous top position.
|
602
|
-
newElementRect = element.getBoundingClientRect()
|
603
|
-
moveBounds(originalRect.left - newElementRect.left, originalRect.top - newElementRect.top)
|
604
|
-
|
605
|
-
u.each(fixedElements(element), e.fixedToAbsolute)
|
606
|
-
|
607
|
-
bounds: bounds
|
608
|
-
moveBounds: moveBounds
|
609
|
-
|
610
|
-
###**
|
611
|
-
Marks this element as a scrolling container ("viewport").
|
612
|
-
|
613
|
-
Apply this attribute if your app uses a custom panel layout with fixed positioning
|
614
|
-
instead of scrolling `<body>`. As an alternative you can also push a selector
|
615
|
-
matching your custom viewport to the [`up.viewport.config.viewports`](/up.viewport.config) array.
|
616
|
-
|
617
|
-
[`up.reveal()`](/up.reveal) will always try to scroll the viewport closest
|
618
|
-
to the element that is being revealed. By default this is the `<body>` element.
|
619
|
-
|
620
|
-
\#\#\# Example
|
621
|
-
|
622
|
-
Here is an example for a layout for an e-mail client, showing a list of e-mails
|
623
|
-
on the left side and the e-mail text on the right side:
|
624
|
-
|
625
|
-
.side {
|
626
|
-
position: fixed;
|
627
|
-
top: 0;
|
628
|
-
bottom: 0;
|
629
|
-
left: 0;
|
630
|
-
width: 100px;
|
631
|
-
overflow-y: scroll;
|
632
|
-
}
|
633
|
-
|
634
|
-
.main {
|
635
|
-
position: fixed;
|
636
|
-
top: 0;
|
637
|
-
bottom: 0;
|
638
|
-
left: 100px;
|
639
|
-
right: 0;
|
640
|
-
overflow-y: scroll;
|
641
|
-
}
|
642
|
-
|
643
|
-
This would be the HTML (notice the `up-viewport` attribute):
|
644
|
-
|
645
|
-
<div class=".side" up-viewport>
|
646
|
-
<a href="/emails/5001" up-target=".main">Re: Your invoice</a>
|
647
|
-
<a href="/emails/2023" up-target=".main">Quote for services</a>
|
648
|
-
<a href="/emails/9002" up-target=".main">Fwd: Room reservation</a>
|
649
|
-
</div>
|
650
|
-
|
651
|
-
<div class="main" up-viewport>
|
652
|
-
<h1>Re: Your Invoice</h1>
|
653
|
-
<p>
|
654
|
-
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
|
655
|
-
Stet clita kasd gubergren, no sea takimata sanctus est.
|
656
|
-
</p>
|
657
|
-
</div>
|
658
|
-
|
659
|
-
@selector [up-viewport]
|
660
|
-
@stable
|
661
|
-
###
|
662
|
-
|
663
|
-
###**
|
664
|
-
Marks this element as being fixed to the top edge of the screen
|
665
|
-
using `position: fixed`.
|
666
|
-
|
667
|
-
When [following a fragment link](/a-up-target), the viewport is scrolled
|
668
|
-
so the targeted element becomes visible. By using this attribute you can make
|
669
|
-
Unpoly aware of fixed elements that are obstructing the viewport contents.
|
670
|
-
Unpoly will then scroll the viewport far enough that the revealed element is fully visible.
|
671
|
-
|
672
|
-
Instead of using this attribute,
|
673
|
-
you can also configure a selector in [`up.viewport.config.fixedTop`](/up.viewport.config#config.fixedTop).
|
674
|
-
|
675
|
-
\#\#\# Example
|
676
|
-
|
677
|
-
<div class="top-nav" up-fixed="top">...</div>
|
678
|
-
|
679
|
-
@selector [up-fixed=top]
|
680
|
-
@stable
|
681
|
-
###
|
682
|
-
|
683
|
-
###**
|
684
|
-
Marks this element as being fixed to the bottom edge of the screen
|
685
|
-
using `position: fixed`.
|
686
|
-
|
687
|
-
When [following a fragment link](/a-up-target), the viewport is scrolled
|
688
|
-
so the targeted element becomes visible. By using this attribute you can make
|
689
|
-
Unpoly aware of fixed elements that are obstructing the viewport contents.
|
690
|
-
Unpoly will then scroll the viewport far enough that the revealed element is fully visible.
|
691
|
-
|
692
|
-
Instead of using this attribute,
|
693
|
-
you can also configure a selector in [`up.viewport.config.fixedBottom`](/up.viewport.config#config.fixedBottom).
|
694
|
-
|
695
|
-
\#\#\# Example
|
696
|
-
|
697
|
-
<div class="bottom-nav" up-fixed="bottom">...</div>
|
698
|
-
|
699
|
-
@selector [up-fixed=bottom]
|
700
|
-
@stable
|
701
|
-
###
|
702
|
-
|
703
|
-
|
704
|
-
###**
|
705
|
-
Marks this element as being anchored to the right edge of the screen,
|
706
|
-
typically fixed navigation bars.
|
707
|
-
|
708
|
-
Since [modal dialogs](/up.modal) hide the document scroll bar,
|
709
|
-
elements anchored to the right appear to jump when the dialog opens or
|
710
|
-
closes. Applying this attribute to anchored elements will make Unpoly
|
711
|
-
aware of the issue and adjust the `right` property accordingly.
|
712
|
-
|
713
|
-
You should give this attribute to layout elements
|
714
|
-
with a CSS of `right: 0` with `position: fixed` or `position:absolute`.
|
715
|
-
|
716
|
-
Instead of giving this attribute to any affected element,
|
717
|
-
you can also configure a selector in [`up.viewport.config.anchoredRight`](/up.viewport.config#config.anchoredRight).
|
718
|
-
|
719
|
-
\#\#\# Example
|
720
|
-
|
721
|
-
Here is the CSS for a navigation bar that is anchored to the top edge of the screen:
|
722
|
-
|
723
|
-
.top-nav {
|
724
|
-
position: fixed;
|
725
|
-
top: 0;
|
726
|
-
left: 0;
|
727
|
-
right: 0;
|
728
|
-
}
|
729
|
-
|
730
|
-
By adding an `up-anchored="right"` attribute to the element, we can prevent the
|
731
|
-
`right` edge from jumping when a [modal dialog](/up.modal) opens or closes:
|
732
|
-
|
733
|
-
<div class="top-nav" up-anchored="right">...</div>
|
734
|
-
|
735
|
-
@selector [up-anchored=right]
|
736
|
-
@stable
|
737
|
-
###
|
738
|
-
|
739
|
-
###**
|
740
|
-
@function up.viewport.firstHashTarget
|
741
|
-
@internal
|
742
|
-
###
|
743
|
-
firstHashTarget = (hash) ->
|
744
|
-
if hash = pureHash(hash)
|
745
|
-
selector = [
|
746
|
-
# First match an <* up-id="hash">. This won't be picked up without JS,
|
747
|
-
# preventing the scroll position from jump if up.viewport.revealPadding
|
748
|
-
# is set.
|
749
|
-
e.attributeSelector('up-id', hash),
|
750
|
-
# Match an <* id="hash">
|
751
|
-
e.attributeSelector('id', hash),
|
752
|
-
# Match an <a name="hash">
|
753
|
-
'a' + e.attributeSelector('name', hash)
|
754
|
-
].join(',')
|
755
|
-
up.fragment.first(selector)
|
756
|
-
|
757
|
-
###**
|
758
|
-
Returns `'foo'` if the hash is `'#foo'`.
|
759
|
-
|
760
|
-
Returns undefined if the hash is `'#'`, `''` or `undefined`.
|
761
|
-
|
762
|
-
@function pureHash
|
763
|
-
@internal
|
764
|
-
###
|
765
|
-
pureHash = (value) ->
|
766
|
-
if value && value[0] == '#'
|
767
|
-
value = value.substr(1)
|
768
|
-
u.presence(value)
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
up.on 'up:app:booted', -> revealHash(location.hash)
|
773
|
-
|
774
|
-
up.on 'up:framework:reset', reset
|
775
|
-
|
776
|
-
<% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
|
777
|
-
reveal: reveal
|
778
|
-
revealHash: revealHash
|
779
|
-
firstHashTarget: firstHashTarget
|
780
|
-
scroll: scroll
|
781
|
-
config: config
|
782
|
-
closest: closest
|
783
|
-
subtree: getSubtree
|
784
|
-
around: getAround
|
785
|
-
all: getAll
|
786
|
-
rootSelector: rootSelector
|
787
|
-
root: getRoot
|
788
|
-
rootWidth: rootWidth
|
789
|
-
rootHeight: rootHeight
|
790
|
-
rootHasVerticalScrollbar: rootHasVerticalScrollbar
|
791
|
-
rootOverflowElement: rootOverflowElement
|
792
|
-
isRoot: isRoot
|
793
|
-
scrollbarWidth: scrollbarWidth
|
794
|
-
scrollTops: scrollTops
|
795
|
-
saveScroll: saveScroll
|
796
|
-
restoreScroll: restoreScroll
|
797
|
-
scrollAfterInsertFragment: scrollAfterInsertFragment
|
798
|
-
anchoredRight: anchoredRight
|
799
|
-
fixedElements: fixedElements
|
800
|
-
absolutize: absolutize
|
801
|
-
|
802
|
-
up.scroll = up.viewport.scroll
|
803
|
-
up.reveal = up.viewport.reveal
|
804
|
-
up.revealHash = up.viewport.revealHash
|
805
|
-
|
806
|
-
up.legacy.renamedModule 'layout', 'viewport'
|