Compare commits

..

No commits in common. "c3eab22b4e54356e535118d5f1ae9a312426f828" and "d118d185e2aef38092ac25615660b835f1e728d0" have entirely different histories.

16 changed files with 120 additions and 64 deletions

View file

@ -747,6 +747,16 @@
}
});
/*
Hanger list controls
*/
$("input[type=submit][data-confirm]").live("click", function (e) {
if (!confirm(this.getAttribute("data-confirm"))) e.preventDefault();
});
/*
Closet list droppable

View file

@ -0,0 +1,66 @@
(function() {
var donationForm = document.getElementById('donation-form');
function field(name) {
return donationForm.querySelector(
'input[name=donation\\[' + name + '\\]]');
}
var checkout = StripeCheckout.configure({
key: donationForm.getAttribute('data-checkout-publishable-key'),
image: donationForm.getAttribute('data-checkout-image'),
token: function(token) {
field('stripe_token').value = token.id;
field('stripe_token_type').value = token.type;
field('donor_email').value = token.email;
donationForm.submit();
},
bitcoin: true
});
donationForm.addEventListener('submit', function(e) {
if (!field('stripe_token').value) {
e.preventDefault();
var amountChoice =
donationForm.querySelector('input[name=amount]:checked');
if (amountChoice.value === "custom") {
amountChoice = document.getElementById('amount-custom-value');
}
// Start parsing at the first digit in the string, to trim leading dollar
// signs and what have you.
var amountNumberString = (amountChoice.value.match(/[0-9].*/) || [""])[0];
var amount = Math.floor(parseFloat(amountNumberString) * 100);
if (!isNaN(amount)) {
field('amount').value = amountNumberString;
checkout.open({
name: 'Dress to Impress',
description: 'Donation (thank you!)',
amount: amount,
panelLabel: "Donate"
});
}
}
});
var toggle = document.getElementById('success-thanks-toggle-description');
if (toggle) {
toggle.addEventListener('click', function() {
var desc = document.getElementById('description');
var attr = 'data-show';
if (desc.hasAttribute(attr)) {
desc.removeAttribute(attr);
} else {
desc.setAttribute(attr, true);
}
});
}
document.getElementById('amount-custom').addEventListener('change', function(e) {
if (e.target.checked) {
document.getElementById('amount-custom-value').focus();
}
});
})();

View file

