Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ = jQuery
  2. $(document).on 'click', 'a.actionable.do_favourite', (evt) ->
  3.   evt.preventDefault()
  4.   $a = $ @
  5.   return if $a.hasClass("loading")
  6.  
  7.   $a.toggleClass('loading')
  8.   $a.closest('.f_s').toggleClass('f_a')
  9.  
  10.   onSuccess = ->
  11.     $a.toggleClass('loading')
  12.  
  13.     #Changing title
  14.     if $a.closest('.f_s').hasClass('f_a') #Active
  15.       $a.attr('title', $a.attr('data-title-on'))
  16.     else  #Inactive
  17.       $a.attr('title', $a.attr('data-title-off'))
  18.  
  19.     $('span.count').each ->
  20.       $this = $ @
  21.       # 'current' for Classifieds
  22.       if $this.parent().hasClass('current')
  23.         count = +($this.text().trim().replace(/[\(\)]/g, ''))
  24.         if $a.closest('.f_s').hasClass('f_a') #Active
  25.           $this.text("(#{count  + 1})")
  26.         else  #Inactive
  27.           $this.text("(#{count  - 1})")
  28.  
  29.     # 'favs' class for Community
  30.     $('span.count.favs').each ->
  31.       $this = $ @
  32.       count = +($this.text().trim().replace(/[\(\)]/g, ''))
  33.       if $a.closest('.f_s').hasClass('f_a')
  34.         $this.text("(#{count  + 1})")
  35.       else
  36.         $this.text("(#{count  - 1})")
  37.  
  38.   $.get(@getAttribute('data-action')).success(onSuccess)
  39.  
  40. jQuery ($) ->
  41.   $('.notify-frequency').change ->
  42.     selected = $(@).find('option:selected').val()
  43.     $.get(@getAttribute('data-action'), updating_frequency: selected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement