Created
October 23, 2009 12:35
-
-
Save mattparker/216847 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var Dom = YAHOO.util.Dom, | |
Event = YAHOO.util.Event, | |
Lang = YAHOO.lang, | |
Toolbar = YAHOO.widget.Toolbar; | |
/** | |
* The Rich Text Editor is a UI control that replaces a standard HTML textarea; it allows for the rich formatting of text content, including common structural treatments like lists, formatting treatments like bold and italic text, and drag-and-drop inclusion and sizing of images. The Rich Text Editor's toolbar is extensible via a plugin architecture so that advanced implementations can achieve a high degree of customization. | |
* @constructor | |
* @class SimpleEditor | |
* @extends YAHOO.util.Element | |
* @param {String/HTMLElement} el The textarea element to turn into an editor. | |
* @param {Object} attrs Object liternal containing configuration parameters. | |
*/ | |
YAHOO.LPLT.widget.Editor = function(el, attrs) { | |
YAHOO.LPLT.widget.Editor.superclass.constructor.call(this, el, attrs); | |
}; | |
YAHOO.extend(YAHOO.LPLT.widget.Editor, YAHOO.widget.Editor, { | |
/** | |
* @method cmd_backcolorfull | |
* @param value Value passed from the execCommand method | |
* @description This is an execCommand override method. It is called from execCommand when the execCommand('backcolorfull') is used. | |
*/ | |
cmd_backcolorfull: function( value ){ | |
var exec = true, el = this._getSelectedElement(), action = 'backcolorfull'; | |
if (!this._isElement(el, 'body') && !this._hasSelection()) { | |
el.style.backgroundColor = value; | |
this._selectNode(el); | |
exec = false; | |
} else { | |
if (!this.get('insert')) { | |
this._createCurrentElement('div', { backgroundColor: value, color: el.style.color, fontSize: el.style.fontSize, fontFamily: el.style.fontFamily }); | |
this._selectNode(this.currentElement[0]); | |
} | |
exec = false; | |
} | |
return [exec, action]; | |
}, | |
/** | |
* @private | |
* @description Handles the colorpicker buttons in the toolbar. | |
* @param {Object} o Object returned from Toolbar's buttonClick Event | |
*/ | |
_handleColorPicker: function(o) { | |
var cmd = o.button; | |
var value = '#' + o.color; | |
if ((cmd == 'forecolor') || (cmd == 'backcolor') || (cmd == 'backcolorfull')) { | |
this.execCommand(cmd, value); | |
} | |
} | |
} ); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment