/pigeoncms/Plugins/syntaxhighlighter/tests/cases/011_smart_tabs.html

http://pigeoncms.googlecode.com/ · HTML · 98 lines · 80 code · 18 blank · 0 comment · 0 complexity · 3d2a9cdf01efb438fc51db11f0f71e69 MD5 · raw file

  1. <pre id="sh_011_smart_tabs_a" class="brush: plain;">
  2. the words in this paragraph
  3. should look like they are
  4. evenly spaced between columns
  5. </pre>
  6. <pre id="sh_011_smart_tabs_b" class="brush: plain; tab-size: 8;">
  7. the words in this paragraph
  8. should look like they are
  9. evenly spaced between columns
  10. </pre>
  11. <pre id="sh_011_smart_tabs_c" class="brush: plain; smart-tabs: false">
  12. the words in this paragraph
  13. should look out of whack
  14. because smart tabs are disabled
  15. </pre>
  16. <script type="text/javascript">
  17. queue(function()
  18. {
  19. var $sh;
  20. module('011_smart_tabs');
  21. var evenLines = [
  22. 'the words in this paragraph',
  23. 'should look like they are',
  24. 'evenly spaced between columns'
  25. ],
  26. unevenLines = [
  27. 'the words in this paragraph',
  28. 'should look out of whack',
  29. 'because smart tabs are disabled'
  30. ]
  31. ;
  32. function fixSpaces(s)
  33. {
  34. s = encodeURIComponent(s).replace(/%C2%A0/g, '%20');
  35. return unescape(s).replace(/\s+$/g, '');
  36. };
  37. test('default tab size is 4', function()
  38. {
  39. $sh = $('#sh_011_smart_tabs_a');
  40. ok_sh($sh);
  41. ok_toolbar($sh);
  42. ok_code($sh);
  43. $sh.find('.code .line').each(function(index)
  44. {
  45. var s1 = fixSpaces($(this).text()),
  46. s2 = fixSpaces(evenLines[index])
  47. ;
  48. equal(s1, s2, 'Line ' + index);
  49. });
  50. });
  51. test('tab size changed to 8', function()
  52. {
  53. $sh = $('#sh_011_smart_tabs_b');
  54. ok_sh($sh);
  55. ok_toolbar($sh);
  56. ok_code($sh);
  57. $sh.find('.code .line').each(function(index)
  58. {
  59. var s1 = fixSpaces($(this).text()),
  60. s2 = fixSpaces(evenLines[index])
  61. ;
  62. equal(s1, s2, 'Line ' + index);
  63. });
  64. });
  65. test('smart tabs are off', function()
  66. {
  67. $sh = $('#sh_011_smart_tabs_c');
  68. ok_sh($sh);
  69. ok_toolbar($sh);
  70. ok_code($sh);
  71. $sh.find('.code .line').each(function(index)
  72. {
  73. var s1 = fixSpaces($(this).text()),
  74. s2 = fixSpaces(unevenLines[index])
  75. ;
  76. equal(s1, s2, 'Line ' + index);
  77. });
  78. });
  79. });
  80. </script>