analytics/lib/plausible_web/templates/site/new_goal.html.eex

38 lines
2.3 KiB
Elixir
Raw Normal View History

2019-10-31 08:39:51 +03:00
<%= form_for @changeset, "/#{@site.domain}/goals", [class: "max-w-sm w-full mx-auto bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8"], fn f -> %>
<h2>Add goal for <%= @site.domain %></h2>
<div class="mt-6 text-sm font-bold">Goal trigger</div>
<div class="my-3 w-full flex rounded border border-grey-light">
<div class="w-1/2 text-center py-2 border-r border-grey shadow-inner font-bold bg-grey-lighter cursor-pointer" id="pageview-tab">Pageview</div>
<div class="w-1/2 text-center py-2 bg-grey-lightest cursor-pointer" id="event-tab">Custom event</div>
</div>
<div class="my-6">
<div id="pageview-fields">
<%= label f, :page_path, class: "block text-sm font-bold" %>
<%= text_input f, :page_path, class: "transition mt-3 bg-grey-lighter appearance-none border border-transparent rounded w-full p-2 text-grey-darker leading-normal appearance-none focus:outline-none focus:bg-white focus:border-grey-light", placeholder: "/success" %>
<%= error_tag f, :page_path %>
</div>
<div id="event-fields" class="hidden">
<%= label f, :event_name, class: "block text-sm font-bold" %>
<%= text_input f, :event_name, class: "transition mt-3 bg-grey-lighter appearance-none border border-transparent rounded w-full p-2 text-grey-darker leading-normal appearance-none focus:outline-none focus:bg-white focus:border-grey-light", placeholder: "Signup" %>
<%= error_tag f, :event_name %>
</div>
</div>
<%= submit "Add goal →", class: "button mt-4 w-full" %>
<% end %>
<script>
document.getElementById('pageview-tab').onclick = function() {
document.getElementById('pageview-fields').classList.remove('hidden')
document.getElementById('pageview-tab').classList.add('shadow-inner', 'font-bold')
document.getElementById('event-fields').classList.add('hidden')
document.getElementById('event-tab').classList.remove('shadow-inner', 'font-bold')
}
document.getElementById('event-tab').onclick = function() {
document.getElementById('event-fields').classList.remove('hidden')
document.getElementById('event-tab').classList.add('shadow-inner', 'font-bold')
document.getElementById('pageview-fields').classList.add('hidden')
document.getElementById('pageview-tab').classList.remove('shadow-inner', 'font-bold')
}
</script>