Better mechanics for this code?

Better mechanics for this code?

Hello, 
I have the following code and even though it does what i want to do i think that i write too many lines of code for this function.

In short, i have some modals in which i load forms dynamically with .html(). I want to add / remove in each modal opened the "modal-lg, modal-md" class etc.. in a better way. 

In my fiddle i use some if statements. Is there any other way to achieve this by using less lines of code?
I've tried addClass, removeClass, toggleClass etc.. but it doesn't seem to work as expected. 

HERE'S MY FIDDLE

Thank you!