Last active
August 29, 2015 14:22
-
-
Save noahub/a12b620b7cf756b11e0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(function($){ | |
var spacing = 20; /* Spacing between fields */ | |
var submitNewLine = false; /* Place the Submit button on a new line? */ | |
/* There's usually no need to change anything beyond here */ | |
var fields = $('div.lp-pom-form-field'); | |
fields = fields.add( $('.lp-pom-form .lp-pom-button').eq(0) ); | |
var width = fields.eq(0).width() + spacing; | |
var tallest = fields.eq(0).height(); | |
var maxWidth = $('.lp-pom-block').eq(0).width() - $('.lp-pom-form').eq(0).position().left; | |
var top = 0; | |
var left = 0; | |
for(var i=1; i<fields.length; i++){ | |
field = fields.eq(i); | |
left = left + width; | |
if(left + width > maxWidth){ | |
top = top + tallest + spacing; | |
left = 0; | |
tallest = field.height(); | |
} | |
if(field.attr('class').indexOf('lp-pom-button') != -1){ | |
if(submitNewLine == true){ | |
top = top + tallest + spacing; | |
left = 0; | |
}else{ | |
top = top + 10; /* Better aligns submit button with text field */ | |
} | |
} | |
field.css('top', top+'px'); | |
field.css('left', left+'px'); | |
if(field.height() > tallest){ | |
tallest = field.height(); | |
} | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment