Sha256: b1d836bdd88846459d9c87443969a4e672a440b6cf82d58e8092162be5b54381

Contents?: true

Size: 1009 Bytes

Versions: 4

Compression:

Stored size: 1009 Bytes

Contents

'use strict';

# TODO define componentjs required packages, as requirejs packages
observable   = require('indefinido-observable').mixin

define ->
  (widget) ->

    widget = observable widget

    # TODO transfer data from old scope to new one
    # widget.subscribe 'scope', ->

    enhance_presenter = (presenter) ->
      widget = @
      presenter.presentation         ||= {binders: {}}
      presenter.presentation.binders ||= {}

      {presentation: {binders}} = presenter


      binders['scope-*'] =
        bind: ->
          @scope_name = @args[0].replace /-/g, '_'
        routine: (element, value) ->
          widget.scope_to widget.scope[@scope_name] value

      binders.scope =

        routine: (element, value) ->
          keypath = @keypath.substring 1 if @keypath[0] == '_'
          name = "by_#{@key}_#{keypath || @keypath}"
          widget.scope_to widget.scope[name] value

    enhance_presenter.call widget, widget.presenter
    widget.subscribe 'presenter', enhance_presenter



Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ende-0.3.5 lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee
ende-0.3.4 lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee
ende-0.3.3 lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee
ende-0.3.2 lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee