impress/app/views/closet_hangers/index.html.haml
Emi Matchu cae2f3ca74 Serve jquery and jquery.tmpl from our own codebase, instead of a CDN
Right, yeah, we've been depending on an external CDN for a long time
for jQuery and the jQuery Template library, and I don't like that kind
of external dependency! Let's put it in with the rest of our libs.
2024-09-20 19:23:53 -07:00

169 lines
7.8 KiB
Text

- content_for :before_title, advertise_campaign_progress(@campaign)
- unless public_perspective?
- title t('.title_for.you')
- add_body_class 'current-user'
- secondary_nav do
%span#toggle-help= t('.toggle_help')
= form_tag items_path, :method => :get, :id => 'closet-hangers-items-search', 'data-current-user-id' => current_user.id do
= text_field_tag :q, nil, :placeholder => t('.item_search_placeholder')
= submit_tag t('.item_search_submit'), :name => nil
- else
- title t('.title_for.another_user', :user_name => @user.name)
- secondary_nav do
%span#toggle-compare Compare with Your Items
- canonical_path user_closet_hangers_path(@user)
- content_for :before_flashes do
#closet-hangers-contact
- if public_perspective?
- if @user.contact_neopets_username?
= link_to t('.send_neomail', neopets_username: @user.contact_neopets_username),
send_neomail_url(@user.contact_neopets_username),
:class => 'neomail'
= link_to t('.lookup',
neopets_username: @user.contact_neopets_username),
neopets_lookup_url(@user.contact_neopets_username),
:class => 'lookup'
- else
= form_for @user do |f|
= f.label :contact_neopets_connection_id
= f.collection_select :contact_neopets_connection_id, @user.neopets_connections, :id, :neopets_username, {include_blank: true}, 'data-new-text' => t('.neopets_username.new'), 'data-new-prompt' => t('.neopets_username.prompt')
= f.submit t('.neopets_username.submit')
- unless public_perspective?
%noscript
%p.warning
Managing your items is a lot easier with Javascript. With Javascript
disabled, you'll have to click each item you want to manage, update the
quantities for each list on the item page, and refresh this page
manually once you want to see your changes. It still works, but consider
enabling Javascript to make your life easier.
= render :partial => 'help', :locals => {:user => @user}
#closet-hangers-extras
#closet-hangers-share
%label{:for => 'closet-hangers-share-box'}= t '.public_url_label'
%input#closet-hangers-share-box{:type => 'text',
:value => user_closet_hangers_url(@user),
:readonly => true}
= link_to t('.import_from.closet'), new_neopets_page_import_task_path(page_type: 'closet', expected_index: 1)
= link_to t('.import_from.safety_deposit'), new_neopets_page_import_task_path(page_type: 'safety_deposit', expected_index: 1)
= link_to t('.import_from.gallery'), new_neopets_page_import_task_path(page_type: 'gallery', expected_index: 1)
= link_to t('.export_to.petpage'), petpage_user_closet_hangers_path(@user)
#closet-hangers{:class => public_perspective? ? nil : 'current-user'}
- unless public_perspective?
-# TODO: i18n
.bulk-actions{'data-target-count' => 0}
.bulk-actions-intro
Manage items in bulk! Select an item by clicking its thumbnail, or choose
a list and Select All.
.bulk-actions-form
.bulk-actions-target-desc
%span.bulk-actions-target-desc-singular
With the 1 selected item:
%span.bulk-actions-target-desc-plural
With the
%span.bulk-actions-target-count 0
selected items:
%ul.bulk-actions-options
%li
= form_tag user_closet_hangers_path(@user), method: :put, class: 'bulk-actions-move-all' do
= select_tag 'list_id', options_for_select(destination_options)
%button Move
%li
= form_tag user_closet_hangers_path(@user), method: :delete, class: 'bulk-actions-remove-all' do
%button Remove all
%li
%button.bulk-actions-deselect-all Deselect all
- [true, false].each do |owned|
%section.closet-hangers-group{'data-owned' => owned.to_s, :id => "closet-hangers-group-#{owned}"}
%header
%h3= closet_lists_group_name(closet_hangers_subject(@user), owned)
%span.toggle.show= t '.toggle_group.show'
%span.toggle.hide= t '.toggle_group.hide'
- unless public_perspective?
= link_to_add_closet_list t('.add_list'), :owned => owned, :class => 'add-closet-list'
.closet-hangers-group-content
= render_closet_lists(@closet_lists_by_owned[owned])
- if !public_perspective? || unlisted_hangers_count(owned) > 0
.closet-list.unlisted{'data-hangers-count' => unlisted_hangers_count(owned)}
%header
- unless public_perspective?
= form_for @user, :html => {:class => 'visibility-form'} do |f|
= f.select hangers_group_visibility_field_name(owned),
closet_visibility_choices(:human_name)
= f.submit t('.unlisted.submit')
= closet_visibility_descriptions
.closet-list-controls
= form_tag user_closet_hangers_path(@user), method: :delete, class: 'remove-all' do
= hidden_field_tag :list_id, owned
= submit_tag t('.remove_all.submit'), confirm: t('.remove_all.confirm')
%button.select-all= t('.select_all')
- if has_lists?(owned)
%h4= t '.unlisted.header'
- if !@public_perspective
= render partial: 'closet_lists/trading_neomail_warning', locals: {list: @user.null_closet_list(owned), user: @user}
- cache unlisted_hangers_cache_key(owned) do
.closet-list-content
.closet-list-hangers
= render_unlisted_closet_hangers(owned)
%span.empty-list= t '.unlisted.empty'
- if user_signed_in?
%script#autocomplete-item-tmpl{type: 'text/x-jquery-tmpl'}
%a
= t '.autocomplete.add_item_html', item_name: '${item_name}'
%script#autocomplete-add-to-list-tmpl{type: 'text/x-jquery-tmpl'}
%a
= t '.autocomplete.add_to_list_html', list_name: '${list_name}'
%script#autocomplete-add-to-group-tmpl{type: 'text/x-jquery-tmpl'}
%a
= t '.autocomplete.add_to_group_html', group_name: '${group_name}'
%script#autocomplete-already-in-collection-tmpl{type: 'text/x-jquery-tmpl'}
%span
= t '.autocomplete.already_in_collection_html',
collection_name: '${collection_name}'
-# Gotta do this weird subbing in the path, since the braces will be
-# escaped if they themselves are inserted. Probably deserves a more legit
-# method, especially if we ever need it again.
- templated_hanger_path = user_closet_hanger_path(user_id: '$0', id: '$1').sub('$0', '${user_id}').sub('$1', '${closet_hanger_id}')
%script#closet-hanger-update-tmpl{type: 'text/x-jquery-tmpl'}
= form_tag templated_hanger_path, method: :put, authenticity_token: false, class: 'closet-hanger-update' do
= hidden_field_tag 'closet_hanger[list_id]', '${list_id}'
= hidden_field_tag 'closet_hanger[owned]', '${owned}'
= number_field_tag 'closet_hanger[quantity]', '${quantity}',
min: 0, required: true
%script#closet-hanger-destroy-tmpl{type: 'text/x-jquery-tmpl'}
-# TODO: remove me?
- content_for :stylesheets do
= stylesheet_link_tag 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/south-street/jquery-ui.css'
- content_for :javascripts do
= javascript_include_tag 'jquery', 'jquery.tmpl', 'jquery.ui',
'jquery.jgrowl', defer: true
- content_for :javascripts_body do
= javascript_include_tag 'closet_hangers/index', defer: true
- if public_perspective? && user_signed_in?
- content_for :meta do
%meta{
name: "trade-matches-owns",
value: @items.select(&:owned?).map(&:id).join(",")
}
%meta{
name: "trade-matches-wants",
value: @items.select(&:wanted?).map(&:id).join(",")
}