/**
* @module editor
* @description <p>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.</p>
* @namespace YAHOO.widget
* @requires yahoo, dom, element, event, container_core, simpleeditor
* @optional dragdrop, animation, menu, button
* @beta
*/
(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 Editor
* @extends YAHOO.widget.SimpleEditor
* @param {String/HTMLElement} el The textarea element to turn into an editor.
* @param {Object} attrs Object liternal containing configuration parameters.
*/
YAHOO.widget.Editor = function(el, attrs) {
YAHOO.log('Editor Initalizing', 'info', 'Editor');
YAHOO.widget.Editor.superclass.constructor.call(this, el, attrs);
};
/**
* @private
* @method _cleanClassName
* @description Makes a useable classname from dynamic data, by dropping it to lowercase and replacing spaces with -'s.
* @param {String} str The classname to clean up
* @return {String}
*/
function _cleanClassName(str) {
return str.replace(/ /g, '-').toLowerCase();
}
YAHOO.extend(YAHOO.widget.Editor, YAHOO.widget.SimpleEditor, {
/**
* @property STR_BEFORE_EDITOR
* @description The accessibility string for the element before the iFrame
* @type String
*/
STR_BEFORE_EDITOR: 'This text field can contain stylized text and graphics. To cycle through all formatting options, use the keyboard shortcut Control + Shift + T to place focus on the toolbar and navigate between option heading names. <h4>Common formatting keyboard shortcuts:</h4><ul><li>Control Shift B sets text to bold</li> <li>Control Shift I sets text to italic</li> <li>Control Shift U underlines text</li> <li>Control Shift [ aligns text left</li> <li>Control Shift | centers text</li> <li>Control Shift ] aligns text right</li> <li>Control Shift L adds an HTML link</li> <li>To exit this text editor use the keyboard shortcut Control + Shift + ESC.</li></ul>',
/**
* @property STR_CLOSE_WINDOW
* @description The Title of the close button in the Editor Window
* @type String
*/
STR_CLOSE_WINDOW: 'Close Window',
/**
* @property STR_CLOSE_WINDOW_NOTE
* @description A note appearing in the Editor Window to tell the user that the Escape key will close the window
* @type String
*/
STR_CLOSE_WINDOW_NOTE: 'To close this window use the Control + Shift + W key',
/**
* @property STR_IMAGE_PROP_TITLE
* @description The title for the Image Property Editor Window
* @type String
*/
STR_IMAGE_PROP_TITLE: 'Image Options',
/**
* @property STR_IMAGE_URL
* @description The label string for Image URL
* @type String
*/
STR_IMAGE_URL: 'Image Url',
/**
* @property STR_IMAGE_TITLE
* @description The label string for Image Description
* @type String
*/
STR_IMAGE_TITLE: 'Description',
/**
* @property STR_IMAGE_SIZE
* @description The label string for Image Size
* @type String
*/
STR_IMAGE_SIZE: 'Size',
/**
* @property STR_IMAGE_ORIG_SIZE
* @description The label string for Original Image Size
* @type String
*/
STR_IMAGE_ORIG_SIZE: 'Original Size',
/**
* @property STR_IMAGE_COPY
* @description The label string for the image copy and paste message for Opera and Safari
* @type String
*/
STR_IMAGE_COPY: '<span class="tip"><span class="icon icon-info"></span><strong>Note:</strong>To move this image just highlight it, cut, and paste where ever you\'d like.</span>',
/**
* @property STR_IMAGE_PADDING
* @description The label string for the image padding.
* @type String
*/
STR_IMAGE_PADDING: 'Padding',
/**
* @property STR_IMAGE_BORDER
* @description The label string for the image border.
* @type String
*/
STR_IMAGE_BORDER: 'Border',
/**
* @property STR_IMAGE_TEXTFLOW
* @description The label string for the image text flow.
* @type String
*/
STR_IMAGE_TEXTFLOW: 'Text Flow',
/**
* @property STR_LOCAL_FILE_WARNING
* @description The label string for the local file warning.
* @type String
*/
STR_LOCAL_FILE_WARNING: '<span class="tip"><span class="icon icon-warn"></span><strong>Note:</strong>This image/link points to a file on your computer and will not be accessible to others on the internet.</span>',
/**
* @property STR_LINK_PROP_TITLE
* @description The label string for the Link Property Editor Window.
* @type String
*/
STR_LINK_PROP_TITLE: 'Link Options',
/**
* @property STR_LINK_PROP_REMOVE
* @description The label string for the Remove link from text link inside the property editor.
* @type String
*/
STR_LINK_PROP_REMOVE: 'Remove link from text',
/**
* @property STR_LINK_NEW_WINDOW
* @description The string for the open in a new window label.
* @type String
*/
STR_LINK_NEW_WINDOW: 'Open in a new window.',
/**
* @property STR_LINK_TITLE
* @description The string for the link description.
* @type String
*/
STR_LINK_TITLE: 'Description',
/**
* @protected
* @property CLASS_LOCAL_FILE
* @description CSS class applied to an element when it's found to have a local url.
* @type String
*/
CLASS_LOCAL_FILE: 'warning-localfile',
/**
* @protected
* @property CLASS_HIDDEN
* @description CSS class applied to the body when the hiddenelements button is pressed.
* @type String
*/
CLASS_HIDDEN: 'yui-hidden',
/**
* @method init
* @description The Editor class' initialization method
*/
init: function(p_oElement, p_oAttributes) {
YAHOO.log('init', 'info', 'Editor');
this._defaultToolbar = {
collapse: true,
titlebar: 'Text Editing Tools',
draggable: false,
buttonType: 'advanced',
buttons: [
{ group: 'fontstyle', label: 'Font Name and Size',
buttons: [
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true,
menu: [
{ text: 'Arial', checked: true },
{ text: 'Arial Black' },
{ text: 'Comic Sans MS' },
{ text: 'Courier New' },
{ text: 'Lucida Console' },
{ text: 'Tahoma' },
{ text: 'Times New Roman' },
{ text: 'Trebuchet MS' },
{ text: 'Verdana' }
]
},
{ type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true }
]
},
{ type: 'separator' },
{ group: 'textstyle', label: 'Font Style',
buttons: [
{ type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' },
{ type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' },
{ type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' },
{ type: 'separator' },
{ type: 'push', label: 'Subscript', value: 'subscript', disabled: true },
{ type: 'push', label: 'Superscript', value: 'superscript', disabled: true },
{ type: 'separator' },
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
{ type: 'color', label: 'Background Color', value: 'backcolor', disabled: true },
{ type: 'separator' },
{ type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true },
{ type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' }
]
},
{ type: 'separator' },
{ group: 'alignment', label: 'Alignment',
buttons: [
{ type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' },
{ type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' },
{ type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' },
{ type: 'push', label: 'Justify', value: 'justifyfull' }
]
},
{ type: 'separator' },
{ group: 'parastyle', label: 'Paragraph Style',
buttons: [
{ type: 'select', label: 'Normal', value: 'heading', disabled: true,
menu: [
{ text: 'Normal', value: 'none', checked: true },
{ text: 'Header 1', value: 'h1' },
{ text: 'Header 2', value: 'h2' },
{ text: 'Header 3', value: 'h3' },
{ text: 'Header 4', value: 'h4' },
{ text: 'Header 5', value: 'h5' },
{ text: 'Header 6', value: 'h6' }
]
}
]
},
{ type: 'separator' },
{ group: 'indentlist', label: 'Indenting and Lists',
buttons: [
{ type: 'push', label: 'Indent', value: 'indent', disabled: true },
{ type: 'push', label: 'Outdent', value: 'outdent', disabled: true },
{ type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' },
{ type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' }
]
},
{ type: 'separator' },
{ group: 'insertitem', label: 'Insert Item',
buttons: [
{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true },
{ type: 'push', label: 'Insert Image', value: 'insertimage' }
]
}
]
};
YAHOO.widget.Editor.superclass.init.call(this, p_oElement, p_oAttributes);
},
/**
* @method initAttributes
* @description Initializes all of the configuration attributes used to create
* the editor.
* @param {Object} attr Object literal specifying a set of
* configuration attributes used to create the editor.
*/
initAttributes: function(attr) {
YAHOO.widget.Editor.superclass.initAttributes.call(this, attr);
/**
* @attribute localFileWarning
* @description Should we throw the warning if we detect a file that is local to their machine?
* @default true
* @type Boolean
*/
this.setAttributeConfig('localFileWarning', {
value: attr.locaFileWarning || true
});
/**
* @attribute hiddencss
* @description The CSS used to show/hide hidden elements on the page, these rules must be prefixed with the class provided in <code>this.CLASS_HIDDEN</code>
* @default <code><pre>
.yui-hidden font, .yui-hidden strong, .yui-hidden b, .yui-hidden em, .yui-hidden i, .yui-hidden u, .yui-hidden div, .yui-hidden p, .yui-hidden span, .yui-hidden img, .yui-hidden ul, .yui-hidden ol, .yui-hidden li, .yui-hidden table {
border: 1px dotted #ccc;
}
.yui-hidden .yui-non {
border: none;
}
.yui-hidden img {
padding: 2px;
}</pre></code>
* @type String
*/
this.setAttributeConfig('hiddencss', {
value: attr.hiddencss || '.yui-hidden font, .yui-hidden strong, .yui-hidden b, .yui-hidden em, .yui-hidden i, .yui-hidden u, .yui-hidden div,.yui-hidden p,.yui-hidden span,.yui-hidden img, .yui-hidden ul, .yui-hidden ol, .yui-hidden li, .yui-hidden table { border: 1px dotted #ccc; } .yui-hidden .yui-non { border: none; } .yui-hidden img { padding: 2px; }',
writeOnce: true
});
},
/**
* @private
* @method _fixNodes
* @description Fix href and imgs as well as remove invalid HTML.
*/
_fixNodes: function() {
YAHOO.widget.Editor.superclass._fixNodes.call(this);
var url = '';
var imgs = this._getDoc().getElementsByTagName('img');
for (var im = 0; im < imgs.length; im++) {
if (imgs[im].getAttribute('href', 2)) {
url = imgs[im].getAttribute('src', 2);
if (this._isLocalFile(url)) {
Dom.addClass(imgs[im], this.CLASS_LOCAL_FILE);
} else {
Dom.removeClass(imgs[im], this.CLASS_LOCAL_FILE);
}
}
}
var fakeAs = this._getDoc().body.getElementsByTagName('a');
for (var a = 0; a < fakeAs.length; a++) {
if (fakeAs[a].getAttribute('href', 2)) {
url = fakeAs[a].getAttribute('href', 2);
if (this._isLocalFile(url)) {
Dom.addClass(fakeAs[a], this.CLASS_LOCAL_FILE);
} else {
Dom.removeClass(fakeAs[a], this.CLASS_LOCAL_FILE);
}
}
}
},
/**
* @private
* @property _disabled
* @description The Toolbar items that should be disabled if there is no selection present in the editor.
* @type Array
*/
_disabled: [ 'createlink', 'forecolor', 'backcolor', 'fontname', 'fontsize', 'superscript', 'subscript', 'removeformat', 'heading', 'indent' ],
/**
* @private
* @property _alwaysDisabled
* @description The Toolbar items that should ALWAYS be disabled event if there is a selection present in the editor.
* @type Object
*/
_alwaysDisabled: { 'outdent': true },
/**
* @private
* @property _alwaysEnabled
* @description The Toolbar items that should ALWAYS be enabled event if there isn't a selection present in the editor.
* @type Object
*/
_alwaysEnabled: { hiddenelements: true },
/**
* @private
* @method _handleKeyDown
* @param {Event} ev The event we are working on.
* @description Override method that handles some new keydown events inside the iFrame document.
*/
_handleKeyDown: function(ev) {
YAHOO.widget.Editor.superclass._handleKeyDown.call(this, ev);
var doExec = false,
action = null,
exec = false;
if (ev.shiftKey && ev.ctrlKey) {
doExec = true;
}
switch (ev.keyCode) {
case 219: //Left
action = 'justifyleft';
break;
case 220: //Center
action = 'justifycenter';
break;
case 221: //Right
action = 'justifyright';
break;
}
if (doExec && action) {
this.execCommand(action, null);
Event.stopEvent(ev);
this.nodeChange();
}
},
_handleCreateLinkClick: function() {
var el = this._getSelectedElement();
if (this._isElement(el, 'img')) {
this.STOP_EXEC_COMMAND = true;
this.currentElement[0] = el;
this.toolbar.fireEvent('insertimageClick', { type: 'insertimageClick', target: this.toolbar });
this.fireEvent('afterExecCommand', { type: 'afterExecCommand', target: this });
return false;
}
if (this.get('limitCommands')) {
if (!this.toolbar.getButtonByValue('createlink')) {
YAHOO.log('Toolbar Button for (createlink) was not found, skipping exec.', 'info', 'Editor');
return false;
}
}
this.on('afterExecCommand', function() {
var win = new YAHOO.widget.EditorWindow('createlink', {
width: '350px'
});
var el = this.currentElement[0],
url = '',
title = '',
target = '',
localFile = false;
if (el) {
if (el.getAttribute('href', 2) !== null) {
url = el.getAttribute('href', 2);
if (this._isLocalFile(url)) {
//Local File throw Warning
YAHOO.log('Local file reference found, show local warning', 'warn', 'Editor');
win.setFooter(this.STR_LOCAL_FILE_WARNING);
localFile = true;
} else {
win.setFooter(' ');
}
}
if (el.getAttribute('title') !== null) {
title = el.getAttribute('title');
}
if (el.getAttribute('target') !== null) {
target = el.getAttribute('target');
}
}
var str = '<label for="createlink_url"><strong>' + this.STR_LINK_URL + ':</strong> <input type="text" name="createlink_url" id="createlink_url" value="' + url + '"' + ((localFile) ? ' class="warning"' : '') + '></label>';
str += '<label for="createlink_target"><strong> </strong><input type="checkbox" name="createlink_target_" id="createlink_target" value="_blank"' + ((target) ? ' checked' : '') + '> ' + this.STR_LINK_NEW_WINDOW + '</label>';
str += '<label for="createlink_title"><strong>' + this.STR_LINK_TITLE + ':</strong> <input type="text" name="createlink_title" id="createlink_title" value="' + title + '"></label>';
var body = document.createElement('div');
body.innerHTML = str;
var unlinkCont = document.createElement('div');
unlinkCont.className = 'removeLink';
var unlink = document.createElement('a');
unlink.href = '#';
unlink.innerHTML = this.STR_LINK_PROP_REMOVE;
unlink.title = this.STR_LINK_PROP_REMOVE;
Event.on(unlink, 'click', function(ev) {
Event.stopEvent(ev);
this.execCommand('unlink');
this.closeWindow();
}, this, true);
unlinkCont.appendChild(unlink);
body.appendChild(unlinkCont);
win.setHeader(this.STR_LINK_PROP_TITLE);
win.setBody(body);
Event.onAvailable('createlink_url', function() {
window.setTimeout(function() {
try {
YAHOO.util.Dom.get('createlink_url').focus();
} catch (e) {}
}, 50);
Event.on('createlink_url', 'blur', function() {
var url = Dom.get('createlink_url');
if (this._isLocalFile(url.value)) {
//Local File throw Warning
Dom.addClass(url, 'warning');
YAHOO.log('Local file reference found, show local warning', 'warn', 'Editor');
this.get('panel').setFooter(this.STR_LOCAL_FILE_WARNING);
} else {
Dom.removeClass(url, 'warning');
this.get('panel').setFooter(' ');
}
}, this, true);
}, this, true);
this.openWindow(win);
});
},
/**
* @private
* @method _handleCreateLinkWindowClose
* @description Handles the closing of the Link Properties Window.
*/
_handleCreateLinkWindowClose: function() {
var url = Dom.get('createlink_url'),
target = Dom.get('createlink_target'),
title = Dom.get('createlink_title'),
el = this.currentElement[0],
a = el;
if (url && url.value) {
var urlValue = url.value;
if ((urlValue.indexOf(':/'+'/') == -1) && (urlValue.substring(0,1) != '/') && (urlValue.substring(0, 6).toLowerCase() != 'mailto')) {
if ((urlValue.indexOf('@') != -1) && (urlValue.substring(0, 6).toLowerCase() != 'mailto')) {
//Found an @ sign, prefix with mailto:
urlValue = 'mailto:' + urlValue;
} else {
/* :// not found adding */
if (urlValue.substring(0, 1) != '#') {
urlValue = 'http:/'+'/' + urlValue;
}
}
}
el.setAttribute('href', urlValue);
if (target.checked) {
el.setAttribute('target', target.value);
} else {
el.setAttribute('target', '');
}
el.setAttribute('title', ((title.value) ? title.value : ''));
} else {
var _span = this._getDoc().createElement('span');
_span.innerHTML = el.innerHTML;
Dom.addClass(_span, 'yui-non');
el.parentNode.replaceChild(_span, el);
}
this.nodeChange();
this.currentElement = [];
},
/**
* @private
* @method _handleInsertImageClick
* @description Opens the Image Properties Window when the insert Image button is clicked or an Image is Double Clicked.
*/
_handleInsertImageClick: function() {
if (this.get('limitCommands')) {
if (!this.toolbar.getButtonByValue('insertimage')) {
YAHOO.log('Toolbar Button for (insertimage) was not found, skipping exec.', 'info', 'Editor');
return false;
}
}
this._setBusy();
this.on('afterExecCommand', function() {
var el = this.currentElement[0],
body = null,
link = '',
target = '',
title = '',
src = '',
align = '',
height = 75,
width = 75,
padding = 0,
oheight = 0,
owidth = 0,
blankimage = false,
win = new YAHOO.widget.EditorWindow('insertimage', {
width: '415px'
});
if (!el) {
el = this._getSelectedElement();
}
if (el) {
if (el.getAttribute('src')) {
src = el.getAttribute('src', 2);
if (src.indexOf(this.get('blankimage')) != -1) {
src = this.STR_IMAGE_HERE;
blankimage = true;
}
}
if (el.getAttribute('alt', 2)) {
title = el.getAttribute('alt', 2);
}
if (el.getAttribute('title', 2)) {
title = el.getAttribute('title', 2);
}
if (el.parentNode && this._isElement(el.parentNode, 'a')) {
link = el.parentNode.getAttribute('href', 2);
if (el.parentNode.getAttribute('target') !== null) {
target = el.parentNode.getAttribute('target');
}
}
height = parseInt(el.height, 10);
width = parseInt(el.width, 10);
if (el.style.height) {
height = parseInt(el.style.height, 10);
}
if (el.style.width) {
width = parseInt(el.style.width, 10);
}
if (el.style.margin) {
padding = parseInt(el.style.margin, 10);
}
if (!el._height) {
el._height = height;
}
if (!el._width) {
el._width = width;
}
oheight = el._height;
owidth = el._width;
}
var str = '<label for="insertimage_url"><strong>' + this.STR_IMAGE_URL + ':</strong> <input type="text" id="insertimage_url" value="' + src + '" size="40"></label>';
body = document.createElement('div');
body.innerHTML = str;
var tbarCont = document.createElement('div');
tbarCont.id = 'img_toolbar';
body.appendChild(tbarCont);
var str2 = '<label for="insertimage_title"><strong>' + this.STR_IMAGE_TITLE + ':</strong> <input type="text" id="insertimage_title" value="' + title + '" size="40"></label>';
str2 += '<label for="insertimage_link"><strong>' + this.STR_LINK_URL + ':</strong> <input type="text" name="insertimage_link" id="insertimage_link" value="' + link + '"></label>';
str2 += '<label for="insertimage_target"><strong> </strong><input type="checkbox" name="insertimage_target_" id="insertimage_target" value="_blank"' + ((target) ? ' checked' : '') + '> ' + this.STR_LINK_NEW_WINDOW + '</label>';
var div = document.createElement('div');
div.innerHTML = str2;
body.appendChild(div);
win.cache = body;
var tbar = new YAHOO.widget.Toolbar(tbarCont, {
/* {{{ */
buttonType: this._defaultToolbar.buttonType,
buttons: [
{ group: 'textflow', label: this.STR_IMAGE_TEXTFLOW + ':',
buttons: [
{ type: 'push', label: 'Left', value: 'left' },
{ type: 'push', label: 'Inline', value: 'inline' },
{ type: 'push', label: 'Block', value: 'block' },
{ type: 'push', label: 'Right', value: 'right' }
]
},
{ type: 'separator' },
{ group: 'padding', label: this.STR_IMAGE_PADDING + ':',
buttons: [
{ type: 'spin', label: ''+padding, value: 'padding', range: [0, 50] }
]
},
{ type: 'separator' },
{ group: 'border', label: this.STR_IMAGE_BORDER + ':',
buttons: [
{ type: 'select', label: 'Border Size', value: 'bordersize',
menu: [
{ text: 'none', value: '0', checked: true },
{ text: '1px', value: '1' },
{ text: '2px', value: '2' },
{ text: '3px', value: '3' },
{ text: '4px', value: '4' },
{ text: '5px', value: '5' }
]
},
{ type: 'select', label: 'Border Type', value: 'bordertype', disabled: true,
menu: [
{ text: 'Solid', value: 'solid', checked: true },
{ text: 'Dashed', value: 'dashed' },
{ text: 'Dotted', value: 'dotted' }
]
},
{ type: 'color', label: 'Border Color', value: 'bordercolor', disabled: true }
]
}
]
/* }}} */
});
var bsize = '0';
var btype = 'solid';
if (el.style.borderLeftWidth) {
bsize = parseInt(el.style.borderLeftWidth, 10);
}
if (el.style.borderLeftStyle) {
btype = el.style.borderLeftStyle;
}
var bs_button = tbar.getButtonByValue('bordersize');
var bSizeStr = ((parseInt(bsize, 10) > 0) ? '' : 'none');
bs_button.set('label', '<span class="yui-toolbar-bordersize-' + bsize + '">'+bSizeStr+'</span>');
this._updateMenuChecked('bordersize', bsize, tbar);
var bt_button = tbar.getButtonByValue('bordertype');
bt_button.set('label', '<span class="yui-toolbar-bordertype-' + btype + '"></span>');
this._updateMenuChecked('bordertype', btype, tbar);
if (parseInt(bsize, 10) > 0) {
tbar.enableButton(bt_button);
tbar.enableButton(bs_button);
}
var cont = tbar.get('cont');
var hw = document.createElement('div');
hw.className = 'yui-toolbar-group yui-toolbar-group-height-width height-width';
hw.innerHTML = '<h3>' + this.STR_IMAGE_SIZE + ':</h3>';
var orgSize = '';
if ((height != oheight) || (width != owidth)) {
orgSize = '<span class="info">' + this.STR_IMAGE_ORIG_SIZE + '<br>'+ owidth +' x ' + oheight + '</span>';
}
hw.innerHTML += '<span tabIndex="-1"><input type="text" size="3" value="'+width+'" id="insertimage_width"> x <input type="text" size="3" value="'+height+'" id="insertimage_height"></span>' + orgSize;
cont.insertBefore(hw, cont.firstChild);
Event.onAvailable('insertimage_width', function() {
Event.on('insertimage_width', 'blur', function() {
var value = parseInt(Dom.get('insertimage_width').value, 10);
if (value > 5) {
el.style.width = value + 'px';
//Removed moveWindow call so the window doesn't jump
//this.moveWindow();
}
}, this, true);
}, this, true);
Event.onAvailable('insertimage_height', function() {
Event.on('insertimage_height', 'blur', function() {
var value = parseInt(Dom.get('insertimage_height').value, 10);
if (value > 5) {
el.style.height = value + 'px';
//Removed moveWindow call so the window doesn't jump
//this.moveWindow();
}
}, this, true);
}, this, true);
if ((el.align == 'right') || (el.align == 'left')) {
tbar.selectButton(el.align);
} else if (el.style.display == 'block') {
tbar.selectButton('block');
} else {
tbar.selectButton('inline');
}
if (parseInt(el.style.marginLeft, 10) > 0) {
tbar.getButtonByValue('padding').set('label', ''+parseInt(el.style.marginLeft, 10));
}
if (el.style.borderSize) {
tbar.selectButton('bordersize');
tbar.selectButton(parseInt(el.style.borderSize, 10));
}
tbar.on('colorPickerClicked', function(o) {
var size = '1', type = 'solid', color = 'black';
if (el.style.borderLeftWidth) {
size = parseInt(el.style.borderLeftWidth, 10);
}
if (el.style.borderLeftStyle) {
type = el.style.borderLeftStyle;
}
if (el.style.borderLeftColor) {
color = el.style.borderLeftColor;
}
var borderString = size + 'px ' + type + ' #' + o.color;
el.style.border = borderString;
}, this.toolbar, true);
tbar.on('buttonClick', function(o) {
var value = o.button.value,
borderString = '';
if (o.button.menucmd) {