Skip to content

Commit

Permalink
Merge pull request #10332 from nanaya/store-cart-ts
Browse files Browse the repository at this point in the history
Typescript StoreCart class
  • Loading branch information
notbakaneko authored Jul 4, 2023
2 parents 314b4f4 + f96b6b7 commit e830ee4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
8 changes: 0 additions & 8 deletions resources/js/_classes/store-cart.coffee

This file was deleted.

3 changes: 2 additions & 1 deletion resources/js/core-legacy/store-supporter-tag.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { route } from 'laroute'
import { fadeToggle } from 'utils/fade'
import { toggleCart } from 'utils/store-cart'

export default class StoreSupporterTag
RESOLUTION: 8
Expand Down Expand Up @@ -148,7 +149,7 @@ export default class StoreSupporterTag
messageInputVisible = enabled && @user?.id != window.currentUser.id
fadeToggle(@messageInput, messageInputVisible)

StoreCart.setEnabled(enabled)
toggleCart(enabled)
# TODO: need to elevate this element when switching over to new store design.
$(@el).toggleClass('js-store--disabled', !enabled)
$('.js-slider').slider('disabled': !enabled)
1 change: 0 additions & 1 deletion resources/js/entrypoints/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'app-deps';

import 'jquery-pubsub.coffee';

import '_classes/store-cart.coffee';
import '_classes/store-supporter-tag-price.coffee';
import '_classes/timeout.coffee';

Expand Down
6 changes: 3 additions & 3 deletions resources/js/store-username-change.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import { route } from 'laroute'
import { trans } from 'utils/lang'
import { toggleCart } from 'utils/store-cart'

preventUsernameSubmission = ->
StoreCart.setEnabled(false)
toggleCart(false)
$('#username-check-price').text ''

checkUsernameValidity = ->
Expand All @@ -17,10 +18,9 @@ checkUsernameValidity = ->
return unless data.username == $('.js-username-change-input').val()

if data.available
$('.js-store-add-to-cart').attr 'disabled', false
toggleCart(true)
$('#username-check-price').text data.costString
$('#username-form-price').val data.cost
$('#product-form').data('disabled', false)
else
preventUsernameSubmission()

Expand Down
7 changes: 7 additions & 0 deletions resources/js/utils/store-cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

export function toggleCart(flag: boolean) {
$('.js-store-add-to-cart').prop('disabled', !flag);
$('#product-form').data('disabled', !flag);
}

0 comments on commit e830ee4

Please sign in to comment.