فهرست منبع

Crude mockup.

Herbert Vojčík 12 سال پیش
والد
کامیت
bfedd5e2ca
14فایلهای تغییر یافته به همراه554 افزوده شده و 56 حذف شده
  1. 25 0
      demo.html
  2. 0 20
      devel.html
  3. 0 7
      js/Sample.deploy.js
  4. 0 7
      js/Sample.js
  5. 13 0
      js/Trapped-Demo.deploy.js
  6. 13 0
      js/Trapped-Demo.js
  7. 171 0
      js/Trapped-Frontend.deploy.js
  8. 226 0
      js/Trapped-Frontend.js
  9. 0 4
      js/Trapped.deploy.js
  10. 0 4
      js/Trapped.js
  11. 0 9
      st/Sample.st
  12. 17 0
      st/Trapped-Demo.st
  13. 89 0
      st/Trapped-Frontend.st
  14. 0 5
      st/Trapped.st

+ 25 - 0
demo.html

@@ -0,0 +1,25 @@
+<html>
+<head>
+    <title data-trap="NameView:Name">[placeholder:Name]</title>
+    <script src="/vendor/amber/js/amber.js"></script>
+</head>
+<body>
+<script type="text/javascript">
+    loadAmber({
+        files:['Trapped-Frontend.js', 'Trapped-Demo.js'],
+        packageHome:'./',
+        ready:function () {
+            $(function() {
+                smalltalk.Browser._openOn_(smalltalk.App);
+                smalltalk.Name._start();
+                smalltalk.App._start();
+                smalltalk.Trapped._start();
+            });
+        }
+    });
+</script>
+<div data-trap="AppView:App">
+    [placeholder:App]
+</div>
+</body>
+</html>

+ 0 - 20
devel.html

@@ -1,20 +0,0 @@
-<html>
-<head>
-    <title trapped-app="Name"></title>
-    <script src="/vendor/amber/js/amber.js"></script>
-</head>
-<body>
-<script type="text/javascript">
-    loadAmber({
-        files:['Trapped.js', 'Sample.js'],
-        packageHome:'./',
-        ready:function () {
-            smalltalk.Browser._openOn_(smalltalk.Application);
-            smalltalk.Trapped._start();
-        }
-    });
-</script>
-<div trapped-app="Application">
-</div>
-</body>
-</html>

+ 0 - 7
js/Sample.deploy.js

@@ -1,7 +0,0 @@
-smalltalk.addPackage('Sample', {});
-smalltalk.addClass('Application', smalltalk.Object, [], 'Sample');
-
-
-smalltalk.addClass('Name', smalltalk.Object, [], 'Sample');
-
-

+ 0 - 7
js/Sample.js

@@ -1,7 +0,0 @@
-smalltalk.addPackage('Sample', {});
-smalltalk.addClass('Application', smalltalk.Object, [], 'Sample');
-
-
-smalltalk.addClass('Name', smalltalk.Object, [], 'Sample');
-
-

+ 13 - 0
js/Trapped-Demo.deploy.js

