Skip to content

Instantly share code, notes, and snippets.

View LucasCalazans's full-sized avatar
:octocat:
jQuery > JS

Lucas Calazans LucasCalazans

:octocat:
jQuery > JS
View GitHub Profile
@LucasCalazans
LucasCalazans / trigger.js
Last active May 11, 2020 20:20
Trigger function without jQuery
const trigger = (element, eventName) => {
let event;
if (document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent(eventName, true, true);
} else {
event = document.createEventObject();
event.eventType = eventName;
}
@LucasCalazans
LucasCalazans / checkout_cart_index.xml
Last active July 24, 2018 15:17
Magento 2 - Remove all Gift references including KnockoutJS components.
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.giftcardaccount" remove="true" />
<referenceBlock name="checkout.cart.order.actions.gift_options" remove="true" />
<referenceBlock name="checkout.cart.item.renderers.simple.actions.gift_options" remove="true" />
<referenceBlock name="checkout.cart.item.renderers.default.actions.gift_options" remove="true" />
<referenceBlock name="checkout.cart.item.renderers.bundle.actions.gift_options" remove="true" />
<referenceBlock name="checkout.cart.item.renderers.configurable.actions.gift_options" remove="true" />
<referenceBlock name="checkout.cart.item.renderers.giftcard.actions.gift_options" remove="true" />
@LucasCalazans
LucasCalazans / default.xml
Last active June 19, 2018 15:02
Add "sticky-header" class to body
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="js/sticky-header.js" type="application/javascript" />
</head>
</page>
@LucasCalazans
LucasCalazans / README.md
Last active November 25, 2024 11:23
Magento - KnockoutJS (Add masks to all fields in the store)
@LucasCalazans
LucasCalazans / cc-utils.js
Last active June 5, 2020 17:51
Verify the CC brand
export const CC_BRAND_ELO = 'elo';
export const CC_BRAND_VISA = 'visa';
export const CC_BRAND_MASTER = 'master';
export const CC_BRAND_AMEX = 'amex';
export const CC_BRAND_DISCOVER = 'discover';
export const CC_BRAND_DINERS = 'diners';
export const CC_BRAND_HIPER = 'hiper';
const REPEATED_NUMBERS = 'not-valid';
export const getCardBrand = number => {