Skip to content

Instantly share code, notes, and snippets.

@alej0varas
Last active November 28, 2016 08:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alej0varas/1ec591b646eb71234b6a to your computer and use it in GitHub Desktop.
Save alej0varas/1ec591b646eb71234b6a to your computer and use it in GitHub Desktop.
hallo.js font family plugin
// hallo fontfamily plugin
// (c) 2014 Alejandro Varas
// hallofontfamily may be freely distributed under the MIT license
(function(jQuery) {
return jQuery.widget("IKS.hallofontfamily", {
options: {
uuid: '',
fonts: [
// from http://web.mit.edu/jmorzins/www/fonts.html
"Arial",
"Helvetica",
"Times New Roman",
"Times",
"Courier New",
"Courier",
// Other options that usually work cross-platform are:
"Palatino",
"Garamond",
// "Bookman",
// "Avant Garde",
// Fonts that work on Windows and MacOS but not Unix+X are:
"Verdana",
"Georgia",
"Comic Sans MS",
"Trebuchet MS",
"Arial Black",
"Impact"
],
},
populateToolbar: function(toolbar) {
var buttonset, widget,
_this = this;
widget = this;
buttonset = jQuery("<span class=\"" + widget.widgetName + "\"></span>");
this.createbuttons(buttonset);
buttonset.hallobuttonset();
toolbar.append(buttonset);
},
createbuttons: function (buttonset) {
var _this = this
jQuery.each(this.options.fonts, function(index) {
var family = _this.options.fonts[index];
var buttonElement;
buttonElement = jQuery('<span></span>');
buttonElement.hallobutton({
uuid: _this.options.uuid,
editable: _this.options.editable,
label: family,
command: 'fontName',
commandValue: family,
cssClass: _this.options.buttonCssClass,
});
buttonElement.find('.ui-button-text').css('font-family', family);
buttonElement.find('.ui-button-text').text('F');
buttonset.append(buttonElement);
});
},
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment