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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +43 -25
- data/README.md +5 -6
- 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 +15376 -10484
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +6 -4
- 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/change.rb +372 -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
- data/lib/unpoly-rails.rb +9 -3
- metadata +42 -316
- data/.gitignore +0 -10
- data/.ruby-version +0 -1
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -39
- data/Rakefile +0 -154
- 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/browser.coffee.erb +0 -240
- data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +0 -45
- 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 -64
- 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 -544
- 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 -247
- 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 -1129
- data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -445
- data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
- data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1084
- data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -928
- data/lib/assets/javascripts/unpoly/framework.coffee +0 -65
- 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 -253
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -827
- 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 -300
- 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 -476
- 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 -1677
- data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -830
- 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-bootstrap3.coffee +0 -2
- data/lib/assets/javascripts/unpoly.coffee +0 -28
- 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/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
- data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
- data/lib/assets/stylesheets/unpoly.sass +0 -1
- 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 -29
- data/spec_app/Gemfile.lock +0 -223
- 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 -5
- 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/boot_test_controller.rb +0 -31
- 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 -17
- 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 -11
- data/spec_app/app/mailers/.keep +0 -0
- data/spec_app/app/models/concerns/.keep +0 -0
- data/spec_app/app/views/boot_test/defer.erb +0 -18
- data/spec_app/app/views/boot_test/module.erb +0 -18
- data/spec_app/app/views/boot_test/sync.erb +0 -17
- data/spec_app/app/views/compiler_test/timestamp.erb +0 -10
- 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 -6
- 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 -82
- 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/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 -33
- data/spec_app/config/secrets.yml +0 -22
- data/spec_app/config.ru +0 -4
- 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 -1527
- data/spec_app/spec/javascripts/up/fragment_spec.js.coffee +0 -2624
- 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 -1098
- data/spec_app/spec/javascripts/up/log_spec.js.coffee +0 -119
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +0 -939
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +0 -582
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +0 -508
- data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +0 -39
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +0 -1145
- 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 -1434
- 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,622 +0,0 @@
|
|
1
|
-
###**
|
2
|
-
Linking to fragments
|
3
|
-
====================
|
4
|
-
|
5
|
-
The `up.link` module lets you build links that update fragments instead of entire pages.
|
6
|
-
|
7
|
-
\#\#\# Motivation
|
8
|
-
|
9
|
-
In a traditional web application, the entire page is destroyed and re-created when the
|
10
|
-
user follows a link:
|
11
|
-
|
12
|
-
![Traditional page flow](/images/tutorial/fragment_flow_vanilla.svg){:width="620" class="picture has_border is_sepia has_padding"}
|
13
|
-
|
14
|
-
This makes for an unfriendly experience:
|
15
|
-
|
16
|
-
- State changes caused by AJAX updates get lost during the page transition.
|
17
|
-
- Unsaved form changes get lost during the page transition.
|
18
|
-
- The JavaScript VM is reset during the page transition.
|
19
|
-
- If the page layout is composed from multiple scrollable containers
|
20
|
-
(e.g. a pane view), the scroll positions get lost during the page transition.
|
21
|
-
- The user sees a "flash" as the browser loads and renders the new page,
|
22
|
-
even if large portions of the old and new page are the same (navigation, layout, etc.).
|
23
|
-
|
24
|
-
Unpoly fixes this by letting you annotate links with an [`up-target`](/a-up-target)
|
25
|
-
attribute. The value of this attribute is a CSS selector that indicates which page
|
26
|
-
fragment to update. The server **still renders full HTML pages**, but we only use
|
27
|
-
the targeted fragments and discard the rest:
|
28
|
-
|
29
|
-
![Unpoly page flow](/images/tutorial/fragment_flow_unpoly.svg){:width="620" class="picture has_border is_sepia has_padding"}
|
30
|
-
|
31
|
-
With this model, following links feels smooth. All transient DOM changes outside the updated fragment are preserved.
|
32
|
-
Pages also load much faster since the DOM, CSS and Javascript environments do not need to be
|
33
|
-
destroyed and recreated for every request.
|
34
|
-
|
35
|
-
|
36
|
-
\#\#\# Example
|
37
|
-
|
38
|
-
Let's say we are rendering three pages with a tabbed navigation to switch between screens:
|
39
|
-
|
40
|
-
Your HTML could look like this:
|
41
|
-
|
42
|
-
```
|
43
|
-
<nav>
|
44
|
-
<a href="/pages/a">A</a>
|
45
|
-
<a href="/pages/b">B</a>
|
46
|
-
<a href="/pages/b">C</a>
|
47
|
-
</nav>
|
48
|
-
|
49
|
-
<article>
|
50
|
-
Page A
|
51
|
-
</article>
|
52
|
-
```
|
53
|
-
|
54
|
-
Since we only want to update the `<article>` tag, we annotate the links
|
55
|
-
with an `up-target` attribute:
|
56
|
-
|
57
|
-
```
|
58
|
-
<nav>
|
59
|
-
<a href="/pages/a" up-target="article">A</a>
|
60
|
-
<a href="/pages/b" up-target="article">B</a>
|
61
|
-
<a href="/pages/b" up-target="article">C</a>
|
62
|
-
</nav>
|
63
|
-
```
|
64
|
-
|
65
|
-
Note that instead of `article` you can use any other CSS selector like `#main .article`.
|
66
|
-
|
67
|
-
With these [`up-target`](/a-up-target) annotations Unpoly only updates the targeted part of the screen.
|
68
|
-
The JavaScript environment will persist and the user will not see a white flash while the
|
69
|
-
new page is loading.
|
70
|
-
|
71
|
-
@module up.link
|
72
|
-
###
|
73
|
-
|
74
|
-
up.link = do ->
|
75
|
-
|
76
|
-
u = up.util
|
77
|
-
e = up.element
|
78
|
-
|
79
|
-
###**
|
80
|
-
Fetches this given URL with JavaScript and [replaces](/up.replace) the
|
81
|
-
current `<body>` element with the response's `<body>` element.
|
82
|
-
|
83
|
-
\#\#\# Example
|
84
|
-
|
85
|
-
This would replace the current page with the response for `/users`:
|
86
|
-
|
87
|
-
up.visit('/users')
|
88
|
-
|
89
|
-
@function up.visit
|
90
|
-
@param {string} url
|
91
|
-
The URL to visit.
|
92
|
-
@param {string} [options.target='body']
|
93
|
-
The selector to replace.
|
94
|
-
@param {Object} [options]
|
95
|
-
See options for [`up.replace()`](/up.replace)
|
96
|
-
@stable
|
97
|
-
###
|
98
|
-
visit = (url, options = {}) ->
|
99
|
-
selector = options.target ? 'body'
|
100
|
-
up.replace(selector, url, options)
|
101
|
-
|
102
|
-
###**
|
103
|
-
Fetches the given link's `[href]` with JavaScript and [replaces](/up.replace) the current page with HTML from the response.
|
104
|
-
|
105
|
-
By default the page's `<body>` element will be replaced.
|
106
|
-
If the link has an attribute like `a[up-target]`
|
107
|
-
or `a[up-modal]`, the respective Unpoly behavior will be used.
|
108
|
-
|
109
|
-
Emits the event `up:link:follow`.
|
110
|
-
|
111
|
-
\#\#\# Examples
|
112
|
-
|
113
|
-
Assume we have a link with an `a[up-target]` attribute:
|
114
|
-
|
115
|
-
<a href="/users" up-target=".main">Users</a>
|
116
|
-
|
117
|
-
Calling `up.follow()` with this link will replace the page's `.main` fragment
|
118
|
-
as if the user had clicked on the link:
|
119
|
-
|
120
|
-
var link = document.querySelector('a')
|
121
|
-
up.follow(link)
|
122
|
-
|
123
|
-
@function up.follow
|
124
|
-
@param {Element|jQuery|string} linkOrSelector
|
125
|
-
An element or selector which is either an `<a>` tag or any element with an `[up-href]` attribute.
|
126
|
-
@param {string} [options.target]
|
127
|
-
The selector to replace.
|
128
|
-
|
129
|
-
Defaults to the link's `[up-target]`, `[up-modal]` or `[up-popup]` attribute.
|
130
|
-
If no target is given, the `<body>` element will be replaced.
|
131
|
-
@param {String} [options.url]
|
132
|
-
The URL to navigate to.
|
133
|
-
|
134
|
-
Defaults to the link's `[up-href]` or `[href]` attribute.
|
135
|
-
@param {boolean|string} [options.reveal=true]
|
136
|
-
Whether to [reveal](/up.reveal) the target fragment after it was replaced.
|
137
|
-
|
138
|
-
You can also pass a CSS selector for the element to reveal.
|
139
|
-
@param {boolean|string} [options.failReveal=true]
|
140
|
-
Whether to [reveal](/up.reveal) the target fragment when the server responds with an error.
|
141
|
-
|
142
|
-
You can also pass a CSS selector for the element to reveal.
|
143
|
-
@return {Promise}
|
144
|
-
A promise that will be fulfilled when the link destination
|
145
|
-
has been loaded and rendered.
|
146
|
-
@stable
|
147
|
-
###
|
148
|
-
follow = (linkOrSelector, options) ->
|
149
|
-
link = e.get(linkOrSelector)
|
150
|
-
variant = followVariantForLink(link)
|
151
|
-
variant.followLink(link, options)
|
152
|
-
|
153
|
-
###**
|
154
|
-
This event is [emitted](/up.emit) when a link is [followed](/up.follow) through Unpoly.
|
155
|
-
|
156
|
-
The event is emitted on the `<a>` element that is being followed.
|
157
|
-
|
158
|
-
@event up:link:follow
|
159
|
-
@param {Element} event.target
|
160
|
-
The link element that will be followed.
|
161
|
-
@param event.preventDefault()
|
162
|
-
Event listeners may call this method to prevent the link from being followed.
|
163
|
-
@stable
|
164
|
-
###
|
165
|
-
|
166
|
-
###**
|
167
|
-
@function defaultFollow
|
168
|
-
@internal
|
169
|
-
###
|
170
|
-
defaultFollow = (link, options) ->
|
171
|
-
options = u.options(options)
|
172
|
-
url = options.url ? link.getAttribute('up-href') ? link.getAttribute('href')
|
173
|
-
target = options.target ? link.getAttribute('up-target')
|
174
|
-
options.failTarget ?= link.getAttribute('up-fail-target')
|
175
|
-
options.fallback ?= link.getAttribute('up-fallback')
|
176
|
-
options.transition ?= e.booleanOrStringAttr(link, 'up-transition')
|
177
|
-
options.failTransition ?= e.booleanOrStringAttr(link, 'up-fail-transition')
|
178
|
-
options.history ?= e.booleanOrStringAttr(link, 'up-history')
|
179
|
-
options.reveal ?= e.booleanOrStringAttr(link, 'up-reveal') ? true
|
180
|
-
options.failReveal ?= e.booleanOrStringAttr(link, 'up-fail-reveal') ? true
|
181
|
-
options.cache ?= e.booleanAttr(link, 'up-cache')
|
182
|
-
options.restoreScroll ?= e.booleanAttr(link, 'up-restore-scroll') # the option may contain an Object, but not the attr
|
183
|
-
options.method = followMethod(link, options)
|
184
|
-
options.origin ?= link
|
185
|
-
options.layer ?= link.getAttribute('up-layer')
|
186
|
-
options.failLayer ?= link.getAttribute('up-fail-layer')
|
187
|
-
options.confirm ?= link.getAttribute('up-confirm')
|
188
|
-
options.scrollBehavior ?= link.getAttribute('up-scroll-behavior')
|
189
|
-
options.scrollSpeed ?= link.getAttribute('up-scroll-speed')
|
190
|
-
options = u.merge(options, up.motion.animateOptions(options, link))
|
191
|
-
|
192
|
-
up.browser.whenConfirmed(options).then ->
|
193
|
-
up.replace(target, url, options)
|
194
|
-
|
195
|
-
defaultPreload = (link, options) ->
|
196
|
-
options = u.options(options)
|
197
|
-
options.preload = true
|
198
|
-
defaultFollow(link, options)
|
199
|
-
|
200
|
-
###**
|
201
|
-
Returns the HTTP method that should be used when following the given link.
|
202
|
-
|
203
|
-
Looks at the link's `up-method` or `data-method` attribute.
|
204
|
-
Defaults to `"get"`.
|
205
|
-
|
206
|
-
@function up.link.followMethod
|
207
|
-
@param link
|
208
|
-
@param options.method {string}
|
209
|
-
@internal
|
210
|
-
###
|
211
|
-
followMethod = (link, options = {}) ->
|
212
|
-
rawMethod = options.method ? link.getAttribute('up-method') ? link.getAttribute('data-method') ? 'GET'
|
213
|
-
rawMethod.toUpperCase()
|
214
|
-
|
215
|
-
###**
|
216
|
-
No-op that is called when we allow a browser's default action to go through,
|
217
|
-
so we can spy on it in unit tests. See `link_spec.js`.
|
218
|
-
|
219
|
-
@function allowDefault
|
220
|
-
@internal
|
221
|
-
###
|
222
|
-
allowDefault = (event) ->
|
223
|
-
|
224
|
-
followVariants = []
|
225
|
-
|
226
|
-
###**
|
227
|
-
Registers the given handler for links with the given selector.
|
228
|
-
|
229
|
-
This does more than a simple `click` handler:
|
230
|
-
|
231
|
-
- It also handles `[up-instant]`
|
232
|
-
- It also handles `[up-href]`
|
233
|
-
|
234
|
-
@function up.link.addFollowVariant
|
235
|
-
@param {string} simplifiedSelector
|
236
|
-
A selector without `a` or `[up-href]`, e.g. `[up-target]`
|
237
|
-
@param {Function(element, options)} options.follow
|
238
|
-
@param {Function(element, options)} options.preload
|
239
|
-
@internal
|
240
|
-
###
|
241
|
-
addFollowVariant = (simplifiedSelector, options) ->
|
242
|
-
variant = new up.FollowVariant(simplifiedSelector, options)
|
243
|
-
followVariants.push(variant)
|
244
|
-
variant.registerEvents()
|
245
|
-
variant
|
246
|
-
|
247
|
-
###**
|
248
|
-
Returns whether the given link will be [followed](/up.follow) by Unpoly
|
249
|
-
instead of making a full page load.
|
250
|
-
|
251
|
-
A link will be followed by Unpoly if it has an attribute
|
252
|
-
like `a[up-target]` or `a[up-modal]`.
|
253
|
-
|
254
|
-
@function up.link.isFollowable
|
255
|
-
@param {Element|jQuery|string} linkOrSelector
|
256
|
-
The link to check.
|
257
|
-
@experimental
|
258
|
-
###
|
259
|
-
isFollowable = (linkOrSelector) ->
|
260
|
-
linkOrSelector = e.get(linkOrSelector)
|
261
|
-
!!followVariantForLink(linkOrSelector, default: false)
|
262
|
-
|
263
|
-
###**
|
264
|
-
Returns the handler function that can be used to follow the given link.
|
265
|
-
E.g. it wil return a handler calling `up.modal.follow` if the link is a `[up-modal]`,
|
266
|
-
but a handler calling `up.link.follow` if the links is `[up-target]`.
|
267
|
-
|
268
|
-
@param {Element} link
|
269
|
-
@return {Object}
|
270
|
-
@internal
|
271
|
-
###
|
272
|
-
followVariantForLink = (link, options = {}) ->
|
273
|
-
variant = u.find followVariants, (variant) -> variant.matchesLink(link)
|
274
|
-
variant ||= DEFAULT_FOLLOW_VARIANT unless options.default is false
|
275
|
-
variant
|
276
|
-
|
277
|
-
###**
|
278
|
-
Makes sure that the given link will be [followed](/up.follow)
|
279
|
-
by Unpoly instead of making a full page load.
|
280
|
-
|
281
|
-
This is done by giving the link an `a[up-follow]` attribute
|
282
|
-
unless it already have it an attribute like `a[up-target]` or `a[up-modal]`.
|
283
|
-
|
284
|
-
@function up.link.makeFollowable
|
285
|
-
@param {Element|jQuery|string} linkOrSelector
|
286
|
-
The link to process.
|
287
|
-
@experimental
|
288
|
-
###
|
289
|
-
makeFollowable = (link) ->
|
290
|
-
unless isFollowable(link)
|
291
|
-
link.setAttribute('up-follow', '')
|
292
|
-
|
293
|
-
shouldProcessEvent = (event, link) ->
|
294
|
-
target = event.target
|
295
|
-
# We never handle events for the right mouse button, or when Shift/CTRL/Meta is pressed
|
296
|
-
return false unless u.isUnmodifiedMouseEvent(event)
|
297
|
-
# If we actually targeted `link`, save ourselves the expensive DOM traversal below
|
298
|
-
return true if target == link
|
299
|
-
# If user clicked on a child link of $link, or in an <input> within an [up-expand][up-href]
|
300
|
-
# we want those other elements handle the click.
|
301
|
-
betterTargetSelector = "a, [up-href], #{up.form.fieldSelector()}"
|
302
|
-
betterTarget = e.closest(target, betterTargetSelector)
|
303
|
-
return !betterTarget || betterTarget == link
|
304
|
-
|
305
|
-
###**
|
306
|
-
Returns whether the given link has a [safe](https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1)
|
307
|
-
HTTP method like `GET`.
|
308
|
-
|
309
|
-
@function up.link.isSafe
|
310
|
-
@experimental
|
311
|
-
###
|
312
|
-
isSafe = (selectorOrLink, options) ->
|
313
|
-
method = followMethod(selectorOrLink, options)
|
314
|
-
up.proxy.isSafeMethod(method)
|
315
|
-
|
316
|
-
###**
|
317
|
-
[Follows](/up.follow) this link with JavaScript and replaces a CSS selector
|
318
|
-
on the current page with a corresponding element from the response.
|
319
|
-
|
320
|
-
\#\#\# Example
|
321
|
-
|
322
|
-
This will update the fragment `<div class="main">` with the same element
|
323
|
-
fetched from `/posts/5`:
|
324
|
-
|
325
|
-
<a href="/posts/5" up-target=".main">Read post</a>
|
326
|
-
|
327
|
-
\#\#\# Updating multiple fragments
|
328
|
-
|
329
|
-
You can update multiple fragments from a single request by separating
|
330
|
-
separators with a comma (like in CSS).
|
331
|
-
|
332
|
-
For instance, if opening a post should
|
333
|
-
also update a bubble showing the number of unread posts, you might
|
334
|
-
do this:
|
335
|
-
|
336
|
-
<a href="/posts/5" up-target=".main, .unread-count">Read post</a>
|
337
|
-
|
338
|
-
\#\#\# Appending or prepending content
|
339
|
-
|
340
|
-
By default Unpoly will replace the given selector with the same
|
341
|
-
selector from the server response. Instead of replacing you
|
342
|
-
can *append* the loaded content to the existing content by using the
|
343
|
-
`:after` pseudo selector. In the same fashion, you can use `:before`
|
344
|
-
to indicate that you would like the *prepend* the loaded content.
|
345
|
-
|
346
|
-
A practical example would be a paginated list of items. Below the list is
|
347
|
-
a button to load the next page. You can append to the existing list
|
348
|
-
by using `:after` in the `up-target` selector like this:
|
349
|
-
|
350
|
-
<ul class="tasks">
|
351
|
-
<li>Wash car</li>
|
352
|
-
<li>Purchase supplies</li>
|
353
|
-
<li>Fix tent</li>
|
354
|
-
</ul>
|
355
|
-
|
356
|
-
<a href="/page/2" class="next-page" up-target=".tasks:after, .next-page">
|
357
|
-
Load more tasks
|
358
|
-
</a>
|
359
|
-
|
360
|
-
\#\#\# Following elements that are no links
|
361
|
-
|
362
|
-
You can also use `[up-target]` to turn an arbitrary element into a link.
|
363
|
-
In this case, put the link's destination into the `[up-href]` attribute:
|
364
|
-
|
365
|
-
<button up-target=".main" up-href="/foo/bar">Go</button>
|
366
|
-
|
367
|
-
Note that using any element other than `<a>` will prevent users from
|
368
|
-
opening the destination in a new tab.
|
369
|
-
|
370
|
-
@selector a[up-target]
|
371
|
-
@param {string} up-target
|
372
|
-
The CSS selector to replace
|
373
|
-
|
374
|
-
Inside the CSS selector you may refer to this link as `&` ([like in Sass](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector)).
|
375
|
-
@param {string} [up-method='get']
|
376
|
-
The HTTP method to use for the request.
|
377
|
-
@param {string} [up-transition='none']
|
378
|
-
The [transition](/up.motion) to use for morphing between the old and new elements.
|
379
|
-
@param [up-fail-target='body']
|
380
|
-
The CSS selector to replace if the server responds with an error.
|
381
|
-
|
382
|
-
Inside the CSS selector you may refer to this link as `&` ([like in Sass](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector)).
|
383
|
-
@param {string} [up-fail-transition='none']
|
384
|
-
The [transition](/up.motion) to use for morphing between the old and new elements
|
385
|
-
when the server responds with an error.
|
386
|
-
@param {string} [up-fallback]
|
387
|
-
The selector to update when the original target was not found in the page.
|
388
|
-
@param {string} [up-href]
|
389
|
-
The destination URL to follow.
|
390
|
-
If omitted, the the link's `href` attribute will be used.
|
391
|
-
@param {string} [up-confirm]
|
392
|
-
A message that will be displayed in a cancelable confirmation dialog
|
393
|
-
before the link is followed.
|
394
|
-
@param {string} [up-reveal='true']
|
395
|
-
Whether to reveal the target element after it was replaced.
|
396
|
-
|
397
|
-
You can also pass a CSS selector for the element to reveal.
|
398
|
-
Inside the CSS selector you may refer to this link as `&` ([like in Sass](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector)).
|
399
|
-
@param {string} [up-fail-reveal='true']
|
400
|
-
Whether to reveal the target element when the server responds with an error.
|
401
|
-
|
402
|
-
You can also pass a CSS selector for the element to reveal.
|
403
|
-
Inside the CSS selector you may refer to this link as `&` ([like in Sass](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector)).
|
404
|
-
@param {string} [up-restore-scroll='false']
|
405
|
-
Whether to restore previously known scroll position of all viewports
|
406
|
-
within the target selector.
|
407
|
-
@param {string} [up-cache]
|
408
|
-
Whether to force the use of a cached response (`true`)
|
409
|
-
or never use the cache (`false`)
|
410
|
-
or make an educated guess (default).
|
411
|
-
@param {string} [up-layer='auto']
|
412
|
-
The name of the layer that ought to be updated. Valid values are
|
413
|
-
`'auto'`, `'page'`, `'modal'` and `'popup'`.
|
414
|
-
|
415
|
-
If set to `'auto'` (default), Unpoly will try to find a match in the link's layer.
|
416
|
-
If no match was found in that layer,
|
417
|
-
Unpoly will search in other layers, starting from the topmost layer.
|
418
|
-
@param {string} [up-fail-layer='auto']
|
419
|
-
The name of the layer that ought to be updated if the server sends a
|
420
|
-
non-200 status code.
|
421
|
-
@param [up-history]
|
422
|
-
Whether to push an entry to the browser history when following the link.
|
423
|
-
|
424
|
-
Set this to `'false'` to prevent the URL bar from being updated.
|
425
|
-
Set this to a URL string to update the history with the given URL.
|
426
|
-
@stable
|
427
|
-
###
|
428
|
-
DEFAULT_FOLLOW_VARIANT = addFollowVariant '[up-target], [up-follow]',
|
429
|
-
# Don't just pass the `defaultFollow` function reference so we can stub it in tests
|
430
|
-
follow: (link, options) -> defaultFollow(link, options)
|
431
|
-
preload: (link, options) -> defaultPreload(link, options)
|
432
|
-
|
433
|
-
###**
|
434
|
-
Fetches this link's `[href]` with JavaScript and [replaces](/up.replace) the
|
435
|
-
current `<body>` element with the response's `<body>` element.
|
436
|
-
|
437
|
-
To only update a fragment instead of the entire `<body>`, see `a[up-target]`.
|
438
|
-
|
439
|
-
\#\#\# Example
|
440
|
-
|
441
|
-
<a href="/users" up-follow>User list</a>
|
442
|
-
|
443
|
-
\#\#\# Turn any element into a link
|
444
|
-
|
445
|
-
You can also use `[up-follow]` to turn an arbitrary element into a link.
|
446
|
-
In this case, put the link's destination into the `up-href` attribute:
|
447
|
-
|
448
|
-
<span up-follow up-href="/foo/bar">Go</span>
|
449
|
-
|
450
|
-
Note that using any element other than `<a>` will prevent users from
|
451
|
-
opening the destination in a new tab.
|
452
|
-
|
453
|
-
@selector a[up-follow]
|
454
|
-
|
455
|
-
@param {string} [up-method='get']
|
456
|
-
The HTTP method to use for the request.
|
457
|
-
@param [up-fail-target='body']
|
458
|
-
The selector to replace if the server responds with an error.
|
459
|
-
@param {string} [up-fallback]
|
460
|
-
The selector to update when the original target was not found in the page.
|
461
|
-
@param {string} [up-transition='none']
|
462
|
-
The [transition](/up.motion) to use for morphing between the old and new elements.
|
463
|
-
@param {string} [up-fail-transition='none']
|
464
|
-
The [transition](/up.motion) to use for morphing between the old and new elements
|
465
|
-
when the server responds with an error.
|
466
|
-
@param [up-href]
|
467
|
-
The destination URL to follow.
|
468
|
-
If omitted, the the link's `href` attribute will be used.
|
469
|
-
@param {string} [up-confirm]
|
470
|
-
A message that will be displayed in a cancelable confirmation dialog
|
471
|
-
before the link is followed.
|
472
|
-
@param {string} [up-history]
|
473
|
-
Whether to push an entry to the browser history when following the link.
|
474
|
-
|
475
|
-
Set this to `'false'` to prevent the URL bar from being updated.
|
476
|
-
Set this to a URL string to update the history with the given URL.
|
477
|
-
@param [up-restore-scroll='false']
|
478
|
-
Whether to restore the scroll position of all viewports
|
479
|
-
within the response.
|
480
|
-
@stable
|
481
|
-
###
|
482
|
-
|
483
|
-
###**
|
484
|
-
By adding an `up-instant` attribute to a link, the destination will be
|
485
|
-
fetched on `mousedown` instead of `click` (`mouseup`).
|
486
|
-
|
487
|
-
<a href="/users" up-target=".main" up-instant>User list</a>
|
488
|
-
|
489
|
-
This will save precious milliseconds that otherwise spent
|
490
|
-
on waiting for the user to release the mouse button. Since an
|
491
|
-
AJAX request will be triggered right way, the interaction will
|
492
|
-
appear faster.
|
493
|
-
|
494
|
-
Note that using `[up-instant]` will prevent a user from canceling a
|
495
|
-
click by moving the mouse away from the link. However, for
|
496
|
-
navigation actions this isn't needed. E.g. popular operation
|
497
|
-
systems switch tabs on `mousedown` instead of `click`.
|
498
|
-
|
499
|
-
`[up-instant]` will also work for links that open [modals](/up.modal) or [popups](/up.popup).
|
500
|
-
|
501
|
-
@selector a[up-instant]
|
502
|
-
@stable
|
503
|
-
###
|
504
|
-
|
505
|
-
###**
|
506
|
-
[Follows](/up.follow) this link *as fast as possible*.
|
507
|
-
|
508
|
-
This is done by:
|
509
|
-
|
510
|
-
- [Following the link through AJAX](/a-up-target) instead of a full page load
|
511
|
-
- [Preloading the link's destination URL](/a-up-preload)
|
512
|
-
- [Triggering the link on `mousedown`](/a-up-instant) instead of on `click`
|
513
|
-
|
514
|
-
\#\#\# Example
|
515
|
-
|
516
|
-
Use `up-dash` like this:
|
517
|
-
|
518
|
-
<a href="/users" up-dash=".main">User list</a>
|
519
|
-
|
520
|
-
This is shorthand for:
|
521
|
-
|
522
|
-
<a href="/users" up-target=".main" up-instant up-preload>User list</a>
|
523
|
-
|
524
|
-
@selector a[up-dash]
|
525
|
-
@param {string} [up-dash='body']
|
526
|
-
The CSS selector to replace
|
527
|
-
|
528
|
-
Inside the CSS selector you may refer to this link as `&` ([like in Sass](https://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector)).
|
529
|
-
@stable
|
530
|
-
###
|
531
|
-
up.macro '[up-dash]', (element) ->
|
532
|
-
target = e.booleanOrStringAttr(element, 'up-dash')
|
533
|
-
element.removeAttribute('up-dash')
|
534
|
-
newAttrs = {
|
535
|
-
'up-preload': '',
|
536
|
-
'up-instant': ''
|
537
|
-
}
|
538
|
-
if target is true
|
539
|
-
# If it's literally `true` then we don't have a target selector.
|
540
|
-
# Just follow the link by replacing `<body>`.
|
541
|
-
makeFollowable(element)
|
542
|
-
else
|
543
|
-
newAttrs['up-target'] = target
|
544
|
-
e.setMissingAttrs(element, newAttrs)
|
545
|
-
|
546
|
-
###**
|
547
|
-
Add an `[up-expand]` attribute to any element to enlarge the click area of a
|
548
|
-
descendant link.
|
549
|
-
|
550
|
-
`[up-expand]` honors all the Unppoly attributes in expanded links, like
|
551
|
-
`a[up-target]`, `a[up-instant]` or `a[up-preload]`.
|
552
|
-
It also expands links that open [modals](/up.modal) or [popups](/up.popup).
|
553
|
-
|
554
|
-
|
555
|
-
\#\#\# Example
|
556
|
-
|
557
|
-
<div class="notification" up-expand>
|
558
|
-
Record was saved!
|
559
|
-
<a href="/records">Close</a>
|
560
|
-
</div>
|
561
|
-
|
562
|
-
In the example above, clicking anywhere within `.notification` element
|
563
|
-
would [follow](/up.follow) the *Close* link.
|
564
|
-
|
565
|
-
\#\#\# Elements with multiple contained links
|
566
|
-
|
567
|
-
If a container contains more than one link, you can set the value of the
|
568
|
-
`up-expand` attribute to a CSS selector to define which link should be expanded:
|
569
|
-
|
570
|
-
<div class="notification" up-expand=".close">
|
571
|
-
Record was saved!
|
572
|
-
<a class="details" href="/records/5">Details</a>
|
573
|
-
<a class="close" href="/records">Close</a>
|
574
|
-
</div>
|
575
|
-
|
576
|
-
\#\#\# Limitations
|
577
|
-
|
578
|
-
`[up-expand]` has some limitations for advanced browser users:
|
579
|
-
|
580
|
-
- Users won't be able to right-click the expanded area to open a context menu
|
581
|
-
- Users won't be able to `CTRL`+click the expanded area to open a new tab
|
582
|
-
|
583
|
-
To overcome these limitations, consider nesting the entire clickable area in an actual `<a>` tag.
|
584
|
-
[It's OK to put block elements inside an anchor tag](https://makandracards.com/makandra/43549-it-s-ok-to-put-block-elements-inside-an-a-tag).
|
585
|
-
|
586
|
-
@selector [up-expand]
|
587
|
-
@param {string} [up-expand]
|
588
|
-
A CSS selector that defines which containing link should be expanded.
|
589
|
-
|
590
|
-
If omitted, the first link in this element will be expanded.
|
591
|
-
@stable
|
592
|
-
###
|
593
|
-
up.macro '[up-expand]', (area) ->
|
594
|
-
selector = area.getAttribute('up-expand') || 'a, [up-href]'
|
595
|
-
childLinks = e.all(area, selector)
|
596
|
-
|
597
|
-
if childLink = childLinks[0]
|
598
|
-
upAttributePattern = /^up-/
|
599
|
-
newAttrs = {}
|
600
|
-
newAttrs['up-href'] = childLink.getAttribute('href')
|
601
|
-
for attribute in childLink.attributes
|
602
|
-
name = attribute.name
|
603
|
-
if name.match(upAttributePattern)
|
604
|
-
newAttrs[name] = attribute.value
|
605
|
-
e.setMissingAttrs(area, newAttrs)
|
606
|
-
area.removeAttribute('up-expand')
|
607
|
-
makeFollowable(area)
|
608
|
-
|
609
|
-
<% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
|
610
|
-
visit: visit
|
611
|
-
follow: follow
|
612
|
-
makeFollowable: makeFollowable
|
613
|
-
isSafe: isSafe
|
614
|
-
isFollowable: isFollowable
|
615
|
-
shouldProcessEvent: shouldProcessEvent
|
616
|
-
followMethod: followMethod
|
617
|
-
addFollowVariant: addFollowVariant
|
618
|
-
followVariantForLink: followVariantForLink
|
619
|
-
allowDefault: allowDefault
|
620
|
-
|
621
|
-
up.visit = up.link.visit
|
622
|
-
up.follow = up.link.follow
|