Skip to content

Commit

Permalink
Added a 'standard' button set that I'll likely use most.
Browse files Browse the repository at this point in the history
  • Loading branch information
swilliams committed Jul 16, 2010
1 parent 890754a commit b4cd357
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/wysihat.js
Expand Up @@ -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);
});
};
21 changes: 13 additions & 8 deletions 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) {
Expand All @@ -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
Expand Down Expand Up @@ -119,8 +119,6 @@ WysiHat.Toolbar = function() {
* "<a href='#' class='button bold'><span>Bold</span></a>"
**/
function addButton(options, handler) {
//options = $H(options);

if (!options['name']) {
options['name'] = options['label'].toLowerCase();
}
Expand Down Expand Up @@ -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(); } }
];

0 comments on commit b4cd357

Please sign in to comment.