From 1f1259c373322b2379c10deee3cb7658054aec23 Mon Sep 17 00:00:00 2001 From: Eric Chan Chin Hoe Date: Wed, 9 Nov 2016 19:53:15 +0800 Subject: [PATCH] Do not equalize field height when screen size is lesser than 700px After the forms are being condensed in mobile view, it should stop equalising the height of the fields as it has only 1 field per row. --- gridforms/gridforms.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gridforms/gridforms.js b/gridforms/gridforms.js index b4b12d5..633160e 100644 --- a/gridforms/gridforms.js +++ b/gridforms/gridforms.js @@ -44,7 +44,7 @@ jQuery(function($) { var that = this; that.el.fieldsContainers.click(function(event) { var focusableFields = that.el.focusableFields.selector; - + if (!$(event.target).is(focusableFields)) { $(this).find('input[type="text"],input[type="number"],input[type="tel"],input[type="email"], textarea, select').first().focus(); } @@ -66,11 +66,11 @@ jQuery(function($) { var fieldsRows = this.el.fieldsRows; var fieldsContainers = this.el.fieldsContainers; - // Make sure that the fields aren't stacked - if (!this.areFieldsStacked()) { + // Make sure that the fields aren't stacked and window width is more than 700px + if (!this.areFieldsStacked() && $(window).width() > 700) { fieldsRows.filter(":visible").each(function() { var fieldRow = $(this); - + // Singleton textarea rows should determine their row height var rowInputs = fieldRow.children(); if (rowInputs.length === 1 && rowInputs.children("textarea").length === 1) return; @@ -84,13 +84,13 @@ jQuery(function($) { } }, areFieldsStacked: function() { - // Get the first row - // which does not only contain one field + // Get the first row + // which does not only contain one field var firstRow = this.el.fieldsRows .not('[data-row-span="1"]') .first(); - // Get to the total width + // Get to the total width // of each field witin the row var totalWidth = 0; firstRow.children().each(function() {