From 84f700deae8196326d427003e4c357bc30c2e7e3 Mon Sep 17 00:00:00 2001
From: Oleg Tsoy <oleg_ts@live.ru>
Date: Mon, 29 Feb 2016 20:35:54 +0300
Subject: [PATCH] fix #125 double save press

---
 resources/app.js | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/resources/app.js b/resources/app.js
index 5ffa9ce2..6be56345 100644
--- a/resources/app.js
+++ b/resources/app.js
@@ -406,24 +406,13 @@ var app = {
 
 	formAlignmentAfterValidation : function(form){
 		// to avoid hiding of error message under the fixed nav bar
-		var destination = form.find(".formError:not('.greenPopup'):first").offset().top;
-		var resizedDestnation = destination-105;
-		jQuery('html').animate({
-			scrollTop:resizedDestnation
-		}, 'slow');
-	},
-
-	/**
-	 * Function to push down the error message size when validation is invoked
-	 * @params : form Element
-	 */
-	formAlignmentAfterValidation : function(form){
-		// to avoid hiding of error message under the fixed nav bar
-		var destination = form.find(".formError:not('.greenPopup'):first").offset().top;
-		var resizedDestnation = destination-105;
-		jQuery('html').animate({
-			scrollTop:resizedDestnation
-		}, 'slow');
+        var formOffset = form.find(".formError:not('.greenPopup'):first").offset();
+        if(formOffset !== null && typeof(formOffset) === 'object' && formOffset.hasOwnProperty('top')) {
+            var resizedDestnation = formOffset.top - 105;
+            $('html, body').animate({
+                scrollTop:resizedDestnation
+            }, 'slow');
+        }
 	},
 
 	convertToDatePickerFormat: function(dateFormat){
-- 
GitLab