Bladeren bron

Fixed list selection

Nicolas Petton 11 jaren geleden
bovenliggende
commit
180c7bb2cc
6 gewijzigde bestanden met toevoegingen van 67 en 94 verwijderingen
  1. 16 12
      js/Helios-Browser.deploy.js
  2. 20 16
      js/Helios-Browser.js
  3. 9 24
      js/Helios-Core.deploy.js
  4. 10 30
      js/Helios-Core.js
  5. 8 4
      st/Helios-Browser.st
  6. 4 8
      st/Helios-Core.st

+ 16 - 12
js/Helios-Browser.deploy.js

@@ -478,10 +478,10 @@ return $2;
 $1;
 };
 $3=self;
-_st($3)._selectListItem_(aClass);
+_st($3)._activateItem_(aClass);
 $4=_st($3)._focus();
 return self}, function($ctx1) {$ctx1.fill(self,"onClassSelected:",{aClass:aClass},smalltalk.HLClassesListWidget)})},
-messageSends: ["selectedItem:", "ifNil:", "selectListItem:", "focus"]}),
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"]}),
 smalltalk.HLClassesListWidget);
 
 smalltalk.addMethod(
@@ -959,7 +959,7 @@ smalltalk.method({
 selector: "onMethodSelected:",
 fn: function (aMethod){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
 _st(self)._selectedItem_(aMethod);
 $1=aMethod;
 if(($receiver = $1) == nil || $receiver == undefined){
@@ -968,9 +968,11 @@ return $2;
 } else {
 $1;
 };
-_st(self)._focus();
-return self}, function($ctx1) {$ctx1.fill(self,"onMethodSelected:",{aMethod:aMethod}, smalltalk.HLMethodsListWidget)})},
-messageSends: ["selectedItem:", "ifNil:", "focus"]}),
+$3=self;
+_st($3)._activateItem_(aMethod);
+$4=_st($3)._focus();
+return self}, function($ctx1) {$ctx1.fill(self,"onMethodSelected:",{aMethod:aMethod},smalltalk.HLMethodsListWidget)})},
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"]}),
 smalltalk.HLMethodsListWidget);
 
 smalltalk.addMethod(
@@ -1275,10 +1277,10 @@ var self=this;
 return smalltalk.withContext(function($ctx1) { 
var $1,$2;
 $1=self;
 _st($1)._selectedItem_(aPackage);
-_st($1)._selectListItem_(aPackage);
+_st($1)._activateItem_(aPackage);
 $2=_st($1)._focus();
 return self}, function($ctx1) {$ctx1.fill(self,"onPackageSelected:",{aPackage:aPackage},smalltalk.HLPackagesListWidget)})},
-messageSends: ["selectedItem:", "selectListItem:", "focus"]}),
+messageSends: ["selectedItem:", "activateItem:", "focus"]}),
 smalltalk.HLPackagesListWidget);
 
 smalltalk.addMethod(
@@ -1454,7 +1456,7 @@ smalltalk.method({
 selector: "onProtocolSelected:",
 fn: function (aString){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
 _st(self)._selectedItem_(aString);
 $1=aString;
 if(($receiver = $1) == nil || $receiver == undefined){
@@ -1463,9 +1465,11 @@ return $2;
 } else {
 $1;
 };
-_st(self)._focus();
-return self}, function($ctx1) {$ctx1.fill(self,"onProtocolSelected:",{aString:aString}, smalltalk.HLProtocolsListWidget)})},
-messageSends: ["selectedItem:", "ifNil:", "focus"]}),
+$3=self;
+_st($3)._activateItem_(aString);
+$4=_st($3)._focus();
+return self}, function($ctx1) {$ctx1.fill(self,"onProtocolSelected:",{aString:aString},smalltalk.HLProtocolsListWidget)})},
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"]}),
 smalltalk.HLProtocolsListWidget);
 
 smalltalk.addMethod(

+ 20 - 16
js/Helios-Browser.js

@@ -629,12 +629,12 @@ return $2;
 $1;
 };
 $3=self;
-_st($3)._selectListItem_(aClass);
+_st($3)._activateItem_(aClass);
 $4=_st($3)._focus();
 return self}, function($ctx1) {$ctx1.fill(self,"onClassSelected:",{aClass:aClass},smalltalk.HLClassesListWidget)})},
 args: ["aClass"],
-source: "onClassSelected: aClass\x0a\x09self selectedItem: aClass.\x0a\x09aClass ifNil: [ ^ self ].\x0a    \x0a\x09self \x0a\x09\x09selectListItem: aClass;\x0a\x09\x09focus",
-messageSends: ["selectedItem:", "ifNil:", "selectListItem:", "focus"],
+source: "onClassSelected: aClass\x0a\x09self selectedItem: aClass.\x0a\x09aClass ifNil: [ ^ self ].\x0a    \x0a\x09self \x0a\x09\x09activateItem: aClass;\x0a\x09\x09focus",
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"],
 referencedClasses: []
 }),
 smalltalk.HLClassesListWidget);
