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.innerEval = function (expr) { return eval(expr); }; $pkg.transport = {"type":"amd","amdNamespace":"amber/legacy"}; $core.addClass("Counter", $globals.Widget, ["count", "header"], "Examples"); //>>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", fn: 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"); }, //>>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"] }), $globals.Counter); $core.addMethod( $core.method({ selector: "increase", protocol: "actions", fn: 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"); }, //>>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"] }), $globals.Counter); $core.addMethod( $core.method({ selector: "initialize", protocol: "initialization", fn: 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"); ($globals.Counter.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, [])); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.supercall = false; //>>excludeEnd("ctx");; $self.count=(0); return self; //>>excludeStart("ctx", pragmas.excludeDebugContexts); }, function($ctx1) {$ctx1.fill(self,"initialize",{})}); //>>excludeEnd("ctx"); }, //>>excludeStart("ide", pragmas.excludeIdeData); args: [], source: "initialize\x0a\x09super initialize.\x0a\x09count := 0", referencedClasses: [], //>>excludeEnd("ide"); pragmas: [], messageSends: ["initialize"] }), $globals.Counter); $core.addMethod( $core.method({ selector: "renderOn:", protocol: "rendering", fn: 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"); $self.header=$recv($1)._yourself(); $2=$recv(html)._button(); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["button"]=1; //>>excludeEnd("ctx"); $recv($2)._with_("++"); //>>excludeStart("ctx", pragmas.excludeDebugContexts); $ctx1.sendIdx["with:"]=2; //>>excludeEnd("ctx"); $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"); $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"); }, //>>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"] }), $globals.Counter); $core.addMethod( $core.method({ selector: "tryExample", protocol: "example", fn: 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"); }, //>>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"] }), $globals.Counter.a$cls); });