Skip to content
Browse files

Fx.Accordion no longer modifies the DOM order of its elements; added …

…an option and capability to show section without effects (for startup)

Fixed a bug in Formvaldiator where it referenced the namespace instead of "this"
  • Loading branch information...
1 parent 5d50307 commit ff2a6b88608cf91cc602b99e57b8eae2c2e3a63b @anutron anutron committed Mar 19, 2009
Showing with 13 additions and 20 deletions.
  1. +2 −2 Docs/Fx/Fx.Accordion.md
  2. +2 −0 README.md
  3. +1 −1 Source/Forms/FormValidator.js
  4. +8 −17 Source/Fx/Fx.Accordion.js
View
4 Docs/Fx/Fx.Accordion.md
@@ -34,6 +34,7 @@ The *Fx.Accordion* class creates a group of Elements that are toggled when their
* fixedHeight - (*boolean*: defaults to false) If set to true, displayed elements will have a fixed height.
* fixedWidth - (*boolean*: defaults to false) If set to true, displayed elements will have a fixed width.
* alwaysHide - (*boolean*: defaults to false) If set to true, it will be possible to close all displayable elements. Otherwise, one will remain open at all time.
+* initialDisplayFx - (*boolean*; defaults to true) If set to false, the initial item displayed will not display with an effect but will just be shown immediately.
### Returns:
@@ -87,13 +88,12 @@ Dynamically adds a new section into the *Fx.Accordion* at the specified position
### Syntax:
- myAccordion.addSection(toggler, element[, pos]);
+ myAccordion.addSection(toggler, element);
### Arguments:
1. toggler - (*element*) The Element that toggles the *Fx.Accordion* section open.
2. element - (*element*) The Element that should stretch open when the toggler is clicked.
-3. pos - (*integer*, optional) The index at which these objects are to be inserted within the *Fx.Accordion* (defaults to the end).
### Returns:
View
2 README.md
@@ -24,6 +24,8 @@ MooTools Plugins and Enhancements Repository
* URI
- domain renamed to host
+* Fx.Accordion
+ - no longer organizes the DOM for you
### Breaking Changes from More
View
2 Source/Forms/FormValidator.js
@@ -240,7 +240,7 @@ var FormValidator = new Class({
ignoreField: function(field, warn){
field = $(field);
if (field){
- FormValidator.enforceField(field);
+ this.enforceField(field);
if (warn) field.addClass('warnOnly');
else field.addClass('ignoreValidation');
}
View
25 Source/Fx/Fx.Accordion.js
@@ -25,7 +25,8 @@ Fx.Accordion = new Class({
fixedWidth: false,
wait: false,
alwaysHide: false,
- trigger: 'click'
+ trigger: 'click',
+ initialDisplayFx: true
},
initialize: function(){
@@ -55,24 +56,15 @@ Fx.Accordion = new Class({
for (var fx in this.effects) el.setStyle(fx, 0);
}
}, this);
- if ($chk(this.options.display)) this.display(this.options.display);
+ if ($chk(this.options.display)) this.display(this.options.display, this.options.initialDisplayFx);
},
- addSection: function(toggler, element, pos){
+ addSection: function(toggler, element){
toggler = $(toggler);
element = $(element);
var test = this.togglers.contains(toggler);
- var len = this.togglers.length;
this.togglers.include(toggler);
this.elements.include(element);
- if (len && (!test || pos)){
- pos = $pick(pos, len - 1);
- toggler.inject(this.togglers[pos], 'before');
- element.inject(toggler, 'after');
- } else if (this.container && !test){
- toggler.inject(this.container);
- element.inject(this.container);
- }
var idx = this.togglers.indexOf(toggler);
toggler.addEvent(this.options.trigger, this.display.bind(this, idx));
if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'});
@@ -81,13 +73,12 @@ Fx.Accordion = new Class({
if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth;
if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight;
element.setStyle('overflow', 'hidden');
- if (!test){
- for (var fx in this.effects) element.setStyle(fx, 0);
- }
+ if (!test) for (var fx in this.effects) element.setStyle(fx, 0);
return this;
},
- display: function(index){
+ display: function(index, useFx){
+ useFx = $pick(useFx, true);
index = ($type(index) == 'element') ? this.elements.indexOf(index) : index;
if ((this.timer && this.options.wait) || (index === this.previous && !this.options.alwaysHide)) return this;
this.previous = index;
@@ -98,7 +89,7 @@ Fx.Accordion = new Class({
this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el]);
for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]];
}, this);
- return this.start(obj);
+ return useFx ? this.start(obj) : this.set(obj);
}
});

0 comments on commit ff2a6b8

Please sign in to comment.
Something went wrong with that request. Please try again.