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.
 
 
 
 

36 line
816 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. function cleanSource(html) {
  11. var lines = html.split(/\n/);
  12. lines.shift();
  13. lines.splice(-1, 1);
  14. var indentSize = lines[0].length - lines[0].trim().length,
  15. re = new RegExp(" {" + indentSize + "}");
  16. lines = lines.map(function(line){
  17. if (line.match(re)) {
  18. line = line.substring(indentSize);
  19. }
  20. return line;
  21. });
  22. lines = lines.join("\n");
  23. return lines;
  24. }
  25. })();