Skip to content

Commit

Permalink
fixup! misc updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
sherakama committed May 8, 2020
1 parent 24319b4 commit c1052de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dist/js/scripts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 2 additions & 36 deletions src/js/scripts.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,2 @@
/**
* @file
* A JavaScript file for the theme.
*
* In order for this JavaScript to be loaded on pages, see the instructions in
* the README.txt next to this file.
*/

// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it with an "anonymous closure". See:
// - https://drupal.org/node/1446420
// - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
(function (Drupal, $, window) {

// To understand behaviors, see https://www.drupal.org/node/2269515
Drupal.behaviors.stanford_starter = {
attach: function (context, settings) {

// Execute code once the DOM is ready. $(document).ready() not required within Drupal.behaviors.

$(window).load(function () {
// Execute code once the window is fully loaded.
});

$(window).resize(function () {
// Execute code when the window is resized.
});

$(window).scroll(function () {
// Execute code when the window scrolls.
});

}
};

} (Drupal, jQuery, this));
// Theme code.
import './stanford_starter.behaviors.js';
21 changes: 21 additions & 0 deletions src/js/stanford_starter.behaviors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Behavior Example that works with Webpack.
*
* @see: https://www.npmjs.com/package/drupal-behaviors-loader
*
* Webpack wraps everything in enclosures and hides the global variables from
* scripts so special handling is needed.
*/

export default {

// Attach Drupal Behavior.
attach (context, settings) {
// console.log("Attached.");
},

// Detach Example.
detach () {
// console.log("Detached.");
}
}

0 comments on commit c1052de

Please sign in to comment.