Remember open/close state of help text with localStorage.
This commit is contained in:
parent
ce74a9f642
commit
ec8d5e84de
|
@ -27,13 +27,16 @@ body.front h1.page-header {
|
|||
}
|
||||
|
||||
/**
|
||||
* Style help glyphicon in page title.
|
||||
* Style help text glyphicons.
|
||||
*/
|
||||
.page-header .glyphicon-question-sign {
|
||||
color: #3a87ad;
|
||||
cursor: pointer;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
.region-help .glyphicon-remove {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove padding and list style from user login block links (request new password).
|
||||
|
|
|
@ -2,12 +2,28 @@
|
|||
Drupal.behaviors.farm_theme_help = {
|
||||
attach: function(context, settings) {
|
||||
if ($('.region-help', context).length) {
|
||||
var glyphicon = '<span class="glyphicon glyphicon-question-sign" aria-hidden="true" title="Click for more information"></span>';
|
||||
$('.page-header', context).append(' ' + glyphicon);
|
||||
$('.region-help', context).hide();
|
||||
var helpGlyphicon = '<span class="glyphicon glyphicon-question-sign" aria-hidden="true" data-toggle="tooltip" data-placement="bottom" title="Expand/collapse help text"></span>';
|
||||
var closeGlyphicon = '<span class="glyphicon glyphicon-remove" aria-hidden="true" title="Click to hide help" style="float: right;"></span>';
|
||||
$('.page-header', context).append(' ' + helpGlyphicon);
|
||||
$('.region-help', context).prepend(' ' + closeGlyphicon);
|
||||
if (localStorage.getItem('farmThemeHelpCollapsed') === '1') {
|
||||
$('.region-help', context).hide();
|
||||
}
|
||||
$('.page-header .glyphicon-question-sign', context).click(function() {
|
||||
$('.region-help', context).slideToggle();
|
||||
Drupal.behaviors.farm_theme_help.toggleHelp();
|
||||
});
|
||||
$('.region-help .glyphicon-remove', context).click(function() {
|
||||
$('.page-header .glyphicon-question-sign').tooltip('show');
|
||||
Drupal.behaviors.farm_theme_help.toggleHelp();
|
||||
});
|
||||
}
|
||||
},
|
||||
toggleHelp: function(context) {
|
||||
$('.region-help', context).slideToggle();
|
||||
if (localStorage.getItem('farmThemeHelpCollapsed') === '1') {
|
||||
localStorage.removeItem('farmThemeHelpCollapsed');
|
||||
} else {
|
||||
localStorage.setItem('farmThemeHelpCollapsed', '1');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue