diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui3.0.0/assets/syntax.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui3.0.0/assets/syntax.js Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,56 @@ +if (YUI && yuiConfig) { + YUI(yuiConfig).use('node', 'event-mouseenter', 'later', function(Y) { + var items = Y.all('.yui-syntax-highlight'), + openWindow = function(node, print) { + var n = Y.one('#' + node.get('id') + '-plain'), + code = n.get('value'), win = null, + h = n.get('offsetHeight'); + + code = code.replace(//g, '>'); + win = window.open('', "codeview", "status=0,scrollbars=1,width=600,height=400,menubar=0,toolbar=0,directories=0"); + win.document.body.innerHTML = '
' + code + '
'; + + if (print) { + Y.later(1000, win, function() { + win.focus(); + win.print(); + win.focus(); + }); + } + }, + handleClick = function(e) { + if (e.target.get('tagName').toLowerCase() == 'a') { + var type = e.target.get('innerHTML').replace(/ /g, ''); + switch (type) { + case 'print': + openWindow(e.target.get('parentNode.parentNode'), true); + break; + case 'viewplain': + openWindow(e.target.get('parentNode.parentNode')); + break; + case 'togglelinenumbers': + e.target.get('parentNode.parentNode').toggleClass('yui-syntax-highlight-linenumbers'); + break; + case 'copy': + break; + } + } + e.halt(); + }; + + + + items.each(function(i) { + //var header = Y.Node.create(''); + var header = Y.Node.create(''); + header.on('click', handleClick); + i.insertBefore(header, i.get('firstChild')); + i.on('mouseenter', function() { + header.removeClass('hidden'); + }); + i.on('mouseleave', function() { + header.addClass('hidden'); + }); + }); + }); +}