Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created February 1, 2010 03:14
Show Gist options
  • Select an option

  • Save whalesalad/291427 to your computer and use it in GitHub Desktop.

Select an option

Save whalesalad/291427 to your computer and use it in GitHub Desktop.
init_accordion: function() {
var contact = this;
window.currently_open = null;
var Office = function() {
var self = this,
args = arguments;
self.init.apply(self, args);
};
Office.prototype = {
init: function(office, index) {
var self = this;
self.index = index;
self.office = office;
self.link = office.children('h4').children('a');
self.link.bind('click', function(event) {
if (self.is_open()) {
return false;
}
window.currently_expanded.collapse();
self.expand();
return false;
});
if (self.is_open()) window.currently_expanded = self;
},
is_open: function() {
var self = this;
return (self.office.hasClass('expanded')) ? true : false;
},
expand: function() {
var self = this;
contact.map.panTo(contact.office_locations[self.index]);
self.office.addClass('expanded');
window.currently_expanded = self;
},
collapse: function() {
var self = this;
self.office.removeClass('expanded');
}
};
/*
For each of the office items in the list (the items which will compose the accordion),
create a new office object which will do all of the heavy lifting.
*/
$('.locationAccordion .location').each(function(index) {
new Office($(this), index);
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment