From 23911ce6b0ef905ae3343c1a8fb47aa2cf1aed32 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Sun, 16 Aug 2009 18:51:27 +0530 Subject: Adding hyphenation web based examples and patterns --- hyphenation/web/COPYING.LESSER.txt | 165 ++++ hyphenation/web/Hyphenator.js | 1605 ++++++++++++++++++++++++++++++++++++ hyphenation/web/example.html | 103 +++ hyphenation/web/patterns/bn.js | 13 + hyphenation/web/patterns/gu.js | 12 + hyphenation/web/patterns/hi.js | 12 + hyphenation/web/patterns/kn.js | 13 + hyphenation/web/patterns/ml.js | 14 + hyphenation/web/patterns/or.js | 14 + hyphenation/web/patterns/pa.js | 12 + hyphenation/web/patterns/ta.js | 12 + hyphenation/web/patterns/te.js | 12 + 12 files changed, 1987 insertions(+) create mode 100644 hyphenation/web/COPYING.LESSER.txt create mode 100644 hyphenation/web/Hyphenator.js create mode 100644 hyphenation/web/example.html create mode 100644 hyphenation/web/patterns/bn.js create mode 100644 hyphenation/web/patterns/gu.js create mode 100644 hyphenation/web/patterns/hi.js create mode 100644 hyphenation/web/patterns/kn.js create mode 100644 hyphenation/web/patterns/ml.js create mode 100644 hyphenation/web/patterns/or.js create mode 100644 hyphenation/web/patterns/pa.js create mode 100644 hyphenation/web/patterns/ta.js create mode 100644 hyphenation/web/patterns/te.js diff --git a/hyphenation/web/COPYING.LESSER.txt b/hyphenation/web/COPYING.LESSER.txt new file mode 100644 index 0000000..fc8a5de --- /dev/null +++ b/hyphenation/web/COPYING.LESSER.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/hyphenation/web/Hyphenator.js b/hyphenation/web/Hyphenator.js new file mode 100644 index 0000000..1bc369b --- /dev/null +++ b/hyphenation/web/Hyphenator.js @@ -0,0 +1,1605 @@ +/*! + * Hyphenator 2.3.0 - client side hyphenation for webbrowsers + * Copyright (C) 2009 Mathias Nater, Zürich (mathias at mnn dot ch) + * 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. + */ + +/* + * Comments are jsdoctoolkit formatted. See jsdoctoolkit.org + */ + +/* The following comment is for JSLint: */ +/*global window, ActiveXObject, unescape */ +/*jslint browser: true, eqeqeq: true, immed: true, newcap: true, nomen: true, onevar: true, undef: true, white: true, indent: 4*/ + +/** + * @fileOverview + * A script that does hyphenation in (X)HTML files + * @author Mathias Nater, mathias@mnn.ch + * @version 2.3.0 + */ + +/** + * @constructor + * @description Provides all functionality to do hyphenation, except the patterns that are loaded + * externally. + * @namespace Holds all methods and properties + * @example + * <script src = "Hyphenator.js" type = "text/javascript"></script> + * <script type = "text/javascript"> + *   Hyphenator.run(); + * </script> + */ +var Hyphenator = (function () { + + + /** + * @name Hyphenator-languageHint + * @fieldOf Hyphenator + * @description + * A string to be displayed in a prompt if the language can't be guessed. + * If you add hyphenation patterns change this string. + * Internally, this string is used to define languages that are supported by Hyphenator. + * @see Hyphenator-supportedLang + * @type string + * @private + * @see Hyphenator-autoSetMainLanguage + */ + var languageHint = 'cs, da, bn, de, en, es, fi, fr, gu, hi, hu, it, kn, ml, nl, or, pa, pl, pt, ru, sv, ta, te, uk', + + /** + * @name Hyphenator-supportedLang + * @fieldOf Hyphenator + * @description + * A generated key-value object that stores supported languages. + * The languages are retrieved from {@link Hyphenator-languageHint}. + * @type object + * @private + * @example + * Check if language lang is supported: + * if (supportedLang[lang]) + */ + supportedLang = (function () { + var k, i = 0, a = languageHint.split(', '), r = {}; + while (!!(k = a[i++])) { + r[k] = true; + } + return r; + }()), + + /** + * @name Hyphenator-prompterStrings + * @fieldOf Hyphenator + * @description + * A key-value object holding the strings to be displayed if the language can't be guessed + * If you add hyphenation patterns change this string. + * @type object + * @private + * @see Hyphenator-autoSetMainLanguage + */ + prompterStrings = { + 'cs': 'Jazyk této internetové stránky nebyl automaticky rozpoznán. Určete prosím její jazyk:', + 'da': 'Denne websides sprog kunne ikke bestemmes. Angiv venligst sprog:', + 'de': 'Die Sprache dieser Webseite konnte nicht automatisch bestimmt werden. Bitte Sprache angeben:', + 'en': 'The language of this website could not be determined automatically. Please indicate the main language:', + 'es': 'El idioma del sitio no pudo determinarse autom%E1ticamente. Por favor, indique el idioma principal:', + 'fi': 'Sivun kielt%E4 ei tunnistettu automaattisesti. M%E4%E4rit%E4 sivun p%E4%E4kieli:', + 'fr': 'La langue de ce site n%u2019a pas pu %EAtre d%E9termin%E9e automatiquement. Veuillez indiquer une langue, s.v.p.%A0:', + 'hu': 'A weboldal nyelvét nem sikerült automatikusan megállapítani. Kérem adja meg a nyelvet:', + 'it': 'Lingua del sito sconosciuta. Indicare una lingua, per favore:', + 'ml': 'ഈ വെ%u0D2C%u0D4D%u200Cസൈറ്റിന്റെ ഭാഷ കണ്ടുപിടിയ്ക്കാ%u0D28%u0D4D%u200D കഴിഞ്ഞില്ല. ഭാഷ ഏതാണെന്നു തിരഞ്ഞെടുക്കുക:', + 'nl': 'De taal van deze website kan niet automatisch worden bepaald. Geef de hoofdtaal op:', + 'pt': 'A língua deste site não pôde ser determinada automaticamente. Por favor indique a língua principal:', + 'ru': 'Язык этого сайта не может быть определен автоматически. Пожалуйста укажите язык:', + 'sv': 'Spr%E5ket p%E5 den h%E4r webbplatsen kunde inte avg%F6ras automatiskt. V%E4nligen ange:', + 'uk': 'Мова цього веб-сайту не може бути визначена автоматично. Будь ласка, вкажіть головну мову:' + }, + + /** + * @name Hyphenator-basePath + * @fieldOf Hyphenator + * @description + * A string storing the basepath from where Hyphenator.js was loaded. + * This is used to load the patternfiles. + * The basepath is determined dynamically by searching all script-tags for Hyphenator.js + * If the path cannot be determined http://hyphenator.googlecode.com/svn/trunk/ is used as fallback. + * @type string + * @private + * @see Hyphenator-loadPatterns + */ + basePath = (function () { + var s = document.getElementsByTagName('script'), i = 0, p, src, t; + while (!!(t = s[i++])) { + if (!t.src) { + continue; + } + src = t.src; + p = src.indexOf('Hyphenator.js'); + if (p !== -1) { + return src.substring(0, p); + } + } + return 'http://hyphenator.googlecode.com/svn/trunk/'; + }()), + + /** + * @name Hyphenator-isLocal + * @fieldOf Hyphenator + * @description + * 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 (basePath.indexOf(window.location.hostname) !== -1) { + re = true; + } + return re; + }()), + + /** + * @name Hyphenator-documentLoaded + * @fieldOf Hyphenator + * @description + * documentLoaded is true, when the DOM has been loaded. This is set by runOnContentLoaded + */ + documentLoaded = false, + + /** + * @name Hyphenator-dontHyphenate + * @fieldOf Hyphenator + * @description + * A key-value object containing all html-tags whose content should not be hyphenated + * @type object + * @private + * @see Hyphenator-hyphenateElement + */ + dontHyphenate = {'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}, + + /** + * @name Hyphenator-enableCache + * @fieldOf Hyphenator + * @description + * A variable to set if caching is enabled or not + * @type boolean + * @default true + * @private + * @see Hyphenator.config + * @see hyphenateWord + */ + enableCache = true, + + /** + * @name Hyphenator-enableRemoteLoading + * @fieldOf Hyphenator + * @description + * A variable to set if pattern files should be loaded remotely or not + * @type boolean + * @default true + * @private + * @see Hyphenator.config + * @see Hyphenator-loadPatterns + */ + enableRemoteLoading = true, + + /** + * @name Hyphenator-displayToggleBox + * @fieldOf Hyphenator + * @description + * A variable to set if the togglebox should be displayed or not + * @type boolean + * @default false + * @private + * @see Hyphenator.config + * @see Hyphenator-toggleBox + */ + displayToggleBox = false, + + /** + * @name Hyphenator-hyphenateClass + * @fieldOf Hyphenator + * @description + * A string containing the css-class-name for the hyphenate class + * @type string + * @default 'hyphenate' + * @private + * @example + * <p class = "hyphenate">Text</p> + * @see Hyphenator.config + */ + hyphenateClass = 'hyphenate', + + /** + * @name Hyphenator-dontHyphenateClass + * @fieldOf Hyphenator + * @description + * A string containing the css-class-name for elements that should not be hyphenated + * @type string + * @default 'donthyphenate' + * @private + * @example + * <p class = "donthyphenate">Text</p> + * @see Hyphenator.config + */ + dontHyphenateClass = 'donthyphenate', + + /** + * @name Hyphenator-min + * @fieldOf Hyphenator + * @description + * A number wich indicates the minimal length of words to hyphenate. + * @type number + * @default 6 + * @private + * @see Hyphenator.config + */ + min = 6, + + /** + * @name Hyphenator-isBookmarklet + * @fieldOf Hyphenator + * @description + * Indicates if Hyphanetor runs as bookmarklet or not. + * @type boolean + * @default false + * @private + */ + isBookmarklet = (function () { + var loc = null, re = false, jsArray = document.getElementsByTagName('script'), i, l; + for (i = 0, l = jsArray.length; i < l; i++) { + if (!!jsArray[i].getAttribute('src')) { + loc = jsArray[i].getAttribute('src'); + } + if (!loc) { + continue; + } else if (loc.indexOf('Hyphenator.js?bm=true') !== -1) { + re = true; + } + } + return re; + }()), + + /** + * @name Hyphenator-mainLanguage + * @fieldOf Hyphenator + * @description + * The general language of the document + * @type number + * @private + * @see Hyphenator-autoSetMainLanguage + */ + mainLanguage = null, + + /** + * @name Hyphenator-elements + * @fieldOf Hyphenator + * @description + * An array holding all elements that have to be hyphenated. This var is filled by + * {@link Hyphenator-gatherDocumentInfos} + * @type array + * @private + */ + elements = [], + + /** + * @name Hyphenator-exceptions + * @fieldOf Hyphenator + * @description + * 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. + * @see Hyphenator-prepareLanguagesObj + * @type object + * @private + */ + exceptions = {}, + + /** + * @name Hyphenator-docLanguages + * @fieldOf Hyphenator + * @description + * An object holding all languages used in the document. This is filled by + * {@link Hyphenator-gatherDocumentInfos} + * @type object + * @private + */ + docLanguages = {}, + + + /** + * @name Hyphenator-state + * @fieldOf Hyphenator + * @description + * A number that inidcates the current state of the script + * 0: not initialized + * 1: loading patterns + * 2: ready + * 3: hyphenation done + * 4: hyphenation removed + * @type number + * @private + */ + state = 0, + + /** + * @name Hyphenator-url + * @fieldOf Hyphenator + * @description + * A string containing a RegularExpression to match URL's + * @type string + * @private + */ + url = '(\\w*:\/\/)?((\\w*:)?(\\w*)@)?((([\\d]{1,3}\\.){3}([\\d]{1,3}))|(([\\w]*\\.)+([\\w]{2,4})))(:\\d*)?(\/[\\w#!:\\.?\\+=&%@!\\-]*)*', + + /** + * @name Hyphenator-mail + * @fieldOf Hyphenator + * @description + * A string containing a RegularExpression to match mail-adresses + * @type string + * @private + */ + mail = '[\\w-\\.]+@[\\w\\.]+', + + /** + * @name Hyphenator-urlRE + * @fieldOf Hyphenator + * @description + * A RegularExpressions-Object for url- and mail adress matching + * @type object + * @private + */ + urlOrMailRE = new RegExp('(' + url + ')|(' + mail + ')', 'i'), + + /** + * @name Hyphenator-zeroWidthSpace + * @fieldOf Hyphenator + * @description + * A string that holds a char. + * Depending on the browser, this is the zero with space or an empty string. + * The zeroWidthSpace is inserted after a '-' in compound words, so even FF and IE + * will break after a '-' if necessary. + * zeroWidthSpace is also used to break URLs + * @type string + * @private + */ + zeroWidthSpace = (function () { + var zws, ua = navigator.userAgent.toLowerCase(); + if (ua.indexOf('msie 6') === -1) { + zws = String.fromCharCode(8203); //Unicode zero width space + } else { + zws = ''; //IE6 doesn't support zws + } + return zws; + }()), + + /** + * @name Hyphenator-onHyphenationDone + * @fieldOf Hyphenator + * @description + * A method to be called, when the last element has been hyphenated or the hyphenation has been + * removed from the last element. + * @see Hyphenator.config + * @type function + * @private + */ + onHyphenationDone = function () {}, + + /** + * @name Hyphenator-onError + * @fieldOf Hyphenator + * @description + * A function that can be called upon an error. + * @see Hyphenator.config + * @type function + * @private + */ + onError = function (e) { + alert("Hyphenator.js says:\n\nAn Error ocurred:\n" + e.message); + }, + + /** + * @name Hyphenator-selectorFunction + * @fieldOf Hyphenator + * @description + * A function that has to return a HTMLNodeList of Elements to be hyphenated. + * By default it uses the classname ('hyphenate') to select the elements. + * @see Hyphenator.config + * @type function + * @private + */ + selectorFunction = function () { + var tmp, el = [], i, l; + if (document.getElementsByClassName) { + el = document.getElementsByClassName(hyphenateClass); + } else { + tmp = document.getElementsByTagName('*'); + l = tmp.length; + for (i = 0; i < l; i++) + { + if (tmp[i].className.indexOf(hyphenateClass) !== -1 && tmp[i].className.indexOf(dontHyphenateClass) === -1) { + el.push(tmp[i]); + } + } + } + return el; + }, + + /** + * @name Hyphenator-intermediateState + * @fieldOf Hyphenator + * @description + * The value of style.visibility of the text while it is hyphenated. + * @see Hyphenator.config + * @type string + * @private + */ + intermediateState = 'hidden', + + /** + * @name Hyphenator-hyphen + * @fieldOf Hyphenator + * @description + * A string containing the character for in-word-hyphenation + * @type string + * @default the soft hyphen + * @private + * @see Hyphenator.config + */ + hyphen = String.fromCharCode(173), + + /** + * @name Hyphenator-urlhyphen + * @fieldOf Hyphenator + * @description + * A string containing the character for url/mail-hyphenation + * @type string + * @default the zero width space + * @private + * @see Hyphenator.config + * @see Hyphenator-zeroWidthSpace + */ + urlhyphen = zeroWidthSpace, + + /** + * @name Hyphenator-Expando + * @methodOf Hyphenator + * @description + * This custom object stores data for elements: storing data directly in elements + * (DomElement.customData = foobar;) isn't a good idea. It would lead to conflicts + * in form elements, when the form has a child with name="foobar". Therefore, this + * solution follows the approach of jQuery: the data is stored in an object and + * referenced by a unique attribute of the element. The attribute has a name that + * is built by the prefix "HyphenatorExpando_" and a random number, so if the very + * very rare case occurs, that there's already an attribute with the same name, a + * simple reload is enough to make it function. + * @private + */ + Expando = (function () { + var container = {}, + name = "HyphenatorExpando_" + Math.random(), + uuid = 0; + return { + getDataForElem : function (elem) { + return container[elem[name]]; + }, + setDataForElem : function (elem, data) { + var id; + if (elem[name] && elem[name] !== '') { + id = elem[name]; + } else { + id = uuid++; + elem[name] = id; + } + container[id] = data; + }, + appendDataForElem : function (elem, data) { + var k; + for (k in data) { + if (data.hasOwnProperty(k)) { + container[elem[name]][k] = data[k]; + } + } + }, + delDataOfElem : function (elem) { + delete container[elem[name]]; + } + }; + }()), + + /* + * ContentLoaded.js + * + * Author: Diego Perini (diego.perini at gmail.com) + * Summary: Cross-browser wrapper for DOMContentLoaded + * Updated: 17/05/2008 + * License: MIT + * Version: 1.1 + * + * URL: + * http://javascript.nwbox.com/ContentLoaded/ + * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE + * + * Notes: + * based on code by Dean Edwards and John Resig + * http://dean.edwards.name/weblog/2006/06/again/ + */ + // @w window reference + // @f function reference + //function ContentLoaded(w, f) { + /** + * @name Hyphenator-runOnContentLoaded + * @methodOf Hyphenator + * @description + * A crossbrowser solution for the DOMContentLoaded-Event + * @author Diego Perini (diego.perini at gmail.com) + * http://javascript.nwbox.com/ContentLoaded/ + * @param object the window-object + * @param function-object the function to call onDOMContentLoaded + * @private + */ + runOnContentLoaded = function (w, f) { + var d = w.document, + D = 'DOMContentLoaded', + // user agent, version + u = w.navigator.userAgent.toLowerCase(), + v = parseFloat(u.match(/.+(?:rv|it|ml|ra|ie)[\/: ]([\d.]+)/)[1]), + oldonload = w.onload; + + function init(e) { + if (!documentLoaded) { + documentLoaded = true; + // pass a fake event if needed + f((e.type && e.type === D) ? e : { + type: D, + target: d, + eventPhase: 0, + currentTarget: d, + timeStamp: new Date().getTime(), + eventType: e.type || e + }); + } + } + + // safari < 525.13 + if (/webkit\//.test(u) && v < 525.13) { + + (function () { + if (/complete|loaded/.test(d.readyState)) { + init('khtml-poll'); + } else { + setTimeout(arguments.callee, 10); + } + }()); + + // internet explorer all versions + } else if (/msie/.test(u) && !w.opera) { + + d.attachEvent('onreadystatechange', + function (e) { + if (d.readyState === 'complete') { + d.detachEvent('on' + e.type, arguments.callee); + init(e); + } + } + ); + if (w.self === top) { + (function () { + try { + d.documentElement.doScroll('left'); + } catch (e) { + setTimeout(arguments.callee, 10); + return; + } + init('msie-poll'); + }()); + } + + // browsers having native DOMContentLoaded + } else if (d.addEventListener && + (/opera\//.test(u) && v > 9) || + (/gecko\//.test(u) && v >= 1.8) || + (/khtml\//.test(u) && v >= 4.0) || + (/webkit\//.test(u) && v >= 525.13)) { + + d.addEventListener(D, + function (e) { + d.removeEventListener(D, arguments.callee, false); + init(e); + }, false + ); + + // fallback to last resort for older browsers + } else { + + // from Simon Willison + /** + * @ignore + */ + w.onload = function (e) { + init(e || w.event); + if (typeof oldonload === 'function') { + oldonload(e || w.event); + } + }; + + } + }, + /* end ContentLoaded.js */ + + /** + * @name Hyphenator-getLang + * @methodOf Hyphenator + * @description + * Gets the language of an element. If no language is set, it may use the {@link Hyphenator-mainLanguage}. + * @param object The first parameter is an DOM-Element-Object + * @param boolean 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. + * @private + */ + getLang = function (el, fallback) { + if (!!el.getAttribute('lang')) { + return el.getAttribute('lang').substring(0, 2).toLowerCase(); + } + // The following doesn't work in IE due to a bug when getAttribute('xml:lang') in a table + /*if (!!el.getAttribute('xml:lang')) { + return el.getAttribute('xml:lang').substring(0, 2); + }*/ + //instead, we have to do this (thanks to borgzor): + try { + if (!!el.getAttribute('xml:lang')) { + return el.getAttribute('xml:lang').substring(0, 2).toLowerCase(); + } + } catch (ex) {} + if (el.tagName !== 'HTML') { + return getLang(el.parentNode, true); + } + if (fallback) { + return mainLanguage; + } + return null; + }, + + /** + * @name Hyphenator-autoSetMainLanguage + * @methodOf Hyphenator + * @description + * Retrieves the language of the document from the DOM. + * The function looks in the following places: + *