first you have to make a unique root namespace like that :
window.Accordian = window.Accordian || {};
This part must be done on top of all the next !
it Can be done in the head of html page in a script tag.
after you can use your object :
//creating a function :
Accordian.slide = function() {
$('h3').click( function() {
$(this).next('div').slideToggle('1000');
$(this).toggleClass('toggled');
});
}
//and later using it :
Accordian.slide()
This is the simplest way !
You prefered using multiple file, so let's try :
mains.js
/*$*/( function(globalAccordian) {
"use strict"
/* var Accordian = { */
globalAccordian = {
// doing like this will override your globalAccordian
// if it was already generated by another script
slide : function() {
$('h3').click( function() {
$(this).next('div').slideToggle('1000');
$(this).toggleClass('toggled');
});
},
slideEaseOutBounce: function() {
$('h3').click( function() {
$(this).next().animate(
{'height' : 'toggle'}, 1000, 'easeOutBounce'
);
$(this).toggleClass('toggled');
});
},
slideEaseInOutExpo: function() {
$('h3').click( function() {
$(this).next().animate(
{'height' : 'toggle'}, 1000, 'easeInOutExpo'
);
$(this).toggleClass('toggled');
});
}
})( window.Accordian || {} );
script.js
$(document).ready( function() {
Accordian.slide();
})