Browse Source

TrappedView subclass of Widget; renderOn: used.

Herbert Vojčík 12 years ago
parent
commit
4812d3e699
3 changed files with 53 additions and 11 deletions
  1. 16 2
      js/Trapped-Frontend.deploy.js
  2. 25 6
      js/Trapped-Frontend.js
  3. 12 3
      st/Trapped-Frontend.st

+ 16 - 2
js/Trapped-Frontend.deploy.js

@@ -145,7 +145,7 @@ smalltalk.TrappedFly);
 
 
 
-smalltalk.addClass('TrappedView', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addClass('TrappedView', smalltalk.Widget, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_observe_",
 smalltalk.method({
@@ -156,13 +156,27 @@ return self}
 }),
 smalltalk.TrappedView);
 
+smalltalk.addMethod(
+"_renderOn_",
+smalltalk.method({
+selector: "renderOn:",
+fn: function (html){
+var self=this;
+smalltalk.send(html,"_with_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]),"__comma",[": contents"])]);
+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"])]);
+var el;
+el=smalltalk.send(jQuery,"_value_",[aHTMLElement]);
+smalltalk.send(el,"_empty",[]);
+smalltalk.send(self,"_appendToJQuery_",[el]);
 return self}
 }),
 smalltalk.TrappedView);

+ 25 - 6
js/Trapped-Frontend.js

@@ -190,12 +190,12 @@ smalltalk.TrappedFly);
 
 
 
-smalltalk.addClass('TrappedView', smalltalk.Object, [], 'Trapped-Frontend');
+smalltalk.addClass('TrappedView', smalltalk.Widget, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_observe_",
 smalltalk.method({
 selector: "observe:",
-category: 'not yet classified',
+category: 'initializing',
 fn: function (aFly){
 var self=this;
 return self},
@@ -206,18 +206,37 @@ referencedClasses: []
 }),
 smalltalk.TrappedView);
 
+smalltalk.addMethod(
+"_renderOn_",
+smalltalk.method({
+selector: "renderOn:",
+category: 'rendering',
+fn: function (html){
+var self=this;
+smalltalk.send(html,"_with_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]),"__comma",[": contents"])]);
+return self},
+args: ["html"],
+source: "renderOn: html\x0a\x09html with: self class name, ': contents'",
+messageSends: ["with:", ",", "name", "class"],
+referencedClasses: []
+}),
+smalltalk.TrappedView);
+
 smalltalk.addMethod(
 "_startOn_",
 smalltalk.method({
 selector: "startOn:",
-category: 'not yet classified',
+category: 'initializing',
 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"])]);
+var el;
+el=smalltalk.send(jQuery,"_value_",[aHTMLElement]);
+smalltalk.send(el,"_empty",[]);
+smalltalk.send(self,"_appendToJQuery_",[el]);
 return self},
 args: ["aHTMLElement"],
-source: "startOn: aHTMLElement\x0a\x09(jQuery value: aHTMLElement) html: self class name, ': contents'",
-messageSends: ["html:", ",", "name", "class", "value:"],
+source: "startOn: aHTMLElement\x0a\x09| el |\x0a    el := jQuery value: aHTMLElement.\x0a    el empty.\x0a    self appendToJQuery: el.",
+messageSends: ["value:", "empty", "appendToJQuery:"],
 referencedClasses: []
 }),
 smalltalk.TrappedView);

+ 12 - 3
st/Trapped-Frontend.st

@@ -74,16 +74,25 @@ start
 	Trapped current register: self name: self name
 ! !
 
-Object subclass: #TrappedView
+Widget subclass: #TrappedView
 	instanceVariableNames: ''
 	package: 'Trapped-Frontend'!
 
-!TrappedView methodsFor: 'not yet classified'!
+!TrappedView methodsFor: 'initializing'!
 
 observe: aFly
 !
 
 startOn: aHTMLElement
-	(jQuery value: aHTMLElement) html: self class name, ': contents'
+	| el |
+    el := jQuery value: aHTMLElement.
+    el empty.
+    self appendToJQuery: el.
+! !
+
+!TrappedView methodsFor: 'rendering'!
+
+renderOn: html
+	html with: self class name, ': contents'
 ! !