From d76923393b4250c8a9c29d4dc35d4bebc0237a0e Mon Sep 17 00:00:00 2001 From: jpl Date: Thu, 16 Feb 2017 12:17:29 +0100 Subject: removing html5 polyfill, housemade fix --- app/assets/javascripts/forms.coffee | 10 ++++ app/assets/javascripts/plugins/html5-form-attr.js | 69 ----------------------- 2 files changed, 10 insertions(+), 69 deletions(-) delete mode 100644 app/assets/javascripts/plugins/html5-form-attr.js diff --git a/app/assets/javascripts/forms.coffee b/app/assets/javascripts/forms.coffee index 153a53c66..194a4089c 100644 --- a/app/assets/javascripts/forms.coffee +++ b/app/assets/javascripts/forms.coffee @@ -6,6 +6,16 @@ @submitMover = -> $('.formSubmitr').appendTo('.page-action') + # IE fix + isIE = false || !!document.documentMode + isEdge = !isIE && !!window.StyleMedia + + if isIE || isEdge + $('.formSubmitr').each -> + target = $(this).attr('form') + + $(this).on 'click', -> + $('#' + target).submit() $(document).on 'ready page:load', togglableFilter $(document).on 'ready page:load', submitMover diff --git a/app/assets/javascripts/plugins/html5-form-attr.js b/app/assets/javascripts/plugins/html5-form-attr.js deleted file mode 100644 index 8ec2d7161..000000000 --- a/app/assets/javascripts/plugins/html5-form-attr.js +++ /dev/null @@ -1,69 +0,0 @@ -(function($) { - - /** - * polyfill for html5 form attr - */ - var SAMPLE_FORM_NAME, sampleElementFound, sampleForm, sampleFormAndHiddenInput; - SAMPLE_FORM_NAME = 'html-5-polyfill-test'; - sampleForm = $('
'); - sampleFormAndHiddenInput = sampleForm.add($('')); - sampleFormAndHiddenInput.prependTo('body'); - sampleElementFound = sampleForm[0].elements[0]; - sampleFormAndHiddenInput.remove(); - if (sampleElementFound) { - return; - } - - /** - * Append a field to a form - # - */ - $.fn.appendField = function(data) { - var $form; - if (!this.is('form')) { - return; - } - if (!$.isArray(data) && data.name && data.value) { - data = [data]; - } - $form = this; - $.each(data, function(i, item) { - $('').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) { - var data; - data = $('[form=' + this.id + ']').serializeArray(); - $(this).appendField(data); - }).each(function() { - var $fields, form; - form = this; - $fields = $('[form=' + this.id + ']'); - $fields.filter('button, input').filter('[type=reset],[type=submit]').click(function() { - var type; - type = this.type.toLowerCase(); - if (type === 'reset') { - form.reset(); - $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); -- cgit v1.2.3