unpoly-rails 0.62.1 → 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 +53 -1
- data/README.md +1 -1
- 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 +15377 -10465
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +6 -4
- data/lib/unpoly-rails.rb +9 -3
- data/lib/unpoly/rails/change.rb +372 -0
- data/lib/unpoly/rails/change/cache.rb +26 -0
- data/lib/unpoly/rails/change/context.rb +80 -0
- data/lib/unpoly/rails/change/field.rb +117 -0
- data/lib/unpoly/rails/change/field_definition.rb +74 -0
- data/lib/unpoly/rails/change/layer.rb +60 -0
- data/lib/unpoly/rails/controller.rb +47 -0
- data/lib/unpoly/rails/error.rb +5 -0
- data/lib/unpoly/rails/request_echo_headers.rb +2 -2
- data/lib/unpoly/rails/version.rb +1 -1
- data/lib/unpoly/tasks.rb +45 -0
- metadata +43 -313
- data/.gitignore +0 -10
- data/.ruby-version +0 -1
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -45
- data/Rakefile +0 -145
- data/bower.json +0 -27
- data/design/animation-ghosting.txt +0 -72
- data/design/design.txt +0 -34
- data/design/draft.html.erb +0 -48
- data/design/draft.rb +0 -9
- data/design/es6.js +0 -32
- data/design/ghost-debugging.txt +0 -118
- data/design/homepage.txt +0 -236
- data/design/ie11.txt +0 -9
- data/design/measure_import_node.js +0 -330
- data/design/measure_jquery/element_list.js +0 -41
- data/design/measure_jquery/up.on_vs_addEventListener.js +0 -56
- data/design/positioning.txt +0 -28
- data/design/query-params-in-form-actions/cases.html +0 -125
- data/design/rename.txt +0 -0
- data/design/test_rejected_promise.txt +0 -5
- data/design/unpoly errors.txt +0 -19
- data/lib/assets/javascripts/unpoly-bootstrap3.coffee +0 -2
- data/lib/assets/javascripts/unpoly-bootstrap3/feedback-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.coffee +0 -1
- data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.coffee +0 -14
- data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly.coffee +0 -28
- data/lib/assets/javascripts/unpoly/browser.coffee.erb +0 -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 -246
- data/lib/assets/javascripts/unpoly/classes/response.coffee +0 -157
- data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +0 -102
- data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +0 -67
- data/lib/assets/javascripts/unpoly/classes/selector.coffee +0 -60
- data/lib/assets/javascripts/unpoly/classes/store/memory.coffee +0 -26
- data/lib/assets/javascripts/unpoly/classes/store/session.coffee +0 -59
- data/lib/assets/javascripts/unpoly/classes/tether.coffee +0 -105
- data/lib/assets/javascripts/unpoly/classes/url_set.coffee +0 -32
- data/lib/assets/javascripts/unpoly/cookie.coffee +0 -56
- data/lib/assets/javascripts/unpoly/element.coffee.erb +0 -1126
- data/lib/assets/javascripts/unpoly/event.coffee.erb +0 -445
- data/lib/assets/javascripts/unpoly/feedback.coffee +0 -353
- data/lib/assets/javascripts/unpoly/form.coffee.erb +0 -1075
- data/lib/assets/javascripts/unpoly/fragment.coffee.erb +0 -928
- data/lib/assets/javascripts/unpoly/framework.coffee +0 -67
- data/lib/assets/javascripts/unpoly/history.coffee +0 -268
- data/lib/assets/javascripts/unpoly/legacy.coffee +0 -60
- data/lib/assets/javascripts/unpoly/link.coffee.erb +0 -622
- data/lib/assets/javascripts/unpoly/log.coffee +0 -248
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +0 -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 -298
- data/lib/assets/javascripts/unpoly/proxy.coffee +0 -672
- data/lib/assets/javascripts/unpoly/radio.coffee +0 -60
- data/lib/assets/javascripts/unpoly/rails.coffee +0 -24
- data/lib/assets/javascripts/unpoly/syntax.coffee.erb +0 -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 -1676
- data/lib/assets/javascripts/unpoly/viewport.coffee.erb +0 -830
- data/lib/assets/stylesheets/unpoly-bootstrap3.sass +0 -1
- data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.sass +0 -27
- data/lib/assets/stylesheets/unpoly.sass +0 -1
- data/lib/assets/stylesheets/unpoly/close.sass +0 -2
- data/lib/assets/stylesheets/unpoly/dom.sass +0 -5
- data/lib/assets/stylesheets/unpoly/layout.sass +0 -2
- data/lib/assets/stylesheets/unpoly/link.sass +0 -2
- data/lib/assets/stylesheets/unpoly/modal.sass +0 -116
- data/lib/assets/stylesheets/unpoly/popup.sass +0 -7
- data/lib/assets/stylesheets/unpoly/toast.sass +0 -33
- data/lib/assets/stylesheets/unpoly/tooltip.sass +0 -62
- data/lib/unpoly/rails/inspector.rb +0 -149
- data/lib/unpoly/rails/inspector_accessor.rb +0 -30
- data/package.json +0 -38
- data/spec_app/.firefox-version +0 -1
- data/spec_app/.gitignore +0 -17
- data/spec_app/.rspec +0 -2
- data/spec_app/Gemfile +0 -30
- data/spec_app/Gemfile.lock +0 -229
- data/spec_app/README.rdoc +0 -28
- data/spec_app/Rakefile +0 -6
- data/spec_app/app/assets/images/.keep +0 -0
- data/spec_app/app/assets/images/favicon.png +0 -0
- data/spec_app/app/assets/images/grid.png +0 -0
- data/spec_app/app/assets/javascripts/bootstrap_manifest.coffee +0 -6
- data/spec_app/app/assets/javascripts/integration_test.coffee +0 -6
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +0 -6
- data/spec_app/app/assets/stylesheets/_helpers.sass +0 -5
- data/spec_app/app/assets/stylesheets/bootstrap_manifest.sass +0 -2
- data/spec_app/app/assets/stylesheets/integration_test.sass +0 -88
- data/spec_app/app/assets/stylesheets/jasmine_specs.sass +0 -20
- data/spec_app/app/controllers/application_controller.rb +0 -14
- data/spec_app/app/controllers/binding_test_controller.rb +0 -51
- data/spec_app/app/controllers/compiler_test_controller.rb +0 -5
- data/spec_app/app/controllers/css_test_controller.rb +0 -5
- data/spec_app/app/controllers/error_test_controller.rb +0 -5
- data/spec_app/app/controllers/form_test/basics_controller.rb +0 -14
- data/spec_app/app/controllers/form_test/redirects_controller.rb +0 -17
- data/spec_app/app/controllers/form_test/uploads_controller.rb +0 -15
- data/spec_app/app/controllers/hash_test_controller.rb +0 -5
- data/spec_app/app/controllers/method_test_controller.rb +0 -16
- data/spec_app/app/controllers/motion_test_controller.rb +0 -5
- data/spec_app/app/controllers/pages_controller.rb +0 -9
- data/spec_app/app/controllers/replace_test_controller.rb +0 -5
- data/spec_app/app/controllers/reveal_test_controller.rb +0 -5
- data/spec_app/app/controllers/scroll_test_controller.rb +0 -5
- data/spec_app/app/helpers/application_helper.rb +0 -2
- data/spec_app/app/mailers/.keep +0 -0
- data/spec_app/app/models/concerns/.keep +0 -0
- data/spec_app/app/views/compiler_test/timestamp.erb +0 -9
- data/spec_app/app/views/css_test/modal.erb +0 -47
- data/spec_app/app/views/css_test/modal_contents.erb +0 -5
- data/spec_app/app/views/css_test/modal_contents_wide.erb +0 -5
- data/spec_app/app/views/css_test/popup.erb +0 -81
- data/spec_app/app/views/css_test/popup_contents.erb +0 -5
- data/spec_app/app/views/css_test/tooltip.erb +0 -48
- data/spec_app/app/views/error_test/trigger.erb +0 -80
- data/spec_app/app/views/error_test/unexpected_response.erb +0 -3
- data/spec_app/app/views/form_test/basics/new.erb +0 -60
- data/spec_app/app/views/form_test/redirects/new.erb +0 -27
- data/spec_app/app/views/form_test/redirects/target.erb +0 -4
- data/spec_app/app/views/form_test/submission_result.erb +0 -30
- data/spec_app/app/views/form_test/uploads/new.erb +0 -44
- data/spec_app/app/views/hash_test/unpoly.erb +0 -30
- data/spec_app/app/views/hash_test/vanilla.erb +0 -13
- data/spec_app/app/views/layouts/integration_test.erb +0 -22
- data/spec_app/app/views/layouts/jasmine_rails/spec_runner.html.erb +0 -20
- data/spec_app/app/views/method_test/form_target.erb +0 -17
- data/spec_app/app/views/method_test/page1.erb +0 -11
- data/spec_app/app/views/method_test/page2.erb +0 -6
- data/spec_app/app/views/motion_test/animations.erb +0 -16
- data/spec_app/app/views/motion_test/transitions.erb +0 -13
- data/spec_app/app/views/pages/start.erb +0 -79
- data/spec_app/app/views/replace_test/_nav.erb +0 -6
- data/spec_app/app/views/replace_test/page1.erb +0 -14
- data/spec_app/app/views/replace_test/page2.erb +0 -14
- data/spec_app/app/views/replace_test/table.erb +0 -16
- data/spec_app/app/views/reveal_test/long1.erb +0 -17
- data/spec_app/app/views/reveal_test/long2.erb +0 -17
- data/spec_app/app/views/reveal_test/within_document_viewport.erb +0 -24
- data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +0 -28
- data/spec_app/app/views/scroll_test/long1.erb +0 -30
- data/spec_app/bin/bundle +0 -3
- data/spec_app/bin/rails +0 -8
- data/spec_app/bin/rake +0 -8
- data/spec_app/bin/setup +0 -29
- data/spec_app/bin/spring +0 -18
- data/spec_app/config.ru +0 -4
- data/spec_app/config/application.rb +0 -28
- data/spec_app/config/boot.rb +0 -3
- data/spec_app/config/database.yml +0 -25
- data/spec_app/config/environment.rb +0 -5
- data/spec_app/config/environments/development.rb +0 -41
- data/spec_app/config/environments/production.rb +0 -79
- data/spec_app/config/environments/test.rb +0 -42
- data/spec_app/config/initializers/assets.rb +0 -19
- data/spec_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec_app/config/initializers/bower_rails.rb +0 -16
- data/spec_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec_app/config/initializers/inflections.rb +0 -16
- data/spec_app/config/initializers/mime_types.rb +0 -4
- data/spec_app/config/initializers/session_store.rb +0 -3
- data/spec_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec_app/config/locales/en.yml +0 -23
- data/spec_app/config/routes.rb +0 -30
- data/spec_app/config/secrets.yml +0 -22
- data/spec_app/db/schema.rb +0 -23
- data/spec_app/db/seeds.rb +0 -7
- data/spec_app/lib/assets/.keep +0 -0
- data/spec_app/lib/tasks/.keep +0 -0
- data/spec_app/lib/tasks/cucumber.rake +0 -65
- data/spec_app/log/.keep +0 -0
- data/spec_app/public/404.html +0 -67
- data/spec_app/public/422.html +0 -67
- data/spec_app/public/500.html +0 -66
- data/spec_app/public/favicon.ico +0 -0
- data/spec_app/public/robots.txt +0 -5
- data/spec_app/script/cucumber +0 -10
- data/spec_app/spec/controllers/binding_test_controller_spec.rb +0 -248
- data/spec_app/spec/javascripts/helpers/agent_detector.coffee +0 -20
- data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +0 -103
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +0 -21
- data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/fixture.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/index.js.coffee +0 -1
- data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +0 -1
- data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -69
- data/spec_app/spec/javascripts/helpers/last_request.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +0 -24
- data/spec_app/spec/javascripts/helpers/promise_state.js +0 -18
- data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +0 -23
- data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +0 -2
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +0 -25
- data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +0 -12
- data/spec_app/spec/javascripts/helpers/spec_util.coffee +0 -47
- data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_array.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_error.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_jquery.js.coffee +0 -5
- data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +0 -11
- data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +0 -7
- data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +0 -10
- data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +0 -15
- data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +0 -16
- data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +0 -9
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -18
- data/spec_app/spec/javascripts/helpers/to_match_list.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +0 -8
- data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +0 -13
- data/spec_app/spec/javascripts/helpers/to_match_url.coffee +0 -14
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +0 -200
- data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +0 -5
- data/spec_app/spec/javascripts/support/jasmine.yml +0 -51
- data/spec_app/spec/javascripts/up/browser_spec.js.coffee +0 -150
- data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +0 -82
- data/spec_app/spec/javascripts/up/classes/config_spec.coffee +0 -24
- data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +0 -45
- data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +0 -34
- data/spec_app/spec/javascripts/up/classes/params_spec.coffee +0 -557
- data/spec_app/spec/javascripts/up/classes/request_spec.coffee +0 -50
- data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +0 -51
- data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +0 -70
- data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +0 -114
- data/spec_app/spec/javascripts/up/element_spec.coffee +0 -897
- data/spec_app/spec/javascripts/up/event_spec.js.coffee +0 -530
- data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +0 -401
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +0 -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 -1137
- data/spec_app/spec/javascripts/up/radio_spec.js.coffee +0 -212
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +0 -118
- data/spec_app/spec/javascripts/up/spec_spec.js.coffee +0 -9
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +0 -304
- data/spec_app/spec/javascripts/up/toast_spec.js.coffee +0 -37
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +0 -163
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +0 -1420
- data/spec_app/spec/javascripts/up/viewport_spec.js.coffee +0 -655
- data/spec_app/spec/spec_helper.rb +0 -62
- data/spec_app/test/controllers/.keep +0 -0
- data/spec_app/test/fixtures/.keep +0 -0
- data/spec_app/test/helpers/.keep +0 -0
- data/spec_app/test/integration/.keep +0 -0
- data/spec_app/test/mailers/.keep +0 -0
- data/spec_app/test/models/.keep +0 -0
- data/spec_app/test/test_helper.rb +0 -10
- data/spec_app/vendor/asset-libs/es6-promise-4.1.6/es6-promise.auto.js +0 -1159
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.bower.json +0 -43
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +0 -10
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +0 -6
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +0 -56
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js +0 -790
- data/spec_app/vendor/assets/.keep +0 -0
- data/unpoly-rails.gemspec +0 -24
@@ -1,119 +0,0 @@
|
|
1
|
-
u = up.util
|
2
|
-
$ = jQuery
|
3
|
-
|
4
|
-
describe 'up.log', ->
|
5
|
-
|
6
|
-
describe 'JavaScript functions', ->
|
7
|
-
|
8
|
-
describe 'up.log.puts', ->
|
9
|
-
|
10
|
-
it 'sends a log message to the developer console iff the log is enabled', ->
|
11
|
-
spyOn(console, 'log')
|
12
|
-
|
13
|
-
up.log.disable()
|
14
|
-
up.log.puts('message')
|
15
|
-
expect(console.log).not.toHaveBeenCalled()
|
16
|
-
|
17
|
-
up.log.enable()
|
18
|
-
up.log.puts('message')
|
19
|
-
expect(console.log).toHaveBeenCalledWith('[UP] message')
|
20
|
-
|
21
|
-
describe 'up.log.debug', ->
|
22
|
-
|
23
|
-
it 'sends a debug message to the developer console iff the log is enabled', ->
|
24
|
-
spyOn(console, 'debug')
|
25
|
-
|
26
|
-
up.log.disable()
|
27
|
-
up.log.debug('message')
|
28
|
-
expect(console.debug).not.toHaveBeenCalled()
|
29
|
-
|
30
|
-
up.log.enable()
|
31
|
-
up.log.debug('message')
|
32
|
-
expect(console.debug).toHaveBeenCalledWith('[UP] message')
|
33
|
-
|
34
|
-
describe 'up.log.error', ->
|
35
|
-
|
36
|
-
it 'sends an error message to the developer console regardless whether the log is enabled or not', ->
|
37
|
-
spyOn(console, 'error')
|
38
|
-
|
39
|
-
up.log.disable()
|
40
|
-
up.log.error('message1')
|
41
|
-
expect(console.error).toHaveBeenCalledWith('[UP] message1')
|
42
|
-
|
43
|
-
up.log.enable()
|
44
|
-
up.log.error('message2')
|
45
|
-
expect(console.error.calls.allArgs()).toEqual [
|
46
|
-
['[UP] message1'],
|
47
|
-
['[UP] message2']
|
48
|
-
]
|
49
|
-
|
50
|
-
describe 'up.log.sprintf', ->
|
51
|
-
|
52
|
-
describe 'with string argument', ->
|
53
|
-
|
54
|
-
it 'serializes with surrounding quotes', ->
|
55
|
-
formatted = up.log.sprintf('before %o after', 'argument')
|
56
|
-
expect(formatted).toEqual('before "argument" after')
|
57
|
-
|
58
|
-
describe 'with undefined argument', ->
|
59
|
-
|
60
|
-
it 'serializes to the word "undefined"', ->
|
61
|
-
formatted = up.log.sprintf('before %o after', undefined)
|
62
|
-
expect(formatted).toEqual('before undefined after')
|
63
|
-
|
64
|
-
describe 'with null argument', ->
|
65
|
-
|
66
|
-
it 'serializes to the word "null"', ->
|
67
|
-
formatted = up.log.sprintf('before %o after', null)
|
68
|
-
expect(formatted).toEqual('before null after')
|
69
|
-
|
70
|
-
describe 'with number argument', ->
|
71
|
-
|
72
|
-
it 'serializes the number as string', ->
|
73
|
-
formatted = up.log.sprintf('before %o after', 5)
|
74
|
-
expect(formatted).toEqual('before 5 after')
|
75
|
-
|
76
|
-
describe 'with function argument', ->
|
77
|
-
|
78
|
-
it 'serializes the function code', ->
|
79
|
-
formatted = up.log.sprintf('before %o after', `function foo() {}`)
|
80
|
-
expect(formatted).toEqual('before function foo() {} after')
|
81
|
-
|
82
|
-
describe 'with array argument', ->
|
83
|
-
|
84
|
-
it 'recursively serializes the elements', ->
|
85
|
-
formatted = up.log.sprintf('before %o after', [1, "foo"])
|
86
|
-
expect(formatted).toEqual('before [1, "foo"] after')
|
87
|
-
|
88
|
-
describe 'with element argument', ->
|
89
|
-
|
90
|
-
it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
|
91
|
-
$element = $('<table id="id-value" name="name-value" class="class-value" title="title-value">')
|
92
|
-
element = $element.get(0)
|
93
|
-
formatted = up.log.sprintf('before %o after', element)
|
94
|
-
expect(formatted).toEqual('before <table id="id-value" name="name-value" class="class-value"> after')
|
95
|
-
|
96
|
-
describe 'with jQuery argument', ->
|
97
|
-
|
98
|
-
it 'serializes the tag name with id, name and class attributes, but ignores other attributes', ->
|
99
|
-
$element1 = $('<table id="table-id">')
|
100
|
-
$element2 = $('<ul id="ul-id">')
|
101
|
-
formatted = up.log.sprintf('before %o after', $element1.add($element2))
|
102
|
-
expect(formatted).toEqual('before $(<table id="table-id">, <ul id="ul-id">) after')
|
103
|
-
|
104
|
-
describe 'with object argument', ->
|
105
|
-
|
106
|
-
it 'serializes to JSON', ->
|
107
|
-
object = { foo: 'foo-value', bar: 'bar-value' }
|
108
|
-
formatted = up.log.sprintf('before %o after', object)
|
109
|
-
expect(formatted).toEqual('before {"foo":"foo-value","bar":"bar-value"} after')
|
110
|
-
|
111
|
-
it "skips a key if a getter crashes", ->
|
112
|
-
object = {}
|
113
|
-
Object.defineProperty(object, 'foo', get: (-> throw "error"))
|
114
|
-
formatted = up.log.sprintf('before %o after', object)
|
115
|
-
expect(formatted).toEqual('before {} after')
|
116
|
-
|
117
|
-
object.bar = 'bar'
|
118
|
-
formatted = up.log.sprintf('before %o after', object)
|
119
|
-
expect(formatted).toEqual('before {"bar":"bar"} after')
|
@@ -1,939 +0,0 @@
|
|
1
|
-
u = up.util
|
2
|
-
e = up.element
|
3
|
-
$ = jQuery
|
4
|
-
|
5
|
-
describe 'up.modal', ->
|
6
|
-
|
7
|
-
beforeEach ->
|
8
|
-
up.modal.config.openDuration = 5
|
9
|
-
up.modal.config.closeDuration = 5
|
10
|
-
|
11
|
-
describe 'JavaScript functions', ->
|
12
|
-
|
13
|
-
describe 'up.modal.follow', ->
|
14
|
-
|
15
|
-
it "loads the given link's destination in a dialog window", (done) ->
|
16
|
-
$link = $fixture('a[href="/path/to"][up-modal=".middle"]').text('link')
|
17
|
-
promise = up.modal.follow($link)
|
18
|
-
|
19
|
-
u.task =>
|
20
|
-
expect(@lastRequest().url).toMatch /\/path\/to$/
|
21
|
-
@respondWith """
|
22
|
-
<div class="before">new-before</div>
|
23
|
-
<div class="middle">new-middle</div>
|
24
|
-
<div class="after">new-after</div>
|
25
|
-
"""
|
26
|
-
|
27
|
-
promise.then =>
|
28
|
-
expect($('.up-modal')).toBeAttached()
|
29
|
-
expect($('.up-modal-dialog')).toBeAttached()
|
30
|
-
expect($('.up-modal-dialog .middle')).toBeAttached()
|
31
|
-
expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
|
32
|
-
expect($('.up-modal-dialog .before')).not.toBeAttached()
|
33
|
-
expect($('.up-modal-dialog .after')).not.toBeAttached()
|
34
|
-
done()
|
35
|
-
|
36
|
-
describe 'up.modal.extract', ->
|
37
|
-
|
38
|
-
it 'opens a modal by extracting the given selector from the given HTML string', (done) ->
|
39
|
-
up.history.config.enabled = true
|
40
|
-
|
41
|
-
oldHref = location.href
|
42
|
-
promise = up.modal.extract '.middle', """
|
43
|
-
<div class="before">new-before</div>
|
44
|
-
<div class="middle">new-middle</div>
|
45
|
-
<div class="after">new-after</div>
|
46
|
-
"""
|
47
|
-
|
48
|
-
promise.then =>
|
49
|
-
expect($('.up-modal')).toBeAttached()
|
50
|
-
expect($('.up-modal-dialog')).toBeAttached()
|
51
|
-
expect($('.up-modal-dialog .middle')).toBeAttached()
|
52
|
-
expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
|
53
|
-
expect($('.up-modal-dialog .before')).not.toBeAttached()
|
54
|
-
expect($('.up-modal-dialog .after')).not.toBeAttached()
|
55
|
-
|
56
|
-
# Can't change URLs
|
57
|
-
expect(location.href).toEqual(oldHref)
|
58
|
-
done()
|
59
|
-
|
60
|
-
describe 'up.modal.visit', ->
|
61
|
-
|
62
|
-
it "requests the given URL and places the given selector into a modal", (done) ->
|
63
|
-
up.history.config.enabled = true
|
64
|
-
|
65
|
-
promise = up.modal.visit('/foo', target: '.middle')
|
66
|
-
|
67
|
-
u.task =>
|
68
|
-
@respondWith """
|
69
|
-
<div class="before">new-before</div>
|
70
|
-
<div class="middle">new-middle</div>
|
71
|
-
<div class="after">new-after</div>
|
72
|
-
"""
|
73
|
-
|
74
|
-
promise.then =>
|
75
|
-
expect('.up-modal').toBeAttached()
|
76
|
-
expect('.up-modal-dialog').toBeAttached()
|
77
|
-
expect('.up-modal-dialog .middle').toBeAttached()
|
78
|
-
expect('.up-modal-dialog .middle').toHaveText('new-middle')
|
79
|
-
expect('.up-modal-dialog .before').not.toBeAttached()
|
80
|
-
expect('.up-modal-dialog .after').not.toBeAttached()
|
81
|
-
expect(location.pathname).toMatchUrl('/foo')
|
82
|
-
done()
|
83
|
-
|
84
|
-
it "doesn't create an .up-modal frame and replaces { failTarget } if the server returns a non-200 response", (done) ->
|
85
|
-
$fixture('.error').text('old error')
|
86
|
-
|
87
|
-
promise = up.modal.visit('/foo', target: '.target', failTarget: '.error')
|
88
|
-
|
89
|
-
u.task =>
|
90
|
-
@respondWith
|
91
|
-
status: 500
|
92
|
-
responseText: """
|
93
|
-
<div class="target">new target</div>
|
94
|
-
<div class="error">new error</div>
|
95
|
-
"""
|
96
|
-
|
97
|
-
promise.catch =>
|
98
|
-
expect('.up-modal').not.toBeAttached()
|
99
|
-
expect('.error').toHaveText('new error')
|
100
|
-
done()
|
101
|
-
|
102
|
-
it 'always makes a request for the given selector, and does not "improve" the selector with a fallback', asyncSpec (next) ->
|
103
|
-
up.modal.visit('/foo', target: '.target', failTarget: '.error')
|
104
|
-
next =>
|
105
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
106
|
-
headers = @lastRequest().requestHeaders
|
107
|
-
expect(headers['X-Up-Target']).toEqual('.target')
|
108
|
-
|
109
|
-
describe 'preventing elements from jumping as scrollbars change', ->
|
110
|
-
|
111
|
-
it "brings its own scrollbar, padding the body on the right", (done) ->
|
112
|
-
$body = $(document.body)
|
113
|
-
|
114
|
-
$fixture('.spacer').css(height: '9000px')
|
115
|
-
# Safari 11 has no vertical scrollbar that takes away space from the document,
|
116
|
-
# so the entire shifting logic is skipped.
|
117
|
-
if up.viewport.rootHasVerticalScrollbar()
|
118
|
-
|
119
|
-
$rootOverflowElement = $(up.viewport.rootOverflowElement())
|
120
|
-
|
121
|
-
promise = up.modal.visit('/foo', target: '.container')
|
122
|
-
|
123
|
-
u.task =>
|
124
|
-
@respondWith('<div class="container">text</div>')
|
125
|
-
|
126
|
-
promise.then ->
|
127
|
-
$modal = $('.up-modal')
|
128
|
-
$viewport = $modal.find('.up-modal-viewport')
|
129
|
-
scrollbarWidth = up.viewport.scrollbarWidth()
|
130
|
-
|
131
|
-
expect($modal).toBeAttached()
|
132
|
-
expect($viewport.css('overflow-y')).toEqual('scroll')
|
133
|
-
expect($rootOverflowElement.css('overflow-y')).toEqual('hidden')
|
134
|
-
expect(parseInt($body.css('padding-right'))).toBeAround(scrollbarWidth, 5)
|
135
|
-
|
136
|
-
up.modal.close().then ->
|
137
|
-
expect($rootOverflowElement.css('overflow-y')).toEqual('scroll')
|
138
|
-
expect(parseInt($body.css('padding-right'))).toBe(0)
|
139
|
-
done()
|
140
|
-
else
|
141
|
-
expect(true).toBe(true)
|
142
|
-
done()
|
143
|
-
|
144
|
-
it "gives the scrollbar to .up-modal instead of .up-modal-viewport while animating, so we don't see scaled scrollbars in a zoom-in animation", (done) ->
|
145
|
-
openPromise = up.modal.extract('.container', '<div class="container">text</div>', animation: 'fade-in', duration: 100)
|
146
|
-
|
147
|
-
u.timer 50, ->
|
148
|
-
$modal = $('.up-modal')
|
149
|
-
$viewport = $modal.find('.up-modal-viewport')
|
150
|
-
expect($modal).toHaveClass('up-modal-animating')
|
151
|
-
expect($modal.css('overflow-y')).toEqual('scroll')
|
152
|
-
expect($viewport.css('overflow-y')).toEqual('hidden')
|
153
|
-
|
154
|
-
openPromise.then ->
|
155
|
-
expect($modal).not.toHaveClass('up-modal-animating')
|
156
|
-
expect($modal.css('overflow-y')).not.toEqual('scroll')
|
157
|
-
expect($viewport.css('overflow-y')).toEqual('scroll')
|
158
|
-
closePromise = up.modal.close(animation: 'fade-out', duration: 400)
|
159
|
-
|
160
|
-
u.timer 50, ->
|
161
|
-
expect($modal).toHaveClass('up-modal-animating')
|
162
|
-
expect($modal.css('overflow-y')).toEqual('scroll')
|
163
|
-
expect($viewport.css('overflow-y')).toEqual('hidden')
|
164
|
-
done()
|
165
|
-
|
166
|
-
it "does not add right padding to the body if the document's overflow element has overflow-y: hidden", (done) ->
|
167
|
-
restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'hidden')
|
168
|
-
$fixture('.spacer').css(height: '9000px')
|
169
|
-
|
170
|
-
up.modal.extract('.container', '<div class="container">text</div>').then ->
|
171
|
-
$body = $('body')
|
172
|
-
expect($('.up-modal')).toBeAttached()
|
173
|
-
expect(parseInt($body.css('padding-right'))).toBe(0)
|
174
|
-
|
175
|
-
up.modal.close().then ->
|
176
|
-
expect(parseInt($body.css('padding-right'))).toBe(0)
|
177
|
-
restoreBody()
|
178
|
-
done()
|
179
|
-
|
180
|
-
it "does not add right padding to the body if the document's overflow element has overflow-y: auto, but does not currently have scrollbars", (done) ->
|
181
|
-
restoreBody = e.setTemporaryStyle(up.viewport.rootOverflowElement(), overflowY: 'auto')
|
182
|
-
restoreReporter = e.setTemporaryStyle($('.jasmine_html-reporter')[0], height: '100px', overflowY: 'hidden')
|
183
|
-
|
184
|
-
up.modal.extract('.container', '<div class="container">text</div>').then ->
|
185
|
-
$body = $('body')
|
186
|
-
expect($('.up-modal')).toBeAttached()
|
187
|
-
expect(parseInt($body.css('padding-right'))).toBe(0)
|
188
|
-
|
189
|
-
up.modal.close().then ->
|
190
|
-
expect(parseInt($body.css('padding-right'))).toBe(0)
|
191
|
-
restoreReporter()
|
192
|
-
restoreBody()
|
193
|
-
done()
|
194
|
-
|
195
|
-
it 'pushes right-anchored elements away from the edge of the screen', (done) ->
|
196
|
-
$fixture('.spacer').css(height: '9000px')
|
197
|
-
# Safari 11 has no vertical scrollbar that takes away space from the document,
|
198
|
-
# so the entire shifting logic is skipped.
|
199
|
-
if up.viewport.rootHasVerticalScrollbar()
|
200
|
-
scrollbarWidth = up.viewport.scrollbarWidth()
|
201
|
-
$anchoredElement = $fixture('div[up-anchored=right]').css
|
202
|
-
position: 'absolute'
|
203
|
-
top: '0'
|
204
|
-
right: '30px'
|
205
|
-
|
206
|
-
promise = up.modal.visit('/foo', target: '.container')
|
207
|
-
|
208
|
-
u.task =>
|
209
|
-
@respondWith('<div class="container">text</div>')
|
210
|
-
|
211
|
-
promise.then ->
|
212
|
-
expect(parseInt($anchoredElement.css('right'))).toBeAround(30 + scrollbarWidth, 10)
|
213
|
-
|
214
|
-
up.modal.close().then ->
|
215
|
-
expect(parseInt($anchoredElement.css('right'))).toBeAround(30 , 10)
|
216
|
-
done()
|
217
|
-
else
|
218
|
-
expect(true).toBe(true)
|
219
|
-
done()
|
220
|
-
|
221
|
-
describe 'opening a modal while another modal is open', ->
|
222
|
-
|
223
|
-
it 'does not open multiple modals or pad the body twice if the user starts loading a second modal before the first was done loading', (done) ->
|
224
|
-
up.modal.config.closeDuration = 10
|
225
|
-
scrollbarWidth = up.viewport.scrollbarWidth()
|
226
|
-
|
227
|
-
# Load a first modal
|
228
|
-
up.modal.visit('/path1', target: '.container', animation: 'fade-in', duration: 50)
|
229
|
-
|
230
|
-
# Immediately load a second modal in the same frame.
|
231
|
-
# This will discard the first request immediately.
|
232
|
-
up.modal.visit('/path2', target: '.container', animation: 'fade-in', duration: 50)
|
233
|
-
|
234
|
-
u.task =>
|
235
|
-
# The second modal has survived
|
236
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
237
|
-
expect(@lastRequest().url).toMatchUrl('/path2')
|
238
|
-
|
239
|
-
# We send the response for 2
|
240
|
-
@respondWith('<div class="container">response2</div>')
|
241
|
-
|
242
|
-
u.timer 10, =>
|
243
|
-
# The second modal is now opening
|
244
|
-
up.modal.visit('/path3', target: '.container', animation: 'fade-in', duration: 50)
|
245
|
-
|
246
|
-
# Load a third modal before the second was done opening
|
247
|
-
u.task =>
|
248
|
-
# Since we're still opening the second modal, no request has been made.
|
249
|
-
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
250
|
-
|
251
|
-
u.timer 180, =>
|
252
|
-
# Now that the second modal has opened, we make the request to /path3
|
253
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
254
|
-
expect(@lastRequest().url).toMatchUrl('/path3')
|
255
|
-
|
256
|
-
@respondWith('<div class="container">response3</div>')
|
257
|
-
|
258
|
-
u.timer 180, =>
|
259
|
-
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
260
|
-
expect($('.up-modal').length).toBe(1)
|
261
|
-
expect($('.up-modal-dialog').length).toBe(1)
|
262
|
-
expect($('.container')).toHaveText('response3')
|
263
|
-
bodyPadding = parseInt($('body').css('padding-right'))
|
264
|
-
expect(bodyPadding).toBeAround(scrollbarWidth, 10)
|
265
|
-
if scrollbarWidth > 0 # this test does not make sense on old Safaris
|
266
|
-
expect(bodyPadding).not.toBeAround(2 * scrollbarWidth, 2 * 5)
|
267
|
-
done()
|
268
|
-
|
269
|
-
it 'closes the current modal and wait for its close animation to finish before starting the open animation of a second modal', asyncSpec (next) ->
|
270
|
-
up.modal.config.openAnimation = 'fade-in'
|
271
|
-
up.modal.config.openDuration = 100
|
272
|
-
up.modal.config.closeAnimation = 'fade-out'
|
273
|
-
up.modal.config.closeDuration = 100
|
274
|
-
|
275
|
-
events = []
|
276
|
-
u.each ['up:modal:open', 'up:modal:opened', 'up:modal:close', 'up:modal:closed'], (event) ->
|
277
|
-
up.on event, ->
|
278
|
-
events.push(event)
|
279
|
-
|
280
|
-
up.modal.extract('.target', '<div class="target">response1</div>')
|
281
|
-
|
282
|
-
next =>
|
283
|
-
# First modal is starting opening animation (will take 100 ms)
|
284
|
-
expect(events).toEqual ['up:modal:open']
|
285
|
-
expect($('.target')).toHaveText('response1')
|
286
|
-
|
287
|
-
next.after (100 + (timingTolerance = 100)), =>
|
288
|
-
# First modal has completed opening animation after 100 ms
|
289
|
-
expect(events).toEqual ['up:modal:open', 'up:modal:opened']
|
290
|
-
expect($('.target')).toHaveText('response1')
|
291
|
-
|
292
|
-
# We open another modal, which will cause the first modal to start closing (will take 100 ms)
|
293
|
-
up.modal.extract('.target', '<div class="target">response2</div>')
|
294
|
-
|
295
|
-
next.after 50, =>
|
296
|
-
# Second modal is still waiting for first modal's closing animaton to finish.
|
297
|
-
expect(events).toEqual ['up:modal:open', 'up:modal:opened', 'up:modal:close']
|
298
|
-
expect($('.target')).toHaveText('response1')
|
299
|
-
|
300
|
-
next.after (50 + 100 + (timingTolerance = 200)), =>
|
301
|
-
# First modal has finished closing, second modal has finished opening.
|
302
|
-
expect(events).toEqual ['up:modal:open', 'up:modal:opened', 'up:modal:close', 'up:modal:closed', 'up:modal:open', 'up:modal:opened']
|
303
|
-
expect($('.target')).toHaveText('response2')
|
304
|
-
|
305
|
-
it 'closes an opening modal if a second modal starts opening before the first modal has finished its open animation', asyncSpec (next) ->
|
306
|
-
up.modal.config.openAnimation = 'fade-in'
|
307
|
-
up.modal.config.openDuration = 100
|
308
|
-
up.modal.config.closeAnimation = 'fade-out'
|
309
|
-
up.modal.config.closeDuration = 100
|
310
|
-
|
311
|
-
# Open the first modal
|
312
|
-
up.modal.extract('.target', '<div class="target">response1</div>')
|
313
|
-
|
314
|
-
next.after 50, =>
|
315
|
-
# First modal is still in its opening animation
|
316
|
-
expect($('.target')).toHaveText('response1')
|
317
|
-
|
318
|
-
# Open a second modal
|
319
|
-
up.modal.extract('.target', '<div class="target">response2</div>')
|
320
|
-
|
321
|
-
next =>
|
322
|
-
# First modal is starting close animation. Second modal waits for that.
|
323
|
-
expect($('.target')).toHaveText('response1')
|
324
|
-
|
325
|
-
next.after 10, =>
|
326
|
-
# Second modal is still waiting for first modal's closing animaton to finish.
|
327
|
-
expect($('.target')).toHaveText('response1')
|
328
|
-
|
329
|
-
next.after (140 + (timingTolerance = 220)), =>
|
330
|
-
# First modal has finished closing, second modal has finished opening.
|
331
|
-
expect($('.target')).toHaveText('response2')
|
332
|
-
|
333
|
-
it 'uses the correct flavor config for the first and second modal', asyncSpec (next) ->
|
334
|
-
up.modal.config.openAnimation = 'fade-in'
|
335
|
-
up.modal.config.openDuration = 20
|
336
|
-
up.modal.config.closeAnimation = 'fade-out'
|
337
|
-
up.modal.config.closeDuration = 20
|
338
|
-
up.modal.flavor 'custom-drawer',
|
339
|
-
openAnimation: 'move-from-right'
|
340
|
-
closeAnimation: 'move-to-right'
|
341
|
-
|
342
|
-
animations = []
|
343
|
-
spyOn(up, 'animate').and.callFake (element, animation, options) ->
|
344
|
-
if e.matches(element, '.up-modal-viewport')
|
345
|
-
animations.push
|
346
|
-
text: element.querySelector('.target').innerText.trim()
|
347
|
-
animation: animation
|
348
|
-
deferred = u.newDeferred()
|
349
|
-
u.timer options.duration, -> deferred.resolve()
|
350
|
-
deferred.promise()
|
351
|
-
|
352
|
-
up.modal.extract('.target', '<div class="target">response1</div>')
|
353
|
-
|
354
|
-
next =>
|
355
|
-
expect(animations).toEqual [
|
356
|
-
{ animation: 'fade-in', text: 'response1' }
|
357
|
-
]
|
358
|
-
|
359
|
-
next.after 30, =>
|
360
|
-
# first modal is now done animating
|
361
|
-
expect(animations).toEqual [
|
362
|
-
{ animation: 'fade-in', text: 'response1' }
|
363
|
-
]
|
364
|
-
|
365
|
-
up.modal.extract('.target', '<div class="target">response2</div>', flavor: 'custom-drawer')
|
366
|
-
|
367
|
-
next =>
|
368
|
-
expect(animations).toEqual [
|
369
|
-
{ animation: 'fade-in', text: 'response1' },
|
370
|
-
{ animation: 'fade-out', text: 'response1' },
|
371
|
-
]
|
372
|
-
|
373
|
-
next.after 30, =>
|
374
|
-
expect(animations).toEqual [
|
375
|
-
{ animation: 'fade-in', text: 'response1' },
|
376
|
-
{ animation: 'fade-out', text: 'response1' },
|
377
|
-
{ animation: 'move-from-right', text: 'response2' }
|
378
|
-
]
|
379
|
-
|
380
|
-
expect($('.up-modal').attr('up-flavor')).toEqual('custom-drawer')
|
381
|
-
|
382
|
-
|
383
|
-
it 'never resolves the open() promise and shows no error if close() was called before the response was received', asyncSpec (next) ->
|
384
|
-
openPromise = up.modal.visit('/foo', target: '.container')
|
385
|
-
|
386
|
-
next =>
|
387
|
-
up.modal.close()
|
388
|
-
|
389
|
-
next =>
|
390
|
-
respond = => @respondWith('<div class="container">text</div>')
|
391
|
-
expect(respond).not.toThrowError()
|
392
|
-
|
393
|
-
next.await =>
|
394
|
-
expect($('.up-toast')).not.toBeAttached()
|
395
|
-
promise = promiseState(openPromise)
|
396
|
-
promise.then (result) => expect(result.state).toEqual('pending')
|
397
|
-
|
398
|
-
describe 'up.modal.coveredUrl', ->
|
399
|
-
|
400
|
-
describeCapability 'canPushState', ->
|
401
|
-
|
402
|
-
it 'returns the URL behind the modal overlay', (done) ->
|
403
|
-
up.history.config.enabled = true
|
404
|
-
up.history.replace('/foo')
|
405
|
-
|
406
|
-
expect(up.modal.coveredUrl()).toBeMissing()
|
407
|
-
visitPromise = up.modal.visit('/bar', target: '.container')
|
408
|
-
u.task =>
|
409
|
-
@respondWith('<div class="container">text</div>')
|
410
|
-
visitPromise.then ->
|
411
|
-
expect(up.modal.coveredUrl()).toMatchUrl('/foo')
|
412
|
-
up.modal.close().then ->
|
413
|
-
expect(up.modal.coveredUrl()).toBeMissing()
|
414
|
-
done()
|
415
|
-
|
416
|
-
describe 'up.modal.flavors', ->
|
417
|
-
|
418
|
-
it 'allows to register new modal variants with its own default configuration', asyncSpec (next) ->
|
419
|
-
up.modal.flavors.variant = { maxWidth: 200 }
|
420
|
-
$link = $fixture('a[href="/path"][up-modal=".target"][up-flavor="variant"]')
|
421
|
-
Trigger.click($link)
|
422
|
-
|
423
|
-
next =>
|
424
|
-
@respondWith('<div class="target">new text</div>')
|
425
|
-
|
426
|
-
next =>
|
427
|
-
$modal = $('.up-modal')
|
428
|
-
$dialog = $modal.find('.up-modal-dialog')
|
429
|
-
expect($modal).toBeAttached()
|
430
|
-
expect($modal.attr('up-flavor')).toEqual('variant')
|
431
|
-
expect($dialog.attr('style')).toContain('max-width: 200px')
|
432
|
-
|
433
|
-
it 'does not change the configuration of non-flavored modals', asyncSpec (next) ->
|
434
|
-
up.modal.flavors.variant = { maxWidth: 200 }
|
435
|
-
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
436
|
-
Trigger.click($link)
|
437
|
-
|
438
|
-
next =>
|
439
|
-
@respondWith('<div class="target">new text</div>')
|
440
|
-
|
441
|
-
next =>
|
442
|
-
$modal = $('.up-modal')
|
443
|
-
$dialog = $modal.find('.up-modal-dialog')
|
444
|
-
expect($modal).toBeAttached()
|
445
|
-
expect($dialog.attr('style')).toBeBlank()
|
446
|
-
|
447
|
-
describe 'up.modal.close', ->
|
448
|
-
|
449
|
-
it 'closes a currently open modal', (done) ->
|
450
|
-
up.modal.extract('.content', '<div class="content">Modal content</div>')
|
451
|
-
|
452
|
-
u.task =>
|
453
|
-
expect('.up-modal .content').toBeAttached()
|
454
|
-
|
455
|
-
up.modal.close().then ->
|
456
|
-
expect('.up-modal .content').not.toBeAttached()
|
457
|
-
done()
|
458
|
-
|
459
|
-
it 'does nothing if no modal is open', (done) ->
|
460
|
-
wasClosed = false
|
461
|
-
up.on 'up:modal:close', ->
|
462
|
-
wasClosed = true
|
463
|
-
|
464
|
-
up.modal.close().then ->
|
465
|
-
expect(wasClosed).toBe(false)
|
466
|
-
done()
|
467
|
-
|
468
|
-
describe 'unobtrusive behavior', ->
|
469
|
-
|
470
|
-
describe 'a[up-modal]', ->
|
471
|
-
|
472
|
-
beforeEach ->
|
473
|
-
up.motion.config.enabled = false
|
474
|
-
|
475
|
-
# Some examples only want to check if follow() has been called, without
|
476
|
-
# actually making a request.
|
477
|
-
@stubFollow = =>
|
478
|
-
@$link = $fixture('a[href="/path"][up-modal=".target"]')
|
479
|
-
@followSpy = up.modal.knife.mock('followAsap').and.returnValue(Promise.resolve())
|
480
|
-
@defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
|
481
|
-
|
482
|
-
it 'opens the clicked link in a modal', asyncSpec (next) ->
|
483
|
-
@$link = $fixture('a[href="/path"][up-modal=".target"]')
|
484
|
-
Trigger.click(@$link)
|
485
|
-
|
486
|
-
next =>
|
487
|
-
lastRequest = @lastRequest()
|
488
|
-
expect(lastRequest.url).toMatchUrl('/path')
|
489
|
-
@respondWith '<div class="target">new content</div>'
|
490
|
-
|
491
|
-
next =>
|
492
|
-
expect('.up-modal').toBeAttached()
|
493
|
-
expect('.up-modal-content').toHaveText('new content')
|
494
|
-
|
495
|
-
describe 'when modifier keys are held', ->
|
496
|
-
|
497
|
-
# IE does not call JavaScript and always performs the default action on right clicks
|
498
|
-
unless AgentDetector.isIE() || AgentDetector.isEdge()
|
499
|
-
it 'does nothing if the right mouse button is used', asyncSpec (next) ->
|
500
|
-
@stubFollow()
|
501
|
-
Trigger.click(@$link, button: 2)
|
502
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
503
|
-
|
504
|
-
it 'does nothing if shift is pressed during the click', asyncSpec (next) ->
|
505
|
-
@stubFollow()
|
506
|
-
Trigger.click(@$link, shiftKey: true)
|
507
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
508
|
-
|
509
|
-
it 'does nothing if ctrl is pressed during the click', asyncSpec (next) ->
|
510
|
-
@stubFollow()
|
511
|
-
Trigger.click(@$link, ctrlKey: true)
|
512
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
513
|
-
|
514
|
-
it 'does nothing if meta is pressed during the click', asyncSpec (next) ->
|
515
|
-
@stubFollow()
|
516
|
-
Trigger.click(@$link, metaKey: true)
|
517
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
518
|
-
|
519
|
-
describe 'with [up-instant] modifier', ->
|
520
|
-
|
521
|
-
beforeEach ->
|
522
|
-
@stubFollow()
|
523
|
-
@$link.attr('up-instant', '')
|
524
|
-
|
525
|
-
it 'opens the modal on mousedown (instead of on click)', asyncSpec (next) ->
|
526
|
-
Trigger.mousedown(@$link)
|
527
|
-
next =>
|
528
|
-
expect(@followSpy).toHaveBeenCalledWith(@$link[0], {})
|
529
|
-
|
530
|
-
it 'does nothing on mouseup', asyncSpec (next) ->
|
531
|
-
Trigger.mouseup(@$link)
|
532
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
533
|
-
|
534
|
-
it 'does nothing on click', asyncSpec (next) ->
|
535
|
-
Trigger.mousedown(@$link)
|
536
|
-
Trigger.click(@$link)
|
537
|
-
next => expect(@followSpy.calls.count()).toBe(1)
|
538
|
-
|
539
|
-
# IE does not call JavaScript and always performs the default action on right clicks
|
540
|
-
unless AgentDetector.isIE() || AgentDetector.isEdge()
|
541
|
-
it 'does nothing if the right mouse button is pressed down', asyncSpec (next) ->
|
542
|
-
Trigger.mousedown(@$link, button: 2)
|
543
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
544
|
-
|
545
|
-
it 'does nothing if shift is pressed during mousedown', asyncSpec (next) ->
|
546
|
-
Trigger.mousedown(@$link, shiftKey: true)
|
547
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
548
|
-
|
549
|
-
it 'does nothing if ctrl is pressed during mousedown', asyncSpec (next) ->
|
550
|
-
Trigger.mousedown(@$link, ctrlKey: true)
|
551
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
552
|
-
|
553
|
-
it 'does nothing if meta is pressed during mousedown', asyncSpec (next) ->
|
554
|
-
Trigger.mousedown(@$link, metaKey: true)
|
555
|
-
next => expect(@followSpy).not.toHaveBeenCalled()
|
556
|
-
|
557
|
-
describe 'with [up-method] modifier', ->
|
558
|
-
|
559
|
-
it 'honours the given method', asyncSpec (next) ->
|
560
|
-
$link = $fixture('a[href="/path"][up-modal=".target"][up-method="post"]')
|
561
|
-
Trigger.click($link)
|
562
|
-
|
563
|
-
next =>
|
564
|
-
expect(@lastRequest().method).toEqual 'POST'
|
565
|
-
|
566
|
-
describe 'with [up-cache] modifier', ->
|
567
|
-
it 'honours the given setting', asyncSpec (next) ->
|
568
|
-
$link = $fixture('a[href="/path"][up-modal=".target"][up-cache="false"]')
|
569
|
-
Trigger.clickSequence($link)
|
570
|
-
|
571
|
-
next =>
|
572
|
-
@respondWith('<div class="target">modal content 1</div>')
|
573
|
-
|
574
|
-
next =>
|
575
|
-
expect('.up-modal .target').toHaveText('modal content 1')
|
576
|
-
history.back()
|
577
|
-
|
578
|
-
next =>
|
579
|
-
Trigger.clickSequence($link)
|
580
|
-
|
581
|
-
next =>
|
582
|
-
@respondWith('<div class="target">modal content 2</div>')
|
583
|
-
|
584
|
-
next =>
|
585
|
-
expect('.up-modal .target').toHaveText('modal content 2')
|
586
|
-
|
587
|
-
it 'adds a history entry and allows the user to use the back button', asyncSpec (next) ->
|
588
|
-
up.motion.config.enabled = false
|
589
|
-
up.history.config.enabled = true
|
590
|
-
up.history.config.popTargets = ['.container']
|
591
|
-
|
592
|
-
up.history.push('/original-path')
|
593
|
-
|
594
|
-
$container = $fixture('.container').text('old container content')
|
595
|
-
$link = $container.affix('a[href="/new-path"][up-modal=".target"]')
|
596
|
-
|
597
|
-
expect(location.pathname).toEqual('/original-path')
|
598
|
-
|
599
|
-
Trigger.clickSequence($link)
|
600
|
-
|
601
|
-
next =>
|
602
|
-
@respondWith('<div class="target">modal content</div>')
|
603
|
-
|
604
|
-
next =>
|
605
|
-
expect(location.pathname).toEqual('/new-path')
|
606
|
-
expect('.up-modal .target').toHaveText('modal content')
|
607
|
-
|
608
|
-
history.back()
|
609
|
-
|
610
|
-
next.after (waitForBrowser = 70), =>
|
611
|
-
@respondWith('<div class="container">restored container content</div>')
|
612
|
-
|
613
|
-
next =>
|
614
|
-
expect(location.pathname).toEqual('/original-path')
|
615
|
-
expect('.container').toHaveText('restored container content')
|
616
|
-
expect('.up-modal').not.toBeAttached()
|
617
|
-
|
618
|
-
it 'allows to open a modal after closing a previous modal with the escape key (bugfix)', asyncSpec (next) ->
|
619
|
-
up.motion.config.enabled = false
|
620
|
-
|
621
|
-
$link1 = $fixture('a[href="/path1"][up-modal=".target"]')
|
622
|
-
$link2 = $fixture('a[href="/path2"][up-modal=".target"]')
|
623
|
-
Trigger.clickSequence($link1)
|
624
|
-
|
625
|
-
next =>
|
626
|
-
@respondWith('<div class="target">content 1</div>')
|
627
|
-
|
628
|
-
next =>
|
629
|
-
expect(up.modal.isOpen()).toBe(true)
|
630
|
-
|
631
|
-
Trigger.escapeSequence(document.body)
|
632
|
-
|
633
|
-
next =>
|
634
|
-
expect(up.modal.isOpen()).toBe(false)
|
635
|
-
|
636
|
-
Trigger.clickSequence($link2)
|
637
|
-
|
638
|
-
next =>
|
639
|
-
@respondWith('<div class="target">content 1</div>')
|
640
|
-
|
641
|
-
next =>
|
642
|
-
expect(up.modal.isOpen()).toBe(true)
|
643
|
-
|
644
|
-
|
645
|
-
describe '[up-drawer]', ->
|
646
|
-
|
647
|
-
beforeEach ->
|
648
|
-
up.motion.config.enabled = false
|
649
|
-
|
650
|
-
it 'slides in a drawer that covers the full height of the screen', asyncSpec (next) ->
|
651
|
-
$link = $fixture('a[href="/qux"][up-drawer=".target"]').text('label')
|
652
|
-
up.hello($link)
|
653
|
-
Trigger.clickSequence($link)
|
654
|
-
|
655
|
-
next =>
|
656
|
-
@respondWith '<div class="target">new text</div>'
|
657
|
-
|
658
|
-
next =>
|
659
|
-
expect(up.modal.isOpen()).toBe(true)
|
660
|
-
expect($('.up-modal').attr('up-flavor')).toEqual('drawer')
|
661
|
-
windowHeight = up.viewport.rootHeight()
|
662
|
-
modalHeight = $('.up-modal-content').outerHeight()
|
663
|
-
expect(modalHeight).toEqual(windowHeight)
|
664
|
-
expect($('.up-modal-content').offset()).toEqual(top: 0, left: 0)
|
665
|
-
|
666
|
-
it 'puts the drawer on the right if the opening link sits in the right 50% of the screen', asyncSpec (next) ->
|
667
|
-
$link = $fixture('a[href="/foo"][up-drawer=".target"]').text('label')
|
668
|
-
$link.css
|
669
|
-
position: 'absolute'
|
670
|
-
right: '0'
|
671
|
-
up.hello($link)
|
672
|
-
Trigger.clickSequence($link)
|
673
|
-
|
674
|
-
next =>
|
675
|
-
@respondWith '<div class="target">new text</div>'
|
676
|
-
|
677
|
-
next =>
|
678
|
-
expect(up.modal.isOpen()).toBe(true)
|
679
|
-
windowWidth = up.viewport.rootWidth()
|
680
|
-
modalWidth = $('.up-modal-content').outerWidth()
|
681
|
-
scrollbarWidth = up.viewport.scrollbarWidth()
|
682
|
-
expect($('.up-modal-content').offset().left).toBeAround(windowWidth - modalWidth - scrollbarWidth, 1.0)
|
683
|
-
|
684
|
-
describe '[up-close]', ->
|
685
|
-
|
686
|
-
backgroundClicked = undefined
|
687
|
-
|
688
|
-
beforeEach ->
|
689
|
-
up.motion.config.enabled = false
|
690
|
-
backgroundClicked = jasmine.createSpy('background clicked')
|
691
|
-
up.on 'click', backgroundClicked
|
692
|
-
|
693
|
-
describe 'when clicked inside a modal', ->
|
694
|
-
|
695
|
-
it 'closes the open modal and halts the event chain', asyncSpec (next) ->
|
696
|
-
up.modal.extract('.target', '<div class="target"><a up-close>text</a></div>', animation: false)
|
697
|
-
|
698
|
-
next =>
|
699
|
-
$link = $('.up-modal a[up-close]') # link is within the modal
|
700
|
-
Trigger.clickSequence($link)
|
701
|
-
|
702
|
-
next =>
|
703
|
-
expect(up.modal.isOpen()).toBe(false)
|
704
|
-
expect(backgroundClicked).not.toHaveBeenCalled()
|
705
|
-
|
706
|
-
|
707
|
-
describe 'when no modal is open', ->
|
708
|
-
|
709
|
-
it 'does nothing and allows the event chain to continue', asyncSpec (next) ->
|
710
|
-
$link = $fixture('a[up-close]') # link is outside the modal
|
711
|
-
up.hello($link)
|
712
|
-
Trigger.clickSequence($link)
|
713
|
-
|
714
|
-
next =>
|
715
|
-
expect(backgroundClicked).toHaveBeenCalled()
|
716
|
-
|
717
|
-
describe 'closing', ->
|
718
|
-
|
719
|
-
it 'closes the modal on close icon click', asyncSpec (next) ->
|
720
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
721
|
-
|
722
|
-
next =>
|
723
|
-
$closeIcon = $('.up-modal-close')
|
724
|
-
Trigger.clickSequence($closeIcon)
|
725
|
-
|
726
|
-
next =>
|
727
|
-
expect(up.modal.isOpen()).toBe(false)
|
728
|
-
|
729
|
-
it 'closes the modal on backdrop click', asyncSpec (next) ->
|
730
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
731
|
-
|
732
|
-
next =>
|
733
|
-
$backdrop = $('.up-modal-backdrop')
|
734
|
-
Trigger.clickSequence($backdrop)
|
735
|
-
|
736
|
-
next =>
|
737
|
-
expect(up.modal.isOpen()).toBe(false)
|
738
|
-
|
739
|
-
it "does not close the modal when clicking on an element outside the modal's DOM hierarchy", asyncSpec (next) ->
|
740
|
-
$container = $fixture('.container')
|
741
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
742
|
-
|
743
|
-
next =>
|
744
|
-
Trigger.clickSequence($container)
|
745
|
-
|
746
|
-
next =>
|
747
|
-
expect(up.modal.isOpen()).toBe(true)
|
748
|
-
|
749
|
-
it 'closes the modal when the user presses the escape key', asyncSpec (next) ->
|
750
|
-
wasClosed = false
|
751
|
-
up.on 'up:modal:close', ->
|
752
|
-
wasClosed = true
|
753
|
-
|
754
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
755
|
-
|
756
|
-
next =>
|
757
|
-
Trigger.escapeSequence(document.body)
|
758
|
-
|
759
|
-
next =>
|
760
|
-
expect(wasClosed).toBe(true)
|
761
|
-
|
762
|
-
it 'stays open if #preventDefault() is called on up:modal:close event', asyncSpec (next) ->
|
763
|
-
up.modal.extract('.target', '<div class="target"><a up-close>text</a></div>', animation: false)
|
764
|
-
up.on 'up:modal:close', (e) -> e.preventDefault()
|
765
|
-
|
766
|
-
next =>
|
767
|
-
$backdrop = $('.up-modal-backdrop')
|
768
|
-
Trigger.clickSequence($backdrop)
|
769
|
-
|
770
|
-
next =>
|
771
|
-
expect(up.modal.isOpen()).toBe(true)
|
772
|
-
|
773
|
-
# Since there isn't anyone who could handle the rejection inside
|
774
|
-
# the event handler, our handler mutes the rejection.
|
775
|
-
expect(window).not.toHaveUnhandledRejections()
|
776
|
-
|
777
|
-
describe 'when opened with { closable: false }', ->
|
778
|
-
|
779
|
-
it 'does not render a close icon', asyncSpec (next) ->
|
780
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
781
|
-
|
782
|
-
next =>
|
783
|
-
expect('.up-modal').not.toHaveDescendant('.up-modal-close')
|
784
|
-
|
785
|
-
it 'does not close the modal on backdrop click', asyncSpec (next) ->
|
786
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
787
|
-
|
788
|
-
next =>
|
789
|
-
$backdrop = $('.up-modal-backdrop')
|
790
|
-
Trigger.clickSequence($backdrop)
|
791
|
-
|
792
|
-
next =>
|
793
|
-
expect(up.modal.isOpen()).toBe(true)
|
794
|
-
|
795
|
-
it 'does not close the modal when the user presses the escape key', asyncSpec (next) ->
|
796
|
-
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
797
|
-
|
798
|
-
next =>
|
799
|
-
Trigger.escapeSequence(document.body)
|
800
|
-
|
801
|
-
next =>
|
802
|
-
expect(up.modal.isOpen()).toBe(true)
|
803
|
-
|
804
|
-
describe 'when replacing content', ->
|
805
|
-
|
806
|
-
beforeEach ->
|
807
|
-
up.motion.config.enabled = false
|
808
|
-
|
809
|
-
it 'prefers to replace a selector within the modal', asyncSpec (next) ->
|
810
|
-
$outside = $fixture('.foo').text('old outside')
|
811
|
-
up.modal.visit('/path', target: '.foo')
|
812
|
-
|
813
|
-
next =>
|
814
|
-
@respondWith("<div class='foo'>old inside</div>")
|
815
|
-
|
816
|
-
next =>
|
817
|
-
up.extract('.foo', "<div class='foo'>new text</div>")
|
818
|
-
|
819
|
-
next =>
|
820
|
-
expect($outside).toBeAttached()
|
821
|
-
expect($outside).toHaveText('old outside')
|
822
|
-
expect($('.up-modal-content')).toHaveText('new text')
|
823
|
-
|
824
|
-
it 'auto-closes the modal when a replacement from inside the modal affects a selector behind the modal', asyncSpec (next) ->
|
825
|
-
$fixture('.outside').text('old outside')
|
826
|
-
up.modal.visit('/path', target: '.inside')
|
827
|
-
|
828
|
-
next =>
|
829
|
-
@respondWith("<div class='inside'>old inside</div>")
|
830
|
-
|
831
|
-
next =>
|
832
|
-
up.extract('.outside', "<div class='outside'>new outside</div>", origin: $('.inside'))
|
833
|
-
|
834
|
-
next =>
|
835
|
-
expect($('.outside')).toHaveText('new outside')
|
836
|
-
expect($('.up-modal')).not.toBeAttached()
|
837
|
-
|
838
|
-
it 'does not restore the covered URL when auto-closing (since it would override the URL from the triggering update)', asyncSpec (next) ->
|
839
|
-
up.history.config.enabled = true
|
840
|
-
up.motion.config.enabled = true
|
841
|
-
up.modal.config.openDuration = 0
|
842
|
-
up.modal.config.closeDuration = 20
|
843
|
-
|
844
|
-
$fixture('.outside').text('old outside')
|
845
|
-
up.modal.visit('/path', target: '.inside')
|
846
|
-
|
847
|
-
next =>
|
848
|
-
@respondWith("<div class='inside'>old inside</div>") # Populate modal
|
849
|
-
|
850
|
-
next =>
|
851
|
-
up.extract('.outside', "<div class='outside'>new outside</div>",
|
852
|
-
origin: $('.inside'), history: '/new-location') # Provoke auto-close
|
853
|
-
|
854
|
-
next =>
|
855
|
-
expect(location.href).toMatchUrl '/new-location'
|
856
|
-
|
857
|
-
it 'does not auto-close the modal when a replacement from inside the modal affects a selector inside the modal', asyncSpec (next) ->
|
858
|
-
$fixture('.outside').text('old outside')
|
859
|
-
up.modal.visit('/path', target: '.inside')
|
860
|
-
|
861
|
-
next =>
|
862
|
-
@respondWith("<div class='inside'>old inside</div>")
|
863
|
-
|
864
|
-
next =>
|
865
|
-
up.extract('.inside', "<div class='inside'>new inside</div>", origin: $('.inside'))
|
866
|
-
|
867
|
-
next =>
|
868
|
-
expect($('.inside')).toHaveText('new inside')
|
869
|
-
expect($('.up-modal')).toBeAttached()
|
870
|
-
|
871
|
-
it 'does not auto-close the modal when a replacement from outside the modal affects a selector outside the modal', asyncSpec (next) ->
|
872
|
-
$fixture('.outside').text('old outside')
|
873
|
-
up.modal.visit('/path', target: '.inside')
|
874
|
-
|
875
|
-
next =>
|
876
|
-
@respondWith("<div class='inside'>old inside</div>")
|
877
|
-
|
878
|
-
next =>
|
879
|
-
up.extract('.outside', "<div class='outside'>new outside</div>", origin: $('.outside'))
|
880
|
-
|
881
|
-
next =>
|
882
|
-
expect($('.outside')).toHaveText('new outside')
|
883
|
-
expect($('.up-modal')).toBeAttached()
|
884
|
-
|
885
|
-
it 'does not auto-close the modal when a replacement from outside the modal affects a selector inside the modal', asyncSpec (next) ->
|
886
|
-
$fixture('.outside').text('old outside')
|
887
|
-
up.modal.visit('/path', target: '.inside')
|
888
|
-
|
889
|
-
next =>
|
890
|
-
@respondWith("<div class='inside'>old inside</div>")
|
891
|
-
|
892
|
-
next =>
|
893
|
-
up.extract('.inside', "<div class='inside'>new inside</div>", origin: $('.outside'))
|
894
|
-
|
895
|
-
next =>
|
896
|
-
expect($('.inside')).toHaveText('new inside')
|
897
|
-
expect($('.up-modal')).toBeAttached()
|
898
|
-
|
899
|
-
it 'does not auto-close the modal when the new fragment is within a popup', asyncSpec (next) ->
|
900
|
-
up.modal.visit('/modal', target: '.modal-content')
|
901
|
-
|
902
|
-
next =>
|
903
|
-
@respondWith("<div class='modal-content'></div>")
|
904
|
-
|
905
|
-
next =>
|
906
|
-
up.popup.attach('.modal-content', url: '/popup', target: '.popup-content')
|
907
|
-
|
908
|
-
next =>
|
909
|
-
@respondWith("<div class='popup-content'></div>")
|
910
|
-
|
911
|
-
next =>
|
912
|
-
expect($('.up-modal')).toBeAttached()
|
913
|
-
expect($('.up-popup')).toBeAttached()
|
914
|
-
|
915
|
-
it 'does not close the modal when a clicked [up-target] link within the modal links to cached content (bugfix)', asyncSpec (next) ->
|
916
|
-
up.modal.extract '.content', """
|
917
|
-
<div class="content">
|
918
|
-
<a href="/foo" up-target=".content">link</a>
|
919
|
-
</div>
|
920
|
-
"""
|
921
|
-
|
922
|
-
next =>
|
923
|
-
$link = $('.up-modal .content a')
|
924
|
-
expect($link).toBeAttached()
|
925
|
-
up.proxy.preload($link)
|
926
|
-
|
927
|
-
next =>
|
928
|
-
@respondWith """
|
929
|
-
<div class="content">
|
930
|
-
new text
|
931
|
-
</div>
|
932
|
-
"""
|
933
|
-
|
934
|
-
next =>
|
935
|
-
Trigger.clickSequence('.up-modal .content a')
|
936
|
-
|
937
|
-
next =>
|
938
|
-
expect($('.up-modal')).toBeAttached()
|
939
|
-
expect($('.up-modal .content')).toHaveText('new text')
|