Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Edit the global default settings #77

Closed
pomartel opened this issue Oct 7, 2014 · 6 comments
Closed

[Feature] Edit the global default settings #77

pomartel opened this issue Oct 7, 2014 · 6 comments

Comments

@pomartel
Copy link

pomartel commented Oct 7, 2014

It would be nice if the default settings could be override globally. I could for example change the default button texts to a different locale without having to pass it as params each time I create a new dialog. I will check if I can send you a pull request but my JS skills are a bit rusted!

@pomartel pomartel changed the title Edit the global default settings [Feature] Edit the global default settings Oct 8, 2014
@t4t5
Copy link
Owner

t4t5 commented Oct 9, 2014

Currently, lines 191-203 in sweet-alert.js are the ones holding the default parameters like this:

var params = {
  title: '',
  text: '',
  type: null,
  allowOutsideClick: false,
  showCancelButton: false,
  closeOnConfirm: true,
  confirmButtonText: 'OK',
  confirmButtonColor: '#AEDEF4',
  cancelButtonText: 'Cancel',
  imageUrl: null,
  imageSize: null
};

Couldn't you just change this so that it fits your project? I don't think there's a need to add an additional place where you can set the defaults.

@pomartel
Copy link
Author

pomartel commented Oct 9, 2014

Yes, I saw that but the params variable is not public so I cannot extend it from the outside. It would be nice if this could be changed the way jQuery UI does it for exemple. You would just have to expose the params hash so it can be extended from outside the plugin.

I can give it a try on a pull request if you feel this is something others could benefit from.

@alkrauss48
Copy link

I agree with @pomartel, the ability to set default options outside of the plugin file would be cool. Having to edit the lib file makes updates more tedious, and prevents the ability to use a public CDN. Currently I'm just handling it with a function that has default attributes, merges in the custom attributes from the parameters, and calls swal. It works, but would be cool to have it baked in!

Great plugin, this seriously makes UI much more awesome.

@zzarcon
Copy link
Contributor

zzarcon commented Oct 17, 2014

Guys what do you think about #139? This PR adds the feature (which I think it's a powerful feature) to set a default user params without changing the source code or exporting some variables to global scope, you just have to call the setDefaults method.

@pomartel
Copy link
Author

@zzarcon yes, I think your implementation is better than mine. Let's hope it gets merged!

@zzarcon
Copy link
Contributor

zzarcon commented Oct 18, 2014

@pomartel thanks man! Right now I'm waiting some feedback of @t4t5. I also hope that this will be merged because it's very tedious to pass the defaults parameters for each new alert :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants