Skip to content

Instantly share code, notes, and snippets.

View jenter's full-sized avatar
:octocat:
Working from home

Jason Enter jenter

:octocat:
Working from home
  • Earth
  • 20:52 (UTC -04:00)
View GitHub Profile
// normal selector
$('.testelement .something').click(function(e) {
console.log('this is clicked');
});
// could be improved by storing as a variable
var something = $('.testelement .something');
something.click(function(e) {
console.log('this is clicked');
});
function example_preprocess_panels_pane(&$vars) {
// add class per pane type
switch ($vars['pane']->subtype) {
case 'something-panel_pane_plan':
$vars['classes_array'][] = 'gw-grid-1';
break;
case 'another-panel_pane_plan':
$vars['classes_array'][] = 'gw-grid-2';
break;
var timerEl;
$(window).bind("resize", function () {
if (timerEl) {
clearTimeout(timerEl);
}
timerEl = setTimeout(function () {
// put code here ////////
console.log('the page has been resized');
(function ($, Drupal, window, document, undefined) {
/**
* Functionality for Nav bar
*/
Drupal.behaviors.NavigationBar = {
attach: function (context, settings) {
if (context === document) { // only fires on document load
// JS code goes in here
.common-css {
// these are needed regardless of browser size
background: blue;
border: 1px solid black;
width: 100%;
// adjustments based on media query
@media #{$large} {
width: 50%;
// currently written as
.region-right-sidebar .block {
background: {
image: url('../../rotary_org/images/div.png');
position: left top;
repeat: no-repeat;
}
}
// shorthand
var testVar = $("body.section div.something");
if (testVar.length) { // checks to if exists
// add code in here
console.log(testVar);
}
(function ($) {
// insert Drupal.behaviors here
})(jQuery);