diff --git a/src/wysihat.js b/src/wysihat.js index 8d45cb4..c911887 100644 --- a/src/wysihat.js +++ b/src/wysihat.js @@ -33,11 +33,15 @@ var WysiHat = {}; //= require "wysihat/toolbar" // Set wysihat as a jQuery plugin -$.fn.wysihat = function() { +$.fn.wysihat = function(options) { + options = options || { + buttons: WysiHat.Toolbar.ButtonSets.Standard + } + return this.each(function() { var editor = WysiHat.Editor.attach($(this)); var toolbar = new WysiHat.Toolbar(editor); toolbar.initialize(editor); - toolbar.addButtonSet(WysiHat.Toolbar.ButtonSets.Basic); + toolbar.addButtonSet(options.buttons); }); }; \ No newline at end of file diff --git a/src/wysihat/toolbar.js b/src/wysihat/toolbar.js index 0bcea09..b6ebe7a 100644 --- a/src/wysihat/toolbar.js +++ b/src/wysihat/toolbar.js @@ -1,31 +1,31 @@ //= require "events/selection_change" // function createClass() { -// var parent = null; +// var parent = null; // var properties = arguments; // function klass() { // this.initialize.apply(this, arguments); // } // klass.superclass = parent; // klass.subclasses = []; -// +// // if (parent) { // subclass.prototype = parent.prototype; // klass.prototype = new subclass; // parent.subclasses.push(klass); // } -// +// // for (var i = 0, length = properties.length; i < length; i++) { // klass.addMethods(properties[i]); // } -// +// // if (!klass.prototype.initialize) { // klass.prototype.initialize = function() {}; // } // klass.prototype.constructor = klass; // return klass; // } -// +// // function addMethods(source) { // var ancestor = this.superclass && this.superclass.prototype; // for (var key in source) { @@ -46,7 +46,7 @@ WysiHat.Toolbar = function() { var editor; var element; - + /** * new WysiHat.Toolbar(editor) * - editor (WysiHat.Editor): the editor object that you want to attach to @@ -119,8 +119,6 @@ WysiHat.Toolbar = function() { * "Bold" **/ function addButton(options, handler) { - //options = $H(options); - if (!options['name']) { options['name'] = options['label'].toLowerCase(); } @@ -282,3 +280,10 @@ WysiHat.Toolbar.ButtonSets.Basic = [ { label: "Underline" }, { label: "Italic" } ]; + +WysiHat.Toolbar.ButtonSets.Standard = [ + { label: "Bold" }, + { label: "Italic" }, + { label: "Strikethrough" }, + { label: "Bullets", handler: function(editor) { return editor.toggleUnorderedList(); } } +];