Skip to content

Instantly share code, notes, and snippets.

@ryanschuhler
Last active November 16, 2015 18:36
Show Gist options
  • Select an option

  • Save ryanschuhler/14fdecfd2cad208d6a0f to your computer and use it in GitHub Desktop.

Select an option

Save ryanschuhler/14fdecfd2cad208d6a0f to your computer and use it in GitHub Desktop.
osb_height_equalizer.js
AUI.add(
'osb-height-equalizer',
function(A) {
var OSBHeightEqualizer = A.Component.create(
{
ATTRS: {
container: {
value: '.equal-height-container'
},
_height: {
value: '0'
}
},
NAME: 'osb-height-equalizer',
prototype: {
bindUI: function() {
var instance = this;
A.on('load', instance.syncUI, instance);
A.on('resize', instance.syncUI, instance);
},
syncUI: function() {
var instance = this;
instance._findHeight();
instance._setHeight();
},
_findHeight: function() {
var instance = this;
var heights = [];
A.all(instance.get('container')).each(
function(node) {
node.setStyle('height', 'auto');
heights.push(node.height());
}
);
instance.set('_height', Math.max.apply(null, heights));
},
_setHeight: function() {
var instance = this;
A.all(instance.get('container')).each(
function(node) {
node.setStyle('height', instance.get('_height'));
}
);
}
}
}
);
A.OSBHeightEqualizer = OSBHeightEqualizer;
},
'1.5.2',
{
requires:['aui-base']
}
);
AUI().use(
'osb-height-equalizer',
function(A) {
window.test = A;
var row = new A.OSBHeightEqualizer({
"container" : ".download-bullets ul"
}).render();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment