| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | define("amber/Examples", ["amber_vm/smalltalk","amber_vm/nil","amber_vm/_st"], function(smalltalk,nil,_st){smalltalk.addPackage('Examples');smalltalk.packages["Examples"].transport = {"type":"amd","amdNamespace":"amber"};smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');smalltalk.Counter.comment="This is a trivial Widget example mimicking the classic Counter example in Seaside.\x0aIn order to play with it, just evaluate the doit below in a workspace.\x0aThen take a look in the HTML document above the IDE.\x0a\x0a\x09\x09Counter new appendToJQuery: 'body' asJQuery";smalltalk.addMethod(smalltalk.method({selector: "decrease",category: 'actions',fn: function (){var self=this;return smalltalk.withContext(function($ctx1) { self["@count"]=_st(self["@count"]).__minus((1));_st(self["@header"])._contents_((function(html){return smalltalk.withContext(function($ctx2) {return _st(html)._with_(_st(self["@count"])._asString());}, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));return self}, function($ctx1) {$ctx1.fill(self,"decrease",{},smalltalk.Counter)})},args: [],source: "decrease\x0a\x09count := count - 1.\x0a\x09header contents: [:html | html with: count asString]",messageSends: ["-", "contents:", "with:", "asString"],referencedClasses: []}),smalltalk.Counter);smalltalk.addMethod(smalltalk.method({selector: "increase",category: 'actions',fn: function (){var self=this;return smalltalk.withContext(function($ctx1) { self["@count"]=_st(self["@count"]).__plus((1));_st(self["@header"])._contents_((function(html){return smalltalk.withContext(function($ctx2) {return _st(html)._with_(_st(self["@count"])._asString());}, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1)})}));return self}, function($ctx1) {$ctx1.fill(self,"increase",{},smalltalk.Counter)})},args: [],source: "increase\x0a\x09count := count + 1.\x0a\x09header contents: [:html | html with: count asString]",messageSends: ["+", "contents:", "with:", "asString"],referencedClasses: []}),smalltalk.Counter);smalltalk.addMethod(smalltalk.method({selector: "initialize",category: 'initialization',fn: function (){var self=this;return smalltalk.withContext(function($ctx1) { smalltalk.Counter.superclass.fn.prototype._initialize.apply(_st(self), []);self["@count"]=(0);return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.Counter)})},args: [],source: "initialize\x0a\x09super initialize.\x0a\x09count := 0",messageSends: ["initialize"],referencedClasses: []}),smalltalk.Counter);smalltalk.addMethod(smalltalk.method({selector: "renderOn:",category: 'rendering',fn: function (html){var self=this;return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4,$5,$6;$1=_st(html)._h1();_st($1)._with_(_st(self["@count"])._asString());$2=_st($1)._yourself();self["@header"]=$2;$3=_st(html)._button();_st($3)._with_("++");$4=_st($3)._onClick_((function(){return smalltalk.withContext(function($ctx2) {return self._increase();}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));$5=_st(html)._button();_st($5)._with_("--");$6=_st($5)._onClick_((function(){return smalltalk.withContext(function($ctx2) {return self._decrease();}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},smalltalk.Counter)})},args: ["html"],source: "renderOn: html\x0a\x09header := html h1\x0a\x09with: count asString;\x0a\x09yourself.\x0a\x09html button\x0a\x09with: '++';\x0a\x09onClick: [self increase].\x0a\x09html button\x0a\x09with: '--';\x0a\x09onClick: [self decrease]",messageSends: ["with:", "asString", "h1", "yourself", "button", "onClick:", "increase", "decrease"],referencedClasses: []}),smalltalk.Counter);smalltalk.addMethod(smalltalk.method({selector: "tryExample",category: 'example',fn: function (){var self=this;return smalltalk.withContext(function($ctx1) { _st(self._new())._appendToJQuery_("body"._asJQuery());return self}, function($ctx1) {$ctx1.fill(self,"tryExample",{},smalltalk.Counter.klass)})},args: [],source: "tryExample\x0a\x09\x22In order to play with the Counter, just select the\x0a\x09doit below and press the Do it button. Then take a\x0a\x09look in the HTML document above the IDE.\x22\x0a\x0a\x09\x22Counter tryExample\x22\x0a\x09\x09self new appendToJQuery: 'body' asJQuery",messageSends: ["appendToJQuery:", "asJQuery", "new"],referencedClasses: []}),smalltalk.Counter.klass);});
 |