@ -3,17 +3,22 @@ function setFormStateCookie(value) {
document.cookie = `DTIItemPageUserListsFormState=${value};max-age=${thirtyDays}`;
}
document.addEventListener("click", (event) => {
if (event.target.matches(".item-header .user-lists-form-opener")) {
const header = event.target.closest(".item-header");
const headers = document.querySelectorAll(".item-header");
for (const header of headers) {
try {
const form = header.querySelector(".user-lists-form");
if (form.hasAttribute("hidden")) {
form.removeAttribute("hidden");
setFormStateCookie("open");
} else {
form.setAttribute("hidden", "");
setFormStateCookie("closed");
}
event.preventDefault();
const opener = header.querySelector(".user-lists-form-opener");
opener.addEventListener("click", (event) => {
if (form.hasAttribute("hidden")) {
form.removeAttribute("hidden");
setFormStateCookie("open");
} else {
form.setAttribute("hidden", "");
setFormStateCookie("closed");
}
event.preventDefault();
});
} catch (error) {
console.error(`Error applying dialog behavior to item header:`, error);
}
});
}

View file

@ -0,0 +1,3 @@
$("form.button_to input[type=submit]").click(function (e) {
if (!confirm(this.getAttribute("data-confirm"))) e.preventDefault();
});

View file

@ -194,7 +194,7 @@
Preview.updateWithName(name_el);
name_el.keyup(function () {
if (previewWithNameTimeout && Preview.Job.current) {
if (previewWithNameTimeout) {
clearTimeout(previewWithNameTimeout);
Preview.Job.current.loading = false;
}

View file

@ -108,12 +108,13 @@ module ApplicationHelper
JAVASCRIPT_LIBRARIES = {
:jquery => 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js',
:jquery20 => 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js',
:jquery_tmpl => 'https://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js',
}
def include_javascript_libraries(*library_names)
raw(library_names.inject('') do |html, name|
html + javascript_include_tag(JAVASCRIPT_LIBRARIES[name], defer: true)
html + javascript_include_tag(JAVASCRIPT_LIBRARIES[name])
end)
end

View file

@ -1,29 +1,16 @@
import React from "react";
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";
import {
ChakraProvider,
Box,
theme as defaultTheme,
useColorModeValue,
} from "@chakra-ui/react";
import { ChakraProvider, Box, useColorModeValue } from "@chakra-ui/react";
import { ApolloProvider } from "@apollo/client";
import { BrowserRouter } from "react-router-dom";
import { Global } from "@emotion/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import produce from "immer";
import apolloClient from "./apolloClient";
const reactQueryClient = new QueryClient();
// Use Chakra's default theme, but with the global styles removed. (We've
// copied them into our `ScopedCSSReset` component, to apply in only the places
// we actually want them!)
const theme = produce(defaultTheme, (theme) => {
theme.styles.global = {};
});
export default function AppProvider({ children }) {
React.useEffect(() => setupLogging(), []);
@ -31,7 +18,7 @@ export default function AppProvider({ children }) {
<BrowserRouter>
<QueryClientProvider client={reactQueryClient}>
<ApolloProvider client={apolloClient}>
<ChakraProvider resetCSS={false} theme={theme}>
<ChakraProvider resetCSS={false}>
<ScopedCSSReset>{children}</ScopedCSSReset>
</ChakraProvider>
</ApolloProvider>
@ -104,16 +91,6 @@ function ScopedCSSReset({ children }) {
<Global
styles={`
:where(.chakra-css-reset, .chakra-portal) {
/* Chakra's default global styles, placed here so we can override
* the actual _global_ styles in the theme to be empty. That way,
* it only affects Chakra stuff, not all elements! */
font-family: var(--chakra-fonts-body);
color: var(--chakra-colors-gray-800);
background: var(--chakra-colors-white);
transition-property: background-color;
transition-duration: var(--chakra-transition-duration-normal);
line-height: var(--chakra-lineHeights-base);
*,
*::before,
*::after {

View file

@ -153,10 +153,7 @@
- content_for :javascripts do
= include_javascript_libraries :jquery, :jquery_tmpl
= javascript_include_tag 'ajax_auth', 'lib/jquery.ui', 'lib/jquery.jgrowl',
defer: true
- content_for :javascripts_body do
= javascript_include_tag 'closet_hangers/index', defer: true
'closet_hangers/index'
- if public_perspective? && user_signed_in?
- content_for :meta do

View file

@ -123,5 +123,9 @@
#{mail_to 'webmaster@openneo.net', "Please email us for more information."}
Thank you!!
- content_for :javascripts do
= javascript_include_tag 'https://checkout.stripe.com/checkout.js',
'fundraising/campaigns/show'
- content_for :stylesheets do
= stylesheet_link_tag 'fundraising/campaigns/show'

View file

@ -43,9 +43,7 @@
- content_for :javascripts do
= include_javascript_libraries :jquery
- content_for :javascripts_body do
= javascript_include_tag 'fundraising/donations/show', defer: true
= javascript_include_tag 'fundraising/donations/show'
- content_for :stylesheets do
= stylesheet_link_tag 'fundraising/donations/show'

View file

@ -96,4 +96,4 @@
'data-is-current' => current_subpage == 'trades_seeking'
- content_for :javascripts do
= javascript_include_tag 'items/item_header', defer: true
= javascript_include_tag 'items/item_header'

View file

@ -23,6 +23,6 @@
%li= link_to(contributor.name, user_contributions_path(contributor)) + format_contribution_count(count)
%footer= t '.contributors.footer'
- content_for :javascripts_body do
- content_for :javascripts do
= javascript_include_tag 'item-page', defer: true

View file

@ -21,8 +21,6 @@
= signed_in_meta_tag
- if user_signed_in?
= current_user_id_meta_tag
= javascript_include_tag 'application', defer: true
= yield :javascripts
= yield :head
%body{:class => body_class}
#container
@ -75,9 +73,7 @@
%li= mail_to contact_email, t('.footer.email')
%p= t '.footer.copyright', :year => Date.today.year
= javascript_include_tag 'application'
= yield(:javascripts)
-# For scripts that expect to get to just execute once every time the page
-# loads. For future JS, it would be advisable to write it such that it's
-# okay for Turbo to run it once at the start of the page, then listen to
-# `turbo:load` events or use inline scripts to actually _do_ things.
= yield :javascripts_body

View file

@ -6,3 +6,8 @@
%ul#outfits= render @outfits
- else
%p= twl '.no_outfits', :start_link_url => root_path
- content_for :javascripts do
= include_javascript_libraries :jquery
= javascript_include_tag 'outfits/index'

View file

@ -123,8 +123,5 @@
= t '.preview.pet_not_found'
- content_for :javascripts do
= include_javascript_libraries :jquery, :jquery_tmpl
= javascript_include_tag 'ajax_auth', 'lib/jquery.timeago', defer: true
- content_for :javascripts_body do
= javascript_include_tag 'outfits/new', defer: true
= include_javascript_libraries :jquery20, :jquery_tmpl
= javascript_include_tag 'ajax_auth', 'lib/jquery.timeago', 'outfits/new'

View file

@ -79,7 +79,4 @@
- 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
= javascript_include_tag 'ajax_auth', 'pets/bulk'