Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
j_platform / app / assets / javascripts / j_platform / projects.js.coffee
Size: Mime:
$(document).on "click", "#btn-new-project", (e) ->
  e.preventDefault()
  unless $(@).hasClass('prevent')
    $.ajax
      url: ($ @).attr('href')
      success: (data) ->
        $("#modal-holder").html(data)
        $("#modal-new-project").modal('show')
        $("#modal-new-project").on "shown.bs.modal", ->
          validateAvatarFileType()
          $('#new_project').enableClientSideValidations()

$(document).on "click", ".project-card .edit-link", (e) ->
  e.preventDefault()
  $.ajax
    url: $(this).attr('href'),
    success: (data) ->
      $("#modal-holder").html(data)
      $("#modal-edit-project").modal('show')
      $("#modal-edit-project").on "shown.bs.modal", ->
        validateAvatarFileType()
        $('#modal-holder form').enableClientSideValidations()

$(document).on "ajax:success", ".new_project", (e, data) ->
  destroyModal("#modal-new-project")

  #TODO: Why is this code necessary? The server request is inconsistent,
  #      Based on whether an image is added or not.
  #      This seems to be due to the modal posting to two different endpoints
  #      GET //admin/clients/4/projects/new versus POST //admin/clients/4/projects
  #      The same code has been flagged further down.
  #      Alex Kessaris 2013-08-07
  if $(data).prop('tagName') == 'TEXTAREA' or $(data).prop('tagName') == 'META'
    remotiHTML = $($(data).text())
  else
    remotiHTML = $(data)

  $(".projects-container #active-cards").prepend(remotiHTML)
  svgFill()
  newProjectCount = parseInt($('.client-project-count').html())+1
  $('.client-project-count').html(newProjectCount)
  enableCardClick()
  enableTooltip()
  remotiHTML.click()
  sortProjectCard()

$(document).on "ajax:error", ".new_project", (e, xhr) ->
  e.preventDefault()
  $("#modal-new-project .modal-body").replaceWith($($.parseHTML(xhr.responseText)[1]).find(".modal-body"))
  validateAvatarFileType()
  sortProjectCard()

$(document).on "ajax:success", ".edit_project", (e, data) ->

  #TODO: Why is this code necessary? The server request is inconsistent,
  #      Based on whether an image is added or not.
  #      Alex Kessaris 2013-08-07
  if $(data).prop('tagName') == 'TEXTAREA' or $(data).prop('tagName') == 'META'
    remotiHTML = $($(data).text()).html()
  else
    remotiHTML = $(data).html()

  project_id = $(this).attr('data-project-id')
  destroyModal("#modal-edit-project")
  $("#project"+project_id).html(remotiHTML)
  svgFill()
  enableTooltip()


$(document).on "ajax:error", ".edit_project", (e, xhr, status, error) ->
  if status == 'error'
    e.preventDefault()
    $("#modal-edit-project .modal-body").replaceWith($($.parseHTML(xhr.responseText)[1]).find(".modal-body"))
    validateAvatarFileType()
  else if status == 'parsererror'
    project_id = $(this).attr("data-project-id")
    $("#modal-edit-project").modal('hide')
    $("article#project"+project_id).html($(xhr.responseText).html())
    svgFill()

$(document).on "click", "#project-avatar .avatar-upload-link, #avatar-preview", (e) ->
  e.preventDefault()
  $('#project-avatar .project-avatar-upload').click()