Skip to content

Instantly share code, notes, and snippets.

import _ from 'lodash';
import $ from 'jquery';
import {tools} from './tools.js';
@AllyReid
AllyReid / gfontSwitcher.js
Last active January 24, 2019 02:10
Google Font Switcher - Basic example
$("#gfont").on('change', function(){
var fontName = $("option:selected", this).attr("data-font-name");
var fontChoice = $(this).val();
WebFont.load({
google: {
families: [fontChoice]
}
});
/**
* Prefilter for caching ajax calls - adapted from
* https://github.com/paulirish/jquery-ajax-localstorage-cache, made to work with jqXHR Deferred Promises.
* See also $.ajaxTransport.
* New parameters available on the ajax call:
* localCache : true, // required if we want to use the cache functionality
* cacheTTL : 1, // in hours. Optional
* cacheKey : 'post', // optional
* isCacheValid : function // optional - return true for valid, false for invalid
* @method $.ajaxPrefilter