Sha256: 3a58310ebc4016d40716c6a14b0ec41119c2862fb2acbac7b15dcbfb74fa1174

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class Profile
  @defaults:
    confirm_popup: '.leave-confirmation-popup'
    leave_button: '.leave_page'
    close_button: '.popup_close, .btn_close'
    pending_factor: '.pending-changes'
    exclude: '.content a'
    target: 'a'

  @init: (options)->
    options = $.extend({}, @defaults, options || {})
    # console.log 'Profile init', options
    $(options.target).not(options.exclude).on 'click.leave-confirmation', (evt) ->
      if $(options.pending_factor).length > 0
        evt.preventDefault()
        # alert evt.target.href
        root = $(options.confirm_popup)
        root.find(options.leave_button).attr('href', evt.target.href).off 'click.leave-confirmation'
        root.find(options.close_button).on 'click', ->
          root.hide()

        if evt.target.attributes['ng-click']? || evt.target.attributes['ng_click']?
          root.find(options.leave_button).on 'click', ->
            evt.target.dispatchEvent(new Event('click'))
        root.show()
        return false
      return true
    return

window.Profile = Profile

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/account/profile.js.coffee