Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Consolidated two of the new classes into one.
Browse files Browse the repository at this point in the history
  • Loading branch information
deleteme committed Sep 9, 2009
1 parent 6b0db65 commit 43bbce7
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions javascripts/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@ Example Markup structure:
</ul>
*/
var CanFireEvents = Class.create({
initialize: function(name){
this.name = name;
},
fireEvent: function (state, memo) {
//console.log(this.name + ':' + state, memo);
document.fire(this.name + ':' + state, memo);
}
});

var CanBeDisabled = Class.create(CanFireEvents, {
initialize: function ($super, name, element, memo, disabled) {
var CanBeDisabledAndFireEvents = Class.create({
initialize: function (name, element, memo, disabled) {
console.log(arguments);
this.disabled = disabled || false;
this.elementToBeDisabled = element;
$super(name, memo);
this.name = name;
if (this.disabled) this.disable();
},
disable: function () {
Expand All @@ -42,12 +33,16 @@ var CanBeDisabled = Class.create(CanFireEvents, {
toggleDisabled: function(){
if (this.disabled) this.enable();
else this.disable();
},
fireEvent: function (state, memo) {
console.log(this.name + ':' + state, memo);
document.fire(this.name + ':' + state, memo);
}
});



var Accordion = Class.create(CanBeDisabled, {
var Accordion = Class.create(CanBeDisabledAndFireEvents, {
initialize: function($super, id, options){
this.id = id;
this.root = $(id);
Expand All @@ -60,7 +55,7 @@ var Accordion = Class.create(CanBeDisabled, {
disabled: false
}, options || {});

$super(this.id, this.root, this.options.disabled);
$super(id, this.root, this.options.disabled);

this.accordionEffectOptions = $H({
duration: this.options.effectDuration,
Expand All @@ -84,7 +79,7 @@ var Accordion = Class.create(CanBeDisabled, {
this.root.observe('click', this.rootObserver.bind(this));
},
rootObserver: function(e){
var el = e.element();
var el = e.findElement();
if (el.up('.' + this.options.classNames.title)) el = el.up('.' + this.options.classNames.title);

if (el.match('.' + this.options.classNames.title)) {
Expand Down Expand Up @@ -151,7 +146,7 @@ var Accordion = Class.create(CanBeDisabled, {
}
});

var AccordionSection = Class.create(CanBeDisabled, {
var AccordionSection = Class.create(CanBeDisabledAndFireEvents, {
initialize: function($super, i, accordion){
this.index = i;
this.accordion = accordion;
Expand Down

0 comments on commit 43bbce7

Please sign in to comment.