Browse Source

Platform-Browser introduced

Herbert Vojčík 9 years ago
parent
commit
40d951add7

+ 0 - 49
contrib/src/Web.js

@@ -5301,55 +5301,6 @@ messageSends: ["append:", "asString"]
 }),
 $globals.Object);
 
-$core.addMethod(
-$core.method({
-selector: "postMessageTo:",
-protocol: '*Web',
-fn: function (aFrame){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=self._postMessageTo_origin_(aFrame,"*");
-return $1;
-//>>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: '*Web',
-fn: function (aFrame,aString){
-var 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<return aFrame.postMessage(self, aString)>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Object);
-
 $core.addMethod(
 $core.method({
 selector: "appendToBrush:",

+ 0 - 8
contrib/src/Web.st

@@ -1075,14 +1075,6 @@ appendToBrush: aTagBrush
 
 appendToJQuery: aJQuery
 	aJQuery append: self asString
-!
-
-postMessageTo: aFrame
-^ self postMessageTo: aFrame origin: '*'
-!
-
-postMessageTo: aFrame origin: aString
-<return aFrame.postMessage(self, aString)>
 ! !
 
 !String methodsFor: '*Web'!

+ 0 - 155
contrib/src/Wrappers-JQuery.js

@@ -13,161 +13,6 @@ $core.packages["Wrappers-JQuery"].innerEval = function (expr) { return eval(expr
 $core.packages["Wrappers-JQuery"].imports = ["jQuery=jquery"];
 $core.packages["Wrappers-JQuery"].transport = {"type":"amd","amdNamespace":"amber-contrib-jquery"};
 
-$core.addClass('BrowserInterface', $globals.Object, [], 'Wrappers-JQuery');
-//>>excludeStart("ide", pragmas.excludeIdeData);
-$globals.BrowserInterface.comment="I am platform interface class that tries to use window and jQuery; that is, one for browser environment.\x0a\x0a## API\x0a\x0a    self isAvailable. \x22true if window and jQuery exist\x22.\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    }.";
-//>>excludeEnd("ide");
-$core.addMethod(
-$core.method({
-selector: "ajax:",
-protocol: 'actions',
-fn: function (anObject){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(jQuery)._ajax_(anObject);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},$globals.BrowserInterface)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["anObject"],
-source: "ajax: anObject\x0a\x09^ jQuery ajax: anObject",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["ajax:"]
-}),
-$globals.BrowserInterface);
-
-$core.addMethod(
-$core.method({
-selector: "alert:",
-protocol: 'actions',
-fn: function (aString){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(window)._alert_(aString);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},$globals.BrowserInterface)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "alert: aString\x0a\x09^ window alert: aString",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["alert:"]
-}),
-$globals.BrowserInterface);
-
-$core.addMethod(
-$core.method({
-selector: "confirm:",
-protocol: 'actions',
-fn: function (aString){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(window)._confirm_(aString);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},$globals.BrowserInterface)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "confirm: aString\x0a\x09^ window confirm: aString",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["confirm:"]
-}),
-$globals.BrowserInterface);
-
-$core.addMethod(
-$core.method({
-selector: "isAvailable",
-protocol: 'testing',
-fn: function (){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return typeof window !== "undefined" && typeof jQuery !== "undefined";
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"isAvailable",{},$globals.BrowserInterface)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "isAvailable\x0a<return typeof window !== \x22undefined\x22 && typeof jQuery !== \x22undefined\x22>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.BrowserInterface);
-
-$core.addMethod(
-$core.method({
-selector: "prompt:",
-protocol: 'actions',
-fn: function (aString){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(window)._prompt_(aString);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},$globals.BrowserInterface)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "prompt: aString\x0a\x09^ window prompt: aString",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["prompt:"]
-}),
-$globals.BrowserInterface);
-
-$core.addMethod(
-$core.method({
-selector: "prompt:default:",
-protocol: 'actions',
-fn: function (aString,defaultString){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-var $1;
-$1=$recv(window)._prompt_default_(aString,defaultString);
-return $1;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"prompt:default:",{aString:aString,defaultString:defaultString},$globals.BrowserInterface)});
-//>>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.BrowserInterface);
-
-
-
 $core.addClass('JQuery', $globals.Object, [], 'Wrappers-JQuery');
 
 $core.addMethod(

+ 0 - 46
contrib/src/Wrappers-JQuery.st

@@ -1,51 +1,5 @@
 Smalltalk createPackage: 'Wrappers-JQuery'!
 (Smalltalk packageAt: 'Wrappers-JQuery') imports: {'jQuery' -> 'jquery'}!
-Object subclass: #BrowserInterface
-	instanceVariableNames: ''
-	package: 'Wrappers-JQuery'!
-!BrowserInterface commentStamp!
-I am platform interface class that tries to use window and jQuery; that is, one for browser environment.
-
-## API
-
-    self isAvailable. "true if window and jQuery exist".
-
-    self alert: 'Hey, there is a problem'.
-    self confirm: 'Affirmative?'.
-    self prompt: 'Your name:'.
-
-    self ajax: #{
-        'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'
-    }.!
-
-!BrowserInterface methodsFor: 'actions'!
-
-ajax: anObject
-	^ jQuery ajax: anObject
-!
-
-alert: aString
-	^ window alert: aString
-!
-
-confirm: aString
-	^ window confirm: aString
-!
-
-prompt: aString
-	^ window prompt: aString
-!
-
-prompt: aString default: defaultString
-	^ window prompt: aString default: defaultString
-! !
-
-!BrowserInterface methodsFor: 'testing'!
-
-isAvailable
-<return typeof window !!== "undefined" && typeof jQuery !!== "undefined">
-! !
-
 Object subclass: #JQuery
 	instanceVariableNames: ''
 	package: 'Wrappers-JQuery'!

+ 220 - 0
src/Platform-Browser.js

@@ -0,0 +1,220 @@
+define("amber_core/Platform-Browser", ["amber/boot"
+//>>excludeStart("imports", pragmas.excludeImports);
+, "amber-contrib-jquery/Wrappers-JQuery"
+//>>excludeEnd("imports");
+, "amber_core/Kernel-Objects"], function($boot
+//>>excludeStart("imports", pragmas.excludeImports);
+
+//>>excludeEnd("imports");
+){
+var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
+$core.addPackage('Platform-Browser');
+$core.packages["Platform-Browser"].innerEval = function (expr) { return eval(expr); };
+$core.packages["Platform-Browser"].imports = ["amber-contrib-jquery/Wrappers-JQuery"];
+$core.packages["Platform-Browser"].transport = {"type":"amd","amdNamespace":"amber_core"};
+
+$core.addClass('BrowserInterface', $globals.Object, [], 'Platform-Browser');
+//>>excludeStart("ide", pragmas.excludeIdeData);
+$globals.BrowserInterface.comment="I am platform interface class that tries to use window and jQuery; that is, one for browser environment.\x0a\x0a## API\x0a\x0a    self isAvailable. \x22true if window and jQuery exist\x22.\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    }.";
+//>>excludeEnd("ide");
+$core.addMethod(
+$core.method({
+selector: "ajax:",
+protocol: 'actions',
+fn: function (anObject){
+var self=this;
+function $JQuery(){return $globals.JQuery||(typeof JQuery=="undefined"?nil:JQuery)}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv($recv($JQuery())._current())._ajax_(anObject);
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"ajax:",{anObject:anObject},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject"],
+source: "ajax: anObject\x0a\x09^ JQuery current ajax: anObject",
+referencedClasses: ["JQuery"],
+//>>excludeEnd("ide");
+messageSends: ["ajax:", "current"]
+}),
+$globals.BrowserInterface);
+
+$core.addMethod(
+$core.method({
+selector: "alert:",
+protocol: 'actions',
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(window)._alert_(aString);
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"alert:",{aString:aString},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "alert: aString\x0a\x09^ window alert: aString",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["alert:"]
+}),
+$globals.BrowserInterface);
+
+$core.addMethod(
+$core.method({
+selector: "confirm:",
+protocol: 'actions',
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(window)._confirm_(aString);
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"confirm:",{aString:aString},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "confirm: aString\x0a\x09^ window confirm: aString",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["confirm:"]
+}),
+$globals.BrowserInterface);
+
+$core.addMethod(
+$core.method({
+selector: "isAvailable",
+protocol: 'testing',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return typeof window !== "undefined" && typeof jQuery !== "undefined";
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isAvailable",{},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "isAvailable\x0a<return typeof window !== \x22undefined\x22 && typeof jQuery !== \x22undefined\x22>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.BrowserInterface);
+
+$core.addMethod(
+$core.method({
+selector: "prompt:",
+protocol: 'actions',
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(window)._prompt_(aString);
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"prompt:",{aString:aString},$globals.BrowserInterface)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "prompt: aString\x0a\x09^ window prompt: aString",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["prompt:"]
+}),
+$globals.BrowserInterface);
+
+$core.addMethod(
+$core.method({
+selector: "prompt:default:",
+protocol: 'actions',
+fn: function (aString,defaultString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=$recv(window)._prompt_default_(aString,defaultString);
+return $1;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"prompt:default:",{aString:aString,defaultString:defaultString},$globals.BrowserInterface)});
+//>>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.BrowserInterface);
+
+
+$core.addMethod(
+$core.method({
+selector: "postMessageTo:",
+protocol: '*Platform-Browser',
+fn: function (aFrame){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1;
+$1=self._postMessageTo_origin_(aFrame,"*");
+return $1;
+//>>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;
+//>>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<return aFrame.postMessage(self, aString)>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Object);
+
+});

+ 58 - 0
src/Platform-Browser.st

@@ -0,0 +1,58 @@
+Smalltalk createPackage: 'Platform-Browser'!
+(Smalltalk packageAt: 'Platform-Browser') imports: {'amber-contrib-jquery/Wrappers-JQuery'}!
+Object subclass: #BrowserInterface
+	instanceVariableNames: ''
+	package: 'Platform-Browser'!
+!BrowserInterface commentStamp!
+I am platform interface class that tries to use window and jQuery; that is, one for browser environment.
+
+## API
+
+    self isAvailable. "true if window and jQuery exist".
+
+    self alert: 'Hey, there is a problem'.
+    self confirm: 'Affirmative?'.
+    self prompt: 'Your name:'.
+
+    self ajax: #{
+        'url' -> '/patch.js'. 'type' -> 'GET'. dataType->'script'
+    }.!
+
+!BrowserInterface methodsFor: 'actions'!
+
+ajax: anObject
+	^ JQuery current ajax: anObject
+!
+
+alert: aString
+	^ window alert: aString
+!
+
+confirm: aString
+	^ window confirm: aString
+!
+
+prompt: aString
+	^ window prompt: aString
+!
+
+prompt: aString default: defaultString
+	^ window prompt: aString default: defaultString
+! !
+
+!BrowserInterface methodsFor: 'testing'!
+
+isAvailable
+<return typeof window !!== "undefined" && typeof jQuery !!== "undefined">
+! !
+
+!Object methodsFor: '*Platform-Browser'!
+
+postMessageTo: aFrame
+^ self postMessageTo: aFrame origin: '*'
+!
+
+postMessageTo: aFrame origin: aString
+<return aFrame.postMessage(self, aString)>
+! !
+

+ 1 - 0
support/deploy.js

@@ -9,6 +9,7 @@ define([
     'amber_core/Kernel-Exceptions',
     'amber_core/Kernel-Transcript',
     'amber_core/Kernel-Announcements',
+    'amber_core/Platform-Browser',
     'amber-contrib-web/Web'
     // --- packages of the core Amber end here ---
 ], function (amber) { return amber; });