mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Support IE11
Previously `let of` loop was used, which isn't supported in IE11. It seems it just fails when there is some JS syntax error (doesn't matter where exactly) and dataType: 'json' has no effect. Closes #982
This commit is contained in:
parent
8666f4f714
commit
02f9e99428
6 changed files with 35 additions and 8 deletions
|
@ -8,6 +8,10 @@
|
|||
#= require jquery-ui/datepicker
|
||||
#= require select2
|
||||
#= require jquery.doubleScroll
|
||||
|
||||
# Load order does matter
|
||||
#= require polyfills/node_list_for_each
|
||||
|
||||
#= require datepicker
|
||||
#= require spell_check
|
||||
#= require admin/application
|
||||
|
|
11
app/assets/javascripts/polyfills/node_list_for_each.js
Normal file
11
app/assets/javascripts/polyfills/node_list_for_each.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Needed mainly for IE11
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
|
||||
|
||||
if (window.NodeList && !NodeList.prototype.forEach) {
|
||||
NodeList.prototype.forEach = function (callback, thisArg) {
|
||||
thisArg = thisArg || window;
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
callback.call(thisArg, this[i], i, this);
|
||||
}
|
||||
};
|
||||
}
|
|
@ -4,5 +4,9 @@
|
|||
#= require jquery-ui/datepicker
|
||||
#= require select2
|
||||
#= require datepicker
|
||||
|
||||
# Load order does matter
|
||||
#= require polyfills/node_list_for_each
|
||||
|
||||
#= require spell_check
|
||||
#= require shared/general
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#= require jquery-ui/datepicker
|
||||
#= require select2
|
||||
#= require datepicker
|
||||
|
||||
# Load order does matter
|
||||
#= require polyfills/node_list_for_each
|
||||
|
||||
#= require spell_check
|
||||
#= require popover
|
||||
#= require text_field_trimmer
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
(function() {
|
||||
(function () {
|
||||
function disableSpellCheck() {
|
||||
let selector = 'input[type=text], textarea';
|
||||
let textFields = document.querySelectorAll(selector);
|
||||
|
||||
for (let field of textFields) {
|
||||
field.spellcheck = false;
|
||||
}
|
||||
textFields.forEach(
|
||||
function (field, _currentIndex, _listObj) {
|
||||
field.spellcheck = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
disableSpellCheck();
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
function trimTextFields() {
|
||||
let selector = 'input[type=text], input[type=search], input[type=email], textarea';
|
||||
let textFields = document.querySelectorAll(selector);
|
||||
let listener = function () {
|
||||
let changeListener = function () {
|
||||
this.value = this.value.trim();
|
||||
};
|
||||
|
||||
for (let field of textFields) {
|
||||
field.addEventListener('change', listener);
|
||||
}
|
||||
textFields.forEach(
|
||||
function (field, currentIndex, listObj) {
|
||||
field.addEventListener('change', changeListener);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
trimTextFields();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue