Sha256: f2270394e428c23922112edbf45bc19cefa865bd4490ee2eeb7efe327d296567

Contents?: true

Size: 1.47 KB

Versions: 20

Compression:

Stored size: 1.47 KB

Contents

@app.controller 'AssetListCtrl',  ['$scope', ($scope) ->

  $scope.assetCount = ->
    $scope.assets.length

  $scope.editUrl = (asset) ->
    $scope.assetUrl.replace(/~id/, asset.id)

  $scope.afterUpload = (asset) ->
    $scope.assets.unshift(asset)
    $scope.assets = $scope.assets.slice(0, 20)

]

@app.controller 'AssetUploadCtrl', ['$scope', ($scope) ->

  $scope.method = ->
    if $scope.asset['new_record?'] then 'post' else 'patch'

  $scope.saveUrl = ->
    if $scope.asset['new_record?'] then $scope.createUrl else $scope.updateUrl.replace(/~id$/, $scope.asset.id)

  $scope.saveButtonClass = ->
    if $scope.asset['new_record?'] then 'success' else 'primary'

  $scope.saveButtonText = ->
    if $scope.asset['new_record?'] then 'Upload file' else 'Update media'

  $scope.afterUpload = (asset) ->
    $scope.asset = asset

]

@app.directive 'assetUpload', ->
  (scope, $el, attrs) ->
    unless window.FileReader && Modernizr.draganddrop
      $el.hide()
      return
    if attrs.assetFallback
      scope.hideFileField = true
    $el.filedrop
      fallback_id:  attrs.assetFallback
      url:          attrs.assetUpload
      paramname:    'asset[file]'
      maxfiles:     attrs.assetMaxfiles || 1
      dragOver:   -> $(this).addClass('hover')
      dragLeave:  -> $(this).removeClass('hover')
      drop:       -> $(this).removeClass('hover')
      uploadFinished: (i, file, response, time) ->
        scope.afterUpload(response.asset)
        scope.$apply() unless scope.$$phase


Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.7.0.beta.1 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.6.0 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.6.0.beta.4 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.6.0.beta.3 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.6.0.beta.2 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.6.0.beta.1 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.3 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.2 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.1 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0.alpha.5 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0.alpha.4 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0.alpha.3 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0.alpha.2 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.5.0.alpha.1 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.4.0 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.4.0.beta.3 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.3.3 app/assets/javascripts/push_type/assets.js.coffee
push_type_admin-0.3.1 app/assets/javascripts/push_type/assets.js.coffee