I would like to add a little javascript to my bootstrap child-theme, but is not loading.
These are the configuration files:
child.info.yml :
core: 8.x
type: theme
base theme: bootstrap
name: 'child'
description: 'Uses the jsDelivr CDN for all CSS and JavaScript. No source files or compiling is necessary and is recommended for simple sites or beginners.'
package: 'Bootstrap'
regions:
navigation: 'Navigation'
navigation_collapsible: 'Navigation (Collapsible)'
header: 'Top Bar'
highlighted: 'Highlighted'
help: 'Help'
content: 'Content'
sidebar_first: 'Primary'
sidebar_second: 'Secondary'
footer: 'Footer'
page_top: 'Page top'
page_bottom: 'Page bottom'
libraries:
- 'child/global-styling'
child.libraries.yml:
global-styling:
css:
theme:
css/style.css: {}
css/masonry.css: {}
css/basic-page.css: {}
js:
js/main.js: {}
dependencies:
- core/jquery
- core/drupal.ajax
- core/drupal
- core/drupalSettings
- core/jquery.once
main.js
$(document).ready(function($) {
$(function() {
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 300) {
$("#navbar").addClass('smaller');
} else {
$("#navbar").removeClass("smaller");
}
});
});
})(jQuery);