Skip to content

Instantly share code, notes, and snippets.

@davglass
Created May 27, 2009 14:08
Show Gist options
  • Save davglass/118657 to your computer and use it in GitHub Desktop.
Save davglass/118657 to your computer and use it in GitHub Desktop.
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var myConfig = {
height: '150px',
width: '100%',
animate: true,
dompath: false,
focusAtStart: true
};
var state = 'off';
var myEditor = new YAHOO.widget.Editor('news_body', myConfig);
myEditor.on('toolbarLoaded', function() {
var codeConfig = {
type: 'push', label: 'Edit HTML Code', value: 'editcode'
};
this.toolbar.addButtonToGroup(codeConfig, 'insertitem');
this.toolbar.on('editcodeClick', function() {
var ta = this.get('element'),
iframe = this.get('iframe').get('element');
if (state == 'on') {
state = 'off';
this.toolbar.set('disabled', false);
this.setEditorHTML(ta.value);
Dom.removeClass(iframe, 'editor-hidden');
Dom.addClass(ta, 'editor-hidden');
this.show();
this._focusWindow();
} else {
state = 'on';
this.cleanHTML();
Dom.addClass(iframe, 'editor-hidden');
Dom.removeClass(ta, 'editor-hidden');
this.toolbar.set('disabled', true);
this.toolbar.getButtonByValue('editcode').set ('disabled', false);
this.toolbar.selectButton('editcode');
this.hide();
}
return false;
}, this, true);
this.on('cleanHTML', function(ev) {
this.get('element').value = ev.html;
}, this, true);
this.on('afterRender', function() {
var wrapper = this.get('editor_wrapper');
wrapper.appendChild(this.get('element'));}, this, true);
this.setStyle('width', '100%');
this.setStyle('height', '100%');
this.setStyle('visibility', '');
this.setStyle('top', '');
this.setStyle('left', '');
this.setStyle('position', '');
this.addClass('editor-hidden');
}, myEditor, true);
myEditor._defaultToolbar.titlebar=false; myEditor. _defaultToolbar.buttonType = 'advanced';
myEditor.render();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment