Fixed NodeList.forEach (and some refactoring)
This commit is contained in:
parent
f234a64df7
commit
52bbdb1a09
2 changed files with 33 additions and 34 deletions
|
@ -12,9 +12,3 @@
|
||||||
{{#translate}}JavaScript must be enabled in order for this form to work{{/translate}}
|
{{#translate}}JavaScript must be enabled in order for this form to work{{/translate}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<script>
|
|
||||||
document.querySelectorAll('.js-warning').forEach(function(el) {
|
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
|
@ -1,41 +1,46 @@
|
||||||
<script>
|
<script>
|
||||||
var btnBgColor = '{{btnBgColor}}';
|
(function () {
|
||||||
var btnBgColorHover = '{{btnBgColorHover}}';
|
var forEach = function (array, callback, scope) {
|
||||||
|
for (var i = 0; i < array.length; i++) {
|
||||||
if (typeof moment !== 'undefined' && moment.tz) {
|
callback.call(scope, i, array[i]);
|
||||||
(function () {
|
|
||||||
var tz = moment.tz.guess();
|
|
||||||
if (tz) {
|
|
||||||
document.querySelectorAll('.tz-detect').forEach(function(el) {
|
|
||||||
el.value = tz;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll('a[href="#submit"]').forEach(function(a) {
|
|
||||||
a.onclick = function() {
|
|
||||||
var form = document.getElementById('main-form');
|
|
||||||
form && form.submit();
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
||||||
// Fixes MJML Button until they do ...
|
forEach(document.querySelectorAll('.js-warning'), function(i, el) {
|
||||||
// https://github.com/mjmlio/mjml/issues/359
|
el.style.display = 'none';
|
||||||
|
});
|
||||||
|
|
||||||
if (window.btnBgColor) {
|
forEach(document.querySelectorAll('a[href="#submit"]'), function(i, a) {
|
||||||
(function() {
|
a.onclick = function() {
|
||||||
|
var form = document.getElementById('main-form');
|
||||||
|
form && form.submit();
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof moment !== 'undefined' && moment.tz) {
|
||||||
|
forEach(document.querySelectorAll('.tz-detect'), function(i, el) {
|
||||||
|
el.value = moment.tz.guess() || '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fixes MJML Button until they do ...
|
||||||
|
// https://github.com/mjmlio/mjml/issues/359
|
||||||
|
|
||||||
|
var btnBgColor = '{{btnBgColor}}';
|
||||||
|
var btnBgColorHover = '{{btnBgColorHover}}';
|
||||||
|
|
||||||
|
if (btnBgColor) {
|
||||||
var s = document.createElement('style');
|
var s = document.createElement('style');
|
||||||
var c = document.createTextNode(
|
var c = document.createTextNode(
|
||||||
'.td-btn:hover { background-color: ' + window.btnBgColorHover + '; }' +
|
'.td-btn:hover { background-color: ' + btnBgColorHover + '; }' +
|
||||||
'.td-btn { cursor: pointer !important; }' +
|
'.td-btn { cursor: pointer !important; }' +
|
||||||
'.a-btn { background-color: transparent !important; }'
|
'.a-btn { background-color: transparent !important; }'
|
||||||
);
|
);
|
||||||
s.appendChild(c);
|
s.appendChild(c);
|
||||||
document.getElementsByTagName('head')[0].appendChild(s);
|
document.getElementsByTagName('head')[0].appendChild(s);
|
||||||
document.querySelectorAll('a').forEach(function(a) {
|
forEach(document.querySelectorAll('a'), function(i, a) {
|
||||||
if (a.parentNode.getAttribute('bgcolor') === window.btnBgColor) {
|
if (a.parentNode.getAttribute('bgcolor') === btnBgColor) {
|
||||||
a.target = '_self';
|
a.target = '_self';
|
||||||
a.className += 'a-btn';
|
a.className += 'a-btn';
|
||||||
a.parentNode.className += 'td-btn';
|
a.parentNode.className += 'td-btn';
|
||||||
|
@ -44,8 +49,8 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
}
|
||||||
}
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- custom scripts from config -->
|
<!-- custom scripts from config -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue