Skip to content

Instantly share code, notes, and snippets.

View frankyonnetti's full-sized avatar

Frank Yonnetti frankyonnetti

View GitHub Profile
@frankyonnetti
frankyonnetti / jQuery - hide on outside click.js
Created May 23, 2021 19:32
jQuery - hide on outside click #jquery #esc
var subMenuButton = 'ul#primary-menu li.menu-item-has-children > a'
var subMenuDropdown = 'ul.submenu.menu-depth-1'
// Hide menu drop-down on outside click
$(document).on('click', function (e) {
if ($(subMenuButton).hasClass('expanded') && $(e.target).closest(subMenuButton).length === 0) {
$(subMenuButton).removeClass('expanded')
$(subMenuDropdown).hide()
}
})
@frankyonnetti
frankyonnetti / HTML--script-tag-with-date.html
Created May 23, 2021 19:27
Script tag with date #javascript #html #cache
<script>
document.write("<script type='text/javascript' src='/js/script.js?v=" + Date.now() + "'><\/script>");
</script>
// Browsersync notify
#__bs_notify__ {
/* Move notification to bottom-left */
color: $white !important;
font-size: rem(15) !important;
font-weight: 500;
text-shadow: 0 -1px 0 $black;
border-top-right-radius: 8px !important;
border-bottom-left-radius: 0 !important;
background-color: rgba($black, 0.8) !important;
@frankyonnetti
frankyonnetti / GIT - diff patch.sh
Created May 23, 2021 19:05
GIT - diff patch #git #patch
# create patch from www directory
git diff 79896c5ede e8d7f85300c4 --relative > drupal-core-7.72-7.73.patch
# run patch dry-run
patch -p1 --dry-run < ~/patches/PATCHFILE
@frankyonnetti
frankyonnetti / Font PX-to-REM-Conversion.md
Created May 23, 2021 19:01
Font PX-to-REM-Conversion #rem

The rem checker

PX to REM Conversion

8px  = 0.5rem
9px  = 0.5625rem
10px = 0.625rem
11px = 0.6875rem
12px = 0.75rem

13px = 0.8125rem

@frankyonnetti
frankyonnetti / Drupal7--if-node-type-in-PAGE.tpl.php
Created May 23, 2021 18:39
Drupal7--if-node-type-in-PAGE.tpl.php #drupal7
<?php if (!empty($node) && $node->type == 'content_type_name'): ?>
Do something...
<?php endif; ?>
@frankyonnetti
frankyonnetti / Drupal - empty view block.md
Created May 23, 2021 16:54
Drupal - empty view block #drupal #views #block
@frankyonnetti
frankyonnetti / Drupal 8 - render node field on page.html.twig.md
Last active May 23, 2021 16:48
Drupal 8 - render node field on page.html.twig #drupal8 #twig #fields

Drupal 8 & Twig

Render field value

For example, the node title

{{ node.title.value }}

Render field entity value

@frankyonnetti
frankyonnetti / Drupal 8 - menu_link_attributes.yaml
Last active May 23, 2021 16:47
Drupal 8 - menu_link_attributes #drupal8 #menu
@frankyonnetti
frankyonnetti / Drupal 8 - blocks.md
Last active May 23, 2021 16:46
Drupal 8 - blocks #drupal8