@@ -1245,7 +1245,7 @@ selector: "onMethodSelected:",
 category: 'reactions',
 fn: function (aMethod){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
 _st(self)._selectedItem_(aMethod);
 $1=aMethod;
 if(($receiver = $1) == nil || $receiver == undefined){
@@ -1254,11 +1254,13 @@ return $2;
 } else {
 $1;
 };
-_st(self)._focus();
-return self}, function($ctx1) {$ctx1.fill(self,"onMethodSelected:",{aMethod:aMethod}, smalltalk.HLMethodsListWidget)})},
+$3=self;
+_st($3)._activateItem_(aMethod);
+$4=_st($3)._focus();
+return self}, function($ctx1) {$ctx1.fill(self,"onMethodSelected:",{aMethod:aMethod},smalltalk.HLMethodsListWidget)})},
 args: ["aMethod"],
-source: "onMethodSelected: aMethod\x0a\x09self selectedItem: aMethod.\x0a\x09aMethod ifNil: [ ^ self ].\x0a    \x0a    self focus",
-messageSends: ["selectedItem:", "ifNil:", "focus"],
+source: "onMethodSelected: aMethod\x0a\x09self selectedItem: aMethod.\x0a\x09aMethod ifNil: [ ^ self ].\x0a    \x0a    self \x0a\x09\x09activateItem: aMethod;\x0a\x09\x09focus",
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"],
 referencedClasses: []
 }),
 smalltalk.HLMethodsListWidget);
@@ -1656,12 +1658,12 @@ var self=this;
 return smalltalk.withContext(function($ctx1) { 
var $1,$2;
 $1=self;
 _st($1)._selectedItem_(aPackage);
-_st($1)._selectListItem_(aPackage);
+_st($1)._activateItem_(aPackage);
 $2=_st($1)._focus();
 return self}, function($ctx1) {$ctx1.fill(self,"onPackageSelected:",{aPackage:aPackage},smalltalk.HLPackagesListWidget)})},
 args: ["aPackage"],
-source: "onPackageSelected: aPackage\x0a\x09self \x0a\x09\x09selectedItem: aPackage;\x0a\x09\x09selectListItem: aPackage;\x0a\x09\x09focus",
-messageSends: ["selectedItem:", "selectListItem:", "focus"],
+source: "onPackageSelected: aPackage\x0a\x09self \x0a\x09\x09selectedItem: aPackage;\x0a\x09\x09activateItem: aPackage;\x0a\x09\x09focus",
+messageSends: ["selectedItem:", "activateItem:", "focus"],
 referencedClasses: []
 }),
 smalltalk.HLPackagesListWidget);
@@ -1885,7 +1887,7 @@ selector: "onProtocolSelected:",
 category: 'reactions',
 fn: function (aString){
 var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
 _st(self)._selectedItem_(aString);
 $1=aString;
 if(($receiver = $1) == nil || $receiver == undefined){
@@ -1894,11 +1896,13 @@ return $2;
 } else {
 $1;
 };
-_st(self)._focus();
-return self}, function($ctx1) {$ctx1.fill(self,"onProtocolSelected:",{aString:aString}, smalltalk.HLProtocolsListWidget)})},
+$3=self;
+_st($3)._activateItem_(aString);
+$4=_st($3)._focus();
+return self}, function($ctx1) {$ctx1.fill(self,"onProtocolSelected:",{aString:aString},smalltalk.HLProtocolsListWidget)})},
 args: ["aString"],
-source: "onProtocolSelected: aString\x0a\x09self selectedItem: aString.\x0a\x09aString ifNil: [ ^ self ].\x0a    \x0a    self focus",
-messageSends: ["selectedItem:", "ifNil:", "focus"],
+source: "onProtocolSelected: aString\x0a\x09self selectedItem: aString.\x0a\x09aString ifNil: [ ^ self ].\x0a    \x0a    self \x0a\x09\x09activateItem: aString;\x0a\x09\x09focus",
+messageSends: ["selectedItem:", "ifNil:", "activateItem:", "focus"],
 referencedClasses: []
 }),
 smalltalk.HLProtocolsListWidget);

+ 9 - 24
js/Helios-Core.deploy.js

