Browse Source

PlatformInterface >> newXhr

also deprecated IntefacingObject >> ajax:,
as InterfacingObject should be about interfacing w/ UI solely
(preparing for #1163).
Herbert Vojčík 9 years ago
parent
commit
97dc9acb87

+ 7 - 1
API-CHANGES.txt

@@ -1,7 +1,13 @@
 0.14.14:
 
-+ Environment
+* InterfacingObject >> ajax: deprecated
+
++ Environment >>
   + renamePackage:to:
++ BrowserInterface >>
+  + newXhr
++ PlatformInterface class >>
+  + newXhr
 
 
 0.14.12:

+ 26 - 0
src/Platform-Browser.js

@@ -112,6 +112,32 @@ messageSends: []
 }),
 $globals.BrowserInterface);
 
+$core.addMethod(
+$core.method({
+selector: "newXhr",
+protocol: 'actions',
+fn: function (){
+var self=this;
+function $XMLHttpRequest(){return $globals.XMLHttpRequest||(typeof XMLHttpRequest=="undefined"?nil:XMLHttpRequest)}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($XMLHttpRequest())._new();
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newXhr",{},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "newXhr\x0a\x09^ XMLHttpRequest new",
+referencedClasses: ["XMLHttpRequest"],
+//>>excludeEnd("ide");
+messageSends: ["new"]
+}),
+$globals.BrowserInterface);
+
 $core.addMethod(
 $core.method({
 selector: "prompt:",

+ 4 - 0
src/Platform-Browser.st

@@ -33,6 +33,10 @@ confirm: aString
 	^ window confirm: aString
 !
 
+newXhr
+	^ XMLHttpRequest new
+!
+
 prompt: aString
 	^ window prompt: aString
 !

+ 4 - 3
src/Platform-ImportExport.js

@@ -2822,10 +2822,11 @@ selector: "ajaxPutAt:data:onSuccess:onError:",
 protocol: 'private',
 fn: function (aURL,aString,aBlock,anotherBlock){
 var self=this;
+function $PlatformInterface(){return $globals.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._ajax_($globals.HashedCollection._newFromPairs_(["url",aURL,"type","PUT","data",aString,"contentType","text/plain;charset=UTF-8","success",aBlock,"error",anotherBlock]));
+$recv($PlatformInterface())._ajax_($globals.HashedCollection._newFromPairs_(["url",aURL,"type","PUT","data",aString,"contentType","text/plain;charset=UTF-8","success",aBlock,"error",anotherBlock]));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"ajaxPutAt:data:onSuccess:onError:",{aURL:aURL,aString:aString,aBlock:aBlock,anotherBlock:anotherBlock},$globals.PackageHandler)});
@@ -2833,8 +2834,8 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aURL", "aString", "aBlock", "anotherBlock"],
-source: "ajaxPutAt: aURL data: aString onSuccess: aBlock onError: anotherBlock\x0a\x09self\x0a\x09\x09ajax: #{\x0a\x09\x09\x09'url' -> aURL.\x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'success' -> aBlock.\x0a\x09\x09\x09'error' -> anotherBlock\x0a\x09\x09}",
-referencedClasses: [],
+source: "ajaxPutAt: aURL data: aString onSuccess: aBlock onError: anotherBlock\x0a\x09PlatformInterface\x0a\x09\x09ajax: #{\x0a\x09\x09\x09'url' -> aURL.\x0a\x09\x09\x09'type' -> 'PUT'.\x0a\x09\x09\x09'data' -> aString.\x0a\x09\x09\x09'contentType' -> 'text/plain;charset=UTF-8'.\x0a\x09\x09\x09'success' -> aBlock.\x0a\x09\x09\x09'error' -> anotherBlock\x0a\x09\x09}",
+referencedClasses: ["PlatformInterface"],
 //>>excludeEnd("ide");
 messageSends: ["ajax:"]
 }),

+ 1 - 1
src/Platform-ImportExport.st

@@ -791,7 +791,7 @@ load: aPackage
 !PackageHandler methodsFor: 'private'!
 
 ajaxPutAt: aURL data: aString onSuccess: aBlock onError: anotherBlock
-	self
+	PlatformInterface
 		ajax: #{
 			'url' -> aURL.
 			'type' -> 'PUT'.

+ 33 - 2
src/Platform-Services.js

@@ -313,6 +313,7 @@ function $PlatformInterface(){return $globals.PlatformInterface||(typeof Platfor
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $1;
+self._deprecatedAPI();
 $1=$recv($PlatformInterface())._ajax_(anObject);
 return $1;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -321,10 +322,10 @@ return $1;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anObject"],
-source: "ajax: anObject\x0a\x09^ PlatformInterface ajax: anObject",
+source: "ajax: anObject\x0a\x09self deprecatedAPI.\x0a\x09^ PlatformInterface ajax: anObject",
 referencedClasses: ["PlatformInterface"],
 //>>excludeEnd("ide");
-messageSends: ["ajax:"]
+messageSends: ["deprecatedAPI", "ajax:"]
 }),
 $globals.InterfacingObject);
 
@@ -1702,6 +1703,36 @@ messageSends: ["initialize", "ifNotNil:", "new", "ifTrue:", "isAvailable", "setW
 }),
 $globals.PlatformInterface.klass);
 
+$core.addMethod(
+$core.method({
+selector: "newXhr",
+protocol: 'actions',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $2,$1,$receiver;
+$2=self["@worker"];
+if(($receiver = $2) == null || $receiver.isNil){
+$1=self._error_("newXhr: not available");
+} else {
+$1=$recv(self["@worker"])._newXhr();
+};
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newXhr",{},$globals.PlatformInterface.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "newXhr\x0a\x09^ worker\x0a\x09\x09ifNotNil: [ worker newXhr ]\x0a\x09\x09ifNil: [ self error: 'newXhr: not available' ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifNotNil:ifNil:", "newXhr", "error:"]
+}),
+$globals.PlatformInterface.klass);
+
 $core.addMethod(
 $core.method({
 selector: "prompt:",

+ 7 - 0
src/Platform-Services.st

@@ -95,6 +95,7 @@ I am superclass of all object that interface with user or environment. `Widget`
 !InterfacingObject methodsFor: 'actions'!
 
 ajax: anObject
+	self deprecatedAPI.
 	^ PlatformInterface ajax: anObject
 !
 
@@ -397,6 +398,12 @@ existsGlobal: aString
 		ifAbsent: [ false ]
 !
 
+newXhr
+	^ worker
+		ifNotNil: [ worker newXhr ]
+		ifNil: [ self error: 'newXhr: not available' ]
+!
+
 prompt: aString
 	^ worker
 		ifNotNil: [ worker prompt: aString ]