In the recipe we just looked at, we extended the Options class, took an option in the form of a CSV of Google fonts, and styled text using CSS. Get ready to see how even the instantiation line can be generated based on a few clicks. That way, no typos or issues with unavailable fonts can creep in and catch us off guard.
Designers, especially, love this one-time-use class method.
Dabble in a bit of polymorphism. When no fonts are passed during instantiation, route the flow of action to a new method that generates an interface. That interface will have a multi-select input widget that onClick
updates a TEXTAREA
with an instantiation code that designers can use to embed their Google web fonts.
For brevity, only the new method is shown:
... generate_code: function() { // for each of the styles available, create an li // display in multiselect format, generate code on click this.fonts = []; this.gwfdirfonts.each(function(font) { this.fonts.include...