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,1098 +0,0 @@
|
|
1
|
-
u = up.util
|
2
|
-
$ = jQuery
|
3
|
-
|
4
|
-
describe 'up.link', ->
|
5
|
-
|
6
|
-
u = up.util
|
7
|
-
|
8
|
-
describe 'JavaScript functions', ->
|
9
|
-
|
10
|
-
describe 'up.follow', ->
|
11
|
-
|
12
|
-
it 'emits a preventable up:link:follow event', asyncSpec (next) ->
|
13
|
-
$link = $fixture('a[href="/destination"][up-target=".response"]')
|
14
|
-
|
15
|
-
listener = jasmine.createSpy('follow listener').and.callFake (event) ->
|
16
|
-
event.preventDefault()
|
17
|
-
|
18
|
-
$link.on('up:link:follow', listener)
|
19
|
-
|
20
|
-
up.follow($link)
|
21
|
-
|
22
|
-
next =>
|
23
|
-
expect(listener).toHaveBeenCalled()
|
24
|
-
event = listener.calls.mostRecent().args[0]
|
25
|
-
expect(event.target).toEqual($link[0])
|
26
|
-
|
27
|
-
# No request should be made because we prevented the event
|
28
|
-
expect(jasmine.Ajax.requests.count()).toEqual(0)
|
29
|
-
|
30
|
-
describeCapability 'canPushState', ->
|
31
|
-
|
32
|
-
it 'loads the given link via AJAX and replaces the response in the given target', asyncSpec (next) ->
|
33
|
-
$fixture('.before').text('old-before')
|
34
|
-
$fixture('.middle').text('old-middle')
|
35
|
-
$fixture('.after').text('old-after')
|
36
|
-
$link = $fixture('a[href="/path"][up-target=".middle"]')
|
37
|
-
|
38
|
-
up.follow($link)
|
39
|
-
|
40
|
-
next =>
|
41
|
-
@respondWith """
|
42
|
-
<div class="before">new-before</div>
|
43
|
-
<div class="middle">new-middle</div>
|
44
|
-
<div class="after">new-after</div>
|
45
|
-
"""
|
46
|
-
|
47
|
-
next =>
|
48
|
-
expect($('.before')).toHaveText('old-before')
|
49
|
-
expect($('.middle')).toHaveText('new-middle')
|
50
|
-
expect($('.after')).toHaveText('old-after')
|
51
|
-
|
52
|
-
it 'uses the method from a data-method attribute', asyncSpec (next) ->
|
53
|
-
$link = $fixture('a[href="/path"][data-method="PUT"]')
|
54
|
-
up.follow($link)
|
55
|
-
|
56
|
-
next =>
|
57
|
-
request = @lastRequest()
|
58
|
-
expect(request).toHaveRequestMethod('PUT')
|
59
|
-
|
60
|
-
it 'allows to refer to the link itself as "&" in the CSS selector', asyncSpec (next) ->
|
61
|
-
$container = $fixture('div')
|
62
|
-
$link1 = $('<a id="first" href="/path" up-target="&">first-link</a>').appendTo($container)
|
63
|
-
$link2 = $('<a id="second" href="/path" up-target="&">second-link</a>').appendTo($container)
|
64
|
-
up.follow($link2)
|
65
|
-
|
66
|
-
next => @respondWith '<div id="second">second-div</div>'
|
67
|
-
next => expect($container.text()).toBe('first-linksecond-div')
|
68
|
-
|
69
|
-
it 'adds history entries and allows the user to use the back- and forward-buttons', asyncSpec (next) ->
|
70
|
-
up.history.config.enabled = true
|
71
|
-
|
72
|
-
waitForBrowser = 100
|
73
|
-
|
74
|
-
# By default, up.history will replace the <body> tag when
|
75
|
-
# the user presses the back-button. We reconfigure this
|
76
|
-
# so we don't lose the Jasmine runner interface.
|
77
|
-
up.history.config.popTargets = ['.container']
|
78
|
-
|
79
|
-
respondWith = (html, title) =>
|
80
|
-
@lastRequest().respondWith
|
81
|
-
status: 200
|
82
|
-
contentType: 'text/html'
|
83
|
-
responseText: "<div class='container'><div class='target'>#{html}</div></div>"
|
84
|
-
responseHeaders: { 'X-Up-Title': title }
|
85
|
-
|
86
|
-
# followAndRespond = ($link, html, title) ->
|
87
|
-
# promise = up.follow($link)
|
88
|
-
# respondWith(html, title)
|
89
|
-
# promise
|
90
|
-
|
91
|
-
$link1 = $fixture('a[href="/one"][up-target=".target"]')
|
92
|
-
$link2 = $fixture('a[href="/two"][up-target=".target"]')
|
93
|
-
$link3 = $fixture('a[href="/three"][up-target=".target"]')
|
94
|
-
$container = $fixture('.container')
|
95
|
-
$target = $fixture('.target').appendTo($container).text('original text')
|
96
|
-
|
97
|
-
up.follow($link1)
|
98
|
-
|
99
|
-
next =>
|
100
|
-
respondWith('text from one', 'title from one')
|
101
|
-
|
102
|
-
next =>
|
103
|
-
expect($('.target')).toHaveText('text from one')
|
104
|
-
expect(location.pathname).toEqual('/one')
|
105
|
-
expect(document.title).toEqual('title from one')
|
106
|
-
|
107
|
-
up.follow($link2)
|
108
|
-
|
109
|
-
next =>
|
110
|
-
respondWith('text from two', 'title from two')
|
111
|
-
|
112
|
-
next =>
|
113
|
-
expect($('.target')).toHaveText('text from two')
|
114
|
-
expect(location.pathname).toEqual('/two')
|
115
|
-
expect(document.title).toEqual('title from two')
|
116
|
-
|
117
|
-
up.follow($link3)
|
118
|
-
|
119
|
-
next =>
|
120
|
-
respondWith('text from three', 'title from three')
|
121
|
-
|
122
|
-
next =>
|
123
|
-
expect($('.target')).toHaveText('text from three')
|
124
|
-
expect(location.pathname).toEqual('/three')
|
125
|
-
expect(document.title).toEqual('title from three')
|
126
|
-
|
127
|
-
history.back()
|
128
|
-
|
129
|
-
next.after waitForBrowser, =>
|
130
|
-
respondWith('restored text from two', 'restored title from two')
|
131
|
-
|
132
|
-
next =>
|
133
|
-
expect($('.target')).toHaveText('restored text from two')
|
134
|
-
expect(location.pathname).toEqual('/two')
|
135
|
-
expect(document.title).toEqual('restored title from two')
|
136
|
-
|
137
|
-
history.back()
|
138
|
-
|
139
|
-
next.after waitForBrowser, =>
|
140
|
-
respondWith('restored text from one', 'restored title from one')
|
141
|
-
|
142
|
-
next =>
|
143
|
-
expect($('.target')).toHaveText('restored text from one')
|
144
|
-
expect(location.pathname).toEqual('/one')
|
145
|
-
expect(document.title).toEqual('restored title from one')
|
146
|
-
|
147
|
-
history.forward()
|
148
|
-
|
149
|
-
next.after waitForBrowser, =>
|
150
|
-
# Since the response is cached, we don't have to respond
|
151
|
-
expect($('.target')).toHaveText('restored text from two', 'restored title from two')
|
152
|
-
expect(location.pathname).toEqual('/two')
|
153
|
-
expect(document.title).toEqual('restored title from two')
|
154
|
-
|
155
|
-
it 'does not add additional history entries when linking to the current URL', asyncSpec (next) ->
|
156
|
-
up.history.config.enabled = true
|
157
|
-
|
158
|
-
# By default, up.history will replace the <body> tag when
|
159
|
-
# the user presses the back-button. We reconfigure this
|
160
|
-
# so we don't lose the Jasmine runner interface.
|
161
|
-
up.history.config.popTargets = ['.container']
|
162
|
-
|
163
|
-
up.proxy.config.cacheExpiry = 0
|
164
|
-
|
165
|
-
respondWith = (text) =>
|
166
|
-
@respondWith """
|
167
|
-
<div class="container">
|
168
|
-
<div class='target'>#{text}</div>
|
169
|
-
</div>
|
170
|
-
"""
|
171
|
-
|
172
|
-
$link1 = $fixture('a[href="/one"][up-target=".target"]')
|
173
|
-
$link2 = $fixture('a[href="/two"][up-target=".target"]')
|
174
|
-
$container = $fixture('.container')
|
175
|
-
$target = $fixture('.target').appendTo($container).text('original text')
|
176
|
-
|
177
|
-
up.follow($link1)
|
178
|
-
|
179
|
-
next =>
|
180
|
-
respondWith('text from one')
|
181
|
-
|
182
|
-
next =>
|
183
|
-
expect($('.target')).toHaveText('text from one')
|
184
|
-
expect(location.pathname).toEqual('/one')
|
185
|
-
|
186
|
-
up.follow($link2)
|
187
|
-
|
188
|
-
next =>
|
189
|
-
respondWith('text from two')
|
190
|
-
|
191
|
-
next =>
|
192
|
-
expect($('.target')).toHaveText('text from two')
|
193
|
-
expect(location.pathname).toEqual('/two')
|
194
|
-
|
195
|
-
up.follow($link2)
|
196
|
-
|
197
|
-
next =>
|
198
|
-
respondWith('text from two')
|
199
|
-
|
200
|
-
next =>
|
201
|
-
expect($('.target')).toHaveText('text from two')
|
202
|
-
expect(location.pathname).toEqual('/two')
|
203
|
-
|
204
|
-
history.back()
|
205
|
-
|
206
|
-
next.after 100, =>
|
207
|
-
respondWith('restored text from one')
|
208
|
-
|
209
|
-
next =>
|
210
|
-
expect($('.target')).toHaveText('restored text from one')
|
211
|
-
expect(location.pathname).toEqual('/one')
|
212
|
-
|
213
|
-
history.forward()
|
214
|
-
|
215
|
-
next.after 100, =>
|
216
|
-
respondWith('restored text from two')
|
217
|
-
|
218
|
-
next =>
|
219
|
-
expect($('.target')).toHaveText('restored text from two')
|
220
|
-
expect(location.pathname).toEqual('/two')
|
221
|
-
|
222
|
-
it 'does add additional history entries when linking to the current URL, but with a different hash', asyncSpec (next) ->
|
223
|
-
up.history.config.enabled = true
|
224
|
-
|
225
|
-
# By default, up.history will replace the <body> tag when
|
226
|
-
# the user presses the back-button. We reconfigure this
|
227
|
-
# so we don't lose the Jasmine runner interface.
|
228
|
-
up.history.config.popTargets = ['.container']
|
229
|
-
|
230
|
-
up.proxy.config.cacheExpiry = 0
|
231
|
-
|
232
|
-
respondWith = (text) =>
|
233
|
-
@respondWith """
|
234
|
-
<div class="container">
|
235
|
-
<div class='target'>#{text}</div>
|
236
|
-
</div>
|
237
|
-
"""
|
238
|
-
|
239
|
-
$link1 = $fixture('a[href="/one"][up-target=".target"]')
|
240
|
-
$link2 = $fixture('a[href="/two"][up-target=".target"]')
|
241
|
-
$link2WithHash = $fixture('a[href="/two#hash"][up-target=".target"]')
|
242
|
-
$container = $fixture('.container')
|
243
|
-
$target = $fixture('.target').appendTo($container).text('original text')
|
244
|
-
|
245
|
-
up.follow($link1)
|
246
|
-
|
247
|
-
next =>
|
248
|
-
respondWith('text from one')
|
249
|
-
|
250
|
-
next =>
|
251
|
-
expect($('.target')).toHaveText('text from one')
|
252
|
-
expect(location.pathname).toEqual('/one')
|
253
|
-
expect(location.hash).toEqual('')
|
254
|
-
|
255
|
-
up.follow($link2)
|
256
|
-
|
257
|
-
next =>
|
258
|
-
respondWith('text from two')
|
259
|
-
|
260
|
-
next =>
|
261
|
-
expect($('.target')).toHaveText('text from two')
|
262
|
-
expect(location.pathname).toEqual('/two')
|
263
|
-
expect(location.hash).toEqual('')
|
264
|
-
|
265
|
-
up.follow($link2WithHash)
|
266
|
-
|
267
|
-
next =>
|
268
|
-
respondWith('text from two with hash')
|
269
|
-
|
270
|
-
next =>
|
271
|
-
expect($('.target')).toHaveText('text from two with hash')
|
272
|
-
expect(location.pathname).toEqual('/two')
|
273
|
-
expect(location.hash).toEqual('#hash')
|
274
|
-
|
275
|
-
history.back()
|
276
|
-
|
277
|
-
next.after 100, =>
|
278
|
-
respondWith('restored text from two')
|
279
|
-
|
280
|
-
next =>
|
281
|
-
expect($('.target')).toHaveText('restored text from two')
|
282
|
-
expect(location.pathname).toEqual('/two')
|
283
|
-
expect(location.hash).toEqual('')
|
284
|
-
|
285
|
-
history.forward()
|
286
|
-
|
287
|
-
next.after 100, =>
|
288
|
-
respondWith('restored text from two with hash')
|
289
|
-
|
290
|
-
next =>
|
291
|
-
expect($('.target')).toHaveText('restored text from two with hash')
|
292
|
-
expect(location.pathname).toEqual('/two')
|
293
|
-
expect(location.hash).toEqual('#hash')
|
294
|
-
|
295
|
-
describe 'with { restoreScroll: true } option', ->
|
296
|
-
|
297
|
-
beforeEach ->
|
298
|
-
up.history.config.enabled = true
|
299
|
-
|
300
|
-
it 'does not reveal, but instead restores the scroll positions of all viewports around the target', asyncSpec (next) ->
|
301
|
-
|
302
|
-
$viewport = $fixture('div[up-viewport] .element').css
|
303
|
-
'height': '100px'
|
304
|
-
'width': '100px'
|
305
|
-
'overflow-y': 'scroll'
|
306
|
-
|
307
|
-
followLink = (options = {}) ->
|
308
|
-
$link = $viewport.find('.link')
|
309
|
-
up.follow($link, options)
|
310
|
-
|
311
|
-
respond = (linkDestination) =>
|
312
|
-
@respondWith """
|
313
|
-
<div class="element" style="height: 300px">
|
314
|
-
<a class="link" href="#{linkDestination}" up-target=".element">Link</a>
|
315
|
-
</div>
|
316
|
-
"""
|
317
|
-
|
318
|
-
up.replace('.element', '/foo')
|
319
|
-
|
320
|
-
next =>
|
321
|
-
# Provide the content at /foo with a link to /bar in the HTML
|
322
|
-
respond('/bar')
|
323
|
-
|
324
|
-
next =>
|
325
|
-
$viewport.scrollTop(65)
|
326
|
-
|
327
|
-
# Follow the link to /bar
|
328
|
-
followLink()
|
329
|
-
|
330
|
-
next =>
|
331
|
-
# Provide the content at /bar with a link back to /foo in the HTML
|
332
|
-
respond('/foo')
|
333
|
-
|
334
|
-
next =>
|
335
|
-
# Follow the link back to /foo, restoring the scroll position of 65px
|
336
|
-
followLink(restoreScroll: true)
|
337
|
-
# No need to respond because /foo has been cached before
|
338
|
-
|
339
|
-
next =>
|
340
|
-
expect($viewport.scrollTop()).toEqual(65)
|
341
|
-
|
342
|
-
|
343
|
-
describe 'revealing', ->
|
344
|
-
|
345
|
-
it 'reaveals the target fragment', asyncSpec (next) ->
|
346
|
-
$link = $fixture('a[href="/action"][up-target=".target"]')
|
347
|
-
$target = $fixture('.target')
|
348
|
-
|
349
|
-
revealStub = up.viewport.knife.mock('reveal')
|
350
|
-
|
351
|
-
up.follow($link)
|
352
|
-
|
353
|
-
next =>
|
354
|
-
@respondWith('<div class="target">new text</div>')
|
355
|
-
|
356
|
-
next =>
|
357
|
-
expect(revealStub).toHaveBeenCalled()
|
358
|
-
expect(revealStub.calls.mostRecent().args[0]).toMatchSelector('.target')
|
359
|
-
|
360
|
-
it 'reveals the { failTarget } if the server responds with an error', asyncSpec (next) ->
|
361
|
-
$link = $fixture('a[href="/action"][up-target=".target"][up-fail-target=".fail-target"]')
|
362
|
-
$target = $fixture('.target')
|
363
|
-
$failTarget = $fixture('.fail-target')
|
364
|
-
|
365
|
-
revealStub = up.viewport.knife.mock('reveal')
|
366
|
-
|
367
|
-
up.follow($link)
|
368
|
-
|
369
|
-
next =>
|
370
|
-
@respondWith
|
371
|
-
status: 500,
|
372
|
-
responseText: """
|
373
|
-
<div class="fail-target">
|
374
|
-
Errors here
|
375
|
-
</div>
|
376
|
-
"""
|
377
|
-
|
378
|
-
next =>
|
379
|
-
expect(revealStub).toHaveBeenCalled()
|
380
|
-
expect(revealStub.calls.mostRecent().args[0]).toMatchSelector('.fail-target')
|
381
|
-
|
382
|
-
|
383
|
-
describe 'with { reveal } option', ->
|
384
|
-
|
385
|
-
it 'allows to reveal a different selector', asyncSpec (next) ->
|
386
|
-
$link = $fixture('a[href="/action"][up-target=".target"]')
|
387
|
-
$target = $fixture('.target')
|
388
|
-
$other = $fixture('.other')
|
389
|
-
|
390
|
-
revealStub = up.viewport.knife.mock('reveal')
|
391
|
-
|
392
|
-
up.follow($link, reveal: '.other')
|
393
|
-
|
394
|
-
next =>
|
395
|
-
@respondWith """
|
396
|
-
<div class="target">
|
397
|
-
new text
|
398
|
-
</div>
|
399
|
-
<div class="other">
|
400
|
-
new other
|
401
|
-
</div>
|
402
|
-
"""
|
403
|
-
|
404
|
-
next =>
|
405
|
-
expect(revealStub).toHaveBeenCalled()
|
406
|
-
expect(revealStub.calls.mostRecent().args[0]).toMatchSelector('.other')
|
407
|
-
|
408
|
-
it 'still reveals the { failTarget } for a failed submission', asyncSpec (next) ->
|
409
|
-
$link = $fixture('a[href="/action"][up-target=".target"][up-fail-target=".fail-target"]')
|
410
|
-
$target = $fixture('.target')
|
411
|
-
$failTarget = $fixture('.fail-target')
|
412
|
-
$other = $fixture('.other')
|
413
|
-
|
414
|
-
revealStub = up.viewport.knife.mock('reveal')
|
415
|
-
|
416
|
-
up.follow($link, reveal: '.other', failTarget: '.fail-target')
|
417
|
-
|
418
|
-
next =>
|
419
|
-
@respondWith
|
420
|
-
status: 500,
|
421
|
-
responseText: """
|
422
|
-
<div class="fail-target">
|
423
|
-
Errors here
|
424
|
-
</div>
|
425
|
-
"""
|
426
|
-
|
427
|
-
next =>
|
428
|
-
expect(revealStub).toHaveBeenCalled()
|
429
|
-
expect(revealStub.calls.mostRecent().args[0]).toMatchSelector('.fail-target')
|
430
|
-
|
431
|
-
describe 'with { failReveal } option', ->
|
432
|
-
|
433
|
-
it 'reveals the given selector when the server responds with an error', asyncSpec (next) ->
|
434
|
-
$link = $fixture('a[href="/action"][up-target=".target"][up-fail-target=".fail-target"]')
|
435
|
-
$target = $fixture('.target')
|
436
|
-
$failTarget = $fixture('.fail-target')
|
437
|
-
$other = $fixture('.other')
|
438
|
-
$failOther = $fixture('.fail-other')
|
439
|
-
|
440
|
-
revealStub = up.viewport.knife.mock('reveal')
|
441
|
-
|
442
|
-
up.follow($link, reveal: '.other', failReveal: '.fail-other')
|
443
|
-
|
444
|
-
next =>
|
445
|
-
@respondWith
|
446
|
-
status: 500,
|
447
|
-
responseText: """
|
448
|
-
<div class="fail-target">
|
449
|
-
Errors here
|
450
|
-
</div>
|
451
|
-
<div class="fail-other">
|
452
|
-
Fail other here
|
453
|
-
</div>
|
454
|
-
"""
|
455
|
-
|
456
|
-
next =>
|
457
|
-
expect(revealStub).toHaveBeenCalled()
|
458
|
-
expect(revealStub.calls.mostRecent().args[0]).toMatchSelector('.fail-other')
|
459
|
-
|
460
|
-
describe "when the browser is already on the link's destination", ->
|
461
|
-
|
462
|
-
it "doesn't make a request and reveals the target container"
|
463
|
-
|
464
|
-
it "doesn't make a request and reveals the target of a #hash in the URL"
|
465
|
-
|
466
|
-
describe 'with { confirm } option', ->
|
467
|
-
|
468
|
-
it 'follows the link after the user OKs a confirmation dialog', asyncSpec (next) ->
|
469
|
-
spyOn(up, 'replace')
|
470
|
-
spyOn(window, 'confirm').and.returnValue(true)
|
471
|
-
$link = $fixture('a[href="/danger"][up-target=".middle"]')
|
472
|
-
up.follow($link, confirm: 'Do you really want to go there?')
|
473
|
-
|
474
|
-
next =>
|
475
|
-
expect(window.confirm).toHaveBeenCalledWith('Do you really want to go there?')
|
476
|
-
expect(up.replace).toHaveBeenCalled()
|
477
|
-
|
478
|
-
it 'does not follow the link if the user cancels the confirmation dialog', asyncSpec (next) ->
|
479
|
-
spyOn(up, 'replace')
|
480
|
-
spyOn(window, 'confirm').and.returnValue(false)
|
481
|
-
$link = $fixture('a[href="/danger"][up-target=".middle"]')
|
482
|
-
up.follow($link, confirm: 'Do you really want to go there?')
|
483
|
-
|
484
|
-
next =>
|
485
|
-
expect(window.confirm).toHaveBeenCalledWith('Do you really want to go there?')
|
486
|
-
expect(up.replace).not.toHaveBeenCalled()
|
487
|
-
|
488
|
-
it 'does not show a confirmation dialog if the option is not a present string', asyncSpec (next) ->
|
489
|
-
spyOn(up, 'replace')
|
490
|
-
spyOn(window, 'confirm')
|
491
|
-
$link = $fixture('a[href="/danger"][up-target=".middle"]')
|
492
|
-
up.follow($link, confirm: '')
|
493
|
-
|
494
|
-
next =>
|
495
|
-
expect(window.confirm).not.toHaveBeenCalled()
|
496
|
-
expect(up.replace).toHaveBeenCalled()
|
497
|
-
|
498
|
-
it 'does not show a confirmation dialog when preloading', asyncSpec (next) ->
|
499
|
-
spyOn(up, 'replace')
|
500
|
-
spyOn(window, 'confirm')
|
501
|
-
$link = $fixture('a[href="/danger"][up-target=".middle"]')
|
502
|
-
up.follow($link, confirm: 'Are you sure?', preload: true)
|
503
|
-
|
504
|
-
next =>
|
505
|
-
expect(window.confirm).not.toHaveBeenCalled()
|
506
|
-
expect(up.replace).toHaveBeenCalled()
|
507
|
-
|
508
|
-
describeFallback 'canPushState', ->
|
509
|
-
|
510
|
-
it 'navigates to the given link without JavaScript', asyncSpec (next) ->
|
511
|
-
$link = $fixture('a[href="/path"]')
|
512
|
-
spyOn(up.browser, 'navigate')
|
513
|
-
up.follow($link)
|
514
|
-
|
515
|
-
next =>
|
516
|
-
expect(up.browser.navigate).toHaveBeenCalledWith('/path', jasmine.anything())
|
517
|
-
|
518
|
-
it 'uses the method from a data-method attribute', asyncSpec (next) ->
|
519
|
-
$link = $fixture('a[href="/path"][data-method="PUT"]')
|
520
|
-
spyOn(up.browser, 'navigate')
|
521
|
-
up.follow($link)
|
522
|
-
|
523
|
-
next =>
|
524
|
-
expect(up.browser.navigate).toHaveBeenCalledWith('/path', { method: 'PUT' })
|
525
|
-
|
526
|
-
describe 'up.link.shouldProcessEvent', ->
|
527
|
-
|
528
|
-
buildEvent = (target, attrs) ->
|
529
|
-
event = Trigger.createMouseEvent('mousedown', attrs)
|
530
|
-
# Cannot change event.target on a native event property, but we can with Object.defineProperty()
|
531
|
-
Object.defineProperty(event, 'target', get: -> target)
|
532
|
-
event
|
533
|
-
|
534
|
-
it "returns true when the given event's target is the given link itself", ->
|
535
|
-
$link = $fixture('a[href="/foo"]')
|
536
|
-
event = buildEvent($link[0])
|
537
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(true)
|
538
|
-
|
539
|
-
it "returns true when the given event's target is a non-link child of the given link", ->
|
540
|
-
$link = $fixture('a[href="/foo"]')
|
541
|
-
$span = $link.affix('span')
|
542
|
-
event = buildEvent($span[0])
|
543
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(true)
|
544
|
-
|
545
|
-
it "returns false when the given event's target is a child link of the given link (think [up-expand])", ->
|
546
|
-
$link = $fixture('div[up-href="/foo"]')
|
547
|
-
$childLink = $link.affix('a[href="/bar"]')
|
548
|
-
event = buildEvent($childLink[0])
|
549
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
550
|
-
|
551
|
-
it "returns false when the given event's target is a child input of the given link (think [up-expand])", ->
|
552
|
-
$link = $fixture('div[up-href="/foo"]')
|
553
|
-
$childInput = $link.affix('input[type="text"]')
|
554
|
-
event = buildEvent($childInput[0])
|
555
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
556
|
-
|
557
|
-
it 'returns false if the right mouse button is used', ->
|
558
|
-
$link = $fixture('a[href="/foo"]')
|
559
|
-
event = buildEvent($link[0], button: 2)
|
560
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
561
|
-
|
562
|
-
it 'returns false if shift is pressed during the click', ->
|
563
|
-
$link = $fixture('a[href="/foo"]')
|
564
|
-
event = buildEvent($link[0], shiftKey: 2)
|
565
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
566
|
-
|
567
|
-
it 'returns false if ctrl is pressed during the click', ->
|
568
|
-
$link = $fixture('a[href="/foo"]')
|
569
|
-
event = buildEvent($link[0], ctrlKey: 2)
|
570
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
571
|
-
|
572
|
-
it 'returns false if meta is pressed during the click', ->
|
573
|
-
$link = $fixture('a[href="/foo"]')
|
574
|
-
event = buildEvent($link[0], metaKey: 2)
|
575
|
-
expect(up.link.shouldProcessEvent(event, $link[0])).toBe(false)
|
576
|
-
|
577
|
-
describe 'up.link.makeFollowable', ->
|
578
|
-
|
579
|
-
it "adds [up-follow] to a link that wouldn't otherwise be handled by Unpoly", ->
|
580
|
-
$link = $fixture('a[href="/path"]').text('label')
|
581
|
-
up.link.makeFollowable($link[0])
|
582
|
-
expect($link.attr('up-follow')).toEqual('')
|
583
|
-
|
584
|
-
it "does not add [up-follow] to a link that is already [up-target]", ->
|
585
|
-
$link = $fixture('a[href="/path"][up-target=".target"]').text('label')
|
586
|
-
up.link.makeFollowable($link[0])
|
587
|
-
expect($link.attr('up-follow')).toBeMissing()
|
588
|
-
|
589
|
-
it "does not add [up-follow] to a link that is already [up-modal]", ->
|
590
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]').text('label')
|
591
|
-
up.link.makeFollowable($link[0])
|
592
|
-
expect($link.attr('up-follow')).toBeMissing()
|
593
|
-
|
594
|
-
it "does not add [up-follow] to a link that is already [up-popup]", ->
|
595
|
-
$link = $fixture('a[href="/path"][up-popup=".target"]').text('label')
|
596
|
-
up.link.makeFollowable($link[0])
|
597
|
-
expect($link.attr('up-follow')).toBeMissing()
|
598
|
-
|
599
|
-
describe 'up.visit', ->
|
600
|
-
|
601
|
-
it 'should have tests'
|
602
|
-
|
603
|
-
describe 'up.link.isFollowable', ->
|
604
|
-
|
605
|
-
it 'returns true for an [up-target] link', ->
|
606
|
-
$link = $fixture('a[href="/foo"][up-target=".target"]')
|
607
|
-
up.hello $link
|
608
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
609
|
-
|
610
|
-
it 'returns true for an [up-follow] link', ->
|
611
|
-
$link = $fixture('a[href="/foo"][up-follow]')
|
612
|
-
up.hello $link
|
613
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
614
|
-
|
615
|
-
it 'returns true for an [up-modal] link', ->
|
616
|
-
$link = $fixture('a[href="/foo"][up-modal=".target"]')
|
617
|
-
up.hello $link
|
618
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
619
|
-
|
620
|
-
it 'returns true for an [up-popup] link', ->
|
621
|
-
$link = $fixture('a[href="/foo"][up-popup=".target"]')
|
622
|
-
up.hello $link
|
623
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
624
|
-
|
625
|
-
it 'returns true for an [up-drawer] link', ->
|
626
|
-
$link = $fixture('a[href="/foo"][up-drawer=".target"]')
|
627
|
-
up.hello $link
|
628
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
629
|
-
|
630
|
-
it 'returns true for an [up-target] span with [up-href]', ->
|
631
|
-
$link = $fixture('span[up-href="/foo"][up-target=".target"]')
|
632
|
-
up.hello $link
|
633
|
-
expect(up.link.isFollowable($link)).toBe(true)
|
634
|
-
|
635
|
-
it 'returns false if the given link will be handled by the browser', ->
|
636
|
-
$link = $fixture('a[href="/foo"]')
|
637
|
-
up.hello $link
|
638
|
-
expect(up.link.isFollowable($link)).toBe(false)
|
639
|
-
|
640
|
-
it 'returns false if the given link will be handled by Rails UJS', ->
|
641
|
-
$link = $fixture('a[href="/foo"][data-method="put"]')
|
642
|
-
up.hello $link
|
643
|
-
expect(up.link.isFollowable($link)).toBe(false)
|
644
|
-
|
645
|
-
describe 'unobtrusive behavior', ->
|
646
|
-
|
647
|
-
describe 'a[up-target]', ->
|
648
|
-
|
649
|
-
it 'does not follow a form with up-target attribute (bugfix)', asyncSpec (next) ->
|
650
|
-
$form = $fixture('form[up-target]')
|
651
|
-
up.hello($form)
|
652
|
-
followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
653
|
-
Trigger.clickSequence($form)
|
654
|
-
|
655
|
-
next =>
|
656
|
-
expect(followSpy).not.toHaveBeenCalled()
|
657
|
-
|
658
|
-
describeCapability 'canPushState', ->
|
659
|
-
|
660
|
-
it 'requests the [href] with AJAX and replaces the [up-target] selector', asyncSpec (next) ->
|
661
|
-
$fixture('.target')
|
662
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
663
|
-
Trigger.clickSequence($link)
|
664
|
-
|
665
|
-
next =>
|
666
|
-
@respondWith('<div class="target">new text</div>')
|
667
|
-
|
668
|
-
next =>
|
669
|
-
expect($('.target')).toHaveText('new text')
|
670
|
-
|
671
|
-
|
672
|
-
it 'adds a history entry', asyncSpec (next) ->
|
673
|
-
up.history.config.enabled = true
|
674
|
-
|
675
|
-
$fixture('.target')
|
676
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
677
|
-
Trigger.clickSequence($link)
|
678
|
-
|
679
|
-
next =>
|
680
|
-
@respondWith('<div class="target">new text</div>')
|
681
|
-
|
682
|
-
next =>
|
683
|
-
expect($('.target')).toHaveText('new text')
|
684
|
-
expect(location.pathname).toEqual('/path')
|
685
|
-
|
686
|
-
it 'respects a X-Up-Location header that the server sends in case of a redirect', asyncSpec (next) ->
|
687
|
-
up.history.config.enabled = true
|
688
|
-
|
689
|
-
$fixture('.target')
|
690
|
-
$link = $fixture('a[href="/path"][up-target=".target"]')
|
691
|
-
Trigger.clickSequence($link)
|
692
|
-
|
693
|
-
next =>
|
694
|
-
@respondWith
|
695
|
-
responseText: '<div class="target">new text</div>'
|
696
|
-
responseHeaders: { 'X-Up-Location': '/other/path' }
|
697
|
-
|
698
|
-
next =>
|
699
|
-
expect($('.target')).toHaveText('new text')
|
700
|
-
expect(location.pathname).toEqual('/other/path')
|
701
|
-
|
702
|
-
describe 'choice of target layer', ->
|
703
|
-
|
704
|
-
beforeEach ->
|
705
|
-
up.motion.config.enabled = false
|
706
|
-
|
707
|
-
it 'prefers to update a container in the same layer as the clicked link', asyncSpec (next) ->
|
708
|
-
$fixture('.document').affix('.target').text('old document text')
|
709
|
-
up.modal.extract('.target', "<div class='target'>old modal text</div>")
|
710
|
-
|
711
|
-
next =>
|
712
|
-
expect($('.document .target')).toHaveText('old document text')
|
713
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
714
|
-
|
715
|
-
$linkInModal = $('.up-modal').affix('a[href="/bar"][up-target=".target"]')
|
716
|
-
Trigger.clickSequence($linkInModal)
|
717
|
-
|
718
|
-
next =>
|
719
|
-
@respondWith '<div class="target">new text from modal link</div>'
|
720
|
-
|
721
|
-
next =>
|
722
|
-
expect($('.document .target')).toHaveText('old document text')
|
723
|
-
expect($('.up-modal .target')).toHaveText('new text from modal link')
|
724
|
-
|
725
|
-
describe 'with [up-layer] modifier', ->
|
726
|
-
|
727
|
-
it 'allows to name a layer for the update', asyncSpec (next) ->
|
728
|
-
$fixture('.document').affix('.target').text('old document text')
|
729
|
-
up.modal.extract('.target', "<div class='target'>old modal text</div>", sticky: true)
|
730
|
-
|
731
|
-
next =>
|
732
|
-
expect($('.document .target')).toHaveText('old document text')
|
733
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
734
|
-
|
735
|
-
$linkInModal = $('.up-modal').affix('a[href="/bar"][up-target=".target"][up-layer="page"]')
|
736
|
-
Trigger.clickSequence($linkInModal)
|
737
|
-
|
738
|
-
next =>
|
739
|
-
@respondWith '<div class="target">new text from modal link</div>'
|
740
|
-
|
741
|
-
next =>
|
742
|
-
expect($('.document .target')).toHaveText('new text from modal link')
|
743
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
744
|
-
|
745
|
-
it 'ignores [up-layer] if the server responds with an error', asyncSpec (next) ->
|
746
|
-
$fixture('.document').affix('.target').text('old document text')
|
747
|
-
up.modal.extract('.target', "<div class='target'>old modal text</div>", sticky: true)
|
748
|
-
|
749
|
-
next =>
|
750
|
-
expect($('.document .target')).toHaveText('old document text')
|
751
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
752
|
-
|
753
|
-
$linkInModal = $('.up-modal').affix('a[href="/bar"][up-target=".target"][up-fail-target=".target"][up-layer="page"]')
|
754
|
-
Trigger.clickSequence($linkInModal)
|
755
|
-
|
756
|
-
next =>
|
757
|
-
@respondWith
|
758
|
-
responseText: '<div class="target">new failure text from modal link</div>'
|
759
|
-
status: 500
|
760
|
-
|
761
|
-
next =>
|
762
|
-
expect($('.document .target')).toHaveText('old document text')
|
763
|
-
expect($('.up-modal .target')).toHaveText('new failure text from modal link')
|
764
|
-
|
765
|
-
it 'allows to name a layer for a non-200 response using an [up-fail-layer] modifier', asyncSpec (next) ->
|
766
|
-
$fixture('.document').affix('.target').text('old document text')
|
767
|
-
up.modal.extract('.target', "<div class='target'>old modal text</div>", sticky: true)
|
768
|
-
|
769
|
-
next =>
|
770
|
-
expect($('.document .target')).toHaveText('old document text')
|
771
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
772
|
-
|
773
|
-
$linkInModal = $('.up-modal').affix('a[href="/bar"][up-target=".target"][up-fail-target=".target"][up-fail-layer="page"]')
|
774
|
-
Trigger.clickSequence($linkInModal)
|
775
|
-
|
776
|
-
next =>
|
777
|
-
@respondWith
|
778
|
-
responseText: '<div class="target">new failure text from modal link</div>'
|
779
|
-
status: 500
|
780
|
-
|
781
|
-
next =>
|
782
|
-
expect($('.document .target')).toHaveText('new failure text from modal link')
|
783
|
-
expect($('.up-modal .target')).toHaveText('old modal text')
|
784
|
-
|
785
|
-
describe 'with [up-fail-target] modifier', ->
|
786
|
-
|
787
|
-
beforeEach ->
|
788
|
-
$fixture('.success-target').text('old success text')
|
789
|
-
$fixture('.failure-target').text('old failure text')
|
790
|
-
@$link = $fixture('a[href="/path"][up-target=".success-target"][up-fail-target=".failure-target"]')
|
791
|
-
|
792
|
-
it 'uses the [up-fail-target] selector for a failed response', asyncSpec (next) ->
|
793
|
-
Trigger.clickSequence(@$link)
|
794
|
-
|
795
|
-
next =>
|
796
|
-
@respondWith('<div class="failure-target">new failure text</div>', status: 500)
|
797
|
-
|
798
|
-
next =>
|
799
|
-
expect($('.success-target')).toHaveText('old success text')
|
800
|
-
expect($('.failure-target')).toHaveText('new failure text')
|
801
|
-
|
802
|
-
# Since there isn't anyone who could handle the rejection inside
|
803
|
-
# the event handler, our handler mutes the rejection.
|
804
|
-
expect(window).not.toHaveUnhandledRejections() if REJECTION_EVENTS_SUPPORTED
|
805
|
-
|
806
|
-
|
807
|
-
it 'uses the [up-target] selector for a successful response', asyncSpec (next) ->
|
808
|
-
Trigger.clickSequence(@$link)
|
809
|
-
|
810
|
-
next =>
|
811
|
-
@respondWith('<div class="success-target">new success text</div>', status: 200)
|
812
|
-
|
813
|
-
next =>
|
814
|
-
expect($('.success-target')).toHaveText('new success text')
|
815
|
-
expect($('.failure-target')).toHaveText('old failure text')
|
816
|
-
|
817
|
-
describe 'with [up-transition] modifier', ->
|
818
|
-
|
819
|
-
it 'morphs between the old and new target element', asyncSpec (next) ->
|
820
|
-
$fixture('.target.old')
|
821
|
-
$link = $fixture('a[href="/path"][up-target=".target"][up-transition="cross-fade"][up-duration="500"][up-easing="linear"]')
|
822
|
-
Trigger.clickSequence($link)
|
823
|
-
|
824
|
-
next =>
|
825
|
-
@respondWith '<div class="target new">new text</div>'
|
826
|
-
|
827
|
-
next =>
|
828
|
-
@$oldGhost = $('.target.old')
|
829
|
-
@$newGhost = $('.target.new')
|
830
|
-
expect(@$oldGhost).toBeAttached()
|
831
|
-
expect(@$newGhost).toBeAttached()
|
832
|
-
expect(@$oldGhost).toHaveOpacity(1, 0.15)
|
833
|
-
expect(@$newGhost).toHaveOpacity(0, 0.15)
|
834
|
-
|
835
|
-
next.after 250, =>
|
836
|
-
expect(@$oldGhost).toHaveOpacity(0.5, 0.15)
|
837
|
-
expect(@$newGhost).toHaveOpacity(0.5, 0.15)
|
838
|
-
|
839
|
-
describe 'wih a CSS selector in the [up-fallback] attribute', ->
|
840
|
-
|
841
|
-
it 'uses the fallback selector if the [up-target] CSS does not exist on the page', asyncSpec (next) ->
|
842
|
-
$fixture('.fallback').text('old fallback')
|
843
|
-
$link = $fixture('a[href="/path"][up-target=".target"][up-fallback=".fallback"]')
|
844
|
-
Trigger.clickSequence($link)
|
845
|
-
|
846
|
-
next =>
|
847
|
-
@respondWith """
|
848
|
-
<div class="target">new target</div>
|
849
|
-
<div class="fallback">new fallback</div>
|
850
|
-
"""
|
851
|
-
|
852
|
-
next =>
|
853
|
-
expect('.fallback').toHaveText('new fallback')
|
854
|
-
|
855
|
-
it 'ignores the fallback selector if the [up-target] CSS exists on the page', asyncSpec (next) ->
|
856
|
-
$fixture('.target').text('old target')
|
857
|
-
$fixture('.fallback').text('old fallback')
|
858
|
-
$link = $fixture('a[href="/path"][up-target=".target"][up-fallback=".fallback"]')
|
859
|
-
Trigger.clickSequence($link)
|
860
|
-
|
861
|
-
next =>
|
862
|
-
@respondWith """
|
863
|
-
<div class="target">new target</div>
|
864
|
-
<div class="fallback">new fallback</div>
|
865
|
-
"""
|
866
|
-
|
867
|
-
next =>
|
868
|
-
expect('.target').toHaveText('new target')
|
869
|
-
expect('.fallback').toHaveText('old fallback')
|
870
|
-
|
871
|
-
it 'does not add a history entry when an up-history attribute is set to "false"', asyncSpec (next) ->
|
872
|
-
up.history.config.enabled = true
|
873
|
-
|
874
|
-
oldPathname = location.pathname
|
875
|
-
$fixture('.target')
|
876
|
-
$link = $fixture('a[href="/path"][up-target=".target"][up-history="false"]')
|
877
|
-
Trigger.clickSequence($link)
|
878
|
-
|
879
|
-
next =>
|
880
|
-
@respondWith
|
881
|
-
responseText: '<div class="target">new text</div>'
|
882
|
-
responseHeaders: { 'X-Up-Location': '/other/path' }
|
883
|
-
|
884
|
-
next =>
|
885
|
-
expect($('.target')).toHaveText('new text')
|
886
|
-
expect(location.pathname).toEqual(oldPathname)
|
887
|
-
|
888
|
-
describe 'a[up-follow]', ->
|
889
|
-
|
890
|
-
beforeEach ->
|
891
|
-
@$link = $fixture('a[href="/follow-path"][up-follow]')
|
892
|
-
@followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
893
|
-
@defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
|
894
|
-
|
895
|
-
it "calls up.follow with the clicked link", asyncSpec (next) ->
|
896
|
-
Trigger.click(@$link)
|
897
|
-
next =>
|
898
|
-
expect(@followSpy).toHaveBeenCalledWith(@$link[0], {})
|
899
|
-
|
900
|
-
# IE does not call JavaScript and always performs the default action on right clicks
|
901
|
-
unless AgentDetector.isIE() || AgentDetector.isEdge()
|
902
|
-
it 'does nothing if the right mouse button is used', asyncSpec (next) ->
|
903
|
-
Trigger.click(@$link, button: 2)
|
904
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
905
|
-
|
906
|
-
it 'does nothing if shift is pressed during the click', asyncSpec (next) ->
|
907
|
-
Trigger.click(@$link, shiftKey: true)
|
908
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
909
|
-
|
910
|
-
it 'does nothing if ctrl is pressed during the click', asyncSpec (next)->
|
911
|
-
Trigger.click(@$link, ctrlKey: true)
|
912
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
913
|
-
|
914
|
-
it 'does nothing if meta is pressed during the click', asyncSpec (next)->
|
915
|
-
Trigger.click(@$link, metaKey: true)
|
916
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
917
|
-
|
918
|
-
describe 'with [up-instant] modifier', ->
|
919
|
-
|
920
|
-
beforeEach ->
|
921
|
-
@$link.attr('up-instant', '')
|
922
|
-
|
923
|
-
it 'follows a link on mousedown (instead of on click)', asyncSpec (next)->
|
924
|
-
Trigger.mousedown(@$link)
|
925
|
-
next => expect(@followSpy.calls.mostRecent().args[0]).toEqual(@$link[0])
|
926
|
-
|
927
|
-
it 'does nothing on mouseup', asyncSpec (next)->
|
928
|
-
Trigger.mouseup(@$link)
|
929
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
930
|
-
|
931
|
-
it 'does nothing on click if there was an earlier mousedown event', asyncSpec (next)->
|
932
|
-
Trigger.mousedown(@$link)
|
933
|
-
Trigger.click(@$link)
|
934
|
-
next => expect(@followSpy.calls.count()).toBe(1)
|
935
|
-
|
936
|
-
it 'does follow a link on click if there was never a mousedown event (e.g. if the user pressed enter)', asyncSpec (next) ->
|
937
|
-
Trigger.click(@$link)
|
938
|
-
next => expect(@followSpy.calls.mostRecent().args[0]).toEqual(@$link[0])
|
939
|
-
|
940
|
-
# IE does not call JavaScript and always performs the default action on right clicks
|
941
|
-
unless AgentDetector.isIE() || AgentDetector.isEdge()
|
942
|
-
it 'does nothing if the right mouse button is pressed down', asyncSpec (next)->
|
943
|
-
Trigger.mousedown(@$link, button: 2)
|
944
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
945
|
-
|
946
|
-
it 'does nothing if shift is pressed during mousedown', asyncSpec (next) ->
|
947
|
-
Trigger.mousedown(@$link, shiftKey: true)
|
948
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
949
|
-
|
950
|
-
it 'does nothing if ctrl is pressed during mousedown', asyncSpec (next) ->
|
951
|
-
Trigger.mousedown(@$link, ctrlKey: true)
|
952
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
953
|
-
|
954
|
-
it 'does nothing if meta is pressed during mousedown', asyncSpec (next) ->
|
955
|
-
Trigger.mousedown(@$link, metaKey: true)
|
956
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
957
|
-
|
958
|
-
describe '[up-dash]', ->
|
959
|
-
|
960
|
-
it "is a shortcut for [up-preload], [up-instant] and [up-target], using [up-dash]'s value as [up-target]", ->
|
961
|
-
$link = $fixture('a[href="/path"][up-dash=".target"]').text('label')
|
962
|
-
up.hello($link)
|
963
|
-
expect($link.attr('up-preload')).toEqual('')
|
964
|
-
expect($link.attr('up-instant')).toEqual('')
|
965
|
-
expect($link.attr('up-target')).toEqual('.target')
|
966
|
-
|
967
|
-
it "adds [up-follow] attribute if [up-dash]'s value is 'true'", ->
|
968
|
-
$link = $fixture('a[href="/path"][up-dash="true"]').text('label')
|
969
|
-
up.hello($link)
|
970
|
-
expect($link.attr('up-follow')).toEqual('')
|
971
|
-
|
972
|
-
it "adds [up-follow] attribute if [up-dash] is present, but has no value", ->
|
973
|
-
$link = $fixture('a[href="/path"][up-dash]').text('label')
|
974
|
-
up.hello($link)
|
975
|
-
expect($link.attr('up-follow')).toEqual('')
|
976
|
-
|
977
|
-
it "does not add an [up-follow] attribute if [up-dash] is 'true', but [up-target] is present", ->
|
978
|
-
$link = $fixture('a[href="/path"][up-dash="true"][up-target=".target"]').text('label')
|
979
|
-
up.hello($link)
|
980
|
-
expect($link.attr('up-follow')).toBeMissing()
|
981
|
-
expect($link.attr('up-target')).toEqual('.target')
|
982
|
-
|
983
|
-
it "does not add an [up-follow] attribute if [up-dash] is 'true', but [up-modal] is present", ->
|
984
|
-
$link = $fixture('a[href="/path"][up-dash="true"][up-modal=".target"]').text('label')
|
985
|
-
up.hello($link)
|
986
|
-
expect($link.attr('up-follow')).toBeMissing()
|
987
|
-
expect($link.attr('up-modal')).toEqual('.target')
|
988
|
-
|
989
|
-
it "does not add an [up-follow] attribute if [up-dash] is 'true', but [up-popup] is present", ->
|
990
|
-
$link = $fixture('a[href="/path"][up-dash="true"][up-popup=".target"]').text('label')
|
991
|
-
up.hello($link)
|
992
|
-
expect($link.attr('up-follow')).toBeMissing()
|
993
|
-
expect($link.attr('up-popup')).toEqual('.target')
|
994
|
-
|
995
|
-
it "removes the [up-dash] attribute when it's done", ->
|
996
|
-
$link = $fixture('a[href="/path"]').text('label')
|
997
|
-
up.hello($link)
|
998
|
-
expect($link.attr('up-dash')).toBeMissing()
|
999
|
-
|
1000
|
-
describe '[up-expand]', ->
|
1001
|
-
|
1002
|
-
it 'copies up-related attributes of a contained link', ->
|
1003
|
-
$area = $fixture('div[up-expand] a[href="/path"][up-target="selector"][up-instant][up-preload]')
|
1004
|
-
up.hello($area)
|
1005
|
-
expect($area.attr('up-target')).toEqual('selector')
|
1006
|
-
expect($area.attr('up-instant')).toEqual('')
|
1007
|
-
expect($area.attr('up-preload')).toEqual('')
|
1008
|
-
|
1009
|
-
it "renames a contained link's href attribute to up-href so the container is considered a link", ->
|
1010
|
-
$area = $fixture('div[up-expand] a[up-follow][href="/path"]')
|
1011
|
-
up.hello($area)
|
1012
|
-
expect($area.attr('up-href')).toEqual('/path')
|
1013
|
-
|
1014
|
-
it 'copies attributes from the first link if there are multiple links', ->
|
1015
|
-
$area = $fixture('div[up-expand]')
|
1016
|
-
$link1 = $area.affix('a[href="/path1"]')
|
1017
|
-
$link2 = $area.affix('a[href="/path2"]')
|
1018
|
-
up.hello($area)
|
1019
|
-
expect($area.attr('up-href')).toEqual('/path1')
|
1020
|
-
|
1021
|
-
it "copies an contained non-link element with up-href attribute", ->
|
1022
|
-
$area = $fixture('div[up-expand] span[up-follow][up-href="/path"]')
|
1023
|
-
up.hello($area)
|
1024
|
-
expect($area.attr('up-href')).toEqual('/path')
|
1025
|
-
|
1026
|
-
it 'adds an up-follow attribute if the contained link has neither up-follow nor up-target attributes', ->
|
1027
|
-
$area = $fixture('div[up-expand] a[href="/path"]')
|
1028
|
-
up.hello($area)
|
1029
|
-
expect($area.attr('up-follow')).toEqual('')
|
1030
|
-
|
1031
|
-
it 'can be used to enlarge the click area of a link', asyncSpec (next) ->
|
1032
|
-
$area = $fixture('div[up-expand] a[href="/path"]')
|
1033
|
-
up.hello($area)
|
1034
|
-
spyOn(up, 'replace')
|
1035
|
-
Trigger.clickSequence($area)
|
1036
|
-
next =>
|
1037
|
-
expect(up.replace).toHaveBeenCalled()
|
1038
|
-
|
1039
|
-
it 'does nothing when the user clicks another link in the expanded area', asyncSpec (next) ->
|
1040
|
-
$area = $fixture('div[up-expand]')
|
1041
|
-
$expandedLink = $area.affix('a[href="/expanded-path"][up-follow]')
|
1042
|
-
$otherLink = $area.affix('a[href="/other-path"][up-follow]')
|
1043
|
-
up.hello($area)
|
1044
|
-
followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
1045
|
-
Trigger.clickSequence($otherLink)
|
1046
|
-
next =>
|
1047
|
-
expect(followSpy.calls.count()).toEqual(1)
|
1048
|
-
expect(followSpy.calls.mostRecent().args[0]).toEqual($otherLink[0])
|
1049
|
-
|
1050
|
-
it 'does nothing when the user clicks on an input in the expanded area', asyncSpec (next) ->
|
1051
|
-
$area = $fixture('div[up-expand]')
|
1052
|
-
$expandedLink = $area.affix('a[href="/expanded-path"][up-follow]')
|
1053
|
-
$input = $area.affix('input[type=text]')
|
1054
|
-
up.hello($area)
|
1055
|
-
followSpy = up.link.knife.mock('defaultFollow').and.returnValue(Promise.resolve())
|
1056
|
-
Trigger.clickSequence($input)
|
1057
|
-
next =>
|
1058
|
-
expect(followSpy).not.toHaveBeenCalled()
|
1059
|
-
|
1060
|
-
it 'does not trigger multiple replaces when the user clicks on the expanded area of an [up-instant] link (bugfix)', asyncSpec (next) ->
|
1061
|
-
$area = $fixture('div[up-expand] a[href="/path"][up-follow][up-instant]')
|
1062
|
-
up.hello($area)
|
1063
|
-
spyOn(up, 'replace')
|
1064
|
-
Trigger.clickSequence($area)
|
1065
|
-
next =>
|
1066
|
-
expect(up.replace.calls.count()).toEqual(1)
|
1067
|
-
|
1068
|
-
it 'does not add an up-follow attribute if the expanded link is [up-dash] with a selector (bugfix)', ->
|
1069
|
-
$area = $fixture('div[up-expand] a[href="/path"][up-dash=".element"]')
|
1070
|
-
up.hello($area)
|
1071
|
-
expect($area.attr('up-follow')).toBeMissing()
|
1072
|
-
|
1073
|
-
it 'does not an up-follow attribute if the expanded link is [up-dash] without a selector (bugfix)', ->
|
1074
|
-
$area = $fixture('div[up-expand] a[href="/path"][up-dash]')
|
1075
|
-
up.hello($area)
|
1076
|
-
expect($area.attr('up-follow')).toEqual('')
|
1077
|
-
|
1078
|
-
describe 'with a CSS selector in the property value', ->
|
1079
|
-
|
1080
|
-
it "expands the contained link that matches the selector", ->
|
1081
|
-
$area = $fixture('div[up-expand=".second"]')
|
1082
|
-
$link1 = $area.affix('a.first[href="/path1"]')
|
1083
|
-
$link2 = $area.affix('a.second[href="/path2"]')
|
1084
|
-
up.hello($area)
|
1085
|
-
expect($area.attr('up-href')).toEqual('/path2')
|
1086
|
-
|
1087
|
-
it 'does nothing if no contained link matches the selector', ->
|
1088
|
-
$area = $fixture('div[up-expand=".foo"]')
|
1089
|
-
$link = $area.affix('a[href="/path1"]')
|
1090
|
-
up.hello($area)
|
1091
|
-
expect($area.attr('up-href')).toBeUndefined()
|
1092
|
-
|
1093
|
-
it 'does not match an element that is not a descendant', ->
|
1094
|
-
$area = $fixture('div[up-expand=".second"]')
|
1095
|
-
$link1 = $area.affix('a.first[href="/path1"]')
|
1096
|
-
$link2 = $fixture('a.second[href="/path2"]') # not a child of $area
|
1097
|
-
up.hello($area)
|
1098
|
-
expect($area.attr('up-href')).toBeUndefined()
|