1 if (YUI && yuiConfig) {
2 YUI(yuiConfig).use('node', 'event-mouseenter', 'yui-later', function(Y) {
3 var items = Y.all('.yui-syntax-highlight'),
4 openWindow = function(node, print) {
5 var n = Y.one('#' + node.get('id') + '-plain'),
6 code = n.get('value'), win = null,
7 h = n.get('offsetHeight');
9 code = code.replace(/</g, '<').replace(/>/g, '>');
10 win = window.open('', "codeview", "status=0,scrollbars=1,width=600,height=400,menubar=0,toolbar=0,directories=0");
11 win.document.body.innerHTML = '<pre>' + code + '</pre>';
14 Y.later(1000, win, function() {
21 handleClick = function(e) {
22 if (e.target.get('tagName').toLowerCase() == 'a') {
23 var type = e.target.get('innerHTML').replace(/ /g, '');
26 openWindow(e.target.get('parentNode.parentNode'), true);
29 openWindow(e.target.get('parentNode.parentNode'));
31 case 'togglelinenumbers':
32 e.target.get('parentNode.parentNode').toggleClass('yui-syntax-highlight-linenumbers');
43 items.each(function(i) {
44 //var header = Y.Node.create('<div class="syn-header hidden"><a href="#">view plain</a> | <a href="#">print</a> | <a href="#">copy</a></div>');
45 var header = Y.Node.create('<div class="syn-header hidden"><a href="#">view plain</a> | <a href="#">print</a> | <a href="#">toggle line numbers</a></div>');
46 header.on('click', handleClick);
47 i.insertBefore(header, i.get('firstChild'));
48 i.on('mouseenter', function() {
49 header.removeClass('hidden');
51 i.on('mouseleave', function() {
52 header.addClass('hidden');