From 5cb79f62824fdb0ddbbda9ac4e4dfcf2eef42393 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Wed, 31 Aug 2016 14:04:45 +0200 Subject: [PATCH] Fix the default parameters in JS This was causing major issues in IE. --- app/assets/javascripts/comments.js | 6 ++++-- app/assets/javascripts/sitewide/form_errors.js | 3 ++- app/assets/javascripts/sitewide/form_validators.js.erb | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/comments.js b/app/assets/javascripts/comments.js index 02b3e5a8d..55eba53fc 100644 --- a/app/assets/javascripts/comments.js +++ b/app/assets/javascripts/comments.js @@ -1,4 +1,5 @@ -function initCommentOptions(scrollableContainer, useParentOffset = true) { +function initCommentOptions(scrollableContainer, useParentOffset) { + useParentOffset = (typeof useParentOffset !== 'undefined') ? useParentOffset : true; scrollCommentOptions($(".dropdown-comment"), useParentOffset); // Reposition dropdown to the left @@ -25,7 +26,8 @@ function initCommentOptions(scrollableContainer, useParentOffset = true) { }, true); } -function scrollCommentOptions(selector, useParentOffset = true) { +function scrollCommentOptions(selector, useParentOffset) { + useParentOffset = (typeof useParentOffset !== 'undefined') ? useParentOffset : true; _.each(selector, function(el) { var $el = $(el); var offset = useParentOffset ? $el.offset().top : $el.position().top; diff --git a/app/assets/javascripts/sitewide/form_errors.js b/app/assets/javascripts/sitewide/form_errors.js index adbb2c746..8695dcf6d 100644 --- a/app/assets/javascripts/sitewide/form_errors.js +++ b/app/assets/javascripts/sitewide/form_errors.js @@ -5,7 +5,8 @@ /* * Render errors specified in JSON format for many form elements. */ -$.fn.renderFormErrors = function (modelName, errors, clear = true, ev) { +$.fn.renderFormErrors = function (modelName, errors, clear, ev) { + clear = (typeof clear !== 'undefined') ? clear : true; if (clear || _.isUndefined(clear)) { this.clearFormErrors(); } diff --git a/app/assets/javascripts/sitewide/form_validators.js.erb b/app/assets/javascripts/sitewide/form_validators.js.erb index 6b0045616..f42afec50 100644 --- a/app/assets/javascripts/sitewide/form_validators.js.erb +++ b/app/assets/javascripts/sitewide/form_validators.js.erb @@ -18,7 +18,9 @@ $.fn.onSubmitValidator = function(validatorCb) { } }; -function textValidator(ev, textInput, canBeBlank = false, limitLength = true) { +function textValidator(ev, textInput, canBeBlank) { + canBeBlank = (typeof canBeBlank !== 'undefined') ? canBeBlank : false; + limitLength = (typeof limitLength !== 'undefined') ? limitLength : true; var nameTooShort = $(textInput).val().length === 0; var nameTooLong = $(textInput).val().length > 50; var errMsg;