Explorar o código

Only show last modal window.

Clean up the previous one.

Removes UI blocks because div#overlay.
Herby Vojčík %!s(int64=5) %!d(string=hai) anos
pai
achega
2246ef9f0f
Modificáronse 2 ficheiros con 79 adicións e 13 borrados
  1. 63 12
      src/Helios-Core.js
  2. 16 1
      src/Helios-Core.st

+ 63 - 12
src/Helios-Core.js

@@ -6437,17 +6437,18 @@ $1=".dialog"._asJQuery();
 $ctx1.sendIdx["asJQuery"]=1;
 //>>excludeEnd("ctx");
 $recv($1)._removeClass_("active");
-$recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
+$recv($globals.HLModalWidget)._current_(nil);
 $2="#overlay"._asJQuery();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["asJQuery"]=2;
+$ctx1.sendIdx["asJQuery"]=2;
 //>>excludeEnd("ctx");
 $recv($2)._remove();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx2.sendIdx["remove"]=1;
+$ctx1.sendIdx["remove"]=1;
+//>>excludeEnd("ctx");
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 return $recv($recv($self.wrapper)._asJQuery())._remove();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -6461,11 +6462,11 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "remove\x0a\x09'.dialog' asJQuery removeClass: 'active'.\x0a\x09[ \x0a\x09\x09'#overlay' asJQuery remove.\x0a\x09\x09wrapper asJQuery remove\x0a\x09] valueWithTimeout: 300",
-referencedClasses: [],
+source: "remove\x0a\x09'.dialog' asJQuery removeClass: 'active'.\x0a\x09HLModalWidget current: nil.\x0a\x09'#overlay' asJQuery remove.\x0a\x09[ \x0a\x09\x09wrapper asJQuery remove\x0a\x09] valueWithTimeout: 300",
+referencedClasses: ["HLModalWidget"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["removeClass:", "asJQuery", "valueWithTimeout:", "remove"]
+messageSends: ["removeClass:", "asJQuery", "current:", "remove", "valueWithTimeout:"]
 }),
 $globals.HLModalWidget);
 
@@ -6601,6 +6602,16 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
+var $1,$receiver;
+$1=$recv($globals.HLModalWidget)._current();
+if(($receiver = $1) == null || $receiver.a$nil){
+$1;
+} else {
+var old;
+old=$receiver;
+$recv(old)._remove();
+}
+$recv($globals.HLModalWidget)._current_(self);
 $self._appendToJQuery_("body"._asJQuery());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -6609,15 +6620,55 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "show\x0a\x09self appendToJQuery: 'body' asJQuery",
-referencedClasses: [],
+source: "show\x0a\x09HLModalWidget current ifNotNil: [ :old | old remove ].\x0a\x09HLModalWidget current: self.\x0a\x09self appendToJQuery: 'body' asJQuery",
+referencedClasses: ["HLModalWidget"],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["appendToJQuery:", "asJQuery"]
+messageSends: ["ifNotNil:", "current", "remove", "current:", "appendToJQuery:", "asJQuery"]
 }),
 $globals.HLModalWidget);
 
 
+$core.setSlots($globals.HLModalWidget.a$cls, ["current"]);
+$core.addMethod(
+$core.method({
+selector: "current",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+return $self.current;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "current\x0a\x09^ current",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}),
+$globals.HLModalWidget.a$cls);
+
+$core.addMethod(
+$core.method({
+selector: "current:",
+protocol: "accessing",
+fn: function (anHLModelWidget){
+var self=this,$self=this;
+$self.current=anHLModelWidget;
+return self;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anHLModelWidget"],
+source: "current: anHLModelWidget\x0a\x09current := anHLModelWidget",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: []
+}),
+$globals.HLModalWidget.a$cls);
+
 
 $core.addClass("HLConfirmationWidget", $globals.HLModalWidget, ["cancelButtonLabel", "confirmButtonLabel", "confirmationString", "actionBlock", "cancelBlock"], "Helios-Core");
 //>>excludeStart("ide", pragmas.excludeIdeData);

+ 16 - 1
src/Helios-Core.st

@@ -1463,13 +1463,16 @@ I implement an abstract modal widget.!
 
 remove
 	'.dialog' asJQuery removeClass: 'active'.
+	HLModalWidget current: nil.
+	'#overlay' asJQuery remove.
 	[ 
-		'#overlay' asJQuery remove.
 		wrapper asJQuery remove
 	] valueWithTimeout: 300
 !
 
 show
+	HLModalWidget current ifNotNil: [ :old | old remove ].
+	HLModalWidget current: self.
 	self appendToJQuery: 'body' asJQuery
 ! !
 
@@ -1512,6 +1515,18 @@ setupKeyBindings
 		e keyCode = String esc asciiValue ifTrue: [ self cancel ] ]
 ! !
 
+HLModalWidget class slots: {#current}!
+
+!HLModalWidget class methodsFor: 'accessing'!
+
+current
+	^ current
+!
+
+current: anHLModelWidget
+	current := anHLModelWidget
+! !
+
 HLModalWidget subclass: #HLConfirmationWidget
 	slots: {#cancelButtonLabel. #confirmButtonLabel. #confirmationString. #actionBlock. #cancelBlock}
 	package: 'Helios-Core'!