Sha256: 2d2a41c9a135e83ffb55e1c765c1c67bf8a6f7b50c529ae36188f28b02f6e05d

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

smart_link_effect_duration = 100


smart_link_effect_hide = (target, effect, fn) ->
    opts = { duration: smart_link_effect_duration, complete: fn }
    console.log "smart_link_effect_hide: #{effect}"
    switch effect
        when 'show'
            target.hide()
            fn()
        when 'fade'
            target.fadeOut opts
        when 'slide'
            target.slideUp opts

smart_link_effect_show = (target, effect) ->
    opts = { duration: smart_link_effect_duration }
    console.log "smart_link_effect_show: #{effect}"
    switch effect
        when 'show'
            target.show()
        when 'fade'
            target.fadeIn opts
        when 'slide'
            target.slideDown opts

smart_link_click = (e) ->
    console?.log "smart link clicked: #{e}"
    el = $(e.currentTarget)
    show_id = el.attr 'data-show-id'
    hide_id = el.attr 'data-hide-id'
    effect = (el.attr 'data-effect') || 'show'
    if hide_id?
        smart_link_effect_hide $(hide_id), effect, ->
            smart_link_effect_show $(show_id), effect
    else
        smart_link_effect_show $(show_id), effect
    e.preventDefault()
    false

$ ->
    $('body').on 'click', '.smart-link', smart_link_click

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aerogel-pages-1.4.16 assets/vendor/smart-links.js.coffee
aerogel-pages-1.4.14 assets/vendor/smart-links.js.coffee
aerogel-pages-1.4.12 assets/vendor/smart-links.js.coffee