diff options
| author | jpl | 2017-02-16 12:17:29 +0100 | 
|---|---|---|
| committer | jpl | 2017-02-16 12:17:29 +0100 | 
| commit | d76923393b4250c8a9c29d4dc35d4bebc0237a0e (patch) | |
| tree | e171a025e68690158dabba8feb28627df3b5696b | |
| parent | 85376bf645602356cf6970ac46e35c6d884f8583 (diff) | |
| download | chouette-core-d76923393b4250c8a9c29d4dc35d4bebc0237a0e.tar.bz2 | |
removing html5 polyfill, housemade fix
| -rw-r--r-- | app/assets/javascripts/forms.coffee | 10 | ||||
| -rw-r--r-- | app/assets/javascripts/plugins/html5-form-attr.js | 69 | 
2 files changed, 10 insertions, 69 deletions
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 = $('<form id=\'' + SAMPLE_FORM_NAME + '\'/>'); -  sampleFormAndHiddenInput = sampleForm.add($('<input type=\'hidden\' form=\'' + SAMPLE_FORM_NAME + '\'/>')); -  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) { -      $('<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) { -    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);  | 
