quocvuongdn

#coffeescript: example to write jQuery

Feb 2nd, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready ->
  2.   control.init()
  3.   return
  4.  
  5. control =
  6.   init: ->
  7.     c = this
  8.     c.slider()
  9.     c.dropdown_province()
  10.     c.tab_journey()
  11.     return
  12.   slider: ->
  13.     $('.flexslider').flexslider
  14.       animation: 'slide'
  15.       easing: 'swing'
  16.       slideshowSpeed: 4000
  17.     return
  18.   dropdown_province: ->
  19.     focusTextbox = null
  20.     dropdown = $('.dropdown-province')
  21.     $('.province').focus ->
  22.       focusTextbox = $(this)
  23.       position = focusTextbox.position()
  24.       dropdown.css('top', position.top + 28).css('left', position.left).fadeIn 500
  25.       return
  26.     $('.dropdown-province .btn-close').on 'click', (event) ->
  27.       dropdown.hide()
  28.       return
  29.     $('.dropdown-province a').on 'click', (event) ->
  30.       event.preventDefault()
  31.       province = $(this).text()
  32.       focusTextbox.val province
  33.       dropdown.hide()
  34.       return
  35.     return
  36.   tab_journey: ->
  37.     $('.tabs a').on 'click', (event) ->
  38.       event.preventDefault()
  39.       parent = $(this).parent()
  40.       parent.addClass 'active'
  41.       parent.siblings().removeClass 'active'
  42.       tab = $(this).attr('href')
  43.       idContent = $(this).closest('ul').data('target')
  44.       contents = $('#' + idContent)
  45.       contents.children('.content').not(tab).css 'display', 'none'
  46.       contents.find(tab).fadeIn()
  47.       return
  48.     return
  49.  
  50. # ---
  51. # generated by js2coffee 2.0.0
Advertisement
Add Comment
Please, Sign In to add comment