Advertisement
iPokemon24

Style Tags for Proboards v5

Apr 21st, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. var force_br = /\[break\]/gi;
  4. var check = /\[attr="?(class|id|rel|style)"?,"?(.+?)"?\]/i;
  5. var css = /\[newclass="?(.+?)"?\](.+?)\[\/newclass\]/i;
  6. $(".style-tag-me").each(function(a,b){
  7. var html = $(b).html();
  8. if(css.test(html)){
  9. var result = css.exec(html);
  10. while(result != null){
  11. var classn = RegExp.$1;
  12. classn = classn.replace(/&gt;/g,">");
  13. html = html.replace(css,"<style type='text/css'> "+classn+" { $2 } </style>");
  14. result = css.exec(html);
  15. }
  16. }
  17. if(/\[nospaces\]/i.test(html)){ html = html.replace(/\[nospaces\]/i,""); $(b).addClass("hide-br"); }
  18. if(force_br.test(html)){ html = html.replace(force_br,"<br class='good' />"); }
  19. if(html != $(b).html()) $(b).html(html);
  20. });
  21. function recursiveCheck(ele){
  22. ele = $(ele);
  23. if(ele.find("div").length){
  24. ele.find("div").each(function(index,elem){ recursiveCheck(elem); });
  25. }
  26. actualFunction(ele);
  27. }
  28. function actualFunction(ele){
  29. ele = $(ele);
  30. if(check.test(ele.html())){
  31. var result = check.exec(ele.html());
  32. while(result != null){
  33. var attr = RegExp.$1;
  34. var value = RegExp.$2;
  35. ele.attr(attr,value);
  36. ele.html(ele.html().replace(check,""));
  37. result = check.exec(ele.html());
  38. }
  39. }
  40. }
  41.  
  42. $(".style-tag-me div").each(function(a,b){
  43. recursiveCheck($(b));
  44. });
  45. $(".hide-br br:not(.good)").remove();
  46. $('.ui-autosearch').on('autosearchaftersearch.style_tag', function () {
  47. $(".style-tag-me div").each(function(a,b){
  48. recursiveCheck($(b));
  49. });
  50. $(".hide-br br:not(.good)").remove();
  51. //if(!$.pushStateSupport()&& $('.ui-autosearch').data('autosearch').lastHash != "initial load" ){ //older browsers and IE
  52. if(!$('.ui-autosearch').data('autosearch').popped){
  53. $('.ui-autosearch').data('autosearch')._trigger('afterSearch.style_tag');
  54. }
  55. }
  56. });
  57. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement