Sha256: 13509d2d3eee70f512c7b3b884e1c63a913a30c1412ca282a5bb619589b48ac4

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

# //= require_tree ../../helpers
# //= require material_raingular/directives/upload/events
class DirectiveModels.MrUploadModel extends AngularLinkModel
  @inject(
    '$injector'
  )
  initialize: ->
    [@ngModelCtrl,@mrCallbackCtrl] = @$controller
    [@model,@key] = Helpers.NgModelParse(@$attrs.ngModel,@$scope)
    @fileUpload = new Helpers.FileUpload(@$scope,@model,@key,@$element,@callback.bind(@),@$injector)
    @options = @$scope.$eval(@$attrs.mrUploadOptions)
    new Modules.MrUploadEvents(@$element,@fileUpload,@disabled)
  callback: (data) ->
    @$scope[@model][@key] = data[@key]
    @$scope[@model].thumb = data.thumb
    @$scope[@model].id    = data.id unless @$scope[@model].id
    @$scope.progress = 100
    @$element.removeClass('covered')
    @mrCallbackCtrl?.evaluate(data)

  fileData: ->
    data = {}
    data.path  = @$scope[@model]?[@key]?.url
    data.name  = @$scope[@model]?[@key]?.name
    data.thumb = @$scope[@model]?.thumb?.url
    return data
  fileUploadShow: (type) -> @options[type]
  disabled: =>
    el = @$element[0]
    until !el.parentElement
      return true if el.getAttribute('disabled')
      el = el.parentElement
  accept: -> @$attrs.accept || '*'

  @register(Directives.MrUpload)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
material_raingular-0.6.10 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.9 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.8 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.7 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.6 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.5 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.4 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.3 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.2.3 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.2.2 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.2.1 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee
material_raingular-0.6.2 lib/assets/javascripts/material_raingular/directives/upload/linkmodel.coffee