Jump to content

SweetAlert2


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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
Share on other sites

  • 1 year later...
  • 4 months later...
  • 1 year later...

var UniJToast1 := TUniJToast.Criar(nil);
UniJToast1.text := 'Um brinde progressivo' ;
UniJToast1.loaderBg := '#FF0000';
UniJToast1.pos := TPosition.mid_center;
UniJToast1.hideDepois := 10000;
UniJToast1.Icon := TIconType.success;
UniJToast1.ShowMessage;

 

Good afternoon, I don't have the component installed, I create it at runtime, it works. But the icon does not appear, does anyone have any tips?

Capturar.PNG

Link to comment
Share on other sites

procedure TMessages.ShowToast(const Title, Text: String; MsgDlgType: TMsgDlgType; hideAfter: integer);
Var
 UniJToast: TUniJToast;
begin
  UniJToast := TUniJToast.Create(fParentForm);
  try

    case MsgDlgType of //TIconType = (none, success, error, warning, info);
      mtWarning     : UniJToast.icon := TIconType.warning;
      mtConfirmation: UniJToast.icon := TIconType.success;
      mtError       : UniJToast.icon := TIconType.error;
      mtInformation : UniJToast.icon := TIconType.info;
    else
      UniJToast.icon := TIconType.success;

    end;//case

    UniJToast.pos := TPosition.mid_center;
    UniJToast.allowToastClose := True;
    UniJToast.hideAfter := hideAfter;
    UniJToast.heading := Title;
    UniJToast.text := Text;

    UniJToast.ShowMessage;

  finally
    UniJToast.Free;
  end;// try-fin
end;

 

Screenshot_27.jpg

Link to comment
Share on other sites

  • 2 months later...

Hi, I tried to use link in the message but I can't. has anyone done this?

 

class procedure TToastUtils.Aviso(Text : String; Close: Boolean; Titulo : String; hideAfter : Integer);
var
  lJToast: TuniJToast;
begin
  lJToast := TuniJToast.Create(nil);
  try
    lJToast.Text := Text;
    lJToast.showHideTransition := TTransition.plain;
    lJToast.allowToastClose := Close;
    lJToast.stack := True;
    lJToast.stackSize := 4;
    lJToast.textAlign := TTextAlign.left;
    lJToast.pos := top_center;
    lJToast.loaderBg := '#ED9E00';
    lJToast.bgColor := '#FFA900';
    lJToast.textColor := '#FFFFFF';
    lJToast.icon := TIconType.warning;
    lJToast.heading := Titulo;
    lJToast.hideAfter := hideAfter;
    lJToast.ShowMessage;
  finally
    FreeAndNil(lJToast);
  end;
end;

TToastUtils.Aviso('Yes! check this <a href="https://github.com/kamranahmedse/jquery-toast-plugin/commits/master">update</a>.', True)

Link to comment
Share on other sites

  • 9 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...