lib/assets/javascripts/unpoly/flow.js.coffee in unpoly-rails-0.22.0 vs lib/assets/javascripts/unpoly/flow.js.coffee in unpoly-rails-0.22.1

- old
+ new

@@ -1,11 +1,11 @@ ###* Changing page fragments programmatically ======================================== -This module contains Unpoly's core functions to [change](/up.replace) or [destroy](/up.destroy) - page fragments via Javascript. +This module contains Unpoly's core functions to [change](/up.replace) or +[destroy](/up.destroy) page fragments via Javascript. All the other Unpoly modules (like [`up.link`](/up.link) or [`up.modal`](/up.modal)) are based on this module. @class up.flow @@ -121,11 +121,11 @@ The server is free to optimize Unpoly requests by only rendering the HTML fragment that is being updated. The request's `X-Up-Target` header will contain the CSS selector for the updating fragment. If you are using the `unpoly-rails` gem you can also access the selector via - `up.selector` in all controllers, views and helpers. + `up.target` in all controllers, views and helpers. \#\#\#\# Events Unpoly will emit [`up:fragment:destroyed`](/up:fragment:destroyed) on the element that was replaced and [`up:fragment:inserted`](/up:fragment:inserted) on the new @@ -213,10 +213,14 @@ @internal ### processResponse = (isSuccess, selector, url, request, xhr, options) -> options.method = u.normalizeMethod(u.option(u.methodFromXhr(xhr), options.method)) options.title = u.option(u.titleFromXhr(xhr), options.title) + + unless options.title is false || u.isString(options.title) || (options.history is false && options.title isnt true) + options.title = u.titleFromXhr(xhr) + isReloadable = (options.method == 'GET') # The server can send us the current path using a header value. # This way we know the actual URL if the server has redirected. if urlFromServer = u.locationFromXhr(xhr) @@ -348,12 +352,13 @@ $(child) else if options.requireMatch u.error("Could not find selector %s in response %o", selector, html) updateHistory = (options) -> + if options.title + document.title = options.title if options.history - document.title = options.title if options.title up.history[options.historyMethod](options.history) swapElements = ($old, $new, pseudoClass, transition, options) -> transition ||= 'none' @@ -569,10 +574,10 @@ pseudoClass: pseudoClass transition: transition ###* Compiles a page fragment that has been inserted into the DOM - without Unpoly. + by external code. **As long as you manipulate the DOM using Unpoly, you will never need to call this method.** You only need to use `up.hello` if the DOM is manipulated without Unpoly' involvement, e.g. by setting the `innerHTML` property or calling jQuery methods like