From 627069e776b3be943e0e5477ae73dc44cada52b9 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 26 Jan 2018 01:53:16 +0200 Subject: [PATCH] Run all inline JS on window.ready --- app/views/registrar/domains/form/_contacts.haml | 1 + app/views/registrar/domains/form/_dnskeys.haml | 1 + app/views/registrar/domains/form/_nameservers.haml | 1 + app/views/registrar/payments/pay.html.haml | 4 ++-- app/views/registrar/polls/show.haml | 9 +++++---- app/views/registrar/sessions/login_mid.haml | 3 ++- app/views/registrar/xml_consoles/show.haml | 4 +++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/views/registrar/domains/form/_contacts.haml b/app/views/registrar/domains/form/_contacts.haml index 931f206b5..bf34fe5b8 100644 --- a/app/views/registrar/domains/form/_contacts.haml +++ b/app/views/registrar/domains/form/_contacts.haml @@ -22,6 +22,7 @@ = text_field_tag "domain[contacts_attributes][#{k}][code_helper]", contacts.find_by(code: v['code']).try(:search_name), class: 'form-control', data: {autocomplete: search_contacts_registrar_domains_path}, required: true :coffee + window.ready = -> clone = $('.js-contact:first').clone() $("#js-domain-contacts").nestedAttributes bindAddTo: $(".add-domain-contact") diff --git a/app/views/registrar/domains/form/_dnskeys.haml b/app/views/registrar/domains/form/_dnskeys.haml index 7d41682f6..dbb6eb935 100644 --- a/app/views/registrar/domains/form/_dnskeys.haml +++ b/app/views/registrar/domains/form/_dnskeys.haml @@ -68,6 +68,7 @@ class: 'form-control' :coffee + window.ready = -> $("#dnskeys").nestedAttributes bindAddTo: $(".add-dnskey") afterAdd: (item) -> diff --git a/app/views/registrar/domains/form/_nameservers.haml b/app/views/registrar/domains/form/_nameservers.haml index 572821c6c..89691269b 100644 --- a/app/views/registrar/domains/form/_nameservers.haml +++ b/app/views/registrar/domains/form/_nameservers.haml @@ -27,5 +27,6 @@ = text_field_tag "domain[nameservers_attributes][#{k}][ipv6]", v['ipv6'], class: 'form-control'#, ipv6: true :coffee + window.ready = -> $("#nameservers").nestedAttributes bindAddTo: $(".add-nameserver") diff --git a/app/views/registrar/payments/pay.html.haml b/app/views/registrar/payments/pay.html.haml index 62f5fb87a..dcd889f34 100644 --- a/app/views/registrar/payments/pay.html.haml +++ b/app/views/registrar/payments/pay.html.haml @@ -6,5 +6,5 @@ :coffeescript - $(document).ready -> - $('.payment-form form').submit() \ No newline at end of file + window.ready = -> + $('.payment-form form').submit() diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index e013bad7b..791c28cca 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -82,8 +82,9 @@ %p.bg-info{style: 'padding: 15px;'}= t(:you_have_no_new_messages) :coffee - $(".js-keyrelay-confirm").on "click", -> - $(".js-keyrelay-form").submit() + window.ready = -> + $(".js-keyrelay-confirm").on "click", -> + $(".js-keyrelay-form").submit() - $(".js-transfer-confirm").on "click", -> - $(".js-transfer-form").submit() + $(".js-transfer-confirm").on "click", -> + $(".js-transfer-form").submit() diff --git a/app/views/registrar/sessions/login_mid.haml b/app/views/registrar/sessions/login_mid.haml index eeb18402d..f5dcc7c38 100644 --- a/app/views/registrar/sessions/login_mid.haml +++ b/app/views/registrar/sessions/login_mid.haml @@ -13,7 +13,8 @@ 00007, 60000007, 00000766 :coffee - $('.js-login').attr('disabled', false) + window.ready = -> + $('.js-login').attr('disabled', false) status_interval = null mid_status = () -> diff --git a/app/views/registrar/xml_consoles/show.haml b/app/views/registrar/xml_consoles/show.haml index 4b07f6aec..f96b67738 100644 --- a/app/views/registrar/xml_consoles/show.haml +++ b/app/views/registrar/xml_consoles/show.haml @@ -61,8 +61,10 @@ = CodeRay.scan(@result.to_s.force_encoding("UTF-8"), :xml).div().html_safe :javascript + window.addEventListener('load', + function(){ $('.js-load-xml').click(function() { $.get('xml_console/load_xml', {obj: $(this).data('obj'), epp_action: $(this).data('epp-action')}, function(data) { $('textarea[name="payload"]').html(data); }); - }); + });});