[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 var SVGNS='http://www.w3.org/2000/svg',XLINKNS='http://www.w3.org/1999/xlink'; 2 3 function textrotate_make_svg(el) 4 { 5 var string=el.firstChild.nodeValue; 6 7 // Add absolute-positioned string (to measure length) 8 var abs=document.createElement('div'); 9 abs.appendChild(document.createTextNode(string)); 10 abs.style.position='absolute'; 11 document.body.appendChild(abs); 12 var textWidth=abs.offsetWidth * 1.2,textHeight=abs.offsetHeight; 13 document.body.removeChild(abs); 14 15 // Create SVG 16 var svg=document.createElementNS(SVGNS,'svg'); 17 svg.setAttribute('version','1.1'); 18 svg.setAttribute('width',20); 19 svg.setAttribute('height',textWidth); 20 21 // Add text 22 var text=document.createElementNS(SVGNS,'text'); 23 svg.appendChild(text); 24 text.setAttribute('x',textWidth); 25 text.setAttribute('y',-textHeight/4); 26 text.setAttribute('text-anchor','end'); 27 text.setAttribute('transform','rotate(90)'); 28 29 text.appendChild(document.createTextNode(string)); 30 31 // Is there an icon near the text? 32 var icon=el.parentNode.firstChild; 33 if(icon.nodeName.toLowerCase()=='img') { 34 el.parentNode.removeChild(icon); 35 var image=document.createElementNS(SVGNS,'image'); 36 var iconx=el.offsetHeight/4; 37 if(iconx>width-16) iconx=width-16; 38 image.setAttribute('x',iconx); 39 image.setAttribute('y',textWidth+4); 40 image.setAttribute('width',16); 41 image.setAttribute('height',16); 42 image.setAttributeNS(XLINKNS,'href',icon.src); 43 svg.appendChild(image); 44 } 45 46 // Replace original content with this new SVG 47 el.parentNode.insertBefore(svg,el); 48 el.parentNode.removeChild(el); 49 } 50 51 function browser_supports_svg() { 52 return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"); 53 } 54 55 function textrotate_init() { 56 if (!browser_supports_svg()) { 57 // Feature detect, else bail. 58 return; 59 } 60 61 YUI().use('yui2-dom', function(Y) { 62 var elements= Y.YUI2.util.Dom.getElementsByClassName('completion-criterianame', 'span'); 63 for(var i=0;i<elements.length;i++) 64 { 65 var el=elements[i]; 66 el.parentNode.style.verticalAlign='bottom'; 67 el.parentNode.style.width='20px'; 68 69 textrotate_make_svg(el); 70 } 71 }); 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |