app/styleguide/js/libs/highlighter/shCore.js
/**
 * Quick code mouse double click handler.
 */
Quick code mouse double click handler.
Quick code mouse double click handler .
function quickCodeHandler(e)
{
  var target = e.target,
    highlighterDiv = findParentElement(target, '.syntaxhighlighter'),
    container = findParentElement(target, '.container'),
    textarea = document.createElement('textarea'),
    highlighter
    ;
  if (!container || !highlighterDiv || findElement(container, 'textarea'))
    return;
  highlighter = getHighlighterById(highlighterDiv.id);
  addClass(highlighterDiv, 'source');
  var lines = container.childNodes,
    code = []
    ;
  for (var i = 0; i < lines.length; i++)
    code.push(lines[i].innerText || lines[i].textContent);
  code = code.join('\r');
    code = code.replace(/\u00a0/g, " ");
  textarea.appendChild(document.createTextNode(code));
  container.appendChild(textarea);
  textarea.focus();
  textarea.select();
  attachEvent(textarea, 'blur', function(e)
  {
    textarea.parentNode.removeChild(textarea);
    removeClass(highlighterDiv, 'source');
  });
}
function quickCodeHandler ( e ) { var target = e . target , highlighterDiv = findParentElement ( target , '.syntaxhighlighter' ) , container = findParentElement ( target , '.container' ) , textarea = document . createElement ( 'textarea' ) , highlighter ; if ( ! container || ! highlighterDiv || findElement ( container , 'textarea' ) ) return ; highlighter = getHighlighterById ( highlighterDiv . id ) ; addClass ( highlighterDiv , 'source' ) ; var lines = container . childNodes , code = [ ] ; for ( var i = 0 ; i < lines . length ; i ++ ) code . push ( lines [ i ] . innerText || lines [ i ] . textContent ) ; code = code . join ( '\r' ) ; code = code . replace ( / \u00a0 / g , " " ) ; textarea . appendChild ( document . createTextNode ( code ) ) ; container . appendChild ( textarea ) ; textarea . focus ( ) ; textarea . select ( ) ; attachEvent ( textarea , 'blur' , function ( e ) { textarea . parentNode . removeChild ( textarea ) ; removeClass ( highlighterDiv , 'source' ) ; } ) ; }
Quick code mouse double click handler.
Quick code mouse double click handler .
// add source class name // Have to go over each line and grab it's text, can't just do it on the // container because Firefox loses all \n where as Webkit doesn't. // using \r instead of \r or \r\n makes this work equally well on IE, FF and Webkit // For Webkit browsers, replace nbsp with a breaking space // inject <textarea/> tag // preselect all text // set up handler for lost focus