You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 regels
948 B

  1. (function(){
  2. var $button = $("<div id='source-button' class='btn btn-primary btn-xs'>&lt; &gt;</div>").click(function(){
  3. var html = $(this).parent().html();
  4. html = cleanSource(html);
  5. $("#source-modal pre").text(html);
  6. $("#source-modal").modal();
  7. });
  8. $('.bs-component [data-toggle="popover"]').popover();
  9. $('.bs-component [data-toggle="tooltip"]').tooltip();
  10. $(".bs-component").hover(function(){
  11. $(this).append($button);
  12. $button.show();
  13. }, function(){
  14. $button.hide();
  15. });
  16. function cleanSource(html) {
  17. var lines = html.split(/\n/);
  18. lines.shift();
  19. lines.splice(-1, 1);
  20. var indentSize = lines[0].length - lines[0].trim().length,
  21. re = new RegExp(" {" + indentSize + "}");
  22. lines = lines.map(function(line){
  23. if (line.match(re)) {
  24. line = line.substring(indentSize);
  25. }
  26. return line;
  27. });
  28. lines = lines.join("\n");
  29. return lines;
  30. }
  31. })();