1
0
Fork 0
forked from OpenNeo/impress
impress/app/views/pets/bulk.html.haml
Emi Matchu c011e99819 Fix various JS Turbo issues
First one, Turbo reasonably yelled at us in the JS console that we
should put its script tag in the `head` rather than the `body`, because
it re-executes scripts in the `body` and we don't want to spin up Turbo
multiple times!

I also removed some scripts that aren't relevant anymore, fixed a bug
in `outfits/new.js` where failing to load a donation pet would cause
the preview thing to not work when you type (I think this might've
already been an issue?), reworked `item_header.js` to just run once in
the `head`, and split scripts into `:javascripts` (run once in `head`)
vs `:javascripts_body` (run every page load in `body`).
2024-03-13 21:26:22 -07:00

85 lines
2.7 KiB
Text

- title t('modeling_hub')
= form_tag load_pet_path, :id => 'needed-items-form' do
- localized_cache :action_suffix => 'needed_items_content' do
%h3= t '.needed_items.header'
%p= t '.needed_items.explanation'
= origin_tag bulk_pets_path
= destination_tag 'needed_items'
%input#needed-items-pet-name-field{:type => "text", :name => "name"}/
%input{:type => "submit", :value => t('.needed_items.submit')}/
#needed-items-alert.alert
#needed-items-pet.script-only
%h4
%img#needed-items-pet-thumbnail.inline-image
%span#needed-items-pet-header
%button#needed-items-reload= t '.needed_items.reload'
%ul#needed-items-pet-items
= form_tag load_pet_path, :id => 'bulk-pets-form' do
- localized_cache :action_suffix => 'bulk_pets_content' do
%h3= t '.bulk_pets.header'
%p= t '.bulk_pets.explanation'
= origin_tag bulk_pets_path
%div.noscript
%input{:name => "name", :type => "text"}/
%input{:type => "submit", :value => t('.bulk_pets.submit')}/
%div.script-only
%textarea
%button#bulk-pets-form-add{:type => "button"}= t '.bulk_pets.add'
%button#bulk-pets-form-clear{:type => "button"}= t '.bulk_pets.clear'
%ul
- localized_cache :action_suffix => 'templates' do
%script#item-template{:type => 'text/x-jquery-tmpl'}
%li{:class => 'object{{if owned}} owned{{/if}}'}
= link_to item_path(':id').sub(':id', '${id}') do
%img{:src => '${thumbnail_url}', :alt => '${description}', :title => '${description}'}
%span.name ${name}
{{if nc}}
= nc_icon
{{/if}}
.closeted-icons
{{if owned}}
= owned_icon
{{/if}}
{{if wanted}}
= wanted_icon
{{/if}}
{{if owned}}
%span.object-owned= t '.needed_items.item_owned'
{{/if}}
%script#needed-items-pet-header-template{:type => 'text/x-jquery/tmpl'}
= t '.needed_items.pet_header', :pet_name => '${pet_name}'
%script#bulk-pets-submission-template{:type => 'text/x-jquery/tmpl'}
%li.waiting
%img{:src => 'https://pets.neopets.com/cpn/${pet_name}/1/1.png'}
%span.name ${pet_name}
%span.waiting-message= t '.bulk_pets.waiting'
%span.loading-message= t '.bulk_pets.loading'
%span.response
%script#bulk-pets-submission-success-template{:type => 'text/x-jquery/tmpl'}
= t '.bulk_pets.submission_success', :points => '${points}'
- content_for :javascripts do
= include_javascript_libraries :jquery, :jquery_tmpl
= javascript_include_tag 'ajax_auth', defer: true
- content_for :javascripts_body do
= javascript_include_tag 'pets/bulk', defer: true