Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. ##Original HTML
  2.  
  3. <a>link one is really really long <img src="img.png" /></a>
  4. <a>link two</a>
  5. <a>link three</a>
  6. <a>link four</a>
  7.  
  8. ###Initialise
  9.  
  10. Parse the HTML into DOM elements.
  11.  
  12. __IF__ there is more than one root element, wrap them in a span element.
  13.  
  14. <span>
  15. <a>link one is really really long <img src="img.png" /></a>
  16. <a>link two</a>
  17. <a>link three</a>
  18. <a>link four</a>
  19. </span>
  20.  
  21. ###Phase 1
  22.  
  23. __IF__ there is more than one child DOM element __THEN__ Remove the last DOM element. __GOTO__ [Measure](#measure)
  24.  
  25. __ELSE IF__ the remaining child element itself has child elements __GOTO__ [Phase 1(child element)](#phase-1)
  26.  
  27. __ELSE GOTO__ [Phase 2](#phase-2)
  28.  
  29. <span>
  30. <a>link one is really really long <img src="img.png" /></a>
  31. <a>link two</a>
  32. <a>link three</a>
  33. </span>
  34.  
  35. ###Phase 2
  36.  
  37. Get the text content of the remaining DOM element and truncate at the last space.
  38.  
  39. <span>
  40. <a>link one is really really</a>
  41. </span>
  42.  
  43. __GOTO__ [Measure](#measure)
  44.  
  45. ###Measure
  46.  
  47. __IF__ the HTML height is overflowing the containing element __GOTO__ Current Phase
  48.  
  49. __ELSE RETURN__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement