dist/up.js in upjs-rails-0.10.1 vs dist/up.js in upjs-rails-0.10.2
- old
+ new
@@ -1981,11 +1981,11 @@
for a list of pre-defined timing functions.
@param {Number} [options.snap]
When [revealing](#up.reveal) elements, Up.js will scroll an viewport
to the top when the revealed element is closer to the top than `options.snap`.
@param {Number} [options.substance]
- The top number of pixel rows of an element to [reveal](#up.reveal).
+ A number indicating how many top pixel rows of an element to [reveal](#up.reveal).
*/
config = u.config({
duration: 0,
viewports: ['body', '.up-modal', '[up-viewport]'],
fixedTop: ['[up-fixed~=top]'],
@@ -2487,15 +2487,13 @@
@param {String|Boolean} [options.history=true]
If a `String` is given, it is used as the URL the browser's location bar and history.
If omitted or true, the `url` argument will be used.
If set to `false`, the history will remain unchanged.
@param {String|Boolean} [options.source=true]
- @param {String} [options.reveal]
- Up.js will try to [reveal](/up.layout#up.reveal) the element being updated, by
- scrolling its containing viewport. Set this option to `false` to prevent any scrolling.
-
- If omitted, this will use the [default from `up.layout`](/up.layout#up.layout.defaults).
+ @param {String} [options.reveal=false]
+ Whether to [reveal](/up.layout#up.reveal) the element being updated, by
+ scrolling its containing viewport.
@param {Boolean} [options.restoreScroll=`false`]
If set to true, Up.js will try to restore the scroll position
of all the viewports within the updated element. The position
will be reset to the last known top position before a previous
history change for the current URL.
@@ -2618,11 +2616,11 @@
}
}
};
};
reveal = function($element, options) {
- if (options.reveal !== false) {
+ if (options.reveal) {
return up.reveal($element);
} else {
return u.resolvedDeferred();
}
};
@@ -3878,11 +3876,10 @@
@method up.visit
@param {String} url
The URL to visit.
@param {String} [options.target='body']
The selector to replace.
- See options for [`up.replace`](/up.flow#up.replace)
@param {Object} options
See options for [`up.replace`](/up.flow#up.replace)
*/
visit = function(url, options) {
var selector;
@@ -3912,28 +3909,35 @@
The selector to replace.
Defaults to the `up-target` attribute on `link`,
or to `body` if such an attribute does not exist.
@param {Function|String} [options.transition]
A transition function or name.
- @param {Element|jQuery|String} [options.reveal]
- Whether to reveal the followed element within its viewport.
@param {Number} [options.duration]
The duration of the transition. See [`up.morph`](/up.motion#up.morph).
@param {Number} [options.delay]
The delay before the transition starts. See [`up.morph`](/up.motion#up.morph).
@param {String} [options.easing]
The timing function that controls the transition's acceleration. [`up.morph`](/up.motion#up.morph).
+ @param {Element|jQuery|String} [options.reveal]
+ Whether to reveal the target element within its viewport before updating.
+ @param {Boolean} [options.restoreScroll]
+ If set to `true`, this will attempt to [`restore scroll positions`](/up.layout#up.restoreScroll)
+ previously seen on the destination URL.
+ @param {Boolean} [options.cache]
+ Whether to force the use of a cached response (`true`)
+ or never use the cache (`false`)
+ or make an educated guess (`undefined`).
*/
follow = function(link, options) {
var $link, selector, url;
$link = $(link);
options = u.options(options);
url = u.option($link.attr('up-href'), $link.attr('href'));
selector = u.option(options.target, $link.attr('up-target'), 'body');
options.transition = u.option(options.transition, u.castedAttr($link, 'up-transition'), u.castedAttr($link, 'up-animation'));
options.history = u.option(options.history, u.castedAttr($link, 'up-history'));
- options.reveal = u.option(options.reveal, u.castedAttr($link, 'up-reveal'));
+ options.reveal = u.option(options.reveal, u.castedAttr($link, 'up-reveal'), true);
options.cache = u.option(options.cache, u.castedAttr($link, 'up-cache'));
options.restoreScroll = u.option(options.restoreScroll, u.castedAttr($link, 'up-restore-scroll'));
options.method = followMethod($link, options);
options = u.merge(options, up.motion.animateOptions(options, $link));
return up.replace(selector, url, options);
@@ -3997,16 +4001,22 @@
@method a[up-target]
@ujs
@param {String} up-target
The CSS selector to replace
- @param [up-href]
+ @param {String} [up-href]
The destination URL to follow.
If omitted, the the link's `href` attribute will be used.
- @param [up-restore-scroll='false']
- Whether to restore the scroll position of all viewports
+ @param {String} [up-reveal='true']
+ Whether to reveal the target element within its viewport before updating.
+ @param {String} [up-restore-scroll='false']
+ Whether to restore previously known scroll position of all viewports
within the target selector.
+ @param {String} [up-cache]
+ Whether to force the use of a cached response (`true`)
+ or never use the cache (`false`)
+ or make an educated guess (`undefined`).
*/
up.on('click', 'a[up-target], [up-href][up-target]', function(event, $link) {
if (shouldProcessLinkEvent(event, $link)) {
if ($link.is('[up-instant]')) {
return event.preventDefault();
@@ -4276,28 +4286,42 @@
The duration of the transition. See [`up.morph`](/up.motion#up.morph).
@param {Number} [options.delay]
The delay before the transition starts. See [`up.morph`](/up.motion#up.morph).
@param {String} [options.easing]
The timing function that controls the transition's acceleration. [`up.morph`](/up.motion#up.morph).
+ @param {Element|jQuery|String} [options.reveal]
+ Whether to reveal the target element within its viewport.
+ @param {Boolean} [options.restoreScroll]
+ If set to `true`, this will attempt to [`restore scroll positions`](/up.layout#up.restoreScroll)
+ previously seen on the destination URL.
@param {Boolean} [options.cache]
- Whether to accept a cached response.
+ Whether to force the use of a cached response (`true`)
+ or never use the cache (`false`)
+ or make an educated guess (`undefined`).
+
+ By default only responses to `GET` requests are cached
+ for a few minutes.
@return {Promise}
- A promise for the AJAX response
+ A promise for the successful form submission.
*/
submit = function(formOrSelector, options) {
- var $form, animateOptions, failureSelector, failureTransition, historyOption, httpMethod, request, successSelector, successTransition, successUrl, url, useCache;
+ var $form, failureSelector, failureTransition, historyOption, httpMethod, implantOptions, request, successSelector, successTransition, successUrl, url, useCache;
$form = $(formOrSelector).closest('form');
options = u.options(options);
successSelector = u.option(options.target, $form.attr('up-target'), 'body');
failureSelector = u.option(options.failTarget, $form.attr('up-fail-target'), function() {
return u.createSelectorFromElement($form);
});
historyOption = u.option(options.history, u.castedAttr($form, 'up-history'), true);
successTransition = u.option(options.transition, u.castedAttr($form, 'up-transition'));
failureTransition = u.option(options.failTransition, u.castedAttr($form, 'up-fail-transition'), successTransition);
httpMethod = u.option(options.method, $form.attr('up-method'), $form.attr('data-method'), $form.attr('method'), 'post').toUpperCase();
- animateOptions = up.motion.animateOptions(options, $form);
+ implantOptions = {};
+ implantOptions.reveal = u.option(options.reveal, u.castedAttr($form, 'up-reveal'), true);
+ implantOptions.cache = u.option(options.cache, u.castedAttr($form, 'up-cache'));
+ implantOptions.restoreScroll = u.option(options.restoreScroll, u.castedAttr($form, 'up-restore-scroll'));
+ implantOptions = u.extend(implantOptions, up.motion.animateOptions(options, $form));
useCache = u.option(options.cache, u.castedAttr($form, 'up-cache'));
url = u.option(options.url, $form.attr('action'), up.browser.url());
$form.addClass('up-active');
if (!up.browser.canPushState() && historyOption !== false) {
$form.get(0).submit();
@@ -4326,19 +4350,19 @@
};
return up.proxy.ajax(request).always(function() {
return $form.removeClass('up-active');
}).done(function(html, textStatus, xhr) {
var successOptions;
- successOptions = u.merge(animateOptions, {
+ successOptions = u.merge(implantOptions, {
history: successUrl(xhr),
transition: successTransition
});
return up.flow.implant(successSelector, html, successOptions);
}).fail(function(xhr, textStatus, errorThrown) {
var failureOptions, html;
html = xhr.responseText;
- failureOptions = u.merge(animateOptions, {
+ failureOptions = u.merge(implantOptions, {
transition: failureTransition
});
return up.flow.implant(failureSelector, html, failureOptions);
});
};
@@ -4469,9 +4493,20 @@
@param {String} [up-method]
The HTTP method to be used to submit the form (`get`, `post`, `put`, `delete`, `patch`).
Alternately you can use an attribute `data-method`
([Rails UJS](https://github.com/rails/jquery-ujs/wiki/Unobtrusive-scripting-support-for-jQuery))
or `method` (vanilla HTML) for the same purpose.
+ @param {String} [up-reveal='true']
+ Whether to reveal the target element within its viewport before updating.
+ @param {String} [up-restore-scroll='false']
+ Whether to restore previously known scroll position of all viewports
+ within the target selector.
+ @param {String} [up-cache]
+ Whether to force the use of a cached response (`true`)
+ or never use the cache (`false`)
+ or make an educated guess (`undefined`).
+
+ By default only responses to `GET` requests are cached for a few minutes.
*/
up.on('submit', 'form[up-target]', function(event, $form) {
event.preventDefault();
return submit($form);
});