dist/up.js in upjs-rails-0.7.0 vs dist/up.js in upjs-rails-0.7.1
- old
+ new
@@ -1674,15 +1674,15 @@
\#\#\#\# Custom elements
You can also use `up.compiler` to implement custom elements like this:
- <current-time></current-time>
+ <clock></clock>
Here is the Javascript that inserts the current time into to these elements:
- up.compiler('current-time', function($element) {
+ up.compiler('clock', function($element) {
var now = new Date();
$element.text(now.toString()));
});
@@ -1695,14 +1695,14 @@
You should clean up after yourself whenever your compilers have global
side effects, like a [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval)
or event handlers bound to the document root.
- Here is a version of `<current-time>` that updates
+ Here is a version of `<clock>` that updates
the time every second, and cleans up once it's done:
- up.compiler('current-time', function($element) {
+ up.compiler('clock', function($element) {
function update() {
var now = new Date();
$element.text(now.toString()));
}
@@ -1715,11 +1715,11 @@
});
If we didn't clean up after ourselves, we would have many ticking intervals
operating on detached DOM elements after we have created and removed a couple
- of `<current-time>` elements.
+ of `<clock>` elements.
\#\#\#\# Attaching structured data
In case you want to attach structured data to the event you're observing,
@@ -2679,13 +2679,10 @@
};
timestamp = function() {
return (new Date()).valueOf();
};
normalizeRequest = function(request) {
- if (!u.isHash(request)) {
- debugger;
- }
if (!request._normalized) {
request.method = u.normalizeMethod(request.method);
if (request.url) {
request.url = u.normalizeUrl(request.url);
}
@@ -3002,11 +2999,11 @@
up.follow($link);
@method up.follow
@param {Element|jQuery|String} link
An element or selector which resolves to an `<a>` tag
- or any element that is marked up with an `up-follow` attribute.
+ or any element that is marked up with an `up-href` attribute.
@param {String} [options.target]
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]
@@ -3023,11 +3020,11 @@
*/
follow = function(link, options) {
var $link, selector, url;
$link = $(link);
options = u.options(options);
- url = u.option($link.attr('href'), $link.attr('up-href'));
+ 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, $link.attr('up-transition'), $link.attr('up-animation'));
options.history = u.option(options.history, $link.attr('up-history'));
options.scroll = u.option(options.scroll, $link.attr('up-scroll'), 'body');
options.cache = u.option(options.cache, $link.attr('up-cache'));
@@ -3090,19 +3087,19 @@
<button up-target=".main" up-href="/foo/bar">Go</button>
Note that using any element other than `<a>` will prevent users from
opening the destination in a new tab.
- @method [up-target]
+ @method a[up-target]
@ujs
@param {String} up-target
The CSS selector to replace
@param [up-href]
The destination URL to follow.
If omitted, the the link's `href` attribute will be used.
*/
- up.on('click', '[up-target]', function(event, $link) {
+ 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();
} else {
event.preventDefault();
@@ -3125,14 +3122,14 @@
Note that using `[up-instant]` will prevent a user from canceling a link
click by moving the mouse away from the interaction area. However, for
navigation actions this isn't needed. E.g. popular operation
systems switch tabs on `mousedown` instead of `click`.
- @method [up-instant]
+ @method a[up-instant]
@ujs
*/
- up.on('mousedown', '[up-instant]', function(event, $link) {
+ up.on('mousedown', 'a[up-instant], [up-href][up-instant]', function(event, $link) {
if (shouldProcessLinkEvent(event, $link)) {
event.preventDefault();
return follow($link);
}
});
@@ -3142,11 +3139,11 @@
@private
*/
childClicked = function(event, $link) {
var $target, $targetLink;
$target = $(event.target);
- $targetLink = $target.closest('a, [up-follow]');
+ $targetLink = $target.closest('a, [up-href]');
return $targetLink.length && $link.find($targetLink).length;
};
shouldProcessLinkEvent = function(event, $link) {
return u.isUnmodifiedMouseEvent(event) && !childClicked(event, $link);
};
@@ -3170,18 +3167,17 @@
<span up-follow up-href="/foo/bar">Go</span>
Note that using any element other than `<a>` will prevent users from
opening the destination in a new tab.
- @method [up-follow]
+ @method a[up-follow]
@ujs
- @param {String} [up-follow]
@param [up-href]
The destination URL to follow.
If omitted, the the link's `href` attribute will be used.
*/
- up.on('click', '[up-follow]', function(event, $link) {
+ up.on('click', 'a[up-follow], [up-href][up-follow]', function(event, $link) {
if (shouldProcessLinkEvent(event, $link)) {
if ($link.is('[up-instant]')) {
return event.preventDefault();
} else {
event.preventDefault();
@@ -3208,19 +3204,20 @@
@ujs
@method [up-expand]
*/
up.compiler('[up-expand]', function($fragment) {
var attribute, i, len, link, name, newAttrs, ref, upAttributePattern;
- link = $fragment.find('[up-href], [href]').get(0);
+ link = $fragment.find('a, [up-href]').get(0);
link || u.error('No link to expand within %o', $fragment);
upAttributePattern = /^up-/;
newAttrs = {};
+ newAttrs['up-href'] = $(link).attr('href');
ref = link.attributes;
for (i = 0, len = ref.length; i < len; i++) {
attribute = ref[i];
name = attribute.name;
- if (name === 'href' || name.match(upAttributePattern)) {
+ if (name.match(upAttributePattern)) {
newAttrs[name] = attribute.value;
}
}
u.setMissingAttrs($fragment, newAttrs);
return $fragment.removeAttr('up-expand');
@@ -4364,10 +4361,10 @@
up.navigation = (function() {
var CLASS_ACTIVE, CLASS_CURRENT, SELECTORS_SECTION, SELECTOR_ACTIVE, SELECTOR_SECTION, SELECTOR_SECTION_INSTANT, enlargeClickArea, locationChanged, normalizeUrl, sectionClicked, sectionUrls, selector, u, unmarkActive;
u = up.util;
CLASS_ACTIVE = 'up-active';
CLASS_CURRENT = 'up-current';
- SELECTORS_SECTION = ['[href]', '[up-target]', '[up-follow]', '[up-modal]', '[up-popup]', '[up-href]'];
+ SELECTORS_SECTION = ['a', '[up-href]'];
SELECTOR_SECTION = SELECTORS_SECTION.join(', ');
SELECTOR_SECTION_INSTANT = ((function() {
var i, len, results;
results = [];
for (i = 0, len = SELECTORS_SECTION.length; i < len; i++) {