Hello,
I''m having the following code below - when I click on the button in
order to
toggle a div, it is working when the div is visible - after it is toggled
once, the beforeStart stuff isn''t executed anymore!
interestingly, when I change this Effect.toggle(this.bContentWrap,
''blind'',
{
to this: Effect.toggle(this.bContentWrap, ''slide'', {
everything seems to work.
does anybody have an idea what''s causing this?
thank you in advance for your help.
// sidebar boxes
Effect.SizeBox = Class.create();
Object.extend(Object.extend(Effect.SizeBox.prototype,
Effect.Base.prototype), {
initialize: function(element) {
this.element = $(element);
Element.cleanWhitespace(this.element);
$A(this.element.getElementsByTagName(''*'')).each(
function(el) {
try {
Element.cleanWhitespace(el);
}
catch (e) {}
});
this.bContainer = this.element;
this.bContainerId = this.bContainer.getAttribute(''id'');
this.bTitle = this.bContainer.childNodes[0];
this.bBtnToggle =
this.bTitle.getElementsByTagName(''IMG'')[0];
this.bContentWrap = this.bContainer.childNodes[1];
this.bContent = this.bContentWrap.childNodes[0];
this.originalHeight = Element.getHeight(this.bContentWrap);
this.boolUpdate = false;
this.btnToggleClick = this.toggle.bindAsEventListener(this);
Event.observe(this.bBtnToggle, ''click'',
this.btnToggleClick);
},
toggle: function() {
Effect.toggle(this.bContentWrap, ''slide'', {
beforeStart: function() {
if (this.bContainerId == ''fm-box-0'') {
//alert(''info box toggled'');
if (!Element.visible(this.bContentWrap)) {
var oHeight = this.originalHeight*-1;
this.resize(oHeight) ;
this.boolUpdate = true;
}
}
}.bind(this),
afterFinish: function() {
if (this.bContainerId == ''fm-box-0'') {
var oHeight = this.originalHeight;
this.resize(oHeight);
this.boolUpdate = false;
}
this.update();
}.bind(this)
})
},
resize: function(oHeight) {
if (!this.boolUpdate) {
Element.setStyle(treeBox.bContentWrap, {height:
(Element.getHeight(treeBox.bContentWrap) > 0) ?
(Element.getHeight(treeBox.bContentWrap) + oHeight) + ''px'' : 0
+ ''px''});
Element.setStyle(treeBox.bContent, {height:
(parseFloat(Element.getStyle(treeBox.bContent, ''height'')) +
oHeight) +
''px''});
}
},
update: function() {
(Element.visible(this.bContentWrap)) ?
this.bBtnToggle.setAttribute(''title'',
''Collapse'') :
this.bBtnToggle.setAttribute(''title'',
''Expand'');
(Element.visible(this.bContentWrap)) ?
Element.removeClassName(this.bBtnToggle,''fm-btn-expand'') :
Element.removeClassName(this.bBtnToggle,''fm-btn-collapse'');
(Element.visible(this.bContentWrap)) ?
Element.addClassName(this.bBtnToggle,''fm-btn-collapse'') :
Element.addClassName(this.bBtnToggle, ''fm-btn-expand'');
}
});
Marco M. Jaeger | Url: http://mmjaeger.com <http://mmjaeger.com/> |
E-mail:
mail-yVS5avHIROZWk0Htik3J/w@public.gmane.org
Do you need business consulting, webdesign or webhosting: please visit
http://j-cons.com <http://j-cons.com/> or please contact me at
mail-tqBp8EdZ1v6Xj1p+fO2waQ@public.gmane.org
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs