upjs-rails 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +6 -3
- data/dist/up-bootstrap.css +5 -0
- data/dist/up-bootstrap.js +14 -0
- data/dist/up-bootstrap.min.css +1 -0
- data/dist/up-bootstrap.min.js +1 -0
- data/dist/up.css +22 -36
- data/dist/up.js +300 -137
- data/dist/up.min.css +1 -1
- data/dist/up.min.js +2 -2
- data/lib/assets/javascripts/up/browser.js.coffee +9 -35
- data/lib/assets/javascripts/up/bus.js.coffee +10 -10
- data/lib/assets/javascripts/up/modal.js.coffee +98 -40
- data/lib/assets/javascripts/up/motion.js.coffee +13 -13
- data/lib/assets/javascripts/up/navigation.js.coffee +28 -3
- data/lib/assets/javascripts/up/popup.js.coffee +14 -12
- data/lib/assets/javascripts/up/proxy.js.coffee +21 -24
- data/lib/assets/javascripts/up/util.js.coffee +72 -9
- data/lib/assets/javascripts/up/viewport.js.coffee +10 -8
- data/lib/assets/javascripts/up-bootstrap/modal-ext.js.coffee +16 -0
- data/lib/assets/javascripts/up-bootstrap.js.coffee +1 -0
- data/lib/assets/stylesheets/up/modal.css.sass +37 -24
- data/lib/assets/stylesheets/up/popup.css.sass +1 -6
- data/lib/assets/stylesheets/up-bootstrap/modal-ext.css.sass +9 -0
- data/lib/assets/stylesheets/up-bootstrap.css.sass +1 -0
- data/lib/assets/stylesheets/up.css.sass +3 -0
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +26 -0
- data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +6 -0
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +24 -0
- metadata +11 -3
- data/lib/assets/stylesheets/up.css +0 -3
@@ -15,8 +15,26 @@ up.navigation = (->
|
|
15
15
|
|
16
16
|
u = up.util
|
17
17
|
|
18
|
+
###*
|
19
|
+
Sets default options for this module.
|
20
|
+
|
21
|
+
@method up.navigation.defaults
|
22
|
+
@param {Number} [options.currentClass]
|
23
|
+
The class to set on [links that point the current location](#up-current).
|
24
|
+
###
|
25
|
+
config = u.config
|
26
|
+
currentClass: 'up-current'
|
27
|
+
|
28
|
+
reset = ->
|
29
|
+
config.reset()
|
30
|
+
|
31
|
+
currentClass = ->
|
32
|
+
klass = config.currentClass
|
33
|
+
unless u.contains(klass, 'up-current')
|
34
|
+
klass += ' up-current'
|
35
|
+
klass
|
36
|
+
|
18
37
|
CLASS_ACTIVE = 'up-active'
|
19
|
-
CLASS_CURRENT = 'up-current'
|
20
38
|
SELECTORS_SECTION = ['a', '[up-href]', '[up-alias]']
|
21
39
|
SELECTOR_SECTION = SELECTORS_SECTION.join(', ')
|
22
40
|
SELECTOR_SECTION_INSTANT = ("#{selector}[up-instant]" for selector in SELECTORS_SECTION).join(', ')
|
@@ -67,6 +85,8 @@ up.navigation = (->
|
|
67
85
|
normalizeUrl(up.popup.source())
|
68
86
|
])
|
69
87
|
|
88
|
+
klass = currentClass()
|
89
|
+
|
70
90
|
u.each $(SELECTOR_SECTION), (section) ->
|
71
91
|
$section = $(section)
|
72
92
|
# if $section is marked up with up-follow,
|
@@ -74,9 +94,9 @@ up.navigation = (->
|
|
74
94
|
urls = sectionUrls($section)
|
75
95
|
|
76
96
|
if currentUrls.matchesAny(urls)
|
77
|
-
$section.addClass(
|
97
|
+
$section.addClass(klass)
|
78
98
|
else
|
79
|
-
$section.removeClass(
|
99
|
+
$section.removeClass(klass)
|
80
100
|
|
81
101
|
###*
|
82
102
|
Links that are currently loading are assigned the `up-active`
|
@@ -186,4 +206,9 @@ up.navigation = (->
|
|
186
206
|
if $fragment.is('.up-modal, .up-popup')
|
187
207
|
locationChanged()
|
188
208
|
|
209
|
+
# The framework is reset between tests
|
210
|
+
up.bus.on 'framework:reset', reset
|
211
|
+
|
212
|
+
defaults: config.update
|
213
|
+
|
189
214
|
)()
|
@@ -27,19 +27,20 @@ up.popup = (->
|
|
27
27
|
|
28
28
|
currentSource = undefined
|
29
29
|
|
30
|
-
config =
|
31
|
-
openAnimation: 'fade-in'
|
32
|
-
closeAnimation: 'fade-out'
|
33
|
-
position: 'bottom-right'
|
34
|
-
|
35
30
|
###*
|
36
31
|
@method up.popup.defaults
|
37
32
|
@param {String} options.animation
|
38
33
|
@param {String} options.position
|
39
34
|
###
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
config = u.config
|
36
|
+
openAnimation: 'fade-in'
|
37
|
+
closeAnimation: 'fade-out'
|
38
|
+
position: 'bottom-right'
|
39
|
+
|
40
|
+
reset = ->
|
41
|
+
close()
|
42
|
+
config.reset()
|
43
|
+
|
43
44
|
setPosition = ($link, $popup, position) ->
|
44
45
|
linkBox = u.measure($link, full: true)
|
45
46
|
css = switch position
|
@@ -182,6 +183,8 @@ up.popup = (->
|
|
182
183
|
)
|
183
184
|
currentSource = undefined
|
184
185
|
up.destroy($popup, options)
|
186
|
+
else
|
187
|
+
u.resolvedPromise()
|
185
188
|
|
186
189
|
autoclose = ->
|
187
190
|
unless $('.up-popup').is('[up-sticky]')
|
@@ -255,14 +258,13 @@ up.popup = (->
|
|
255
258
|
close()
|
256
259
|
)
|
257
260
|
|
258
|
-
# The framework is reset between tests
|
259
|
-
|
260
|
-
up.bus.on 'framework:reset', close
|
261
|
+
# The framework is reset between tests
|
262
|
+
up.bus.on 'framework:reset', reset
|
261
263
|
|
262
264
|
open: open
|
263
265
|
close: close
|
264
266
|
source: source
|
265
|
-
defaults:
|
267
|
+
defaults: config.update
|
266
268
|
contains: contains
|
267
269
|
|
268
270
|
)()
|
@@ -58,9 +58,24 @@ up.proxy = (->
|
|
58
58
|
preloadDelayTimer = undefined
|
59
59
|
busyDelayTimer = undefined
|
60
60
|
pendingCount = undefined
|
61
|
-
config = undefined
|
62
61
|
busyEventEmitted = undefined
|
63
|
-
|
62
|
+
|
63
|
+
###*
|
64
|
+
@method up.proxy.defaults
|
65
|
+
@param {Number} [options.preloadDelay=75]
|
66
|
+
The number of milliseconds to wait before [`[up-preload]`](#up-preload)
|
67
|
+
starts preloading.
|
68
|
+
@param {Number} [options.cacheSize=70]
|
69
|
+
The maximum number of responses to cache.
|
70
|
+
If the size is exceeded, the oldest items will be dropped from the cache.
|
71
|
+
@param {Number} [options.cacheExpiry=300000]
|
72
|
+
The number of milliseconds until a cache entry expires.
|
73
|
+
Defaults to 5 minutes.
|
74
|
+
@param {Number} [options.busyDelay=300]
|
75
|
+
How long the proxy waits until emitting the `proxy:busy` [event](/up.bus).
|
76
|
+
Use this to prevent flickering of spinners.
|
77
|
+
###
|
78
|
+
config = u.config
|
64
79
|
busyDelay: 300
|
65
80
|
preloadDelay: 75
|
66
81
|
cacheSize: 70
|
@@ -80,29 +95,11 @@ up.proxy = (->
|
|
80
95
|
cancelPreloadDelay()
|
81
96
|
cancelBusyDelay()
|
82
97
|
pendingCount = 0
|
83
|
-
config
|
98
|
+
config.reset()
|
84
99
|
busyEventEmitted = false
|
85
100
|
|
86
101
|
reset()
|
87
102
|
|
88
|
-
###*
|
89
|
-
@method up.proxy.defaults
|
90
|
-
@param {Number} [options.preloadDelay=75]
|
91
|
-
The number of milliseconds to wait before [`[up-preload]`](#up-preload)
|
92
|
-
starts preloading.
|
93
|
-
@param {Number} [options.cacheSize=70]
|
94
|
-
The maximum number of responses to cache.
|
95
|
-
If the size is exceeded, the oldest items will be dropped from the cache.
|
96
|
-
@param {Number} [options.cacheExpiry=300000]
|
97
|
-
The number of milliseconds until a cache entry expires.
|
98
|
-
Defaults to 5 minutes.
|
99
|
-
@param {Number} [options.busyDelay=300]
|
100
|
-
How long the proxy waits until emitting the `proxy:busy` [event](/up.bus).
|
101
|
-
Use this to prevent flickering of spinners.
|
102
|
-
###
|
103
|
-
defaults = (options) ->
|
104
|
-
u.extend(config, options)
|
105
|
-
|
106
103
|
cacheKey = (request) ->
|
107
104
|
normalizeRequest(request)
|
108
105
|
[ request.url,
|
@@ -336,8 +333,6 @@ up.proxy = (->
|
|
336
333
|
u.debug("Won't preload %o due to unsafe method %o", $link, method)
|
337
334
|
u.resolvedPromise()
|
338
335
|
|
339
|
-
up.bus.on 'framework:reset', reset
|
340
|
-
|
341
336
|
###*
|
342
337
|
Links with an `up-preload` attribute will silently fetch their target
|
343
338
|
when the user hovers over the click area, or when the user puts her
|
@@ -359,6 +354,8 @@ up.proxy = (->
|
|
359
354
|
unless up.link.childClicked(event, $element)
|
360
355
|
checkPreload($element)
|
361
356
|
|
357
|
+
up.bus.on 'framework:reset', reset
|
358
|
+
|
362
359
|
preload: preload
|
363
360
|
ajax: ajax
|
364
361
|
get: get
|
@@ -368,6 +365,6 @@ up.proxy = (->
|
|
368
365
|
remove: remove
|
369
366
|
idle: idle
|
370
367
|
busy: busy
|
371
|
-
defaults:
|
368
|
+
defaults: config.update
|
372
369
|
|
373
370
|
)()
|
@@ -12,6 +12,16 @@ If you use them in your own code, you will get hurt.
|
|
12
12
|
###
|
13
13
|
up.util = (->
|
14
14
|
|
15
|
+
memoize = (func) ->
|
16
|
+
cache = undefined
|
17
|
+
cached = false
|
18
|
+
(args...) ->
|
19
|
+
if cached
|
20
|
+
cache
|
21
|
+
else
|
22
|
+
cached = true
|
23
|
+
cache = func(args...)
|
24
|
+
|
15
25
|
get = (url, options) ->
|
16
26
|
options = options or {}
|
17
27
|
options.url = url
|
@@ -337,7 +347,15 @@ up.util = (->
|
|
337
347
|
|
338
348
|
compact = (array) ->
|
339
349
|
select array, isGiven
|
340
|
-
|
350
|
+
|
351
|
+
uniq = (array) ->
|
352
|
+
seen = {}
|
353
|
+
select array, (element) ->
|
354
|
+
if seen.hasOwnProperty(element)
|
355
|
+
false
|
356
|
+
else
|
357
|
+
seen[element] = true
|
358
|
+
|
341
359
|
select = (array, tester) ->
|
342
360
|
matches = []
|
343
361
|
each array, (element) ->
|
@@ -359,19 +377,47 @@ up.util = (->
|
|
359
377
|
element = document.documentElement
|
360
378
|
width: element.clientWidth
|
361
379
|
height: element.clientHeight
|
362
|
-
|
380
|
+
|
381
|
+
# This is how Bootstrap does it also:
|
382
|
+
# https://github.com/twbs/bootstrap/blob/c591227602996c542b9fd0cb65cff3cc9519bdd5/dist/js/bootstrap.js#L1187
|
383
|
+
scrollbarWidth = memoize ->
|
384
|
+
$outer = $('<div>').css
|
385
|
+
position: 'absolute'
|
386
|
+
top: '0'
|
387
|
+
left: '0'
|
388
|
+
width: '50px'
|
389
|
+
height: '50px'
|
390
|
+
overflowY: 'scroll'
|
391
|
+
$outer.appendTo(document.body)
|
392
|
+
outer = $outer.get(0)
|
393
|
+
width = outer.offsetWidth - outer.clientWidth
|
394
|
+
$outer.remove()
|
395
|
+
width
|
396
|
+
|
397
|
+
|
398
|
+
###*
|
399
|
+
Modifies the given function so it only runs once.
|
400
|
+
Subsequent calls will return the previous return value.
|
401
|
+
|
402
|
+
@method up.util.once
|
403
|
+
@private
|
404
|
+
###
|
405
|
+
once = (fun) ->
|
406
|
+
result = undefined
|
407
|
+
->
|
408
|
+
result = fun() if fun?
|
409
|
+
fun = undefined
|
410
|
+
result
|
411
|
+
|
363
412
|
temporaryCss = ($element, css, block) ->
|
364
413
|
oldCss = $element.css(keys(css))
|
365
|
-
# debug("Stored old CSS", oldCss)
|
366
414
|
$element.css(css)
|
367
|
-
memo = ->
|
368
|
-
# debug("Restoring CSS %o on %o", oldCss, $element)
|
369
|
-
$element.css(oldCss)
|
415
|
+
memo = -> $element.css(oldCss)
|
370
416
|
if block
|
371
417
|
block()
|
372
418
|
memo()
|
373
419
|
else
|
374
|
-
memo
|
420
|
+
once(memo)
|
375
421
|
|
376
422
|
forceCompositing = ($element) ->
|
377
423
|
oldTransforms = $element.css(['transform', '-webkit-transform'])
|
@@ -512,8 +558,8 @@ up.util = (->
|
|
512
558
|
escapePressed = (event) ->
|
513
559
|
event.keyCode == 27
|
514
560
|
|
515
|
-
contains = (
|
516
|
-
|
561
|
+
contains = (stringOrArray, element) ->
|
562
|
+
stringOrArray.indexOf(element) >= 0
|
517
563
|
|
518
564
|
castsToTrue = (object) ->
|
519
565
|
String(object) == "true"
|
@@ -574,6 +620,19 @@ up.util = (->
|
|
574
620
|
array.splice(index, 1)
|
575
621
|
element
|
576
622
|
|
623
|
+
config = (factoryOptions = {}) ->
|
624
|
+
hash =
|
625
|
+
reset: ->
|
626
|
+
ownKeys = Object.getOwnPropertyNames(hash)
|
627
|
+
for key in ownKeys
|
628
|
+
delete hash[key] unless contains(apiKeys, key)
|
629
|
+
hash.update copy(factoryOptions)
|
630
|
+
update: (options) ->
|
631
|
+
extend(hash, options)
|
632
|
+
apiKeys = Object.getOwnPropertyNames(hash)
|
633
|
+
hash.reset()
|
634
|
+
hash
|
635
|
+
|
577
636
|
presentAttr: presentAttr
|
578
637
|
createElement: createElement
|
579
638
|
normalizeUrl: normalizeUrl
|
@@ -596,6 +655,7 @@ up.util = (->
|
|
596
655
|
detect: detect
|
597
656
|
select: select
|
598
657
|
compact: compact
|
658
|
+
uniq: uniq
|
599
659
|
last: last
|
600
660
|
isNull: isNull
|
601
661
|
isDefined: isDefined
|
@@ -644,5 +704,8 @@ up.util = (->
|
|
644
704
|
resolvableWhen: resolvableWhen
|
645
705
|
setMissingAttrs: setMissingAttrs
|
646
706
|
remove: remove
|
707
|
+
memoize: memoize
|
708
|
+
scrollbarWidth: scrollbarWidth
|
709
|
+
config: config
|
647
710
|
|
648
711
|
)()
|
@@ -12,11 +12,6 @@ up.viewport = (->
|
|
12
12
|
|
13
13
|
u = up.util
|
14
14
|
|
15
|
-
config =
|
16
|
-
duration: 0
|
17
|
-
view: 'body'
|
18
|
-
easing: 'swing'
|
19
|
-
|
20
15
|
###*
|
21
16
|
@method up.viewport.defaults
|
22
17
|
@param {Number} [options.duration]
|
@@ -24,8 +19,13 @@ up.viewport = (->
|
|
24
19
|
@param {Number} [options.padding]
|
25
20
|
@param {String|Element|jQuery} [options.view]
|
26
21
|
###
|
27
|
-
|
28
|
-
|
22
|
+
config = u.config
|
23
|
+
duration: 0
|
24
|
+
view: 'body'
|
25
|
+
easing: 'swing'
|
26
|
+
|
27
|
+
reset = ->
|
28
|
+
config.reset()
|
29
29
|
|
30
30
|
SCROLL_PROMISE_KEY = 'up-scroll-promise'
|
31
31
|
|
@@ -114,10 +114,12 @@ up.viewport = (->
|
|
114
114
|
else
|
115
115
|
u.resolvedDeferred()
|
116
116
|
|
117
|
+
up.bus.on 'framework:reset', reset
|
118
|
+
|
117
119
|
reveal: reveal
|
118
120
|
scroll: scroll
|
119
121
|
finishScrolling: finishScrolling
|
120
|
-
defaults:
|
122
|
+
defaults: config.update
|
121
123
|
|
122
124
|
)()
|
123
125
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Use BS `modal-dialog` and `modal-content` classes.
|
2
|
+
# Also don't show a close button by default, since BS
|
3
|
+
# expects user to add this manually within the content block.
|
4
|
+
up.modal.defaults
|
5
|
+
template: """
|
6
|
+
<div class="up-modal">
|
7
|
+
<div class="up-modal-dialog modal-dialog">
|
8
|
+
<div class="up-modal-content modal-content"></div>
|
9
|
+
</div>
|
10
|
+
</div>
|
11
|
+
"""
|
12
|
+
|
13
|
+
# BS use the class `active` to highlight the current section
|
14
|
+
# of a navigation bar.
|
15
|
+
up.navigation.defaults
|
16
|
+
currentClass: 'active'
|
@@ -0,0 +1 @@
|
|
1
|
+
#= require_tree ./up-bootstrap
|
@@ -1,8 +1,11 @@
|
|
1
1
|
$stratum: 10000
|
2
|
-
|
3
|
-
|
4
|
-
$close
|
2
|
+
$substratum-dialog: 1000
|
3
|
+
$substratum-content: 2000
|
4
|
+
$substratum-close: 3000
|
5
|
+
|
6
|
+
$close-height: 36px
|
5
7
|
$close-width: 36px
|
8
|
+
$close-font-size: 34px
|
6
9
|
|
7
10
|
=transform($transform)
|
8
11
|
transform: $transform
|
@@ -17,22 +20,42 @@ $close-width: 36px
|
|
17
20
|
right: 0
|
18
21
|
z-index: $stratum
|
19
22
|
background-color: rgba(90, 90, 90, 0.4)
|
23
|
+
overflow-x: hidden
|
24
|
+
overflow-y: scroll
|
25
|
+
// We prefer centering the dialog as an `inline-block`
|
26
|
+
// to giving it a horizontal margin of `auto`. This way
|
27
|
+
// the width of `.up-modal-dialog` is controlled by the
|
28
|
+
// contents of `.up-modal-content`.
|
29
|
+
text-align: center
|
20
30
|
|
21
31
|
.up-modal-dialog
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
max-width: 100%
|
27
|
-
max-height: 100%
|
28
|
-
background-color: #fff
|
29
|
-
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.3)
|
32
|
+
// The z-index lives in the stacking context of .up-modal
|
33
|
+
z-index: $substratum-dialog
|
34
|
+
// Make sure .up-modal-close is relative to the dialog
|
35
|
+
position: relative
|
30
36
|
// In case someone sets padding on the dialog box,
|
31
37
|
// the width and height attributes set by up.modal
|
32
38
|
// should be honored exactly.
|
33
|
-
box-sizing: border-box
|
39
|
+
box-sizing: border-box
|
40
|
+
margin: 30px 10px
|
41
|
+
|
42
|
+
// In case someone sets a huge width on the dialog.
|
43
|
+
max-width: 100%
|
44
|
+
|
45
|
+
// Make it grow with the width of .up-modal-content
|
46
|
+
display: inline-block
|
47
|
+
text-align: left
|
48
|
+
|
49
|
+
.up-modal-content
|
50
|
+
// The z-index lives in the stacking context of .up-modal
|
51
|
+
z-index: $substratum-content
|
52
|
+
padding: 20px
|
53
|
+
background-color: #fff
|
54
|
+
box-shadow: 0 0 10px 1px rgba(0, 0, 0, 0.3)
|
34
55
|
|
35
56
|
.up-modal-close
|
57
|
+
// The z-index lives in the stacking context of .up-modal
|
58
|
+
z-index: $substratum-close
|
36
59
|
position: absolute
|
37
60
|
right: 0
|
38
61
|
top: 0
|
@@ -40,17 +63,7 @@ $close-width: 36px
|
|
40
63
|
text-align: center
|
41
64
|
line-height: $close-height
|
42
65
|
height: $close-height
|
43
|
-
|
44
|
-
color: #
|
45
|
-
font-weight: bold
|
46
|
-
text-transform: uppercase
|
66
|
+
font-size: $close-font-size
|
67
|
+
color: #666
|
47
68
|
cursor: pointer
|
48
|
-
+transform(translateY(-100%))
|
49
69
|
|
50
|
-
.up-modal-content
|
51
|
-
overflow-x: hidden
|
52
|
-
overflow-y: auto
|
53
|
-
width: 100%
|
54
|
-
height: 100%
|
55
|
-
padding: 20px
|
56
|
-
box-sizing: border-box
|
@@ -1,5 +1,4 @@
|
|
1
|
-
$stratum:
|
2
|
-
$stratum-within-modal: 15000
|
1
|
+
$stratum: 20000
|
3
2
|
|
4
3
|
.up-popup
|
5
4
|
z-index: $stratum
|
@@ -7,7 +6,3 @@ $stratum-within-modal: 15000
|
|
7
6
|
background-color: #fff
|
8
7
|
padding: 15px
|
9
8
|
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3)
|
10
|
-
|
11
|
-
.up-modal .up-popup
|
12
|
-
z-index: $stratum-within-modal
|
13
|
-
|
@@ -0,0 +1,9 @@
|
|
1
|
+
.up-modal-dialog
|
2
|
+
// Up.js: Is an inline-block, centered with text-align
|
3
|
+
// BS: Is a block, centered with a horizontal margin of "auto"
|
4
|
+
display: block
|
5
|
+
|
6
|
+
.up-modal-content
|
7
|
+
// Up.js: Gives some default padding
|
8
|
+
// BS: Expects content to set the padding
|
9
|
+
padding: 0
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree ./up-bootstrap
|
data/lib/upjs/rails/version.rb
CHANGED
data/spec_app/Gemfile.lock
CHANGED
@@ -31,6 +31,32 @@ describe 'up.modal', ->
|
|
31
31
|
expect($('.up-modal-dialog .after')).not.toExist()
|
32
32
|
done()
|
33
33
|
|
34
|
+
it "brings its own scrollbar, padding the body on the right in order to prevent jumping", (done) ->
|
35
|
+
promise = up.modal.open(url: '/foo', target: '.container')
|
36
|
+
|
37
|
+
jasmine.Ajax.requests.mostRecent().respondWith
|
38
|
+
status: 200
|
39
|
+
contentType: 'text/html'
|
40
|
+
responseText:
|
41
|
+
"""
|
42
|
+
<div class="container">text</div>
|
43
|
+
"""
|
44
|
+
|
45
|
+
promise.then ->
|
46
|
+
|
47
|
+
$modal = $('.up-modal')
|
48
|
+
$body = $('body')
|
49
|
+
expect($modal).toExist()
|
50
|
+
expect($modal.css('overflow-y')).toEqual('scroll')
|
51
|
+
expect($body.css('overflow-y')).toEqual('hidden')
|
52
|
+
expect(parseInt($body.css('padding-right'))).toBeAround(15, 10)
|
53
|
+
|
54
|
+
up.modal.close().then ->
|
55
|
+
expect($body.css('overflow-y')).toEqual('scroll')
|
56
|
+
expect(parseInt($body.css('padding-right'))).toBe(0)
|
57
|
+
|
58
|
+
done()
|
59
|
+
|
34
60
|
describe 'up.modal.close', ->
|
35
61
|
|
36
62
|
it 'should have tests'
|
@@ -34,6 +34,12 @@ describe 'up.navigation', ->
|
|
34
34
|
expect($currentLink).toHaveClass('up-current')
|
35
35
|
expect($otherLink).not.toHaveClass('up-current')
|
36
36
|
|
37
|
+
it 'allows to configure a custom "current" class, but always also sets .up-current', ->
|
38
|
+
up.navigation.defaults(currentClass: 'highlight')
|
39
|
+
spyOn(up.browser, 'url').and.returnValue('/foo')
|
40
|
+
$currentLink = up.ready(affix('a[href="/foo"]'))
|
41
|
+
expect($currentLink).toHaveClass('highlight up-current')
|
42
|
+
|
37
43
|
if up.browser.canPushState()
|
38
44
|
|
39
45
|
it 'marks a link as .up-current if it links to the current URL, but is missing a trailing slash', ->
|
@@ -56,3 +56,27 @@ describe 'up.util', ->
|
|
56
56
|
array = ['foo', 'bar', 'baz']
|
57
57
|
tester = (element) -> element[0] == 'z'
|
58
58
|
expect(up.util.detect(array, tester)).toBeNull()
|
59
|
+
|
60
|
+
describe '.config', ->
|
61
|
+
|
62
|
+
it 'creates an object with the given attributes', ->
|
63
|
+
object = up.util.config(a: 1, b: 2)
|
64
|
+
expect(object.a).toBe(1)
|
65
|
+
expect(object.b).toBe(2)
|
66
|
+
|
67
|
+
it 'provies an #update method that merges the given options into the object', ->
|
68
|
+
object = up.util.config(a: 1)
|
69
|
+
object.update(b: 2, c: 3)
|
70
|
+
expect(object.b).toBe(2)
|
71
|
+
expect(object.c).toBe(3)
|
72
|
+
|
73
|
+
it 'provides a #reset method that resets the object to its original state', ->
|
74
|
+
object = up.util.config(a: 1)
|
75
|
+
expect(object.b).toBeUndefined()
|
76
|
+
object.b = 2
|
77
|
+
expect(object.b).toBe(2)
|
78
|
+
object.reset()
|
79
|
+
expect(object.b).toBeUndefined()
|
80
|
+
# Make sure that resetting doesn't remove #reset or #update
|
81
|
+
expect(object.reset).toBeDefined()
|
82
|
+
expect(object.update).toBeDefined()
|
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.8.
|
4
|
+
version: 0.8.1
|
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-08-
|
11
|
+
date: 2015-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -76,10 +76,16 @@ files:
|
|
76
76
|
- design/draft.html.erb
|
77
77
|
- design/draft.rb
|
78
78
|
- design/rename.txt
|
79
|
+
- dist/up-bootstrap.css
|
80
|
+
- dist/up-bootstrap.js
|
81
|
+
- dist/up-bootstrap.min.css
|
82
|
+
- dist/up-bootstrap.min.js
|
79
83
|
- dist/up.css
|
80
84
|
- dist/up.js
|
81
85
|
- dist/up.min.css
|
82
86
|
- dist/up.min.js
|
87
|
+
- lib/assets/javascripts/up-bootstrap.js.coffee
|
88
|
+
- lib/assets/javascripts/up-bootstrap/modal-ext.js.coffee
|
83
89
|
- lib/assets/javascripts/up.js.coffee
|
84
90
|
- lib/assets/javascripts/up/browser.js.coffee
|
85
91
|
- lib/assets/javascripts/up/bus.js.coffee
|
@@ -98,7 +104,9 @@ files:
|
|
98
104
|
- lib/assets/javascripts/up/tooltip.js.coffee
|
99
105
|
- lib/assets/javascripts/up/util.js.coffee
|
100
106
|
- lib/assets/javascripts/up/viewport.js.coffee
|
101
|
-
- lib/assets/stylesheets/up.css
|
107
|
+
- lib/assets/stylesheets/up-bootstrap.css.sass
|
108
|
+
- lib/assets/stylesheets/up-bootstrap/modal-ext.css.sass
|
109
|
+
- lib/assets/stylesheets/up.css.sass
|
102
110
|
- lib/assets/stylesheets/up/close.css.sass
|
103
111
|
- lib/assets/stylesheets/up/error.css.sass
|
104
112
|
- lib/assets/stylesheets/up/link.css.sass
|