upjs-rails 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -68,11 +68,30 @@ up.modal = (($) ->
68
68
  </div>
69
69
  """
70
70
 
71
- currentSource = undefined
71
+ ###*
72
+ Returns the source URL for the fragment displayed in the current modal overlay,
73
+ or `undefined` if no modal is currently open.
74
+
75
+ @method up.modal.url
76
+ @return {String}
77
+ the source URL
78
+ ###
79
+ currentUrl = undefined
80
+
81
+ ###*
82
+ Returns the URL of the page below the modal overlay.
83
+
84
+ @method up.modal.coveredUrl
85
+ @return {String}
86
+ @protected
87
+ ###
88
+ coveredUrl = ->
89
+ $modal = $('.up-modal')
90
+ $modal.attr('up-covered-url')
72
91
 
73
92
  reset = ->
74
93
  close()
75
- currentSource = undefined
94
+ currentUrl = undefined
76
95
  config.reset()
77
96
 
78
97
  templateHtml = ->
@@ -83,20 +102,20 @@ up.modal = (($) ->
83
102
  template
84
103
 
85
104
  rememberHistory = ->
86
- $popup = $('.up-modal')
87
- $popup.attr('up-previous-url', up.browser.url())
88
- $popup.attr('up-previous-title', document.title)
105
+ $modal = $('.up-modal')
106
+ $modal.attr('up-covered-url', up.browser.url())
107
+ $modal.attr('up-covered-title', document.title)
89
108
 
90
109
  discardHistory = ->
91
- $popup = $('.up-modal')
92
- $popup.removeAttr('up-previous-url')
93
- $popup.removeAttr('up-previous-title')
110
+ $modal = $('.up-modal')
111
+ $modal.removeAttr('up-covered-url')
112
+ $modal.removeAttr('up-covered-title')
94
113
 
95
114
  createHiddenModal = (options) ->
96
115
  $modal = $(templateHtml())
97
116
  $modal.attr('up-sticky', '') if options.sticky
98
- $modal.attr('up-previous-url', up.browser.url())
99
- $modal.attr('up-previous-title', document.title)
117
+ $modal.attr('up-covered-url', up.browser.url())
118
+ $modal.attr('up-covered-title', document.title)
100
119
  $dialog = $modal.find('.up-modal-dialog')
101
120
  $dialog.css('width', options.width) if u.isPresent(options.width)
102
121
  $dialog.css('max-width', options.maxWidth) if u.isPresent(options.maxWidth)
@@ -138,7 +157,7 @@ up.modal = (($) ->
138
157
  shiftElements()
139
158
  $modal.show()
140
159
  deferred = up.animate($modal, animation, animateOptions)
141
- deferred.then -> up.bus.emit('up:modal:opened')
160
+ deferred.then -> up.emit('up:modal:opened')
142
161
 
143
162
  ###*
144
163
  Opens the given link's destination in a modal overlay:
@@ -146,7 +165,7 @@ up.modal = (($) ->
146
165
  var $link = $('...');
147
166
  up.modal.follow($link);
148
167
 
149
- Any option attributes for [`a[up-modal]`](#a.up-modal) will be honored.
168
+ Any option attributes for [`a[up-modal]`](/a.up-modal) will be honored.
150
169
 
151
170
  \#\#\#\# Events
152
171
 
@@ -162,10 +181,10 @@ up.modal = (($) ->
162
181
  The selector to extract from the response and open in a modal dialog.
163
182
  @param {Number} [options.width]
164
183
  The width of the dialog in pixels.
165
- By [default](#up.modal.defaults) the dialog will grow to fit its contents.
184
+ By [default](/up.modal.config) the dialog will grow to fit its contents.
166
185
  @param {Number} [options.height]
167
186
  The width of the dialog in pixels.
168
- By [default](#up.modal.defaults) the dialog will grow to fit its contents.
187
+ By [default](/up.modal.config) the dialog will grow to fit its contents.
169
188
  @param {Boolean} [options.sticky=false]
170
189
  If set to `true`, the modal remains
171
190
  open even if the page changes in the background.
@@ -174,11 +193,11 @@ up.modal = (($) ->
174
193
  @param {String} [options.animation]
175
194
  The animation to use when opening the modal.
176
195
  @param {Number} [options.duration]
177
- The duration of the animation. See [`up.animate`](/up.motion#up.animate).
196
+ The duration of the animation. See [`up.animate`](/up.animate).
178
197
  @param {Number} [options.delay]
179
- The delay before the animation starts. See [`up.animate`](/up.motion#up.animate).
198
+ The delay before the animation starts. See [`up.animate`](/up.animate).
180
199
  @param {String} [options.easing]
181
- The timing function that controls the animation's acceleration. [`up.animate`](/up.motion#up.animate).
200
+ The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
182
201
  @return {Promise}
183
202
  A promise that will be resolved when the modal has finished loading.
184
203
  ###
@@ -205,7 +224,7 @@ up.modal = (($) ->
205
224
  The CSS selector to extract from the response.
206
225
  The extracted content will be placed into the dialog window.
207
226
  @param {Object} options
208
- See options for [previous `up.modal.open` variant](#up.modal.open).
227
+ See options for [previous `up.modal.open` variant](/up.modal.open).
209
228
  ###
210
229
  visit = (url, options) ->
211
230
  options = u.options(options)
@@ -249,17 +268,6 @@ up.modal = (($) ->
249
268
  # callers by returning a Deferred that will never be resolved.
250
269
  $.Deferred()
251
270
 
252
- ###*
253
- Returns the source URL for the fragment displayed in the current modal overlay,
254
- or `undefined` if no modal is currently open.
255
-
256
- @method up.modal.source
257
- @return {String}
258
- the source URL
259
- ###
260
- source = ->
261
- currentSource
262
-
263
271
  ###*
264
272
  Closes a currently opened modal overlay.
265
273
  Does nothing if no modal is currently open.
@@ -273,7 +281,7 @@ up.modal = (($) ->
273
281
 
274
282
  @method up.modal.close
275
283
  @param {Object} options
276
- See options for [`up.animate`](/up.motion#up.animate)
284
+ See options for [`up.animate`](/up.animate)
277
285
  ###
278
286
  close = (options) ->
279
287
  $modal = $('.up-modal')
@@ -281,14 +289,14 @@ up.modal = (($) ->
281
289
  if up.bus.nobodyPrevents('up:modal:close', $element: $modal)
282
290
  options = u.options(options,
283
291
  animation: config.closeAnimation,
284
- url: $modal.attr('up-previous-url')
285
- title: $modal.attr('up-previous-title')
292
+ url: $modal.attr('up-covered-url')
293
+ title: $modal.attr('up-covered-title')
286
294
  )
287
- currentSource = undefined
295
+ currentUrl = undefined
288
296
  deferred = up.destroy($modal, options)
289
297
  deferred.then ->
290
298
  unshifter() while unshifter = unshiftElements.pop()
291
- up.bus.emit('up:modal:closed')
299
+ up.emit('up:modal:closed')
292
300
  deferred
293
301
  else
294
302
  # Although someone prevented the destruction, keep a uniform API for
@@ -354,7 +362,7 @@ up.modal = (($) ->
354
362
  </div>
355
363
 
356
364
  If you want to change the design beyond CSS, you can
357
- configure Up.js to [use a different HTML structure](#up.modal.config).
365
+ configure Up.js to [use a different HTML structure](/up.modal.config).
358
366
 
359
367
 
360
368
  \#\#\#\# Closing behavior
@@ -397,7 +405,7 @@ up.modal = (($) ->
397
405
  up.on('up:fragment:inserted', (event, $fragment) ->
398
406
  if contains($fragment)
399
407
  if newSource = $fragment.attr('up-source')
400
- currentSource = newSource
408
+ currentUrl = newSource
401
409
  else if !up.popup.contains($fragment)
402
410
  autoclose()
403
411
  )
@@ -428,9 +436,11 @@ up.modal = (($) ->
428
436
  follow: follow
429
437
  open: -> up.error('up.modal.open no longer exists. Please use either up.modal.follow or up.modal.visit.')
430
438
  close: close
431
- source: source
439
+ url: -> currentUrl
440
+ coveredUrl: coveredUrl
432
441
  config: config
433
442
  defaults: -> u.error('up.modal.defaults(...) no longer exists. Set values on he up.modal.config property instead.')
434
443
  contains: contains
444
+ source: -> up.error('up.popup.source no longer exists. Please use up.popup.url instead.')
435
445
 
436
446
  )(jQuery)
@@ -82,7 +82,7 @@ up.motion = (($) ->
82
82
  | `move-from-right` | Moves the element leftwards from beyond the right edge of the screen until it reaches its current position |
83
83
  | `none` | An animation that has no visible effect. Sounds useless at first, but can save you a lot of `if` statements. |
84
84
 
85
- You can define additional named animations using [`up.animation`](#up.animation).
85
+ You can define additional named animations using [`up.animation`](/up.animation).
86
86
 
87
87
  \#\#\#\# Animating CSS properties directly
88
88
 
@@ -258,9 +258,9 @@ up.motion = (($) ->
258
258
  | `move-right` | Moves the first element rightwards until it exists the screen at the right edge. Simultaneously moves the second element rightwards from beyond the left edge of the screen until it reaches its current position. |
259
259
  | `none` | A transition that has no visible effect. Sounds useless at first, but can save you a lot of `if` statements. |
260
260
 
261
- You can define additional named transitions using [`up.transition`](#up.transition).
261
+ You can define additional named transitions using [`up.transition`](/up.transition).
262
262
 
263
- You can also compose a transition from two [named animations](#named-animations).
263
+ You can also compose a transition from two [named animations](/named-animations).
264
264
  separated by a slash character (`/`):
265
265
 
266
266
  - `move-to-bottom/fade-in`
@@ -392,7 +392,7 @@ up.motion = (($) ->
392
392
  )
393
393
  )
394
394
 
395
- It is recommended that your transitions use [`up.animate`](#up.animate),
395
+ It is recommended that your transitions use [`up.animate`](/up.animate),
396
396
  passing along the `options` that were passed to you.
397
397
 
398
398
  If you choose to *not* use `up.animate` and roll your own
@@ -404,7 +404,7 @@ up.motion = (($) ->
404
404
  4. The returned promise responds to a `resolve()` function that
405
405
  instantly jumps to the last transition frame and resolves the promise.
406
406
 
407
- Calling [`up.animate`](#up.animate) with an object argument
407
+ Calling [`up.animate`](/up.animate) with an object argument
408
408
  will take care of all these points.
409
409
 
410
410
  @method up.transition
@@ -425,7 +425,7 @@ up.motion = (($) ->
425
425
  )
426
426
 
427
427
  It is recommended that your definitions always end by calling
428
- calling [`up.animate`](#up.animate) with an object argument, passing along
428
+ calling [`up.animate`](/up.animate) with an object argument, passing along
429
429
  the `options` that were passed to you.
430
430
 
431
431
  If you choose to *not* use `up.animate` and roll your own
@@ -437,7 +437,7 @@ up.motion = (($) ->
437
437
  4. The returned promise responds to a `resolve()` function that
438
438
  instantly jumps to the last animation frame and resolves the promise.
439
439
 
440
- Calling [`up.animate`](#up.animate) with an object argument
440
+ Calling [`up.animate`](/up.animate) with an object argument
441
441
  will take care of all these points.
442
442
 
443
443
  @method up.animation
@@ -21,7 +21,7 @@ up.navigation = (($) ->
21
21
  @method up.navigation.config
22
22
  @property
23
23
  @param {Number} [config.currentClasses]
24
- An array of classes to set on [links that point the current location](#up-current).
24
+ An array of classes to set on [links that point the current location](/up-current).
25
25
  ###
26
26
  config = u.config
27
27
  currentClasses: ['up-current']
@@ -81,11 +81,12 @@ up.navigation = (($) ->
81
81
  matchesAny: matchesAny
82
82
 
83
83
  locationChanged = ->
84
-
85
84
  currentUrls = urlSet([
86
85
  normalizeUrl(up.browser.url()),
87
- normalizeUrl(up.modal.source()),
88
- normalizeUrl(up.popup.source())
86
+ normalizeUrl(up.modal.url()),
87
+ normalizeUrl(up.modal.coveredUrl()),
88
+ normalizeUrl(up.popup.url()),
89
+ normalizeUrl(up.popup.coveredUrl())
89
90
  ])
90
91
 
91
92
  klass = currentClass()
@@ -176,7 +177,7 @@ up.navigation = (($) ->
176
177
  A link matches the current location (and is marked as `.up-current`) if it matches either:
177
178
 
178
179
  - the link's `href` attribute
179
- - the link's [`up-href`](/up.link#turn-any-element-into-a-link) attribute
180
+ - the link's [`up-href`](#turn-any-element-into-a-link) attribute
180
181
  - a space-separated list of URLs in the link's `up-alias` attribute
181
182
 
182
183
  \#\#\#\# Matching URL by prefix
@@ -25,7 +25,26 @@ up.popup = (($) ->
25
25
 
26
26
  u = up.util
27
27
 
28
- currentSource = undefined
28
+ ###*
29
+ Returns the source URL for the fragment displayed
30
+ in the current popup, or `undefined` if no popup is open.
31
+
32
+ @method up.popup.url
33
+ @return {String}
34
+ the source URL
35
+ ###
36
+ currentUrl = undefined
37
+
38
+ ###*
39
+ Returns the URL of the page or modal below the popup.
40
+
41
+ @method up.popup.coveredUrl
42
+ @return {String}
43
+ @protected
44
+ ###
45
+ coveredUrl = ->
46
+ $popup = $('.up-popup')
47
+ $popup.attr('up-covered-url')
29
48
 
30
49
  ###*
31
50
  @method up.popup.config
@@ -92,13 +111,13 @@ up.popup = (($) ->
92
111
 
93
112
  rememberHistory = ->
94
113
  $popup = $('.up-popup')
95
- $popup.attr('up-previous-url', up.browser.url())
96
- $popup.attr('up-previous-title', document.title)
114
+ $popup.attr('up-covered-url', up.browser.url())
115
+ $popup.attr('up-covered-title', document.title)
97
116
 
98
117
  discardHistory = ->
99
118
  $popup = $('.up-popup')
100
- $popup.removeAttr('up-previous-url')
101
- $popup.removeAttr('up-previous-title')
119
+ $popup.removeAttr('up-covered-url')
120
+ $popup.removeAttr('up-covered-title')
102
121
 
103
122
  createHiddenPopup = ($link, selector, sticky) ->
104
123
  $popup = u.$createElementFromSelector('.up-popup')
@@ -125,11 +144,11 @@ up.popup = (($) ->
125
144
  @param {String} [options.animation]
126
145
  The animation to use when opening the popup.
127
146
  @param {Number} [options.duration]
128
- The duration of the animation. See [`up.animate`](/up.motion#up.animate).
147
+ The duration of the animation. See [`up.animate`](/up.animate).
129
148
  @param {Number} [options.delay]
130
- The delay before the animation starts. See [`up.animate`](/up.motion#up.animate).
149
+ The delay before the animation starts. See [`up.animate`](/up.animate).
131
150
  @param {String} [options.easing]
132
- The timing function that controls the animation's acceleration. [`up.animate`](/up.motion#up.animate).
151
+ The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
133
152
  @param {Boolean} [options.sticky=false]
134
153
  If set to `true`, the popup remains
135
154
  open even if the page changes in the background.
@@ -155,35 +174,23 @@ up.popup = (($) ->
155
174
  insert: -> updated($link, $popup, position, animation, animateOptions)
156
175
  )
157
176
 
158
- ###*
159
- Returns the source URL for the fragment displayed
160
- in the current popup overlay, or `undefined` if no
161
- popup is open.
162
-
163
- @method up.popup.source
164
- @return {String}
165
- the source URL
166
- ###
167
- source = ->
168
- currentSource
169
-
170
177
  ###*
171
178
  Closes a currently opened popup overlay.
172
179
  Does nothing if no popup is currently open.
173
180
 
174
181
  @method up.popup.close
175
182
  @param {Object} options
176
- See options for [`up.animate`](/up.motion#up.animate).
183
+ See options for [`up.animate`](/up.animate).
177
184
  ###
178
185
  close = (options) ->
179
186
  $popup = $('.up-popup')
180
187
  if $popup.length
181
188
  options = u.options(options,
182
189
  animation: config.closeAnimation,
183
- url: $popup.attr('up-previous-url'),
184
- title: $popup.attr('up-previous-title')
190
+ url: $popup.attr('up-covered-url'),
191
+ title: $popup.attr('up-covered-title')
185
192
  )
186
- currentSource = undefined
193
+ currentUrl = undefined
187
194
  up.destroy($popup, options)
188
195
  else
189
196
  u.resolvedPromise()
@@ -240,7 +247,7 @@ up.popup = (($) ->
240
247
  up.on('up:fragment:inserted', (event, $fragment) ->
241
248
  if contains($fragment)
242
249
  if newSource = $fragment.attr('up-source')
243
- currentSource = newSource
250
+ currentUrl = newSource
244
251
  else
245
252
  autoclose()
246
253
  )
@@ -269,10 +276,12 @@ up.popup = (($) ->
269
276
 
270
277
  attach: attach
271
278
  close: close
272
- source: source
279
+ url: -> currentUrl
280
+ coveredUrl: coveredUrl
273
281
  config: config
274
282
  defaults: -> u.error('up.popup.defaults(...) no longer exists. Set values on he up.popup.config property instead.')
275
283
  contains: contains
276
- open: -> up.warn('up.popup.open no longer exists. Please use up.popup.attach instead.')
284
+ open: -> up.error('up.popup.open no longer exists. Please use up.popup.attach instead.')
285
+ source: -> up.error('up.popup.source no longer exists. Please use up.popup.url instead.')
277
286
 
278
287
  )(jQuery)
@@ -3,8 +3,8 @@ Caching and preloading
3
3
  ======================
4
4
 
5
5
  All HTTP requests go through the Up.js proxy.
6
- It caches a [limited](/up.proxy#up.proxy.config) number of server responses
7
- for a [limited](/up.proxy#up.proxy.config) amount of time,
6
+ It caches a [limited](/up.proxy.config) number of server responses
7
+ for a [limited](/up.proxy.config) amount of time,
8
8
  making requests to these URLs return insantly.
9
9
 
10
10
  The cache is cleared whenever the user makes a non-`GET` request
@@ -63,7 +63,7 @@ up.proxy = (($) ->
63
63
  @method up.proxy.config
64
64
  @property
65
65
  @param {Number} [config.preloadDelay=75]
66
- The number of milliseconds to wait before [`[up-preload]`](#up-preload)
66
+ The number of milliseconds to wait before [`[up-preload]`](/up-preload)
67
67
  starts preloading.
68
68
  @param {Number} [config.cacheSize=70]
69
69
  The maximum number of responses to cache.
@@ -244,7 +244,7 @@ up.proxy = (($) ->
244
244
  if wasIdle
245
245
  emission = ->
246
246
  if busy() # a fast response might have beaten the delay
247
- up.bus.emit('up:proxy:busy')
247
+ up.emit('up:proxy:busy')
248
248
  busyEventEmitted = true
249
249
  if config.busyDelay > 0
250
250
  busyDelayTimer = setTimeout(emission, config.busyDelay)
@@ -254,14 +254,14 @@ up.proxy = (($) ->
254
254
  loadEnded = ->
255
255
  pendingCount -= 1
256
256
  if idle() && busyEventEmitted
257
- up.bus.emit('up:proxy:idle')
257
+ up.emit('up:proxy:idle')
258
258
  busyEventEmitted = false
259
259
 
260
260
  load = (request) ->
261
261
  u.debug('Loading URL %o', request.url)
262
- up.bus.emit('up:proxy:load', request)
262
+ up.emit('up:proxy:load', request)
263
263
  promise = u.ajax(request)
264
- promise.always -> up.bus.emit('up:proxy:receive', request)
264
+ promise.always -> up.emit('up:proxy:receive', request)
265
265
  promise
266
266
 
267
267
  isIdempotent = (request) ->
@@ -78,7 +78,7 @@ up.tooltip = (($) ->
78
78
 
79
79
  @method up.tooltip.close
80
80
  @param {Object} options
81
- See options for [`up.animate`](/up.motion#up.animate).
81
+ See options for [`up.animate`](/up.animate).
82
82
  ###
83
83
  close = (options) ->
84
84
  $tooltip = $('.up-tooltip')
@@ -540,7 +540,7 @@ up.util = (($) ->
540
540
 
541
541
  Does nothing if the given element is not currently animating.
542
542
 
543
- Also see [`up.motion.finish`](/up.motion#up.motion.finish).
543
+ Also see [`up.motion.finish`](/up.motion.finish).
544
544
 
545
545
  @method up.util.finishCssAnimate
546
546
  @protected
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.12.1'
3
+ VERSION = '0.12.2'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- upjs-rails (0.11.1)
4
+ upjs-rails (0.12.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -2,7 +2,7 @@ describe 'up.bus', ->
2
2
 
3
3
  describe 'Javascript functions', ->
4
4
 
5
- describe 'up.bus.emit', ->
5
+ describe 'up.emit', ->
6
6
 
7
7
  it 'triggers an event on the document', ->
8
8
  emittedEvent = undefined
@@ -15,7 +15,7 @@ describe 'up.bus', ->
15
15
  expect(emittedEvent).toBeUndefined()
16
16
  expect(emitted$Target).toBeUndefined()
17
17
 
18
- up.bus.emit('foo')
18
+ up.emit('foo')
19
19
 
20
20
  expect(emittedEvent).toBeDefined()
21
21
  expect(emittedEvent.preventDefault).toBeDefined()
@@ -27,7 +27,7 @@ describe 'up.bus', ->
27
27
  up.on 'foo', (event) ->
28
28
  emittedEvent = event
29
29
 
30
- up.bus.emit('foo', { customField: 'custom-value' })
30
+ up.emit('foo', { customField: 'custom-value' })
31
31
 
32
32
  expect(emittedEvent.customField).toEqual('custom-value')
33
33
 
@@ -41,7 +41,7 @@ describe 'up.bus', ->
41
41
  emittedEvent = event
42
42
  emitted$Target = $target
43
43
 
44
- up.bus.emit('foo', $element: $element)
44
+ up.emit('foo', $element: $element)
45
45
 
46
46
  expect(emittedEvent).toBeDefined()
47
47
  expect(emitted$Target).toEqual($element)
@@ -81,6 +81,26 @@ describe 'up.modal', ->
81
81
  expect(parseInt($anchoredElement.css('right'))).toBeAround(30 , 10)
82
82
  done()
83
83
 
84
+
85
+ describe 'up.modal.coveredUrl', ->
86
+
87
+ it 'returns the URL behind the modal overlay', (done) ->
88
+ up.history.replace('/foo')
89
+ expect(up.modal.coveredUrl()).toBeUndefined()
90
+ up.modal.visit('/bar', target: '.container')
91
+ @lastRequest().respondWith
92
+ status: 200
93
+ contentType: 'text/html'
94
+ responseText:
95
+ """
96
+ <div class="container">text</div>
97
+ """
98
+ expect(up.modal.coveredUrl()).toEndWith('/foo')
99
+ up.modal.close().then ->
100
+ expect(up.modal.coveredUrl()).toBeUndefined()
101
+ done()
102
+
103
+
84
104
  describe 'up.modal.close', ->
85
105
 
86
106
  it 'should have tests'
@@ -68,9 +68,47 @@ describe 'up.navigation', ->
68
68
  responseText: '<div class="main">new-text</div>'
69
69
  expect($link).toHaveClass('up-current')
70
70
 
71
- it 'marks a link as .up-current if it links to the URL currently shown in the modal'
71
+ it 'marks a link as .up-current if it links to an URL currently shown either within or below the modal', (done) ->
72
+ up.history.replace('/foo')
73
+ $backgroundLink = affix('a[href="/foo"]')
74
+ $modalLink = affix('a[href="/bar"][up-modal=".main"]')
75
+ $unrelatedLink = affix('a[href="/baz]')
72
76
 
73
- it 'marks a link as .up-current if it links to the URL currently shown in the popup'
77
+ $modalLink.click()
78
+ @lastRequest().respondWith
79
+ status: 200
80
+ contentType: 'text/html'
81
+ responseText: '<div class="main">new-text</div>'
82
+ expect($backgroundLink).toHaveClass('up-current')
83
+ expect($modalLink).toHaveClass('up-current')
84
+ expect($unrelatedLink).not.toHaveClass('up-current')
85
+
86
+ up.modal.close().then ->
87
+ expect($backgroundLink).toHaveClass('up-current')
88
+ expect($modalLink).not.toHaveClass('up-current')
89
+ expect($unrelatedLink).not.toHaveClass('up-current')
90
+ done()
91
+
92
+ it 'marks a link as .up-current if it links to the URL currently either within or below the popup', (done) ->
93
+ up.history.replace('/foo')
94
+ $backgroundLink = affix('a[href="/foo"]')
95
+ $popupLink = affix('a[href="/bar"][up-popup=".main"]')
96
+ $unrelatedLink = affix('a[href="/baz]')
97
+
98
+ $popupLink.click()
99
+ @lastRequest().respondWith
100
+ status: 200
101
+ contentType: 'text/html'
102
+ responseText: '<div class="main">new-text</div>'
103
+ expect($backgroundLink).toHaveClass('up-current')
104
+ expect($popupLink).toHaveClass('up-current')
105
+ expect($unrelatedLink).not.toHaveClass('up-current')
106
+
107
+ up.popup.close().then ->
108
+ expect($backgroundLink).toHaveClass('up-current')
109
+ expect($popupLink).not.toHaveClass('up-current')
110
+ expect($unrelatedLink).not.toHaveClass('up-current')
111
+ done()
74
112
 
75
113
  it 'changes .up-current marks as the URL changes'
76
114
 
@@ -110,4 +148,4 @@ describe 'up.navigation', ->
110
148
  contentType: 'text/html'
111
149
  responseText: '<div class="main">new-text</div>'
112
150
  expect($area).toHaveClass('up-current')
113
-
151
+
@@ -6,6 +6,26 @@ describe 'up.popup', ->
6
6
 
7
7
  it 'should have tests'
8
8
 
9
+ describe 'up.popup.coveredUrl', ->
10
+
11
+ it 'returns the URL behind the popup', (done) ->
12
+ up.history.replace('/foo')
13
+ expect(up.popup.coveredUrl()).toBeUndefined()
14
+
15
+ $popupLink = affix('a[href="/bar"][up-popup=".container"]')
16
+ $popupLink.click()
17
+ @lastRequest().respondWith
18
+ status: 200
19
+ contentType: 'text/html'
20
+ responseText:
21
+ """
22
+ <div class="container">text</div>
23
+ """
24
+ expect(up.popup.coveredUrl()).toEndWith('/foo')
25
+ up.popup.close().then ->
26
+ expect(up.popup.coveredUrl()).toBeUndefined()
27
+ done()
28
+
9
29
  describe 'up.popup.close', ->
10
30
 
11
31
  it 'should have tests'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails