Last active
August 29, 2015 14:22
Revisions
-
markwainwright revised this gist
Mar 17, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <script> // unbounce-horizontal-forms 7453328 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=window.lp.jQuery,this.$(function(){c.$form=c.$(".lp-pom-form").eq(0),c.$fields=c.$("div.lp-pom-form-field"),c.$button=c.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==c.submitPlacement&&(c.$fields=c.$fields.add(c.$button)),c.doLayout()}),this.$(window).resize(function(){c.doLayout()})}HorizontalForm.prototype.doLayout=function(){for(var a=this.$fields.eq(0).width()+this.spacing,b=this.$fields.eq(0).height(),c=this.$form.parent().width()-this.$form.position().left,d=0,e=0,f=0;f<this.$fields.length;f++){field=this.$fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=0===f?d:d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.$form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||(g=d+19);field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.$form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: -
markwainwright revised this gist
Feb 25, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ <script> // unbounce-horizontal-forms 8cc88e0 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=window.lp.jQuery,this.$(function(){c.form=c.$(".lp-pom-form").eq(0),c.fields=c.$("div.lp-pom-form-field"),c.button=c.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==c.submitPlacement&&(c.fields=c.fields.add(c.button)),c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=0===f?d:d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||(g=d+19);field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: // - 'inline': in line with the fields // - 'newline': on a new line // - 'manual': wherever you place the button in the page builder new HorizontalForm(20, 'manual'); </script> -
markwainwright revised this gist
Jan 15, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <script> // unbounce-horizontal-forms f137124 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=window.lp.jQuery,this.$(function(){c.form=c.$(".lp-pom-form").eq(0),c.fields=c.$("div.lp-pom-form-field"),c.button=c.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==c.submitPlacement&&(c.fields=c.fields.add(c.button)),c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||(g=d+19);field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: -
markwainwright revised this gist
Oct 15, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <script> // unbounce-horizontal-forms 9698416 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=lp.jQuery,this.form=this.$(".lp-pom-form").eq(0),this.fields=this.$("div.lp-pom-form-field"),this.button=this.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button)),this.$(function(){c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||(g=d+19);field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: -
markwainwright revised this gist
Oct 15, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <script> // unbounce-horizontal-forms 95bde91 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=lp.jQuery,this.form=this.$(".lp-pom-form").eq(0),this.fields=this.$("div.lp-pom-form-field"),this.button=this.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button)),this.$(function(){c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||field.find(":input").css("top","21px");field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: @@ -10,4 +10,4 @@ // - 'manual': wherever you place the button in the page builder new HorizontalForm(20, 'inline'); </script> -
markwainwright revised this gist
Oct 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // unbounce-horizontal-forms 15-10-2014 (1f9124a) function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=lp.jQuery,this.form=this.$(".lp-pom-form").eq(0),this.fields=this.$("div.lp-pom-form-field"),this.button=this.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button)),this.$(function(){c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||field.find(":input").css("top","21px");field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields, e.g. 20px // Second parameter is submit button placement. Options: // - 'inline': in line with the fields // - 'newline': on a new line -
markwainwright revised this gist
Oct 15, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <script> // unbounce-horizontal-forms 15-10-2014 (1f9124a) function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=lp.jQuery,this.form=this.$(".lp-pom-form").eq(0),this.fields=this.$("div.lp-pom-form-field"),this.button=this.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button)),this.$(function(){c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block-content").eq(0).width()-this.form.position().left,d=0,e=0,f=0;f<this.fields.length;f++){field=this.fields.eq(f),e=0===f?e:e+a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;if(field.is(".lp-pom-button"))if("newline"===this.submitPlacement)g=d+b+spacing,e=0;else{g=d+19;var h=this.form.find(":text").eq(0).height();field.css("height",h-1+"px")}else this.$(field).children("label").length||field.find(":input").css("top","21px");field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields // Second parameter is submit button placement. Options: @@ -10,4 +10,4 @@ // - 'manual': wherever you place the button in the page builder new HorizontalForm(20, 'inline'); </script> -
Mark Wainwright revised this gist
Jun 24, 2014 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ <script> // unbounce-horizontal-forms 24-06-2014 function HorizontalForm(a,b){var c=this;this.spacing=a,this.submitPlacement=b,this.$=lp.jQuery,this.form=this.$(".lp-pom-form").eq(0),this.fields=this.$("div.lp-pom-form-field"),this.button=this.$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button)),this.$(function(){c.layout()}),this.$(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=this.$(".lp-pom-block").eq(0).width()-this.form.position().left,d=0,e=0,f=1;f<this.fields.length;f++){field=this.fields.eq(f),e+=a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;field.is(".lp-pom-button")?"newline"===this.submitPlacement?(g=d+b+spacing,e=0):(g=d+19,field.css("height","32px")):this.$(field).children("label").length||(g=d+19),field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields // Second parameter is submit button placement. Options: -
Mark Wainwright revised this gist
Jun 12, 2014 . 2 changed files with 14 additions and 85 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ <script> // unbounce-horizontal-forms 12-06-2014 function HorizontalForm(a,b){this.spacing=a,this.submitPlacement=b,this.form=$(".lp-pom-form").eq(0),this.fields=$("div.lp-pom-form-field"),this.button=$(".lp-pom-form .lp-pom-button").eq(0),"manual"!==this.submitPlacement&&(this.fields=this.fields.add(this.button));var c=this;lp.jQuery(function(){c.layout()}),lp.jQuery(window).resize(function(){c.layout()})}HorizontalForm.prototype.layout=function(){for(var a=this.fields.eq(0).width()+this.spacing,b=this.fields.eq(0).height(),c=$(".lp-pom-block").eq(0).width()-this.form.position().left,d=0,e=0,f=1;f<this.fields.length;f++){field=this.fields.eq(f),e+=a,e+a>c&&(d=d+b+this.spacing,e=0,b=field.height());var g=d;field.is(".lp-pom-button")?"newline"===this.submitPlacement?(g=d+b+spacing,e=0):(g=d+19,field.css("height","32px")):$(field).children("label").length||(g=d+19),field.css({top:g+"px",left:e+"px"}),field.height()>b&&(b=field.height())}this.form.css({right:"0",width:"auto",height:d+b+"px"})}; // First parameter is spacing between fields // Second parameter is submit button placement. Options: // - 'inline': in line with the fields // - 'newline': on a new line // - 'manual': wherever you place the button in the page builder new HorizontalForm(20, 'inline'); </script> 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 charactersOriginal file line number Diff line number Diff line change @@ -1,85 +0,0 @@ -
markwainwright revised this gist
Apr 1, 2014 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -61,9 +61,7 @@ $(function(){ // If it's a field without a label, add additional vertical offset }else if(!$(field).children('label').length){ thisTop = top + 19; } // Position the field -
markwainwright revised this gist
Apr 1, 2014 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,9 +13,7 @@ $(function(){ var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); if(submitPlacement != 'manual') fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; @@ -31,7 +29,6 @@ $(function(){ // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later @@ -46,12 +43,11 @@ $(function(){ // Reset tallest to current field, for now tallest = field.height(); } var thisTop = top; if(field.is('.lp-pom-button')){ if(submitPlacement == 'newline'){ // Put button on new line -
markwainwright revised this gist
Mar 26, 2014 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,22 @@ $(function(){ // Spacing between fields, in pixels: var spacing = 20; // Options for the submit button placement are 'inline', 'newline' or 'manual': // Manual means the script won't touch the submit button - it can be positioned in the builder. var submitPlacement = 'inline'; // There's usually no need to change anything beyond here. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); if(submitPlacement != 'manual'){ fields = fields.add(button); } // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; @@ -47,7 +53,7 @@ $(function(){ if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitPlacement == 'newline'){ // Put button on new line thisTop = top + tallest + spacing; left = 0; -
markwainwright revised this gist
Mar 17, 2014 . 1 changed file with 58 additions and 60 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,87 +1,85 @@ $(function(){ var spacing = 20; // Spacing between fields, in pixels var submitNewLine = false; // Place the Submit button on a new line? // There's usually no need to change anything beyond here. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - form.position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } var thisTop = top; if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine === true){ // Put button on new line thisTop = top + tallest + spacing; left = 0; }else{ // Format button to better align with form fields thisTop = top + 19; field.css('height', '32px'); } // If it's a field without a label, add additional vertical offset }else if(!$(field).children('label').length){ thisTop = top + 19; } // Position the field field.css({ 'top': thisTop + 'px', 'left': left + 'px' }); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest) tallest = field.height(); } // Resize the form container so error boxes are positioned better form.css({ 'right': '0', 'width': 'auto', 'height': top + tallest +'px' }); }); -
markwainwright revised this gist
Mar 13, 2014 . 2 changed files with 87 additions and 91 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,91 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,87 @@ $(function(){ var spacing = 20; // Spacing between fields, in pixels var submitNewLine = false; // Place the Submit button on a new line? // There's usually no need to change anything beyond here. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - form.position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } var thisTop = top; if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine === true){ // Put button on new line thisTop = top + tallest + spacing; left = 0; }else{ // Format button to better align with form fields thisTop = top + 19; field.css('height', '32px'); } // If it's a field without a label, add additional vertical offset }else if(!$(field).children('label').length){ thisTop = top + 19; } // Position the field field.css({ 'top': thisTop + 'px', 'left': left + 'px' }); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } // Resize the form container so error boxes are positioned better form.css({ 'right': '0', 'width': 'auto', 'height': top + tallest +'px' }); }); -
markwainwright revised this gist
Mar 13, 2014 . 1 changed file with 63 additions and 55 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,81 +2,89 @@ $(function(){ var spacing = 20; // Spacing between fields, in pixels var submitNewLine = false; // Place the Submit button on a new line? // There's usually no need to change anything beyond here. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - form.position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } var thisTop = top; if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine === true){ // Put button on new line thisTop = top + tallest + spacing; left = 0; }else{ // Format button to better align with form fields thisTop = top + 19; field.css('height', '32px'); } // If it's a field without a label, add additional vertical offset }else if(!$(field).children('label').length){ thisTop = top + 19; } // Position the field field.css({ 'top': thisTop + 'px', 'left': left + 'px' }); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } // Resize the form container so error boxes are positioned better form.css({ 'right': '0', 'width': 'auto', 'height': top + tallest +'px' }); }); -
markwainwright revised this gist
Mar 10, 2014 . 1 changed file with 79 additions and 79 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,83 +1,83 @@ <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. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - form.position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } // If the field is a button, either display it on a new line or alongside fields if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine === true){ top = top + tallest + spacing; left = 0; }else{ // Adding 10px better aligns submit button with text fields top = top + 10; } } // Position the field field.css({ 'top': top + 'px', 'left': left + 'px' }); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } // Resize the form container so error boxes are positioned better form.css({ 'right': '0', 'width': 'auto', 'height': top + tallest +'px' }); }); </script> -
markwainwright revised this gist
Mar 10, 2014 . 1 changed file with 76 additions and 62 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,68 +1,82 @@ <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. // Grab all form fields and the submit button var form = $('.lp-pom-form').eq(0); var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); fields = fields.add(button); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - form.position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } // If the field is a button, either display it on a new line or alongside fields if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine === true){ top = top + tallest + spacing; left = 0; }else{ // Adding 10px better aligns submit button with text fields top = top + 10; } } // Position the field field.css({ 'top': top + 'px', 'left': left + 'px' }); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } // Resize the form container so error boxes are positioned better form.css({ 'right': '0', 'width': 'auto', 'height': top + tallest +'px' }); }); -
markwainwright revised this gist
Mar 10, 2014 . 2 changed files with 69 additions and 65 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ <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. // Grab all form fields and the submit button var fields = $('div.lp-pom-form-field'); fields = fields.add( $('.lp-pom-form .lp-pom-button').eq(0) ); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - $('.lp-pom-form').eq(0).position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } // If the field is a button, either display it on a new line or alongside fields if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine == true){ top = top + tallest + spacing; left = 0; }else{ // Adding 10px better aligns submit button with text fields top = top + 10; } } // Position the field field.css('top', top+'px'); field.css('left', left+'px'); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } }); </script> 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 charactersOriginal file line number Diff line number Diff line change @@ -1,65 +0,0 @@ -
markwainwright revised this gist
Mar 7, 2014 . 2 changed files with 65 additions and 69 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,69 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ $(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. // Grab all form fields and the submit button var fields = $('div.lp-pom-form-field'); fields = fields.add( $('.lp-pom-form .lp-pom-button').eq(0) ); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - $('.lp-pom-form').eq(0).position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } // If the field is a button, either display it on a new line or alongside fields if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine == true){ top = top + tallest + spacing; left = 0; }else{ // Adding 10px better aligns submit button with text fields top = top + 10; } } // Position the field field.css('top', top+'px'); field.css('left', left+'px'); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } } }); -
markwainwright revised this gist
Mar 7, 2014 . 1 changed file with 25 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,42 +2,63 @@ $(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. // Grab all form fields and the submit button var fields = $('div.lp-pom-form-field'); fields = fields.add( $('.lp-pom-form .lp-pom-button').eq(0) ); // Work out the horizontal offset of fields var width = fields.eq(0).width() + spacing; // Record the first field's height as tallest for now var tallest = fields.eq(0).height(); // Get the maximum width the form can be var maxWidth = $('.lp-pom-block').eq(0).width() - $('.lp-pom-form').eq(0).position().left; var top = 0; var left = 0; // Loop through each field for(var i=1; i<fields.length; i++){ field = fields.eq(i); // Add a new 'width' amount to last field's left position for placement later left = left + width; // Check if the right edge of this field will be beyond maximum width if(left + width > maxWidth){ // If so, start a new line under the tallest field on current line top = top + tallest + spacing; left = 0; // Reset tallest to current field, for now tallest = field.height(); } // If the field is a button, either display it on a new line or alongside fields if(field.attr('class').indexOf('lp-pom-button') != -1){ if(submitNewLine == true){ top = top + tallest + spacing; left = 0; }else{ // Adding 10px better aligns submit button with text fields top = top + 10; } } // Position the field field.css('top', top+'px'); field.css('left', left+'px'); // If this field is taller than the others on this line so far, record it as the tallest if(field.height() > tallest){ tallest = field.height(); } -
markwainwright revised this gist
Mar 4, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <script type="text/javascript"> $(function(){ var spacing = 20; /* Spacing between fields */ var submitNewLine = false; /* Place the Submit button on a new line? */ -
markwainwright revised this gist
Mar 4, 2014 . 1 changed file with 39 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,48 @@ <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> -
markwainwright created this gist
Mar 4, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <script type="text/javascript"> $(function(){ var gap = 20; /* Horizontal space between fields */ var fields = $('div.lp-pom-form-field'); var button = $('.lp-pom-form .lp-pom-button').eq(0); var offset = fields.eq(0).width()+gap; for(var i=1; i<fields.length; i++){ fields.eq(i).css('top','0'); fields.eq(i).css('left',offset*i+'px'); } button.css('top',fields.eq(0).height()-button.height()+'px'); button.css('left',offset*fields.length+'px'); }); </script>