|
@@ -1511,6 +1511,99 @@ smalltalk.Boolean);
|
|
|
|
|
|
|
|
|
|
|
|
+smalltalk.addClass('BrowserInterface', smalltalk.Object, [], 'Kernel-Objects');
|
|
|
+smalltalk.BrowserInterface.comment="I am superclass of all object that interface with user or environment. `Widget` and a few other classes are subclasses of me.\x0a\x0a## API\x0a\x0a self alert: 'Hey, there is a problem'.\x0a self confirm: 'Affirmative?'.\x0a self prompt: 'Your name:'.\x0a\x0a self ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.\x0a";
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "ajax:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (anObject){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(jQuery)._ajax_(anObject);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},smalltalk.BrowserInterface)})},
|
|
|
+args: ["anObject"],
|
|
|
+source: "ajax: anObject\x0a\x09^jQuery ajax: anObject",
|
|
|
+messageSends: ["ajax:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.BrowserInterface);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "alert:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(window)._alert_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},smalltalk.BrowserInterface)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "alert: aString\x0a\x09^window alert: aString",
|
|
|
+messageSends: ["alert:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.BrowserInterface);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "confirm:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(window)._confirm_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},smalltalk.BrowserInterface)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "confirm: aString\x0a\x09^window confirm: aString",
|
|
|
+messageSends: ["confirm:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.BrowserInterface);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "isAvailable",
|
|
|
+category: 'testing',
|
|
|
+fn: function (){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+return typeof window !== "undefined" && typeof jQuery !== "undefined";
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"isAvailable",{},smalltalk.BrowserInterface)})},
|
|
|
+args: [],
|
|
|
+source: "isAvailable\x0a<return typeof window !== \x22undefined\x22 && typeof jQuery !== \x22undefined\x22>",
|
|
|
+messageSends: [],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.BrowserInterface);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "prompt:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st(window)._prompt_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},smalltalk.BrowserInterface)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "prompt: aString\x0a\x09^window prompt: aString",
|
|
|
+messageSends: ["prompt:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.BrowserInterface);
|
|
|
+
|
|
|
+
|
|
|
+smalltalk.BrowserInterface.klass.iVarNames = ['uiWorker','ajaxWorker'];
|
|
|
+
|
|
|
smalltalk.addClass('Date', smalltalk.Object, [], 'Kernel-Objects');
|
|
|
smalltalk.Date.comment="I am used to work with both dates and times. Therefore `Date today` and `Date now` are both valid in\x0aAmber and answer the same date object.\x0a\x0aDate directly maps to the `Date()` JavaScript constructor, and Amber date objects are JavaScript date objects.\x0a\x0a## API\x0a\x0aThe class-side `instance creation` protocol contains some convenience methods for creating date/time objects such as `#fromSeconds:`.\x0a\x0aArithmetic and comparison is supported (see the `comparing` and `arithmetic` protocols).\x0a\x0aThe `converting` protocol provides convenience methods for various convertions (to numbers, strings, etc.).";
|
|
|
smalltalk.addMethod(
|
|
@@ -2886,6 +2979,86 @@ referencedClasses: []
|
|
|
smalltalk.InspectorHandler.klass);
|
|
|
|
|
|
|
|
|
+smalltalk.addClass('InterfacingObject', smalltalk.Object, [], 'Kernel-Objects');
|
|
|
+smalltalk.InterfacingObject.comment="I am superclass of all object that interface with user or environment. `Widget` and a few other classes are subclasses of me.\x0a\x0a## API\x0a\x0a self alert: 'Hey, there is a problem'.\x0a self confirm: 'Affirmative?'.\x0a self prompt: 'Your name:'.\x0a\x0a self ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.\x0a";
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "ajax:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (anObject){
|
|
|
+var self=this;
|
|
|
+function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st($PlatformInterface())._ajax_(anObject);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},smalltalk.InterfacingObject)})},
|
|
|
+args: ["anObject"],
|
|
|
+source: "ajax: anObject\x0a\x09^PlatformInterface ajax: anObject",
|
|
|
+messageSends: ["ajax:"],
|
|
|
+referencedClasses: ["PlatformInterface"]
|
|
|
+}),
|
|
|
+smalltalk.InterfacingObject);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "alert:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st($PlatformInterface())._alert_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},smalltalk.InterfacingObject)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "alert: aString\x0a\x09^PlatformInterface alert: aString",
|
|
|
+messageSends: ["alert:"],
|
|
|
+referencedClasses: ["PlatformInterface"]
|
|
|
+}),
|
|
|
+smalltalk.InterfacingObject);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "confirm:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st($PlatformInterface())._confirm_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},smalltalk.InterfacingObject)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "confirm: aString\x0a\x09^PlatformInterface confirm: aString",
|
|
|
+messageSends: ["confirm:"],
|
|
|
+referencedClasses: ["PlatformInterface"]
|
|
|
+}),
|
|
|
+smalltalk.InterfacingObject);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "prompt:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1;
|
|
|
+$1=_st($PlatformInterface())._prompt_(aString);
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},smalltalk.InterfacingObject)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "prompt: aString\x0a\x09^PlatformInterface prompt: aString",
|
|
|
+messageSends: ["prompt:"],
|
|
|
+referencedClasses: ["PlatformInterface"]
|
|
|
+}),
|
|
|
+smalltalk.InterfacingObject);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
smalltalk.addClass('JSObjectProxy', smalltalk.Object, ['jsObject'], 'Kernel-Objects');
|
|
|
smalltalk.JSObjectProxy.comment="I handle sending messages to JavaScript objects, making JavaScript object accessing from Amber fully transparent.\x0aMy instances make intensive use of `#doesNotUnderstand:`.\x0a\x0aMy instances are automatically created by Amber whenever a message is sent to a JavaScript object.\x0a\x0a## Usage examples\x0a\x0aJSObjectProxy objects are instanciated by Amber when a Smalltalk message is sent to a JavaScript object.\x0a\x0a\x09window alert: 'hello world'.\x0a\x09window inspect.\x0a\x09(window jQuery: 'body') append: 'hello world'\x0a\x0aAmber messages sends are converted to JavaScript function calls or object property access _(in this order)_. If n one of them match, a `MessageNotUnderstood` error will be thrown.\x0a\x0a## Message conversion rules\x0a\x0a- `someUser name` becomes `someUser.name`\x0a- `someUser name: 'John'` becomes `someUser name = \x22John\x22`\x0a- `console log: 'hello world'` becomes `console.log('hello world')`\x0a- `(window jQuery: 'foo') css: 'background' color: 'red'` becomes `window.jQuery('foo').css('background', 'red')`\x0a\x0a__Note:__ For keyword-based messages, only the first keyword is kept: `window foo: 1 bar: 2` is equivalent to `window foo: 1 baz: 2`.";
|
|
|
smalltalk.addMethod(
|
|
@@ -4461,6 +4634,145 @@ referencedClasses: ["ClassSorterNode", "Array"]
|
|
|
smalltalk.Package.klass);
|
|
|
|
|
|
|
|
|
+smalltalk.addClass('PlatformInterface', smalltalk.Object, [], 'Kernel-Objects');
|
|
|
+smalltalk.PlatformInterface.comment="I am superclass of all object that interface with user or environment. `Widget` and a few other classes are subclasses of me.\x0a\x0a## API\x0a\x0a self alert: 'Hey, there is a problem'.\x0a self confirm: 'Affirmative?'.\x0a self prompt: 'Your name:'.\x0a\x0a self ajax: #{\x0a 'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'\x0a }.\x0a";
|
|
|
+
|
|
|
+smalltalk.PlatformInterface.klass.iVarNames = ['worker'];
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "ajax:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (anObject){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $2,$1;
|
|
|
+$2=self["@worker"];
|
|
|
+if(($receiver = $2) == nil || $receiver == undefined){
|
|
|
+$1=self._error_("ajax: not available");
|
|
|
+} else {
|
|
|
+$1=_st(self["@worker"])._ajax_(anObject);
|
|
|
+};
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: ["anObject"],
|
|
|
+source: "ajax: anObject\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker ajax: anObject ]\x0a\x09\x09ifNil: [ self error: 'ajax: not available' ]",
|
|
|
+messageSends: ["ifNotNil:ifNil:", "ajax:", "error:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "alert:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $2,$1;
|
|
|
+$2=self["@worker"];
|
|
|
+if(($receiver = $2) == nil || $receiver == undefined){
|
|
|
+$1=self._error_("alert: not available");
|
|
|
+} else {
|
|
|
+$1=_st(self["@worker"])._alert_(aString);
|
|
|
+};
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "alert: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker alert: aString ]\x0a\x09\x09ifNil: [ self error: 'alert: not available' ]",
|
|
|
+messageSends: ["ifNotNil:ifNil:", "alert:", "error:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "confirm:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $2,$1;
|
|
|
+$2=self["@worker"];
|
|
|
+if(($receiver = $2) == nil || $receiver == undefined){
|
|
|
+$1=self._error_("confirm: not available");
|
|
|
+} else {
|
|
|
+$1=_st(self["@worker"])._confirm_(aString);
|
|
|
+};
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "confirm: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker confirm: aString ]\x0a\x09\x09ifNil: [ self error: 'confirm: not available' ]",
|
|
|
+messageSends: ["ifNotNil:ifNil:", "confirm:", "error:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "initialize",
|
|
|
+category: 'initialization',
|
|
|
+fn: function (){
|
|
|
+var self=this;
|
|
|
+var candidate;
|
|
|
+function $BrowserInterface(){return smalltalk.BrowserInterface||(typeof BrowserInterface=="undefined"?nil:BrowserInterface)}
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $1,$2;
|
|
|
+smalltalk.PlatformInterface.klass.superclass.fn.prototype._initialize.apply(_st(self), []);
|
|
|
+candidate=_st($BrowserInterface())._new();
|
|
|
+$1=_st(candidate)._isAvailable();
|
|
|
+if(smalltalk.assert($1)){
|
|
|
+self._setWorker_(candidate);
|
|
|
+$2=self;
|
|
|
+return $2;
|
|
|
+};
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"initialize",{candidate:candidate},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: [],
|
|
|
+source: "initialize\x0a\x09| candidate |\x0a\x09\x0a\x09super initialize.\x0a\x09\x0a\x09candidate := BrowserInterface new.\x0a\x09candidate isAvailable ifTrue: [ self setWorker: candidate. ^self ]",
|
|
|
+messageSends: ["initialize", "new", "ifTrue:", "setWorker:", "isAvailable"],
|
|
|
+referencedClasses: ["BrowserInterface"]
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "prompt:",
|
|
|
+category: 'actions',
|
|
|
+fn: function (aString){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+var $2,$1;
|
|
|
+$2=self["@worker"];
|
|
|
+if(($receiver = $2) == nil || $receiver == undefined){
|
|
|
+$1=self._error_("prompt: not available");
|
|
|
+} else {
|
|
|
+$1=_st(self["@worker"])._prompt_(aString);
|
|
|
+};
|
|
|
+return $1;
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: ["aString"],
|
|
|
+source: "prompt: aString\x0a\x09^worker\x0a\x09\x09ifNotNil: [ worker prompt: aString ]\x0a\x09\x09ifNil: [ self error: 'prompt: not available' ]",
|
|
|
+messageSends: ["ifNotNil:ifNil:", "prompt:", "error:"],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+smalltalk.addMethod(
|
|
|
+smalltalk.method({
|
|
|
+selector: "setWorker:",
|
|
|
+category: 'accessing',
|
|
|
+fn: function (anObject){
|
|
|
+var self=this;
|
|
|
+return smalltalk.withContext(function($ctx1) {
|
|
|
+self["@worker"]=anObject;
|
|
|
+return self}, function($ctx1) {$ctx1.fill(self,"setWorker:",{anObject:anObject},smalltalk.PlatformInterface.klass)})},
|
|
|
+args: ["anObject"],
|
|
|
+source: "setWorker: anObject\x0a\x09worker := anObject",
|
|
|
+messageSends: [],
|
|
|
+referencedClasses: []
|
|
|
+}),
|
|
|
+smalltalk.PlatformInterface.klass);
|
|
|
+
|
|
|
+
|
|
|
smalltalk.addClass('Point', smalltalk.Object, ['x', 'y'], 'Kernel-Objects');
|
|
|
smalltalk.Point.comment="I represent an x-y pair of numbers usually designating a geometric coordinate.\x0a\x0a## API\x0a\x0aInstances are traditionally created using the binary `#@` message to a number:\x0a\x0a\x09100@120\x0a\x0aPoints can then be arithmetically manipulated:\x0a\x0a\x09100@100 + (10@10)\x0a\x0a...or for example:\x0a\x0a\x09(100@100) * 2\x0a\x0a**NOTE:** Creating a point with a negative y-value will need a space after `@` in order to avoid a parsing error:\x0a\x0a\x09100@ -100 \x22but 100@-100 would not parse\x22";
|
|
|
smalltalk.addMethod(
|