Explorar el Código

Use JQuery data instead of index of item in list for lookup

Ryan Simmons hace 10 años
padre
commit
2f06c3b496
Se han modificado 4 ficheros con 136 adiciones y 227 borrados
  1. 15 12
      js/Helios-Browser.js
  2. 107 181
      js/Helios-Core.js
  3. 1 2
      st/Helios-Browser.st
  4. 13 32
      st/Helios-Core.st

+ 15 - 12
js/Helios-Browser.js

@@ -1755,25 +1755,28 @@ fn: function (aClass,anInteger,html){
 var self=this;
 var self=this;
 var li;
 var li;
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-var $1,$3,$4,$2;
+var $1,$2,$4,$6,$5,$3;
 li=_st(html)._li();
 li=_st(html)._li();
-$1=li;
-_st($1)._at_put_("list-data",self._listDataKeyFor_(aClass));
-_st($1)._class_(self._listCssClassForItem_(aClass));
+$1=_st(li)._asJQuery();
+$ctx1.sendIdx["asJQuery"]=1;
+_st($1)._data_put_("item",aClass);
+$2=li;
+_st($2)._class_(self._listCssClassForItem_(aClass));
 $ctx1.sendIdx["class:"]=1;
 $ctx1.sendIdx["class:"]=1;
-$2=_st($1)._with_((function(){
+$3=_st($2)._with_((function(){
 return smalltalk.withContext(function($ctx2) {
 return smalltalk.withContext(function($ctx2) {
-$3=_st(html)._a();
-_st($3)._with_((function(){
+$4=_st(html)._a();
+_st($4)._with_((function(){
 return smalltalk.withContext(function($ctx3) {
 return smalltalk.withContext(function($ctx3) {
 _st(_st(html)._tag_("i"))._class_(self._cssClassForItem_(aClass));
 _st(_st(html)._tag_("i"))._class_(self._cssClassForItem_(aClass));
 return self._renderItemLabel_level_on_(aClass,anInteger,html);
 return self._renderItemLabel_level_on_(aClass,anInteger,html);
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
-$4=_st($3)._onClick_((function(){
+$5=_st($4)._onClick_((function(){
 return smalltalk.withContext(function($ctx3) {
 return smalltalk.withContext(function($ctx3) {
-return self._activateListItem_(_st(li)._asJQuery());
+$6=_st(li)._asJQuery();
+return self._activateListItem_($6);
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
-return $4;
+return $5;
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
 $ctx1.sendIdx["with:"]=1;
 $ctx1.sendIdx["with:"]=1;
 _st(self._getChildrenOf_(aClass))._do_((function(each){
 _st(self._getChildrenOf_(aClass))._do_((function(each){
@@ -1782,8 +1785,8 @@ return self._renderItem_level_on_(each,_st(anInteger).__plus((1)),html);
 }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
 }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,4)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"renderItem:level:on:",{aClass:aClass,anInteger:anInteger,html:html,li:li},smalltalk.HLClassesListWidget)})},
 return self}, function($ctx1) {$ctx1.fill(self,"renderItem:level:on:",{aClass:aClass,anInteger:anInteger,html:html,li:li},smalltalk.HLClassesListWidget)})},
 args: ["aClass", "anInteger", "html"],
 args: ["aClass", "anInteger", "html"],
-source: "renderItem: aClass level: anInteger on: html\x0a\x09| li |\x0a    \x0a\x09li := html li.\x0a\x09\x0a    li\x0a    \x09at: 'list-data' put: (self listDataKeyFor: aClass);\x0a\x09\x09class: (self listCssClassForItem: aClass);\x0a\x09\x09with: [ \x0a        \x09html a\x0a            \x09with: [ \x0a            \x09\x09(html tag: 'i') class: (self cssClassForItem: aClass).\x0a  \x09\x09\x09\x09\x09self renderItemLabel: aClass level: anInteger on: html ];\x0a\x09\x09\x09\x09onClick: [\x0a                  \x09self activateListItem: li asJQuery ] ].\x0a                    \x0a    (self getChildrenOf: aClass) do: [ :each |\x0a    \x09self renderItem: each level: anInteger + 1 on: html ]",
-messageSends: ["li", "at:put:", "listDataKeyFor:", "class:", "listCssClassForItem:", "with:", "a", "tag:", "cssClassForItem:", "renderItemLabel:level:on:", "onClick:", "activateListItem:", "asJQuery", "do:", "getChildrenOf:", "renderItem:level:on:", "+"],
+source: "renderItem: aClass level: anInteger on: html\x0a\x09| li |\x0a    \x0a\x09li := html li.\x0a\x09li asJQuery data: 'item' put: aClass.\x0a    li\x0a\x09\x09class: (self listCssClassForItem: aClass);\x0a\x09\x09with: [ \x0a        \x09html a\x0a            \x09with: [ \x0a            \x09\x09(html tag: 'i') class: (self cssClassForItem: aClass).\x0a  \x09\x09\x09\x09\x09self renderItemLabel: aClass level: anInteger on: html ];\x0a\x09\x09\x09\x09onClick: [\x0a                  \x09self activateListItem: li asJQuery ] ].\x0a                    \x0a    (self getChildrenOf: aClass) do: [ :each |\x0a    \x09self renderItem: each level: anInteger + 1 on: html ]",
+messageSends: ["li", "data:put:", "asJQuery", "class:", "listCssClassForItem:", "with:", "a", "tag:", "cssClassForItem:", "renderItemLabel:level:on:", "onClick:", "activateListItem:", "do:", "getChildrenOf:", "renderItem:level:on:", "+"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
 smalltalk.HLClassesListWidget);
 smalltalk.HLClassesListWidget);

+ 107 - 181
js/Helios-Core.js

@@ -1,10 +1,7 @@
-define("amber_core/Helios-Core", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Infrastructure", "amber_core/Canvas", "amber_core/Helios-Exceptions"], function(smalltalk,nil,_st){
+define("amber_core/Helios-Core", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Infrastructure", "amber_core/Canvas"], function(smalltalk,nil,_st){
 smalltalk.addPackage('Helios-Core');
 smalltalk.addPackage('Helios-Core');
 smalltalk.packages["Helios-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
 smalltalk.packages["Helios-Core"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
 
-smalltalk.addClass('HLListItemNotFound', smalltalk.HLError, [], 'Helios-Core');
-
-
 smalltalk.addClass('HLModel', smalltalk.InterfacingObject, ['announcer', 'environment'], 'Helios-Core');
 smalltalk.addClass('HLModel', smalltalk.InterfacingObject, ['announcer', 'environment'], 'Helios-Core');
 smalltalk.HLModel.comment="I am the abstract superclass of all models of Helios.\x0aI am the \x22Model\x22 part of the MVC pattern implementation in Helios.\x0a\x0aI provide access to an `Environment` object and both a local (model-specific) and global (system-specific) announcer.\x0a\x0aThe `#withChangesDo:` method is handy for performing model changes ensuring that all widgets are aware of the change and can prevent it from happening.\x0a\x0aModifications of the system should be done via commands (see `HLCommand` and subclasses).";
 smalltalk.HLModel.comment="I am the abstract superclass of all models of Helios.\x0aI am the \x22Model\x22 part of the MVC pattern implementation in Helios.\x0a\x0aI provide access to an `Environment` object and both a local (model-specific) and global (system-specific) announcer.\x0a\x0aThe `#withChangesDo:` method is handy for performing model changes ensuring that all widgets are aware of the change and can prevent it from happening.\x0a\x0aModifications of the system should be done via commands (see `HLCommand` and subclasses).";
 smalltalk.addMethod(
 smalltalk.addMethod(
@@ -2168,33 +2165,13 @@ selector: "activateItem:",
 category: 'actions',
 category: 'actions',
 fn: function (anObject){
 fn: function (anObject){
 var self=this;
 var self=this;
-var listData;
-function $HLListItemNotFound(){return smalltalk.HLListItemNotFound||(typeof HLListItemNotFound=="undefined"?nil:HLListItemNotFound)}
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-var $3,$5,$4,$2,$1;
-var $early={};
-try {
-listData=_st((function(){
-return smalltalk.withContext(function($ctx2) {
-return self._listDataKeyFor_(anObject);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($HLListItemNotFound(),(function(){
-return smalltalk.withContext(function($ctx2) {
-throw $early=[self];
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
-$3=_st(self["@wrapper"])._asJQuery();
-$5="li[list-data=\x22".__comma(listData);
-$4=_st($5).__comma("\x22]");
-$ctx1.sendIdx[","]=1;
-$2=_st($3)._find_($4);
-$1=_st($2)._eq_((0));
-self._activateListItem_($1);
-return self}
-catch(e) {if(e===$early)return e[0]; throw e}
-}, function($ctx1) {$ctx1.fill(self,"activateItem:",{anObject:anObject,listData:listData},smalltalk.HLListWidget)})},
+self._activateListItem_(self._findListItemFor_(anObject));
+return self}, function($ctx1) {$ctx1.fill(self,"activateItem:",{anObject:anObject},smalltalk.HLListWidget)})},
 args: ["anObject"],
 args: ["anObject"],
-source: "activateItem: anObject\x0a\x09| listData |\x0a\x09listData := [self listDataKeyFor: anObject] on: HLListItemNotFound do: [^self].\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)",
-messageSends: ["on:do:", "listDataKeyFor:", "activateListItem:", "eq:", "find:", "asJQuery", ","],
-referencedClasses: ["HLListItemNotFound"]
+source: "activateItem: anObject\x0a\x09self activateListItem: (self findListItemFor: anObject)",
+messageSends: ["activateListItem:", "findListItemFor:"],
+referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
 
 
@@ -2216,15 +2193,15 @@ $1;
 _st(_st(_st(aListItem)._parent())._children())._removeClass_("active");
 _st(_st(_st(aListItem)._parent())._children())._removeClass_("active");
 _st(aListItem)._addClass_("active");
 _st(aListItem)._addClass_("active");
 self._ensureVisible_(aListItem);
 self._ensureVisible_(aListItem);
-item=_st(self._items())._at_(_st(_st(aListItem)._attr_("list-data"))._asNumber());
+item=_st(aListItem)._data_("item");
 $2=_st(self._selectedItem()).__eq_eq(item);
 $2=_st(self._selectedItem()).__eq_eq(item);
 if(! smalltalk.assert($2)){
 if(! smalltalk.assert($2)){
 self._selectItem_(item);
 self._selectItem_(item);
 };
 };
 return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,item:item},smalltalk.HLListWidget)})},
 return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,item:item},smalltalk.HLListWidget)})},
 args: ["aListItem"],
 args: ["aListItem"],
-source: "activateListItem: aListItem\x0a\x09| item |\x0a\x09\x0a\x09(aListItem get: 0) ifNil: [ ^self ].\x0a\x09aListItem parent children removeClass: 'active'.\x0a\x09aListItem addClass: 'active'.\x0a    \x0a\x09self ensureVisible: aListItem.\x0a    \x0a   \x22Activate the corresponding item\x22\x0a   item := (self items at: (aListItem attr: 'list-data') asNumber).\x0a   self selectedItem == item ifFalse: [\x0a\x09   self selectItem: item ]",
-messageSends: ["ifNil:", "get:", "removeClass:", "children", "parent", "addClass:", "ensureVisible:", "at:", "items", "asNumber", "attr:", "ifFalse:", "==", "selectedItem", "selectItem:"],
+source: "activateListItem: aListItem\x0a\x09| item |\x0a\x09\x0a\x09(aListItem get: 0) ifNil: [ ^self ].\x0a\x09aListItem parent children removeClass: 'active'.\x0a\x09aListItem addClass: 'active'.\x0a    \x0a\x09self ensureVisible: aListItem.\x0a    \x0a   \x22Activate the corresponding item\x22\x0a   item := aListItem data: 'item'.\x0a   self selectedItem == item ifFalse: [\x0a\x09   self selectItem: item ]",
+messageSends: ["ifNil:", "get:", "removeClass:", "children", "parent", "addClass:", "ensureVisible:", "data:", "ifFalse:", "==", "selectedItem", "selectItem:"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
@@ -2319,65 +2296,99 @@ fn: function (aListItem){
 var self=this;
 var self=this;
 var parent,position;
 var parent,position;
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-var $4,$3,$2,$5,$9,$8,$11,$10,$7,$6,$1,$16,$15,$17,$14,$18,$13,$19,$24,$23,$25,$22,$27,$29,$28,$26,$21,$20,$12;
+var $1,$5,$4,$3,$6,$10,$9,$12,$11,$8,$7,$2,$17,$16,$18,$15,$19,$14,$20,$25,$24,$26,$23,$28,$30,$29,$27,$22,$21,$13;
+$1=_st(aListItem)._get_((0));
+$ctx1.sendIdx["get:"]=1;
+if(($receiver = $1) == nil || $receiver == null){
+return self;
+} else {
+$1;
+};
 position=self._positionOf_(aListItem);
 position=self._positionOf_(aListItem);
 parent=_st(aListItem)._parent();
 parent=_st(aListItem)._parent();
-$4=_st(aListItem)._position();
+$5=_st(aListItem)._position();
 $ctx1.sendIdx["position"]=1;
 $ctx1.sendIdx["position"]=1;
-$3=_st($4)._top();
+$4=_st($5)._top();
 $ctx1.sendIdx["top"]=1;
 $ctx1.sendIdx["top"]=1;
-$2=_st($3).__lt((0));
-if(smalltalk.assert($2)){
-$5=_st(parent)._get_((0));
-$ctx1.sendIdx["get:"]=1;
-$9=_st(parent)._get_((0));
+$3=_st($4).__lt((0));
+if(smalltalk.assert($3)){
+$6=_st(parent)._get_((0));
 $ctx1.sendIdx["get:"]=2;
 $ctx1.sendIdx["get:"]=2;
-$8=_st($9)._scrollTop();
+$10=_st(parent)._get_((0));
+$ctx1.sendIdx["get:"]=3;
+$9=_st($10)._scrollTop();
 $ctx1.sendIdx["scrollTop"]=1;
 $ctx1.sendIdx["scrollTop"]=1;
-$11=_st(aListItem)._position();
+$12=_st(aListItem)._position();
 $ctx1.sendIdx["position"]=2;
 $ctx1.sendIdx["position"]=2;
-$10=_st($11)._top();
+$11=_st($12)._top();
 $ctx1.sendIdx["top"]=2;
 $ctx1.sendIdx["top"]=2;
-$7=_st($8).__plus($10);
+$8=_st($9).__plus($11);
 $ctx1.sendIdx["+"]=1;
 $ctx1.sendIdx["+"]=1;
-$6=_st($7).__minus((10));
+$7=_st($8).__minus((10));
 $ctx1.sendIdx["-"]=1;
 $ctx1.sendIdx["-"]=1;
-$1=_st($5)._scrollTop_($6);
+$2=_st($6)._scrollTop_($7);
 $ctx1.sendIdx["scrollTop:"]=1;
 $ctx1.sendIdx["scrollTop:"]=1;
 };
 };
-$16=_st(aListItem)._position();
+$17=_st(aListItem)._position();
 $ctx1.sendIdx["position"]=3;
 $ctx1.sendIdx["position"]=3;
-$15=_st($16)._top();
+$16=_st($17)._top();
 $ctx1.sendIdx["top"]=3;
 $ctx1.sendIdx["top"]=3;
-$17=_st(aListItem)._height();
+$18=_st(aListItem)._height();
 $ctx1.sendIdx["height"]=1;
 $ctx1.sendIdx["height"]=1;
-$14=_st($15).__plus($17);
+$15=_st($16).__plus($18);
 $ctx1.sendIdx["+"]=2;
 $ctx1.sendIdx["+"]=2;
-$18=_st(parent)._height();
+$19=_st(parent)._height();
 $ctx1.sendIdx["height"]=2;
 $ctx1.sendIdx["height"]=2;
-$13=_st($14).__gt($18);
-if(smalltalk.assert($13)){
-$19=_st(parent)._get_((0));
-$ctx1.sendIdx["get:"]=3;
-$24=_st(parent)._get_((0));
-$23=_st($24)._scrollTop();
-$25=_st(aListItem)._height();
+$14=_st($15).__gt($19);
+if(smalltalk.assert($14)){
+$20=_st(parent)._get_((0));
+$ctx1.sendIdx["get:"]=4;
+$25=_st(parent)._get_((0));
+$24=_st($25)._scrollTop();
+$26=_st(aListItem)._height();
 $ctx1.sendIdx["height"]=3;
 $ctx1.sendIdx["height"]=3;
-$22=_st($23).__plus($25);
-$27=_st(parent)._height();
-$29=_st(aListItem)._position();
-$28=_st($29)._top();
-$26=_st($27).__minus($28);
-$21=_st($22).__minus($26);
+$23=_st($24).__plus($26);
+$28=_st(parent)._height();
+$30=_st(aListItem)._position();
+$29=_st($30)._top();
+$27=_st($28).__minus($29);
+$22=_st($23).__minus($27);
 $ctx1.sendIdx["-"]=2;
 $ctx1.sendIdx["-"]=2;
-$20=_st($21).__plus((10));
+$21=_st($22).__plus((10));
 $ctx1.sendIdx["+"]=3;
 $ctx1.sendIdx["+"]=3;
-$12=_st($19)._scrollTop_($20);
+$13=_st($20)._scrollTop_($21);
 };
 };
 return self}, function($ctx1) {$ctx1.fill(self,"ensureVisible:",{aListItem:aListItem,parent:parent,position:position},smalltalk.HLListWidget)})},
 return self}, function($ctx1) {$ctx1.fill(self,"ensureVisible:",{aListItem:aListItem,parent:parent,position:position},smalltalk.HLListWidget)})},
 args: ["aListItem"],
 args: ["aListItem"],
-source: "ensureVisible: aListItem\x09\x0a\x09\x22Move the scrollbar to show the active element\x22\x0a\x09\x0a\x09| parent position |\x0a\x09\x0a\x09position := self positionOf: aListItem.\x0a\x09parent := aListItem parent.\x0a\x09\x0a    aListItem position top < 0 ifTrue: [\x0a\x09\x09(parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem position top - 10) ].\x0a    aListItem position top + aListItem height > parent height ifTrue: [ \x0a\x09\x09(parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem height - (parent height - aListItem position top)) +10 ]",
-messageSends: ["positionOf:", "parent", "ifTrue:", "<", "top", "position", "scrollTop:", "get:", "-", "+", "scrollTop", ">", "height"],
+source: "ensureVisible: aListItem\x09\x0a\x09\x22Move the scrollbar to show the active element\x22\x0a\x09\x0a\x09| parent position |\x0a\x09(aListItem get: 0) ifNil: [ ^self ].\x0a\x09position := self positionOf: aListItem.\x0a\x09parent := aListItem parent.\x0a\x09\x0a    aListItem position top < 0 ifTrue: [\x0a\x09\x09(parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem position top - 10) ].\x0a    aListItem position top + aListItem height > parent height ifTrue: [ \x0a\x09\x09(parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem height - (parent height - aListItem position top)) +10 ]",
+messageSends: ["ifNil:", "get:", "positionOf:", "parent", "ifTrue:", "<", "top", "position", "scrollTop:", "-", "+", "scrollTop", ">", "height"],
+referencedClasses: []
+}),
+smalltalk.HLListWidget);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "findListItemFor:",
+category: 'accessing',
+fn: function (anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $4,$3,$6,$5,$2,$1;
+$4=_st(self["@wrapper"])._asJQuery();
+$ctx1.sendIdx["asJQuery"]=1;
+$3=_st($4)._find_("li");
+$2=_st($3)._filter_(_st((function(thisArg,otherArg){
+return smalltalk.withContext(function($ctx2) {
+$6=_st(thisArg)._asJQuery();
+$5=_st($6)._data_("item");
+return _st($5).__eq(anObject);
+}, function($ctx2) {$ctx2.fillBlock({thisArg:thisArg,otherArg:otherArg},$ctx1,1)})}))._currySelf());
+$1=_st($2)._eq_((0));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"findListItemFor:",{anObject:anObject},smalltalk.HLListWidget)})},
+args: ["anObject"],
+source: "findListItemFor: anObject\x0a\x09^(((wrapper asJQuery find: 'li') \x0a\x09\x09filter: [:thisArg :otherArg | (thisArg asJQuery data: 'item') = anObject] currySelf) eq: 0)",
+messageSends: ["eq:", "filter:", "find:", "asJQuery", "currySelf", "=", "data:"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
@@ -2471,28 +2482,6 @@ referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
 
 
-smalltalk.addMethod(
-smalltalk.method({
-selector: "listDataKeyFor:",
-category: 'actions',
-fn: function (anObject){
-var self=this;
-function $HLListItemNotFound(){return smalltalk.HLListItemNotFound||(typeof HLListItemNotFound=="undefined"?nil:HLListItemNotFound)}
-return smalltalk.withContext(function($ctx1) { 
-var $1;
-$1=_st(_st(self._items())._indexOf_ifAbsent_(anObject,(function(){
-return smalltalk.withContext(function($ctx2) {
-return _st($HLListItemNotFound())._signal();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._asString();
-return $1;
-}, function($ctx1) {$ctx1.fill(self,"listDataKeyFor:",{anObject:anObject},smalltalk.HLListWidget)})},
-args: ["anObject"],
-source: "listDataKeyFor: anObject\x0a\x09^(self items indexOf: anObject ifAbsent: [HLListItemNotFound signal]) asString",
-messageSends: ["asString", "indexOf:ifAbsent:", "items", "signal"],
-referencedClasses: ["HLListItemNotFound"]
-}),
-smalltalk.HLListWidget);
-
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
 selector: "positionOf:",
 selector: "positionOf:",
@@ -2517,34 +2506,14 @@ selector: "refresh",
 category: 'actions',
 category: 'actions',
 fn: function (){
 fn: function (){
 var self=this;
 var self=this;
-var listData;
-function $HLListItemNotFound(){return smalltalk.HLListItemNotFound||(typeof HLListItemNotFound=="undefined"?nil:HLListItemNotFound)}
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-var $3,$5,$4,$2,$1;
-var $early={};
-try {
 smalltalk.HLListWidget.superclass.fn.prototype._refresh.apply(_st(self), []);
 smalltalk.HLListWidget.superclass.fn.prototype._refresh.apply(_st(self), []);
-listData=_st((function(){
-return smalltalk.withContext(function($ctx2) {
-return self._listDataKeyFor_(self._selectedItem());
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($HLListItemNotFound(),(function(){
-return smalltalk.withContext(function($ctx2) {
-throw $early=[self];
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
-$3=_st(self["@wrapper"])._asJQuery();
-$5="li[list-data=\x22".__comma(listData);
-$4=_st($5).__comma("\x22]");
-$ctx1.sendIdx[","]=1;
-$2=_st($3)._find_($4);
-$1=_st($2)._eq_((0));
-self._ensureVisible_($1);
-return self}
-catch(e) {if(e===$early)return e[0]; throw e}
-}, function($ctx1) {$ctx1.fill(self,"refresh",{listData:listData},smalltalk.HLListWidget)})},
+self._ensureVisible_(self._findListItemFor_(self._selectedItem()));
+return self}, function($ctx1) {$ctx1.fill(self,"refresh",{},smalltalk.HLListWidget)})},
 args: [],
 args: [],
-source: "refresh\x0a\x09| listData |\x0a\x0a\x09super refresh.\x0a\x09listData := [self listDataKeyFor: self selectedItem] on: HLListItemNotFound do: [^self].\x0a\x09self ensureVisible: ((wrapper asJQuery find: 'li[list-data=\x22', listData , '\x22]') eq: 0)\x0a\x09",
-messageSends: ["refresh", "on:do:", "listDataKeyFor:", "selectedItem", "ensureVisible:", "eq:", "find:", "asJQuery", ","],
-referencedClasses: ["HLListItemNotFound"]
+source: "refresh\x0a\x09super refresh.\x0a\x09self ensureVisible: (self findListItemFor: self selectedItem)",
+messageSends: ["refresh", "ensureVisible:", "findListItemFor:", "selectedItem"],
+referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
 
 
@@ -2596,53 +2565,40 @@ smalltalk.HLListWidget);
 
 
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
-selector: "renderItem:dataKey:on:",
+selector: "renderItem:on:",
 category: 'rendering',
 category: 'rendering',
-fn: function (anObject,aString,html){
+fn: function (anObject,html){
 var self=this;
 var self=this;
 var li;
 var li;
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-var $1,$3,$4,$2;
+var $1,$2,$4,$6,$5,$3;
 li=_st(html)._li();
 li=_st(html)._li();
-$1=li;
-_st($1)._at_put_("list-data",aString);
-_st($1)._class_(self._listCssClassForItem_(anObject));
+$1=_st(li)._asJQuery();
+$ctx1.sendIdx["asJQuery"]=1;
+_st($1)._data_put_("item",anObject);
+$2=li;
+_st($2)._class_(self._listCssClassForItem_(anObject));
 $ctx1.sendIdx["class:"]=1;
 $ctx1.sendIdx["class:"]=1;
-$2=_st($1)._with_((function(){
+$3=_st($2)._with_((function(){
 return smalltalk.withContext(function($ctx2) {
 return smalltalk.withContext(function($ctx2) {
-$3=_st(html)._a();
-_st($3)._with_((function(){
+$4=_st(html)._a();
+_st($4)._with_((function(){
 return smalltalk.withContext(function($ctx3) {
 return smalltalk.withContext(function($ctx3) {
 _st(_st(html)._tag_("i"))._class_(self._cssClassForItem_(anObject));
 _st(_st(html)._tag_("i"))._class_(self._cssClassForItem_(anObject));
 return self._renderItemLabel_on_(anObject,html);
 return self._renderItemLabel_on_(anObject,html);
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
-$4=_st($3)._onClick_((function(){
+$5=_st($4)._onClick_((function(){
 return smalltalk.withContext(function($ctx3) {
 return smalltalk.withContext(function($ctx3) {
-return self._activateListItem_(_st(li)._asJQuery());
+$6=_st(li)._asJQuery();
+return self._activateListItem_($6);
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
 }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
-return $4;
+return $5;
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
 $ctx1.sendIdx["with:"]=1;
 $ctx1.sendIdx["with:"]=1;
-return self}, function($ctx1) {$ctx1.fill(self,"renderItem:dataKey:on:",{anObject:anObject,aString:aString,html:html,li:li},smalltalk.HLListWidget)})},
-args: ["anObject", "aString", "html"],
-source: "renderItem: anObject dataKey: aString on: html\x0a\x09| li |\x0a    \x0a\x09li := html li.\x0a\x09\x0a    li\x0a        at: 'list-data' put: aString;\x0a\x09\x09class: (self listCssClassForItem: anObject);\x0a        with: [ \x0a        \x09html a\x0a            \x09with: [ \x0a            \x09\x09(html tag: 'i') class: (self cssClassForItem: anObject).\x0a  \x09\x09\x09\x09\x09self renderItemLabel: anObject on: html ];\x0a\x09\x09\x09\x09onClick: [\x0a                  \x09self activateListItem: li asJQuery ] ]",
-messageSends: ["li", "at:put:", "class:", "listCssClassForItem:", "with:", "a", "tag:", "cssClassForItem:", "renderItemLabel:on:", "onClick:", "activateListItem:", "asJQuery"],
-referencedClasses: []
-}),
-smalltalk.HLListWidget);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "renderItem:on:",
-category: 'rendering',
-fn: function (anObject,html){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-self._renderItem_dataKey_on_(anObject,self._listDataKeyFor_(anObject),html);
-return self}, function($ctx1) {$ctx1.fill(self,"renderItem:on:",{anObject:anObject,html:html},smalltalk.HLListWidget)})},
+return self}, function($ctx1) {$ctx1.fill(self,"renderItem:on:",{anObject:anObject,html:html,li:li},smalltalk.HLListWidget)})},
 args: ["anObject", "html"],
 args: ["anObject", "html"],
-source: "renderItem: anObject on: html\x0a\x09self renderItem: anObject dataKey: (self listDataKeyFor: anObject) on: html",
-messageSends: ["renderItem:dataKey:on:", "listDataKeyFor:"],
+source: "renderItem: anObject on: html\x0a\x09| li |\x0a    \x0a\x09li := html li.\x0a\x09li asJQuery data: 'item' put: anObject.\x0a    li\x0a\x09\x09class: (self listCssClassForItem: anObject);\x0a        with: [ \x0a        \x09html a\x0a            \x09with: [ \x0a            \x09\x09(html tag: 'i') class: (self cssClassForItem: anObject).\x0a  \x09\x09\x09\x09\x09self renderItemLabel: anObject on: html ];\x0a\x09\x09\x09\x09onClick: [\x0a                  \x09self activateListItem: li asJQuery ] ]",
+messageSends: ["li", "data:put:", "asJQuery", "class:", "listCssClassForItem:", "with:", "a", "tag:", "cssClassForItem:", "renderItemLabel:on:", "onClick:", "activateListItem:"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
@@ -2670,14 +2626,14 @@ category: 'rendering',
 fn: function (html){
 fn: function (html){
 var self=this;
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 return smalltalk.withContext(function($ctx1) { 
-_st(self._items())._withIndexDo_((function(each,index){
+_st(self._items())._do_((function(each){
 return smalltalk.withContext(function($ctx2) {
 return smalltalk.withContext(function($ctx2) {
-return self._renderItem_dataKey_on_(each,_st(index)._asString(),html);
-}, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
+return self._renderItem_on_(each,html);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"renderListOn:",{html:html},smalltalk.HLListWidget)})},
 return self}, function($ctx1) {$ctx1.fill(self,"renderListOn:",{html:html},smalltalk.HLListWidget)})},
 args: ["html"],
 args: ["html"],
-source: "renderListOn: html\x0a\x09self items withIndexDo: [ :each :index | \x0a    \x09self renderItem: each dataKey: index asString on: html ]",
-messageSends: ["withIndexDo:", "items", "renderItem:dataKey:on:", "asString"],
+source: "renderListOn: html\x0a\x09self items do: [ :each  | \x0a    \x09self renderItem: each  on: html ]",
+messageSends: ["do:", "items", "renderItem:on:"],
 referencedClasses: []
 referencedClasses: []
 }),
 }),
 smalltalk.HLListWidget);
 smalltalk.HLListWidget);
@@ -2763,36 +2719,6 @@ smalltalk.HLListWidget);
 
 
 
 
 smalltalk.addClass('HLNavigationListWidget', smalltalk.HLListWidget, ['previous', 'next'], 'Helios-Core');
 smalltalk.addClass('HLNavigationListWidget', smalltalk.HLListWidget, ['previous', 'next'], 'Helios-Core');
-smalltalk.addMethod(
-smalltalk.method({
-selector: "activateItem:",
-category: 'as yet unclassified',
-fn: function (anObject){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $3,$5,$4,$2,$1;
-var $early={};
-try {
-$3=_st(self["@wrapper"])._asJQuery();
-$5="li[list-data=\x22".__comma(_st(_st(self._items())._indexOf_ifAbsent_(anObject,(function(){
-return smalltalk.withContext(function($ctx2) {
-throw $early=[self];
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._asString());
-$4=_st($5).__comma("\x22]");
-$ctx1.sendIdx[","]=1;
-$2=_st($3)._find_($4);
-$1=_st($2)._eq_((0));
-self._activateListItem_($1);
-return self}
-catch(e) {if(e===$early)return e[0]; throw e}
-}, function($ctx1) {$ctx1.fill(self,"activateItem:",{anObject:anObject},smalltalk.HLNavigationListWidget)})},
-args: ["anObject"],
-source: "activateItem: anObject\x0a\x09self activateListItem: ((wrapper asJQuery find: 'li[list-data=\x22',  (self items indexOf: anObject ifAbsent: [^self]) asString, '\x22]') eq: 0)",
-messageSends: ["activateListItem:", "eq:", "find:", "asJQuery", ",", "asString", "indexOf:ifAbsent:", "items"],
-referencedClasses: []
-}),
-smalltalk.HLNavigationListWidget);
-
 smalltalk.addMethod(
 smalltalk.addMethod(
 smalltalk.method({
 smalltalk.method({
 selector: "next",
 selector: "next",

+ 1 - 2
st/Helios-Browser.st

@@ -642,9 +642,8 @@ renderItem: aClass level: anInteger on: html
 	| li |
 	| li |
     
     
 	li := html li.
 	li := html li.
-	
+	li asJQuery data: 'item' put: aClass.
     li
     li
-    	at: 'list-data' put: (self listDataKeyFor: aClass);
 		class: (self listCssClassForItem: aClass);
 		class: (self listCssClassForItem: aClass);
 		with: [ 
 		with: [ 
         	html a
         	html a

+ 13 - 32
st/Helios-Core.st

@@ -1,8 +1,4 @@
 Smalltalk current createPackage: 'Helios-Core'!
 Smalltalk current createPackage: 'Helios-Core'!
-HLError subclass: #HLListItemNotFound
-	instanceVariableNames: ''
-	package: 'Helios-Core'!
-
 InterfacingObject subclass: #HLModel
 InterfacingObject subclass: #HLModel
 	instanceVariableNames: 'announcer environment'
 	instanceVariableNames: 'announcer environment'
 	package: 'Helios-Core'!
 	package: 'Helios-Core'!
@@ -748,6 +744,11 @@ cssClassForItem: anObject
 	^ ''
 	^ ''
 !
 !
 
 
+findListItemFor: anObject
+	^(((wrapper asJQuery find: 'li') 
+		filter: [:thisArg :otherArg | (thisArg asJQuery data: 'item') = anObject] currySelf) eq: 0)
+!
+
 items
 items
 	^ items ifNil: [ items := self defaultItems ]
 	^ items ifNil: [ items := self defaultItems ]
 !
 !
@@ -783,9 +784,7 @@ activateFirstListItem
 !
 !
 
 
 activateItem: anObject
 activateItem: anObject
-	| listData |
-	listData := [self listDataKeyFor: anObject] on: HLListItemNotFound do: [^self].
-	self activateListItem: ((wrapper asJQuery find: 'li[list-data="', listData , '"]') eq: 0)
+	self activateListItem: (self findListItemFor: anObject)
 !
 !
 
 
 activateListItem: aListItem
 activateListItem: aListItem
@@ -798,7 +797,7 @@ activateListItem: aListItem
 	self ensureVisible: aListItem.
 	self ensureVisible: aListItem.
     
     
    "Activate the corresponding item"
    "Activate the corresponding item"
-   item := (self items at: (aListItem attr: 'list-data') asNumber).
+   item := aListItem data: 'item'.
    self selectedItem == item ifFalse: [
    self selectedItem == item ifFalse: [
 	   self selectItem: item ]
 	   self selectItem: item ]
 !
 !
@@ -819,7 +818,7 @@ ensureVisible: aListItem
 	"Move the scrollbar to show the active element"
 	"Move the scrollbar to show the active element"
 	
 	
 	| parent position |
 	| parent position |
-	
+	(aListItem get: 0) ifNil: [ ^self ].
 	position := self positionOf: aListItem.
 	position := self positionOf: aListItem.
 	parent := aListItem parent.
 	parent := aListItem parent.
 	
 	
@@ -835,16 +834,9 @@ focus
 		self selectedItem ifNil: [ self activateFirstListItem ] ]
 		self selectedItem ifNil: [ self activateFirstListItem ] ]
 !
 !
 
 
-listDataKeyFor: anObject
-	^(self items indexOf: anObject ifAbsent: [HLListItemNotFound signal]) asString
-!
-
 refresh
 refresh
-	| listData |
-
 	super refresh.
 	super refresh.
-	listData := [self listDataKeyFor: self selectedItem] on: HLListItemNotFound do: [^self].
-	self ensureVisible: ((wrapper asJQuery find: 'li[list-data="', listData , '"]') eq: 0)
+	self ensureVisible: (self findListItemFor: self selectedItem)
 !
 !
 
 
 selectItem: anObject
 selectItem: anObject
@@ -881,13 +873,12 @@ renderContentOn: html
    self setupKeyBindings
    self setupKeyBindings
 !
 !
 
 
-renderItem: anObject dataKey: aString on: html
+renderItem: anObject on: html
 	| li |
 	| li |
     
     
 	li := html li.
 	li := html li.
-	
+	li asJQuery data: 'item' put: anObject.
     li
     li
-        at: 'list-data' put: aString;
 		class: (self listCssClassForItem: anObject);
 		class: (self listCssClassForItem: anObject);
         with: [ 
         with: [ 
         	html a
         	html a
@@ -898,17 +889,13 @@ renderItem: anObject dataKey: aString on: html
                   	self activateListItem: li asJQuery ] ]
                   	self activateListItem: li asJQuery ] ]
 !
 !
 
 
-renderItem: anObject on: html
-	self renderItem: anObject dataKey: (self listDataKeyFor: anObject) on: html
-!
-
 renderItemLabel: anObject on: html
 renderItemLabel: anObject on: html
 	html with: anObject asString
 	html with: anObject asString
 !
 !
 
 
 renderListOn: html
 renderListOn: html
-	self items withIndexDo: [ :each :index | 
-    	self renderItem: each dataKey: index asString on: html ]
+	self items do: [ :each  | 
+    	self renderItem: each  on: html ]
 ! !
 ! !
 
 
 HLListWidget subclass: #HLNavigationListWidget
 HLListWidget subclass: #HLNavigationListWidget
@@ -945,12 +932,6 @@ previousFocus
 	self previous ifNotNil: [ self previous focus ]
 	self previous ifNotNil: [ self previous focus ]
 ! !
 ! !
 
 
-!HLNavigationListWidget methodsFor: 'as yet unclassified'!
-
-activateItem: anObject
-	self activateListItem: ((wrapper asJQuery find: 'li[list-data="',  (self items indexOf: anObject ifAbsent: [^self]) asString, '"]') eq: 0)
-! !
-
 !HLNavigationListWidget methodsFor: 'events'!
 !HLNavigationListWidget methodsFor: 'events'!
 
 
 setupKeyBindings
 setupKeyBindings