unpoly-rails 0.57.0 → 0.60.0
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/CHANGELOG.md +393 -1
- data/Gemfile.lock +5 -2
- data/README.md +1 -1
- data/README_RAILS.md +1 -1
- data/Rakefile +10 -1
- data/design/es6.js +32 -0
- data/design/ie11.txt +9 -0
- data/design/measure_jquery/element_list.js +41 -0
- data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
- data/design/todo_jquery.txt +13 -0
- data/dist/unpoly-bootstrap3.js +8 -8
- data/dist/unpoly-bootstrap3.min.js +1 -1
- data/dist/unpoly.css +22 -20
- data/dist/unpoly.js +6990 -5336
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +4 -4
- data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
- data/lib/assets/javascripts/unpoly.coffee +8 -6
- data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
- data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
- data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
- data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
- data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
- data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
- data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
- data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
- data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
- data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
- data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
- data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
- data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
- data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
- data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
- data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
- data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
- data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
- data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
- data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
- data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
- data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
- data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
- data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
- data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
- data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
- data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
- data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
- data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
- data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
- data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
- data/lib/assets/javascripts/unpoly/history.coffee +29 -28
- data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
- data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
- data/lib/assets/javascripts/unpoly/log.coffee +99 -19
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
- data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
- data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
- data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
- data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
- data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
- data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
- data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
- data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
- data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
- data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
- data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
- data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
- data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
- data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
- data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -2
- data/spec_app/Gemfile +2 -1
- data/spec_app/Gemfile.lock +38 -27
- data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
- data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
- data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
- data/spec_app/app/views/css_test/modal.erb +6 -6
- data/spec_app/app/views/css_test/popup.erb +44 -18
- data/spec_app/app/views/css_test/tooltip.erb +23 -4
- data/spec_app/app/views/error_test/trigger.erb +1 -1
- data/spec_app/app/views/form_test/basics/new.erb +1 -3
- data/spec_app/app/views/pages/start.erb +9 -2
- data/spec_app/app/views/reveal_test/long1.erb +1 -1
- data/spec_app/app/views/reveal_test/long2.erb +1 -1
- data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
- data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
- data/spec_app/app/views/scroll_test/long1.erb +30 -0
- data/spec_app/config/routes.rb +1 -0
- data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
- data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
- data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
- data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
- data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
- data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
- data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
- data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
- data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
- data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
- data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
- data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
- data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
- data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
- data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
- data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
- data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
- data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
- data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
- data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
- data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
- data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
- data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
- data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
- data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
- data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
- data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
- data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
- data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
- data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
- data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
- data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
- data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
- data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
- data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
- data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
- data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
- data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
- data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
- data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
- data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
- data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
- data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
- data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
- metadata +57 -19
- data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
- data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
- data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
- data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
- data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
- data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
- data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
- data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
- data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
- data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
- data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -1,3 +1,6 @@
|
|
1
|
+
u = up.util
|
2
|
+
$ = jQuery
|
3
|
+
|
1
4
|
describe 'up.log', ->
|
2
5
|
|
3
6
|
describe 'JavaScript functions', ->
|
@@ -5,42 +8,112 @@ describe 'up.log', ->
|
|
5
8
|
describe 'up.log.puts', ->
|
6
9
|
|
7
10
|
it 'sends a log message to the developer console iff the log is enabled', ->
|
8
|
-
spyOn(
|
11
|
+
spyOn(console, 'log')
|
9
12
|
|
10
13
|
up.log.disable()
|
11
14
|
up.log.puts('message')
|
12
|
-
expect(
|
15
|
+
expect(console.log).not.toHaveBeenCalled()
|
13
16
|
|
14
17
|
up.log.enable()
|
15
18
|
up.log.puts('message')
|
16
|
-
expect(
|
19
|
+
expect(console.log).toHaveBeenCalledWith('[UP] message')
|
17
20
|
|
18
21
|
describe 'up.log.debug', ->
|
19
22
|
|
20
23
|
it 'sends a debug message to the developer console iff the log is enabled', ->
|
21
|
-
spyOn(
|
24
|
+
spyOn(console, 'debug')
|
22
25
|
|
23
26
|
up.log.disable()
|
24
27
|
up.log.debug('message')
|
25
|
-
expect(
|
28
|
+
expect(console.debug).not.toHaveBeenCalled()
|
26
29
|
|
27
30
|
up.log.enable()
|
28
31
|
up.log.debug('message')
|
29
|
-
expect(
|
32
|
+
expect(console.debug).toHaveBeenCalledWith('[UP] message')
|
30
33
|
|
31
34
|
describe 'up.log.error', ->
|
32
35
|
|
33
36
|
it 'sends an error message to the developer console regardless whether the log is enabled or not', ->
|
34
|
-
spyOn(
|
37
|
+
spyOn(console, 'error')
|
35
38
|
|
36
39
|
up.log.disable()
|
37
40
|
up.log.error('message1')
|
38
|
-
expect(
|
41
|
+
expect(console.error).toHaveBeenCalledWith('[UP] message1')
|
39
42
|
|
40
43
|
up.log.enable()
|
41
44
|
up.log.error('message2')
|
42
|
-
expect(
|
43
|
-
['
|
44
|
-
['
|
45
|
+
expect(console.error.calls.allArgs()).toEqual [
|
46
|
+
['[UP] message1'],
|
47
|
+
['[UP] message2']
|
45
48
|
]
|
46
|
-
|
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,23 +1,22 @@
|
|
1
|
-
|
1
|
+
u = up.util
|
2
|
+
e = up.element
|
3
|
+
$ = jQuery
|
2
4
|
|
3
|
-
|
5
|
+
describe 'up.modal', ->
|
4
6
|
|
5
7
|
beforeEach ->
|
6
8
|
up.modal.config.openDuration = 5
|
7
9
|
up.modal.config.closeDuration = 5
|
8
10
|
|
9
11
|
describe 'JavaScript functions', ->
|
10
|
-
# Safari overlays the scrollbar tracker over the picture.
|
11
|
-
# The scrollbar does not take space.
|
12
|
-
assumedScrollbarWidth = if AgentDetector.isSafari() then 0 else 15
|
13
12
|
|
14
13
|
describe 'up.modal.follow', ->
|
15
14
|
|
16
15
|
it "loads the given link's destination in a dialog window", (done) ->
|
17
|
-
$link =
|
16
|
+
$link = $fixture('a[href="/path/to"][up-modal=".middle"]').text('link')
|
18
17
|
promise = up.modal.follow($link)
|
19
18
|
|
20
|
-
u.
|
19
|
+
u.task =>
|
21
20
|
expect(@lastRequest().url).toMatch /\/path\/to$/
|
22
21
|
@respondWith """
|
23
22
|
<div class="before">new-before</div>
|
@@ -26,12 +25,12 @@ describe 'up.modal', ->
|
|
26
25
|
"""
|
27
26
|
|
28
27
|
promise.then =>
|
29
|
-
expect($('.up-modal')).
|
30
|
-
expect($('.up-modal-dialog')).
|
31
|
-
expect($('.up-modal-dialog .middle')).
|
28
|
+
expect($('.up-modal')).toBeAttached()
|
29
|
+
expect($('.up-modal-dialog')).toBeAttached()
|
30
|
+
expect($('.up-modal-dialog .middle')).toBeAttached()
|
32
31
|
expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
|
33
|
-
expect($('.up-modal-dialog .before')).not.
|
34
|
-
expect($('.up-modal-dialog .after')).not.
|
32
|
+
expect($('.up-modal-dialog .before')).not.toBeAttached()
|
33
|
+
expect($('.up-modal-dialog .after')).not.toBeAttached()
|
35
34
|
done()
|
36
35
|
|
37
36
|
describe 'up.modal.extract', ->
|
@@ -47,12 +46,12 @@ describe 'up.modal', ->
|
|
47
46
|
"""
|
48
47
|
|
49
48
|
promise.then =>
|
50
|
-
expect($('.up-modal')).
|
51
|
-
expect($('.up-modal-dialog')).
|
52
|
-
expect($('.up-modal-dialog .middle')).
|
49
|
+
expect($('.up-modal')).toBeAttached()
|
50
|
+
expect($('.up-modal-dialog')).toBeAttached()
|
51
|
+
expect($('.up-modal-dialog .middle')).toBeAttached()
|
53
52
|
expect($('.up-modal-dialog .middle')).toHaveText('new-middle')
|
54
|
-
expect($('.up-modal-dialog .before')).not.
|
55
|
-
expect($('.up-modal-dialog .after')).not.
|
53
|
+
expect($('.up-modal-dialog .before')).not.toBeAttached()
|
54
|
+
expect($('.up-modal-dialog .after')).not.toBeAttached()
|
56
55
|
|
57
56
|
# Can't change URLs
|
58
57
|
expect(location.href).toEqual(oldHref)
|
@@ -65,7 +64,7 @@ describe 'up.modal', ->
|
|
65
64
|
|
66
65
|
promise = up.modal.visit('/foo', target: '.middle')
|
67
66
|
|
68
|
-
u.
|
67
|
+
u.task =>
|
69
68
|
@respondWith """
|
70
69
|
<div class="before">new-before</div>
|
71
70
|
<div class="middle">new-middle</div>
|
@@ -73,21 +72,21 @@ describe 'up.modal', ->
|
|
73
72
|
"""
|
74
73
|
|
75
74
|
promise.then =>
|
76
|
-
expect('.up-modal').
|
77
|
-
expect('.up-modal-dialog').
|
78
|
-
expect('.up-modal-dialog .middle').
|
75
|
+
expect('.up-modal').toBeAttached()
|
76
|
+
expect('.up-modal-dialog').toBeAttached()
|
77
|
+
expect('.up-modal-dialog .middle').toBeAttached()
|
79
78
|
expect('.up-modal-dialog .middle').toHaveText('new-middle')
|
80
|
-
expect('.up-modal-dialog .before').not.
|
81
|
-
expect('.up-modal-dialog .after').not.
|
79
|
+
expect('.up-modal-dialog .before').not.toBeAttached()
|
80
|
+
expect('.up-modal-dialog .after').not.toBeAttached()
|
82
81
|
expect(location.pathname).toMatchUrl('/foo')
|
83
82
|
done()
|
84
83
|
|
85
84
|
it "doesn't create an .up-modal frame and replaces { failTarget } if the server returns a non-200 response", (done) ->
|
86
|
-
|
85
|
+
$fixture('.error').text('old error')
|
87
86
|
|
88
87
|
promise = up.modal.visit('/foo', target: '.target', failTarget: '.error')
|
89
88
|
|
90
|
-
u.
|
89
|
+
u.task =>
|
91
90
|
@respondWith
|
92
91
|
status: 500
|
93
92
|
responseText: """
|
@@ -96,7 +95,7 @@ describe 'up.modal', ->
|
|
96
95
|
"""
|
97
96
|
|
98
97
|
promise.catch =>
|
99
|
-
expect('.up-modal').not.
|
98
|
+
expect('.up-modal').not.toBeAttached()
|
100
99
|
expect('.error').toHaveText('new error')
|
101
100
|
done()
|
102
101
|
|
@@ -110,29 +109,42 @@ describe 'up.modal', ->
|
|
110
109
|
describe 'preventing elements from jumping as scrollbars change', ->
|
111
110
|
|
112
111
|
it "brings its own scrollbar, padding the body on the right", (done) ->
|
113
|
-
|
112
|
+
$body = $(document.body)
|
114
113
|
|
115
|
-
|
116
|
-
|
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()
|
117
118
|
|
118
|
-
|
119
|
-
$modal = $('.up-modal')
|
120
|
-
$viewport = $modal.find('.up-modal-viewport')
|
121
|
-
$body = $('body')
|
122
|
-
expect($modal).toExist()
|
123
|
-
expect($viewport.css('overflow-y')).toEqual('scroll')
|
124
|
-
expect($body.css('overflow-y')).toEqual('hidden')
|
125
|
-
expect(parseInt($body.css('padding-right'))).toBeAround(assumedScrollbarWidth, 5)
|
119
|
+
$rootOverflowElement = $(up.viewport.rootOverflowElement())
|
126
120
|
|
127
|
-
up.modal.
|
128
|
-
|
129
|
-
|
130
|
-
|
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()
|
131
143
|
|
132
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) ->
|
133
145
|
openPromise = up.modal.extract('.container', '<div class="container">text</div>', animation: 'fade-in', duration: 100)
|
134
146
|
|
135
|
-
u.
|
147
|
+
u.timer 50, ->
|
136
148
|
$modal = $('.up-modal')
|
137
149
|
$viewport = $modal.find('.up-modal-viewport')
|
138
150
|
expect($modal).toHaveClass('up-modal-animating')
|
@@ -145,18 +157,19 @@ describe 'up.modal', ->
|
|
145
157
|
expect($viewport.css('overflow-y')).toEqual('scroll')
|
146
158
|
closePromise = up.modal.close(animation: 'fade-out', duration: 400)
|
147
159
|
|
148
|
-
u.
|
160
|
+
u.timer 50, ->
|
149
161
|
expect($modal).toHaveClass('up-modal-animating')
|
150
162
|
expect($modal.css('overflow-y')).toEqual('scroll')
|
151
163
|
expect($viewport.css('overflow-y')).toEqual('hidden')
|
152
164
|
done()
|
153
165
|
|
154
|
-
it
|
155
|
-
restoreBody =
|
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')
|
156
169
|
|
157
170
|
up.modal.extract('.container', '<div class="container">text</div>').then ->
|
158
171
|
$body = $('body')
|
159
|
-
expect($('.up-modal')).
|
172
|
+
expect($('.up-modal')).toBeAttached()
|
160
173
|
expect(parseInt($body.css('padding-right'))).toBe(0)
|
161
174
|
|
162
175
|
up.modal.close().then ->
|
@@ -164,13 +177,13 @@ describe 'up.modal', ->
|
|
164
177
|
restoreBody()
|
165
178
|
done()
|
166
179
|
|
167
|
-
it
|
168
|
-
restoreBody =
|
169
|
-
restoreReporter =
|
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')
|
170
183
|
|
171
184
|
up.modal.extract('.container', '<div class="container">text</div>').then ->
|
172
185
|
$body = $('body')
|
173
|
-
expect($('.up-modal')).
|
186
|
+
expect($('.up-modal')).toBeAttached()
|
174
187
|
expect(parseInt($body.css('padding-right'))).toBe(0)
|
175
188
|
|
176
189
|
up.modal.close().then ->
|
@@ -180,29 +193,37 @@ describe 'up.modal', ->
|
|
180
193
|
done()
|
181
194
|
|
182
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'
|
183
205
|
|
184
|
-
|
185
|
-
position: 'absolute'
|
186
|
-
top: '0'
|
187
|
-
right: '30px'
|
188
|
-
|
189
|
-
promise = up.modal.visit('/foo', target: '.container')
|
206
|
+
promise = up.modal.visit('/foo', target: '.container')
|
190
207
|
|
191
|
-
|
192
|
-
|
208
|
+
u.task =>
|
209
|
+
@respondWith('<div class="container">text</div>')
|
193
210
|
|
194
|
-
|
195
|
-
|
211
|
+
promise.then ->
|
212
|
+
expect(parseInt($anchoredElement.css('right'))).toBeAround(30 + scrollbarWidth, 10)
|
196
213
|
|
197
|
-
|
198
|
-
|
199
|
-
|
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()
|
200
220
|
|
201
221
|
describe 'opening a modal while another modal is open', ->
|
202
222
|
|
203
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) ->
|
204
224
|
up.modal.config.closeDuration = 10
|
205
|
-
|
225
|
+
scrollbarWidth = up.viewport.scrollbarWidth()
|
226
|
+
|
206
227
|
# Load a first modal
|
207
228
|
up.modal.visit('/path1', target: '.container', animation: 'fade-in', duration: 50)
|
208
229
|
|
@@ -210,7 +231,7 @@ describe 'up.modal', ->
|
|
210
231
|
# This will discard the first request immediately.
|
211
232
|
up.modal.visit('/path2', target: '.container', animation: 'fade-in', duration: 50)
|
212
233
|
|
213
|
-
u.
|
234
|
+
u.task =>
|
214
235
|
# The second modal has survived
|
215
236
|
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
216
237
|
expect(@lastRequest().url).toMatchUrl('/path2')
|
@@ -218,31 +239,31 @@ describe 'up.modal', ->
|
|
218
239
|
# We send the response for 2
|
219
240
|
@respondWith('<div class="container">response2</div>')
|
220
241
|
|
221
|
-
u.
|
242
|
+
u.timer 10, =>
|
222
243
|
# The second modal is now opening
|
223
244
|
up.modal.visit('/path3', target: '.container', animation: 'fade-in', duration: 50)
|
224
245
|
|
225
246
|
# Load a third modal before the second was done opening
|
226
|
-
u.
|
247
|
+
u.task =>
|
227
248
|
# Since we're still opening the second modal, no request has been made.
|
228
249
|
expect(jasmine.Ajax.requests.count()).toEqual(1)
|
229
250
|
|
230
|
-
u.
|
251
|
+
u.timer 180, =>
|
231
252
|
# Now that the second modal has opened, we make the request to /path3
|
232
253
|
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
233
254
|
expect(@lastRequest().url).toMatchUrl('/path3')
|
234
255
|
|
235
256
|
@respondWith('<div class="container">response3</div>')
|
236
257
|
|
237
|
-
u.
|
258
|
+
u.timer 180, =>
|
238
259
|
expect(jasmine.Ajax.requests.count()).toEqual(2)
|
239
260
|
expect($('.up-modal').length).toBe(1)
|
240
261
|
expect($('.up-modal-dialog').length).toBe(1)
|
241
262
|
expect($('.container')).toHaveText('response3')
|
242
263
|
bodyPadding = parseInt($('body').css('padding-right'))
|
243
|
-
expect(bodyPadding).toBeAround(
|
244
|
-
if
|
245
|
-
expect(bodyPadding).not.toBeAround(2 *
|
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)
|
246
267
|
done()
|
247
268
|
|
248
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) ->
|
@@ -319,13 +340,13 @@ describe 'up.modal', ->
|
|
319
340
|
closeAnimation: 'move-to-right'
|
320
341
|
|
321
342
|
animations = []
|
322
|
-
spyOn(up, 'animate').and.callFake (
|
323
|
-
if
|
343
|
+
spyOn(up, 'animate').and.callFake (element, animation, options) ->
|
344
|
+
if e.matches(element, '.up-modal-viewport')
|
324
345
|
animations.push
|
325
|
-
text:
|
346
|
+
text: element.querySelector('.target').innerText.trim()
|
326
347
|
animation: animation
|
327
348
|
deferred = u.newDeferred()
|
328
|
-
u.
|
349
|
+
u.timer options.duration, -> deferred.resolve()
|
329
350
|
deferred.promise()
|
330
351
|
|
331
352
|
up.modal.extract('.target', '<div class="target">response1</div>')
|
@@ -370,7 +391,7 @@ describe 'up.modal', ->
|
|
370
391
|
expect(respond).not.toThrowError()
|
371
392
|
|
372
393
|
next.await =>
|
373
|
-
expect($('.up-toast')).not.
|
394
|
+
expect($('.up-toast')).not.toBeAttached()
|
374
395
|
promise = promiseState(openPromise)
|
375
396
|
promise.then (result) => expect(result.state).toEqual('pending')
|
376
397
|
|
@@ -384,7 +405,7 @@ describe 'up.modal', ->
|
|
384
405
|
|
385
406
|
expect(up.modal.coveredUrl()).toBeMissing()
|
386
407
|
visitPromise = up.modal.visit('/bar', target: '.container')
|
387
|
-
u.
|
408
|
+
u.task =>
|
388
409
|
@respondWith('<div class="container">text</div>')
|
389
410
|
visitPromise.then ->
|
390
411
|
expect(up.modal.coveredUrl()).toMatchUrl('/foo')
|
@@ -396,7 +417,7 @@ describe 'up.modal', ->
|
|
396
417
|
|
397
418
|
it 'allows to register new modal variants with its own default configuration', asyncSpec (next) ->
|
398
419
|
up.modal.flavors.variant = { maxWidth: 200 }
|
399
|
-
$link =
|
420
|
+
$link = $fixture('a[href="/path"][up-modal=".target"][up-flavor="variant"]')
|
400
421
|
Trigger.click($link)
|
401
422
|
|
402
423
|
next =>
|
@@ -405,13 +426,13 @@ describe 'up.modal', ->
|
|
405
426
|
next =>
|
406
427
|
$modal = $('.up-modal')
|
407
428
|
$dialog = $modal.find('.up-modal-dialog')
|
408
|
-
expect($modal).
|
429
|
+
expect($modal).toBeAttached()
|
409
430
|
expect($modal.attr('up-flavor')).toEqual('variant')
|
410
431
|
expect($dialog.attr('style')).toContain('max-width: 200px')
|
411
432
|
|
412
433
|
it 'does not change the configuration of non-flavored modals', asyncSpec (next) ->
|
413
434
|
up.modal.flavors.variant = { maxWidth: 200 }
|
414
|
-
$link =
|
435
|
+
$link = $fixture('a[href="/path"][up-modal=".target"]')
|
415
436
|
Trigger.click($link)
|
416
437
|
|
417
438
|
next =>
|
@@ -420,7 +441,7 @@ describe 'up.modal', ->
|
|
420
441
|
next =>
|
421
442
|
$modal = $('.up-modal')
|
422
443
|
$dialog = $modal.find('.up-modal-dialog')
|
423
|
-
expect($modal).
|
444
|
+
expect($modal).toBeAttached()
|
424
445
|
expect($dialog.attr('style')).toBeBlank()
|
425
446
|
|
426
447
|
describe 'up.modal.close', ->
|
@@ -428,11 +449,11 @@ describe 'up.modal', ->
|
|
428
449
|
it 'closes a currently open modal', (done) ->
|
429
450
|
up.modal.extract('.content', '<div class="content">Modal content</div>')
|
430
451
|
|
431
|
-
u.
|
432
|
-
expect('.up-modal .content').
|
452
|
+
u.task =>
|
453
|
+
expect('.up-modal .content').toBeAttached()
|
433
454
|
|
434
455
|
up.modal.close().then ->
|
435
|
-
expect('.up-modal .content').not.
|
456
|
+
expect('.up-modal .content').not.toBeAttached()
|
436
457
|
done()
|
437
458
|
|
438
459
|
it 'does nothing if no modal is open', (done) ->
|
@@ -454,12 +475,12 @@ describe 'up.modal', ->
|
|
454
475
|
# Some examples only want to check if follow() has been called, without
|
455
476
|
# actually making a request.
|
456
477
|
@stubFollow = =>
|
457
|
-
@$link =
|
478
|
+
@$link = $fixture('a[href="/path"][up-modal=".target"]')
|
458
479
|
@followSpy = up.modal.knife.mock('followAsap').and.returnValue(Promise.resolve())
|
459
480
|
@defaultSpy = spyOn(up.link, 'allowDefault').and.callFake((event) -> event.preventDefault())
|
460
481
|
|
461
482
|
it 'opens the clicked link in a modal', asyncSpec (next) ->
|
462
|
-
@$link =
|
483
|
+
@$link = $fixture('a[href="/path"][up-modal=".target"]')
|
463
484
|
Trigger.click(@$link)
|
464
485
|
|
465
486
|
next =>
|
@@ -468,7 +489,7 @@ describe 'up.modal', ->
|
|
468
489
|
@respondWith '<div class="target">new content</div>'
|
469
490
|
|
470
491
|
next =>
|
471
|
-
expect('.up-modal').
|
492
|
+
expect('.up-modal').toBeAttached()
|
472
493
|
expect('.up-modal-content').toHaveText('new content')
|
473
494
|
|
474
495
|
describe 'when modifier keys are held', ->
|
@@ -504,7 +525,7 @@ describe 'up.modal', ->
|
|
504
525
|
it 'opens the modal on mousedown (instead of on click)', asyncSpec (next) ->
|
505
526
|
Trigger.mousedown(@$link)
|
506
527
|
next =>
|
507
|
-
expect(@followSpy).toHaveBeenCalledWith(@$link, {})
|
528
|
+
expect(@followSpy).toHaveBeenCalledWith(@$link[0], {})
|
508
529
|
|
509
530
|
it 'does nothing on mouseup', asyncSpec (next) ->
|
510
531
|
Trigger.mouseup(@$link)
|
@@ -535,7 +556,7 @@ describe 'up.modal', ->
|
|
535
556
|
describe 'with [up-method] modifier', ->
|
536
557
|
|
537
558
|
it 'honours the given method', asyncSpec (next) ->
|
538
|
-
$link =
|
559
|
+
$link = $fixture('a[href="/path"][up-modal=".target"][up-method="post"]')
|
539
560
|
Trigger.click($link)
|
540
561
|
|
541
562
|
next =>
|
@@ -548,7 +569,7 @@ describe 'up.modal', ->
|
|
548
569
|
|
549
570
|
up.history.push('/original-path')
|
550
571
|
|
551
|
-
$container =
|
572
|
+
$container = $fixture('.container').text('old container content')
|
552
573
|
$link = $container.affix('a[href="/new-path"][up-modal=".target"]')
|
553
574
|
|
554
575
|
expect(location.pathname).toEqual('/original-path')
|
@@ -570,13 +591,13 @@ describe 'up.modal', ->
|
|
570
591
|
next =>
|
571
592
|
expect(location.pathname).toEqual('/original-path')
|
572
593
|
expect('.container').toHaveText('restored container content')
|
573
|
-
expect('.up-modal').not.
|
594
|
+
expect('.up-modal').not.toBeAttached()
|
574
595
|
|
575
596
|
it 'allows to open a modal after closing a previous modal with the escape key (bugfix)', asyncSpec (next) ->
|
576
597
|
up.motion.config.enabled = false
|
577
598
|
|
578
|
-
$link1 =
|
579
|
-
$link2 =
|
599
|
+
$link1 = $fixture('a[href="/path1"][up-modal=".target"]')
|
600
|
+
$link2 = $fixture('a[href="/path2"][up-modal=".target"]')
|
580
601
|
Trigger.clickSequence($link1)
|
581
602
|
|
582
603
|
next =>
|
@@ -585,8 +606,7 @@ describe 'up.modal', ->
|
|
585
606
|
next =>
|
586
607
|
expect(up.modal.isOpen()).toBe(true)
|
587
608
|
|
588
|
-
|
589
|
-
$('body').trigger(escapeEvent)
|
609
|
+
Trigger.escapeSequence(document.body)
|
590
610
|
|
591
611
|
next =>
|
592
612
|
expect(up.modal.isOpen()).toBe(false)
|
@@ -606,7 +626,7 @@ describe 'up.modal', ->
|
|
606
626
|
up.motion.config.enabled = false
|
607
627
|
|
608
628
|
it 'slides in a drawer that covers the full height of the screen', asyncSpec (next) ->
|
609
|
-
$link =
|
629
|
+
$link = $fixture('a[href="/qux"][up-drawer=".target"]').text('label')
|
610
630
|
up.hello($link)
|
611
631
|
Trigger.clickSequence($link)
|
612
632
|
|
@@ -616,13 +636,13 @@ describe 'up.modal', ->
|
|
616
636
|
next =>
|
617
637
|
expect(up.modal.isOpen()).toBe(true)
|
618
638
|
expect($('.up-modal').attr('up-flavor')).toEqual('drawer')
|
619
|
-
windowHeight =
|
639
|
+
windowHeight = up.viewport.rootHeight()
|
620
640
|
modalHeight = $('.up-modal-content').outerHeight()
|
621
641
|
expect(modalHeight).toEqual(windowHeight)
|
622
642
|
expect($('.up-modal-content').offset()).toEqual(top: 0, left: 0)
|
623
643
|
|
624
644
|
it 'puts the drawer on the right if the opening link sits in the right 50% of the screen', asyncSpec (next) ->
|
625
|
-
$link =
|
645
|
+
$link = $fixture('a[href="/foo"][up-drawer=".target"]').text('label')
|
626
646
|
$link.css
|
627
647
|
position: 'absolute'
|
628
648
|
right: '0'
|
@@ -634,9 +654,9 @@ describe 'up.modal', ->
|
|
634
654
|
|
635
655
|
next =>
|
636
656
|
expect(up.modal.isOpen()).toBe(true)
|
637
|
-
windowWidth =
|
657
|
+
windowWidth = up.viewport.rootWidth()
|
638
658
|
modalWidth = $('.up-modal-content').outerWidth()
|
639
|
-
scrollbarWidth =
|
659
|
+
scrollbarWidth = up.viewport.scrollbarWidth()
|
640
660
|
expect($('.up-modal-content').offset().left).toBeAround(windowWidth - modalWidth - scrollbarWidth, 1.0)
|
641
661
|
|
642
662
|
describe '[up-close]', ->
|
@@ -665,7 +685,7 @@ describe 'up.modal', ->
|
|
665
685
|
describe 'when no modal is open', ->
|
666
686
|
|
667
687
|
it 'does nothing and allows the event chain to continue', asyncSpec (next) ->
|
668
|
-
$link =
|
688
|
+
$link = $fixture('a[up-close]') # link is outside the modal
|
669
689
|
up.hello($link)
|
670
690
|
Trigger.clickSequence($link)
|
671
691
|
|
@@ -695,7 +715,7 @@ describe 'up.modal', ->
|
|
695
715
|
expect(up.modal.isOpen()).toBe(false)
|
696
716
|
|
697
717
|
it "does not close the modal when clicking on an element outside the modal's DOM hierarchy", asyncSpec (next) ->
|
698
|
-
$container =
|
718
|
+
$container = $fixture('.container')
|
699
719
|
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
700
720
|
|
701
721
|
next =>
|
@@ -712,8 +732,7 @@ describe 'up.modal', ->
|
|
712
732
|
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false)
|
713
733
|
|
714
734
|
next =>
|
715
|
-
|
716
|
-
$('body').trigger(escapeEvent)
|
735
|
+
Trigger.escapeSequence(document.body)
|
717
736
|
|
718
737
|
next =>
|
719
738
|
expect(wasClosed).toBe(true)
|
@@ -739,7 +758,7 @@ describe 'up.modal', ->
|
|
739
758
|
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
740
759
|
|
741
760
|
next =>
|
742
|
-
expect('.up-modal').not.
|
761
|
+
expect('.up-modal').not.toHaveDescendant('.up-modal-close')
|
743
762
|
|
744
763
|
it 'does not close the modal on backdrop click', asyncSpec (next) ->
|
745
764
|
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
@@ -755,8 +774,7 @@ describe 'up.modal', ->
|
|
755
774
|
up.modal.extract('.modal', '<div class="modal">Modal content</div>', animation: false, closable: false)
|
756
775
|
|
757
776
|
next =>
|
758
|
-
|
759
|
-
$('body').trigger(escapeEvent)
|
777
|
+
Trigger.escapeSequence(document.body)
|
760
778
|
|
761
779
|
next =>
|
762
780
|
expect(up.modal.isOpen()).toBe(true)
|
@@ -767,7 +785,7 @@ describe 'up.modal', ->
|
|
767
785
|
up.motion.config.enabled = false
|
768
786
|
|
769
787
|
it 'prefers to replace a selector within the modal', asyncSpec (next) ->
|
770
|
-
$outside =
|
788
|
+
$outside = $fixture('.foo').text('old outside')
|
771
789
|
up.modal.visit('/path', target: '.foo')
|
772
790
|
|
773
791
|
next =>
|
@@ -777,12 +795,12 @@ describe 'up.modal', ->
|
|
777
795
|
up.extract('.foo', "<div class='foo'>new text</div>")
|
778
796
|
|
779
797
|
next =>
|
780
|
-
expect($outside).
|
798
|
+
expect($outside).toBeAttached()
|
781
799
|
expect($outside).toHaveText('old outside')
|
782
800
|
expect($('.up-modal-content')).toHaveText('new text')
|
783
801
|
|
784
802
|
it 'auto-closes the modal when a replacement from inside the modal affects a selector behind the modal', asyncSpec (next) ->
|
785
|
-
|
803
|
+
$fixture('.outside').text('old outside')
|
786
804
|
up.modal.visit('/path', target: '.inside')
|
787
805
|
|
788
806
|
next =>
|
@@ -793,7 +811,7 @@ describe 'up.modal', ->
|
|
793
811
|
|
794
812
|
next =>
|
795
813
|
expect($('.outside')).toHaveText('new outside')
|
796
|
-
expect($('.up-modal')).not.
|
814
|
+
expect($('.up-modal')).not.toBeAttached()
|
797
815
|
|
798
816
|
it 'does not restore the covered URL when auto-closing (since it would override the URL from the triggering update)', asyncSpec (next) ->
|
799
817
|
up.history.config.enabled = true
|
@@ -801,7 +819,7 @@ describe 'up.modal', ->
|
|
801
819
|
up.modal.config.openDuration = 0
|
802
820
|
up.modal.config.closeDuration = 20
|
803
821
|
|
804
|
-
|
822
|
+
$fixture('.outside').text('old outside')
|
805
823
|
up.modal.visit('/path', target: '.inside')
|
806
824
|
|
807
825
|
next =>
|
@@ -815,7 +833,7 @@ describe 'up.modal', ->
|
|
815
833
|
expect(location.href).toMatchUrl '/new-location'
|
816
834
|
|
817
835
|
it 'does not auto-close the modal when a replacement from inside the modal affects a selector inside the modal', asyncSpec (next) ->
|
818
|
-
|
836
|
+
$fixture('.outside').text('old outside')
|
819
837
|
up.modal.visit('/path', target: '.inside')
|
820
838
|
|
821
839
|
next =>
|
@@ -826,10 +844,10 @@ describe 'up.modal', ->
|
|
826
844
|
|
827
845
|
next =>
|
828
846
|
expect($('.inside')).toHaveText('new inside')
|
829
|
-
expect($('.up-modal')).
|
847
|
+
expect($('.up-modal')).toBeAttached()
|
830
848
|
|
831
849
|
it 'does not auto-close the modal when a replacement from outside the modal affects a selector outside the modal', asyncSpec (next) ->
|
832
|
-
|
850
|
+
$fixture('.outside').text('old outside')
|
833
851
|
up.modal.visit('/path', target: '.inside')
|
834
852
|
|
835
853
|
next =>
|
@@ -840,10 +858,10 @@ describe 'up.modal', ->
|
|
840
858
|
|
841
859
|
next =>
|
842
860
|
expect($('.outside')).toHaveText('new outside')
|
843
|
-
expect($('.up-modal')).
|
861
|
+
expect($('.up-modal')).toBeAttached()
|
844
862
|
|
845
863
|
it 'does not auto-close the modal when a replacement from outside the modal affects a selector inside the modal', asyncSpec (next) ->
|
846
|
-
|
864
|
+
$fixture('.outside').text('old outside')
|
847
865
|
up.modal.visit('/path', target: '.inside')
|
848
866
|
|
849
867
|
next =>
|
@@ -854,7 +872,7 @@ describe 'up.modal', ->
|
|
854
872
|
|
855
873
|
next =>
|
856
874
|
expect($('.inside')).toHaveText('new inside')
|
857
|
-
expect($('.up-modal')).
|
875
|
+
expect($('.up-modal')).toBeAttached()
|
858
876
|
|
859
877
|
it 'does not auto-close the modal when the new fragment is within a popup', asyncSpec (next) ->
|
860
878
|
up.modal.visit('/modal', target: '.modal-content')
|
@@ -869,8 +887,8 @@ describe 'up.modal', ->
|
|
869
887
|
@respondWith("<div class='popup-content'></div>")
|
870
888
|
|
871
889
|
next =>
|
872
|
-
expect($('.up-modal')).
|
873
|
-
expect($('.up-popup')).
|
890
|
+
expect($('.up-modal')).toBeAttached()
|
891
|
+
expect($('.up-popup')).toBeAttached()
|
874
892
|
|
875
893
|
it 'does not close the modal when a clicked [up-target] link within the modal links to cached content (bugfix)', asyncSpec (next) ->
|
876
894
|
up.modal.extract '.content', """
|
@@ -881,7 +899,7 @@ describe 'up.modal', ->
|
|
881
899
|
|
882
900
|
next =>
|
883
901
|
$link = $('.up-modal .content a')
|
884
|
-
expect($link).
|
902
|
+
expect($link).toBeAttached()
|
885
903
|
up.proxy.preload($link)
|
886
904
|
|
887
905
|
next =>
|
@@ -895,5 +913,5 @@ describe 'up.modal', ->
|
|
895
913
|
Trigger.clickSequence('.up-modal .content a')
|
896
914
|
|
897
915
|
next =>
|
898
|
-
expect($('.up-modal')).
|
916
|
+
expect($('.up-modal')).toBeAttached()
|
899
917
|
expect($('.up-modal .content')).toHaveText('new text')
|