Skip to content

Instantly share code, notes, and snippets.

jQuery(document).ready( function() {
var menu = jQuery('ul.menu');
var menuOffset = menu.offset().top;
var previousScroll = 0;
jQuery(window).scroll( function () {
var currentScroll = jQuery(this).scrollTop();
var teaserCount = 1;
jQuery('.field-name-field-teasers > .field-items > .field-item').each( function() {
var TeaserID = 'teaser-id-' + teaserCount;
jQuery(this).attr('id', TeaserID);
teaserCount++;
});
/*Dialogue Teaser Read More Links*/
jQuery('.field-name-field-subitem-expanded-text')
.siblings('.field-name-field-subitem-teaser')
.append('<a class="teaser-read-more" href="#">Read More</a>');
jQuery('.field-name-field-subitem-expanded-text')
.append('<a class="teaser-collapse" href="#">Collapse</a>');
jQuery('.field-name-field-subitem-expanded-text').hide();
@boehmrya
boehmrya / gist:66d23116a0655278e2b6
Created September 15, 2015 19:56
Tooltips in CSS
[tooltip]:before {
/* needed - do not touch */
content: attr(tooltip);
position: absolute;
opacity: 0;
/* customizable */
transition: all 0.3s ease;
padding: 10px;
color: #000;
@boehmrya
boehmrya / gist:855d15fd915c9a249c6c
Created September 14, 2015 02:31
Hide term reference field and set the value on a node add form in drupal
function custom_seven_form_article_node_form_alter(&$form, &$form_state, $form_id) {
$form['field_section']['und']['#type'] = 'hidden';
$form['field_section']['und']['#value'] = 44;
}
@boehmrya
boehmrya / gist:682b19d1b17f56c96fa7
Created September 2, 2014 01:32
Setting persistent variable with full html to display above a form
/**
* Settings page - page callback function (left hook_menu out of gist).
*/
function custom_restricted_types() {
$form['custom_restricted_types'] = array(
'#type' => 'checkboxes',
'#title' => 'Restricted Content Types',
'#options' => node_type_get_names(),
'#default_value' => variable_get('custom_restricted_types', array()),
'#description' => 'Choose the content types to be restricted to all roles except those given the <strong><em>Access Nonprofit Issues Restricted Content</em></strong> permission. That permission can be set at <a href="/admin/people/permissions#module-custom">the permissions page.</a>'
@boehmrya
boehmrya / gist:e445ac82d2064ba02449
Last active August 29, 2015 14:03
Drupal - in template.php, hide one field based on the value of another boolean field
//Hiding one field, based on the value of another boolean field.
function education_abroad_preprocess_node(&$vars) {
//cpr($vars);
if ($vars['type'] == 'student_profile') {
if ($vars['field_hide_scholarship_affiliati']['und'][0]['value'] == 1) {
unset($vars['content']['field_scholarship_affiliation']);
}
}
@boehmrya
boehmrya / gist:e4560e360e213e914b40
Created July 10, 2014 16:21
CSS Comma Delimiter Between Terms in a Term Reference Field (Drupal)
/*Add a comma delimiter between terms in a term reference field*/
.node-type-course .field-name-field-semesters-offered- .field-items .field-item {
display: inline-block;
*display: inline;
*zoom: 1;
}
.node-type-course .field-name-field-semesters-offered- .field-items .field-item:after {
content: ",\0000a0";
}
@boehmrya
boehmrya / superfish_mobile_select_menu
Created July 2, 2014 12:55
Mobile/Tablet Select List for Superfish Menu in Drupal
jQuery(document).ready(function($) {
// Create select list navigation for mobile, small tablets
// Populate dropdown with menu items
/* Clone our navigation */
var mainNavigation = $('nav#block-superfish-1.block').clone();
// Create the dropdown base