1
0

name.st 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Smalltalk createPackage: '{%= name %}'!
  2. (Smalltalk packageAt: '{%= name %}' ifAbsent: [ self error: 'Package not created: {%= name %}' ]) imports: {'amber/jquery/Wrappers-JQuery'. 'amber/web/Web'. 'silk/Silk'}!
  3. Object subclass: #{%= name %}
  4. slots: {}
  5. package: '{%= name %}'!
  6. !{%= name %} methodsFor: 'action'!
  7. alert: aString after: aNumberOfMilliseconds
  8. [ Terminal alert: aString ] valueWithTimeout: aNumberOfMilliseconds
  9. !
  10. doAmberWith
  11. | tag |
  12. tag := (HTMLCanvas onJQuery: '#output-list' asJQuery) root.
  13. tag with: [ :html | html li with: 'Amber Web #with: added me!!' ]
  14. !
  15. doConsoleLog
  16. | greeting target |
  17. greeting := 'Hello'.
  18. target := 'world'.
  19. console log: #{ #greeting -> greeting. #target -> target. #callback -> [ console log: greeting, ', ', target, '!!' ] }
  20. !
  21. doJQueryAppend
  22. '#output-list' asJQuery append: '<li>jQuery append added me!!</li>'
  23. !
  24. doSilkTAG
  25. '#output-list' asSilk LI: 'Silk TAG: added me!!'
  26. ! !
  27. !{%= name %} methodsFor: 'starting'!
  28. augmentPage
  29. '#console-log' asSilk on: #click bind: [ self doConsoleLog ].
  30. '#timeout-alert' asSilk on: #click bind: [ self alert: 'REMINDER!!' after: 5000 ].
  31. '#amber-with' asJQuery click: [ self doAmberWith ].
  32. '#silk-tag' asSilk on: #click bind: [ self doSilkTAG ].
  33. '#jquery-append' asJQuery click: [ self doJQueryAppend ]
  34. ! !
  35. !{%= name %} class methodsFor: 'starting'!
  36. start
  37. self new augmentPage
  38. ! !