define(["amber/boot", "require", "amber/web/Web"], function($boot,requirejs){"use strict"; var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals; var $pkg = $core.addPackage("Examples"); $pkg.transport = {"type":"amd","amdNamespace":"amber/legacy"}; $core.addClass("Counter", $globals.Widget, "Examples"); $core.setSlots($globals.Counter, ["count", "header"]); //>>excludeStart("ide", pragmas.excludeIdeData); $globals.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 tryExample"; //>>excludeEnd("ide"); $core.addMethod( $core.method({ selector: "decrease", protocol: "actions", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "decrease\x0a\x09count := count - 1.\x0a\x09header contents: [ :html | html with: count asString ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["-", "contents:", "with:", "asString"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self.count=$recv($self.count).__minus((1)); $recv($self.header)._contents_((function(html){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(html)._with_($recv($self.count)._asString()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)}); //>>excludeEnd("ctx"); })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"decrease",{})}); //>>excludeEnd("ctx"); }; }), $globals.Counter); $core.addMethod( $core.method({ selector: "increase", protocol: "actions", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "increase\x0a\x09count := count + 1.\x0a\x09header contents: [ :html | html with: count asString ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["+", "contents:", "with:", "asString"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $self.count=$recv($self.count).__plus((1)); $recv($self.header)._contents_((function(html){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $recv(html)._with_($recv($self.count)._asString()); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({html:html},$ctx1,1)}); //>>excludeEnd("ctx"); })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"increase",{})}); //>>excludeEnd("ctx"); }; }), $globals.Counter); $core.addMethod( $core.method({ selector: "initialize", protocol: "initialization", //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "initialize\x0a\x09super initialize.\x0a\x09count := 0", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["initialize"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); [( //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = true, //>>excludeEnd("ctx"); ($methodClass.superclass||$boot.nilAsClass).fn.prototype._initialize.call($self)) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.supercall = false //>>excludeEnd("ctx"); ][0]; $self.count=(0); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"initialize",{})}); //>>excludeEnd("ctx"); }; }), $globals.Counter); $core.addMethod( $core.method({ selector: "renderOn:", protocol: "rendering", //>>excludeStart("ide", pragmas.excludeIdeData); args: ["html"], source: "renderOn: html\x0a\x09header := html h1\x0a\x09\x09with: count asString;\x0a\x09\x09yourself.\x0a\x09html button\x0a\x09\x09with: '++';\x0a\x09\x09onClick: [ self increase ].\x0a\x09html button\x0a\x09\x09with: '--';\x0a\x09\x09onClick: [ self decrease ]", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["with:", "h1", "asString", "yourself", "button", "onClick:", "increase", "decrease"] }, function ($methodClass){ return function (html){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); var $1,$2,$3; $1=$recv(html)._h1(); [$recv($1)._with_($recv($self.count)._asString()) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["with:"]=1 //>>excludeEnd("ctx"); ][0]; $self.header=$recv($1)._yourself(); $2=[$recv(html)._button() //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["button"]=1 //>>excludeEnd("ctx"); ][0]; [$recv($2)._with_("++") //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["with:"]=2 //>>excludeEnd("ctx"); ][0]; [$recv($2)._onClick_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $self._increase(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)}); //>>excludeEnd("ctx"); })) //>>excludeStart("ctx", pragmas.excludeDebugContexts); ,$ctx1.sendIdx["onClick:"]=1 //>>excludeEnd("ctx"); ][0]; $3=$recv(html)._button(); $recv($3)._with_("--"); $recv($3)._onClick_((function(){ //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx2) { //>>excludeEnd("ctx"); return $self._decrease(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)}); //>>excludeEnd("ctx"); })); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html})}); //>>excludeEnd("ctx"); }; }), $globals.Counter); $core.addMethod( $core.method({ selector: "tryExample", protocol: "example", //>>excludeStart("ide", pragmas.excludeIdeData); 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 appendToBrush: 'body' asBrush", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["appendToBrush:", "new", "asBrush"] }, function ($methodClass){ return function (){ var self=this,$self=this; //>>excludeStart("ctx", pragmas.excludeDebugContexts); return $core.withContext(function($ctx1) { //>>excludeEnd("ctx"); $recv($self._new())._appendToBrush_("body"._asBrush()); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"tryExample",{})}); //>>excludeEnd("ctx"); }; }), $globals.Counter.a$cls); });