Skip to content

Instantly share code, notes, and snippets.

@mariohernandez

mariohernandez/card.js

Last active Nov 6, 2016
Embed
What would you like to do?
Example of Javascript for card component
(function ($) {
'use strict';
Drupal.behaviors.card = {
attach: function (context, settings) {
var $bioButton = $('.card__view-bio', context);
var $bioDrawer = $('.card__bio', context);
var showBio = 'View full biography';
var hideBio = 'Hide biography';
$bioButton.on('click', function() {
$bioDrawer.toggleClass('is-open');
$bioButton.toggleClass('flip-carat');
if ($bioDrawer.hasClass('is-open')) {
$bioButton.text(hideBio);
$bioButton.toggleClass('is-open');
}
else {
$bioButton.text(showBio);
$bioButton.removeClass('is-open');
}
});
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.