@@ -489,8 +489,8 @@ smalltalk.method({
 selector: "activateListItem:",
 fn: function (aListItem){
 var self=this;
-var parent,position;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
+var parent,position,item;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4,$5;
 $1=_st(aListItem)._get_((0));
 if(($receiver = $1) == nil || $receiver == undefined){
 $2=self;
@@ -510,9 +510,13 @@ $4=_st(_st(_st(_st(aListItem)._position())._top()).__plus(_st(aListItem)._height
 if(smalltalk.assert($4)){
 _st(_st(parent)._get_((0)))._scrollTop_(_st(_st(_st(_st(_st(parent)._get_((0)))._scrollTop()).__plus(_st(aListItem)._height())).__minus(_st(_st(parent)._height()).__minus(_st(_st(aListItem)._position())._top()))).__plus((10)));
 };
-_st(self)._selectItem_(_st(_st(self)._items())._at_(_st(_st(aListItem)._attr_("list-data"))._asNumber()));
-return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,parent:parent,position:position}, smalltalk.HLListWidget)})},
-messageSends: ["ifNil:", "get:", "positionOf:", "parent", "removeClass:", "children", "addClass:", "ifTrue:", "scrollTop:", "-", "+", "top", "position", "scrollTop", "<", "height", ">", "selectItem:", "at:", "asNumber", "attr:", "items"]}),
+item=_st(_st(self)._items())._at_(_st(_st(aListItem)._attr_("list-data"))._asNumber());
+$5=_st(_st(self)._selectedItem()).__eq_eq(item);
+if(! smalltalk.assert($5)){
+_st(self)._selectItem_(item);
+};
+return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,parent:parent,position:position,item:item},smalltalk.HLListWidget)})},
+messageSends: ["ifNil:", "get:", "positionOf:", "parent", "removeClass:", "children", "addClass:", "ifTrue:", "scrollTop:", "-", "+", "top", "position", "scrollTop", "<", "height", ">", "at:", "asNumber", "attr:", "items", "ifFalse:", "selectItem:", "==", "selectedItem"]}),
 smalltalk.HLListWidget);
 
 smalltalk.addMethod(
@@ -738,25 +742,6 @@ return self}, function($ctx1) {$ctx1.fill(self,"selectItem:",{anObject:anObject}
 messageSends: ["selectedItem:"]}),
 smalltalk.HLListWidget);
 
-smalltalk.addMethod(
-"_selectListItem_",
-smalltalk.method({
-selector: "selectListItem:",
-fn: function (anObject){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1;
-var $early={};
-try {
-_st(self)._selectListItem_(_st(_st(self["@mapping"])._at_ifAbsent_(anObject,(function(){
-return smalltalk.withContext(function($ctx2) {
$1=self;
-throw $early=[$1];
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._asJQuery());
-return self}
-catch(e) {if(e===$early)return e[0]; throw e}
-}, function($ctx1) {$ctx1.fill(self,"selectListItem:",{anObject:anObject},smalltalk.HLListWidget)})},
-messageSends: ["selectListItem:", "asJQuery", "at:ifAbsent:"]}),
-smalltalk.HLListWidget);
-
 smalltalk.addMethod(
 "_selectedItem",
 smalltalk.method({

+ 10 - 30
js/Helios-Core.js

@@ -665,8 +665,8 @@ selector: "activateListItem:",
 category: 'actions',
 fn: function (aListItem){
 var self=this;
-var parent,position;
-return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4;
+var parent,position,item;
+return smalltalk.withContext(function($ctx1) { 
var $1,$2,$3,$4,$5;
 $1=_st(aListItem)._get_((0));
 if(($receiver = $1) == nil || $receiver == undefined){
 $2=self;
@@ -686,11 +686,15 @@ $4=_st(_st(_st(_st(aListItem)._position())._top()).__plus(_st(aListItem)._height
 if(smalltalk.assert($4)){
 _st(_st(parent)._get_((0)))._scrollTop_(_st(_st(_st(_st(_st(parent)._get_((0)))._scrollTop()).__plus(_st(aListItem)._height())).__minus(_st(_st(parent)._height()).__minus(_st(_st(aListItem)._position())._top()))).__plus((10)));
 };
-_st(self)._selectItem_(_st(_st(self)._items())._at_(_st(_st(aListItem)._attr_("list-data"))._asNumber()));
-return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,parent:parent,position:position}, smalltalk.HLListWidget)})},
+item=_st(_st(self)._items())._at_(_st(_st(aListItem)._attr_("list-data"))._asNumber());
+$5=_st(_st(self)._selectedItem()).__eq_eq(item);
+if(! smalltalk.assert($5)){
+_st(self)._selectItem_(item);
+};
+return self}, function($ctx1) {$ctx1.fill(self,"activateListItem:",{aListItem:aListItem,parent:parent,position:position,item:item},smalltalk.HLListWidget)})},
 args: ["aListItem"],
-source: "activateListItem: aListItem\x0a\x09| parent position |\x0a    \x0a\x09(aListItem get: 0) ifNil: [ ^self ].\x0a\x0a\x09position := self positionOf: aListItem.\x0a\x0a    parent := aListItem parent.\x0a\x09parent children removeClass: 'active'.\x0a\x09aListItem addClass: 'active'.\x0a    \x0a    \x22Move the scrollbar to show the active element\x22\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 ].\x0a        \x0a   \x22Activate the corresponding item\x22\x0a   self selectItem: (self items at: (aListItem attr: 'list-data') asNumber)",
-messageSends: ["ifNil:", "get:", "positionOf:", "parent", "removeClass:", "children", "addClass:", "ifTrue:", "scrollTop:", "-", "+", "top", "position", "scrollTop", "<", "height", ">", "selectItem:", "at:", "asNumber", "attr:", "items"],
+source: "activateListItem: aListItem\x0a\x09| parent position item |\x0a    \x0a\x09(aListItem get: 0) ifNil: [ ^self ].\x0a\x0a\x09position := self positionOf: aListItem.\x0a\x0a    parent := aListItem parent.\x0a\x09parent children removeClass: 'active'.\x0a\x09aListItem addClass: 'active'.\x0a    \x0a    \x22Move the scrollbar to show the active element\x22\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 ].\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:", "positionOf:", "parent", "removeClass:", "children", "addClass:", "ifTrue:", "scrollTop:", "-", "+", "top", "position", "scrollTop", "<", "height", ">", "at:", "asNumber", "attr:", "items", "ifFalse:", "selectItem:", "==", "selectedItem"],
 referencedClasses: []
 }),
 smalltalk.HLListWidget);
@@ -993,30 +997,6 @@ referencedClasses: []
 }),
 smalltalk.HLListWidget);
 
