Fixed forms submission in IE (fixes #19)

This commit is contained in:
Djamil Legato
2015-08-07 11:06:06 -07:00
parent b8c197e4ed
commit fc5837bd76
6 changed files with 122 additions and 34 deletions

View File

@@ -1,3 +1,9 @@
# v0.2.1
## XX/XX/2015
1. [](#bugfix)
* Fixed form submission not working in IE
# v0.2.0
## 08/06/2015

View File

@@ -445,7 +445,7 @@ hr {
*/
.switch-grav {
background-color: #fff;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
border-radius: 4px;
/* Selected ON switch-light
*/ }
@@ -574,7 +574,7 @@ form .selectize-control.multi .selectize-input {
border-radius: 2px;
line-height: 1.5; }
form .selectize-control.multi .selectize-input > div.active {
background: #d5d5d5; }
background: #d4d4d4; }
form .selectize-control.single .selectize-input:after {
right: 27px; }
form .selectize-control.single .selectize-input.dropdown-active:after {
@@ -593,7 +593,7 @@ form .large {
height: 10rem; }
form select {
width: 100%;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
background: #fff;
-webkit-appearance: none;
-moz-appearance: none;
@@ -603,17 +603,17 @@ form select {
margin: 0; }
form input[type=text], form input[type=password], form input[type=email] {
width: 100%;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
background: #fff; }
form input[readonly=readonly] {
background: #f2f2f2;
font-weight: bold; }
form textarea {
width: 100%;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
background: #fff; }
form .form-frontmatter-wrapper {
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
border-radius: 4px; }
form .switch-toggle.medium {
width: 100%;
@@ -662,7 +662,7 @@ form .checkboxes {
margin-right: 10px;
position: absolute;
background: #fff;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
border-radius: 4px; }
form .checkboxes input[type=checkbox] {
display: none; }
@@ -670,7 +670,7 @@ form .checkboxes {
content: "\f00c";
font-family: "FontAwesome";
font-size: 1.2rem;
line-height: 1.5rem;
line-height: 1;
text-align: center; }
form .checkboxes.toggleable label {
margin-right: 0; }
@@ -679,7 +679,7 @@ form .checkboxes {
margin-bottom: 3rem; }
.form-frontmatter-wrapper .dragbar {
height: 4px;
background: #d5d5d5;
background: #d4d4d4;
cursor: row-resize; }
#frontmatter + .CodeMirror {
@@ -694,7 +694,7 @@ form .checkboxes {
.form-order-wrapper ul#ordering li {
padding: 0.2rem 1rem;
border-radius: 4px;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
background: #f8f8f8;
color: #8d959a;
margin: 3px 0;
@@ -718,7 +718,7 @@ form .checkboxes {
cursor: move;
padding: 1rem;
border-radius: 4px;
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
background: #f8f8f8;
color: #8d959a;
margin: 3px 0;
@@ -817,16 +817,16 @@ tr {
background: #54c5b0;
color: #fff; }
.button.dropdown-toggle {
border-left: 1px solid #3bab97; }
border-left: 1px solid #3aab97; }
.button.secondary {
background: #2a7a6b;
background: #29796b;
color: rgba(255, 255, 255, 0.85);
border-radius: 4px; }
.button.secondary:hover {
background: #318d7c;
background: #2f8c7c;
color: #fff; }
.button.secondary.dropdown-toggle {
border-left: 1px solid #318d7c; }
border-left: 1px solid #2f8c7c; }
.button-group {
position: relative;
@@ -868,7 +868,7 @@ tr {
background-color: #41bea8;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #3bab97;
border: 1px solid #3aab97;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
@@ -926,7 +926,7 @@ tr {
#admin-login .form-data {
padding-right: 0; }
#admin-login h1 {
background: #21333e url(../images/logo.png) 50% 50% no-repeat;
background: #20333e url(../images/logo.png) 50% 50% no-repeat;
font-size: 0;
color: transparent;
height: 216px;
@@ -942,15 +942,15 @@ tr {
text-align: center;
font-weight: 300;
-webkit-font-smoothing: auto;
border: 1px solid #1e2e39; }
border: 1px solid #1d2e38; }
#admin-login form input::-webkit-input-placeholder {
color: #83949d; }
color: #83949c; }
#admin-login form input::-moz-placeholder {
color: #83949d; }
color: #83949c; }
#admin-login form input:-moz-placeholder {
color: #83949d; }
color: #83949c; }
#admin-login form input:-ms-input-placeholder {
color: #83949d; }
color: #83949c; }
#admin-login form .form-actions {
text-align: center;
margin: 0 -3rem -3rem -3rem;
@@ -974,7 +974,7 @@ tr {
color: #fff; }
#admin-logo {
background: #21333e;
background: #20333e;
height: 4.2rem; }
#admin-logo h3 {
text-transform: uppercase;
@@ -988,7 +988,7 @@ tr {
#admin-user-details {
padding: 2rem;
border-bottom: 1px solid #21333e;
border-bottom: 1px solid #20333e;
overflow: hidden; }
#admin-user-details img {
-webkit-transition: all 0.5s ease;
@@ -1023,7 +1023,7 @@ tr {
#admin-menu li .badges .badge {
display: inline-block;
margin-right: -5px;
color: #e6e6e6; }
color: #e5e5e5; }
#admin-menu li .badges .count {
background-color: #365569; }
#admin-menu li .badges .updates {
@@ -1052,7 +1052,7 @@ tr {
color: #afc7d5;
margin-right: 8px; }
#admin-menu li a:hover {
background: #21333e;
background: #20333e;
color: #fff; }
#admin-menu li a:hover i {
font-size: 1.2rem; }
@@ -1720,7 +1720,7 @@ body.remodal_active .remodal {
border-radius: 0; }
.grav-mdeditor-navbar {
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
background: #fbfbfb; }
@@ -1739,8 +1739,8 @@ body.remodal_active .remodal {
.grav-mdeditor-navbar ul .mdeditor-active a {
background: white;
cursor: auto;
border-left: 1px solid #d5d5d5;
border-right: 1px solid #d5d5d5; }
border-left: 1px solid #d4d4d4;
border-right: 1px solid #d4d4d4; }
.grav-mdeditor-navbar ul .mdeditor-active a:hover {
background: #fff; }
.grav-mdeditor-navbar ul a {
@@ -1763,7 +1763,7 @@ body.remodal_active .remodal {
border-top-right-radius: 4px; }
.grav-mdeditor-content {
border: 1px solid #d5d5d5;
border: 1px solid #d4d4d4;
border-top: 0;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px; }
@@ -1807,7 +1807,7 @@ body.remodal_active .remodal {
[data-mode=split] .grav-mdeditor-button-code, [data-mode=split] .grav-mdeditor-button-preview {
display: none; }
[data-mode=split] .grav-mdeditor-code {
border-right: 1px solid #d5d5d5; }
border-right: 1px solid #d4d4d4; }
[data-mode=split] .grav-mdeditor-code, [data-mode=split] .grav-mdeditor-code .grav-mdeditor-preview {
float: left;
width: 50%; }
@@ -1903,7 +1903,7 @@ body.remodal_active .remodal {
.dropzone {
position: relative;
border: 1px #d5d5d5 solid;
border: 1px #d4d4d4 solid;
border-radius: 4px;
min-height: 4rem;
background: #fff; }

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,78 @@
(function($) {
$(function() {
/**
* polyfill for html5 form attr
*/
// detect if browser supports this
var sampleElement = $('[form]').get(0);
var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;
if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {
// browser supports it, no need to fix
return;
}
/**
* Append a field to a form
*
*/
$.fn.appendField = function(data) {
// for form only
if (!this.is('form')) return;
// wrap data
if (!$.isArray(data) && data.name && data.value) {
data = [data];
}
var $form = this;
// attach new params
$.each(data, function(i, item) {
$('<input/>')
.attr('type', 'hidden')
.attr('name', item.name)
.val(item.value).appendTo($form);
});
return $form;
};
/**
* Find all input fields with form attribute point to jQuery object
*
*/
$('form[id]').submit(function(e) {
// serialize data
var data = $('[form=' + this.id + ']').serializeArray();
// append data to form
$(this).appendField(data);
}).each(function() {
var form = this,
$fields = $('[form=' + this.id + ']');
$fields.filter('button, input').filter('[type=reset],[type=submit]').click(function() {
var type = this.type.toLowerCase();
if (type === 'reset') {
// reset form
form.reset();
// for elements outside form
$fields.each(function() {
this.value = this.defaultValue;
this.checked = this.defaultChecked;
}).filter('select').each(function() {
$(this).find('option').each(function() {
this.selected = this.defaultSelected;
});
});
} else if (type.match(/^submit|image$/i)) {
$(form).appendField({
name: this.name,
value: this.value
}).submit();
}
});
});
});
})(jQuery);

View File

@@ -352,7 +352,7 @@ form {
content:"\f00c";
font-family: "FontAwesome";
font-size: 1.2rem;
line-height: 1.5rem;
line-height: 1;
text-align: center;
}

View File

@@ -56,6 +56,10 @@
{% do assets.addJs(theme_url~'/js/forms/fields/toggle.js') %}
{% do assets.addJs(theme_url~'/js/forms.js') %}
{% if browser.getBrowser == 'msie' %}
{% do assets.addJs(theme_url~'/js/form-attr.polyfill.js') %}
{% endif %}
{{ assets.js() }}
{% endblock %}
{% endblock %}