I am creating a plugin that allows the user to define the notification by typing something like this.
growl-top-left-300px;
I was using a split to get rid the width, but this still required me to have quite a few if statements because I user had the following choices
for example I had
if (position == "growl-top-left" || position == "growl-left-top") {
container.css ({
top: '0px',
left: '0px'
});
}else if (position == "growl-top-right" || position == "growl-right-top") {
container.css ({
top: '0px',
right: '0px'
});
}else if (position == "growl-top-center" || position == "growl-center-top") {
// apply css // Not done yet
}else if (position == "growl-bottom-left" || position == "growl-left-bottom") {
container.css ({
bottom: '0px',
left: '0px'
});
}else if (position == "growl-bottom-right" || position == "growl-right-bottom") {
container.css ({
bottom: '0px',
right: '0px'
});
}else if (position == "growl-bottom-center" || position == "growl-center-bottom") {
// apply css // not done yet
}
but as you can imagine that seems like a lot of redundant code, and I just want to know if anyone has a nicer way to clean it up?
I thought it would be nice if I could get the top and left css values so I can write the following code:
container.css ({
retrivedCSS[0]: '0px',
retrivedCSS[1]: '0px'
})
where retrivedCSS[0] would be the first position and the [1] would be the second position
if's? If it has something like settingtopandleftforgrowl-left-top, then I have a trick ;)