Sha256: 61ad8194e1c4c8ce50bf4da053f7e5c73e2960c51f168d2124e805bf45d2346d

Contents?: true

Size: 938 Bytes

Versions: 28

Compression:

Stored size: 938 Bytes

Contents

# //= require ./angular_scoped_model
@ModalModels ||= {}
class @MaterialModalModel extends AngularScopedModel
  @locals: (args...) ->
    @$inject ||= []
    @$inject.merge(args)
    @$locals = args
  @inject: (args...) ->
    args.push('$scope','$rootScope','$mdDialog')
    @$inject ||= []
    @$inject.merge(args)
  constructor: (args...) ->
    # Bind injected dependencies on scope ie @$scope
    for key, index in @constructor.$inject || []
      @[key] = args[index]
    for key in @constructor.$locals || []
      @$scope[key] = @[key]
    @$scope.hide = @$scope.cancel = @$scope.close = @$mdDialog.hide

    # Bind all functions not begining with _ to scope
    for key, val of @constructor.prototype
      continue if key in ['constructor', 'initialize'] or key[0] is '_'
      @$scope[key] = if (typeof val is 'function') then val.bind?(@) || _.bind(val, @) else val

    # Run initialize function if exists
    @initialize?()

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
material_raingular-0.2.8.6 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.8.5 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.8 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.7 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.6.3 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.6.2 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.6.1 lib/assets/javascripts/super_classes/material_modal_model.coffee
material_raingular-0.2.6 lib/assets/javascripts/super_classes/material_modal_model.coffee