Sha256: 82787746788e3aecb3621129fff08fe994911e790daced890b2807b4a431bc43

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

angular.module('EssayApp.services')
  .factory('reportService', ["$http", ($http) ->
    api = {}

    api.SOURCE_TYPES =
      feedback: 1
      testimonial: 2

    api.send_report = (data, url, onSuccess=null, onFail=null) ->
      # console.log 'send report...', data
      data['source_type_id'] = (api.SOURCE_TYPES[data.type] || 1) unless data['source_type_id']

      $http.post(url, $.param(data), { headers: {'Content-Type': 'application/x-www-form-urlencoded'}}).then(
        (response)->
          onSuccess.call(response) if $.isFunction(onSuccess)
      ,
        (response)->
          onFail.call(response) if $.isFunction(onFail)
      )
      # method: 'POST'
      # url: url
      # format: 'json'
      # data: $.param(data)
      # headers:
      #   'Content-Type': 'application/x-www-form-urlencoded'

    return api
  ])

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/app/services/report_service.js.coffee