Skip to content

Instantly share code, notes, and snippets.

@alej0varas
Created August 20, 2014 12:24
Show Gist options
  • Save alej0varas/41ccc547ec25bde921f6 to your computer and use it in GitHub Desktop.
Save alej0varas/41ccc547ec25bde921f6 to your computer and use it in GitHub Desktop.
hallo.js font size plugin
// Hallo font size plugin
// Shows 7 buttons with an A + the size number.
// https://developer.mozilla.org/en-US/docs/Web/API/document.execCommand
// fontSize
// Changes the font size for the selection or at the insertion point. This requires an HTML font size (1-7) to be passed in as a // value argument.
//
// (c) 2014 Alejandro Varas
// hallofontsize may be freely distributed under the MIT license
(function(jQuery) {
return jQuery.widget("IKS.hallofontsize", {
colorElement : null,
options: {
uuid: '',
},
editable: null,
populateToolbar: function(toolbar) {
var buttonize, buttonset, _this = this;
buttonset = jQuery("<span class=\"" + this.widgetName + "\"></span>");
buttonize = function(alignment, command, size) {
var buttonElement;
buttonElement = jQuery('<span></span>');
buttonElement.hallobutton({
uuid: _this.options.uuid,
editable: _this.options.editable,
label: alignment,
command: command,
commandValue: size,
cssClass: _this.options.buttonCssClass
});
// overrides button font
buttonElement.find('.ui-button-text').text('A' + size);
return buttonset.append(buttonElement);
};
buttonize("Font 1", "fontSize", 1);
buttonize("Font 2", "fontSize", 2);
buttonize("Font 3", "fontSize", 3);
buttonize("Font 4", "fontSize", 4);
buttonize("Font 5", "fontSize", 5);
buttonize("Font 6", "fontSize", 6);
buttonize("Font 7", "fontSize", 7);
buttonset.hallobuttonset();
return toolbar.append(buttonset);
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment