Jump to content
uniGUI Discussion Forums

Recommended Posts

https://sweetalert2.github.io/

Current version: v7.24.2

 

dismiss event not triggered, AjaxRequest always "success"

jsonSweetAlert    := 'swal(' + jsonSweetAlert + ').then(function(){' + ajaxCallbackStr + ' return false; },function (dismiss) { '+ dismissCallbackStr + '});';

Anybody help about this problem?

regards

 

 

Fixed:

   dismissCallbackStr:= BuildAjaxRequest('dismiss');
   jsonSweetAlert    := 'swal(' + jsonSweetAlert + ').then((result)=>{if(result.value){'+ajaxCallbackStr +'}else{'+dismissCallbackStr +'}})';
Link to post
Share on other sites

Bom dia Pessoal, estou tentando criar uma função para chamar o UniSweetAlert.. crio e configuro o componente em tempo de execução, ao tentar usar um Question, configuro o Evento OnSuccess, a Mensagem aparece mas o Evento não é disparado. Só funciona quando coloco o componente na Tela.

Link to post
Share on other sites

Hi everyone

 

I hope someone can assist. I installed the Delphi component on Delphi 10.2.3 (2017-08-04-uniSweetAlert V51), but keep on getting the attached error.

I copied the js and css files to my app's "files" directory.

 

Is there anything else I need to install for SweetAlert to work?

 

Regards

Donald

 

post-5914-0-41689300-1530799451_thumb.png

Link to post
Share on other sites

check permission that file. If I'm not wrong, that error mean swal function not found and mean js file not include project. can check html file from browser

Thank you for your response. I will check the permissions. How do I include the file in the project and how do I check with browser?

 

Regards

Donald

 

 

Sent from my iPad using Tapatalk

Link to post
Share on other sites
  • 2 months later...

Hello,

First of all, thanks to CastleSoft for these components.

I noticed that the "TUniJToast" component does not work properly with the "loader" property. If you choose false, the loader keeps showing.

To correct, I made these changes in the function TUniJToast.BuildJsonParams: string;

I changed these line

   bstr := bstr + 'loader:' + BoolToStr(loader) +',';

for this

   bstr := bstr + 'loader:' + LowerCase(BoolToStr(loader, true)) +',';

 

Link to post
Share on other sites
  • 2 months later...
On 9/22/2018 at 6:01 AM, Pep said:

Hello,

First of all, thanks to CastleSoft for these components.

I noticed that the "TUniJToast" component does not work properly with the "loader" property. If you choose false, the loader keeps showing.

To correct, I made these changes in the function TUniJToast.BuildJsonParams: string;

I changed these line


   bstr := bstr + 'loader:' + BoolToStr(loader) +',';

for this


   bstr := bstr + 'loader:' + LowerCase(BoolToStr(loader, true)) +',';

 

Hey, I found some others issues on the code from jToast.

There is what I changed (in uniJToast > BuildJsonParams):

allowToastClose

if allowToastClose then
  bstr := bstr + 'allowToastClose:true,'
else
  bstr := bstr + 'allowToastClose:false,';

stack

if (stack) then
  bstr := bstr + 'stack:' + IntToStr(stackSize) +','
else
  bstr := bstr + 'stack:false,';

position

bstr := bstr + 'position:' + '"' + StringReplace(GetPosition(pos), '_', '-', [rfReplaceAll]) + '",';

loader (like Pep's post)

if loader then begin
  bstr := bstr + 'loader:true,';
  bstr := bstr + 'loaderBg: ' + '"' + loaderBg + '",';
end else
  bstr := bstr + 'loader:false,';

With these changes the component worked perfectly.

Here is all procedure code:

function TUniJToast.BuildJsonParams: string;
var bstr: string;
begin
   bstr := '{';
   bstr := bstr + 'text:' + '"' + text + '",';
   bstr := bstr + 'heading:' + '"' + heading + '",';
   bstr := bstr + 'icon:'    + '"' + GetIconType(icon) + '",';
   bstr := bstr + 'showHideTransition:' + '"' + GetTransition(showHideTransition) + '",';

   if allowToastClose then
     bstr := bstr + 'allowToastClose:true,'
   else
     bstr := bstr + 'allowToastClose:false,';

   if hideAfter > 0 then
      bstr := bstr + 'hideAfter:' + IntToStr(hideAfter) + ',';

   if (stack) then
      bstr := bstr + 'stack:' + IntToStr(stackSize) +','
   else
      bstr := bstr + 'stack:false,';

   bstr := bstr + 'position:' + '"' + StringReplace(GetPosition(pos), '_', '-', [rfReplaceAll]) + '",';
   bstr := bstr + 'textAlign:' + '"' + GetTextAlign(textAlign)  + '",';
   if loader then begin
     bstr := bstr + 'loader:true,';
     bstr := bstr + 'loaderBg: ' + '"' + loaderBg + '",';
   end else
     bstr := bstr + 'loader:false,';

   // Add Callbacks here
   bstr := bstr + 'beforeShow: function() { ajaxRequest('+JSName+',"beforeShow",[]); },';
   bstr := bstr + 'afterShown: function() { ajaxRequest('+JSName+',"afterShown",[]); },';
   bstr := bstr + 'beforeHide: function() { ajaxRequest('+JSName+',"beforeHide",[]); },';
   bstr := bstr + 'afterHidden: function() { ajaxRequest('+JSName+',"afterHidden",[]); }';
   bstr := bstr + '}';
   result := bstr;
end;

 

Link to post
Share on other sites
  • 2 weeks later...

You can add the following to the TUniJToast.BuildJsonParams  function above for the background color and text color:

if not bgColor.IsEmpty then
    bstr := bstr + 'bgColor:' + '"' + bgColor + '",';

   if not textColor.IsEmpty then
    bstr := bstr + 'textColor:' + '"' + textColor + '",';

 

Link to post
Share on other sites

Code is now available via Github:

https://github.com/CastleSoft/uiXtra

Contains the latest source code (v1.07 - RIO release, uniGUI 1.5 (latest release) - Forum patches/updates in this thread ** Thank you all ** )

MIT lic.. Feel free to FORK / hack / etc.

Sorry. I don't have much time these days to monitor the forums. Enjoy..

PS.. v1.06 is the original release for pre RIO / pre 1.5 / pre patches - if anyone needs it. 

Link to post
Share on other sites
  • 4 months later...

I made some small modified :)

