Advertisement
Guest User

Untitled

a guest
Sep 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. This is a text to be displayed...More
  2.  
  3. <em>This is</em> a text to be d...More
  4.  
  5. *This is* a text to be d...More
  6.  
  7. p.each(function(mel){
  8. var t = mel.get('html'); //get all the content of p
  9. var str = t; //duplicate the string
  10.  
  11. var div = new Element('div', {html:str}); //this function strips tags though don't know if it's useful here
  12. var text = div.textContent || div.innerText || "";
  13. text;
  14.  
  15. if (text.length<100) return;
  16. var tOne = t.substr(0,100); //breaking text on visible and non-visible
  17. var tTwo = t.substr(101,t.length); //all the further code works creating "More" after 100 characters
  18. var dots = new Element('span', {
  19. 'class':'unedit',
  20. 'text':'...'
  21. });
  22. var more = new Element('a', {
  23. href: '#',
  24. 'class':'more unedit',
  25. 'text':'More'
  26. });
  27. var unseen = new Element('span', {
  28. 'class':'appended',
  29. 'html':tTwo,
  30. styles: {
  31. 'display':'none',
  32. }
  33. })
  34. var less = new Element('a', {
  35. href: '#',
  36. 'class':'less unedit',
  37. 'text':'Less'
  38. })
  39. unseen.grab(new Element('br'));
  40. unseen.grab(less);
  41. mel.set('html', tOne);
  42. mel.grab(dots);
  43. mel.grab(more);
  44. mel.grab(unseen);
  45. });
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement