Jelajahi Sumber

Adds a css class to helios widgets

Nicolas Petton 10 tahun lalu
induk
melakukan
f276794979
2 mengubah file dengan 29 tambahan dan 4 penghapusan
  1. 22 3
      src/Helios-Core.js
  2. 7 1
      src/Helios-Core.st

+ 22 - 3
src/Helios-Core.js

@@ -1772,6 +1772,21 @@ referencedClasses: []
 }),
 globals.HLWidget);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "cssClass",
+protocol: 'accessing',
+fn: function (){
+var self=this;
+return "widget";
+},
+args: [],
+source: "cssClass\x0a\x09^ 'widget'",
+messageSends: [],
+referencedClasses: []
+}),
+globals.HLWidget);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "execute:",
@@ -1912,15 +1927,19 @@ protocol: 'rendering',
 fn: function (html){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-self["@wrapper"]=_st(html)._div();
+var $1,$2;
+$1=_st(html)._div();
+_st($1)._class_(self._cssClass());
+$2=_st($1)._yourself();
+self["@wrapper"]=$2;
 _st((function(renderer){
 return smalltalk.withContext(function($ctx2) {
 return self._renderContentOn_(renderer);
 }, function($ctx2) {$ctx2.fillBlock({renderer:renderer},$ctx1,1)})}))._appendToJQuery_(_st(self["@wrapper"])._asJQuery());
 return self}, function($ctx1) {$ctx1.fill(self,"renderOn:",{html:html},globals.HLWidget)})},
 args: ["html"],
-source: "renderOn: html\x0a\x09wrapper := html div.\x0a    [ :renderer | self renderContentOn: renderer ] appendToJQuery: wrapper asJQuery",
-messageSends: ["div", "appendToJQuery:", "renderContentOn:", "asJQuery"],
+source: "renderOn: html\x0a\x09wrapper := html div\x0a\x09\x09class: self cssClass;\x0a\x09\x09yourself.\x0a    [ :renderer | self renderContentOn: renderer ] appendToJQuery: wrapper asJQuery",
+messageSends: ["class:", "div", "cssClass", "yourself", "appendToJQuery:", "renderContentOn:", "asJQuery"],
 referencedClasses: []
 }),
 globals.HLWidget);

+ 7 - 1
src/Helios-Core.st

@@ -628,6 +628,10 @@ I provide common methods, additional behavior to widgets useful for Helios, like
 
 !HLWidget methodsFor: 'accessing'!
 
+cssClass
+	^ 'widget'
+!
+
 manager
 	^ HLManager current
 !
@@ -699,7 +703,9 @@ renderContentOn: html
 !
 
 renderOn: html
-	wrapper := html div.
+	wrapper := html div
+		class: self cssClass;
+		yourself.
     [ :renderer | self renderContentOn: renderer ] appendToJQuery: wrapper asJQuery
 ! !