change SweetAlert Ver. 8.8.5
 Added "FooterText" property                      
 Added "PostionType" property                     
 Added ErrorHTML procedure
 Added ErrorTXT procedure
 Added Question_html procedure.   
 VCL package separated and animation property editor added.
  Clean unused packages from dpk. (bpl size be decrease)
  Register procedures moved to VCL package                  
 Added animate.min.css 3.6.0 (3.7.0 has not tested maybe can be problem.)  http://daneden.me/animate  github: https://github.com/daneden/animate.css
 Test project modified for new properties

I did in Tokyo and unigui Ver. 1480 (sencha 6.5.3)      

If you wanna use this code, its your own risk :)

uniExtensions.7z

  • Like 1
Link to post
Share on other sites

Fix typo. change in "uniSweetAlertPropEdit.pas"  and in test project. main.pas (in TMainForm.UniFormBeforeShow)

    CommaText:= 'None,Default,bounce,bounceIn,bounceInDown,bounceInLeft,bounceInRight,bounceInUp,bounceOut,'+
                'bounceOutDown,bounceOutLeft,bounceOutRight,bounceOutUp,fadeIn,fadeInDown,fadeInDownBig,'+
                'fadeInLeft,fadeInLeftBig,fadeInRight,fadeInRightBig,fadeInUp,fadeInUpBig,fadeOut,fadeOutDown,'+
                'fadeOutDownBig,fadeOutLeft,fadeOutLeftBig,fadeOutRight,fadeOutRightBig,fadeOutUp,fadeOutUpBig,'+
                'flash,flipInX,flipInY,flipOutX,flipOutY,headShake,heartBeat,hinge,jackInTheBox,jello,lightSpeedIn,'+
                'lightSpeedOut,pulse,rollIn,rollOut,rotateIn,rotateInDownLeft,rotateInDownRight,rotateInUpLeft,'+
                'rotateInUpRight,rotateOut,rotateOutDownLeft,rotateOutDownRight,rotateOutUpLeft,rotateOutUpRight,'+
                'rubberBand,shake,slideInDown,slideInLeft,slideInRight,slideInUp,slideOutDown,slideOutLeft,slideOutRight,'+
                'slideOutUp,swing,tada,wobble,zoomIn,zoomInDown,zoomInLeft,zoomInRight,zoomInUp,zoomOut,'+
                'zoomOutDown,zoomOutLeft,zoomOutRight,zoomOutUp';

 

Link to post
Share on other sites

for question, I get allways "sucsess" event and I fixed it

procedure TUniSweetAlert.ShowMessage;
var ajaxCallbackStr, dismissCallbackStr, jsonSweetAlert: string;
begin
   jsonSweetAlert    := BuildJsonParams;
//   ajaxCallbackStr := BuildAjaxRequest('success');
//   dismissCallbackStr := BuildAjaxRequest('dismiss','dismiss');
// Remarked, because always return "success" event !!!!!
//   UniSession.AddJS('swal.fire(' + jsonSweetAlert + ').then(function(){' + ajaxCallbackStr + ' return false; },function (dismiss) { '+ dismissCallbackStr + '});');  // AJT 2019-04-12 FIX Callback
   ajaxCallbackStr   := BuildAjaxRequest('success');
   dismissCallbackStr:= BuildAjaxRequest('dismiss');
   jsonSweetAlert    := 'swal.fire(' + jsonSweetAlert + ').then((result)=>{if(result.value){'+ajaxCallbackStr +'}else{'+dismissCallbackStr +'}});';//2019-04-18 Fixed.
   UniSession.AddJS(jsonSweetAlert);
end;

 

Link to post
Share on other sites
  • 1 year later...

How to create new line message in sweetalert, for example :

Information

name : bla bla bla

address : bla bla bla

Link to post
Share on other sites
  • 4 months later...
×
×
  • Create New...