4944N/A<!
DOCTYPE HTML PUBLIC "-//
W3C//
DTD HTML 4.01//
EN" "
http://
www.w3.org/
TR/
html4/
strict.dtd">
4944N/A <
style type=
"text/css" media=
"screen">
4944N/A border-left: 3px solid red;
5680N/A<
h1 tabindex=
"1">Editor Testing</
h1>
6931N/A<
div id=
"test1" role=
"widget">
6931N/A <
option selected> </
option>
4944N/A <
option>Arial Black</
option>
4944N/A <
option>Comic Sans MS</
option>
5680N/A <
option>Courier New</
option>
5680N/A <
option>Lucida Console</
option>
4944N/A <
option>Times New Roman</
option>
4944N/A <
option>Trebuchet MS</
option>
4944N/A <
option selected> </
option>
5795N/A <
option value=
"1">10</
option>
5795N/A <
option value=
"2">13</
option>
5795N/A <
option value=
"3">16</
option>
5680N/A <
option value=
"4">18</
option>
4944N/A <
option value=
"5">24</
option>
5680N/A <
option value=
"6">32</
option>
5680N/A <
option value=
"7">48</
option>
4944N/A <
button value=
"bold">Bold</
button>
4944N/A <
button value=
"italic">Italic</
button>
6931N/A <
button value=
"underline">Underline</
button>
6931N/A <
button value=
"foo">Foo</
button>
4944N/A <
button value=
"img">InsertImage</
button>
<
button value=
"wrap">Wrap</
button>
<
button value=
"inserthtml">InsertHTML</
button>
<
button value=
"addclass">AddClass</
button>
<
button value=
"removeclass">RemoveClass</
button>
<
button value=
"bidi">BiDi</
button>
<
button value=
"indent">Indent</
button>
<
button value=
"outdent">Outdent</
button>
<
button value=
"insertorderedlist">InsertOrderedList</
button>
<
button value=
"insertunorderedlist">InsertUnOrderedList</
button>
<
button value=
"createlink">createlink</
button>
<
button value=
"inserthorizontalrule">inserthorizontalrule</
button>
<
button value=
"backcolor">backcolor</
button>
<
button value=
"forecolor">forecolor</
button>
<
button value=
"justifycenter">justifycenter</
button>
<
button value=
"justifyleft">justifyleft</
button>
<
button value=
"justifyright">justifyright</
button>
<
button value=
"justifyfull">justifyfull</
button>
<
button value=
"replacecontent">ReplaceContent</
button>
<
button id=
"getHTML">Get HTML</
button>
<
button id=
"setHTML">Set HTML</
button>
<
button id=
"focusEditor">Focus Editor</
button>
<!--button id="showEditor">Show Editor</button--> <li style="font-family: courier new">Item #1</li> <div style="font-family: ; font-size: ;"><br> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <font size="2" face="Tahoma"> <b><span style="font-weight:bold;">From:</span></b> yahoo-account-services-us@cc.yahoo-inc.com<br> <b><span style="font-weight: bold;">To:</span></b> hb.stone@yahoo.com<br> <b><span style="font-weight: bold;">Cc:</span></b> <br> <b><span style="font-weight: bold;">Sent:</span></b> 2010-07-09 14:19:12<br> <b><span style="font-weight: bold;">Subject:</span></b> Verify this email address<br> <div style="direction:ltr;"> <hr noshade width="95%"> <br><br> <table border="0" width="735"> <td width="10%"> </td> <td width="80%"> <font size="+1" color="#631266" face="Arial"> <b>Verify this email address</b> </font> <br> </td> <td width="10%"> </td> <td colspan="3"> </td> <td width="2.5%"> </td> <td> <font face="Arial" size="-3"></font> </td> <td width="2.5%"> </td> <!--p><b>This is a <u>test. <i>This is</i> another</u> test.</b></p> This is some <strong>other</strong> loose test. <p>This <strong>is</strong> <font face="Courier New">another</font> test.</p> <li style="font-family: courier new">Item #1</li> <p>This <strong>is</strong> <font face="Courier New">another</font> test.</p> <
script type=
"text/javascript" src=
"../../build/yui/yui-debug.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/editor-base.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/frame.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/exec-command.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/selection.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/lists.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/editor-tab.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/createlink-base.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript" src=
"js/editor-bidi.js?bust=<?php echo(
time());
?>"></
script>
<
script type=
"text/javascript">
YUI(yConfig).use('node', 'selector-css3', 'base', 'editor-base', 'frame', 'substitute', 'exec-command', 'editor-lists', 'createlink-base', 'editor-bidi', 'editor-lists', function(Y) {
Y.delegate('click', function(e) {
e.target.toggleClass('selected');
var cmd = e.target.get('innerHTML').toLowerCase(),
val = ' <
span style=
"color: red; background-color: blue;">Inserted Text (' + (new Date()).toString() + ')</
span> ';
var ex_return = editor.execCommand(cmd, val);
//console.info('Return: ', cmd, ' :: ', ex_return);
}, '#test1 > div', 'button');
Y.delegate('change', function(e) {
var cmd = e.currentTarget.get('id'),
val = e.currentTarget.get('value');
var ex_return = editor.execCommand(cmd, val);
}, '#test1 > div', 'select');
var s_cont = Y.one('#smilies');
Y.each(smilies, function(v, k) {
s_cont.append('<
img src=
"smilies/' + k + '.gif" alt=
"Click to insert">');
s_cont.delegate('click', function(e) {
var img = e.currentTarget, inst = editor.getInstance();
editor.execCommand('insertandfocus', '<
span>:)</
span>');
editor.focus(function() {
editor.execCommand('insertandfocus', '<
span>:)</
span>');
var buttons = Y.all('#test1 button');
var f_options = Y.all('#fontname option');
var s_options = Y.all('#fontsize option');
var updateButtons = function(e) {
buttons.removeClass('selected');
buttons.each(function(v) {
if (cmds[v.get('value')]) {
var fname = e.fontFamily,
f_options.item(0).set('selected', true);
f_options.each(function(v) {
var val = v.get('value').toLowerCase();
if (val === fname.toLowerCase()) {
s_options.item(0).set('selected', true);
size = size.replace('px', '');
s_options.each(function(v) {
var val = v.get('value').toLowerCase(),
Y.mix(Y.Plugin.ExecCommand.COMMANDS, {
alert('You clicked on Foo');
replacecontent: function() {
var inst = this.getInstance(),
sel = new inst.Selection();
var html = this.get('host').get('content');
html = '<
div><
p>Added From Selection Cache Test.</
p>' + html + '</
div>';
this.get('host').set('content', html);
var cur = sel.focusCursor();
editor = new Y.EditorBase({
content: Y.one('#stub').get('innerHTML'),
extracss: 'body { color: red; } p { border: 1px solid green; padding: .25em; margin: 1em; } #yui-cursor { border: 1px solid purple; }'
editor.after('nodeChange', function(e) {
//console.log('changedType: ' + e.changedType);
//if (e.changedType !== 'execcommand') {
if (e.changedType === 'keyup') {
var txt = e.changedNode.get('text');
Y.each(smilies, function(v, k) {
//Hackey, doesn't work on new line.
if (txt.indexOf(' ' + v) !== -1) {
e.selection.replace(v, '<
span> <
img src=
"smilies/' + k + '.gif"> </
span>');
//editor.plug(Y.Plugin.EditorLists);
//editor.plug(Y.Plugin.EditorBidi);
//Disabled for IE testing..
//editor.plug(Y.Plugin.EditorTab);
editor.after('dom:paste', function(e) {
console.log('DOM Paste');
var inst = editor.getInstance();
Y.later(100, null, function() {
var div = inst.one('p > div');
div.setAttribute('style', '');
e.frameEvent.preventDefault();
if (e.clipboardData.data) {
console.log(e.clipboardData.data);
editor.execCommand('paste');
//editor.execCommand('insertandfocus', e.clipboardData.data);
editor.on('dom:keydown', function(e) {
console.log('Control Pressed');
editor.execCommand('insertbr');
//console.log('Not Pressed');
editor.on('frame:ready', function() {
Y.log('frame:ready, set content', 'info', 'editor');
//This stops image resizes, but for all images!!
//editor.execCommand('enableObjectResizing', false);
//this.set('content', Y.one('#stub').get('innerHTML'));
editor.frame.on('keydown', function(e) {
if (e.charCode == 83 && (e.ctrlKey || e.metaKey)) {
//editor.on('dom:focus', function() {console.log("Focus called");});
//editor.on('dom:blur', function() {console.log("Blur called");});
editor.on('nodeChange', function(e) {
var inst = this.getInstance(),
sel = inst.config.doc.selection.createRange();
editor._lastBookmark = sel.getBookmark();
//console.log(e.changedType + ' :: ' + editor._lastBookmark);
editor.frame.on('dom:focus', function() {
var inst = this.getInstance(), sel, cur;
console.log("Focus called");
if (editor._lastBookmark) {
sel = new inst.Selection();
sel.focusCursor(true, false);
editor.frame.on('dom:activate', function(e) {
var inst = this.getInstance(), sel, cur;
console.log('activate called');
sel = inst.config.doc.selection.createRange();
console.log('focus: ' + editor._lastBookmark);
var bk = sel.moveToBookmark(editor._lastBookmark);
console.log('Move: ' + bk);
editor._lastBookmark = null;
editor.frame.on('dom:focusout', function(e) {
console.log('focusout called');
editor.frame.on('dom:blur', function(e) {
console.log("Blur called");
var inst = this.getInstance(),
sel = new inst.Selection();
editor.on('dom:keyup', function(e) {
var inst = this.getInstance(),
sel = new inst.Selection();
var txt = sel.anchorNode.get('text');
Y.each(smilies, function(v, k) {
//Hackey, doesn't work on new line.
if (txt.indexOf(' ' + v) !== -1) {
sel.replace(v, '<
span> <
img src=
"smilies/' + k + '.gif"> </
span>', sel.anchorTextNode);
Y.on('click', function(e) {
var html = editor.getContent();
Y.on('click', function(e) {
editor.set('content', '<
p>This is a test: ' + (new Date()) + '</
p>');
Y.on('click', function(e) {
Y.on('click', function(e) {
Y.one('#test1').setStyle('display', 'block');