-smalltalk.addMethod(
-"_selectListItem_",
-smalltalk.method({
-selector: "selectListItem:",
-category: 'actions',
-fn: function (anObject){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
var $1;
-var $early={};
-try {
-_st(self)._selectListItem_(_st(_st(self["@mapping"])._at_ifAbsent_(anObject,(function(){
-return smalltalk.withContext(function($ctx2) {
$1=self;
-throw $early=[$1];
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._asJQuery());
-return self}
-catch(e) {if(e===$early)return e[0]; throw e}
-}, function($ctx1) {$ctx1.fill(self,"selectListItem:",{anObject:anObject},smalltalk.HLListWidget)})},
-args: ["anObject"],
-source: "selectListItem: anObject\x0a\x09self selectListItem: (mapping \x0a\x09\x09at: anObject\x0a\x09\x09ifAbsent: [ ^ self ]) asJQuery\x0a",
-messageSends: ["selectListItem:", "asJQuery", "at:ifAbsent:"],
-referencedClasses: []
-}),
-smalltalk.HLListWidget);
-
 smalltalk.addMethod(
 "_selectedItem",
 smalltalk.method({

+ 8 - 4
st/Helios-Browser.st

@@ -252,7 +252,7 @@ onClassSelected: aClass
 	aClass ifNil: [ ^ self ].
     
 	self 
-		selectListItem: aClass;
+		activateItem: aClass;
 		focus
 !
 
@@ -488,7 +488,9 @@ onMethodSelected: aMethod
 	self selectedItem: aMethod.
 	aMethod ifNil: [ ^ self ].
     
-    self focus
+    self 
+		activateItem: aMethod;
+		focus
 !
 
 onMethodsFocusRequested
@@ -588,7 +590,7 @@ selectItem: aPackage
 onPackageSelected: aPackage
 	self 
 		selectedItem: aPackage;
-		selectListItem: aPackage;
+		activateItem: aPackage;
 		focus
 !
 
@@ -704,7 +706,9 @@ onProtocolSelected: aString
 	self selectedItem: aString.
 	aString ifNil: [ ^ self ].
     
-    self focus
+    self 
+		activateItem: aString;
+		focus
 !
 
 onProtocolsFocusRequested

+ 4 - 8
st/Helios-Core.st

@@ -248,7 +248,7 @@ activateItem: anObject
 !
 
 activateListItem: aListItem
-	| parent position |
+	| parent position item |
     
 	(aListItem get: 0) ifNil: [ ^self ].
 
@@ -265,7 +265,9 @@ activateListItem: aListItem
 		(parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem height - (parent height - aListItem position top)) +10 ].
         
    "Activate the corresponding item"
-   self selectItem: (self items at: (aListItem attr: 'list-data') asNumber)
+   item := (self items at: (aListItem attr: 'list-data') asNumber).
+   self selectedItem == item ifFalse: [
+	   self selectItem: item ]
 !
 
 focus
@@ -276,12 +278,6 @@ focus
 
 selectItem: anObject
 	self selectedItem: anObject
-!
-
-selectListItem: anObject
-	self selectListItem: (mapping 
-		at: anObject
-		ifAbsent: [ ^ self ]) asJQuery
 ! !
 
 !HLListWidget methodsFor: 'defaults'!