@@ -0,0 +1,13 @@
+smalltalk.addPackage('Trapped-Demo', {});
+smalltalk.addClass('App', smalltalk.TrappedFly, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('AppView', smalltalk.TrappedView, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('Name', smalltalk.TrappedFly, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('NameView', smalltalk.TrappedView, [], 'Trapped-Demo');
+
+

+ 13 - 0
js/Trapped-Demo.js

@@ -0,0 +1,13 @@
+smalltalk.addPackage('Trapped-Demo', {});
+smalltalk.addClass('App', smalltalk.TrappedFly, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('AppView', smalltalk.TrappedView, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('Name', smalltalk.TrappedFly, [], 'Trapped-Demo');
+
+
+smalltalk.addClass('NameView', smalltalk.TrappedView, [], 'Trapped-Demo');
+
+

+ 171 - 0
js/Trapped-Frontend.deploy.js

@@ -0,0 +1,171 @@
+smalltalk.addPackage('Trapped-Frontend', {});
+smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(self,"_subclassResponsibility",[]);
+return $1;
+}
+}),
+smalltalk.TrappedSingleton);
+
+
+smalltalk.TrappedSingleton.klass.iVarNames = ['current'];
+smalltalk.addMethod(
+"_current",
+smalltalk.method({
+selector: "current",
+fn: function (){
+var self=this;
+var $1;
+if(($receiver = self["@current"]) == nil || $receiver == undefined){
+self["@current"]=smalltalk.send(self,"_new",[]);
+$1=self["@current"];
+} else {
+$1=self["@current"];
+};
+return $1;
+}
+}),
+smalltalk.TrappedSingleton.klass);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_current",[]),"_start",[]);
+return self}
+}),
+smalltalk.TrappedSingleton.klass);
+
+
+smalltalk.addClass('Trapped', smalltalk.TrappedSingleton, ['registry'], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_byName_",
+smalltalk.method({
+selector: "byName:",
+fn: function (aString){
+var self=this;
+var $1;
+$1=smalltalk.send(self["@registry"],"_at_",[aString]);
+return $1;
+}
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+fn: function (){
+var self=this;
+self["@registry"]=smalltalk.HashedCollection._fromPairs_([]);
+return self}
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_register_name_",
+smalltalk.method({
+selector: "register:name:",
+fn: function (aFly,aString){
+var self=this;
+smalltalk.send(self["@registry"],"_at_put_",[aString,aFly]);
+return self}
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+var $1,$2;
+smalltalk.send(smalltalk.send("[data-trap]","_asJQuery",[]),"_each_",[(function(index,elem){
+var trap;
+var viewName;
+var modelName;
+var tokens;
+var model;
+var view;
+trap=smalltalk.send(smalltalk.send(jQuery,"_value_",[elem]),"_attr_",["data-trap"]);
+trap;
+tokens=smalltalk.send(trap,"_tokenize_",[":"]);
+tokens;
+viewName=smalltalk.send(tokens,"_first",[]);
+viewName;
+modelName=smalltalk.send(tokens,"_second",[]);
+modelName;
+model=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_byName_",[modelName]);
+model;
+$1=smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_at_",[viewName]),"_new",[]);
+smalltalk.send($1,"_startOn_",[elem]);
+smalltalk.send($1,"_observe_",[model]);
+$2=smalltalk.send($1,"_yourself",[]);
+view=$2;
+return view;
+})]);
+return self}
+}),
+smalltalk.Trapped);
+
+
+
+smalltalk.addClass('TrappedFly', smalltalk.TrappedSingleton, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
+}
+}),
+smalltalk.TrappedFly);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
+return self}
+}),
+smalltalk.TrappedFly);
+
+
+
+smalltalk.addClass('TrappedView', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_observe_",
+smalltalk.method({
+selector: "observe:",
+fn: function (aFly){
+var self=this;
+return self}
+}),
+smalltalk.TrappedView);
+
+smalltalk.addMethod(
+"_startOn_",
+smalltalk.method({
+selector: "startOn:",
+fn: function (aHTMLElement){
+var self=this;
+smalltalk.send(smalltalk.send(jQuery,"_value_",[aHTMLElement]),"_html_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]),"__comma",[": contents"])]);
+return self}
+}),
+smalltalk.TrappedView);
+
+
+

+ 226 - 0
js/Trapped-Frontend.js

@@ -0,0 +1,226 @@
+smalltalk.addPackage('Trapped-Frontend', {});
+smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(self,"_subclassResponsibility",[]);
+return $1;
+},
+args: [],
+source: "start\x0a\x09^ self subclassResponsibility",
+messageSends: ["subclassResponsibility"],
+referencedClasses: []
+}),
+smalltalk.TrappedSingleton);
+
+
+smalltalk.TrappedSingleton.klass.iVarNames = ['current'];
+smalltalk.addMethod(
+"_current",
+smalltalk.method({
+selector: "current",
+category: 'accessing',
+fn: function (){
+var self=this;
+var $1;
+if(($receiver = self["@current"]) == nil || $receiver == undefined){
+self["@current"]=smalltalk.send(self,"_new",[]);
+$1=self["@current"];
+} else {
+$1=self["@current"];
+};
+return $1;
+},
+args: [],
+source: "current\x0a\x09^ current ifNil: [ current := self new ]",
+messageSends: ["ifNil:", "new"],
+referencedClasses: []
+}),
+smalltalk.TrappedSingleton.klass);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_current",[]),"_start",[]);
+return self},
+args: [],
+source: "start\x0a\x09self current start",
+messageSends: ["start", "current"],
+referencedClasses: []
+}),
+smalltalk.TrappedSingleton.klass);
+
+
+smalltalk.addClass('Trapped', smalltalk.TrappedSingleton, ['registry'], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_byName_",
+smalltalk.method({
+selector: "byName:",
+category: 'accessing',
+fn: function (aString){
+var self=this;
+var $1;
+$1=smalltalk.send(self["@registry"],"_at_",[aString]);
+return $1;
+},
+args: ["aString"],
+source: "byName: aString\x0a\x09^ registry at: aString",
+messageSends: ["at:"],
+referencedClasses: []
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_initialize",
+smalltalk.method({
+selector: "initialize",
+category: 'initialization',
+fn: function (){
+var self=this;
+self["@registry"]=smalltalk.HashedCollection._fromPairs_([]);
+return self},
+args: [],
+source: "initialize\x0a\x09registry := #{}.",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_register_name_",
+smalltalk.method({
+selector: "register:name:",
+category: 'accessing',
+fn: function (aFly,aString){
+var self=this;
+smalltalk.send(self["@registry"],"_at_put_",[aString,aFly]);
+return self},
+args: ["aFly", "aString"],
+source: "register: aFly name: aString\x0a\x09registry at: aString put: aFly",
+messageSends: ["at:put:"],
+referencedClasses: []
+}),
+smalltalk.Trapped);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+var $1,$2;
+smalltalk.send(smalltalk.send("[data-trap]","_asJQuery",[]),"_each_",[(function(index,elem){
+var trap;
+var viewName;
+var modelName;
+var tokens;
+var model;
+var view;
+trap=smalltalk.send(smalltalk.send(jQuery,"_value_",[elem]),"_attr_",["data-trap"]);
+trap;
+tokens=smalltalk.send(trap,"_tokenize_",[":"]);
+tokens;
+viewName=smalltalk.send(tokens,"_first",[]);
+viewName;
+modelName=smalltalk.send(tokens,"_second",[]);
+modelName;
+model=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_byName_",[modelName]);
+model;
+$1=smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_at_",[viewName]),"_new",[]);
+smalltalk.send($1,"_startOn_",[elem]);
+smalltalk.send($1,"_observe_",[model]);
+$2=smalltalk.send($1,"_yourself",[]);
+view=$2;
+return view;
+})]);
+return self},
+args: [],
+source: "start\x0a\x09'[data-trap]' asJQuery each: [ :index :elem |\x0a    \x09| trap viewName modelName tokens model view |\x0a        trap := (jQuery value: elem) attr: 'data-trap'.\x0a        tokens := trap tokenize: ':'.\x0a        viewName := tokens first.\x0a        modelName := tokens second.\x0a       \x09model := Trapped current byName: modelName.\x0a        view := (Smalltalk current at: viewName) new\x0a        \x09startOn: elem;\x0a            observe: model;\x0a            yourself.\x0a    ]",
+messageSends: ["each:", "attr:", "value:", "tokenize:", "first", "second", "byName:", "current", "startOn:", "new", "at:", "observe:", "yourself", "asJQuery"],
+referencedClasses: ["Trapped", "Smalltalk"]
+}),
+smalltalk.Trapped);
+
+
+
+smalltalk.addClass('TrappedFly', smalltalk.TrappedSingleton, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+category: 'action',
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
+},
+args: [],
+source: "name\x0a\x09^ self class name",
+messageSends: ["name", "class"],
+referencedClasses: []
+}),
+smalltalk.TrappedFly);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
+return self},
+args: [],
+source: "start\x0a\x09Trapped current register: self name: self name",
+messageSends: ["register:name:", "name", "current"],
+referencedClasses: ["Trapped"]
+}),
+smalltalk.TrappedFly);
+
+
+
+smalltalk.addClass('TrappedView', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_observe_",
+smalltalk.method({
+selector: "observe:",
+category: 'not yet classified',
+fn: function (aFly){
+var self=this;
+return self},
+args: ["aFly"],
+source: "observe: aFly",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TrappedView);
+
+smalltalk.addMethod(
+"_startOn_",
+smalltalk.method({
+selector: "startOn:",
+category: 'not yet classified',
+fn: function (aHTMLElement){
+var self=this;
+smalltalk.send(smalltalk.send(jQuery,"_value_",[aHTMLElement]),"_html_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]),"__comma",[": contents"])]);
+return self},
+args: ["aHTMLElement"],
+source: "startOn: aHTMLElement\x0a\x09(jQuery value: aHTMLElement) html: self class name, ': contents'",
+messageSends: ["html:", ",", "name", "class", "value:"],
+referencedClasses: []
+}),
+smalltalk.TrappedView);
+
+
+

+ 0 - 4
js/Trapped.deploy.js

@@ -1,4 +0,0 @@
-smalltalk.addPackage('Trapped', {});
-smalltalk.addClass('Trapped', smalltalk.Object, [], 'Trapped');
-
-

+ 0 - 4
js/Trapped.js

@@ -1,4 +0,0 @@
-smalltalk.addPackage('Trapped', {});
-smalltalk.addClass('Trapped', smalltalk.Object, [], 'Trapped');
-
-

+ 0 - 9
st/Sample.st

@@ -1,9 +0,0 @@
-Smalltalk current createPackage: 'Sample' properties: #{}!
-Object subclass: #Application
-	instanceVariableNames: ''
-	package: 'Sample'!
-
-Object subclass: #Name
-	instanceVariableNames: ''
-	package: 'Sample'!
-

+ 17 - 0
st/Trapped-Demo.st

@@ -0,0 +1,17 @@
+Smalltalk current createPackage: 'Trapped-Demo' properties: #{}!
+TrappedFly subclass: #App
+	instanceVariableNames: ''
+	package: 'Trapped-Demo'!
+
+TrappedView subclass: #AppView
+	instanceVariableNames: ''
+	package: 'Trapped-Demo'!
+
+TrappedFly subclass: #Name
+	instanceVariableNames: ''
+	package: 'Trapped-Demo'!
+
+TrappedView subclass: #NameView
+	instanceVariableNames: ''
+	package: 'Trapped-Demo'!
+

+ 89 - 0
st/Trapped-Frontend.st

@@ -0,0 +1,89 @@
+Smalltalk current createPackage: 'Trapped-Frontend' properties: #{}!
+Object subclass: #TrappedSingleton
+	instanceVariableNames: ''
+	package: 'Trapped-Frontend'!
+
+!TrappedSingleton methodsFor: 'action'!
+
+start
+	^ self subclassResponsibility
+! !
+
+TrappedSingleton class instanceVariableNames: 'current'!
+
+!TrappedSingleton class methodsFor: 'accessing'!
+
+current
+	^ current ifNil: [ current := self new ]
+! !
+
+!TrappedSingleton class methodsFor: 'action'!
+
+start
+	self current start
+! !
+
+TrappedSingleton subclass: #Trapped
+	instanceVariableNames: 'registry'
+	package: 'Trapped-Frontend'!
+
+!Trapped methodsFor: 'accessing'!
+
+byName: aString
+	^ registry at: aString
+!
+
+register: aFly name: aString
+	registry at: aString put: aFly
+! !
+
+!Trapped methodsFor: 'action'!
+
+start
+	'[data-trap]' asJQuery each: [ :index :elem |
+    	| trap viewName modelName tokens model view |
+        trap := (jQuery value: elem) attr: 'data-trap'.
+        tokens := trap tokenize: ':'.
+        viewName := tokens first.
+        modelName := tokens second.
+       	model := Trapped current byName: modelName.
+        view := (Smalltalk current at: viewName) new
+        	startOn: elem;
+            observe: model;
+            yourself.
+    ]
+! !
+
+!Trapped methodsFor: 'initialization'!
+
+initialize
+	registry := #{}.
+! !
+
+TrappedSingleton subclass: #TrappedFly
+	instanceVariableNames: ''
+	package: 'Trapped-Frontend'!
+
+!TrappedFly methodsFor: 'action'!
+
+name
+	^ self class name
+!
+
+start
+	Trapped current register: self name: self name
+! !
+
+Object subclass: #TrappedView
+	instanceVariableNames: ''
+	package: 'Trapped-Frontend'!
+
+!TrappedView methodsFor: 'not yet classified'!
+
+observe: aFly
+!
+
+startOn: aHTMLElement
+	(jQuery value: aHTMLElement) html: self class name, ': contents'
+! !
+

+ 0 - 5
st/Trapped.st

@@ -1,5 +0,0 @@
-Smalltalk current createPackage: 'Trapped' properties: #{}!
-Object subclass: #Trapped
-	instanceVariableNames: ''
-	package: 'Trapped'!
-