123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- Smalltalk current createPackage: 'Trapped-Frontend' properties: #{}!
- Object subclass: #TrappedFly
- instanceVariableNames: ''
- package: 'Trapped-Frontend'!
- !TrappedFly methodsFor: 'action'!
- name
- ^ self class name
- !
- start
- Trapped current register: self name: self name
- ! !
- !TrappedFly class methodsFor: 'action'!
- start
- self new start
- ! !
- Object subclass: #TrappedSingleton
- instanceVariableNames: ''
- package: 'Trapped-Frontend'!
- !TrappedSingleton methodsFor: 'action'!
- start
- ^ self subclassResponsibility
- ! !
- TrappedSingleton class instanceVariableNames: 'current'!
- !TrappedSingleton class methodsFor: 'accessing'!
- current
- ^ current ifNil: [ current := self new ]
- ! !
- !TrappedSingleton class methodsFor: 'action'!
- start
- self current start
- ! !
- TrappedSingleton subclass: #Trapped
- instanceVariableNames: 'registry'
- package: 'Trapped-Frontend'!
- !Trapped methodsFor: 'accessing'!
- byName: aString
- ^ registry at: aString
- !
- register: aFly name: aString
- registry at: aString put: aFly
- ! !
- !Trapped methodsFor: 'action'!
- start
- '[data-trap]' asJQuery each: [ :index :elem |
- | trap jq viewName modelName tokens |
- jq := elem asJQuery.
- trap := jq attr: 'data-trap'.
- tokens := trap tokenize: ':'.
- viewName := tokens first.
- modelName := tokens second.
- { modelName } trapDescend: [(Smalltalk current at: viewName) new appendToJQuery: jq].
- ]
- ! !
- !Trapped methodsFor: 'initialization'!
- initialize
- super initialize.
- registry := #{}.
- ! !
- !Trapped class methodsFor: 'accessing'!
- path
- ^TrappedPathStack current elements
- ! !
- TrappedSingleton subclass: #TrappedPathStack
- instanceVariableNames: 'elements'
- package: 'Trapped-Frontend'!
- !TrappedPathStack methodsFor: 'accessing'!
- elements
- ^elements
- ! !
- !TrappedPathStack methodsFor: 'descending'!
- append: anArray
- elements := elements, anArray
- !
- with: anArray do: aBlock
- | old |
- old := elements.
- [ self append: anArray.
- aBlock value ] ensure: [ elements := old ]
- ! !
- !TrappedPathStack methodsFor: 'initialization'!
- initialize
- elements := #().
- ! !
- Widget subclass: #TrappedView
- instanceVariableNames: ''
- package: 'Trapped-Frontend'!
- !TrappedView methodsFor: 'rendering'!
- renderOn: html
- html root empty.
- html with: self class name, ': ', Trapped path
- ! !
- !Array methodsFor: '*Trapped-Frontend'!
- trapDescend: aBlock
- TrappedPathStack current with: self do: aBlock
- ! !
- !Array methodsFor: '*Trapped-Frontend'!
- trapDescend: aBlock
- TrappedPathStack current with: self do: aBlock
- ! !
|