123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- define(["amber/boot", "amber_core/Kernel-Objects"], function($boot){"use strict";
- if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
- if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
- var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
- if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
- $core.addPackage("Platform-Browser");
- $core.packages["Platform-Browser"].innerEval = function (expr) { return eval(expr); };
- $core.packages["Platform-Browser"].transport = {"type":"amd","amdNamespace":"amber_core"};
- $core.addClass("BrowserPlatform", $globals.Object, [], "Platform-Browser");
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.BrowserPlatform.comment="I am `Platform` service implementation for browser.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "globals",
- protocol: "accessing",
- fn: function (){
- var self=this,$self=this;
- return window;
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "globals\x0a\x09^ window",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.BrowserPlatform);
- $core.addMethod(
- $core.method({
- selector: "newXhr",
- protocol: "accessing",
- fn: function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $receiver;
- if(($receiver = $globals.XMLHttpRequest) == null || $receiver.a$nil){
- $self._error_("XMLHttpRequest not available.");
- } else {
- return $recv($globals.NativeFunction)._constructorOf_($globals.XMLHttpRequest);
- }
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"newXhr",{},$globals.BrowserPlatform)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "newXhr\x0a\x09XMLHttpRequest\x0a\x09\x09ifNotNil: [ ^ NativeFunction constructorOf: XMLHttpRequest ]\x0a\x09\x09ifNil: [ self error: 'XMLHttpRequest not available.' ]",
- referencedClasses: ["XMLHttpRequest", "NativeFunction"],
- //>>excludeEnd("ide");
- messageSends: ["ifNotNil:ifNil:", "constructorOf:", "error:"]
- }),
- $globals.BrowserPlatform);
- $core.addMethod(
- $core.method({
- selector: "initialize",
- protocol: "testing",
- fn: function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$self._isFeasible();
- if($core.assert($1)){
- $recv($globals.Platform)._registerIfNone_($self._new());
- }
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.BrowserPlatform.a$cls)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "initialize\x0a\x09self isFeasible ifTrue: [ Platform registerIfNone: self new ]",
- referencedClasses: ["Platform"],
- //>>excludeEnd("ide");
- messageSends: ["ifTrue:", "isFeasible", "registerIfNone:", "new"]
- }),
- $globals.BrowserPlatform.a$cls);
- $core.addMethod(
- $core.method({
- selector: "isFeasible",
- protocol: "testing",
- fn: function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return typeof window !== "undefined";
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"isFeasible",{},$globals.BrowserPlatform.a$cls)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "isFeasible\x0a<inlineJS: 'return typeof window !== \x22undefined\x22'>",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.BrowserPlatform.a$cls);
- $core.addClass("BrowserTerminal", $globals.Object, [], "Platform-Browser");
- //>>excludeStart("ide", pragmas.excludeIdeData);
- $globals.BrowserTerminal.comment="I am `Terminal` service implementation for browser.";
- //>>excludeEnd("ide");
- $core.addMethod(
- $core.method({
- selector: "alert:",
- protocol: "actions",
- fn: function (aString){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $recv(window)._alert_(aString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},$globals.BrowserTerminal)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "alert: aString\x0a\x09^ window alert: aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["alert:"]
- }),
- $globals.BrowserTerminal);
- $core.addMethod(
- $core.method({
- selector: "confirm:",
- protocol: "actions",
- fn: function (aString){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $recv(window)._confirm_(aString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},$globals.BrowserTerminal)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "confirm: aString\x0a\x09^ window confirm: aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["confirm:"]
- }),
- $globals.BrowserTerminal);
- $core.addMethod(
- $core.method({
- selector: "prompt:",
- protocol: "actions",
- fn: function (aString){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $recv(window)._prompt_(aString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},$globals.BrowserTerminal)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString"],
- source: "prompt: aString\x0a\x09^ window prompt: aString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["prompt:"]
- }),
- $globals.BrowserTerminal);
- $core.addMethod(
- $core.method({
- selector: "prompt:default:",
- protocol: "actions",
- fn: function (aString,defaultString){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $recv(window)._prompt_default_(aString,defaultString);
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"prompt:default:",{aString:aString,defaultString:defaultString},$globals.BrowserTerminal)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aString", "defaultString"],
- source: "prompt: aString default: defaultString\x0a\x09^ window prompt: aString default: defaultString",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["prompt:default:"]
- }),
- $globals.BrowserTerminal);
- $core.addMethod(
- $core.method({
- selector: "initialize",
- protocol: "testing",
- fn: function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- var $1;
- $1=$self._isFeasible();
- if($core.assert($1)){
- $recv($globals.Terminal)._registerIfNone_($self._new());
- }
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.BrowserTerminal.a$cls)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "initialize\x0a\x09self isFeasible ifTrue: [ Terminal registerIfNone: self new ]",
- referencedClasses: ["Terminal"],
- //>>excludeEnd("ide");
- messageSends: ["ifTrue:", "isFeasible", "registerIfNone:", "new"]
- }),
- $globals.BrowserTerminal.a$cls);
- $core.addMethod(
- $core.method({
- selector: "isFeasible",
- protocol: "testing",
- fn: function (){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return typeof window !== "undefined";
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"isFeasible",{},$globals.BrowserTerminal.a$cls)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: [],
- source: "isFeasible\x0a<inlineJS: 'return typeof window !== \x22undefined\x22'>",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.BrowserTerminal.a$cls);
- $core.addMethod(
- $core.method({
- selector: "postMessageTo:",
- protocol: "*Platform-Browser",
- fn: function (aFrame){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return $self._postMessageTo_origin_(aFrame,"*");
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"postMessageTo:",{aFrame:aFrame},$globals.Object)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aFrame"],
- source: "postMessageTo: aFrame\x0a^ self postMessageTo: aFrame origin: '*'",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: ["postMessageTo:origin:"]
- }),
- $globals.Object);
- $core.addMethod(
- $core.method({
- selector: "postMessageTo:origin:",
- protocol: "*Platform-Browser",
- fn: function (aFrame,aString){
- var self=this,$self=this;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- return $core.withContext(function($ctx1) {
- //>>excludeEnd("ctx");
- return aFrame.postMessage(self, aString);
- return self;
- //>>excludeStart("ctx", pragmas.excludeDebugContexts);
- }, function($ctx1) {$ctx1.fill(self,"postMessageTo:origin:",{aFrame:aFrame,aString:aString},$globals.Object)});
- //>>excludeEnd("ctx");
- },
- //>>excludeStart("ide", pragmas.excludeIdeData);
- args: ["aFrame", "aString"],
- source: "postMessageTo: aFrame origin: aString\x0a<inlineJS: 'return aFrame.postMessage(self, aString)'>",
- referencedClasses: [],
- //>>excludeEnd("ide");
- messageSends: []
- }),
- $globals.Object);
- });
|