upjs-rails 0.12.4 → 0.12.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -3
- data/dist/up.js +495 -300
- data/dist/up.min.js +2 -2
- data/lib/assets/javascripts/up.js.coffee +3 -1
- data/lib/assets/javascripts/up/browser.js.coffee +8 -8
- data/lib/assets/javascripts/up/bus.js.coffee +77 -37
- data/lib/assets/javascripts/up/flow.js.coffee +40 -6
- data/lib/assets/javascripts/up/form.js.coffee +5 -7
- data/lib/assets/javascripts/up/history.js.coffee +8 -10
- data/lib/assets/javascripts/up/layout.js.coffee +22 -20
- data/lib/assets/javascripts/up/link.js.coffee +10 -15
- data/lib/assets/javascripts/up/modal.js.coffee +92 -72
- data/lib/assets/javascripts/up/motion.js.coffee +16 -17
- data/lib/assets/javascripts/up/navigation.js.coffee +3 -6
- data/lib/assets/javascripts/up/popup.js.coffee +55 -27
- data/lib/assets/javascripts/up/proxy.js.coffee +71 -20
- data/lib/assets/javascripts/up/syntax.js.coffee +30 -15
- data/lib/assets/javascripts/up/tooltip.js.coffee +5 -8
- data/lib/assets/javascripts/up/util.js.coffee +39 -22
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +30 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +6 -0
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +8 -8
- metadata +2 -3
- data/lib/assets/javascripts/up/boot.js.coffee +0 -3
@@ -95,7 +95,7 @@ up.link = (($) ->
|
|
95
95
|
|
96
96
|
up.visit('/users')
|
97
97
|
|
98
|
-
@
|
98
|
+
@function up.visit
|
99
99
|
@param {String} url
|
100
100
|
The URL to visit.
|
101
101
|
@param {String} [options.target='body']
|
@@ -121,7 +121,7 @@ up.link = (($) ->
|
|
121
121
|
var $link = $('a:first'); // select link with jQuery
|
122
122
|
up.follow($link);
|
123
123
|
|
124
|
-
@
|
124
|
+
@function up.follow
|
125
125
|
@param {Element|jQuery|String} linkOrSelector
|
126
126
|
An element or selector which resolves to an `<a>` tag
|
127
127
|
or any element that is marked up with an `up-href` attribute.
|
@@ -170,7 +170,7 @@ up.link = (($) ->
|
|
170
170
|
Defaults to `get`.
|
171
171
|
|
172
172
|
@protected
|
173
|
-
@
|
173
|
+
@function up.link.followMethod
|
174
174
|
@param linkOrSelector
|
175
175
|
@param options.method {String}
|
176
176
|
###
|
@@ -226,8 +226,7 @@ up.link = (($) ->
|
|
226
226
|
Note that using any element other than `<a>` will prevent users from
|
227
227
|
opening the destination in a new tab.
|
228
228
|
|
229
|
-
@
|
230
|
-
@ujs
|
229
|
+
@selector a[up-target]
|
231
230
|
@param {String} up-target
|
232
231
|
The CSS selector to replace
|
233
232
|
@param {String} [up-href]
|
@@ -269,8 +268,7 @@ up.link = (($) ->
|
|
269
268
|
navigation actions this isn't needed. E.g. popular operation
|
270
269
|
systems switch tabs on `mousedown` instead of `click`.
|
271
270
|
|
272
|
-
@
|
273
|
-
@ujs
|
271
|
+
@selector a[up-instant]
|
274
272
|
###
|
275
273
|
up.on 'mousedown', 'a[up-instant], [up-href][up-instant]', (event, $link) ->
|
276
274
|
if shouldProcessLinkEvent(event, $link)
|
@@ -278,7 +276,7 @@ up.link = (($) ->
|
|
278
276
|
follow($link)
|
279
277
|
|
280
278
|
###*
|
281
|
-
@
|
279
|
+
@function up.link.childClicked
|
282
280
|
@private
|
283
281
|
###
|
284
282
|
childClicked = (event, $link) ->
|
@@ -295,7 +293,7 @@ up.link = (($) ->
|
|
295
293
|
This is done by giving the link an `up-follow` attribute
|
296
294
|
if it doesn't already have it an `up-target` or `up-follow` attribute.
|
297
295
|
|
298
|
-
@
|
296
|
+
@function up.link.makeFollowable
|
299
297
|
@protected
|
300
298
|
###
|
301
299
|
makeFollowable = (link) ->
|
@@ -324,8 +322,7 @@ up.link = (($) ->
|
|
324
322
|
Note that using any element other than `<a>` will prevent users from
|
325
323
|
opening the destination in a new tab.
|
326
324
|
|
327
|
-
@
|
328
|
-
@ujs
|
325
|
+
@selector a[up-follow]
|
329
326
|
@param [up-href]
|
330
327
|
The destination URL to follow.
|
331
328
|
If omitted, the the link's `href` attribute will be used.
|
@@ -358,8 +355,7 @@ up.link = (($) ->
|
|
358
355
|
`up-expand` honors all the UJS behavior in expanded links
|
359
356
|
(`up-target`, `up-instant`, `up-preload`, etc.).
|
360
357
|
|
361
|
-
@
|
362
|
-
@method [up-expand]
|
358
|
+
@selector [up-expand]
|
363
359
|
###
|
364
360
|
up.compiler '[up-expand]', ($area) ->
|
365
361
|
link = $area.find('a, [up-href]').get(0)
|
@@ -392,8 +388,7 @@ up.link = (($) ->
|
|
392
388
|
|
393
389
|
<a href="/users" up-target=".main" up-instant up-preload>User list</a>
|
394
390
|
|
395
|
-
@
|
396
|
-
@ujs
|
391
|
+
@selector [up-dash]
|
397
392
|
###
|
398
393
|
up.compiler '[up-dash]', ($element) ->
|
399
394
|
target = u.castedAttr($element, 'up-dash')
|
@@ -2,10 +2,55 @@
|
|
2
2
|
Modal dialogs
|
3
3
|
=============
|
4
4
|
|
5
|
-
Instead of linking to
|
6
|
-
to
|
5
|
+
Instead of [linking to a page fragment](/up.link), you can choose
|
6
|
+
to show a fragment in a modal dialog.
|
7
|
+
|
8
|
+
To open a modal, add an [`up-modal` attribute](/a-up-modal) to a link,
|
9
|
+
or call the Javascript functions [`up.modal.follow`](/up.modal.follow)
|
10
|
+
and [`up.modal.visit`](/up.modal.visit).
|
7
11
|
|
8
|
-
For
|
12
|
+
For smaller popup overlays ("dropdowns") see [up.popup](/up.popup) instead.
|
13
|
+
|
14
|
+
|
15
|
+
\#\#\#\# Customizing the dialog design
|
16
|
+
|
17
|
+
Loading the Up.js stylesheet will give you a minimal dialog design:
|
18
|
+
|
19
|
+
- Dialog contents are displayed in a white box that is centered vertically and horizontally.
|
20
|
+
- There is a a subtle box shadow around the dialog
|
21
|
+
- The box will grow to fit the dialog contents, but never grow larger than the screen
|
22
|
+
- The box is placed over a semi-transparent background to dim the rest of the page
|
23
|
+
- There is a button to close the dialog in the top-right corner
|
24
|
+
|
25
|
+
The easiest way to change how the dialog looks is by overriding the [default CSS styles](https://github.com/makandra/upjs/blob/master/lib/assets/stylesheets/up/modal.css.sass).
|
26
|
+
|
27
|
+
By default the dialog uses the following DOM structure:
|
28
|
+
|
29
|
+
<div class="up-modal">
|
30
|
+
<div class="up-modal-dialog">
|
31
|
+
<div class="up-modal-close" up-close>X</div>
|
32
|
+
<div class="up-modal-content">
|
33
|
+
...
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
If you want to change the design beyond CSS, you can
|
39
|
+
configure Up.js to [use a different HTML structure](/up.modal.config).
|
40
|
+
|
41
|
+
|
42
|
+
\#\#\#\# Closing behavior
|
43
|
+
|
44
|
+
By default the dialog automatically closes
|
45
|
+
*whenever a page fragment below the dialog is updated*.
|
46
|
+
This is useful to have the dialog interact with the page that
|
47
|
+
opened it, e.g. by updating parts of a larger form or by signing in a user
|
48
|
+
and revealing additional information.
|
49
|
+
|
50
|
+
To disable this behavior, give the opening link an `up-sticky` attribute:
|
51
|
+
|
52
|
+
<a href="/settings" up-modal=".options" up-sticky>Settings</a>
|
53
|
+
|
9
54
|
|
10
55
|
@class up.modal
|
11
56
|
###
|
@@ -16,8 +61,7 @@ up.modal = (($) ->
|
|
16
61
|
###*
|
17
62
|
Sets default options for future modals.
|
18
63
|
|
19
|
-
@
|
20
|
-
@property
|
64
|
+
@property up.modal.config
|
21
65
|
@param {Number} [config.width]
|
22
66
|
The width of the dialog as a CSS value like `'400px'` or `50%`.
|
23
67
|
|
@@ -72,7 +116,7 @@ up.modal = (($) ->
|
|
72
116
|
Returns the source URL for the fragment displayed in the current modal overlay,
|
73
117
|
or `undefined` if no modal is currently open.
|
74
118
|
|
75
|
-
@
|
119
|
+
@function up.modal.url
|
76
120
|
@return {String}
|
77
121
|
the source URL
|
78
122
|
###
|
@@ -81,7 +125,7 @@ up.modal = (($) ->
|
|
81
125
|
###*
|
82
126
|
Returns the URL of the page below the modal overlay.
|
83
127
|
|
84
|
-
@
|
128
|
+
@function up.modal.coveredUrl
|
85
129
|
@return {String}
|
86
130
|
@protected
|
87
131
|
###
|
@@ -167,14 +211,9 @@ up.modal = (($) ->
|
|
167
211
|
|
168
212
|
Any option attributes for [`a[up-modal]`](/a.up-modal) will be honored.
|
169
213
|
|
170
|
-
|
171
|
-
|
172
|
-
- Emits an [event](/up.bus) `up:modal:open` when the modal
|
173
|
-
is starting to open.
|
174
|
-
- Emits an [event](/up.bus) `up:modal:opened` when the opening
|
175
|
-
animation has finished and the modal contents are fully visible.
|
214
|
+
Emits events [`up:modal:open`](/up:modal:open) and [`up:modal:opened`](/up:modal:opened).
|
176
215
|
|
177
|
-
@
|
216
|
+
@function up.modal.follow
|
178
217
|
@param {Element|jQuery|String} linkOrSelector
|
179
218
|
The link to follow.
|
180
219
|
@param {String} [options.target]
|
@@ -206,7 +245,6 @@ up.modal = (($) ->
|
|
206
245
|
options.$link = $(linkOrSelector)
|
207
246
|
open(options)
|
208
247
|
|
209
|
-
|
210
248
|
###*
|
211
249
|
Opens a modal for the given URL.
|
212
250
|
|
@@ -217,7 +255,9 @@ up.modal = (($) ->
|
|
217
255
|
This will request `/foo`, extract the `.list` selector from the response
|
218
256
|
and open the selected container in a modal dialog.
|
219
257
|
|
220
|
-
|
258
|
+
Emits events [`up:modal:open`](/up:modal:open) and [`up:modal:opened`](/up:modal:opened).
|
259
|
+
|
260
|
+
@function up.modal.visit
|
221
261
|
@param {String} url
|
222
262
|
The URL to load.
|
223
263
|
@param {String} options.target
|
@@ -231,8 +271,8 @@ up.modal = (($) ->
|
|
231
271
|
options.url = url
|
232
272
|
open(options)
|
233
273
|
|
234
|
-
|
235
274
|
###*
|
275
|
+
@function up.modal.open
|
236
276
|
@private
|
237
277
|
###
|
238
278
|
open = (options) ->
|
@@ -268,18 +308,27 @@ up.modal = (($) ->
|
|
268
308
|
# callers by returning a Deferred that will never be resolved.
|
269
309
|
$.Deferred()
|
270
310
|
|
311
|
+
###*
|
312
|
+
This event is [emitted](/up.emit) when a modal dialog is starting to open.
|
313
|
+
|
314
|
+
@event up:modal:open
|
315
|
+
@param event.preventDefault()
|
316
|
+
Event listeners may call this method to prevent the modal from opening.
|
317
|
+
###
|
318
|
+
|
319
|
+
###*
|
320
|
+
This event is [emitted](/up.emit) when a modal dialog has finished opening.
|
321
|
+
|
322
|
+
@event up:modal:opened
|
323
|
+
###
|
324
|
+
|
271
325
|
###*
|
272
326
|
Closes a currently opened modal overlay.
|
273
327
|
Does nothing if no modal is currently open.
|
274
328
|
|
275
|
-
|
329
|
+
Emits events [`up:modal:close`](/up:modal:close) and [`up:modal:closed`](/up:modal:closed).
|
276
330
|
|
277
|
-
|
278
|
-
is starting to close.
|
279
|
-
- Emits an [event](/up.bus) `modal:closed` when the closing
|
280
|
-
animation has finished and the modal has been removed from the DOM.
|
281
|
-
|
282
|
-
@method up.modal.close
|
331
|
+
@function up.modal.close
|
283
332
|
@param {Object} options
|
284
333
|
See options for [`up.animate`](/up.animate)
|
285
334
|
###
|
@@ -305,6 +354,22 @@ up.modal = (($) ->
|
|
305
354
|
else
|
306
355
|
u.resolvedDeferred()
|
307
356
|
|
357
|
+
###*
|
358
|
+
This event is [emitted](/up.emit) when a modal dialog
|
359
|
+
is starting to [close](/up.modal.close).
|
360
|
+
|
361
|
+
@event up:modal:close
|
362
|
+
@param event.preventDefault()
|
363
|
+
Event listeners may call this method to prevent the modal from closing.
|
364
|
+
###
|
365
|
+
|
366
|
+
###*
|
367
|
+
This event is [emitted](/up.emit) when a modal dialog
|
368
|
+
is done [closing](/up.modal.close).
|
369
|
+
|
370
|
+
@event up:modal:closed
|
371
|
+
###
|
372
|
+
|
308
373
|
autoclose = ->
|
309
374
|
unless $('.up-modal').is('[up-sticky]')
|
310
375
|
discardHistory()
|
@@ -314,7 +379,7 @@ up.modal = (($) ->
|
|
314
379
|
Returns whether the given element or selector is contained
|
315
380
|
within the current modal.
|
316
381
|
|
317
|
-
@
|
382
|
+
@function up.modal.contains
|
318
383
|
@param {String} elementOrSelector
|
319
384
|
@protected
|
320
385
|
###
|
@@ -335,51 +400,7 @@ up.modal = (($) ->
|
|
335
400
|
and place the matching `.blog-list` tag will be placed in
|
336
401
|
a modal dialog.
|
337
402
|
|
338
|
-
|
339
|
-
\#\#\#\# Customizing the dialog design
|
340
|
-
|
341
|
-
Loading the Up.js stylesheet will give you a minimal dialog design:
|
342
|
-
|
343
|
-
- Dialog contents are displayed in a white box that is centered vertically and horizontally.
|
344
|
-
- There is a a subtle box shadow around the dialog
|
345
|
-
- The box will grow to fit the dialog contents, but never grow larger than the screen
|
346
|
-
- The box is placed over a semi-transparent background to dim the rest of the page
|
347
|
-
- There is a button to close the dialog in the top-right corner
|
348
|
-
|
349
|
-
The easiest way to change how the dialog looks is by overriding the [default CSS styles](https://github.com/makandra/upjs/blob/master/lib/assets/stylesheets/up/modal.css.sass).
|
350
|
-
|
351
|
-
By default the dialog uses the following DOM structure (continuing the blog-switcher example from above):
|
352
|
-
|
353
|
-
<div class="up-modal">
|
354
|
-
<div class="up-modal-dialog">
|
355
|
-
<div class="up-modal-close" up-close>X</div>
|
356
|
-
<div class="up-modal-content">
|
357
|
-
<ul class="blog-list">
|
358
|
-
...
|
359
|
-
</ul>
|
360
|
-
</div>
|
361
|
-
</div>
|
362
|
-
</div>
|
363
|
-
|
364
|
-
If you want to change the design beyond CSS, you can
|
365
|
-
configure Up.js to [use a different HTML structure](/up.modal.config).
|
366
|
-
|
367
|
-
|
368
|
-
\#\#\#\# Closing behavior
|
369
|
-
|
370
|
-
By default the dialog automatically closes
|
371
|
-
*whenever a page fragment below the dialog is updated*.
|
372
|
-
This is useful to have the dialog interact with the page that
|
373
|
-
opened it, e.g. by updating parts of a larger form or by signing in a user
|
374
|
-
and revealing additional information.
|
375
|
-
|
376
|
-
To disable this behavior, give the opening link an `up-sticky` attribute:
|
377
|
-
|
378
|
-
<a href="/settings" up-modal=".options" up-sticky>Settings</a>
|
379
|
-
|
380
|
-
|
381
|
-
@method a[up-modal]
|
382
|
-
@ujs
|
403
|
+
@selector a[up-modal]
|
383
404
|
@param [up-sticky]
|
384
405
|
@param [up-animation]
|
385
406
|
@param [up-height]
|
@@ -417,8 +438,7 @@ up.modal = (($) ->
|
|
417
438
|
When this element is clicked, closes a currently open dialog.
|
418
439
|
Does nothing if no modal is currently open.
|
419
440
|
|
420
|
-
@
|
421
|
-
@ujs
|
441
|
+
@selector [up-close]
|
422
442
|
###
|
423
443
|
up.on('click', '[up-close]', (event, $element) ->
|
424
444
|
if $element.closest('.up-modal').length
|
@@ -41,8 +41,7 @@ up.motion = (($) ->
|
|
41
41
|
###*
|
42
42
|
Sets default options for animations and transitions.
|
43
43
|
|
44
|
-
@
|
45
|
-
@property
|
44
|
+
@property up.motion.config
|
46
45
|
@param {Number} [config.duration=300]
|
47
46
|
@param {Number} [config.delay=0]
|
48
47
|
@param {String} [config.easing='ease']
|
@@ -105,7 +104,7 @@ up.motion = (($) ->
|
|
105
104
|
the previous animation will instantly jump to its last frame before
|
106
105
|
the new animation begins.
|
107
106
|
|
108
|
-
@
|
107
|
+
@function up.animate
|
109
108
|
@param {Element|jQuery|String} elementOrSelector
|
110
109
|
The element to animate.
|
111
110
|
@param {String|Function|Object} animation
|
@@ -145,7 +144,7 @@ up.motion = (($) ->
|
|
145
144
|
attributes like `up-easing` or `up-duration`.
|
146
145
|
|
147
146
|
@protected
|
148
|
-
@
|
147
|
+
@function up.motion.animateOptions
|
149
148
|
###
|
150
149
|
animateOptions = (allOptions, $element = null) ->
|
151
150
|
allOptions = u.options(allOptions)
|
@@ -226,7 +225,7 @@ up.motion = (($) ->
|
|
226
225
|
|
227
226
|
Does nothing if the given element is not currently animating.
|
228
227
|
|
229
|
-
@
|
228
|
+
@function up.motion.finish
|
230
229
|
@param {Element|jQuery|String} elementOrSelector
|
231
230
|
###
|
232
231
|
finish = (elementOrSelector) ->
|
@@ -291,7 +290,7 @@ up.motion = (($) ->
|
|
291
290
|
- When the transition has finished, the clones are removed from the DOM and the new element is shown.
|
292
291
|
The old element remains hidden in the DOM.
|
293
292
|
|
294
|
-
@
|
293
|
+
@function up.morph
|
295
294
|
@param {Element|jQuery|String} source
|
296
295
|
@param {Element|jQuery|String} target
|
297
296
|
@param {Function|String} transitionOrName
|
@@ -315,7 +314,7 @@ up.motion = (($) ->
|
|
315
314
|
$old = $(source)
|
316
315
|
$new = $(target)
|
317
316
|
|
318
|
-
parsedOptions = u.only(options, 'reveal', 'restoreScroll')
|
317
|
+
parsedOptions = u.only(options, 'reveal', 'restoreScroll', 'source')
|
319
318
|
parsedOptions = u.extend(parsedOptions, animateOptions(options))
|
320
319
|
|
321
320
|
if up.browser.canCssAnimation()
|
@@ -415,8 +414,8 @@ up.motion = (($) ->
|
|
415
414
|
|
416
415
|
up.transition('cross-fade', ($old, $new, options) ->
|
417
416
|
up.motion.when(
|
418
|
-
animate($old, 'fade-out', options),
|
419
|
-
animate($new, 'fade-in', options)
|
417
|
+
up.animate($old, 'fade-out', options),
|
418
|
+
up.animate($new, 'fade-in', options)
|
420
419
|
)
|
421
420
|
)
|
422
421
|
|
@@ -435,7 +434,7 @@ up.motion = (($) ->
|
|
435
434
|
Calling [`up.animate`](/up.animate) with an object argument
|
436
435
|
will take care of all these points.
|
437
436
|
|
438
|
-
@
|
437
|
+
@function up.transition
|
439
438
|
@param {String} name
|
440
439
|
@param {Function} transition
|
441
440
|
###
|
@@ -447,10 +446,10 @@ up.motion = (($) ->
|
|
447
446
|
|
448
447
|
Here is the definition of the pre-defined `fade-in` animation:
|
449
448
|
|
450
|
-
up.animation('fade-in', ($ghost, options)
|
451
|
-
$ghost.css(opacity: 0)
|
452
|
-
animate($ghost, { opacity: 1 }, options)
|
453
|
-
)
|
449
|
+
up.animation('fade-in', function($ghost, options) {
|
450
|
+
$ghost.css(opacity: 0);
|
451
|
+
up.animate($ghost, { opacity: 1 }, options);
|
452
|
+
})
|
454
453
|
|
455
454
|
It is recommended that your definitions always end by calling
|
456
455
|
calling [`up.animate`](/up.animate) with an object argument, passing along
|
@@ -468,7 +467,7 @@ up.motion = (($) ->
|
|
468
467
|
Calling [`up.animate`](/up.animate) with an object argument
|
469
468
|
will take care of all these points.
|
470
469
|
|
471
|
-
@
|
470
|
+
@function up.animation
|
472
471
|
@param {String} name
|
473
472
|
@param {Function} animation
|
474
473
|
###
|
@@ -486,7 +485,7 @@ up.motion = (($) ->
|
|
486
485
|
the combined promise will have a `resolve` method. This `resolve` method
|
487
486
|
will resolve all the wrapped promises.
|
488
487
|
|
489
|
-
@
|
488
|
+
@function up.motion.when
|
490
489
|
@param promises...
|
491
490
|
@return A new promise.
|
492
491
|
###
|
@@ -496,7 +495,7 @@ up.motion = (($) ->
|
|
496
495
|
Returns a no-op animation or transition which has no visual effects
|
497
496
|
and completes instantly.
|
498
497
|
|
499
|
-
@
|
498
|
+
@function up.motion.none
|
500
499
|
@return {Promise}
|
501
500
|
A resolved promise
|
502
501
|
###
|