editor-instance-source-js.mustache revision 3f2ac16886fbbccf85547608b11143a8795d8db4
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctonyYUI().use('editor', function(Y) {
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony var log = function(str) {
738ad457843927ece7fa5e91e4fb4a5710d13690lgentis Y.one('#out').set('innerHTML', str);
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony };
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony //Create the Base Editor
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony var editor = new Y.EditorBase({
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony content: '<p><b>This is <i class="foo">a test</i></b></p><p><b style="color: red; font-family: Comic Sans MS">This is <span class="foo">a test</span></b></p>',
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony extracss: '.foo { font-weight: normal; color: black; background-color: yellow; }'
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony });
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony //Rendering the Editor
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony editor.render('#editor');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony Y.on('click', function(e) {
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony var inst = editor.getInstance(),
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony bs = inst.all('b');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony log('There are (' + bs.size() + ') B tags in the iframe.');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony }, '#btags');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony Y.on('click', function(e) {
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony var inst = editor.getInstance(),
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony bs = inst.all('i');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony log('There are (' + bs.size() + ') I tags in the iframe.');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony }, '#itags');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony Y.on('click', function(e) {
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony var inst = editor.getInstance(),
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony bs = inst.all('.foo');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony log('There are (' + bs.size() + ') items with class foo in the iframe.');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony }, '#ctags');
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony});
0f6bc9e2c8229996a73fb57ec6c45841346ebcb1pctony