So I am trying to write a jQuery plugin and I have three values that I would like to set the defaults for one is a simple numeric value the others can be set if the user wants, but if they do not set them they need to have a default value of whatever the first is set.
Here is a longer version of what I want
config.duration = 350;
config.closeDuration = closeDuration OR duration;
config.openDuration = openDuration OR duration;
Basically if they are not set default back to whatever the duration value is. Even if the value has been set by the user. (eg. duration = 500)
I am just wondering if there is anyway to streamline this?
jQuery.fn.lighthouse = function(settings) {
var config = {
containerSelector: 'a',
childSelector: 'span',
closeSelector: '.close',
duration: 350,
openDuration: config.duration,
closeDuration: config.duration,
secondaryDuration: 100,
background: 'rgb(230, 230, 230)',
backgroundOpacity: '0.7'
};
if (settings){
config = $.extend(config, settings);
}
}