Sha256: 5bcf0c9b07807e2d691a603e428bfd16ff4e9cdc29e9e5a6bbf564f1397b769f
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
u = up.util class up.FollowVariant constructor: (selector, options) -> @followNow = options.follow @preloadNow = options.preload @selectors = selector.split(/\s*,\s*/) onClick: (event, $link) => if up.link.shouldProcessEvent(event, $link) if $link.is('[up-instant]') # If the link was already processed on mousedown, we still need # to prevent this later click event's chain. up.bus.haltEvent(event) else up.bus.consumeAction(event) @followLink($link) else # For tests up.link.allowDefault(event) onMousedown: (event, $link) => if up.link.shouldProcessEvent(event, $link) up.bus.consumeAction(event) @followLink($link) fullSelector: (additionalClause = '') => parts = [] @selectors.forEach (variantSelector) -> for tagSelector in ['a', '[up-href]'] parts.push "#{tagSelector}#{variantSelector}#{additionalClause}" parts.join(', ') registerEvents: -> up.on 'click', @fullSelector(), (args...) => u.muteRejection @onClick(args...) up.on 'mousedown', @fullSelector('[up-instant]'), (args...) => u.muteRejection @onMousedown(args...) followLink: ($link, options) => options = u.options(options) followEventAttrs = { message: 'Following link', $link: $link, $element: $link } up.bus.whenEmitted('up:link:follow', followEventAttrs).then => up.feedback.start $link, options, => @followNow($link, options) preloadLink: ($link, options) => options = u.options(options) @preloadNow($link, options) matchesLink: ($link) => $link.is(@fullSelector())
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unpoly-rails-0.57.0 | lib/assets/javascripts/unpoly/classes/follow_variant.coffee |