test9.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <title>Test 009</title>
  6. <script>
  7. var Hyphenopoly = {
  8. require: {
  9. "en-us": "FORCEHYPHENOPOLY"
  10. },
  11. setup: {
  12. selectors: {
  13. ".class1": {
  14. hyphen: "·"
  15. },
  16. ".class2": {
  17. hyphen: "|",
  18. compound: "auto"
  19. }
  20. }
  21. },
  22. handleEvent: {
  23. beforeElementHyphenation: function (e) {
  24. if (e.el.className.indexOf("class1") !== -1) {
  25. e.el.style.opacity = "0";
  26. }
  27. },
  28. afterElementHyphenation: function (e) {
  29. if (e.el.className.indexOf("class1") !== -1) {
  30. window.setTimeout(function () {
  31. e.el.style.opacity = "1";
  32. e.el.style.transition = "opacity 1000ms ease";
  33. }, 0);
  34. }
  35. },
  36. hyphenopolyEnd: function (e) {
  37. assert();
  38. }
  39. }
  40. };
  41. </script>
  42. <script src="../Hyphenopoly_Loader.js"></script>
  43. <script>
  44. function assert() {
  45. var tests = 2;
  46. var i = 1;
  47. var test = "";
  48. var ref = "";
  49. var result = true;
  50. while (i <= tests) {
  51. test = document.getElementById("test" + i).innerHTML;
  52. ref = document.getElementById("ref" + i).innerHTML;
  53. if (test === ref) {
  54. document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
  55. result = result && true;
  56. } else {
  57. document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
  58. result = false;
  59. }
  60. i += 1;
  61. }
  62. if (parent != window) {
  63. parent.postMessage(JSON.stringify({
  64. desc: document.getElementById("desc").innerHTML,
  65. index: 9,
  66. result: (result ? "passed" : "failed")
  67. }), window.location.href);
  68. }
  69. }
  70. if (!Hyphenopoly) {
  71. document.addEventListener("DOMContentLoaded", function() {
  72. assert();
  73. });
  74. }
  75. </script>
  76. <style type="text/css">
  77. body {
  78. width:50%;
  79. margin-left:25%;
  80. margin-right:25%;
  81. }
  82. #result {
  83. height: 100px;
  84. }
  85. .test {
  86. background-color: #D8E2F9;
  87. }
  88. .ref {
  89. background-color: #FEEFC0;
  90. }
  91. .hyphenate {
  92. hyphens: auto;
  93. -ms-hyphens: auto;
  94. -moz-hyphens: auto;
  95. -webkit-hyphens: auto;
  96. }
  97. </style>
  98. </head>
  99. <body>
  100. <div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test8.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test10.html">Next&nbsp;&rarr;</a></div>
  101. <h1>Test 009</h1>
  102. <p id="desc">Ease</p>
  103. <div id="result"></div>
  104. <hr>
  105. <h2>1: class1</h2>
  106. <p id="test1" class="test class1" lang="en-us">hyphenation algorithm</p>
  107. <p id="ref1" class="ref" lang="en-us">hy·phen·ation al·go·rithm</p>
  108. <h2>2: class2</h2>
  109. <p id="test2" class="test class2" lang="en-us">hyphenation algorithm</p>
  110. <p id="ref2" class="ref" lang="en-us">hy|phen|ation al|go|rithm</p>
  111. <hr>
  112. <div><span class="test">Test</span> <span class="ref">Ref</span></div>
  113. </body>
  114. </html>