lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.5.0 vs lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.6.0

- old
+ new

@@ -38,19 +38,21 @@ @param {String|Element|jQuery} selectorOrElement The CSS selector to update. You can also pass a DOM element or jQuery element here, in which case a selector will be inferred from the element's class and ID. @param {String} url The URL to fetch from the server. - @param {String} [options.title] @param {String} [options.method='get'] + @param {String} [options.title] + @param {String} [options.transition='none'] @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.transition] @param {String} [options.scroll='body'] + @param {Boolean} [options.cache] + Whether to use a [cached response](/up.proxy) if available. @param {String} [options.historyMethod='push'] @return {Promise} A promise that will be resolved when the page has been updated. ### replace = (selectorOrElement, url, options) -> @@ -69,10 +71,11 @@ request = url: url method: options.method selector: selector + cache: options.cache promise = up.proxy.ajax(request) promise.done (html, textStatus, xhr) -> # The server can send us the current path using a header value. @@ -229,41 +232,56 @@ $control.focus() ###* Destroys the given element or selector. Takes care that all destructors, if any, are called. + The element is removed from the DOM. @method up.destroy @param {String|Element|jQuery} selectorOrElement - @param {String|Function|Object} [options.animation] @param {String} [options.url] @param {String} [options.title] + @param {String} [options.animation='none'] + The animation to use before the element is removed from the DOM. + @param {Number} [options.duration] + The duration of the animation. See [`up.animate`](/up.motion#up.animate). + @param {Number} [options.delay] + The delay before the animation starts. See [`up.animate`](/up.motion#up.animate). + @param {String} [options.easing] + The timing function that controls the animation's acceleration. [`up.animate`](/up.motion#up.animate). ### destroy = (selectorOrElement, options) -> $element = $(selectorOrElement) options = u.options(options, animation: 'none') + animateOptions = up.motion.animateOptions(options) $element.addClass('up-destroying') # If e.g. a modal or popup asks us to restore a URL, do this # before emitting `fragment:destroy`. This way up.navigate sees the # new URL and can assign/remove .up-current classes accordingly. up.history.push(options.url) if u.isPresent(options.url) document.title = options.title if u.isPresent(options.title) up.bus.emit('fragment:destroy', $element) animationPromise = u.presence(options.animation, u.isPromise) || - up.motion.animate($element, options.animation) + up.motion.animate($element, options.animation, animateOptions) animationPromise.then -> $element.remove() ###* Replaces the given selector or element with a fresh copy fetched from the server. + Up.js remembers the URL from which a fragment was loaded, so you + don't usually need to give an URL when reloading. + @method up.reload @param {String|Element|jQuery} selectorOrElement + @param {Object} [options] + See options for [`up.replace`](#up.replace) ### - reload = (selectorOrElement) -> - sourceUrl = source(selectorOrElement) - replace(selectorOrElement, sourceUrl) + reload = (selectorOrElement, options) -> + options = u.options(options, cache: false) + sourceUrl = options.url || source(selectorOrElement) + replace(selectorOrElement, sourceUrl, options) ###* Resets Up.js to the state when it was booted. All custom event handlers, animations, etc. that have been registered will be discarded.