Moka-Controllers.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. define("amber_core/Moka-Controllers", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Moka-Core"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Moka-Controllers');
  3. smalltalk.packages["Moka-Controllers"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('MKAnyKeyInputController', smalltalk.MKAspectController, ['lastValue'], 'Moka-Controllers');
  5. smalltalk.MKAnyKeyInputController.comment="I am the default controller for `MKTextAreaView`. Actions are performed on any key press if the view's value changes.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "inputText",
  9. category: 'accessing',
  10. fn: function (){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. $1=_st(self._view())._value();
  15. return $1;
  16. }, function($ctx1) {$ctx1.fill(self,"inputText",{},smalltalk.MKAnyKeyInputController)})},
  17. args: [],
  18. source: "inputText\x0a\x09^ self view value",
  19. messageSends: ["value", "view"],
  20. referencedClasses: []
  21. }),
  22. smalltalk.MKAnyKeyInputController);
  23. smalltalk.addMethod(
  24. smalltalk.method({
  25. selector: "onKeyPressed:",
  26. category: 'actions',
  27. fn: function (anEvent){
  28. var self=this;
  29. var newValue;
  30. return smalltalk.withContext(function($ctx1) {
  31. var $1;
  32. newValue=self._inputText();
  33. $1=_st(newValue).__eq(self["@lastValue"]);
  34. if(smalltalk.assert($1)){
  35. return self;
  36. };
  37. self["@lastValue"]=newValue;
  38. self._performActionWith_(newValue);
  39. return self}, function($ctx1) {$ctx1.fill(self,"onKeyPressed:",{anEvent:anEvent,newValue:newValue},smalltalk.MKAnyKeyInputController)})},
  40. args: ["anEvent"],
  41. source: "onKeyPressed: anEvent\x0a\x09| newValue |\x0a\x09\x0a\x09newValue := self inputText.\x0a\x09newValue = lastValue ifTrue: [ ^ self ].\x0a\x09\x0a\x09lastValue := newValue.\x0a\x09self performActionWith: newValue",
  42. messageSends: ["inputText", "ifTrue:", "=", "performActionWith:"],
  43. referencedClasses: []
  44. }),
  45. smalltalk.MKAnyKeyInputController);
  46. smalltalk.addClass('MKEnterInputController', smalltalk.MKAnyKeyInputController, [], 'Moka-Controllers');
  47. smalltalk.MKEnterInputController.comment="I am the default controller for `MKInputView`. \x0aActions are performed on 'enter' key press.";
  48. smalltalk.addMethod(
  49. smalltalk.method({
  50. selector: "onKeyPressed:",
  51. category: 'actions',
  52. fn: function (anEvent){
  53. var self=this;
  54. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  55. return smalltalk.withContext(function($ctx1) {
  56. var $1;
  57. $1=_st(_st(anEvent)._keyCode()).__eq(_st(_st($String())._cr())._asciiValue());
  58. if(smalltalk.assert($1)){
  59. smalltalk.MKEnterInputController.superclass.fn.prototype._onKeyPressed_.apply(_st(self), [anEvent]);
  60. };
  61. return self}, function($ctx1) {$ctx1.fill(self,"onKeyPressed:",{anEvent:anEvent},smalltalk.MKEnterInputController)})},
  62. args: ["anEvent"],
  63. source: "onKeyPressed: anEvent\x0a\x09anEvent keyCode = String cr asciiValue ifTrue: [\x0a\x09\x09super onKeyPressed: anEvent ]",
  64. messageSends: ["ifTrue:", "=", "keyCode", "asciiValue", "cr", "onKeyPressed:"],
  65. referencedClasses: ["String"]
  66. }),
  67. smalltalk.MKEnterInputController);
  68. smalltalk.addClass('MKButtonController', smalltalk.MKAspectController, [], 'Moka-Controllers');
  69. smalltalk.MKButtonController.comment="I am the default controller for `MKButtonView`.";
  70. smalltalk.addMethod(
  71. smalltalk.method({
  72. selector: "onPressed",
  73. category: 'actions',
  74. fn: function (){
  75. var self=this;
  76. return smalltalk.withContext(function($ctx1) {
  77. self._performAction();
  78. return self}, function($ctx1) {$ctx1.fill(self,"onPressed",{},smalltalk.MKButtonController)})},
  79. args: [],
  80. source: "onPressed\x0a\x09self performAction",
  81. messageSends: ["performAction"],
  82. referencedClasses: []
  83. }),
  84. smalltalk.MKButtonController);
  85. smalltalk.addClass('MKCheckboxController', smalltalk.MKAspectController, [], 'Moka-Controllers');
  86. smalltalk.MKCheckboxController.comment="I am the default controller for `MKCheckboxView`.";
  87. smalltalk.addMethod(
  88. smalltalk.method({
  89. selector: "onToggled:",
  90. category: 'actions',
  91. fn: function (aBoolean){
  92. var self=this;
  93. return smalltalk.withContext(function($ctx1) {
  94. self._performActionWith_(aBoolean);
  95. return self}, function($ctx1) {$ctx1.fill(self,"onToggled:",{aBoolean:aBoolean},smalltalk.MKCheckboxController)})},
  96. args: ["aBoolean"],
  97. source: "onToggled: aBoolean\x0a\x09self performActionWith: aBoolean",
  98. messageSends: ["performActionWith:"],
  99. referencedClasses: []
  100. }),
  101. smalltalk.MKCheckboxController);
  102. });