Skip to content

Instantly share code, notes, and snippets.

View scottdorman's full-sized avatar

Scott Dorman scottdorman

View GitHub Profile
@scottdorman
scottdorman / knockout-gist-embed.js
Last active August 29, 2015 14:04
A custom Knockout binding handler for embedding gists.
ko.bindingHandlers.gistEmbed = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
var $element, options, gist;
options = ko.utils.unwrapObservable(valueAccessor());
$element = $(element);
$element.data('gist-id', options.gistid);
$element.data('gist-file', options.file);
$element.data('gist-hide-footer', options.hidefooter || 'false');
$element.data('gist-hide-line-numbers', options.hidelinenumbers || 'false');
@scottdorman
scottdorman / bootstrapHelpers.js
Created August 18, 2018 17:15
Saving Bootstrap component state
function restoreAccordionPanel(storageKey, accordionId) {
var activeItem = localStorage.getItem(storageKey);
if (activeItem) {
//remove default collapse settings
$(accordionId + " .panel-collapse").removeClass('in');
//show the account_last visible group
$("#" + activeItem).addClass("in");
}
}