assets/js/hyphenator.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 |
/** @license Hyphenator 4.3.0 - client side hyphenation for webbrowsers * Copyright (C) 2014 Mathias Nater, Zürich (mathiasnater at gmail dot com) * Project and Source hosted on http://code.google.com/p/hyphenator/ * * This JavaScript code is free software: you can redistribute * it and/or modify it under the terms of the GNU Lesser * General Public License (GNU LGPL) as published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. The code is distributed WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. * * As additional permission under GNU GPL version 3 section 7, you * may distribute non-source (e.g., minimized or compacted) forms of * that code without the copy of the GNU GPL normally required by * section 4, provided you include this license notice and a URL * through which recipients can access the Corresponding Source. * * * Hyphenator.js contains code from Bram Steins hypher.js-Project: * https://github.com/bramstein/Hypher * * Code from this project is marked in the source and belongs * to the following license: * * Copyright (c) 2011, Bram Stein * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Comments are jsdoc3 formatted. See http://usejsdoc.org * Use mergeAndPack.html to get rid of the comments and to reduce the file size of this script! */ /* The following comment is for JSLint: */ /*jslint browser: true */ /** * @desc Provides all functionality to do hyphenation, except the patterns that are loaded externally * @global * @namespace Hyphenator * @author Mathias Nater, <mathias@mnn.ch> * @version X.Y.Z * @example * <script src = "Hyphenator.js" type = "text/javascript"></script> * <script type = "text/javascript"> * Hyphenator.run(); * </script> */ var Hyphenator = (function (window) { 'use strict'; /** * @member Hyphenator~contextWindow * @access private * @desc * contextWindow stores the window for the actual document to be hyphenated. * If there are frames this will change. * So use contextWindow instead of window! */ var contextWindow = window, /** * @member {Object.<string, Hyphenator~supportedLangs~supportedLanguage>} Hyphenator~supportedLangs * @desc * A generated key-value object that stores supported languages and meta data. * The key is the {@link http://tools.ietf.org/rfc/bcp/bcp47.txt bcp47} code of the language and the value * is an object of type {@link Hyphenator~supportedLangs~supportedLanguage} * @namespace Hyphenator~supportedLangs * @access private * //Check if language lang is supported: * if (supportedLangs.hasOwnProperty(lang)) */ supportedLangs = (function () { /** * @typedef {Object} Hyphenator~supportedLangs~supportedLanguage * @property {string} file - The name of the pattern file * @property {number} script - The script type of the language (e.g. 'latin' for english), this type is abbreviated by an id * @property {string} prompt - The sentence prompted to the user, if Hyphenator.js doesn't find a language hint */ /** * @lends Hyphenator~supportedLangs */ var r = {}, /** * @method Hyphenator~supportedLangs~o * @desc * Sets a value of Hyphenator~supportedLangs * @access protected * @param {string} code The {@link http://tools.ietf.org/rfc/bcp/bcp47.txt bcp47} code of the language * @param {string} file The name of the pattern file * @param {Number} script A shortcut for a specific script: latin:0, cyrillic: 1, arabic: 2, armenian:3, bengali: 4, devangari: 5, greek: 6 * gujarati: 7, kannada: 8, lao: 9, malayalam: 10, oriya: 11, persian: 12, punjabi: 13, tamil: 14, telugu: 15 * @param {string} prompt The sentence prompted to the user, if Hyphenator.js doesn't find a language hint */ o = function (code, file, script, prompt) { r[code] = {'file': file, 'script': script, 'prompt': prompt}; }; o('be', 'be.js', 1, 'Мова гэтага сайта не можа быць вызначаны аўтаматычна. Калі ласка пакажыце мову:'); o('ca', 'ca.js', 0, ''); o('cs', 'cs.js', 0, 'Jazyk této internetové stránky nebyl automaticky rozpoznán. Určete prosím její jazyk:'); o('da', 'da.js', 0, 'Denne websides sprog kunne ikke bestemmes. Angiv venligst sprog:'); o('bn', 'bn.js', 4, ''); o('de', 'de.js', 0, 'Die Sprache dieser Webseite konnte nicht automatisch bestimmt werden. Bitte Sprache angeben:'); o('el', 'el-monoton.js', 6, ''); o('el-monoton', 'el-monoton.js', 6, ''); o('el-polyton', 'el-polyton.js', 6, ''); o('en', 'en-us.js', 0, 'The language of this website could not be determined automatically. Please indicate the main language:'); o('en-gb', 'en-gb.js', 0, 'The language of this website could not be determined automatically. Please indicate the main language:'); o('en-us', 'en-us.js', 0, 'The language of this website could not be determined automatically. Please indicate the main language:'); o('eo', 'eo.js', 0, 'La lingvo de ĉi tiu retpaĝo ne rekoneblas aŭtomate. Bonvolu indiki ĝian ĉeflingvon:'); o('es', 'es.js', 0, 'El idioma del sitio no pudo determinarse autom%E1ticamente. Por favor, indique el idioma principal:'); o('et', 'et.js', 0, 'Veebilehe keele tuvastamine ebaõnnestus, palun valige kasutatud keel:'); o('fi', 'fi.js', 0, 'Sivun kielt%E4 ei tunnistettu automaattisesti. M%E4%E4rit%E4 sivun p%E4%E4kieli:'); o('fr', 'fr.js', 0, 'La langue de ce site n%u2019a pas pu %EAtre d%E9termin%E9e automatiquement. Veuillez indiquer une langue, s.v.p.%A0:'); o('grc', 'grc.js', 6, ''); o('gu', 'gu.js', 7, ''); o('hi', 'hi.js', 5, ''); o('hu', 'hu.js', 0, 'A weboldal nyelvét nem sikerült automatikusan megállapítani. Kérem adja meg a nyelvet:'); o('hy', 'hy.js', 3, 'Չհաջողվեց հայտնաբերել այս կայքի լեզուն։ Խնդրում ենք նշեք հիմնական լեզուն՝'); o('it', 'it.js', 0, 'Lingua del sito sconosciuta. Indicare una lingua, per favore:'); o('kn', 'kn.js', 8, 'ಜಾಲ ತಾಣದ ಭಾಷೆಯನ್ನು ನಿರ್ಧರಿಸಲು ಸಾಧ್ಯವಾಗುತ್ತಿಲ್ಲ. ದಯವಿಟ್ಟು ಮುಖ್ಯ ಭಾಷೆಯನ್ನು ಸೂಚಿಸಿ:'); o('la', 'la.js', 0, ''); o('lt', 'lt.js', 0, 'Nepavyko automatiškai nustatyti šios svetainės kalbos. Prašome įvesti kalbą:'); o('lv', 'lv.js', 0, 'Šīs lapas valodu nevarēja noteikt automātiski. Lūdzu norādiet pamata valodu:'); o('ml', 'ml.js', 10, 'ഈ വെ%u0D2C%u0D4D%u200Cസൈറ്റിന്റെ ഭാഷ കണ്ടുപിടിയ്ക്കാ%u0D28%u0D4D%u200D കഴിഞ്ഞില്ല. ഭാഷ ഏതാണെന്നു തിരഞ്ഞെടുക്കുക:'); o('nb', 'nb-no.js', 0, 'Nettstedets språk kunne ikke finnes automatisk. Vennligst oppgi språk:'); o('no', 'nb-no.js', 0, 'Nettstedets språk kunne ikke finnes automatisk. Vennligst oppgi språk:'); o('nb-no', 'nb-no.js', 0, 'Nettstedets språk kunne ikke finnes automatisk. Vennligst oppgi språk:'); o('nl', 'nl.js', 0, 'De taal van deze website kan niet automatisch worden bepaald. Geef de hoofdtaal op:'); o('or', 'or.js', 11, ''); o('pa', 'pa.js', 13, ''); o('pl', 'pl.js', 0, 'Języka tej strony nie można ustalić automatycznie. Proszę wskazać język:'); o('pt', 'pt.js', 0, 'A língua deste site não pôde ser determinada automaticamente. Por favor indique a língua principal:'); o('ru', 'ru.js', 1, 'Язык этого сайта не может быть определен автоматически. Пожалуйста укажите язык:'); o('sk', 'sk.js', 0, ''); o('sl', 'sl.js', 0, 'Jezika te spletne strani ni bilo mogoče samodejno določiti. Prosim navedite jezik:'); o('sr-cyrl', 'sr-cyrl.js', 1, 'Језик овог сајта није детектован аутоматски. Молим вас наведите језик:'); o('sr-latn', 'sr-latn.js', 0, 'Jezika te spletne strani ni bilo mogoče samodejno določiti. Prosim navedite jezik:'); o('sv', 'sv.js', 0, 'Spr%E5ket p%E5 den h%E4r webbplatsen kunde inte avg%F6ras automatiskt. V%E4nligen ange:'); o('ta', 'ta.js', 14, ''); o('te', 'te.js', 15, ''); o('tr', 'tr.js', 0, 'Bu web sitesinin dili otomatik olarak tespit edilememiştir. Lütfen dökümanın dilini seçiniz%A0:'); o('uk', 'uk.js', 1, 'Мова цього веб-сайту не може бути визначена автоматично. Будь ласка, вкажіть головну мову:'); o('ro', 'ro.js', 0, 'Limba acestui sit nu a putut fi determinată automat. Alege limba principală:'); return r; }()), /** * @member {string} Hyphenator~basePath * @desc * A string storing the basepath from where Hyphenator.js was loaded. * This is used to load the pattern files. * The basepath is determined dynamically by searching all script-tags for Hyphenator.js * If the path cannot be determined {@link http://hyphenator.googlecode.com/svn/trunk/} is used as fallback. * @access private * @see {@link Hyphenator~loadPatterns} */ basePath = (function () { var s = contextWindow.document.getElementsByTagName('script'), i = 0, p, src, t = s[i], r = ''; while (!!t) { if (!!t.src) { src = t.src; p = src.indexOf('Hyphenator.js'); if (p !== -1) { r = src.substring(0, p); } } i += 1; t = s[i]; } return !!r ? r : '//hyphenator.googlecode.com/svn/trunk/'; }()), /** * @member {boolean} Hyphenator~isLocal * @access private * @desc * isLocal is true, if Hyphenator is loaded from the same domain, as the webpage, but false, if * it's loaded from an external source (i.e. directly from google.code) */ isLocal = (function () { var re = false; if (window.location.href.indexOf(basePath) !== -1) { re = true; } return re; }()), /** * @member {boolean} Hyphenator~documentLoaded * @access private * @desc * documentLoaded is true, when the DOM has been loaded. This is set by {@link Hyphenator~runWhenLoaded} */ documentLoaded = false, /** * @member {boolean} Hyphenator~persistentConfig * @access private * @desc * if persistentConfig is set to true (defaults to false), config options and the state of the * toggleBox are stored in DOM-storage (according to the storage-setting). So they haven't to be * set for each page. * @default false * @see {@link Hyphenator.config} */ persistentConfig = false, /** * @member {boolean} Hyphenator~doFrames * @access private * @desc * switch to control if frames/iframes should be hyphenated, too. * defaults to false (frames are a bag of hurt!) * @default false * @see {@link Hyphenator.config} */ doFrames = false, /** * @member {Object.<string,boolean>} Hyphenator~dontHyphenate * @desc * A key-value object containing all html-tags whose content should not be hyphenated * @access private */ dontHyphenate = {'video': true, 'audio': true, 'script': true, 'code': true, 'pre': true, 'img': true, 'br': true, 'samp': true, 'kbd': true, 'var': true, 'abbr': true, 'acronym': true, 'sub': true, 'sup': true, 'button': true, 'option': true, 'label': true, 'textarea': true, 'input': true, 'math': true, 'svg': true, 'style': true}, /** * @member {boolean} Hyphenator~enableCache * @desc * A variable to set if caching is enabled or not * @default true * @access private * @see {@link Hyphenator.config} */ enableCache = true, /** * @member {string} Hyphenator~storageType * @desc * A variable to define what html5-DOM-Storage-Method is used ('none', 'local' or 'session') * @default 'local' * @access private * @see {@link Hyphenator.config} */ storageType = 'local', /** * @member {Object|undefined} Hyphenator~storage * @desc * An alias to the storage defined in storageType. This is set by {@link Hyphenator~createStorage}. * Set by {@link Hyphenator.run} * @default null * @access private * @see {@link Hyphenator~createStorage} */ storage, /** * @member {boolean} Hyphenator~enableReducedPatternSet * @desc * A variable to set if storing the used patterns is set * @default false * @access private * @see {@link Hyphenator.config} * @see {@link Hyphenator.getRedPatternSet} */ enableReducedPatternSet = false, /** * @member {boolean} Hyphenator~enableRemoteLoading * @desc * A variable to set if pattern files should be loaded remotely or not * @default true * @access private * @see {@link Hyphenator.config} */ enableRemoteLoading = true, /** * @member {boolean} Hyphenator~displayToggleBox * @desc * A variable to set if the togglebox should be displayed or not * @default false * @access private * @see {@link Hyphenator.config} */ displayToggleBox = false, /** * @method Hyphenator~onError * @desc * A function that can be called upon an error. * @see {@link Hyphenator.config} * @access private */ onError = function (e) { window.alert("Hyphenator.js says:\n\nAn Error occurred:\n" + e.message); }, /** * @method Hyphenator~onWarning * @desc * A function that can be called upon a warning. * @see {@link Hyphenator.config} * @access private */ onWarning = function (e) { window.console.log(e.message); }, /** * @method Hyphenator~createElem * @desc * A function alias to document.createElementNS or document.createElement * @access private */ createElem = function (tagname, context) { context = context || contextWindow; var el; if (window.document.createElementNS) { el = context.document.createElementNS('http://www.w3.org/1999/xhtml', tagname); } else if (window.document.createElement) { el = context.document.createElement(tagname); } return el; }, /** * @member {boolean} Hyphenator~css3 * @desc * A variable to set if css3 hyphenation should be used * @default false * @access private * @see {@link Hyphenator.config} */ css3 = false, /** * @typedef {Object} Hyphenator~css3_hsupport * @property {boolean} support - if css3-hyphenation is supported * @property {string} property - the css property name to access hyphen-settings (e.g. -webkit-hyphens) * @property {Object.<string, boolean>} supportedBrowserLangs - an object caching tested languages * @property {function} checkLangSupport - a method that checks if the browser supports a requested language */ /** * @member {Hyphenator~css3_h9n} Hyphenator~css3_h9n * @desc * A generated object containing information for CSS3-hyphenation support * This is set by {@link Hyphenator~css3_gethsupport} * @default undefined * @access private * @see {@link Hyphenator~css3_gethsupport} * @example * //Check if browser supports a language * css3_h9n.checkLangSupport(<lang>) */ css3_h9n, /** * @method Hyphenator~css3_gethsupport * @desc * This function sets {@link Hyphenator~css3_h9n} for the current UA * @type function * @access private * @see Hyphenator~css3_h9n */ css3_gethsupport = function () { var s, createLangSupportChecker = function (prefix) { var testStrings = [ //latin: 0 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', //cyrillic: 1 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя', //arabic: 2 'أبتثجحخدذرزسشصضطظعغفقكلمنهوي', //armenian: 3 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆ', //bengali: 4 'ঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ', //devangari: 5 'ँंःअआइईउऊऋऌएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलळवशषसहऽािीुूृॄेैोौ्॒॑ॠॡॢॣ', //greek: 6 'αβγδεζηθικλμνξοπρσςτυφχψω', //gujarati: 7 'બહઅઆઇઈઉઊઋૠએઐઓઔાિીુૂૃૄૢૣેૈોૌકખગઘઙચછજઝઞટઠડઢણતથદધનપફસભમયરલળવશષ', //kannada: 8 'ಂಃಅಆಇಈಉಊಋಌಎಏಐಒಓಔಕಖಗಘಙಚಛಜಝಞಟಠಡಢಣತಥದಧನಪಫಬಭಮಯರಱಲಳವಶಷಸಹಽಾಿೀುೂೃೄೆೇೈೊೋೌ್ೕೖೞೠೡ', //lao: 9 'ກຂຄງຈຊຍດຕຖທນບປຜຝພຟມຢຣລວສຫອຮະັາິີຶືຸູົຼເແໂໃໄ່້໊໋ໜໝ', //malayalam: 10 'ംഃഅആഇഈഉഊഋഌഎഏഐഒഓഔകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരറലളഴവശഷസഹാിീുൂൃെേൈൊോൌ്ൗൠൡൺൻർൽൾൿ', //oriya: 11 'ଁଂଃଅଆଇଈଉଊଋଌଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଳଵଶଷସହାିୀୁୂୃେୈୋୌ୍ୗୠୡ', //persian: 12 'أبتثجحخدذرزسشصضطظعغفقكلمنهوي', //punjabi: 13 'ਁਂਃਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਲ਼ਵਸ਼ਸਹਾਿੀੁੂੇੈੋੌ੍ੰੱ', //tamil: 14 'ஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழவஷஸஹாிீுூெேைொோௌ்ௗ', //telugu: 15 'ఁంఃఅఆఇఈఉఊఋఌఎఏఐఒఓఔకఖగఘఙచఛజఝఞటఠడఢణతథదధనపఫబభమయరఱలళవశషసహాిీుూృౄెేైొోౌ్ౕౖౠౡ' ], f = function (lang) { var shadow, computedHeight, bdy, r = false; //check if lang has already been tested if (this.supportedBrowserLangs.hasOwnProperty(lang)) { r = this.supportedBrowserLangs[lang]; } else if (supportedLangs.hasOwnProperty(lang)) { //create and append shadow-test-element bdy = window.document.getElementsByTagName('body')[0]; shadow = createElem('div', window); shadow.id = 'Hyphenator_LanguageChecker'; shadow.style.width = '5em'; shadow.style[prefix] = 'auto'; shadow.style.hyphens = 'auto'; shadow.style.fontSize = '12px'; shadow.style.lineHeight = '12px'; shadow.style.visibility = 'hidden'; shadow.lang = lang; shadow.style['-webkit-locale'] = "'" + lang + "'"; shadow.innerHTML = testStrings[supportedLangs[lang].script]; bdy.appendChild(shadow); //measure its height computedHeight = shadow.offsetHeight; //remove shadow element bdy.removeChild(shadow); r = (computedHeight > 12) ? true : false; this.supportedBrowserLangs[lang] = r; } else { r = false; } return r; }; return f; }, r = { support: false, supportedBrowserLangs: {}, property: '', checkLangSupport: {} }; if (window.getComputedStyle) { s = window.getComputedStyle(window.document.getElementsByTagName('body')[0], null); } else { //ancient Browsers don't support CSS3 anyway css3_h9n = r; return; } if (s.hyphens !== undefined) { r.support = true; r.property = 'hyphens'; r.checkLangSupport = createLangSupportChecker('hyphens'); } else if (s['-webkit-hyphens'] !== undefined) { r.support = true; r.property = '-webkit-hyphens'; r.checkLangSupport = createLangSupportChecker('-webkit-hyphens'); } else if (s.MozHyphens !== undefined) { r.support = true; r.property = '-moz-hyphens'; r.checkLangSupport = createLangSupportChecker('MozHyphens'); } else if (s['-ms-hyphens'] !== undefined) { r.support = true; r.property = '-ms-hyphens'; r.checkLangSupport = createLangSupportChecker('-ms-hyphens'); } css3_h9n = r; }, /** * @member {string} Hyphenator~hyphenateClass * @desc * A string containing the css-class-name for the hyphenate class * @default 'hyphenate' * @access private * @example * <p class = "hyphenate">Text</p> * @see {@link Hyphenator.config} */ hyphenateClass = 'hyphenate', /** * @member {string} Hyphenator~urlHyphenateClass * @desc * A string containing the css-class-name for the urlhyphenate class * @default 'urlhyphenate' * @access private * @example * <p class = "urlhyphenate">Text</p> * @see {@link Hyphenator.config} */ urlHyphenateClass = 'urlhyphenate', /** * @member {string} Hyphenator~classPrefix * @desc * A string containing a unique className prefix to be used * whenever Hyphenator sets a CSS-class * @access private */ classPrefix = 'Hyphenator' + Math.round(Math.random() * 1000), /** * @member {string} Hyphenator~hideClass * @desc * The name of the class that hides elements * @access private */ hideClass = classPrefix + 'hide', /** * @member {RegExp} Hyphenator~hideClassRegExp * @desc * RegExp to remove hideClass from a list of classes * @access private */ hideClassRegExp = new RegExp("\\s?\\b" + hideClass + "\\b", "g"), /** * @member {string} Hyphenator~hideClass * @desc * The name of the class that unhides elements * @access private */ unhideClass = classPrefix + 'unhide', /** * @member {RegExp} Hyphenator~hideClassRegExp * @desc * RegExp to remove unhideClass from a list of classes * @access private */ unhideClassRegExp = new RegExp("\\s?\\b" + unhideClass + "\\b", "g"), /** * @member {string} Hyphenator~css3hyphenateClass * @desc * The name of the class that hyphenates elements with css3 * @access private */ css3hyphenateClass = classPrefix + 'css3hyphenate', /** * @member {CSSEdit} Hyphenator~css3hyphenateClass * @desc * The var where CSSEdit class is stored * @access private */ css3hyphenateClassHandle, /** * @member {string} Hyphenator~dontHyphenateClass * @desc * A string containing the css-class-name for elements that should not be hyphenated * @default 'donthyphenate' * @access private * @example * <p class = "donthyphenate">Text</p> * @see {@link Hyphenator.config} */ dontHyphenateClass = 'donthyphenate', /** * @member {number} Hyphenator~min * @desc * A number wich indicates the minimal length of words to hyphenate. * @default 6 * @access private * @see {@link Hyphenator.config} */ min = 6, /** * @member {number} Hyphenator~orphanControl * @desc * Control how the last words of a line are handled: * level 1 (default): last word is hyphenated * level 2: last word is not hyphenated * level 3: last word is not hyphenated and last space is non breaking * @default 1 * @access private */ orphanControl = 1, /** * @member {boolean} Hyphenator~isBookmarklet * @desc * True if Hyphanetor runs as bookmarklet. * @access private */ isBookmarklet = (function () { var loc = null, re = false, scripts = contextWindow.document.getElementsByTagName('script'), i = 0, l = scripts.length; while (!re && i < l) { loc = scripts[i].getAttribute('src'); if (!!loc && loc.indexOf('Hyphenator.js?bm=true') !== -1) { re = true; } i += 1; } return re; }()), /** * @member {string|null} Hyphenator~mainLanguage * @desc * The general language of the document. In contrast to {@link Hyphenator~defaultLanguage}, * mainLanguage is defined by the client (i.e. by the html or by a prompt). * @access private * @see {@link Hyphenator~autoSetMainLanguage} */ mainLanguage = null, /** * @member {string|null} Hyphenator~defaultLanguage * @desc * The language defined by the developper. This language setting is defined by a config option. * It is overwritten by any html-lang-attribute and only taken in count, when no such attribute can * be found (i.e. just before the prompt). * @access private * @see {@link Hyphenator.config} * @see {@link Hyphenator~autoSetMainLanguage} */ defaultLanguage = '', /** * @member {ElementCollection} Hyphenator~elements * @desc * A class representing all elements (of type Element) that have to be hyphenated. This var is filled by * {@link Hyphenator~gatherDocumentInfos} * @access private */ elements = (function () { /** * @constructor Hyphenator~elements~ElementCollection~Element * @desc represents a DOM Element with additional information * @access private */ var Element = function (element) { /** * @member {Object} Hyphenator~elements~ElementCollection~Element~element * @desc A DOM Element * @access protected */ this.element = element; /** * @member {boolean} Hyphenator~elements~ElementCollection~Element~hyphenated * @desc Marks if the element has been hyphenated * @access protected */ this.hyphenated = false; /** * @member {boolean} Hyphenator~elements~ElementCollection~Element~treated * @desc Marks if information of the element has been collected but not hyphenated (e.g. dohyphenation is off) * @access protected */ this.treated = false; }, /** * @constructor Hyphenator~elements~ElementCollection * @desc A collection of Elements to be hyphenated * @access protected */ ElementCollection = function () { /** * @member {number} Hyphenator~elements~ElementCollection~count * @desc The Number of collected Elements * @access protected */ this.count = 0; /** * @member {number} Hyphenator~elements~ElementCollection~hyCount * @desc The Number of hyphenated Elements * @access protected */ this.hyCount = 0; /** * @member {Object.<string, Array.<Element>>} Hyphenator~elements~ElementCollection~list * @desc The collection of elements, where the key is a language code and the value is an array of elements * @access protected */ this.list = {}; }; /** * @member {Object} Hyphenator~elements~ElementCollection.prototype * @augments Hyphenator~elements~ElementCollection * @access protected */ ElementCollection.prototype = { /** * @method Hyphenator~elements~ElementCollection.prototype~add * @augments Hyphenator~elements~ElementCollection * @access protected * @desc adds a DOM element to the collection * @param {Object} el - The DOM element * @param {string} lang - The language of the element */ add: function (el, lang) { var elo = new Element(el); if (!this.list.hasOwnProperty(lang)) { this.list[lang] = []; } this.list[lang].push(elo); this.count += 1; return elo; }, /** * @method Hyphenator~elements~ElementCollection.prototype~remove * @augments Hyphenator~elements~ElementCollection * @access protected * @desc removes a DOM element from the collection * @param {Object} el - The DOM element */ remove: function (el) { var lang, i, e, l; for (lang in this.list) { if (this.list.hasOwnProperty(lang)) { for (i = 0; i < this.list[lang].length; i += 1) { if (this.list[lang][i].element === el) { e = i; l = lang; break; } } } } this.list[l].splice(e, 1); this.count -= 1; this.hyCount -= 1; }, /** * @callback Hyphenator~elements~ElementCollection.prototype~each~callback fn - The callback that is executed for each element * @param {string} [k] The key (i.e. language) of the collection * @param {Hyphenator~elements~ElementCollection~Element} element */ /** * @method Hyphenator~elements~ElementCollection.prototype~each * @augments Hyphenator~elements~ElementCollection * @access protected * @desc takes each element of the collection as an argument of fn * @param {Hyphenator~elements~ElementCollection.prototype~each~callback} fn - A function that takes an element as an argument */ each: function (fn) { var k; for (k in this.list) { if (this.list.hasOwnProperty(k)) { if (fn.length === 2) { fn(k, this.list[k]); } else { fn(this.list[k]); } } } } }; return new ElementCollection(); }()), /** * @member {Object.<sting, string>} Hyphenator~exceptions * @desc * An object containing exceptions as comma separated strings for each language. * When the language-objects are loaded, their exceptions are processed, copied here and then deleted. * Exceptions can also be set by the user. * @see {@link Hyphenator~prepareLanguagesObj} * @access private */ exceptions = {}, /** * @member {Object.<string, boolean>} Hyphenator~docLanguages * @desc * An object holding all languages used in the document. This is filled by * {@link Hyphenator~gatherDocumentInfos} * @access private */ docLanguages = {}, /** * @member {string} Hyphenator~url * @desc * A string containing a insane RegularExpression to match URL's * @access private */ url = '(\\w*:\/\/)?((\\w*:)?(\\w*)@)?((([\\d]{1,3}\\.){3}([\\d]{1,3}))|((www\\.|[a-zA-Z]\\.)?[a-zA-Z0-9\\-\\.]+\\.([a-z]{2,4})))(:\\d*)?(\/[\\w#!:\\.?\\+=&%@!\\-]*)*', // protocoll usr pwd ip or host tld port path /** * @member {string} Hyphenator~mail * @desc * A string containing a RegularExpression to match mail-adresses * @access private */ mail = '[\\w-\\.]+@[\\w\\.]+', /** * @member {RegExp} Hyphenator~urlRE * @desc * A RegularExpressions-Object for url- and mail adress matching * @access private */ urlOrMailRE = new RegExp('(' + url + ')|(' + mail + ')', 'i'), /** * @member {string} Hyphenator~zeroWidthSpace * @desc * A string that holds a char. * Depending on the browser, this is the zero with space or an empty string. * zeroWidthSpace is used to break URLs * @access private */ zeroWidthSpace = (function () { var zws, ua = window.navigator.userAgent.toLowerCase(); zws = String.fromCharCode(8203); //Unicode zero width space if (ua.indexOf('msie 6') !== -1) { zws = ''; //IE6 doesn't support zws } if (ua.indexOf('opera') !== -1 && ua.indexOf('version/10.00') !== -1) { zws = ''; //opera 10 on XP doesn't support zws } return zws; }()), /** * @method Hyphenator~onBeforeWordHyphenation * @desc * This method is called just before a word is hyphenated. * It is called with two parameters: the word and its language. * The method must return a string (aka the word). * @see {@link Hyphenator.config} * @access private * @param {string} word * @param {string} lang * @return {string} The word that goes into hyphenation */ onBeforeWordHyphenation = function (word) { return word; }, /** * @method Hyphenator~onAfterWordHyphenation * @desc * This method is called for each word after it is hyphenated. * Takes the word as a first parameter and its language as a second parameter. * Returns a string that will replace the word that has been hyphenated. * @see {@link Hyphenator.config} * @access private * @param {string} word * @param {string} lang * @return {string} The word that goes into hyphenation */ onAfterWordHyphenation = function (word) { return word; }, /** * @method Hyphenator~onHyphenationDone * @desc * A method to be called, when the last element has been hyphenated. * If there are frames the method is called for each frame. * Therefore the location.href of the contextWindow calling this method is given as a parameter * @see {@link Hyphenator.config} * @param {string} context * @access private */ onHyphenationDone = function (context) { return context; }, /** * @name Hyphenator~selectorFunction * @desc * A function set by the user that has to return a HTMLNodeList or array of Elements to be hyphenated. * By default this is set to false so we can check if a selectorFunction is set… * @see {@link Hyphenator.config} * @see {@link Hyphenator~mySelectorFunction} * @default false * @type {function|boolean} * @access private */ selectorFunction = false, /** * @method Hyphenator~mySelectorFunction * @desc * A function that returns a HTMLNodeList or array of Elements to be hyphenated. * By default it uses the classname ('hyphenate') to select the elements. * @access private */ mySelectorFunction = function (hyphenateClass) { var tmp, el = [], i, l; if (window.document.getElementsByClassName) { el = contextWindow.document.getElementsByClassName(hyphenateClass); } else if (window.document.querySelectorAll) { el = contextWindow.document.querySelectorAll('.' + hyphenateClass); } else { tmp = contextWindow.document.getElementsByTagName('*'); l = tmp.length; for (i = 0; i < l; i += 1) { if (tmp[i].className.indexOf(hyphenateClass) !== -1 && tmp[i].className.indexOf(dontHyphenateClass) === -1) { el.push(tmp[i]); } } } return el; }, /** * @method Hyphenator~selectElements * @desc * A function that uses either selectorFunction set by the user * or the default mySelectorFunction. * @access private */ selectElements = function () { var elems; if (selectorFunction) { elems = selectorFunction(); } else { elems = mySelectorFunction(hyphenateClass); } return elems; }, /** * @member {string} Hyphenator~intermediateState * @desc * The visibility of elements while they are hyphenated: * 'visible': unhyphenated text is visible and then redrawn when hyphenated. * 'hidden': unhyphenated text is made invisible as soon as possible and made visible after hyphenation. * @default 'hidden' * @see {@link Hyphenator.config} * @access private */ intermediateState = 'hidden', /** * @member {string} Hyphenator~unhide * @desc * How hidden elements unhide: either simultaneous (default: 'wait') or progressively. * 'wait' makes Hyphenator.js to wait until all elements are hyphenated (one redraw) * With 'progressive' Hyphenator.js unhides elements as soon as they are hyphenated. * @see {@link Hyphenator.config} * @access private */ unhide = 'wait', /** * @member {Array.<Hyphenator~CSSEdit>} Hyphenator~CSSEditors * @desc A container array that holds CSSEdit classes * For each window object one CSSEdit class is inserted * @access private */ CSSEditors = [], /** * @constructor Hyphenator~CSSEdit * @desc * This class handles access and editing of StyleSheets. * Thanks to this styles (e.g. hiding and unhiding elements upon hyphenation) * can be changed in one place instead for each element. * @access private */ CSSEdit = function (w) { w = w || window; var doc = w.document, /** * @member {Object} Hyphenator~CSSEdit~sheet * @desc * A StyleSheet, where Hyphenator can write to. * If no StyleSheet can be found, lets create one. * @access private */ sheet = (function () { var i, l = doc.styleSheets.length, s, element, r = false; for (i = 0; i < l; i += 1) { s = doc.styleSheets[i]; try { if (!!s.cssRules) { r = s; break; } } catch (ignore) {} } r = false; if (r === false) { element = doc.createElement('style'); element.type = 'text/css'; doc.getElementsByTagName('head')[0].appendChild(element); r = doc.styleSheets[doc.styleSheets.length - 1]; } return r; }()), /** * @typedef {Object} Hyphenator~CSSEdit~changes * @property {Object} sheet - The StyleSheet where the change was made * @property {number} index - The index of the changed rule */ /** * @member {Array.<changes>} Hyphenator~CSSEdit~changes * @desc * Sets a CSS rule for a specified selector * @access private */ changes = [], /** * @typedef Hyphenator~CSSEdit~rule * @property {number} index - The index of the rule * @property {Object} rule - The style rule */ /** * @method Hyphenator~CSSEdit~findRule * @desc * Searches the StyleSheets for a given selector and returns an object containing the rule. * If nothing can be found, false is returned. * @param {string} sel * @return {Hyphenator~CSSEdit~rule|false} * @access private */ findRule = function (sel) { var s, rule, sheets = w.document.styleSheets, rules, i, j, r = false; for (i = 0; i < sheets.length; i += 1) { s = sheets[i]; try { //FF has issues here with external CSS (s.o.p) if (!!s.cssRules) { rules = s.cssRules; } else if (!!s.rules) { // IE < 9 rules = s.rules; } } catch (ignore) {} if (!!rules && !!rules.length) { for (j = 0; j < rules.length; j += 1) { rule = rules[j]; if (rule.selectorText === sel) { r = { index: j, rule: rule }; } } } } return r; }, /** * @method Hyphenator~CSSEdit~addRule * @desc * Adds a rule to the {@link Hyphenator~CSSEdit~sheet} * @param {string} sel - The selector to be added * @param {string} rulesStr - The rules for the specified selector * @return {number} index of the new rule * @access private */ addRule = function (sel, rulesStr) { var i, r; if (!!sheet.insertRule) { if (!!sheet.cssRules) { i = sheet.cssRules.length; } else { i = 0; } r = sheet.insertRule(sel + '{' + rulesStr + '}', i); } else if (!!sheet.addRule) { // IE < 9 if (!!sheet.rules) { i = sheet.rules.length; } else { i = 0; } sheet.addRule(sel, rulesStr, i); r = i; } return r; }, /** * @method Hyphenator~CSSEdit~removeRule * @desc * Removes a rule with the specified index from the specified sheet * @param {Object} sheet - The style sheet * @param {number} index - the index of the rule * @access private */ removeRule = function (sheet, index) { if (sheet.deleteRule) { sheet.deleteRule(index); } else { // IE < 9 sheet.removeRule(index); } }; return { /** * @method Hyphenator~CSSEdit.setRule * @desc * Sets a CSS rule for a specified selector * @access public * @param {string} sel - Selector * @param {string} rulesString - CSS-Rules */ setRule: function (sel, rulesString) { var i, existingRule, cssText; existingRule = findRule(sel); if (!!existingRule) { if (!!existingRule.rule.cssText) { cssText = existingRule.rule.cssText; } else { // IE < 9 cssText = existingRule.rule.style.cssText.toLowerCase(); } if (cssText === '.' + hyphenateClass + ' { visibility: hidden; }') { //browsers w/o IE < 9 and no additional style defs: //add to [changes] for later removal changes.push({sheet: existingRule.rule.parentStyleSheet, index: existingRule.index}); } else if (cssText.indexOf('visibility: hidden') !== -1) { // IE < 9 or additional style defs: // add new rule i = addRule(sel, rulesString); //add to [changes] for later removal changes.push({sheet: sheet, index: i}); // clear existing def existingRule.rule.style.visibility = ''; } else { i = addRule(sel, rulesString); changes.push({sheet: sheet, index: i}); } } else { i = addRule(sel, rulesString); changes.push({sheet: sheet, index: i}); } }, /** * @method Hyphenator~CSSEdit.clearChanges * @desc * Removes all changes Hyphenator has made from the StyleSheets * @access public */ clearChanges: function () { var change = changes.pop(); while (!!change) { removeRule(change.sheet, change.index); change = changes.pop(); } } }; }, /** * @member {string} Hyphenator~hyphen * @desc * A string containing the character for in-word-hyphenation * @default the soft hyphen * @access private * @see {@link Hyphenator.config} */ hyphen = String.fromCharCode(173), /** * @member {string} Hyphenator~urlhyphen * @desc * A string containing the character for url/mail-hyphenation * @default the zero width space * @access private * @see {@link Hyphenator.config} * @see {@link Hyphenator~zeroWidthSpace} */ urlhyphen = zeroWidthSpace, /** * @method Hyphenator~hyphenateURL * @desc * Puts {@link Hyphenator~urlhyphen} (default: zero width space) after each no-alphanumeric char that my be in a URL. * @param {string} url to hyphenate * @returns string the hyphenated URL * @access public */ hyphenateURL = function (url) { var tmp = url.replace(/([:\/\.\?#&\-_,;!@]+)/gi, '$&' + urlhyphen), parts = tmp.split(urlhyphen), i; for (i = 0; i < parts.length; i += 1) { if (parts[i].length > (2 * min)) { parts[i] = parts[i].replace(/(\w{3})(\w)/gi, "$1" + urlhyphen + "$2"); } } if (parts[parts.length - 1] === "") { parts.pop(); } return parts.join(urlhyphen); }, /** * @member {boolean} Hyphenator~safeCopy * @desc * Defines wether work-around for copy issues is active or not * @default true * @access private * @see {@link Hyphenator.config} * @see {@link Hyphenator~registerOnCopy} */ safeCopy = true, /** * @member {Object} Hyphenator~hyphRunFor * @desc * stores location.href for documents where run() has been executed * to warn when Hyphenator.run() executed multiple times * @access private * @see {@link Hyphenator~runWhenLoaded} */ hyphRunFor = {}, /** * @method Hyphenator~runWhenLoaded * @desc * A crossbrowser solution for the DOMContentLoaded-Event based on * <a href = "http://jquery.com/">jQuery</a> * I added some functionality: e.g. support for frames and iframes… * @param {Object} w the window-object * @param {function()} f the function to call when the document is ready * @access private */ runWhenLoaded = function (w, f) { var toplevel, add = window.document.addEventListener ? 'addEventListener' : 'attachEvent', rem = window.document.addEventListener ? 'removeEventListener' : 'detachEvent', pre = window.document.addEventListener ? '' : 'on', init = function (context) { if (hyphRunFor[context.location.href]) { onWarning(new Error("Warning: multiple execution of Hyphenator.run() – This may slow down the script!")); } contextWindow = context || window; f(); hyphRunFor[contextWindow.location.href] = true; }, doScrollCheck = function () { try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ w.document.documentElement.doScroll("left"); } catch (error) { window.setTimeout(doScrollCheck, 1); return; } //maybe modern IE fired DOMContentLoaded if (!hyphRunFor[w.location.href]) { documentLoaded = true; init(w); } }, doOnEvent = function (e) { var i, fl, haveAccess; if (!!e && e.type === 'readystatechange' && w.document.readyState !== 'interactive' && w.document.readyState !== 'complete') { return; } //DOM is ready/interactive, but frames may not be loaded yet! //cleanup events w.document[rem](pre + 'DOMContentLoaded', doOnEvent, false); w.document[rem](pre + 'readystatechange', doOnEvent, false); //check frames fl = w.frames.length; if (fl === 0 || !doFrames) { //there are no frames! //cleanup events w[rem](pre + 'load', doOnEvent, false); documentLoaded = true; init(w); } else if (doFrames && fl > 0) { //we have frames, so wait for onload and then initiate runWhenLoaded recursevly for each frame: if (!!e && e.type === 'load') { //cleanup events w[rem](pre + 'load', doOnEvent, false); for (i = 0; i < fl; i += 1) { haveAccess = undefined; //try catch isn't enough for webkit try { //opera throws only on document.toString-access haveAccess = window.frames[i].document.toString(); } catch (err) { haveAccess = undefined; } if (!!haveAccess) { runWhenLoaded(w.frames[i], f); } } init(w); } } }; if (documentLoaded || w.document.readyState === 'complete') { //Hyphenator has run already (documentLoaded is true) or //it has been loaded after onLoad documentLoaded = true; doOnEvent({type: 'load'}); } else { //register events w.document[add](pre + 'DOMContentLoaded', doOnEvent, false); w.document[add](pre + 'readystatechange', doOnEvent, false); w[add](pre + 'load', doOnEvent, false); toplevel = false; try { toplevel = !window.frameElement; } catch (ignore) {} if (toplevel && w.document.documentElement.doScroll) { doScrollCheck(); //calls init() } } }, /** * @method Hyphenator~getLang * @desc * Gets the language of an element. If no language is set, it may use the {@link Hyphenator~mainLanguage}. * @param {Object} el The first parameter is an DOM-Element-Object * @param {boolean} fallback The second parameter is a boolean to tell if the function should return the {@link Hyphenator~mainLanguage} * if there's no language found for the element. * @return {string} The language of the element * @access private */ getLang = function (el, fallback) { try { return !!el.getAttribute('lang') ? el.getAttribute('lang').toLowerCase() : !!el.getAttribute('xml:lang') ? el.getAttribute('xml:lang').toLowerCase() : el.tagName.toLowerCase() !== 'html' ? getLang(el.parentNode, fallback) : fallback ? mainLanguage : null; } catch (ignore) {} }, /** * @method Hyphenator~autoSetMainLanguage * @desc * Retrieves the language of the document from the DOM and sets the lang attribute of the html-tag. * The function looks in the following places: * <ul> * <li>lang-attribute in the html-tag</li> * <li><meta http-equiv = "content-language" content = "xy" /></li> * <li><meta name = "DC.Language" content = "xy" /></li> * <li><meta name = "language" content = "xy" /></li> * </li> * If nothing can be found a prompt using {@link Hyphenator~languageHint} and a prompt-string is displayed. * If the retrieved language is in the object {@link Hyphenator~supportedLangs} it is copied to {@link Hyphenator~mainLanguage} * @access private */ autoSetMainLanguage = function (w) { w = w || contextWindow; var el = w.document.getElementsByTagName('html')[0], m = w.document.getElementsByTagName('meta'), i, getLangFromUser = function () { var ml, text = '', dH = 300, dW = 450, dX = Math.floor((w.outerWidth - dW) / 2) + window.screenX, dY = Math.floor((w.outerHeight - dH) / 2) + window.screenY, ul = '', languageHint; if (!!window.showModalDialog && (w.location.href.indexOf(basePath) !== -1)) { ml = window.showModalDialog(basePath + 'modalLangDialog.html', supportedLangs, "dialogWidth: " + dW + "px; dialogHeight: " + dH + "px; dialogtop: " + dY + "; dialogleft: " + dX + "; center: on; resizable: off; scroll: off;"); } else { languageHint = (function () { var k, r = ''; for (k in supportedLangs) { if (supportedLangs.hasOwnProperty(k)) { r += k + ', '; } } r = r.substring(0, r.length - 2); return r; }()); ul = window.navigator.language || window.navigator.userLanguage; ul = ul.substring(0, 2); if (!!supportedLangs[ul] && supportedLangs[ul].prompt !== '') { text = supportedLangs[ul].prompt; } else { text = supportedLangs.en.prompt; } text += ' (ISO 639-1)\n\n' + languageHint; ml = window.prompt(window.unescape(text), ul).toLowerCase(); } return ml; }; mainLanguage = getLang(el, false); if (!mainLanguage) { for (i = 0; i < m.length; i += 1) { //<meta http-equiv = "content-language" content="xy"> if (!!m[i].getAttribute('http-equiv') && (m[i].getAttribute('http-equiv').toLowerCase() === 'content-language')) { mainLanguage = m[i].getAttribute('content').toLowerCase(); } //<meta name = "DC.Language" content="xy"> if (!!m[i].getAttribute('name') && (m[i].getAttribute('name').toLowerCase() === 'dc.language')) { mainLanguage = m[i].getAttribute('content').toLowerCase(); } //<meta name = "language" content = "xy"> if (!!m[i].getAttribute('name') && (m[i].getAttribute('name').toLowerCase() === 'language')) { mainLanguage = m[i].getAttribute('content').toLowerCase(); } } } //get lang for frame from enclosing document if (!mainLanguage && doFrames && (!!contextWindow.frameElement)) { autoSetMainLanguage(window.parent); } //fallback to defaultLang if set if (!mainLanguage && defaultLanguage !== '') { mainLanguage = defaultLanguage; } //ask user for lang if (!mainLanguage) { mainLanguage = getLangFromUser(); } el.lang = mainLanguage; }, /** * @method Hyphenator~gatherDocumentInfos * @desc * This method runs through the DOM and executes the process()-function on: * - every node returned by the {@link Hyphenator~selectorFunction}. * @access private */ gatherDocumentInfos = function () { var elToProcess, urlhyphenEls, tmp, i = 0, /** * @method Hyphenator~gatherDocumentInfos * @desc * This method copies the element to the elements-variable, sets its visibility * to intermediateState, retrieves its language and recursivly descends the DOM-tree until * the child-Nodes aren't of type 1 * @param {Object} el a DOM element * @param {string} plang the language of the parent element * @param {boolean} isChild true, if the parent of el has been processed */ process = function (el, pLang, isChild) { isChild = isChild || false; var n, j = 0, hyphenate = true, eLang, useCSS3 = function () { css3hyphenateClassHandle = new CSSEdit(contextWindow); css3hyphenateClassHandle.setRule('.' + css3hyphenateClass, css3_h9n.property + ': auto;'); css3hyphenateClassHandle.setRule('.' + dontHyphenateClass, css3_h9n.property + ': manual;'); if ((eLang !== pLang) && css3_h9n.property.indexOf('webkit') !== -1) { css3hyphenateClassHandle.setRule('.' + css3hyphenateClass, '-webkit-locale : ' + eLang + ';'); } el.className = el.className + ' ' + css3hyphenateClass; }, useHyphenator = function () { //quick fix for test111.html //better: weight elements if (isBookmarklet && eLang !== mainLanguage) { return; } if (supportedLangs.hasOwnProperty(eLang)) { docLanguages[eLang] = true; } else { if (supportedLangs.hasOwnProperty(eLang.split('-')[0])) { //try subtag eLang = eLang.split('-')[0]; docLanguages[eLang] = true; } else if (!isBookmarklet) { hyphenate = false; onError(new Error('Language "' + eLang + '" is not yet supported.')); } } if (hyphenate) { if (intermediateState === 'hidden') { el.className = el.className + ' ' + hideClass; } elements.add(el, eLang); } }; if (el.lang && typeof (el.lang) === 'string') { eLang = el.lang.toLowerCase(); //copy attribute-lang to internal eLang } else if (!!pLang && pLang !== '') { eLang = pLang.toLowerCase(); } else { eLang = getLang(el, true); } if (!isChild) { if (css3 && css3_h9n.support && !!css3_h9n.checkLangSupport(eLang)) { useCSS3(); } else { useHyphenator(); } } else { if (eLang !== pLang) { if (css3 && css3_h9n.support && !!css3_h9n.checkLangSupport(eLang)) { useCSS3(); } else { useHyphenator(); } } else { if (!css3 || !css3_h9n.support || !css3_h9n.checkLangSupport(eLang)) { useHyphenator(); } // else do nothing } } n = el.childNodes[j]; while (!!n) { if (n.nodeType === 1 && !dontHyphenate[n.nodeName.toLowerCase()] && n.className.indexOf(dontHyphenateClass) === -1 && n.className.indexOf(urlHyphenateClass) === -1 && !elToProcess[n]) { process(n, eLang, true); } j += 1; n = el.childNodes[j]; } }, processUrlStyled = function (el) { var n, j = 0; n = el.childNodes[j]; while (!!n) { if (n.nodeType === 1 && !dontHyphenate[n.nodeName.toLowerCase()] && n.className.indexOf(dontHyphenateClass) === -1 && n.className.indexOf(hyphenateClass) === -1 && !urlhyphenEls[n]) { processUrlStyled(n); } else if (n.nodeType === 3) { n.data = hyphenateURL(n.data); } j += 1; n = el.childNodes[j]; } }; if (css3) { css3_gethsupport(); } if (isBookmarklet) { elToProcess = contextWindow.document.getElementsByTagName('body')[0]; process(elToProcess, mainLanguage, false); } else { if (!css3 && intermediateState === 'hidden') { CSSEditors.push(new CSSEdit(contextWindow)); CSSEditors[CSSEditors.length - 1].setRule('.' + hyphenateClass, 'visibility: hidden;'); CSSEditors[CSSEditors.length - 1].setRule('.' + hideClass, 'visibility: hidden;'); CSSEditors[CSSEditors.length - 1].setRule('.' + unhideClass, 'visibility: visible;'); } elToProcess = selectElements(); tmp = elToProcess[i]; while (!!tmp) { process(tmp, '', false); i += 1; tmp = elToProcess[i]; } urlhyphenEls = mySelectorFunction(urlHyphenateClass); i = 0; tmp = urlhyphenEls[i]; while (!!tmp) { processUrlStyled(tmp); i += 1; tmp = urlhyphenEls[i]; } } if (elements.count === 0) { //nothing to hyphenate or all hyphenated by css3 for (i = 0; i < CSSEditors.length; i += 1) { CSSEditors[i].clearChanges(); } onHyphenationDone(contextWindow.location.href); } }, /** * @method Hyphenator~convertPatterns * @desc * converts patterns of the given language to a trie * @access private * @param {Object} language object whose patterns shall be converted */ convertPatterns = function (lo) { var size, tree = {}, convert = function (psize, patterns) { var i = 0, t = tree, cc = 0, points = [], ppos = 0, lastwasp = false, len = 0; while (i < patterns.length) { if (len < psize) { cc = patterns.charCodeAt(i); if (cc >= 49 && cc <= 57) { //this is a hpoint (1-9) points[ppos] = cc - 48; ppos += 1; lastwasp = true; } else { //this is a alphabetic char --> extend the tree? if (!t[cc]) { t[cc] = {}; } t = t[cc]; //go to subtree if (!lastwasp) { points[ppos] = 0; ppos += 1; } lastwasp = false; } len += 1; i += 1; } if (len === psize) { //add last point (0) if (!lastwasp) { points[ppos] = 0; } //write points t.tpoints = points; //reset t = tree; points = []; ppos = 0; lastwasp = false; len = 0; } } }; for (size in lo.patterns) { if (lo.patterns.hasOwnProperty(size)) { convert(parseInt(size, 10), lo.patterns[size]); } } lo.patterns = tree; }, /** * @method Hyphenator~recreatePattern * @desc * Recreates the pattern for the reducedPatternSet * @param {string} pattern The pattern (chars) * @param {string} nodePoints The nodePoints (integers) * @access private * @return {string} The pattern (chars and numbers) */ recreatePattern = function (pattern, nodePoints) { var r = [], c = pattern.split(''), i; for (i = 0; i < nodePoints.length; i += 1) { if (nodePoints[i] !== 0) { r.push(nodePoints[i]); } if (c[i]) { r.push(c[i]); } } return r.join(''); }, /** * @method Hyphenator~convertExceptionsToObject * @desc * Converts a list of comma seprated exceptions to an object: * 'Fortran,Hy-phen-a-tion' -> {'Fortran':'Fortran','Hyphenation':'Hy-phen-a-tion'} * @access private * @param {string} exc a comma separated string of exceptions (without spaces) * @return {Object.<string, string>} */ convertExceptionsToObject = function (exc) { var w = exc.split(', '), r = {}, i, l, key; for (i = 0, l = w.length; i < l; i += 1) { key = w[i].replace(/-/g, ''); if (!r.hasOwnProperty(key)) { r[key] = w[i]; } } return r; }, /** * @method Hyphenator~loadPatterns * @desc * Checks if the requested file is available in the network. * Adds a <script>-Tag to the DOM to load an externeal .js-file containing patterns and settings for the given language. * If the given language is not in the {@link Hyphenator~supportedLangs}-Object it returns. * One may ask why we are not using AJAX to load the patterns. The XMLHttpRequest-Object * has a same-origin-policy. This makes the Bookmarklet impossible. * @param {string} lang The language to load the patterns for * @access private * @see {@link Hyphenator~basePath} */ loadPatterns = function (lang) { var location, xhr, head, script; if (supportedLangs.hasOwnProperty(lang) && !Hyphenator.languages[lang]) { location = basePath + 'patterns/' + supportedLangs[lang].file; } else { return; } if (isLocal && !isBookmarklet) { //check if 'location' is available: xhr = null; try { // Mozilla, Opera, Safari and Internet Explorer (ab v7) xhr = new window.XMLHttpRequest(); } catch (e) { try { //IE>=6 xhr = new window.ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { try { //IE>=5 xhr = new window.ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) { xhr = null; } } } if (xhr) { xhr.open('HEAD', location, true); xhr.setRequestHeader('Cache-Control', 'no-cache'); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 404) { onError(new Error('Could not load\n' + location)); delete docLanguages[lang]; return; } } }; xhr.send(null); } } if (createElem) { head = window.document.getElementsByTagName('head').item(0); script = createElem('script', window); script.src = location; script.type = 'text/javascript'; script.charset = 'utf8'; head.appendChild(script); } }, /** * @method Hyphenator~prepareLanguagesObj * @desc * Adds some feature to the language object: * - cache * - exceptions * Converts the patterns to a trie using {@link Hyphenator~convertPatterns} * If storage is active the object is stored there. * @access private * @param {string} lang The language of the language object */ prepareLanguagesObj = function (lang) { var lo = Hyphenator.languages[lang], wrd; if (!lo.prepared) { if (enableCache) { lo.cache = {}; //Export //lo['cache'] = lo.cache; } if (enableReducedPatternSet) { lo.redPatSet = {}; } //add exceptions from the pattern file to the local 'exceptions'-obj if (lo.hasOwnProperty('exceptions')) { Hyphenator.addExceptions(lang, lo.exceptions); delete lo.exceptions; } //copy global exceptions to the language specific exceptions if (exceptions.hasOwnProperty('global')) { if (exceptions.hasOwnProperty(lang)) { exceptions[lang] += ', ' + exceptions.global; } else { exceptions[lang] = exceptions.global; } } //move exceptions from the the local 'exceptions'-obj to the 'language'-object if (exceptions.hasOwnProperty(lang)) { lo.exceptions = convertExceptionsToObject(exceptions[lang]); delete exceptions[lang]; } else { lo.exceptions = {}; } convertPatterns(lo); wrd = '[\\w' + lo.specialChars + '@' + String.fromCharCode(173) + String.fromCharCode(8204) + '-]{' + min + ',}'; lo.genRegExp = new RegExp('(' + url + ')|(' + mail + ')|(' + wrd + ')', 'gi'); lo.prepared = true; } if (!!storage) { storage.setItem(lang, window.JSON.stringify(lo)); } }, /**** * @method Hyphenator~prepare * @desc * This funtion prepares the Hyphenator~Object: If RemoteLoading is turned off, it assumes * that the patternfiles are loaded, all conversions are made and the callback is called. * If storage is active the object is retrieved there. * If RemoteLoading is on (default), it loads the pattern files and waits until they are loaded, * by repeatedly checking Hyphenator.languages. If a patternfile is loaded the patterns are * converted to their object style and the lang-object extended. * Finally the callback is called. * @access private */ prepare = function (callback) { var lang, interval, tmp1, tmp2, languagesLoaded = function () { var finishedLoading = true, l; for (l in docLanguages) { if (docLanguages.hasOwnProperty(l)) { finishedLoading = false; if (!!Hyphenator.languages[l]) { delete docLanguages[l]; //do conversion while other patterns are loading: prepareLanguagesObj(l); callback(l); } } } return finishedLoading; }; if (!enableRemoteLoading) { for (lang in Hyphenator.languages) { if (Hyphenator.languages.hasOwnProperty(lang)) { prepareLanguagesObj(lang); } } callback('*'); return; } // get all languages that are used and preload the patterns for (lang in docLanguages) { if (docLanguages.hasOwnProperty(lang)) { if (!!storage && storage.test(lang)) { Hyphenator.languages[lang] = window.JSON.parse(storage.getItem(lang)); if (exceptions.hasOwnProperty('global')) { tmp1 = convertExceptionsToObject(exceptions.global); for (tmp2 in tmp1) { if (tmp1.hasOwnProperty(tmp2)) { Hyphenator.languages[lang].exceptions[tmp2] = tmp1[tmp2]; } } } //Replace exceptions since they may have been changed: if (exceptions.hasOwnProperty(lang)) { tmp1 = convertExceptionsToObject(exceptions[lang]); for (tmp2 in tmp1) { if (tmp1.hasOwnProperty(tmp2)) { Hyphenator.languages[lang].exceptions[tmp2] = tmp1[tmp2]; } } delete exceptions[lang]; } //Replace genRegExp since it may have been changed: tmp1 = '[\\w' + Hyphenator.languages[lang].specialChars + '@' + String.fromCharCode(173) + String.fromCharCode(8204) + '-]{' + min + ',}'; Hyphenator.languages[lang].genRegExp = new RegExp('(' + url + ')|(' + mail + ')|(' + tmp1 + ')', 'gi'); delete docLanguages[lang]; callback(lang); } else { loadPatterns(lang); } } } // else async wait until patterns are loaded, then hyphenate if (!languagesLoaded()) { interval = window.setInterval(function () { var loadingDone = languagesLoaded(); if (loadingDone) { window.clearInterval(interval); } }, 100); } }, /** * @method Hyphenator~toggleBox * @desc * Creates the toggleBox: a small button to turn off/on hyphenation on a page. * @see {@link Hyphenator.config} * @access private */ toggleBox = function () { var bdy, myTextNode, text = (Hyphenator.doHyphenation ? 'Hy-phen-a-tion' : 'Hyphenation'), myBox = contextWindow.document.getElementById('HyphenatorToggleBox'); if (!!myBox) { myBox.firstChild.data = text; } else { bdy = contextWindow.document.getElementsByTagName('body')[0]; myBox = createElem('div', contextWindow); myBox.setAttribute('id', 'HyphenatorToggleBox'); myBox.setAttribute('class', dontHyphenateClass); myTextNode = contextWindow.document.createTextNode(text); myBox.appendChild(myTextNode); myBox.onclick = Hyphenator.toggleHyphenation; myBox.style.position = 'absolute'; myBox.style.top = '0px'; myBox.style.right = '0px'; myBox.style.margin = '0'; myBox.style.backgroundColor = '#AAAAAA'; myBox.style.color = '#FFFFFF'; myBox.style.font = '6pt Arial'; myBox.style.letterSpacing = '0.2em'; myBox.style.padding = '3px'; myBox.style.cursor = 'pointer'; myBox.style.WebkitBorderBottomLeftRadius = '4px'; myBox.style.MozBorderRadiusBottomleft = '4px'; myBox.style.borderBottomLeftRadius = '4px'; bdy.appendChild(myBox); } }, /** * @method Hyphenator~hyphenateWord * @desc * This function is the heart of Hyphenator.js. It returns a hyphenated word. * * If there's already a {@link Hyphenator~hypen} in the word, the word is returned as it is. * If the word is in the exceptions list or in the cache, it is retrieved from it. * If there's a '-' hyphenate the parts. * The hyphenated word is returned and (if acivated) cached. * Both special Events onBeforeWordHyphenation and onAfterWordHyphenation are called for the word. * @param {Object} lo A language object (containing the patterns) * @param {string} lang The language of the word * @param {string} word The word * @returns string The hyphenated word * @access public */ hyphenateWord = function (lo, lang, word) { var parts, i, pattern, ww, wwlen, wwhp = [], pstart, plen, trie = lo.patterns, node, nodePoints, hp, wordLength = word.length, hw = '', doCharSubst = function (w) { var subst, r; for (subst in lo.charSubstitution) { if (lo.charSubstitution.hasOwnProperty(subst)) { r = w.replace(new RegExp(subst, 'g'), lo.charSubstitution[subst]); } } return r; }; word = onBeforeWordHyphenation(word, lang); if (word === '') { hw = ''; } else if (enableCache && lo.cache.hasOwnProperty(word)) { //the word is in the cache hw = lo.cache[word]; } else if (word.indexOf(hyphen) !== -1) { //word already contains shy; -> leave at it is! hw = word; } else if (lo.exceptions.hasOwnProperty(word)) { //the word is in the exceptions list hw = lo.exceptions[word].replace(/-/g, hyphen); } else if (word.indexOf('-') !== -1) { //word contains '-' -> hyphenate the parts separated with '-' parts = word.split('-'); for (i = 0; i < parts.length; i += 1) { parts[i] = hyphenateWord(lo, lang, parts[i]); } hw = parts.join('-'); } else { ww = word.toLowerCase(); if (!!lo.charSubstitution) { ww = doCharSubst(ww); } if (word.indexOf("'") !== -1) { ww = ww.replace("'", "’"); //replace APOSTROPHE with RIGHT SINGLE QUOTATION MARK (since the latter is used in the patterns) } ww = '_' + ww + '_'; wwlen = ww.length; for (hp = 0; hp < wwlen + 1; hp += 1) { wwhp[hp] = 0; } for (pstart = 0; pstart < wwlen; pstart += 1) { node = trie; pattern = ''; for (plen = pstart; plen < wwlen; plen += 1) { node = node[ww.charCodeAt(plen)]; //go sub trie if (node) { if (enableReducedPatternSet) { pattern += ww.charAt(plen); } nodePoints = node.tpoints; if (nodePoints) { if (enableReducedPatternSet) { if (!lo.redPatSet) { lo.redPatSet = {}; } lo.redPatSet[pattern] = recreatePattern(pattern, nodePoints); } for (hp = 0; hp < nodePoints.length; hp += 1) { wwhp[pstart + hp] = Math.max(wwhp[pstart + hp], nodePoints[hp]); } } } else { break; } } } //return wwhp for (hp = 0; hp < wordLength; hp += 1) { if (hp >= lo.leftmin && hp <= (wordLength - lo.rightmin) && (wwhp[hp + 1] % 2) !== 0) { hw += hyphen + word.charAt(hp); } else { hw += word.charAt(hp); } } } hw = onAfterWordHyphenation(hw, lang); if (enableCache) { //put the word in the cache lo.cache[word] = hw; } return hw; }, /** * @method Hyphenator~removeHyphenationFromElement * @desc * Removes all hyphens from the element. If there are other elements, the function is * called recursively. * Removing hyphens is usefull if you like to copy text. Some browsers are buggy when the copy hyphenated texts. * @param {Object} el The element where to remove hyphenation. * @access public */ removeHyphenationFromElement = function (el) { var h, u, i = 0, n; switch (hyphen) { case '|': h = '\\|'; break; case '+': h = '\\+'; break; case '*': h = '\\*'; break; default: h = hyphen; } switch (urlhyphen) { case '|': u = '\\|'; break; case '+': u = '\\+'; break; case '*': u = '\\*'; break; default: u = urlhyphen; } n = el.childNodes[i]; while (!!n) { if (n.nodeType === 3) { n.data = n.data.replace(new RegExp(h, 'g'), ''); n.data = n.data.replace(new RegExp(u, 'g'), ''); } else if (n.nodeType === 1) { removeHyphenationFromElement(n); } i += 1; n = el.childNodes[i]; } }, copy = (function () { var Copy = function () { this.oncopyHandler = function (e) { e = e || window.event; var shadow, selection, range, rangeShadow, restore, target = e.target || e.srcElement, currDoc = target.ownerDocument, bdy = currDoc.getElementsByTagName('body')[0], targetWindow = currDoc.defaultView || currDoc.parentWindow; if (target.tagName && dontHyphenate[target.tagName.toLowerCase()]) { //Safari needs this return; } //create a hidden shadow element shadow = currDoc.createElement('div'); //Moving the element out of the screen doesn't work for IE9 (https://connect.microsoft.com/IE/feedback/details/663981/) //shadow.style.overflow = 'hidden'; //shadow.style.position = 'absolute'; //shadow.style.top = '-5000px'; //shadow.style.height = '1px'; //doing this instead: shadow.style.color = window.getComputedStyle ? targetWindow.getComputedStyle(bdy, null).backgroundColor : '#FFFFFF'; shadow.style.fontSize = '0px'; bdy.appendChild(shadow); if (!!window.getSelection) { //FF3, Webkit, IE9 e.stopPropagation(); selection = targetWindow.getSelection(); range = selection.getRangeAt(0); shadow.appendChild(range.cloneContents()); removeHyphenationFromElement(shadow); selection.selectAllChildren(shadow); restore = function () { shadow.parentNode.removeChild(shadow); selection.removeAllRanges(); //IE9 needs that selection.addRange(range); }; } else { // IE<9 e.cancelBubble = true; selection = targetWindow.document.selection; range = selection.createRange(); shadow.innerHTML = range.htmlText; removeHyphenationFromElement(shadow); rangeShadow = bdy.createTextRange(); rangeShadow.moveToElementText(shadow); rangeShadow.select(); restore = function () { shadow.parentNode.removeChild(shadow); if (range.text !== "") { range.select(); } }; } window.setTimeout(restore, 0); }; this.removeOnCopy = function (el) { var body = el.ownerDocument.getElementsByTagName('body')[0]; if (!body) { return; } el = el || body; if (window.removeEventListener) { el.removeEventListener("copy", this.oncopyHandler, true); } else { el.detachEvent("oncopy", this.oncopyHandler); } }; this.registerOnCopy = function (el) { var body = el.ownerDocument.getElementsByTagName('body')[0]; if (!body) { return; } el = el || body; if (window.addEventListener) { el.addEventListener("copy", this.oncopyHandler, true); } else { el.attachEvent("oncopy", this.oncopyHandler); } }; }; return (safeCopy ? new Copy() : false); }()), /** * @method Hyphenator~checkIfAllDone * @desc * Checks if all elements in {@link Hyphenator~elements} are hyphenated, unhides them and fires onHyphenationDone() * @access private */ checkIfAllDone = function () { var allDone = true, i, doclist = {}, doc; elements.each(function (ellist) { var j, l = ellist.length; for (j = 0; j < l; j += 1) { allDone = allDone && ellist[j].hyphenated; if (!doclist.hasOwnProperty(ellist[j].element.baseURI)) { doclist[ellist[j].element.ownerDocument.location.href] = true; } doclist[ellist[j].element.ownerDocument.location.href] = doclist[ellist[j].element.ownerDocument.location.href] && ellist[j].hyphenated; } }); if (allDone) { if (intermediateState === 'hidden' && unhide === 'progressive') { elements.each(function (ellist) { var j, l = ellist.length, el; for (j = 0; j < l; j += 1) { el = ellist[j].element; el.className = el.className.replace(unhideClassRegExp, ''); if (el.className === '') { el.removeAttribute('class'); } } }); } for (i = 0; i < CSSEditors.length; i += 1) { CSSEditors[i].clearChanges(); } for (doc in doclist) { if (doclist.hasOwnProperty(doc)) { onHyphenationDone(doc); } } } }, /** * @method Hyphenator~hyphenateElement * @desc * Takes the content of the given element and - if there's text - replaces the words * by hyphenated words. If there's another element, the function is called recursively. * When all words are hyphenated, the visibility of the element is set to 'visible'. * @param {string} lang - The language-code of the element * @param {Element} elo - The element to hyphenate {@link Hyphenator~elements~ElementCollection~Element} * @access private */ hyphenateElement = function (lang, elo) { var el = elo.element, hyphenate, n, i, lo, controlOrphans = function (part) { var h, r; switch (hyphen) { case '|': h = '\\|'; break; case '+': h = '\\+'; break; case '*': h = '\\*'; break; default: h = hyphen; } //strip off blank space at the end (omitted closing tags) part = part.replace(/[\s]*$/, ''); if (orphanControl >= 2) { //remove hyphen points from last word r = part.split(' '); r[1] = r[1].replace(new RegExp(h, 'g'), ''); r[1] = r[1].replace(new RegExp(zeroWidthSpace, 'g'), ''); r = r.join(' '); } if (orphanControl === 3) { //replace spaces by non breaking spaces r = r.replace(/[ ]+/g, String.fromCharCode(160)); } return r; }; if (Hyphenator.languages.hasOwnProperty(lang)) { lo = Hyphenator.languages[lang]; hyphenate = function (word) { var r; if (!Hyphenator.doHyphenation) { r = word; } else if (urlOrMailRE.test(word)) { r = hyphenateURL(word); } else { r = hyphenateWord(lo, lang, word); } return r; }; if (safeCopy && (el.tagName.toLowerCase() !== 'body')) { copy.registerOnCopy(el); } i = 0; n = el.childNodes[i]; while (!!n) { if (n.nodeType === 3 && n.data.length >= min) { //type 3 = #text -> hyphenate! n.data = n.data.replace(lo.genRegExp, hyphenate); if (orphanControl !== 1) { n.data = n.data.replace(/[\S]+ [\S]+[\s]*$/, controlOrphans); } } i += 1; n = el.childNodes[i]; } } if (intermediateState === 'hidden' && unhide === 'wait') { el.className = el.className.replace(hideClassRegExp, ''); if (el.className === '') { el.removeAttribute('class'); } } if (intermediateState === 'hidden' && unhide === 'progressive') { el.className = el.className.replace(hideClassRegExp, ' ' + unhideClass); } elo.hyphenated = true; elements.hyCount += 1; if (elements.count <= elements.hyCount) { checkIfAllDone(); } }, /** * @method Hyphenator~hyphenateLanguageElements * @desc * Calls hyphenateElement() for all elements of the specified language. * If the language is '*' then all elements are hyphenated. * This is done with a setTimout * to prevent a "long running Script"-alert when hyphenating large pages. * Therefore a tricky bind()-function was necessary. * @param {string} lang The language of the elements to hyphenate * @access private */ hyphenateLanguageElements = function (lang) { function bind(fun, arg1, arg2) { return function () { return fun(arg1, arg2); }; } var i, l; if (lang === '*') { elements.each(function (lang, ellist) { var j, le = ellist.length; for (j = 0; j < le; j += 1) { window.setTimeout(bind(hyphenateElement, lang, ellist[j]), 0); } }); } else { if (elements.list.hasOwnProperty(lang)) { l = elements.list[lang].length; for (i = 0; i < l; i += 1) { window.setTimeout(bind(hyphenateElement, lang, elements.list[lang][i]), 0); } } } }, /** * @method Hyphenator~removeHyphenationFromDocument * @desc * Does what it says and unregisters the onCopyEvent from the elements * @access private */ removeHyphenationFromDocument = function () { elements.each(function (ellist) { var i, l = ellist.length; for (i = 0; i < l; i += 1) { removeHyphenationFromElement(ellist[i].element); if (safeCopy) { copy.removeOnCopy(ellist[i].element); } ellist[i].hyphenated = false; } }); }, /** * @method Hyphenator~createStorage * @desc * inits the private var {@link Hyphenator~storage) depending of the setting in {@link Hyphenator~storageType} * and the supported features of the system. * @access private */ createStorage = function () { var s; try { if (storageType !== 'none' && window.localStorage !== undefined && window.sessionStorage !== undefined && window.JSON.stringify !== undefined && window.JSON.parse !== undefined) { switch (storageType) { case 'session': s = window.sessionStorage; break; case 'local': s = window.localStorage; break; default: s = undefined; break; } //check for private mode s.setItem('storageTest', '1'); s.removeItem('storageTest'); } } catch (e) { //FF throws an error if DOM.storage.enabled is set to false s = undefined; } if (s) { storage = { prefix: 'Hyphenator_' + Hyphenator.version + '_', store: s, test: function (name) { var val = this.store.getItem(this.prefix + name); return (!!val) ? true : false; }, getItem: function (name) { return this.store.getItem(this.prefix + name); }, setItem: function (name, value) { try { this.store.setItem(this.prefix + name, value); } catch (e) { onError(e); } } }; } else { storage = undefined; } }, /** * @method Hyphenator~storeConfiguration * @desc * Stores the current config-options in DOM-Storage * @access private */ storeConfiguration = function () { if (!storage) { return; } var settings = { 'STORED': true, 'classname': hyphenateClass, 'urlclassname': urlHyphenateClass, 'donthyphenateclassname': dontHyphenateClass, 'minwordlength': min, 'hyphenchar': hyphen, 'urlhyphenchar': urlhyphen, 'togglebox': toggleBox, 'displaytogglebox': displayToggleBox, 'remoteloading': enableRemoteLoading, 'enablecache': enableCache, 'enablereducedpatternset': enableReducedPatternSet, 'onhyphenationdonecallback': onHyphenationDone, 'onerrorhandler': onError, 'onwarninghandler': onWarning, 'intermediatestate': intermediateState, 'selectorfunction': selectorFunction || mySelectorFunction, 'safecopy': safeCopy, 'doframes': doFrames, 'storagetype': storageType, 'orphancontrol': orphanControl, 'dohyphenation': Hyphenator.doHyphenation, 'persistentconfig': persistentConfig, 'defaultlanguage': defaultLanguage, 'useCSS3hyphenation': css3, 'unhide': unhide, 'onbeforewordhyphenation': onBeforeWordHyphenation, 'onafterwordhyphenation': onAfterWordHyphenation }; storage.setItem('config', window.JSON.stringify(settings)); }, /** * @method Hyphenator~restoreConfiguration * @desc * Retrieves config-options from DOM-Storage and does configuration accordingly * @access private */ restoreConfiguration = function () { var settings; if (storage.test('config')) { settings = window.JSON.parse(storage.getItem('config')); Hyphenator.config(settings); } }; return { /** * @member {string} Hyphenator.version * @desc * String containing the actual version of Hyphenator.js * [major release].[minor releas].[bugfix release] * major release: new API, new Features, big changes * minor release: new languages, improvements * @access public */ version: '4.3.0', /** * @member {boolean} Hyphenator.doHyphenation * @desc * If doHyphenation is set to false, hyphenateDocument() isn't called. * All other actions are performed. * @default true */ doHyphenation: true, /** * @typedef {Object} Hyphenator.languages.language * @property {Number} leftmin - The minimum of chars to remain on the old line * @property {Number} rightmin - The minimum of chars to go on the new line * @property {string} specialChars - Non-ASCII chars in the alphabet. * @property {Object.<number, string>} patterns - the patterns in a compressed format. The key is the length of the patterns in the value string. * @property {Object.<string, string>} charSubstitution - optional: a hash table with chars that are replaced during hyphenation * @property {string | Object.<string, string>} exceptions - optional: a csv string containing exceptions */ /** * @member {Object.<string, Hyphenator.languages.language>} Hyphenator.languages * @desc * Objects that holds key-value pairs, where key is the language and the value is the * language-object loaded from (and set by) the pattern file. * @namespace Hyphenator.languages * @access public */ languages: {}, /** * @method Hyphenator.config * @desc * The Hyphenator.config() function that takes an object as an argument. The object contains key-value-pairs * containig Hyphenator-settings. * @param {Hyphenator.config} obj * @access public * @example * <script src = "Hyphenator.js" type = "text/javascript"></script> * <script type = "text/javascript"> * Hyphenator.config({'minwordlength':4,'hyphenchar':'|'}); * Hyphenator.run(); * </script> */ config: function (obj) { var assert = function (name, type) { var r, t; t = typeof obj[name]; if (t === type) { r = true; } else { onError(new Error('Config onError: ' + name + ' must be of type ' + type)); r = false; } return r; }, key; if (obj.hasOwnProperty('storagetype')) { if (assert('storagetype', 'string')) { storageType = obj.storagetype; } if (!storage) { createStorage(); } } if (!obj.hasOwnProperty('STORED') && storage && obj.hasOwnProperty('persistentconfig') && obj.persistentconfig === true) { restoreConfiguration(); } for (key in obj) { if (obj.hasOwnProperty(key)) { switch (key) { case 'STORED': break; case 'classname': if (assert('classname', 'string')) { hyphenateClass = obj[key]; } break; case 'urlclassname': if (assert('urlclassname', 'string')) { urlHyphenateClass = obj[key]; } break; case 'donthyphenateclassname': if (assert('donthyphenateclassname', 'string')) { dontHyphenateClass = obj[key]; } break; case 'minwordlength': if (assert('minwordlength', 'number')) { min = obj[key]; } break; case 'hyphenchar': if (assert('hyphenchar', 'string')) { if (obj.hyphenchar === '­') { obj.hyphenchar = String.fromCharCode(173); } hyphen = obj[key]; } break; case 'urlhyphenchar': if (obj.hasOwnProperty('urlhyphenchar')) { if (assert('urlhyphenchar', 'string')) { urlhyphen = obj[key]; } } break; case 'togglebox': if (assert('togglebox', 'function')) { toggleBox = obj[key]; } break; case 'displaytogglebox': if (assert('displaytogglebox', 'boolean')) { displayToggleBox = obj[key]; } break; case 'remoteloading': if (assert('remoteloading', 'boolean')) { enableRemoteLoading = obj[key]; } break; case 'enablecache': if (assert('enablecache', 'boolean')) { enableCache = obj[key]; } break; case 'enablereducedpatternset': if (assert('enablereducedpatternset', 'boolean')) { enableReducedPatternSet = obj[key]; } break; case 'onhyphenationdonecallback': if (assert('onhyphenationdonecallback', 'function')) { onHyphenationDone = obj[key]; } break; case 'onerrorhandler': if (assert('onerrorhandler', 'function')) { onError = obj[key]; } break; case 'onwarninghandler': if (assert('onwarninghandler', 'function')) { onWarning = obj[key]; } break; case 'intermediatestate': if (assert('intermediatestate', 'string')) { intermediateState = obj[key]; } break; case 'selectorfunction': if (assert('selectorfunction', 'function')) { selectorFunction = obj[key]; } break; case 'safecopy': if (assert('safecopy', 'boolean')) { safeCopy = obj[key]; } break; case 'doframes': if (assert('doframes', 'boolean')) { doFrames = obj[key]; } break; case 'storagetype': if (assert('storagetype', 'string')) { storageType = obj[key]; } break; case 'orphancontrol': if (assert('orphancontrol', 'number')) { orphanControl = obj[key]; } break; case 'dohyphenation': if (assert('dohyphenation', 'boolean')) { Hyphenator.doHyphenation = obj[key]; } break; case 'persistentconfig': if (assert('persistentconfig', 'boolean')) { persistentConfig = obj[key]; } break; case 'defaultlanguage': if (assert('defaultlanguage', 'string')) { defaultLanguage = obj[key]; } break; case 'useCSS3hyphenation': if (assert('useCSS3hyphenation', 'boolean')) { css3 = obj[key]; } break; case 'unhide': if (assert('unhide', 'string')) { unhide = obj[key]; } break; case 'onbeforewordhyphenation': if (assert('onbeforewordhyphenation', 'function')) { onBeforeWordHyphenation = obj[key]; } break; case 'onafterwordhyphenation': if (assert('onafterwordhyphenation', 'function')) { onAfterWordHyphenation = obj[key]; } break; default: onError(new Error('Hyphenator.config: property ' + key + ' not known.')); } } } if (storage && persistentConfig) { storeConfiguration(); } }, /** * @method Hyphenator.run * @desc * Bootstrap function that starts all hyphenation processes when called: * Tries to create storage if required and calls {@link Hyphenator~runWhenLoaded} on 'window' handing over the callback 'process' * @access public * @example * <script src = "Hyphenator.js" type = "text/javascript"></script> * <script type = "text/javascript"> * Hyphenator.run(); * </script> */ run: function () { /** *@callback Hyphenator.run~process process - The function is called when the DOM has loaded (or called for each frame) */ var process = function () { try { if (contextWindow.document.getElementsByTagName('frameset').length > 0) { return; //we are in a frameset } autoSetMainLanguage(undefined); gatherDocumentInfos(); prepare(hyphenateLanguageElements); if (displayToggleBox) { toggleBox(); } } catch (e) { onError(e); } }; if (!storage) { createStorage(); } runWhenLoaded(window, process); }, /** * @method Hyphenator.addExceptions * @desc * Adds the exceptions from the string to the appropriate language in the * {@link Hyphenator~languages}-object * @param {string} lang The language * @param {string} words A comma separated string of hyphenated words WITH spaces. * @access public * @example <script src = "Hyphenator.js" type = "text/javascript"></script> * <script type = "text/javascript"> * Hyphenator.addExceptions('de','ziem-lich, Wach-stube'); * Hyphenator.run(); * </script> */ addExceptions: function (lang, words) { if (lang === '') { lang = 'global'; } if (exceptions.hasOwnProperty(lang)) { exceptions[lang] += ", " + words; } else { exceptions[lang] = words; } }, /** * @method Hyphenator.hyphenate * @access public * @desc * Hyphenates the target. The language patterns must be loaded. * If the target is a string, the hyphenated string is returned, * if it's an object, the values are hyphenated directly and undefined (aka nothing) is returned * @param {string|Object} target the target to be hyphenated * @param {string} lang the language of the target * @returns {string|undefined} * @example <script src = "Hyphenator.js" type = "text/javascript"></script> * <script src = "patterns/en.js" type = "text/javascript"></script> * <script type = "text/javascript"> * var t = Hyphenator.hyphenate('Hyphenation', 'en'); //Hy|phen|ation * </script> */ hyphenate: function (target, lang) { var hyphenate, n, i, lo; lo = Hyphenator.languages[lang]; if (Hyphenator.languages.hasOwnProperty(lang)) { if (!lo.prepared) { prepareLanguagesObj(lang); } hyphenate = function (word) { var r; if (urlOrMailRE.test(word)) { r = hyphenateURL(word); } else { r = hyphenateWord(lo, lang, word); } return r; }; if (typeof target === 'object' && !(typeof target === 'string' || target.constructor === String)) { i = 0; n = target.childNodes[i]; while (!!n) { if (n.nodeType === 3 && n.data.length >= min) { //type 3 = #text -> hyphenate! n.data = n.data.replace(lo.genRegExp, hyphenate); } else if (n.nodeType === 1) { if (n.lang !== '') { Hyphenator.hyphenate(n, n.lang); } else { Hyphenator.hyphenate(n, lang); } } i += 1; n = target.childNodes[i]; } } else if (typeof target === 'string' || target.constructor === String) { return target.replace(lo.genRegExp, hyphenate); } } else { onError(new Error('Language "' + lang + '" is not loaded.')); } }, /** * @method Hyphenator.getRedPatternSet * @desc * Returns the reduced pattern set: an object looking like: {'patk': pat} * @param {string} lang the language patterns are stored for * @returns {Object.<string, string>} * @access public */ getRedPatternSet: function (lang) { return Hyphenator.languages[lang].redPatSet; }, /** * @method Hyphenator.isBookmarklet * @desc * Returns {@link Hyphenator~isBookmarklet}. * @returns {boolean} * @access public */ isBookmarklet: function () { return isBookmarklet; }, /** * @method Hyphenator.getConfigFromURI * @desc * reads and sets configurations from GET parameters in the URI * @access public */ getConfigFromURI: function () { /*jslint evil: true*/ var loc = null, re = {}, jsArray = contextWindow.document.getElementsByTagName('script'), i, j, l, s, gp, option; for (i = 0, l = jsArray.length; i < l; i += 1) { if (!!jsArray[i].getAttribute('src')) { loc = jsArray[i].getAttribute('src'); } if (loc && (loc.indexOf('Hyphenator.js?') !== -1)) { s = loc.indexOf('Hyphenator.js?'); gp = loc.substring(s + 14).split('&'); for (j = 0; j < gp.length; j += 1) { option = gp[j].split('='); if (option[0] !== 'bm') { if (option[1] === 'true') { option[1] = true; } else if (option[1] === 'false') { option[1] = false; } else if (isFinite(option[1])) { option[1] = parseInt(option[1], 10); } if (option[0] === 'togglebox' || option[0] === 'onhyphenationdonecallback' || option[0] === 'onerrorhandler' || option[0] === 'selectorfunction' || option[0] === 'onbeforewordhyphenation' || option[0] === 'onafterwordhyphenation') { option[1] = new Function('', option[1]); } re[option[0]] = option[1]; } } break; } } return re; }, /** * @method Hyphenator.toggleHyphenation * @desc * Checks the current state of the ToggleBox and removes or does hyphenation. * @access public */ toggleHyphenation: function () { if (Hyphenator.doHyphenation) { if (!!css3hyphenateClassHandle) { css3hyphenateClassHandle.setRule('.' + css3hyphenateClass, css3_h9n.property + ': none;'); } removeHyphenationFromDocument(); Hyphenator.doHyphenation = false; storeConfiguration(); toggleBox(); } else { if (!!css3hyphenateClassHandle) { css3hyphenateClassHandle.setRule('.' + css3hyphenateClass, css3_h9n.property + ': auto;'); } hyphenateLanguageElements('*'); Hyphenator.doHyphenation = true; storeConfiguration(); toggleBox(); } } }; }(window)); //Export properties/methods (for google closure compiler) /**** to be moved to external file Hyphenator['languages'] = Hyphenator.languages; Hyphenator['config'] = Hyphenator.config; Hyphenator['run'] = Hyphenator.run; Hyphenator['addExceptions'] = Hyphenator.addExceptions; Hyphenator['hyphenate'] = Hyphenator.hyphenate; Hyphenator['getRedPatternSet'] = Hyphenator.getRedPatternSet; Hyphenator['isBookmarklet'] = Hyphenator.isBookmarklet; Hyphenator['getConfigFromURI'] = Hyphenator.getConfigFromURI; Hyphenator['toggleHyphenation'] = Hyphenator.toggleHyphenation; window['Hyphenator'] = Hyphenator; */ /* * call Hyphenator if it is a Bookmarklet */ if (Hyphenator.isBookmarklet()) { Hyphenator.config({displaytogglebox: true, intermediatestate: 'visible', storagetype: 'local', doframes: true, useCSS3hyphenation: true}); Hyphenator.config(Hyphenator.getConfigFromURI()); Hyphenator.run(); } |