Sha256: cf73cb19f0a0c55fa2ad33f42fe8fea0f9c467a25c26c5ab6b6da37209100b4e

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

$(document).ready ->
  
  ## Editor for Post Body
  $('#kublog .editor').wysiwyg(wysiwyg.default_controls)
         
  ### Twitter Char Counter Event ###
  $('#kublog textarea[maxlength]').keyup(charCounter).keyup()
  
  ### Twitter and Facebook Post Cloning Event ###
  $('#kublog .original').keyup(mimicTitle).keyup()
  
  ### Optional Hidden Fields (Currently E-mail notifications, Twitter and Facebook) ###
  $('#kublog .trigger-optional').change ->
    $optional = $(this).siblings('.optional')
    if $(this).attr('checked')?
      $optional.show().find('[disabled]').attr('disabled', false)
    else
      $optional.hide().find('textarea, input').attr('disabled', true)
  
  ### Validates the form through AJAX on server Side ###
  # check doesn't care if editing or creating new post
  $('#kublog #create_post_button').click ->
    resetErrors()
    post_data = $(this).closest('form').first().serialize()
    $.post "#{kublogPath}posts/check.json", post_data, (data) ->
      $form = $('#kublog .post_form')
      $form.data('post', data)
      $form.submit()
      return true
    .error (response)->
      errors =  JSON.parse(response.responseText)
      setErrors('post', errors)
    return false
    
# Handle on Event

charCounter = ->
  $chars_left_display = $(this).siblings('.chars_left')
  actual_chars_left = parseInt($(this).attr('maxlength')) - $(this).val().length
  $chars_left_display.html(actual_chars_left)
  
mimicTitle = -> $('#kublog .mimic').val($(this).val()).keyup()
    
  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kublog-0.0.1.1 app/assets/javascripts/kublog/posts.js.coffee