diff --git a/http-tests/misc/cors-static.sh b/http-tests/misc/cors-static.sh index ae39023f76..00c676bdf4 100755 --- a/http-tests/misc/cors-static.sh +++ b/http-tests/misc/cors-static.sh @@ -6,7 +6,7 @@ set -euo pipefail response=$(curl -i -k -s \ -H "Origin: https://example.com" \ - "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/css/bootstrap.css") + "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/css/ldh.css") # Verify Access-Control-Allow-Origin header is present if ! echo "$response" | grep -q "Access-Control-Allow-Origin: \*"; then @@ -26,7 +26,7 @@ preflight=$(curl -i -k -s \ -X OPTIONS \ -H "Origin: https://example.com" \ -H "Access-Control-Request-Method: GET" \ - "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/css/bootstrap.css") + "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/css/ldh.css") # Verify preflight response has CORS headers if ! echo "$preflight" | grep -q "Access-Control-Allow-Origin: \*"; then diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/css/app.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/css/app.css new file mode 100644 index 0000000000..4cb5415255 --- /dev/null +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/css/app.css @@ -0,0 +1,3273 @@ +/* ========================================================================= + LinkedDataHub App UI kit — composition styles + Builds on ../../colors_and_type.css and the core primitives. Keep tokens here + to a minimum; this file is for layout / component skins. + ========================================================================= */ + +/* Core primitives (incl. the .msi icon base) — app pages link app.css directly, + so the dependency is declared here rather than assumed from styles.css. */ +@import url('core.css'); + +* { box-sizing: border-box; } +html, body { margin: 0; padding: 0; } +body { background: var(--bg-page); color: var(--fg-1); font-family: var(--font-sans); } + +a { color: var(--fg-link); text-decoration: none; } +a:hover { text-decoration: underline; text-underline-offset: 2px; } + +button { font-family: inherit; cursor: pointer; } + +/* Material Symbols (.msi) now lives in ui_kits/core/core.css — the icon + primitive is core-level. app.css inherits it via styles.css. */ + +/* ---------- App shell ---------- */ +.app { + min-height: 100vh; + display: flex; + flex-direction: column; +} + +/* Top header — dark accent gradient with knowledge-graph dot pattern overlay */ +.ldh-header { + position: relative; + height: 56px; + padding: 0 var(--sp-6); + display: grid; + grid-template-columns: 220px 1fr auto; + align-items: center; + gap: var(--sp-6); + background: var(--grad-deep); + color: #fff; + flex-shrink: 0; + isolation: isolate; /* contain ::before stacking without clipping descendants */ +} +.ldh-header::before { + content: ""; + position: absolute; inset: 0; + background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.10) 1px, transparent 1.4px); + background-size: 22px 22px; + pointer-events: none; + opacity: 0.55; + z-index: -1; /* sit under header children so dropdowns can overflow downward */ +} +.ldh-header > * { position: relative; } + +.ldh-wordmark { + display: flex; align-items: center; gap: var(--sp-2); + font-family: var(--font-sans); + font-weight: var(--fw-semibold); + font-size: 16px; + letter-spacing: var(--tracking-snug); + color: #fff; + text-decoration: none; +} +.ldh-wordmark .mark { + width: 24px; height: 24px; + border-radius: 6px; + background: linear-gradient(135deg, var(--ldh-blue-400) 0%, var(--ldh-violet-400) 100%); + position: relative; + box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); +} +.ldh-wordmark .mark::before, .ldh-wordmark .mark::after { + content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,0.9); +} +.ldh-wordmark .mark::before { width: 6px; height: 6px; top: 4px; left: 4px; } +.ldh-wordmark .mark::after { width: 4px; height: 4px; bottom: 5px; right: 5px; } + +.ldh-address { + display: flex; align-items: center; + height: 36px; + min-width: 0; + width: 100%; + max-width: 720px; + padding: 0 12px; + background: rgba(255,255,255,0.08); + border: 1px solid rgba(255,255,255,0.14); + border-radius: var(--r-md); + color: #fff; + gap: 8px; + justify-self: center; +} +.ldh-address:focus-within { + background: rgba(255,255,255,0.16); + border-color: rgba(255,255,255,0.32); + box-shadow: 0 0 0 4px rgba(77, 148, 248, 0.18); +} +.ldh-address .msi { color: rgba(255,255,255,0.72); } +.ldh-address input { + flex: 1; + min-width: 0; + background: transparent; + border: 0; + outline: 0; + color: #fff; + font-family: var(--font-mono); + letter-spacing: 0.02em; + font-size: var(--fs-sm); +} +.ldh-address input::placeholder { color: rgba(255,255,255,0.55); font-family: var(--font-mono); letter-spacing: 0.02em; } + +.ldh-search { + display: flex; align-items: center; + height: 36px; + background: rgba(255,255,255,0.10); + border: 1px solid rgba(255,255,255,0.14); + border-radius: var(--r-md); + padding: 0 var(--sp-3); + gap: var(--sp-2); + color: rgba(255,255,255,0.92); + transition: background var(--dur-base) var(--ease-out-soft), border-color var(--dur-base) var(--ease-out-soft); + max-width: 720px; + width: 100%; + justify-self: center; +} +.ldh-search:focus-within { + background: rgba(255,255,255,0.16); + border-color: rgba(255,255,255,0.32); + box-shadow: 0 0 0 4px rgba(77, 148, 248, 0.18); +} +.ldh-search .msi { color: rgba(255,255,255,0.72); } +.ldh-search input { + flex: 1; + background: transparent; + border: 0; + outline: 0; + color: #fff; + font-family: var(--font-sans); + font-size: var(--fs-sm); +} +.ldh-search input::placeholder { color: rgba(255,255,255,0.55); font-family: var(--font-mono); letter-spacing: 0.02em; } +.ldh-search kbd { + font-family: var(--font-mono); + font-size: 10px; + color: rgba(255,255,255,0.55); + padding: 2px 6px; + border: 1px solid rgba(255,255,255,0.18); + border-radius: 4px; +} + +.ldh-header-actions { display: flex; align-items: center; gap: var(--sp-2); } +.ldh-icon-btn { + width: 36px; height: 36px; + display: inline-flex; align-items: center; justify-content: center; + border-radius: var(--r-md); + background: transparent; + border: 0; + color: rgba(255,255,255,0.85); + transition: background var(--dur-fast) var(--ease-out-soft), color var(--dur-fast) var(--ease-out-soft); +} +.ldh-icon-btn:hover { background: rgba(255,255,255,0.10); color: #fff; } +.ldh-icon-btn.has-dot { position: relative; } +.ldh-icon-btn.has-dot::after { + content: ""; position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; + background: var(--ldh-blue-400); box-shadow: 0 0 0 2px rgba(10,45,87,0.95); +} + +.ldh-avatar { + width: 32px; height: 32px; + border-radius: 50%; + background: linear-gradient(135deg, var(--ldh-blue-400), var(--ldh-violet-400)); + color: #fff; + display: inline-flex; align-items: center; justify-content: center; + font-size: var(--fs-xs); + font-weight: var(--fw-semibold); + letter-spacing: 0.04em; + margin-left: var(--sp-1); + cursor: pointer; + border: 2px solid transparent; + transition: box-shadow var(--dur-fast) var(--ease-out-soft), border-color var(--dur-fast) var(--ease-out-soft); +} +.ldh-avatar:hover, +.ldh-avatar.is-open { + border-color: rgba(255,255,255,0.55); + box-shadow: 0 0 0 3px rgba(77, 148, 248, 0.22); +} + +/* User dropdown — popover anchored under the header avatar */ +.ldh-avatar-wrap { position: relative; display: inline-flex; } +.ldh-user-menu { + position: absolute; + top: calc(100% + 8px); + right: 0; + min-width: 248px; + background: var(--bg-card); + border: 1px solid var(--border-default); + border-radius: var(--r-md); + box-shadow: 0 16px 40px -12px rgba(15, 23, 42, 0.28), 0 4px 12px -4px rgba(15, 23, 42, 0.18); + padding: var(--sp-2); + z-index: 70; + animation: menu-pop var(--dur-fast) var(--ease-out-soft); + color: var(--fg-1); +} +@keyframes menu-pop { + from { opacity: 0; transform: translateY(-4px) scale(0.98); } + to { opacity: 1; transform: translateY(0) scale(1); } +} +.ldh-user-menu .umhead { + display: flex; align-items: center; gap: var(--sp-2); + padding: var(--sp-2); +} +.ldh-user-menu .umavatar { + width: 36px; height: 36px; + border-radius: 50%; + background: linear-gradient(135deg, var(--ldh-blue-400), var(--ldh-violet-400)); + color: #fff; + display: inline-flex; align-items: center; justify-content: center; + font-size: var(--fs-xs); + font-weight: var(--fw-semibold); + letter-spacing: 0.04em; + flex-shrink: 0; +} +.ldh-user-menu .umid { min-width: 0; } +.ldh-user-menu .umname { + font-weight: var(--fw-semibold); + font-size: var(--fs-sm); + color: var(--fg-1); + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; +} +.ldh-user-menu .umemail { + font-size: 11px; + color: var(--fg-2); + font-family: var(--font-mono); + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; +} +.ldh-user-menu .umdiv { + height: 1px; + background: var(--border-default); + margin: var(--sp-1) 0; +} +.ldh-user-menu .umitem { + display: flex; align-items: center; gap: var(--sp-2); + width: 100%; + padding: var(--sp-2); + border: 0; + background: transparent; + border-radius: var(--r-sm); + cursor: pointer; + font-size: var(--fs-sm); + color: var(--fg-1); + text-align: left; + font-family: inherit; +} +.ldh-user-menu .umitem:hover { background: var(--surface-2); } +.ldh-user-menu .umitem.is-danger { color: var(--ldh-red-600, #b42318); } +.ldh-user-menu .umitem.is-danger:hover { background: rgba(180, 35, 24, 0.08); } +.ldh-user-menu .umitem .msi { color: inherit; } + +/* ---------- Tabs row (dataspaces) ---------- */ +.ldh-tabs { + display: flex; + align-items: stretch; + gap: 2px; + padding: 0 var(--sp-6); + background: var(--surface-1); + border-bottom: 1px solid var(--border-default); + height: 40px; +} +.ldh-tab { + display: inline-flex; align-items: center; gap: var(--sp-2); + padding: 0 var(--sp-4); + font-size: var(--fs-sm); + font-weight: var(--fw-medium); + color: var(--fg-muted); + border: 0; + background: transparent; + border-bottom: 2px solid transparent; + transition: color var(--dur-fast) var(--ease-out-soft), border-color var(--dur-fast) var(--ease-out-soft); +} +.ldh-tab:hover { color: var(--fg-1); } +.ldh-tab.is-active { color: var(--fg-1); border-bottom-color: var(--ldh-blue-500); } +.ldh-tab .close { + width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; + border-radius: var(--r-xs); color: var(--fg-hint); +} +.ldh-tab .close:hover { background: var(--bg-hover); color: var(--fg-1); } + +/* ---------- Action bar (Add / Breadcrumb / Toolbar) ---------- */ +/* Action bar Create dropdown — Container / Item picker. */ +.ldh-add-wrap { position: relative; display: inline-flex; } +.ldh-add-wrap .ldh-btn.is-open .caret { transform: rotate(180deg); } +.ldh-add-wrap .ldh-btn .caret { transition: transform var(--dur-fast) var(--ease-out-soft); } +.ldh-add-menu { + position: absolute; + top: calc(100% + 6px); + left: 0; + min-width: 280px; + background: var(--bg-card); + border: 1px solid var(--border-default); + border-radius: var(--r-md); + box-shadow: 0 16px 40px -12px rgba(15, 23, 42, 0.28), 0 4px 12px -4px rgba(15, 23, 42, 0.18); + padding: var(--sp-2); + z-index: 50; + animation: menu-pop var(--dur-fast) var(--ease-out-soft); +} +.ldh-add-menu .hd { + padding: 6px 8px 4px; + font-family: var(--font-mono); + font-size: 10px; + letter-spacing: 0.04em; + text-transform: uppercase; + color: var(--fg-muted); +} +.ldh-add-menu .it { + display: grid; + grid-template-columns: 32px 1fr; + align-items: center; + gap: 10px; + width: 100%; + padding: 8px; + border: 0; + background: transparent; + border-radius: var(--r-sm); + cursor: pointer; + font: inherit; + text-align: left; + color: var(--fg-1); +} +.ldh-add-menu .it:hover { background: var(--surface-1); } +.ldh-add-menu .it .ico { + width: 32px; height: 32px; + display: inline-flex; align-items: center; justify-content: center; + border-radius: var(--r-sm); + background: var(--bg-accent-quiet); + color: var(--ldh-blue-700); +} +.ldh-add-menu .it .body { display: flex; flex-direction: column; min-width: 0; } +.ldh-add-menu .it .body .lbl { + font-size: var(--fs-sm); + font-weight: var(--fw-medium); + color: var(--fg-1); +} +.ldh-add-menu .it .body .sub { + font-size: var(--fs-xs); + color: var(--fg-2); +} + +.ldh-actionbar { + display: grid; + grid-template-columns: auto 1fr auto; + align-items: center; + gap: var(--sp-6); + padding: var(--sp-3) var(--sp-6); + background: var(--surface-0); + border-bottom: 1px solid var(--border-default); + flex-shrink: 0; +} + +/* Primary button (Add / Create / Save) */ +.ldh-btn { + display: inline-flex; align-items: center; gap: var(--sp-2); + height: 36px; + padding: 0 var(--sp-4); + border-radius: var(--r-md); + font-family: var(--font-sans); + font-size: var(--fs-sm); + font-weight: var(--fw-medium); + border: 1px solid transparent; + transition: background var(--dur-fast) var(--ease-out-soft), box-shadow var(--dur-fast) var(--ease-out-soft), transform 80ms var(--ease-out-soft); + background: var(--bg-accent); + color: var(--fg-on-accent); +} +.ldh-btn:hover { background: var(--bg-accent-hover); } +.ldh-btn:active { transform: translateY(1px); } +.ldh-btn:focus-visible { outline: 0; box-shadow: var(--shadow-glow-blue); } +.ldh-btn.is-ghost { + background: transparent; + color: var(--fg-2); + border-color: var(--border-default); +} +.ldh-btn.is-ghost:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-btn.is-quiet { + background: transparent; + color: var(--fg-2); + border-color: transparent; + padding: 0 var(--sp-3); + height: 32px; +} +.ldh-btn.is-quiet:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-btn .caret { font-size: 16px; opacity: 0.85; } + +/* Breadcrumb */ +.ldh-breadcrumb { + display: flex; align-items: center; gap: var(--sp-2); + font-size: var(--fs-sm); + color: var(--fg-muted); + min-width: 0; +} +.ldh-breadcrumb .crumb { + display: inline-flex; align-items: center; gap: var(--sp-2); + padding: 4px 8px; + border-radius: var(--r-sm); + color: var(--fg-link); + transition: background var(--dur-fast) var(--ease-out-soft); + white-space: nowrap; +} +.ldh-breadcrumb .crumb:hover { background: var(--surface-2); text-decoration: none; } +.ldh-breadcrumb .crumb .msi { color: var(--fg-muted); font-size: 18px; } +.ldh-breadcrumb .crumb.is-current { color: var(--fg-1); font-weight: var(--fw-medium); } +.ldh-breadcrumb .sep { color: var(--fg-hint); opacity: 0.6; } + +/* ---------- Breadcrumb · Drive (Google-Drive-flavored, default) ---------- + Roomy horizontal path. Ancestors are quiet medium-weight links with a hover + pill; the current resource is large + bold with a dropdown caret. */ +.ldh-bc-drive { + display: flex; align-items: center; + gap: 2px; + min-width: 0; +} +.ldh-bc-drive .bc-d-up { + display: inline-flex; align-items: center; + padding: 4px 9px; + border-radius: var(--r-md); + color: var(--fg-2); + font-size: var(--fs-base); + font-weight: var(--fw-medium); + white-space: nowrap; + transition: background var(--dur-fast) var(--ease-out-soft), color var(--dur-fast) var(--ease-out-soft); +} +.ldh-bc-drive .bc-d-up:hover { + background: var(--surface-2); + color: var(--fg-1); + text-decoration: none; +} +.ldh-bc-drive .bc-d-sep { + color: var(--fg-hint); + font-size: 18px; + opacity: 0.7; + flex-shrink: 0; +} +.ldh-bc-drive .bc-d-here { + display: inline-flex; align-items: center; + padding: 4px 9px; + border-radius: var(--r-md); + font: inherit; + color: var(--fg-1); + min-width: 0; +} +.ldh-bc-drive .bc-d-name { + font-size: var(--fs-base); + font-weight: var(--fw-medium); + color: var(--fg-1); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; +} + +/* ---------- Breadcrumb · Stack (modern hero) ---------- + Two stacked lines in the middle of the actionbar: + · Parent path — tiny uppercase mono "you came from here" trail. + · Current — large bold name + icon chip + optional class badge. + Reads as a "you are here" hero rather than a list of equal links. */ +.ldh-bc-stack { + display: flex; flex-direction: column; + justify-content: center; + gap: 2px; + min-width: 0; + line-height: 1.2; +} +.ldh-bc-stack .bc-path { + display: flex; align-items: center; gap: 4px; + font-family: var(--font-mono); + font-size: 10px; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--fg-muted); + min-width: 0; +} +.ldh-bc-stack .bc-up { + display: inline-flex; align-items: center; gap: 4px; + padding: 1px 4px; + border-radius: 4px; + color: inherit; +} +.ldh-bc-stack .bc-up:hover { + background: var(--surface-2); + color: var(--fg-2); + text-decoration: none; +} +.ldh-bc-stack .bc-up .msi { font-size: 13px; opacity: 0.7; } +.ldh-bc-stack .bc-sep { + color: var(--fg-hint); + opacity: 0.55; + font-size: 11px; +} +.ldh-bc-stack .bc-here { + display: inline-flex; align-items: center; gap: 8px; + min-width: 0; +} +.ldh-bc-stack .bc-here-ico { + width: 24px; height: 24px; + border-radius: 6px; + background: var(--bg-accent-quiet); + color: var(--ldh-blue-700); + display: inline-flex; align-items: center; justify-content: center; + flex-shrink: 0; +} +.ldh-bc-stack .bc-here-ico .msi { font-size: 16px; } +.ldh-bc-stack .bc-here-name { + font-size: 15px; + font-weight: var(--fw-semibold); + color: var(--fg-1); + letter-spacing: -0.005em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + min-width: 0; +} +.ldh-bc-stack .bc-here-badge { + font-family: var(--font-mono); + font-size: 10px; + letter-spacing: 0.02em; + color: var(--ldh-blue-700); + background: var(--bg-accent-quiet); + border: 1px solid var(--ldh-blue-100); + padding: 1px 6px; + border-radius: var(--r-pill); + flex-shrink: 0; +} + +/* ---------- Breadcrumb · Pills ---------- */ +.ldh-bc-pills { + display: flex; align-items: center; gap: 4px; + flex-wrap: wrap; + min-width: 0; +} +.ldh-bc-pills .bc-pill { + display: inline-flex; align-items: center; gap: 6px; + padding: 4px 10px; + height: 26px; + border-radius: var(--r-pill); + background: var(--surface-1); + border: 1px solid transparent; + color: var(--fg-2); + font-size: var(--fs-sm); + white-space: nowrap; + transition: background var(--dur-fast) var(--ease-out-soft), color var(--dur-fast) var(--ease-out-soft); +} +.ldh-bc-pills .bc-pill:hover { background: var(--bg-hover); color: var(--fg-1); text-decoration: none; } +.ldh-bc-pills .bc-pill.is-current { + background: var(--bg-accent-quiet); + border-color: var(--ldh-blue-100); + color: var(--ldh-blue-700); + font-weight: var(--fw-medium); +} +.ldh-bc-pills .bc-pill .msi { font-size: 14px; opacity: 0.85; } +.ldh-bc-pills .bc-sep { + color: var(--fg-hint); + font-size: 14px; + opacity: 0.7; +} + +/* ---------- Breadcrumb · Compact (iOS-style back + current) ---------- */ +.ldh-bc-compact { + display: inline-flex; align-items: center; gap: 8px; + min-width: 0; +} +.ldh-bc-compact .bc-back { + display: inline-flex; align-items: center; gap: 2px; + padding: 4px 8px 4px 4px; + border-radius: var(--r-sm); + color: var(--fg-link); + font-size: var(--fs-sm); + font-weight: var(--fw-medium); + white-space: nowrap; +} +.ldh-bc-compact .bc-back:hover { background: var(--surface-2); text-decoration: none; } +.ldh-bc-compact .bc-back .msi { font-size: 14px; } +.ldh-bc-compact .bc-divider { + width: 1px; height: 20px; + background: var(--border-default); +} +.ldh-bc-compact .bc-here-compact { + display: inline-flex; align-items: center; gap: 6px; + font-size: var(--fs-sm); + font-weight: var(--fw-semibold); + color: var(--fg-1); + white-space: nowrap; +} +.ldh-bc-compact .bc-here-compact .msi { + color: var(--ldh-blue-700); +} + +/* The Stack style is taller than the rest. Adjust actionbar vertical padding + to keep the row visually balanced regardless of style. */ +.ldh-actionbar--bc-stack { padding-top: var(--sp-2); padding-bottom: var(--sp-2); } +.ldh-actionbar--bc-drive { padding-top: var(--sp-2); padding-bottom: var(--sp-2); } + +/* ───────────────────────────────────────────────────────────────────────── + Tweak-driven overrides — toggled by data-attributes on . + Set by index.html based on the Tweaks panel state. + ───────────────────────────────────────────────────────────────────────── */ + +/* Predicate IRIs — "always" pins the IRI label above the human label even + when the row isn't hovered. */ +html[data-tweak-pred-iris="always"] .ldh-prop-group > .label .pred-iri { + opacity: 1; + transform: translateY(0); + pointer-events: auto; + user-select: text; +} + +/* Density — compact tightens row padding across the property editor. */ +html[data-tweak-density="compact"] .ldh-prop-row > .value, +html[data-tweak-density="compact"] .ldh-prop-row > .row-actions { + padding-top: 4px; + padding-bottom: 4px; +} +html[data-tweak-density="compact"] .ldh-prop-group > .label { + padding-top: 4px; + padding-bottom: 4px; +} +html[data-tweak-density="compact"] .ldh-actionbar { + padding-top: 4px; + padding-bottom: 4px; +} +html[data-tweak-density="compact"] .ldh-block-body { padding: var(--sp-3) 0; } + +/* Header style — subtle = solid dark navy, no gradient. Flat = light card. */ +html[data-tweak-header="subtle"] .ldh-header { + background: var(--ldh-blue-900, #0a1230); +} +html[data-tweak-header="subtle"] .ldh-header::before { opacity: 0; } +html[data-tweak-header="flat"] .ldh-header { + background: var(--bg-card); + color: var(--fg-1); + border-bottom: 1px solid var(--border-default); +} +html[data-tweak-header="flat"] .ldh-header::before { opacity: 0; } +html[data-tweak-header="flat"] .ldh-wordmark { color: var(--fg-1); } +html[data-tweak-header="flat"] .ldh-wordmark .mark { + background: linear-gradient(135deg, var(--ldh-blue-400), var(--ldh-violet-400)); +} +html[data-tweak-header="flat"] .ldh-address { + background: var(--surface-1); + border-color: var(--border-default); + color: var(--fg-1); +} +html[data-tweak-header="flat"] .ldh-address input { color: var(--fg-1); } +html[data-tweak-header="flat"] .ldh-address input::placeholder { color: var(--fg-muted); } +html[data-tweak-header="flat"] .ldh-address .msi { color: var(--fg-muted); } +html[data-tweak-header="flat"] .ldh-avatar { border: 2px solid var(--border-default); } + +/* Block edges — sharp = no radius, borderless = no border + no radius. */ +html[data-tweak-block-edges="sharp"] .ldh-block, +html[data-tweak-block-edges="sharp"] .ldh-view { + border-radius: 0; +} +html[data-tweak-block-edges="borderless"] .ldh-block, +html[data-tweak-block-edges="borderless"] .ldh-view { + border: 0; + border-radius: 0; + box-shadow: none; +} +html[data-tweak-block-edges="borderless"] .ldh-block-head { + border-bottom: 1px solid var(--border-default); +} + +/* Flow — the document treatment: blocks dissolve their card frame (no fill, + border, radius or shadow); the data they contain (grid cards, chart plots, + statement rows) keeps its own surfaces. Consecutive blocks are separated by + a hairline + even vertical rhythm, so prose and structured views interleave + as one continuous reading surface rather than a stack of widgets. */ +html[data-tweak-block-edges="flow"] .ldh-block, +html[data-tweak-block-edges="flow"] .ldh-view { + background: transparent; + border: 0; + border-radius: 0; + box-shadow: none; +} +html[data-tweak-block-edges="flow"] .ldh-block:hover { + box-shadow: none; + transform: none; +} +html[data-tweak-block-edges="flow"] .ldh-content { gap: 0; } +html[data-tweak-block-edges="flow"] .ldh-block-row { padding: var(--sp-6) 0; } +html[data-tweak-block-edges="flow"] .ldh-block-row + .ldh-block-row { + border-top: 1px solid var(--border-default); +} +/* …but data-visualisation bodies still want a white ground — a chart plotted + straight onto the tinted floor reads as unanchored. Plate the chart body + (its own controls/canvas padding supplies the inset) so the plot sits on a + clean surface while prose blocks stay transparent. */ +html[data-tweak-block-edges="flow"] .ldh-block-body:has(> .chart-canvas), +html[data-tweak-block-edges="flow"] .ldh-block-body:has(> .chart-controls) { + background: var(--surface-0); + border: 1px solid var(--border-default); + border-radius: var(--r-md); + padding: 0; + overflow: hidden; +} +/* Resource blocks are structured data surfaces too: the statement list — and + especially a media-header block, whose full-bleed image must keep its corners + clipped — stay on a white card in flow mode (like charts), so the description + doesn't float transparent over the tinted floor. */ +html[data-tweak-block-edges="flow"] .ldh-block:has(.ldh-edit-form) { + background: var(--bg-card); + border: 1px solid var(--border-default); + border-radius: var(--r-lg); + overflow: hidden; +} + +/* Action toolbar (right cluster) */ +.ldh-toolbar { + display: flex; align-items: center; gap: var(--sp-1); + color: var(--fg-muted); +} +.ldh-toolbar .ts { + font-family: var(--font-mono); + font-size: var(--fs-xs); + color: var(--fg-hint); + margin-right: var(--sp-3); + white-space: nowrap; +} +.ldh-toolbar .tb { + width: 36px; height: 36px; + display: inline-flex; align-items: center; justify-content: center; + background: transparent; + border: 0; border-radius: var(--r-sm); + color: var(--fg-2); + transition: background var(--dur-fast) var(--ease-out-soft), color var(--dur-fast) var(--ease-out-soft); +} +.ldh-toolbar .tb:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-toolbar .tb.is-danger:hover { background: var(--danger-50); color: var(--danger-500); } +.ldh-toolbar .divider { + width: 1px; height: 20px; background: var(--border-default); margin: 0 var(--sp-2); +} + +/* ─── Redesigned action cluster (declutter): mode · contextual primary · ⋯ ── */ +.ldh-actions { display: flex; align-items: center; gap: var(--sp-1); color: var(--fg-muted); } +.ldh-actions-div { width: 1px; height: 20px; background: var(--border-default); margin: 0 var(--sp-2); } +.ldh-actions .ldh-btn .msi { font-size: 18px; } + +/* Document dateTime as quiet metadata — never a control */ +.ldh-ab-ts { + display: inline-flex; align-items: center; gap: 4px; + font-family: var(--font-mono); font-size: var(--fs-xs); + color: var(--fg-hint); white-space: nowrap; flex-shrink: 0; +} +.ldh-ab-ts .msi { font-size: 14px; opacity: 0.7; } + +/* Overflow kebab */ +.ldh-of-wrap { position: relative; display: inline-flex; } +.ldh-of-wrap .tb { + width: 36px; height: 36px; + display: inline-flex; align-items: center; justify-content: center; + border: 0; background: transparent; border-radius: var(--r-md); + color: var(--fg-muted); cursor: pointer; + transition: background var(--dur-fast) var(--ease-out-soft), color var(--dur-fast) var(--ease-out-soft); +} +.ldh-of-wrap .tb:hover, .ldh-of-wrap.is-open .tb { background: var(--bg-hover); color: var(--fg-1); } +.ldh-of-menu { + position: absolute; top: calc(100% + 6px); right: 0; z-index: 50; + min-width: 184px; padding: 6px; + background: var(--surface-0); border: 1px solid var(--border-default); + border-radius: var(--r-md); box-shadow: var(--shadow-lg); + display: flex; flex-direction: column; gap: 2px; +} +.ldh-of-menu .it { + display: flex; align-items: center; gap: var(--sp-2); + padding: 8px 10px; border: 0; background: transparent; cursor: pointer; + border-radius: var(--r-sm); font: inherit; font-size: var(--fs-sm); + color: var(--fg-2); text-align: left; +} +.ldh-of-menu .it:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-of-menu .it.is-danger { color: var(--danger-500); } +.ldh-of-menu .it.is-danger:hover { background: var(--danger-50); } +.ldh-of-menu .it .msi { font-size: 18px; } +.ldh-of-menu .it-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; } +.ldh-of-menu .it-hint { font-size: var(--fs-xs); color: var(--ink-4); } +.ldh-of-menu .it:hover .it-hint { color: var(--fg-hint); } +.ldh-of-menu .it.is-danger .it-hint { color: var(--ink-4); } +.ldh-of-div { height: 1px; background: var(--border-default); margin: 4px 2px; } + +/* Mid zone (breadcrumb + timestamp) for zoned/contextual single-row layouts. + The timestamp pushes to the right edge of the zone (just before the actions), + so the "last modified" stamp reads as right-aligned metadata. */ +.ldh-actionbar--zoned .ab-mid, +.ldh-actionbar--contextual .ab-mid { + display: flex; align-items: center; gap: var(--sp-4); min-width: 0; +} +.ldh-actionbar--zoned .ab-mid .ldh-ab-ts, +.ldh-actionbar--contextual .ab-mid .ldh-ab-ts { margin-left: auto; padding-left: var(--sp-4); } + +/* TWO-TIER — location line above, controls line below */ +.ldh-actionbar--twotier { + display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-2); +} +.ldh-actionbar--twotier .ab-context { + display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-width: 0; +} +.ldh-actionbar--twotier .ab-controls { display: flex; align-items: center; gap: var(--sp-4); } +.ldh-actionbar--twotier .ab-spacer { flex: 1; } + +/* CONTEXTUAL — minimal at rest; secondary actions (Edit + ⋯) reveal on hover/ + focus of the bar. Mode switcher stays visible as the one persistent control. */ +.ldh-actionbar--contextual .ldh-actions .ldh-btn, +.ldh-actionbar--contextual .ldh-actions .ldh-of-wrap, +.ldh-actionbar--contextual .ldh-actions .ldh-actions-div { + opacity: 0; transition: opacity var(--dur-base) var(--ease-out-soft); +} +.ldh-actionbar--contextual:hover .ldh-actions .ldh-btn, +.ldh-actionbar--contextual:focus-within .ldh-actions .ldh-btn, +.ldh-actionbar--contextual:hover .ldh-actions .ldh-of-wrap, +.ldh-actionbar--contextual:focus-within .ldh-actions .ldh-of-wrap, +.ldh-actionbar--contextual:hover .ldh-actions .ldh-actions-div, +.ldh-actionbar--contextual:focus-within .ldh-actions .ldh-actions-div { opacity: 1; } + +/* Mode switcher — segmented dropdown */ +.ldh-mode { + position: relative; + display: inline-flex; align-items: center; gap: var(--sp-2); + height: 36px; + padding: 0 var(--sp-3); + background: var(--surface-2); + border: 1px solid var(--border-default); + border-radius: var(--r-md); + color: var(--fg-2); + font-size: var(--fs-sm); + font-weight: var(--fw-medium); + margin-right: var(--sp-2); +} +.ldh-mode > button { background: transparent; border: 0; padding: 0; color: inherit; font: inherit; } +.ldh-mode .label-row { display: inline-flex; align-items: center; gap: var(--sp-2); } +.ldh-mode .label { letter-spacing: 0.02em; } +.ldh-mode .modes-pop { + position: absolute; top: calc(100% + 6px); right: 0; + min-width: 220px; + background: var(--surface-0); + border: 1px solid var(--border-default); + border-radius: var(--r-md); + box-shadow: var(--shadow-lg); + padding: var(--sp-1); + display: none; + z-index: 50; +} +.ldh-mode.is-open .modes-pop { display: block; } +.ldh-mode .mi { + display: flex; align-items: center; gap: var(--sp-3); + padding: var(--sp-2) var(--sp-3); + font-size: var(--fs-sm); color: var(--fg-2); + border-radius: var(--r-sm); + width: 100%; + background: transparent; border: 0; + cursor: pointer; + text-align: left; +} +.ldh-mode .mi:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-mode .mi.is-active { background: var(--ldh-blue-50); color: var(--ldh-blue-700); font-weight: var(--fw-medium); } +.ldh-mode .mi .msi { color: var(--fg-muted); } +.ldh-mode .mi.is-active .msi { color: var(--ldh-blue-600); } +.ldh-mode .mi .desc { display: block; font-size: 11px; color: var(--fg-hint); font-weight: 400; margin-top: 1px; } +.ldh-mode .mi .label-col { flex: 1; } + +/* ---------- Main layout ---------- */ +.ldh-main { + flex: 1; + display: grid; + grid-template-columns: minmax(0, 1fr); + gap: var(--sp-5); + padding: var(--sp-5) var(--sp-6); + max-width: var(--container-xl); + width: 100%; + margin: 0 auto; + align-items: start; +} +.ldh-main.is-flush { padding: var(--sp-3) var(--sp-3); max-width: none; } +.ldh-content { + display: flex; flex-direction: column; gap: var(--sp-6); + min-width: 0; +} + +/* Backlinks / related panel */ +.ldh-panel { + background: var(--bg-card); + border: 1px solid var(--border-default); + border-radius: var(--r-lg); + overflow: hidden; +} +.ldh-panel .ph { + display: flex; align-items: center; justify-content: space-between; + padding: var(--sp-3) var(--sp-4); + background: var(--surface-1); + border-bottom: 1px solid var(--border-default); +} +.ldh-panel .ph .title { + font-family: var(--font-mono); + font-size: 11px; + letter-spacing: var(--tracking-wide); + text-transform: uppercase; + color: var(--fg-muted); +} +.ldh-panel.is-collapsed .pb { display: none; } +.ldh-panel.is-collapsed .ph { border-bottom: 0; } +.ldh-panel .pb { padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); } +.ldh-panel .pb a { display: block; font-size: var(--fs-sm); padding: 4px 0; color: var(--fg-2); } +.ldh-panel .pb a:hover { color: var(--fg-link); } +.ldh-panel .pb .empty { font-size: var(--fs-sm); color: var(--fg-hint); padding: 4px 0; } + +/* ---------- Footer ---------- */ +.ldh-footer { + margin-top: var(--sp-12); + padding: var(--sp-10) var(--sp-6) var(--sp-8); + background: var(--surface-1); + border-top: 1px solid var(--border-default); +} +.ldh-footer .cols { + max-width: var(--container-xl); + margin: 0 auto; + display: grid; + grid-template-columns: 1.4fr repeat(4, 1fr); + gap: var(--sp-8); +} +.ldh-footer .col .ftitle { + font-family: var(--font-mono); + font-size: 11px; + letter-spacing: var(--tracking-wide); + text-transform: uppercase; + color: var(--fg-muted); + margin: 0 0 var(--sp-3); +} +.ldh-footer .col a { display: block; padding: 4px 0; font-size: var(--fs-sm); color: var(--fg-2); } +.ldh-footer .col a:hover { color: var(--fg-link); } +.ldh-footer .brand-col p { + font-size: var(--fs-sm); color: var(--fg-muted); line-height: var(--lh-base); max-width: 280px; margin: var(--sp-3) 0 0; +} +.ldh-footer .legal { + max-width: var(--container-xl); + margin: var(--sp-8) auto 0; + padding-top: var(--sp-4); + border-top: 1px solid var(--border-default); + display: flex; justify-content: space-between; + font-size: var(--fs-xs); + color: var(--fg-hint); + font-family: var(--font-mono); +} + +/* ---------- Generic Block (view block wrapper) ---------- */ +.ldh-block { + /* positioned: the anchor for the block-scoped .ldh-drawer */ + position: relative; + background: var(--bg-card); + border: 1px solid var(--border-default); + border-radius: var(--r-lg); + /* no overflow clipping: dropdown menus (.modes-pop, .ldh-add-menu) render inline inside the card and must escape its box; the block body's inset keeps content clear of the corner arcs */ + transition: box-shadow var(--dur-base) var(--ease-out-soft), border-color var(--dur-base) var(--ease-out-soft); +} +.ldh-block:hover { box-shadow: var(--shadow-sm); } +/* hover-lift transforms (retro themes) make the card a stacking context, trapping its inline dropdowns below later positioned rows; while a popup is open the card must win the paint order over subsequent blocks (but stay under the z-70 action bar) */ +.ldh-block:has(.is-open) { position: relative; z-index: 60; } +.ldh-block.is-quiet { border: 0; background: transparent; } +.ldh-block.is-quiet:hover { box-shadow: none; } +.ldh-block-head { + display: flex; align-items: flex-start; justify-content: space-between; + padding: var(--sp-5) var(--sp-6) var(--sp-3); + gap: var(--sp-4); +} +.ldh-block-head .ttl { font-size: var(--fs-xl); font-weight: var(--fw-semibold); color: var(--fg-1); margin: 0; line-height: var(--lh-snug); letter-spacing: var(--tracking-snug); } +/* Hero text block — the lead resource's title reads at page-title scale, not + block-heading scale, so the top of a document anchors the page. */ +.ldh-block-head .ttl--hero { font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); } +.ldh-block-head .sub { display: block; font-size: var(--fs-sm); color: var(--fg-muted); margin-top: 4px; font-weight: 400; } +.ldh-block-head .actions { display: flex; gap: var(--sp-1); } +.ldh-block-head .actions .tb { + width: 32px; height: 32px; + display: inline-flex; align-items: center; justify-content: center; + background: transparent; border: 0; border-radius: var(--r-sm); + color: var(--fg-muted); +} +.ldh-block-head .actions .tb:hover { background: var(--bg-hover); color: var(--fg-1); } +/* Delete (×) — quiet at rest, danger on hover. The block-removal affordance. */ +.ldh-block-head .actions .tb-danger:hover { background: var(--danger-50); color: var(--danger-500); } + +/* Links button — opens the block links popover (backlinks). The button always + sits inside its .links-nav anchor, so one selector covers every host: block + head actions, the view toolbar's right zone, the content block's corner. */ +.links-nav > .tb-links { + height: 32px; + min-width: 32px; + padding: 0 8px 0 6px; + display: inline-flex; align-items: center; justify-content: center; + gap: 4px; + background: var(--bg-accent-quiet); + color: var(--ldh-blue-700); + border: 1px solid var(--ldh-blue-100); + border-radius: var(--r-sm); +} +.links-nav > .tb-links:hover { background: var(--ldh-blue-100); color: var(--ldh-blue-700); } +.links-nav > .tb-links.is-on { background: var(--ldh-blue-600); color: #fff; border-color: var(--ldh-blue-600); } + +.hero-actions { + position: absolute; + top: var(--sp-4); + right: var(--sp-4); + display: flex; + gap: var(--sp-1); + z-index: 2; +} +.hero-actions .tb-links { + height: 32px; + display: inline-flex; align-items: center; + border-radius: var(--r-sm); + background: rgba(255,255,255,0.72); + backdrop-filter: blur(6px); + border-color: rgba(255,255,255,0.85); +} + +/* Block links popover — backlinks as jump-off navigation, anchored to the + header/toolbar links button. Modeled on .facet-pop; content lazy-loads on + first open. */ +.links-nav { position: relative; } +.links-pop { + position: absolute; top: calc(100% + 6px); right: 0; + min-width: 260px; max-width: 320px; + background: var(--surface-0); border: 1px solid var(--border-default); + border-radius: var(--r-md); box-shadow: var(--shadow-lg); + padding: var(--sp-2); + z-index: 40; + display: none; +} +.links-nav.is-open .links-pop { display: block; } +.links-pop .dh2 { + margin: 0; + padding: var(--sp-2) var(--sp-2) 4px; + font-family: var(--font-mono); font-size: 10px; + letter-spacing: var(--tracking-wide); text-transform: uppercase; + font-weight: var(--fw-medium); + color: var(--fg-muted); +} +.links-pop .dgroup { display: flex; flex-direction: column; gap: 2px; } +.links-pop .drow { + display: flex; align-items: center; gap: 8px; + padding: 6px 8px; + border-radius: var(--r-sm); + text-decoration: none; + color: var(--fg-2); + font-size: var(--fs-sm); + transition: background var(--dur-fast) var(--ease-out-soft); +} +.links-pop .drow:hover { background: var(--bg-hover); color: var(--fg-1); text-decoration: none; } +.links-pop .drow .msi { color: var(--fg-hint); flex-shrink: 0; } +.links-pop .drow .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } + +/* content (XHTML) blocks have no header row — their popover anchors to the + card's top right corner and surfaces on card hover, staying put while open */ +.ldh-block .block-row > .links-nav { position: absolute; top: var(--sp-3); right: var(--sp-3); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out-soft); } +.ldh-block:hover .block-row > .links-nav, .ldh-block .block-row > .links-nav.is-open { opacity: 1; } + +/* Copy-URI button — the header actions' quiet icon treatment for hosts outside + the block head: the view toolbar's right zone and the content block's corner, + where it sits left of the links button and surfaces on the same card hover */ +.ldh-view-toolbar .right .btn-copy-uri, .ldh-block .block-row > .btn-copy-uri { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: var(--r-sm); color: var(--fg-muted); } +.ldh-view-toolbar .right .btn-copy-uri:hover, .ldh-block .block-row > .btn-copy-uri:hover { background: var(--bg-hover); color: var(--fg-1); } +.ldh-block .block-row > .btn-copy-uri { position: absolute; top: var(--sp-3); right: calc(var(--sp-3) + 32px + var(--sp-1)); opacity: 0; transition: opacity var(--dur-fast) var(--ease-out-soft); } +.ldh-block:hover .block-row > .btn-copy-uri { opacity: 1; } +.ldh-block-body { padding: 0 var(--sp-6) var(--sp-6); } +.ldh-block-body.is-flush { padding: 0; } +.ldh-block-foot { + display: flex; align-items: center; justify-content: space-between; + padding: var(--sp-3) var(--sp-6); + border-top: 1px solid var(--border-default); + background: var(--surface-1); +} + +/* Section header — for grouping blocks in ContentMode */ +.ldh-section { + display: flex; flex-direction: column; gap: var(--sp-2); + margin-top: var(--sp-4); +} +.ldh-section .eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ldh-blue-600); } +.ldh-section h2 { margin: 0; font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-snug); color: var(--fg-1); } +.ldh-section p { margin: 4px 0 0; color: var(--fg-2); max-width: 56ch; } + +/* Hero block — uses pastel gradient for the document intro */ +.ldh-hero { + position: relative; + background: var(--grad-aurora); + border: 1px solid var(--border-default); + border-radius: var(--r-lg); + padding: var(--sp-10) var(--sp-8); + overflow: hidden; +} +.ldh-hero::before { + content: ""; position: absolute; inset: 0; + background-image: radial-gradient(circle at 1px 1px, rgba(11,14,20,0.06) 1px, transparent 1.4px); + background-size: 24px 24px; + opacity: 0.7; + pointer-events: none; +} +.ldh-hero > * { position: relative; } + +/* Dark theme: pastel hero would strand light text on a light wash — swap to the + dark accent gradient (governance: pastels/gradients are hero-only anyway). */ +:root[data-theme="dark"] .ldh-hero { + background: var(--grad-deep); + border-color: var(--line-2); +} +:root[data-theme="dark"] .ldh-hero::before { + background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.08) 1px, transparent 1.4px); +} +.ldh-hero .eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ldh-violet-700); } +.ldh-hero h1 { + margin: var(--sp-2) 0 var(--sp-3); + font-size: var(--fs-4xl); + font-weight: var(--fw-semibold); + letter-spacing: var(--tracking-tight); + color: var(--fg-1); + line-height: var(--lh-tight); +} +.ldh-hero h1 em { font-style: italic; font-family: var(--font-display); font-weight: 400; } +.ldh-hero .lede { font-size: var(--fs-md); color: var(--ink-2); max-width: 56ch; line-height: var(--lh-base); margin: 0; } +.ldh-hero .lede + p { margin-top: var(--sp-3); } + +/* Chart controls (re-styled ' + - '', - - boxSelector: ".wym_box", - toolsSelector: ".wym_tools", - toolsListSelector: " ul", - containersSelector: ".wym_containers", - classesSelector: ".wym_classes", - htmlSelector: ".wym_html", - iframeSelector: ".wym_iframe iframe", - iframeBodySelector: ".wym_iframe", - statusSelector: ".wym_status", - toolSelector: ".wym_tools a", - containerSelector: ".wym_containers a", - classSelector: ".wym_classes a", - htmlValSelector: ".wym_html_val", - - updateSelector: ".wymupdate", - updateEvent: "click", - - stringDelimiterLeft: "{", - stringDelimiterRight: "}", - - preInit: null, - preBind: null, - postInit: null - - }, options); - - options = jQuery.extend(WYMeditor.DEFAULT_DIALOG_OPTIONS, options); - - return $textareas.each(function () { - var textarea = this; - // Assigning to _wym because the return value from new isn't - // actually used, but we need to use new to properly change the - // prototype - textarea._wym = new WYMeditor.editor(jQuery(textarea), options); - }); -}; - -// Enable accessing of wymeditor instances via jQuery.wymeditors -jQuery.extend({ - wymeditors: function (i) { - return WYMeditor.INSTANCES[i]; - } -}); - -jQuery.extend({ - getWymeditorByTextarea: function (textarea) { - var i; - if ( - !( - textarea && - textarea.tagName && - textarea.tagName.toLowerCase() === 'textarea' - ) - ) { - throw "jQuery.getWymeditorByTextarea requires a textarea element."; - } - for (i = 0; i < WYMeditor.INSTANCES.length; i++) { - if (textarea === WYMeditor.INSTANCES[i].element[0]) { - return WYMeditor.INSTANCES[i]; - } - } - return false; - } -}); - -/** - jQuery.copyPropsFromObjectToObject - ===================================== - - General helper function that copies specified list of properties from a - specified origin object to a specified target object. - - @param origin The origin object. - @param target The target object. - @param propNames An array of strings, representing the properties to copy. -*/ -jQuery.extend({ - copyPropsFromObjectToObject: function (origin, target, propNames) { - var i, - propName, - prop, - props = {}; - - for (i = 0; i < propNames.length; i++) { - propName = propNames[i]; - prop = origin[propName]; - props[propName] = prop; - } - - jQuery.extend(target, props); - } -}); - -/** - WYMeditor.isInternetExplorerPre11 - ================================= - - Returns true if the current browser is an Internet Explorer version - previous to 11. Otherwise, returns false. -*/ -WYMeditor.isInternetExplorerPre11 = function () { - if ( - jQuery.browser.msie && - jQuery.browser.versionNumber < 11 - ) { - return true; - } - return false; -}; - -/** - WYMeditor.isInternetExplorer11OrNewer - ===================================== - - Returns true if the current browser is an Internet Explorer version 11 or - newer. Otherwise, returns false. -*/ -WYMeditor.isInternetExplorer11OrNewer = function () { - if ( - jQuery.browser.msie && - jQuery.browser.versionNumber >= 11 - ) { - return true; - } - return false; -}; - -/** - WYMeditor._computeWymPath - ========================= - - Get the relative path to the WYMeditor core js file for usage as - a src attribute for script inclusion. - - Looks for script tags on the current page and finds the first matching - src attribute matching any of these values: - * jquery.wymeditor.pack.js - * jquery.wymeditor.min.js - * jquery.wymeditor.packed.js - * jquery.wymeditor.js - * /core.js -*/ -WYMeditor._computeWymPath = function () { - var script = jQuery( - jQuery.grep( - jQuery('script'), - function (s) { - if (!s.src) { - return null; - } - return ( - s.src.match( - /jquery\.wymeditor(\.pack|\.min|\.packed)?\.js(\?.*)?$/ - ) || - s.src.match( - /\/core\.js(\?.*)?$/ - ) - ); - } - ) - ); - if (script.length > 0) { - return script.attr('src'); - } - // We couldn't locate the base path. This will break language loading - // and other features. - WYMeditor.console.warn( - "Error determining wymPath. No base WYMeditor file located." - ); - WYMeditor.console.warn("Assuming wymPath to be the current URL"); - WYMeditor.console.warn("Please pass a correct wymPath option"); - - // Guess that the wymPath is the current directory - return ''; -}; - -/** - WYMeditor._computeBasePath - ========================== - - Get the relative path to the WYMeditor directory root based on the path to - the wymeditor base file. This path is used as the basis for loading: - * Language files - * Skins - * The popup document https://github.com/wymeditor/wymeditor/issues/731 -*/ -WYMeditor._computeBasePath = function (wymPath) { - // Strip everything after the last slash to get the base path - var lastSlashIndex = wymPath.lastIndexOf('/'); - return wymPath.substr(0, lastSlashIndex + 1); -}; - -/********** HELPERS **********/ - -// Returns true if it is a text node with whitespaces only -jQuery.fn.isPhantomNode = function () { - var $nodes = this; - if ($nodes[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - return !(/[^\t\n\r ]/.test($nodes[0].data)); - } - - return false; -}; - -/** - jQuery.fn.nextContentsUntil - =========================== - - Acts like jQuery.nextUntil() but includes text nodes and comments and only - works on the first element in the given jQuery collection.. -*/ -jQuery.fn.nextContentsUntil = function (selector, filter) { - var $nodes = this, - matched = [], - $matched, - cur = $nodes.get(0); - - selector = selector ? selector : ''; - filter = filter ? filter : ''; - - if (!cur) { - // Called on an empty selector. The sibling of nothing is nothing - return jQuery(); - } - // We don't want to include this element, only its siblings - cur = cur.nextSibling; - - while (cur) { - if (!jQuery(cur).is(selector)) { - matched.push(cur); - cur = cur.nextSibling; - } else { - break; - } - } - - $matched = jQuery(matched); - if (filter) { - return $matched.filter(filter); - } - return $matched; -}; -/** - jQuery.fn.nextAllContents - ========================= - - Acts like jQuery.nextAll() but includes text nodes and comments and only - works on the first element in the given jQuery collection.. - - Mostly cribbed from the jQuery source. -*/ -jQuery.fn.nextAllContents = function () { - var $nodes = this; - return jQuery($nodes).nextContentsUntil('', ''); -}; - -/** - jQuery.fn.prevContentsUntil - =========================== - - Acts like jQuery.prevUntil() but includes text nodes and comments and only - works on the first element in the given jQuery collection.. -*/ -jQuery.fn.prevContentsUntil = function (selector, filter) { - var $nodes = this, - matched = [], - $matched, - cur = $nodes.get(0); - - selector = selector ? selector : ''; - filter = filter ? filter : ''; - - if (!cur) { - // Called on an empty selector. The sibling of nothing is nothing - return jQuery(); - } - // We don't want to include this element, only its siblings - cur = cur.previousSibling; - - while (cur) { - if (!jQuery(cur).is(selector)) { - matched.push(cur); - cur = cur.previousSibling; - } else { - break; - } - } - - $matched = jQuery(matched); - if (filter) { - return $matched.filter(filter); - } - return $matched; -}; - -/** - jQuery.fn.prevAllContents - ========================= - - Acts like jQuery.prevAll() but includes text nodes and comments and only - works on the first element in the given jQuery collection.. - - Mostly cribbed from the jQuery source. -*/ -jQuery.fn.prevAllContents = function () { - var $nodes = this; - return jQuery($nodes).prevContentsUntil('', ''); -}; - -WYMeditor.isPhantomNode = function (n) { - if (n.nodeType === WYMeditor.NODE_TYPE.TEXT) { - return !(/[^\t\n\r ]/.test(n.data)); - } - - return false; -}; - -WYMeditor.isPhantomString = function (str) { - return !(/[^\t\n\r ]/.test(str)); -}; - -jQuery.fn.addBack = jQuery.fn.addBack ? jQuery.fn.addBack : jQuery.fn.andSelf; - -// Returns the Parents or the node itself -// `selector` = a jQuery selector -jQuery.fn.parentsOrSelf = function (selector) { - var $n = this; - - if (selector) { - return $n.parents().addBack().filter(selector); - } else { - return $n.parents().addBack(); - } -}; - -// Various helpers - -WYMeditor.Helper = { - - //replace all instances of 'old' by 'rep' in 'str' string - replaceAllInStr: function (str, old, rep) { - var rExp = new RegExp(old, "g"); - return str.replace(rExp, rep); - }, - - //insert 'inserted' at position 'pos' in 'str' string - insertAt: function (str, inserted, pos) { - return str.substr(0, pos) + inserted + str.substring(pos); - }, - - //trim 'str' string - trim: function (str) { - return str.replace(/^(\s*)|(\s*)$/gm, ''); - }, - - //Returns true if `array`` contains `thing`. Uses `===` for comparison of - //provided `thing` with contents of provided `array`. - arrayContains: function (arr, elem) { - var i; - for (i = 0; i < arr.length; i += 1) { - if (arr[i] === elem) { - return true; - } - } - return false; - }, - - //return 'item' position in 'arr' array, or -1 - indexOf: function (arr, item) { - var ret = -1, i; - for (i = 0; i < arr.length; i += 1) { - if (arr[i] === item) { - ret = i; - break; - } - } - return ret; - }, - - //return 'item' object in 'arr' array, checking its 'name' property, or null - _getFromArrayByName: function (arr, name) { - var i, item; - for (i = 0; i < arr.length; i += 1) { - item = arr[i]; - if (item.name === name) { - return item; - } - } - return null; - }, - - // naively returns all event types - // of the provided an element - // according the its property keys that - // begin with 'on' - getAllEventTypes: function (elem) { - var result = []; - for (var key in elem) { - if (key.indexOf('on') === 0 && key !== 'onmousemove') { - result.push(key.slice(2)); - } - } - return result.join(' '); - } -}; - -/** - WYMeditor._getWymClassForBrowser - ================================ - - Returns the constructor for the browser-specific wymeditor instance. - - If does not detect a supported browser, returns false; -*/ -WYMeditor._getWymClassForBrowser = function () { - - // Using https://github.com/gabceb/jquery-browser-plugin - switch (jQuery.browser.name) { - case "msie": - if (WYMeditor.isInternetExplorerPre11()) { - return WYMeditor.WymClassTridentPre7; - } else if (WYMeditor.isInternetExplorer11OrNewer()) { - return WYMeditor.WymClassTrident7; - } else { - return false; - } - break; - case "mozilla": - return WYMeditor.WymClassGecko; - case "chrome": - return WYMeditor.WymClassBlink; - case "safari": - return WYMeditor.WymClassSafari; - } - - if (jQuery.browser.webkit) { - return WYMeditor.WymClassWebKit; - } - - WYMeditor.console.warn("WYMeditor could not instantiate: this browser " + - "is not supported"); - return false; -}; - -"use strict"; -/** - editor._openPopupWindow - ======================= - - Opens a popup window, provided the `windowFeatures`. -*/ -WYMeditor.editor.prototype._openPopupWindow = function (windowFeatures) { - var wym = this, - popup, - basePath = wym._options.basePath; - - popup = window.open( - // https://github.com/wymeditor/wymeditor/issues/731 - jQuery.browser.msie ? basePath + 'popup.html' : '', - "wymPopupWindow", - windowFeatures - ); - - return popup; -}; - -/** - editor.dialog - ============= - - Open a dialog box -*/ -WYMeditor.editor.prototype.dialog = function ( - dialog, - pDialogWindowFeatures, - pBodyHtml -) { - var wym = this, - i, - DIALOGS = WYMeditor.DIALOGS, - dialogObject, - dialogWindowFeatures, - wDialog, - htmlStrReplacements, - dialogHtml, - doc, - selectedContainer, - options = wym._options; - - if (jQuery.isPlainObject(dialog)) { - // Dialog object provided. This is the documented public API way. - dialogObject = dialog; - } else if ( - // Dialog name string provided. This is undocumented. - typeof dialog === "string" && - DIALOGS.hasOwnProperty(dialog) - ) { - WYMeditor.console.warn("DEPRECATION WARNING: `dialog` method " + - "received a string dialog name. Please provide a dialog object " + - "instead."); - dialogObject = DIALOGS[dialog]; - } - - if ( - jQuery.isPlainObject(dialogObject) !== true && - typeof pBodyHtml !== "string" - ) { - throw "`dialog` method: No dialog provided"; - } - - if (dialogObject) { - if ( - dialogObject.hasOwnProperty("title") !== true || - dialogObject.hasOwnProperty("shouldOpen") !== true || - dialogObject.hasOwnProperty("getBodyHtml") !== true - ) { - throw "Expected the dialog object to contain at least `title`, " + - "`shouldOpen` and `getbodyHtml`"; - } - } - - // Return `false` early if this dialog should not open. Use the dialog's - // own function to check this. - if ( - dialogObject && - dialogObject.shouldOpen.call(wym) !== true - ) { - return false; - } - - if (pDialogWindowFeatures) { - // Provided argument - dialogWindowFeatures = pDialogWindowFeatures; - } else if (dialogObject && dialogObject.getWindowFeatures) { - // Dialog's code - dialogWindowFeatures = dialogObject.getWindowFeatures.call(wym); - } else if (options.dialogFeatures) { - // Provided option - dialogWindowFeatures = options.dialogFeatures; - } else { - // Default - dialogWindowFeatures = [ - "menubar=no", - "titlebar=no", - "toolbar=no", - "resizable=no", - "width=560", - "height=300", - "top=0", - "left=0" - ].join(","); - } - - wDialog = wym._openPopupWindow(dialogWindowFeatures); - - if ( - typeof wDialog !== "object" || - wDialog.window !== wDialog - ) { - WYMeditor.console.warn("Could not create a dialog window"); - return false; - } - - // In the case where a dialog window already exists, it will be reused. - // If it is in the background, behind another window, without the following - // `focus` call, it will remain in the background and the user may not - // understand where it is. This `focus` call brings the dialog to the - // foreground, making reasonably sure the user notices it. - wDialog.focus(); - - // Construct the dialog - dialogHtml = options.dialogHtml || String() + - '' + - '' + - '' + - '' + WYMeditor.DIALOG_TITLE + '' + - '' + - WYMeditor.DIALOG_BODY + - ''; - - // HTML template replacements - htmlStrReplacements = [ - { - placeholder: WYMeditor.DIRECTION, - replacement: options.direction - }, - { - placeholder: WYMeditor.DIALOG_TITLE, - replacement: dialogObject ? - wym._encloseString(dialogObject.title) : "Dialog" - }, - { - placeholder: WYMeditor.DIALOG_BODY, - replacement: pBodyHtml || dialogObject.getBodyHtml.call(wym) - } - ]; - - // Perform HTML template replacements - for (i = 0; i < htmlStrReplacements.length; i++) { - dialogHtml = WYMeditor.Helper.replaceAllInStr( - dialogHtml, - htmlStrReplacements[i].placeholder, - htmlStrReplacements[i].replacement - ); - } - - dialogHtml = wym.replaceStrings(dialogHtml); - - doc = wDialog.document; - doc.write(dialogHtml); - if (dialogObject && dialogObject.getBodyClass) { - jQuery(doc.body).addClass(dialogObject.getBodyClass.call(wym)); - } - doc.close(); - - selectedContainer = wym.selectedContainer(); - - wDialog.onbeforeunload = function () { - wym.focusOnDocument(); - }; - - // Pre-init function - if (jQuery.isFunction(options.preInitDialog)) { - options.preInitDialog(wym, wDialog); - } - - // Dialog-specific initialization - if (dialogObject && dialogObject.initialize) { - dialogObject.initialize.call(wym, wDialog); - } - - if (dialogObject && dialogObject.submitHandler) { - jQuery("form", doc).submit(function () { - dialogObject.submitHandler.call(wym, wDialog); - }); - } - - // Cancel button - jQuery(options.cancelSelector, doc).click(function () { - wDialog.close(); - }); - - // Post-init function - if (jQuery.isFunction(options.postInitDialog)) { - options.postInitDialog(wym, wDialog); - } - - return wDialog; -}; - -/* - * An object of default dialogs. - * - * See API documentation for the `dialog` method. - */ -WYMeditor.DIALOGS = { - CreateLink: { - title: "Link", - shouldOpen: function () { - var wym = this, - selectedContainer; - if (wym.hasSelection() !== true) { - return false; - } - selectedContainer = wym.selectedContainer(); - if (selectedContainer === false) { - return false; - } - if ( - wym.selection().isCollapsed && - selectedContainer.tagName.toLowerCase() !== "a" - ) { - return false; - } - return true; - }, - getBodyHtml: function () { - var wym = this; - return wym._options.dialogLinkHtml || String() + - '
' + - '
' + - '' + - '{Link}' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '
'; - }, - getBodyClass: function () { - var wym = this; - return wym._options.dialogSelectorLink || "wym_dialog_link"; - }, - initialize: function (wDialog) { - var wym = this, - doc = wDialog.document, - options = wym._options, - selectedContainer = wym.selectedContainer(), - $hrefInput, - $titleInput, - $relInput, - currentHref, - currentTitle, - currentRel; - - if (!selectedContainer) { - return; - } - - $hrefInput = jQuery(options.hrefSelector, doc); - $titleInput = jQuery(options.titleSelector, doc); - $relInput = jQuery(options.relSelector, doc); - - currentHref = jQuery(selectedContainer).attr(WYMeditor.HREF); - currentTitle = jQuery(selectedContainer).attr(WYMeditor.TITLE); - currentRel = jQuery(selectedContainer).attr(WYMeditor.REL); - - $hrefInput.val(currentHref); - $titleInput.val(currentTitle); - $relInput.val(currentRel); - }, - submitHandler: function (wDialog) { - var wym = this, - options = wym._options, - href = jQuery(options.hrefSelector, wDialog.document).val(), - title = jQuery(options.titleSelector, wDialog.document).val(), - rel = jQuery(options.relSelector, wDialog.document).val(); - - wym.link({ - href: href, - title: title, - rel: rel - }); - wDialog.close(); - } - }, - InsertImage: { - title: "Image", - shouldOpen: function () { - var wym = this, - selectedImage = wym.getSelectedImage(); - if ( - selectedImage && - selectedImage.tagName && - selectedImage.tagName.toLowerCase() === "img" - ) { - return true; - } - return wym.hasSelection(); - }, - getBodyHtml: function () { - var wym = this; - return wym._options.dialogImageHtml || String() + - '
' + - '
' + - '' + - '{Image}' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '
'; - }, - getBodyClass: function () { - var wym = this; - return wym._options.dialogImageSelector || "wym_dialog_image"; - }, - initialize: function (wDialog) { - var wym = this, - doc = wDialog.document, - options = wym._options, - selectedImage = wym.getSelectedImage(), - $srcInput, - $titleInput, - $altInput, - currentSrc, - currentTitle, - currentAlt; - - if (!selectedImage) { - return; - } - - $srcInput = jQuery(options.srcSelector, doc); - $titleInput = jQuery(options.titleSelector, doc); - $altInput = jQuery(options.altSelector, doc); - - currentSrc = jQuery(selectedImage).attr(WYMeditor.SRC); - currentTitle = jQuery(selectedImage).attr(WYMeditor.TITLE); - currentAlt = jQuery(selectedImage).attr(WYMeditor.ALT); - - $srcInput.val(currentSrc); - $titleInput.val(currentTitle); - $altInput.val(currentAlt); - }, - submitHandler: function (wDialog) { - var wym = this, - options = wym._options, - imgAttrs, - selectedImage = wym.getSelectedImage(); - - imgAttrs = { - src: jQuery(options.srcSelector, wDialog.document).val(), - title: jQuery(options.titleSelector, wDialog.document).val(), - alt: jQuery(options.altSelector, wDialog.document).val() - }; - - wym.focusOnDocument(); - - if (selectedImage) { - wym._updateImageAttrs(selectedImage, imgAttrs); - wym.registerModification(); - } else { - wym.insertImage(imgAttrs); - } - wDialog.close(); - } - }, - InsertTable: { - title: "Table", - shouldOpen: function () { - var wym = this; - if ( - wym.hasSelection() !== true || - wym.selection().isCollapsed !== true - ) { - return false; - } - return true; - }, - getBodyHtml: function () { - var wym = this; - return wym._options.dialogTableHtml || String() + - '
' + - '
' + - '' + - '{Table}' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '
'; - }, - getBodyClass: function () { - var wym = this; - return wym._options.dialogTableSelector || "wym_dialog_table"; - }, - submitHandler: function (wDialog) { - var wym = this, - options = wym._options, - doc = wDialog.document, - numRows = jQuery(options.rowsSelector, doc).val(), - numColumns = jQuery(options.colsSelector, doc).val(), - caption = jQuery(options.captionSelector, doc).val(), - summary = jQuery(options.summarySelector, doc).val(); - - wym.insertTable(numRows, numColumns, caption, summary); - wDialog.close(); - } - }, - Paste: { - title: "Paste_From_Word", - shouldOpen: function () { - var wym = this; - return wym.hasSelection(); - }, - getBodyHtml: function () { - var wym = this; - return wym._options.dialogPasteHtml || String() + - '
' + - '' + - '
' + - '{Paste_From_Word}' + - '
' + - '' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '
'; - }, - getBodyClass: function () { - var wym = this; - return wym._options.dialogPasteSelector || "wym_dialog_paste"; - }, - submitHandler: function (wDialog) { - var wym = this, - sText; - sText = jQuery(wym._options.textSelector, wDialog.document).val(); - wym.paste(sText); - wDialog.close(); - } - }, - Preview: { - title: "Preview", - shouldOpen: function () { - return true; - }, - getBodyHtml: function () { - var wym = this; - return wym._options.dialogPreviewHtml || wym.html(); - }, - getWindowFeatures: function () { - return [ - "menubar=no", - "titlebar=no", - "toolbar=no", - "resizable=no", - "width=560", - "height=300", - "top=0", - "left=0", - "scrollbars=yes" - ].join(","); - }, - getBodyClass: function () { - var wym = this; - return wym._options.dialogPreviewSelector || "wym_dialog_preview"; - } - } -}; - -WYMeditor.DIALOG_TITLE = "{Wym_Dialog_Title}"; -WYMeditor.DIALOG_BODY = "{Wym_Dialog_Body}"; -WYMeditor.DIALOG_BUTTON_SELECTOR = ".wym_opens_dialog a"; - -WYMeditor.DEFAULT_DIALOG_OPTIONS = { - hrefSelector: ".wym_href", - srcSelector: ".wym_src", - titleSelector: ".wym_title", - relSelector: ".wym_rel", - altSelector: ".wym_alt", - textSelector: ".wym_text", - rowsSelector: ".wym_rows", - colsSelector: ".wym_cols", - captionSelector: ".wym_caption", - summarySelector: ".wym_summary", - submitSelector: "form", - cancelSelector: ".wym_cancel", - previewSelector: "", - dialogLinkSelector: ".wym_dialog_link", - dialogImageSelector: ".wym_dialog_image", - dialogTableSelector: ".wym_dialog_table", - dialogPasteSelector: ".wym_dialog_paste", - dialogPreviewSelector: ".wym_dialog_preview" -}; - -/* jshint evil: true, camelcase: false, maxlen: 100 */ -/* global -$, rangy */ -"use strict"; - -/** - WYMeditor.editor._init - ====================== - - Initialize a wymeditor instance, including detecting the - current browser and enabling the browser-specific subclass. -*/ -WYMeditor.editor.prototype._init = function () { - // Load the browser-specific subclass - // If this browser isn't supported, do nothing - var wym = this, - WymClass, - browserInstance, - SaxListener, - prop, - h, - iframeHtml, - boxHtml, - aTools, - sTools, - oTool, - sTool, - i, - aClasses, - sClasses, - oClass, - sClass, - aContainers, - sContainers, - sContainer, - oContainer; - - // Get the constructor for the browser-specific instance - WymClass = WYMeditor._getWymClassForBrowser(); - - if (!WymClass) { - // We don't support this browser. Don't initialize. - return; - } - - // Initialize the browser-specific instance - browserInstance = new WymClass(wym); - - if (jQuery.isFunction(wym._options.preInit)) { - wym._options.preInit(wym); - } - - wym.parser = null; - wym.helper = null; - - SaxListener = new WYMeditor.XhtmlSaxListener(); - wym.parser = new WYMeditor.XhtmlParser(SaxListener); - - wym.helper = new WYMeditor.XmlHelper(); - - // Extend the editor object with the browser-specific version. - // We're not using jQuery.extend because we *want* to copy properties via - // the prototype chain - for (prop in browserInstance) { - /*jshint forin: false*/ - // Explicitly not using hasOwnProperty for the inheritance here - // because we want to go up the prototype chain to get all of the - // browser-specific editor methods. This is kind of a code smell, - // but works just fine. - wym[prop] = browserInstance[prop]; - } - - // Load wymbox - wym._box = jQuery(wym.element).hide().after( - wym._options.boxHtml - ).next().addClass( - 'wym_box_' + wym._index - ); - - // Store the instance index and replaced element in wymbox - // but keep it compatible with jQuery < 1.2.3, see #122 - if (jQuery.isFunction(jQuery.fn.data)) { - jQuery.data(wym._box.get(0), WYMeditor.WYM_INDEX, wym._index); - jQuery.data(wym.element.get(0), WYMeditor.WYM_INDEX, wym._index); - } - - h = WYMeditor.Helper; - - // Construct the iframe - iframeHtml = wym._options.iframeHtml; - iframeHtml = h.replaceAllInStr( - iframeHtml, - WYMeditor.IFRAME_BASE_PATH, - wym._options.iframeBasePath - ); - - // Construct wymbox - boxHtml = jQuery(wym._box).html(); - - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.LOGO, wym._options.logoHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.TOOLS, wym._options.toolsHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.CONTAINERS, wym._options.containersHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.CLASSES, wym._options.classesHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.HTML, wym._options.htmlHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.IFRAME, iframeHtml); - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.STATUS, wym._options.statusHtml); - - // Construct the tools list - aTools = eval(wym._options.toolsItems); - sTools = ""; - - for (i = 0; i < aTools.length; i += 1) { - oTool = aTools[i]; - sTool = ''; - if (oTool.name && oTool.title) { - sTool = wym._options.toolsItemHtml; - } - sTool = h.replaceAllInStr(sTool, WYMeditor.TOOL_NAME, oTool.name); - sTool = h.replaceAllInStr( - sTool, - WYMeditor.TOOL_TITLE, - wym._options.stringDelimiterLeft + oTool.title + wym._options.stringDelimiterRight - ); - sTool = h.replaceAllInStr(sTool, WYMeditor.TOOL_CLASS, oTool.css); - sTools += sTool; - } - - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.TOOLS_ITEMS, sTools); - - // Construct the classes list - aClasses = eval(wym._options.classesItems); - sClasses = ""; - - for (i = 0; i < aClasses.length; i += 1) { - oClass = aClasses[i]; - sClass = ''; - if (oClass.name && oClass.title) { - sClass = wym._options.classesItemHtml; - } - sClass = h.replaceAllInStr(sClass, WYMeditor.CLASS_NAME, oClass.name); - sClass = h.replaceAllInStr(sClass, WYMeditor.CLASS_TITLE, oClass.title); - sClasses += sClass; - } - - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.CLASSES_ITEMS, sClasses); - - // Construct the containers list - aContainers = eval(wym._options.containersItems); - sContainers = ""; - - for (i = 0; i < aContainers.length; i += 1) { - oContainer = aContainers[i]; - sContainer = ''; - if (oContainer.name && oContainer.title) { - sContainer = wym._options.containersItemHtml; - } - sContainer = h.replaceAllInStr( - sContainer, - WYMeditor.CONTAINER_NAME, - oContainer.name - ); - sContainer = h.replaceAllInStr(sContainer, WYMeditor.CONTAINER_TITLE, - wym._options.stringDelimiterLeft + - oContainer.title + - wym._options.stringDelimiterRight); - sContainer = h.replaceAllInStr( - sContainer, - WYMeditor.CONTAINER_CLASS, - oContainer.css - ); - sContainers += sContainer; - } - - boxHtml = h.replaceAllInStr(boxHtml, WYMeditor.CONTAINERS_ITEMS, sContainers); - - // I10n - boxHtml = wym.replaceStrings(boxHtml); - - // Load the html in wymbox - jQuery(wym._box).html(boxHtml); - - // Hide the html value - jQuery(wym._box).find(wym._options.htmlSelector).hide(); - - wym.documentStructureManager = new WYMeditor.DocumentStructureManager( - wym, - wym._options.structureRules.defaultRootContainer - ); - - // Some browsers like to trigger an iframe's load event multiple times - // depending on all sorts of small, annoying details. Instead of attempting - // to work-around old ones and predict new ones, let's just ensure the - // initialization only happens once. All methods of detecting load are - // unreliable. - wym.iframeInitialized = false; - - wym._iframe = jQuery(wym._box).find('iframe')[0]; - - jQuery(wym._iframe).load(function () { - wym._onEditorIframeLoad(wym); - }); - - wym.element.attr('data-wym-initialized', 'yes'); - - wym._initSkin(); -}; - -/** - WYMeditor.editor._assignWymDoc - ============================== - - Assigns an editor's document to the `_doc` property. -*/ -WYMeditor.editor.prototype._assignWymDoc = function () { - var wym = this; - - wym._doc = wym._iframe.contentDocument; -}; - -/** - WYMeditor.editor._isDesignModeOn - ================================ - - Returns true if the designMode property of the editor's document is "On". - Returns false, otherwise. -*/ -WYMeditor.editor.prototype._isDesignModeOn = function () { - var wym = this; - - if ( - typeof wym._doc.designMode === "string" && - wym._doc.designMode.toLowerCase() === "on" - ) { - return true; - } - return false; -}; - -/** - WYMeditor.editor._onEditorIframeLoad - ==================================== - - This is a part of the initialization of an editor. - - The initialization procedure of an editor turns asynchronous because part of - it must occur after the loading of the editor's Iframe. - - This function is supposed to be the event handler of the loading of the - editor's Iframe. Therefore, it is the first step since the initialization - procedure gets asynchronous. - - @param wym The editor instance that's being initialized. -*/ -WYMeditor.editor.prototype._onEditorIframeLoad = function (wym) { - wym._assignWymDoc(); - wym._enableDesignModeOnDocument(); - wym._afterDesignModeOn(); -}; - -/** - WYMeditor.editor.get$Buttons - ============================ - - Returns a jQuery object, containing all the UI buttons. -*/ -WYMeditor.editor.prototype.get$Buttons = function () { - var wym = this, - buttonsSelector, - $buttons; - - buttonsSelector = [ - wym._options.toolSelector, - wym._options.containerSelector, - wym._options.classSelector - ].join(', '); - $buttons = jQuery(wym._box).find(buttonsSelector); - - return $buttons; -}; - -/** - WYMeditor.editor.focusOnDocument - ================================ - - Sets focus on the document. -*/ -WYMeditor.editor.prototype.focusOnDocument = function () { - var wym = this, - doc = wym._iframe.contentWindow; - - doc.focus(); -}; - -/** - WYMeditor.editor.registerModification - ===================================== - - Registers a change in the document. This should be called after changes - are made in the document. - - Triggers the `postModification` event afterwards. -*/ -WYMeditor.editor.prototype.registerModification = function (isNativeEdit) { - var wym = this; - - wym.undoRedo._add(); - - if (!isNativeEdit) { - // A non-native-edit modification is registered. Reset Edited. - wym.nativeEditRegistration.edited.reset(); - } - - jQuery(wym.element).trigger(WYMeditor.EVENTS.postModification); -}; - -/** - WYMeditor.editor._bindFocusOnDocumentToButtons - ============================================== - - Binds a handler to clicks on the UI buttons, that sets focus back to the - document. - - Doesn't bind to dialog-opening buttons, because that would cause them to - fall behind the opening window, in some browsers. -*/ -WYMeditor.editor.prototype._bindFocusOnDocumentToButtons = function () { - var wym = this, - $buttons = wym.get$Buttons(); - - $buttons = $buttons.parent().not('.wym_opens_dialog').children('a'); - $buttons.click(function () { - wym.focusOnDocument(); - }); -}; - -/** - WYMeditor.editor._uiQuirks - ========================== - - A hook for browser quirks that work on the UI. - - To be run after plugins had a chance to modify the UI. -*/ -WYMeditor.editor.prototype._uiQuirks = function () { - return; -}; - - -/** - WYMeditor.editor._afterDesignModeOn - =================================== - - This is part of the initialization of an editor, designed to be called - after the editor's document is in designMode. -*/ -WYMeditor.editor.prototype._afterDesignModeOn = function () { - var wym = this; - - if (wym.iframeInitialized === true) { - return; - } - - wym._assignWymDoc(); - wym.$body().addClass("wym_iframe combokeys"); - - wym._doc.title = wym._index; - - // Set the text direction. - jQuery('html', wym._doc).attr('dir', wym._options.direction); - - wym.keyboard = new WYMeditor.Keyboard(wym); - wym.keyboard._attachDefaultKeyboardShortcuts(); - - wym._docEventQuirks(); - - wym._initializeDocumentContent(); - - if (jQuery.isFunction(wym._options.preBind)) { - wym._options.preBind(wym); - } - - wym._bindUIEvents(); - - wym.iframeInitialized = true; - - if (jQuery.isFunction(wym._options.postInit)) { - wym._options.postInit(wym); - } - - // Importantly, these two are after `postInit`, where plugins had a chance - // to modify the UI (add buttons, etc.). - wym._bindFocusOnDocumentToButtons(); - wym._uiQuirks(); - - // Add event listeners to doc elements, e.g. images - wym._listen(); - - wym.undoRedo = new WYMeditor.UndoRedo(wym); - - wym.nativeEditRegistration = new WYMeditor.NativeEditRegistration(wym); - - wym.ih = new WYMeditor.ImageHandler(wym); - - jQuery(wym.element).trigger( - WYMeditor.EVENTS.postIframeInitialization, - wym - ); -}; - -/** - WYMeditor.editor._initializeDocumentContent - =========================================== - - Populates the editor's document with the initial content, according to the - configuration and/or the textarea element's value. -*/ -WYMeditor.editor.prototype._initializeDocumentContent = function () { - var wym = this; - - if (wym._options.html) { - // Populate from the configuration option - wym.html(wym._options.html); - } else { - // Populate from the textarea element - wym.html(wym.element[0].value); - } -}; - -/** - WYMeditor.editor._docEventQuirks - ================================ - - Misc. event bindings on the editor's document, that may be required. -*/ -WYMeditor.editor.prototype._docEventQuirks = function () { - return; -}; - -/** - WYMeditor.editor._bindUIEvents - ============================== - - Binds event handlers for the UI elements. -*/ -WYMeditor.editor.prototype._bindUIEvents = function () { - var wym = this, - $toolbarButtons = jQuery(wym._box).find(wym._options.toolSelector), - dialogButtonSelector = WYMeditor.DIALOG_BUTTON_SELECTOR, - $html_val; - - // Action buttons - $toolbarButtons.not(dialogButtonSelector).click(function () { - var button = this; - wym.exec(jQuery(button).attr(WYMeditor.NAME)); - return false; - }); - - // Dialog buttons - $toolbarButtons.filter(dialogButtonSelector).click(function () { - var button = this, - dialogName = jQuery(button).attr(WYMeditor.NAME), - dialog = WYMeditor.DIALOGS[dialogName]; - - // The following would also work, but is deprecated: - // wym.dialog(dialogName); - wym.dialog(dialog); - return false; - }); - - // Containers buttons - jQuery(wym._box).find(wym._options.containerSelector).click(function () { - var containerButton = this; - wym.setRootContainer(jQuery(containerButton).attr(WYMeditor.NAME)); - return false; - }); - - // Handle keyup event on the HTML value textarea: set the editor value - // Handle focus/blur events to check if the element has focus, see #147 - $html_val = jQuery(wym._box).find(wym._options.htmlValSelector); - $html_val.keyup(function () { - var valTextarea = this; - wym.$body().html(jQuery(valTextarea).val()); - }); - $html_val.focus(function () { - var valTextarea = this; - jQuery(valTextarea).toggleClass('hasfocus'); - }); - $html_val.blur(function () { - var valTextarea = this; - jQuery(valTextarea).toggleClass('hasfocus'); - }); - - // Handle click events on classes buttons - jQuery(wym._box).find(wym._options.classSelector).click(function () { - var classButton = this, - aClasses = eval(wym._options.classesItems), - sName = jQuery(classButton).attr(WYMeditor.NAME), - - oClass = WYMeditor.Helper._getFromArrayByName(aClasses, sName), - jqexpr; - - if (oClass) { - jqexpr = oClass.expr; - wym.toggleClass(sName, jqexpr); - } - return false; - }); - - // Handle update event on update element - jQuery(wym._options.updateSelector).bind( - wym._options.updateEvent, - function () { - wym.update(); - } - ); - - // This may recover an unexpected shut down of `designMode`. - wym.$body().bind("focus", function () { - if (wym._isDesignModeOn() !== true) { - wym._enableDesignModeOnDocument(); - } - }); -}; - -/** - WYMeditor.editor._enableDesignModeOnDocument - ============================================ - - Enables `designMode` on the document, if it is not already enabled. -*/ -WYMeditor.editor.prototype._enableDesignModeOnDocument = function () { - var wym = this; - - if (wym._isDesignModeOn()) { - throw "Expected `designMode` to be off."; - } - - try { - wym._doc.designMode = "On"; - } catch (e) { - // Bail out gracefully if this went wrong. - } - if (typeof wym._designModeQuirks === "function") { - wym._designModeQuirks(); - } -}; - -/** - WYMeditor.editor.get$WymBox - =========================== - - Get a jQuery containing the WYMeditor box. -*/ -WYMeditor.editor.prototype.get$WymBox = function () { - var wym = this; - return wym._box; -}; - -/** - WYMeditor.editor.vanish - ========================= - - Removes the WYMeditor instance from existence and replaces the - 'data-wym-initialized' attirbute of its textarea with 'data-wym-vanished'. -*/ -WYMeditor.editor.prototype.vanish = function () { - var wym = this, - instances = WYMeditor.INSTANCES, - i; - - wym._box.remove(); - wym.element - .removeAttr('data-wym-initialized') - .attr('data-wym-vanished', '') - .show(); - instances.splice(wym._index, 1); - - // Refresh each editor's _index value - for (i = 0; i < instances.length; i++) { - instances[i]._index = i; - } -}; - -WYMeditor.editor.prototype._exec = function (cmd, param) { - var wym = this, - $span; - - if (typeof cmd !== "string") { - throw "`_exec` expected a String `cmd`"; - } - - if (param && typeof param !== "string") { - throw "`_exec` expected a String `param`"; - } - - if ( - wym.selectedContainer() === wym.body() && - // These are the two commands that are allowed directly in the body. - cmd !== WYMeditor.EXEC_COMMANDS.INSERT_IMAGE && - cmd !== WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK - ) { - return false; - } - - wym._doc.execCommand(cmd, false, param); - - $span = jQuery(wym.selectedContainer()).filter("span").not("[id]"); - if ($span.length === 0) { - return true; - } - if ( - $span.attr("class") === "" && - $span.attr("style") === "font-weight: normal;" || - $span.attr("class").toLowerCase() === "apple-style-span" - ) { - // An undesireable `span` was created. WebKit & Blink do this. - $span.contents().unwrap(); - } - - return true; -}; - -/** - WYMeditor.editor.rawHtml - ===================== - - Get or set the wymbox html value. HTML is NOT parsed when either set/get. - Use html() if you are unsure what this function does. -*/ -WYMeditor.editor.prototype.rawHtml = function (html) { - var wym = this; - if (typeof html === 'string') { - wym.$body().html(html); - wym.update(); - } else { - return wym.$body().html(); - } -}; - -/** - WYMeditor.editor.html - ===================== - - Get or set the wymbox html value. HTML is parsed before it is inserted and - parsed before it is return. Use rawHtml() if parsing is not wanted/needed. -*/ -WYMeditor.editor.prototype.html = function (html) { - var wym = this; - if (typeof html === 'string') { - wym.rawHtml(wym.parser.parse(html)); - wym.prepareDocForEditing(); - } else { - return wym.parser.parse(wym.rawHtml()); - } -}; - -/** - WYMeditor.editor.exec - ===================== - - Execute a button command on the currently-selected container. The command - can be anything from "indent this element" to "open a dialog to create a - table." - - `cmd` is a string corresponding to the command that should be run, roughly - matching the designMode execCommand strategy (and falling through to - execCommand in some cases). -*/ -WYMeditor.editor.prototype.exec = function (cmd) { - var wym = this, - custom_run; - switch (cmd) { - - case WYMeditor.EXEC_COMMANDS.TOGGLE_HTML: - wym.update(); - wym.toggleHtml(); - break; - - case WYMeditor.EXEC_COMMANDS.INSERT_ORDEREDLIST: - wym._insertOrderedList(); - break; - - case WYMeditor.EXEC_COMMANDS.INSERT_UNORDEREDLIST: - wym._insertUnorderedList(); - break; - - case WYMeditor.EXEC_COMMANDS.INDENT: - wym.indent(); - break; - - case WYMeditor.EXEC_COMMANDS.OUTDENT: - wym.outdent(); - break; - - case WYMeditor.EXEC_COMMANDS.UNDO: - wym.undoRedo.undo(); - break; - - case WYMeditor.EXEC_COMMANDS.REDO: - wym.undoRedo.redo(); - break; - - - default: - custom_run = false; - jQuery.each(wym._options.customCommands, function () { - var customCommand = this; - if (cmd === customCommand.name) { - custom_run = true; - customCommand.run.apply(wym); - return false; - } - }); - if (!custom_run) { - if ( - // Deligate all other commands to `_exec` - wym._exec(cmd) === true - ) { - wym.registerModification(); - } - } - break; - } -}; - -/** - WYMeditor.editor.selection - ========================== - - Override the default selection function to use rangy. -*/ -WYMeditor.editor.prototype.selection = function () { - var wym = this, - iframe = wym._iframe, - sel; - - if (window.rangy && !rangy.initialized) { - rangy.init(); - } - - sel = rangy.getIframeSelection(iframe); - - return sel; -}; - -/** - WYMeditor.editor.nodeAfterSel - ============================= - - Returns the node that is immediately after the selection. -*/ -WYMeditor.editor.prototype.nodeAfterSel = function () { - var wym = this, - sel = wym.selection(); - - // Different browsers describe selection differently. Here be dragons. - if ( - sel.anchorNode.tagName && - jQuery.inArray( - sel.anchorNode.tagName.toLowerCase(), - WYMeditor.NON_CONTAINING_ELEMENTS - ) === -1 - ) { - if (sel.anchorNode.childNodes.length === 0) { - return; - } - return sel.anchorNode.childNodes[sel.anchorOffset]; - } - - if ( - sel.focusNode.nodeType === WYMeditor.NODE_TYPE.TEXT && - sel.focusNode.data.length === sel.focusOffset - ) { - if (!sel.focusNode.nextSibling) { - return; - } - return sel.focusNode.nextSibling; - } - - return sel.focusNode; -}; - -/** - WYMeditor.editor.get$CommonParent - ================================= - - Returns a jQuery of the common parent of two nodes. -*/ -WYMeditor.editor.prototype.get$CommonParent = function (one, two) { - if ( - typeof one !== 'object' || - typeof one.nodeType !== 'number' || - typeof two !== 'object' || - typeof two.nodeType !== 'number' - ) { - throw "`one` and `two` must be DOM nodes."; - } - - if (one.nodeType === WYMeditor.NODE_TYPE.TEXT) { - // These checks seem to be required for our tests to pass in PhantomJS. - one = one.parentNode; - } - if (two.nodeType === WYMeditor.NODE_TYPE.TEXT) { - // These checks seem to be required for our tests to pass in PhantomJS. - two = two.parentNode; - } - - if (one === two) { - // This is just an optimisation. - return jQuery(one); - } - - var $one = jQuery(one), - $two = jQuery(two), - $commonParent; - - $commonParent = $one.parents().addBack().has($two).last(); - - if ($commonParent.length === 0) { - throw "Couldn't find common parent. This shouldn't happen."; - } - - return $commonParent; -}; - -/** - WYMeditor.editor.selectedContainer - ================================== - - Get the selected container. - - * If no selection, returns `false`. - * If selection starts and ends in the same element, returns that element. - * If an element that contains one end of the selection is ancestor to the - element that contains the other end, return that ancestor element. - * Otherwise, returns `false`. - - For example (``|`` marks selection ends): - -

|Foo bar|

- - The ``p`` is returned. - -

Foo |bar|

- - The ``i`` is returned. -*/ -WYMeditor.editor.prototype.selectedContainer = function () { - var wym = this, - selection, - $anchor, - $focus, - $selectedContainer; - - if (wym.hasSelection() !== true) { - return false; - } - - selection = wym.selection(); - $anchor = jQuery(selection.anchorNode); - $focus = jQuery(selection.focusNode); - - if ($anchor[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - $anchor = $anchor.parent(); - } - - if ($focus[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - $focus = $focus.parent(); - } - - if ($anchor[0] === $focus[0]) { - return $anchor[0]; - } - - $selectedContainer = $anchor.has($focus); - if ($selectedContainer.length === 0) { - $selectedContainer = $focus.has($anchor); - } - - if ($selectedContainer.length === 0) { - return false; - } - - return $selectedContainer[0]; -}; - -// Deprecated in favor of `WYMeditor.editor.selectedContainer`. -WYMeditor.editor.prototype.selected = function () { - var wym = this; - - WYMeditor.console.warn( - "The function WYMeditor.editor.selected() is " + - "deprecated. Use WYMeditor.editor.selectedContainer" - ); - - return wym.selectedContainer(); -}; - -/** - WYMeditor.editor.isBlockNode - ============================= - - Returns true if the provided node is a block type node. Otherwise - returns false. - - @param node The node to check. -*/ - -WYMeditor.editor.prototype.isBlockNode = function (node) { - if ( - node.tagName && - jQuery.inArray( - node.tagName.toLowerCase(), - WYMeditor.BLOCKS - ) > -1 - ) { - return true; - } - return false; -}; - -/** - WYMeditor.editor.isInlineNode - ============================= - - Returns true if the provided node is an inline type node. Otherwise - returns false. - - @param node The node to check. -*/ - -WYMeditor.editor.prototype.isInlineNode = function (node) { - if ( - node.nodeType === WYMeditor.NODE_TYPE.TEXT || - jQuery.inArray( - node.tagName.toLowerCase(), - WYMeditor.INLINE_ELEMENTS - ) > -1 - ) { - return true; - } - return false; -}; - -/** - WYMeditor.editor.isListNode - =========================== - - Returns true if the provided node is a list element. Otherwise - returns false. - - @param node The node to check. -*/ - -WYMeditor.editor.prototype.isListNode = function (node) { - if ( - node.tagName && - jQuery.inArray( - node.tagName.toLowerCase(), - WYMeditor.LIST_TYPE_ELEMENTS - ) > -1 - ) { - return true; - } - return false; -}; - -/** - WYMeditor.editor.unwrapIfMeaninglessSpan - - If the given node is a span with no useful attributes, unwrap it. - - For certain editing actions (mostly list indent/outdent), it's necessary to - wrap content in a span element to retain grouping because it's not obvious that - the content will stay together without grouping. This method detects that - specific situation and then unwraps the content if the span is in fact not - necessary. - - @param element The element. -*/ -WYMeditor.editor.prototype.unwrapIfMeaninglessSpan = function (element) { - var $element = jQuery(element), - i = 0, - attrName, - meaninglessAttrNames = [ - '_wym_visited', - 'length', - 'ie8_length' - ]; - - if (!element || typeof (element.tagName) === 'undefined' || - element.tagName.toLowerCase() !== 'span') { - return false; - } - - while (i < element.attributes.length) { - attrName = element.attributes[i].nodeName; - if (jQuery.inArray(attrName, meaninglessAttrNames) === -1) { - return false; - } - i++; - } - - $element.before($element.contents()); - $element.remove(); - return true; -}; - -/** - WYMeditor.editor.getRootContainer - ================================= - - Get the selected root container. -*/ -WYMeditor.editor.prototype.getRootContainer = function () { - var wym = this; - - return jQuery(wym.selectedContainer()) - .parentsOrSelf() - .not('html, body, blockquote') - .last()[0]; -}; - -/** - WYMeditor.editor.setRootContainer - ================================= - - Set the selected root container. -*/ -WYMeditor.editor.prototype.setRootContainer = function (sType) { - var wym = this, - container = null, - aTypes, - newNode, - blockquote, - nodes, - lgt, - firstNode, - x; - - if (sType.toLowerCase() === WYMeditor.TH) { - container = wym.selectedContainer(); - - // Find the TD or TH container - switch (container.tagName.toLowerCase()) { - - case WYMeditor.TD: - case WYMeditor.TH: - break; - default: - aTypes = [WYMeditor.TD, WYMeditor.TH]; - container = wym.findUp(wym.selectedContainer(), aTypes); - break; - } - - // If it exists, switch - if (container !== null) { - sType = WYMeditor.TD; - if (container.tagName.toLowerCase() === WYMeditor.TD) { - sType = WYMeditor.TH; - } - wym.restoreSelectionAfterManipulation(function () { - wym.switchTo(container, sType, false); - return true; - }); - wym.update(); - wym.registerModification(); - } - } else { - // Set the container type - aTypes = [ - WYMeditor.P, - WYMeditor.DIV, - WYMeditor.H1, - WYMeditor.H2, - WYMeditor.H3, - WYMeditor.H4, - WYMeditor.H5, - WYMeditor.H6, - WYMeditor.PRE, - WYMeditor.BLOCKQUOTE - ]; - container = wym.findUp(wym.selectedContainer(), aTypes); - - if (container) { - if (sType.toLowerCase() === WYMeditor.BLOCKQUOTE) { - // Blockquotes must contain a block level element - blockquote = wym.findUp( - wym.selectedContainer(), - WYMeditor.BLOCKQUOTE - ); - if (blockquote === null) { - newNode = wym._doc.createElement(sType); - container.parentNode.insertBefore(newNode, container); - newNode.appendChild(container); - wym.setCaretIn(newNode.firstChild); - } else { - nodes = blockquote.childNodes; - lgt = nodes.length; - - if (lgt > 0) { - firstNode = nodes.item(0); - } - for (x = 0; x < lgt; x += 1) { - blockquote.parentNode.insertBefore( - nodes.item(0), - blockquote - ); - } - blockquote.parentNode.removeChild(blockquote); - if (firstNode) { - wym.setCaretIn(firstNode); - } - } - } else { - // Not a blockquote - wym.restoreSelectionAfterManipulation(function () { - wym.switchTo(container, sType, false); - return true; - }); - } - - wym.update(); - wym.registerModification(); - } - } - - return false; -}; - -/** - WYMeditor.editor.isForbiddenRootContainer - ========================================= - - Returns true if provided `tagName` is disallowed as a root container. - Returns false if it is allowed. - - @param tagName A string of the tag name. -*/ -WYMeditor.editor.prototype.isForbiddenRootContainer = function (tagName) { - return jQuery.inArray(tagName.toLowerCase(), - WYMeditor.FORBIDDEN_ROOT_CONTAINERS) > -1; -}; - -/** - WYMeditor.editor.keyCanCreateBlockElement - ========================================= - - Determines whether the key represented by the passed keyCode can create a - block element within the editor when pressed. Returns true if the key can - create a block element when pressed, and returns false if otherwise. - - @param keyCode A numberic key code representing a key -*/ -WYMeditor.editor.prototype.keyCanCreateBlockElement = function (keyCode) { - return jQuery.inArray(keyCode, - WYMeditor.POTENTIAL_BLOCK_ELEMENT_CREATION_KEYS) > -1; -}; - -/** - WYMeditor.editor.toggleClass - ============================ - - Toggle a class on the selected element or one of its parents -*/ -WYMeditor.editor.prototype.toggleClass = function (sClass, jqexpr) { - var wym = this, - $element; - - $element = jQuery(wym.getSelectedImage()); - if ($element.length !== 1) { - $element = jQuery(wym.selectedContainer()) - // `.last()` is used here because the `.addBack()` from - // `.parentsOrSelf` reverses the array. - .parentsOrSelf(jqexpr).last(); - } - $element.toggleClass(sClass); - - if (!$element.attr(WYMeditor.CLASS)) { - $element.removeAttr(wym._class); - } - wym.registerModification(); -}; - -/** - WYMeditor.editor.getSelectedImage - ================================= - - If selection encompasses exactly a single image, returns that image. - Otherwise returns `false`. -*/ -WYMeditor.editor.prototype.getSelectedImage = function () { - var wym = this, - selectedNodes, - selectedNode; - - if (wym.hasSelection() !== true) { - return false; - } - if (wym.selection().isCollapsed !== false) { - return false; - } - - selectedNodes = wym._getSelectedNodes(); - - if (selectedNodes.length !== 1) { - return false; - } - - selectedNode = selectedNodes[0]; - - if ( - !selectedNode.tagName || - selectedNode.tagName.toLowerCase() !== "img" - ) { - return false; - } - - return selectedNode; -}; - -/** - WYMeditor.editor.findUp - ======================= - - Return the first parent or self container, based on its type - - `filter` is a string or an array of strings on which to filter the container -*/ -WYMeditor.editor.prototype.findUp = function (node, filter) { - if (typeof (node) === 'undefined' || node === null) { - return null; - } - - if (node.nodeName === "#text") { - // For text nodes, we need to look from the nodes container object - node = node.parentNode; - } - var tagname = node.tagName.toLowerCase(), - bFound, - i; - if (typeof (filter) === WYMeditor.STRING) { - while (tagname !== filter && tagname !== WYMeditor.BODY) { - node = node.parentNode; - tagname = node.tagName.toLowerCase(); - } - } else { - bFound = false; - while (!bFound && tagname !== WYMeditor.BODY) { - for (i = 0; i < filter.length; i += 1) { - if (tagname === filter[i]) { - bFound = true; - break; - } - } - if (!bFound) { - node = node.parentNode; - if (node === null) { - // No parentNode, so we're not going to find anything - // up the ancestry chain that matches - return null; - } - tagname = node.tagName.toLowerCase(); - } - } - } - - if (tagname === WYMeditor.BODY) { - return null; - } - - return node; -}; - -/** - WYMeditor.editor.switchTo - ========================= - - Switch the type of an element. - - @param element The element. - @param sType A string of the desired type. For example, 'p'. - @param stripAttrs a boolean that determines whether the attributes of - the element will be stripped or preserved. - -*/ -WYMeditor.editor.prototype.switchTo = function ( - element, - sType, - stripAttrs -) { - var wym = this, - $element = jQuery(element), - newElement, - i, - attrs = element.attributes; - - if (!element.tagName) { - throw "This must be an element."; - } - - if (element.tagName.toLowerCase() === 'img') { - throw "Will not change the type of an 'img' element."; - } - - newElement = wym._doc.createElement(sType); - jQuery(newElement).append(element.childNodes); - $element.replaceWith(newElement); - - if (!stripAttrs) { - for (i = 0; i < attrs.length; ++i) { - newElement.setAttribute( - attrs.item(i).nodeName, - attrs.item(i).value - ); - } - } - - return newElement; -}; - -WYMeditor.editor.prototype.replaceStrings = function (sVal) { - var wym = this, - key; - // Check if the language file has already been loaded - // if not, get it via a synchronous ajax call - if (!WYMeditor.STRINGS[wym._options.lang]) { - WYMeditor.console.error( - "WYMeditor: language '" + wym._options.lang + "' not found." - ); - WYMeditor.console.error( - "Unable to perform i10n." - ); - return sVal; - } - - // Replace all the strings in sVal and return it - for (key in WYMeditor.STRINGS[wym._options.lang]) { - if (WYMeditor.STRINGS[wym._options.lang].hasOwnProperty(key)) { - sVal = WYMeditor.Helper.replaceAllInStr( - sVal, - wym._options.stringDelimiterLeft + key + wym._options.stringDelimiterRight, - WYMeditor.STRINGS[wym._options.lang][key] - ); - } - } - return sVal; -}; - -WYMeditor.editor.prototype._encloseString = function (sVal) { - var wym = this; - return wym._options.stringDelimiterLeft + - sVal + - wym._options.stringDelimiterRight; -}; - -/** - editor.getCurrentState - ====================== - - Returns an object with the current state of the editor. - - The state includes: - - ``html`` - The return value of ``editor.rawHtml()``. - ``savedSelection`` - A Rangy saved selection, if anything is selected. - The ``win`` and the ``doc`` properties are deleted, - instead of referencing the window object and the document object, - respectively. - In order to provide this as an argument to Rangy's ``restoreSelection``, - these must be reassigned. - - It may include more things in the future. -*/ -WYMeditor.editor.prototype.getCurrentState = function () { - var wym = this, - state = {}, - selection, - wymIframeWindow = wym._iframe.contentWindow; - - if (wym.hasSelection()) { - selection = wym.selection(); - } - - if ( - selection && - selection.anchorNode === wym.body() && - selection.anchorOffset === 0 && - selection.isCollapsed - ) { - // meaningless selection - selection = false; - } - - if (selection) { - state.savedSelection = rangy.saveSelection(wymIframeWindow); - } - - state.html = wym.rawHtml(); - - if (state.savedSelection) { - // Selection was saved. This means that in the document, DOM elements, - // which are markers for the selection, were placed, and that references - // to these markers were saved in `state.savedselection`. The markers - // were saved in `state.html`, along with the whole document, as HTML. - // Restoring the selection removes the markers and restores the - // selection to almost exactly as it was before it was saved. - rangy.restoreSelection(state.savedSelection); - // This is for time-travel, so selection is considered not to be - // restored. The markers may be created again from the saved HTML. In - // that case, leaving this value at `true` would mean that - // `rangy.restoreSelection` will refuse to restore this selection. - state.savedSelection.restored = false; - // These refer to the window and the document and can't be processed by - // the `object-history` module that is used by the `UndoRedo` module. - delete state.savedSelection.win; - delete state.savedSelection.doc; - } - - return state; -}; - -/** - editor.hasSelection - =================== - - Returns true if there is a selection. Returns false otherwise. -*/ -WYMeditor.editor.prototype.hasSelection = function () { - var wym = this; - - if ( - // `isSelectionValid` is undocumented in current Rangy (`1.2.2`). - // It seems to be required because the `rangeCount` in `IE <= 8` seems - // to be misleading. - rangy.isSelectionValid(wym._iframe.contentWindow) !== true - ) { - return false; - } - - if (wym.selection().rangeCount === 0) { - return false; - } - - return true; -}; - -/** - editor._setSingleSelectionRange - =============================== - - Sets the selection to the single provided Rangy range. - - @param range A Rangy range. -*/ -WYMeditor.editor.prototype._setSingleSelectionRange = function (range) { - var wym = this, - selection; - - selection = wym.selection(); - - selection.setSingleRange(range); -}; - -/** - editor.status - ============= - - Print the given string as a status message. -*/ -WYMeditor.editor.prototype.status = function (sMessage) { - var wym = this; - // Print status message - jQuery(wym._box).find(wym._options.statusSelector).html(sMessage); -}; - -/** - editor.update - ============= - - Update the element and textarea values. -*/ -WYMeditor.editor.prototype.update = function () { - var wym = this, - html; - - html = wym.html(); - jQuery(wym.element).val(html); - jQuery(wym._box).find(wym._options.htmlValSelector).not('.hasfocus').val(html); //#147 -}; - -/** - editor.prepareDocForEditing - =========================== - - Makes some editor-only modifications to the body of the document, which are necessary - for the user interface. For example, inserts `br` elements in certain places. - These modifications will not show up in the HTML output. - -*/ -WYMeditor.editor.prototype.prepareDocForEditing = function () { - var wym = this, - $body; - - wym._spaceBlockingElements(); - wym._fixDoubleBr(); - - $body = wym.$body(); - if ($body.children().length === 0) { - wym.$body().append('
'); - } - - jQuery(wym.element).trigger(WYMeditor.EVENTS.postBlockMaybeCreated, wym); -}; - -/** - editor._spaceBlockingElements - ============================= - - Insert
elements between adjacent blocking elements and - p elements, between block elements or blocking elements and the - start/end of the document. -*/ -WYMeditor.editor.prototype._spaceBlockingElements = function () { - var wym = this, - blockingSelector = - WYMeditor.DocumentStructureManager.CONTAINERS_BLOCKING_NAVIGATION.join(', '), - $body = wym.$body(), - children = $body.children(), - - placeholderNode, - $firstChild, - $lastChild, - blockSepSelector, - blockInListSepSelector, - $blockInList; - - if (jQuery.browser.mozilla) { - placeholderNode = '
'; - } else { - placeholderNode = '
'; - } - - // Make sure that we still have a placeholder node at both the begining and - // end - if (children.length > 0) { - $firstChild = jQuery(children[0]); - $lastChild = jQuery(children[children.length - 1]); - - if ($firstChild.is(blockingSelector)) { - $firstChild.before(placeholderNode); - } - - if ($lastChild.is(blockingSelector)) { - $lastChild.after(placeholderNode); - } - } - - blockSepSelector = wym._getBlockSepSelector(); - - // Put placeholder nodes between consecutive blocking elements and between - // blocking elements and normal block-level elements - $body.find(blockSepSelector).before(placeholderNode); - - blockInListSepSelector = wym._getBlockInListSepSelector(); - $blockInList = $body.find(blockInListSepSelector); - - // The $blockInList selection must be iterated over to only add placeholder - // nodes after blocking elements at the end of a list item rather than all - // blocking elements in a list. No jQuery selection that is supported on - // all browsers can do this check, so that is why it must be done by using - // `each` to iterate over the selection. Note that the handling of the - // spacing of other blocking elements in a list besides after the last - // blocking element in a list item is already handled by the - // blockSepSelector used before this. - $blockInList.each(function () { - var block = this, - $block = jQuery(block); - - if (!$block.next(blockingSelector).length && - !$block.next('br').length) { - - $block.after(placeholderNode); - } - }); -}; - -/** - editor._getBlockSepSelector - =========================== - - Build a string representing a jquery selector that will find all - elements which need a spacer
before them. This includes all consecutive - blocking elements and between blocking elements and normal non-blocking - elements. -*/ -WYMeditor.editor.prototype._getBlockSepSelector = function () { - var wym = this, - blockCombo = [], - containersBlockingNav = - WYMeditor.DocumentStructureManager.CONTAINERS_BLOCKING_NAVIGATION, - containersNotBlockingNav; - - if (typeof (wym._blockSpacersSel) !== 'undefined') { - return wym._blockSpacersSel; - } - - // Generate the list of non-blocking elements by removing the blocking - // elements from the list of validRootContainers - containersNotBlockingNav = jQuery.grep( - wym.documentStructureManager.structureRules.validRootContainers, - function (item) { - return jQuery.inArray(item, containersBlockingNav) === -1; - } - ); - - // Consecutive blocking elements need separators - jQuery.each( - containersBlockingNav, - function (indexO, elementO) { - jQuery.each( - containersBlockingNav, - function (indexI, elementI) { - blockCombo.push(elementO + ' + ' + elementI); - } - ); - } - ); - - // A blocking element either followed by or preceeded by a not blocking - // element needs separators - jQuery.each( - containersBlockingNav, - function (indexO, elementO) { - jQuery.each( - containersNotBlockingNav, - function (indexI, elementI) { - blockCombo.push(elementO + ' + ' + elementI); - blockCombo.push(elementI + ' + ' + elementO); - } - ); - } - ); - wym._blockSpacersSel = blockCombo.join(', '); - return wym._blockSpacersSel; -}; - -/* - editor._getBlockInListSepSelector - ================================= - - Returns a selector for getting all of the block elements in lists - or sublists. The block elements at the end of lists or sublists should have - a spacer line break after them in the editor at all times. -*/ -WYMeditor.editor.prototype._getBlockInListSepSelector = function () { - var wym = this, - blockCombo = []; - - if (typeof (wym._blockInListSpacersSel) !== 'undefined') { - return wym._blockInListSpacersSel; - } - - jQuery.each(WYMeditor.LIST_TYPE_ELEMENTS, function (indexO, elementO) { - jQuery.each(WYMeditor.BLOCKING_ELEMENTS, function (indexI, elementI) { - blockCombo.push(elementO + ' ' + elementI); - }); - }); - - wym._blockInListSpacersSel = blockCombo.join(', '); - return wym._blockInListSpacersSel; -}; - -/** - editor._fixDoubleBr - =================== - - Remove the

elements that are inserted between - paragraphs, usually after hitting enter from an existing paragraph. -*/ -WYMeditor.editor.prototype._fixDoubleBr = function () { - var wym = this, - $body = wym.$body(), - $last_br; - - // Strip consecutive brs unless they're in a pre tag - $body.children('br + br').filter(':not(pre br)').remove(); - - // Also remove any brs between two p's - $body.find('p + br').next('p').prev('br').remove(); - - // Remove brs floating at the end after a p - $last_br = $body.find('p + br').slice(-1); - if ($last_br.length > 0) { - if ($last_br.next().length === 0) { - $last_br.remove(); - } - } -}; - -/** - WYMeditor.editor.link - ====================== - - Creates a link, or changes attributes of an `a`, at selection. - - @param attrs Object with key-value pairs of attributes for the `a`. -*/ -WYMeditor.editor.prototype.link = function (attrs) { - var wym = this, - $selected, - uniqueStamp, - $a; - - if (jQuery.isPlainObject(attrs) !== true) { - throw "Expected a plain object."; - } - - if ( - attrs.hasOwnProperty('href') !== true || - typeof attrs.href !== 'string' || - attrs.href.length === 0 - ) { - // Would probably be best to throw here, but... - // This is used by a dialog that doesn't check input. - // The dialog is created by `WYMeditor.INIT_DIALOG`. - return; - } - - $selected = jQuery(wym.selectedContainer()); - if ($selected.is('a')) { - $a = $selected; - } else { - uniqueStamp = wym.uniqueStamp(); - wym._exec(WYMeditor.EXEC_COMMANDS.CREATE_LINK, uniqueStamp); - $a = jQuery("a[href=" + uniqueStamp + "]", wym.body()); - } - - if ($a.length === 0) { - // This occurs when a link wasn't created, because, for example - // the selection didn't allow it. - return; - } - $a.attr(attrs); - - wym.registerModification(); -}; - -/** - WYMeditor.editor.insertImage - ============================ - - Inserts an image at selection. - - @param attrs Object with key-value pairs of attributes for the `img`. -*/ -WYMeditor.editor.prototype.insertImage = function (attrs) { - var wym = this, - uniqueStamp, - $img; - - if (jQuery.isPlainObject(attrs) !== true) { - throw "Expected a plain object."; - } - - if ( - attrs.hasOwnProperty('src') !== true || - typeof attrs.src !== 'string' || - attrs.src.length === 0 - ) { - // Would probably be best to throw here, but... - // This is used by a dialog that doesn't check input. - // The dialog is created by `WYMeditor.INIT_DIALOG`. - return; - } - - uniqueStamp = wym.uniqueStamp(); - wym._exec(WYMeditor.EXEC_COMMANDS.INSERT_IMAGE, uniqueStamp); - $img = jQuery("img[src=" + uniqueStamp + "]", wym.body()); - - if ($img.length === 0) { - // This occurs when a link wasn't created, because, for example - // the selection didn't allow it. - return; - } - $img.attr(attrs); - - // PhantomJS seems to add strange spans around images. - wym.$body().find('.Apple-style-span').children().unwrap(); - - wym.registerModification(); -}; - -/** - editor._updateImageAttrs - ======================== - - Updates provided `img`'s attributes with provided `attrs`. -*/ -WYMeditor.editor.prototype._updateImageAttrs = function (img, attrs) { - var $img = jQuery(img); - if (attrs.src !== $img.attr('src')) { - // this data is used in the ImageHandler. - // height/width ratio is now most likely invalid - $img.data('DimensionsRatio', null); - - // since the height/width ration is most likely different - // these proportions are most likely wrong. - // easiest solution is to remove them - // and let the user deal with - // the real size of the source image - // and he'll be able to resize it - $img.removeAttr('height').removeAttr('width'); - } - $img.attr(attrs); -}; - -/** - editor.toggleHtml - ================= - - Show/Hide the HTML textarea. -*/ -WYMeditor.editor.prototype.toggleHtml = function () { - var wym = this; - jQuery(wym._box).find(wym._options.htmlSelector).toggle(); -}; - -WYMeditor.editor.prototype.uniqueStamp = function () { - var now = new Date(); - return "wym" + now.getTime(); -}; - -/** - Paste the given array of paragraph-items at the given range inside the given $container. - - It has already been determined that the paragraph has multiple lines and - that the container we're pasting to is a block container capable of accepting - further nested blocks. -*/ -WYMeditor.editor.prototype._handleMultilineBlockContainerPaste = function ( - wym, $container, range, paragraphStrings -) { - - var i, - $insertAfter, - html, - blockSplitter, - leftSide, - rightSide, - rangeNodeComparison, - $splitRightParagraph, - firstParagraphString, - firstParagraphHtml, - blockParent, - blockParentType; - - - // Now append all subsequent paragraphs - $insertAfter = jQuery(blockParent); - - // Just need to split the current container and put new block elements - // in between - blockSplitter = 'p'; - if ($container.is('li')) { - // Instead of creating paragraphs on line breaks, we'll need to create li's - blockSplitter = 'li'; - } - // Split the selected element then build and insert the appropriate html - // This accounts for cases where the start selection is at the - // start of a node or in the middle of a text node by splitting the - // text nodes using rangy's splitBoundaries() - range.splitBoundaries(); // Split any partially-select text nodes - blockParent = wym.findUp( - range.startContainer, - ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li'] - ); - blockParentType = blockParent.tagName; - leftSide = []; - rightSide = []; - jQuery(blockParent).contents().each(function (index, element) { - // Capture all of the dom nodes to the left and right of our - // range. We can't remove them in the same step because that - // loses the selection in webkit - - rangeNodeComparison = range.compareNode(element); - if (rangeNodeComparison === range.NODE_BEFORE || - (rangeNodeComparison === range.NODE_BEFORE_AND_AFTER && - range.startOffset === range.startContainer.length)) { - // Because of the way splitBoundaries() works, the - // collapsed selection might appear in the right-most index - // of the border node, which means it will show up as - // - // eg. | is the selection and <> are text node boundaries - // - // - // We detect that case by counting any - // NODE_BEFORE_AND_AFTER result where the offset is at the - // very end of the node as a member of the left side - leftSide.push(element); - } else { - rightSide.push(element); - } - }); - // Now remove all of the left and right nodes - for (i = 0; i < leftSide.length; i++) { - jQuery(leftSide[i]).remove(); - } - for (i = 0; i < rightSide.length; i++) { - jQuery(rightSide[i]).remove(); - } - - // Rebuild our split nodes and add the inserted content - if (leftSide.length > 0) { - // We have left-of-selection content - // Put the content back inside our blockParent - jQuery(blockParent).prepend(leftSide); - } - if (rightSide.length > 0) { - // We have right-of-selection content. - // Split it off in to a node of the same type after our - // blockParent - $splitRightParagraph = jQuery('<' + blockParentType + '>' + - '', wym._doc); - $splitRightParagraph.insertAfter(jQuery(blockParent)); - $splitRightParagraph.append(rightSide); - } - - // Insert the first paragraph in to the current node, and then - // start appending subsequent paragraphs - firstParagraphString = paragraphStrings.splice( - 0, - 1 - )[0]; - firstParagraphHtml = firstParagraphString.split(WYMeditor.NEWLINE).join('
'); - jQuery(blockParent).html(jQuery(blockParent).html() + firstParagraphHtml); - - // Now append all subsequent paragraphs - $insertAfter = jQuery(blockParent); - for (i = 0; i < paragraphStrings.length; i++) { - html = '<' + blockSplitter + '>' + - (paragraphStrings[i].split(WYMeditor.NEWLINE).join('
')) + - ''; - $insertAfter = jQuery(html, wym._doc).insertAfter($insertAfter); - } -}; - -/** - editor.paste - ============ - - Paste text into the editor below the carret, used for "Paste from Word". - - Takes the string to insert as an argument. Two or more newlines separates - paragraphs. May contain inline HTML. -*/ -WYMeditor.editor.prototype.paste = function (str) { - var wym = this, - container = wym.selectedContainer(), - paragraphStrings, - j, - textNodesToInsert, - blockSplitter, - $container = jQuery(container), - html = '', - paragraphs, - i, - isSingleLine = false, - sel = wym.selection(), - textNode, - range = sel.getRangeAt(0), - insertionNodes; - - // Start by collapsing the range to the start of the selection. We're - // punting on implementing a paste that also replaces existing content for - // now, - range.collapse(true); // Collapse to the the begining of the selection - - // Split string into paragraphs by two or more newlines - paragraphStrings = str.split(new RegExp(WYMeditor.NEWLINE + '{2,}', 'g')); - - if (paragraphStrings.length === 1) { - // This is a one-line paste, which is an easy case. - // We try not to wrap these in paragraphs - isSingleLine = true; - } - - if (typeof container === 'undefined' || - (container && container.tagName.toLowerCase() === WYMeditor.BODY)) { - // No selection, or body selection. Paste at the end of the document - - if (isSingleLine) { - // Easy case. Wrap the string in p tags - paragraphs = jQuery( - '

' + paragraphStrings[0] + '

', - wym._doc - ).appendTo(wym._doc.body); - } else { - // Need to build paragraphs and insert them at the end - blockSplitter = 'p'; - for (i = paragraphStrings.length - 1; i >= 0; i -= 1) { - // Going backwards because rangy.insertNode leaves the - // selection in front of the inserted node - html = '<' + blockSplitter + '>' + - (paragraphStrings[i].split(WYMeditor.NEWLINE).join('
')) + - ''; - // Build multiple nodes from the HTML because ie6 chokes - // creating multiple nodes implicitly via jquery - insertionNodes = jQuery(html, wym._doc); - for (j = insertionNodes.length - 1; j >= 0; j--) { - // Loop backwards through all of the nodes because - // insertNode moves that direction - range.insertNode(insertionNodes[j]); - } - } - } - } else { - // Pasting inside an existing element - if (isSingleLine || $container.is('pre')) { - // Easy case. Insert a text node at the current selection - textNode = wym._doc.createTextNode(str); - range.insertNode(textNode); - } else if ($container.is('p,h1,h2,h3,h4,h5,h6,li')) { - wym._handleMultilineBlockContainerPaste(wym, $container, range, paragraphStrings); - } else { - // We're in a container that doesn't accept nested paragraphs (eg. td). Use - //
separators everywhere instead - textNodesToInsert = str.split(WYMeditor.NEWLINE); - for (i = textNodesToInsert.length - 1; i >= 0; i -= 1) { - // Going backwards because rangy.insertNode leaves the - // selection in front of the inserted node - textNode = wym._doc.createTextNode(textNodesToInsert[i]); - range.insertNode(textNode); - if (i > 0) { - // Don't insert an opening br - range.insertNode(jQuery('
', wym._doc).get(0)); - } - } - } - } - wym.registerModification(); -}; - -WYMeditor.editor.prototype.insert = function (html) { - // Do we have a selection? - var wym = this, - selection = wym.hasSelection() ? wym.selection() : false, - range, - node; - if (selection) { - // Overwrite selection with provided html - range = selection.getRangeAt(0); - node = range.createContextualFragment(html); - range.deleteContents(); - range.insertNode(node); - } -}; - -/** - editor.canSetCaretBefore - ======================== - - Returns true if it is OK to set a collapsed selection immediately before - a node. Otherwise returns false. - - @param node A node to check about. - */ -WYMeditor.editor.prototype.canSetCaretBefore = function (node) { - var wym = this; - if (node.nodeType === WYMeditor.NODE_TYPE.TEXT) { - return true; - } - if ( - node.tagName && - node.tagName.toLowerCase() === 'br' - ) { - if ( - !node.previousSibling - ) { - return true; - - } else if ( - node.previousSibling.tagName && - node.previousSibling.tagName.toLowerCase() === 'br' - ) { - return true; - - } else if (wym.isBlockNode(node.previousSibling)) { - return true; - - } else if (node.previousSibling.nodeType === WYMeditor.NODE_TYPE.TEXT) { - return true; - } - } - return false; -}; - -/** - editor.setCaretBefore - ===================== - - Sets a collapsed selection to immediately before a provided node. - - Not to be confused with `editor.setCaretIn`, which sets a collapsed - selection inside a container node, at the start. - - @param node A node to set the selection to immediately before of. - */ -WYMeditor.editor.prototype.setCaretBefore = function (node) { - var wym = this, - range = rangy.createRange(wym._doc), - selection = wym.selection(); - - if (!wym.canSetCaretBefore(node)) { - throw "Can't set caret before this node."; - } - - range.selectNode(node); - range.collapse(true); - - selection.setSingleRange(range); -}; - -/** - editor.canSetCaretIn - ==================== - - Returns true if it is OK to set a collapsed selection inside a node. - Otherwise returns false. - - @param node A node to check about. - */ -WYMeditor.editor.prototype.canSetCaretIn = function (node) { - var wym = this; - if ( - node.nodeType === WYMeditor.NODE_TYPE.TEXT || - ( - node.tagName && - jQuery.inArray( - node.tagName.toLowerCase(), - WYMeditor.NO_CARET_ELEMENTS - ) > -1 - ) - ) { - return false; - } - // Rangy issue #209. - if (wym.isInlineNode(node)) { - - if (node.childNodes.length === 0) { - // Not possible to work-around this issue. - return false; - } - // It is possible to work-around this issue by setting a non-collapsed - // selection. Warn about this. - WYMeditor.console.warn("Can set a non-collapsed selection. Rangy issue #209."); - } - return true; -}; - -/** - editor.setCaretIn - ================= - - Sets a collapsed selection to inside provided container element, at the start. - - Not to be confused with `editor.setCaretBefore`, which sets a collapsed - selection immediately before a node. - - @param element An element to set the selection inside of, at the start. - */ -WYMeditor.editor.prototype.setCaretIn = function (element) { - var wym = this, - range = rangy.createRange(wym._doc), - selection = wym.selection(); - - if ( - !wym.canSetCaretIn(element) - ) { - throw "The element must be able to contain other elements. Perhaps " + - " you would like to use `setCaretBefore`, instead."; - } - - range.selectNodeContents(element); - - // Rangy issue #209. - if (wym.isInlineNode(element)) { - - // Don't collapse the range. As long as - // this occurs only in tests it is probably OK. Warn. - WYMeditor.console.warn("Can't set a collapsed selection. Setting " + - "a non-collapsed selection, instead. Rangy issue #209."); - } else { - range.collapse(true); - } - - selection.setSingleRange(range); -}; - -/** - editor._splitListItemContents - ============================= - - Utility - - Splits a list item into the content that should stay with the li as it is - indented/outdent and the things that should stay at their current indent level. - - `itemContents` are what a user would consider that list's contents - `sublistContents` are the sub-items that are nested inside the li - (basically everything after the first ol/ul inclusive). - - The returned object has `itemContents` and `sublistContents` properties. -*/ -WYMeditor.editor.prototype._splitListItemContents = function ($listItem) { - var $allContents, - i, - elmnt, - hitSublist = false, - splitObject = {itemContents: [], sublistContents: []}; - - $allContents = $listItem.contents(); - - for (i = 0; i < $allContents.length; i++) { - elmnt = $allContents.get(i); - if (hitSublist || jQuery(elmnt).is('ol,ul')) { - // We've hit the first sublist. Everything from this point on is - // considered `sublistContents` - hitSublist = true; - splitObject.sublistContents.push(elmnt); - } else { - splitObject.itemContents.push(elmnt); - } - } - - return splitObject; -}; - -/** - editor._joinAdjacentLists - ========================= - - Utility - - Joins two lists if they are adjacent and are of the same type. - - The end result will be `listTwo`s contents being appended to `listOne` -*/ -WYMeditor.editor.prototype._joinAdjacentLists = function (listOne, listTwo) { - var $listTwoContents; - - if (typeof listOne === 'undefined' || - typeof listTwo === 'undefined') { - // Invalid arguments - return; - } - if (listOne.nextSibling !== listTwo || - listOne.tagName.toLowerCase() !== listTwo.tagName.toLowerCase()) { - return; - } - - $listTwoContents = jQuery(listTwo).contents(); - $listTwoContents.unwrap(); // Kill listTwo - $listTwoContents.detach(); - jQuery(listOne).append($listTwoContents); -}; - -/** - editor._indentSingleItem - ======================== - - Indent a single list item via the dom, ensuring that the selected node moves in - exactly one level and all other nodes stay at the same level. - */ -WYMeditor.editor.prototype._indentSingleItem = function (listItem) { - var wym = this, - $liToIndent, - listType, - spacerHtml, - containerHtml, - - splitContent, - $itemContents, - $sublistContents, - - $prevLi, - $prevSublist, - $firstSublist, - - $spacer, - $spacerContents; - - // The algorithm used here is generally: - // 1. Ensure there's a previous li to put the `liToIndent`. - // 2. Move the `liToIndent` into a sublist in the previous li. - // 3. If we added a spacer_li after `liToIndent` remove it and move its - // contents inside `liToIndent`. - - // For step 2, the sublist to use can either be: - // 1. An existing sublist of the correct type at the end of the previous li. - // 2. An existing sublist inside `liToIndent`. - // 3. A new sublist that we create. - - $liToIndent = jQuery(listItem); - listType = $liToIndent.parent()[0].tagName.toLowerCase(); - - // Separate out the contents into things that should stay with the li as it - // moves and things that should stay at their current level - splitContent = wym._splitListItemContents($liToIndent); - $sublistContents = jQuery(splitContent.sublistContents); - $itemContents = jQuery(splitContent.itemContents); - - $prevLi = $liToIndent.prev().filter('li'); - // Ensure we actually have a previous li in which to put the `liToIndent` - if ($prevLi.length === 0) { - spacerHtml = '
  • '; - $liToIndent.before(spacerHtml); - $prevLi = $liToIndent.prev(); - } - - // Move `liToIndent` to a sublist inside its previous sibling li - $prevSublist = $prevLi.contents().last().filter('ol,ul'); - if ($prevSublist.length > 0) { - // Case 1: We have a sublist at the appropriate level as a previous - // sibling. Leave the sublist contents where they are and join the - // previous sublist - - // Join our node at the end of the target sublist - $prevSublist.append($liToIndent); - - // Stick all of the sublist contents at the end of the previous li - $sublistContents.detach(); - $prevLi.append($sublistContents); - - // If we just moved two lists of the same type next to eachother, join - // them - $firstSublist = $sublistContents.first(); - wym._joinAdjacentLists($prevSublist.get(0), $firstSublist.get(0)); - } else { - if ($sublistContents.length > 0) { - // Case 2: We need to move our existing sublist to the previous li - $sublistContents.detach(); - $prevLi.append($sublistContents); - $prevSublist = $sublistContents.first(); - } else { - // Case 3: Create a spacer sublist in the previous li in which to - // place `liToIndent` - containerHtml = '<' + listType + '>'; - $prevLi.append(containerHtml); - $prevSublist = $prevLi.contents().last(); - } - - // Move our li to the start of the sublist - $prevSublist.prepend($liToIndent); - } - - // If we eliminated the need for a spacer_li, remove it - if ($liToIndent.next().is('.spacer_li')) { - $spacer = $liToIndent.next('.spacer_li'); - $spacerContents = $spacer.contents(); - $spacerContents.detach(); - $liToIndent.append($spacerContents); - $spacer.remove(); - } - -}; - -/** - editor._outdentSingleItem - ========================= - - Outdent a single list item via the dom, ensuring that the selected node moves in - exactly one level and all other nodes stay at the same level. - */ -WYMeditor.editor.prototype._outdentSingleItem = function (listItem) { - var wym = this, - $liToOutdent, - listType, - spacerListHtml, - - splitContent, - $itemContents, - $sublistContents, - - $parentLi, - $parentList, - - $subsequentSiblingContent, - $subsequentParentListSiblingContent, - - $sublist; - - // The algorithm used here is generally: - // 1. Gather all subsequent sibling content in `liToIndent`s list along - // with all subsequent sibling content in `liToIndent`s parent list. - // 2. Move `liToIndent` after the li whose sublist it's in. - // 3. Create a sublist of the same type of `liToIndent`s parent list inside - // `liToIndent`. - // 4. If `liToIndent` has a sublist, use a spacer_li and list to hold its - // position inside the new sublist. - // 5. Append all original subsequent siblings inside the created sublist. - // 6. Append all of `liToIndent`s original parent list subsequent sibling - // content after the created sublist. - // 7. Remove `liToOutdent`'s original parent list and parent li if either - // are now empty - - $liToOutdent = jQuery(listItem); - listType = $liToOutdent.parent()[0].tagName.toLowerCase(); - - // If this list item isn't already indented at least one level, don't allow - // outdenting - if (!$liToOutdent.parent().parent().is('ol,ul,li')) { - return; - } - if (!$liToOutdent.parent().parent().is('li')) { - // We have invalid list nesting and we need to fix that - WYMeditor.console.log( - 'Attempting to fix invalid list nesting before outdenting.' - ); - wym._fixInvalidListNesting(listItem); - } - - // Separate out the contents into things that should stay with the li as it - // moves and things that should stay at their current level - splitContent = wym._splitListItemContents($liToOutdent); - $sublistContents = jQuery(splitContent.sublistContents); - $itemContents = jQuery(splitContent.itemContents); - - // Gather subsequent sibling and parent sibling content - $parentLi = $liToOutdent.parent().parent('li'); - // Invalid HTML could cause this selector to fail, which breaks our logic. - // Bail out rather than possibly losing content - if ($parentLi.length === 0) { - WYMeditor.console.error('Invalid list. No parentLi found, so aborting outdent'); - return; - } - $parentList = $liToOutdent.parent(); - $subsequentSiblingContent = $liToOutdent.nextAllContents(); - $subsequentParentListSiblingContent = $parentList.nextAllContents(); - - // Move the li to after the parent li - $liToOutdent.detach(); - $parentLi.after($liToOutdent); - - // If this node has one or more sublists, they will need to be indented - // by one with a fake parent to hold their previous position - if ($sublistContents.length > 0) { - spacerListHtml = '<' + listType + '>' + - '
  • ' + - ''; - $liToOutdent.append(spacerListHtml); - $sublist = $liToOutdent.children().last(); - // Add all of the sublistContents inside our new spacer li - $sublistContents.detach(); - $sublist.children('li').append($sublistContents); - } - - if ($subsequentSiblingContent.length > 0) { - // Nest the previously-subsequent items inside the list to - // retain order and their indent level - if (typeof $sublist === 'undefined') { - // Insert a sublist if we don't already have one - spacerListHtml = '<' + listType + '>'; - $liToOutdent.append(spacerListHtml); - $sublist = $liToOutdent.children().last(); - } - $subsequentSiblingContent.detach(); - $sublist.append($subsequentSiblingContent); - } - - // If we have a parentItem with content after our parent list - // eg.
      - //
    1. one - //
        - // two - //
          - // three - // - //
    - // we'll need to split that parentItem to retain proper content ordering - if ($subsequentParentListSiblingContent.length > 0) { - // Move the subsequent content in to a new list item after our parent li - $subsequentParentListSiblingContent.detach(); - - // If our last content and the first content in the subsequent content - // are both text nodes, insert a
    spacer to avoid crunching the - // text together visually. This maintains the same "visual" structure. - if ($liToOutdent.contents().length > 0 && - $liToOutdent.contents().last()[0].nodeType === WYMeditor.NODE_TYPE.TEXT && - $subsequentParentListSiblingContent[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - $liToOutdent.append('
    '); - } - - $liToOutdent.append($subsequentParentListSiblingContent); - } - - // Remove our parentList if it's empty and if we just removed that, the - // parentLi is likely to be empty also - if ($parentList.contents().length === 0) { - $parentList.remove(); - } - if ($parentLi.contents().length === 0) { - $parentLi.remove(); - } -}; - -/** - editor._fixInvalidListNesting - ============================= - - Take an li/ol/ul and correct any list nesting issues in the entire list - tree. - - Corrected lists have the following properties: - 1. ol and ul nodes *only* allow li children. - 2. All li nodes have either an ol or ul parent. - - The `alreadyCorrected` argument is used to indicate if a correction has - already been made, which means we need to return true even if no further - corrections are made. - - Returns true if any nodes were corrected. - */ -WYMeditor.editor.prototype._fixInvalidListNesting = function (listItem, alreadyCorrected) { - // Travel up the dom until we're at the root ol/ul/li - var wym = this, - currentNode = listItem, - parentNode, - tagName; - if (typeof alreadyCorrected === 'undefined') { - alreadyCorrected = false; - } - if (!currentNode) { - return alreadyCorrected; - } - while (currentNode.parentNode) { - parentNode = currentNode.parentNode; - if (parentNode.nodeType !== WYMeditor.NODE_TYPE.ELEMENT) { - // Our parent is outside a valid list structure. Stop at this node. - break; - } - tagName = parentNode.tagName.toLowerCase(); - if (tagName !== 'ol' && tagName !== 'ul' && tagName !== 'li') { - // Our parent is outside a valid list structure. Stop at this node. - break; - - } - // We're still traversing up a list structure. Keep going - currentNode = parentNode; - } - // We have the root node. Make sure it's legit - if (jQuery(currentNode).is('li')) { - // We have an li as the "root" because its missing a parent list. - // Correct this problem and then try again to correct the nesting. - WYMeditor.console.log( - "Correcting orphaned root li before correcting invalid list nesting." - ); - wym._correctOrphanedListItem(currentNode); - return wym._fixInvalidListNesting(currentNode, true); - } - if (!jQuery(currentNode).is('ol,ul')) { - WYMeditor.console.error("Can't correct invalid list nesting. No root list found"); - return alreadyCorrected; - } - return wym._fixInvalidlyNestedList(currentNode, alreadyCorrected); -}; - -/** - editor._isPOrDivAfterEnterInEmptyNestedLi(container) - ==================================================== - - Detects one of the types of resulting DOM in issue #430. - - The case is when a 'p' or a 'div' are introduced into the parent 'li'. - Since we don't allow a 'p' or a 'div' directly within 'li's it is replaced - with a 'br'. - - Returns true if detected positively and false otherwise. - - @param container An element to check this about. - */ - -WYMeditor.editor.prototype._isPOrDivAfterEnterInEmptyNestedLi = function -(container) { - if ( - jQuery.inArray( - container.tagName.toLowerCase(), - WYMeditor.DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS - ) > -1 && - container.parentNode.tagName.toLowerCase() === 'li' - ) { - switch (container.childNodes.length) { - case 0: - return true; - case 1: - if ( - container.childNodes[0].tagName && - container.childNodes[0].tagName.toLowerCase() === 'br' - ) { - return true; - } else if ( - container.childNodes[0].nodeType === WYMeditor.NODE_TYPE.TEXT && - container.childNodes[0].data === WYMeditor.NBSP - ) { - return true; - } - } - } - return false; -}; - -/** - editor._isSpilledListAfterEnterInEmptyLi - ======================================== - - Detects one of the types of resulting DOM in issue #430. - - In this type of resulting DOM, the contents of a `li` have been - "spilled" after that `li`. - - Returns true if detected positively and false otherwise. - - @param container An element to check this about. - */ - -WYMeditor.editor.prototype._isSpilledListAfterEnterInEmptyLi = function - (container) { - var wym = this; - if ( - container.tagName.toLowerCase() === 'li' && - container.previousSibling && - wym.isListNode(container.previousSibling) && - container.previousSibling.previousSibling && - container.previousSibling.previousSibling.tagName - .toLowerCase() === 'li' && - wym.isListNode(container.parentNode) - ) { - return true; - } - return false; -}; - -/** - editor._handlePotentialEnterInEmptyNestedLi - =========================================== - - Issue #430. When the caret is in an empty nested `li` and the enter key is - pressed, browsers perform DOM manipulations that are different than what - we desire. - - This detects two out of three types of the DOM manipulations and calls for - their correction. - - The third type of DOM manipulation is harder to detect, but, luckily, it - is tolerable, so it goes undetected. This results in a difference in UX - across browsers. - - For detailed information on this please see the issue #430's description. - - @param keyPressed The code of the key that was pressed, to check whether - it is an enter. - @param container The currently selected container. - */ - -WYMeditor.editor.prototype._handlePotentialEnterInEmptyNestedLi = function ( - keyPressed, container) { - - if (keyPressed !== WYMeditor.KEY_CODE.ENTER) { - // Only an enter key press can result a p/div in an empty nested list. - return null; - } - - var wym = this; - - if (wym._isPOrDivAfterEnterInEmptyNestedLi(container)) { - wym._replaceNodeWithBrAndSetCaret(container); - } else if (wym._isSpilledListAfterEnterInEmptyLi(container)) { - wym._appendSiblingsUntilNextLiToPreviousLi(container); - wym._replaceNodeWithBrAndSetCaret(container); - } -}; - -/** - editor._replaceNodeWithBrAndSetCaret - ==================================== - - Replaces a node with a `br` element and sets caret before it. - - If the previousSibling is inline (except for a `br`) then another `br` - is added before. - - @param node This is the node to be replaced. -*/ -WYMeditor.editor.prototype._replaceNodeWithBrAndSetCaret = function (node) { - var wym = this, - $node = jQuery(node); - - if ( - node.previousSibling && - !node.previousSibling.tagName || - node.previousSibling.tagName.toLowerCase() !== 'br' && - wym.isInlineNode(node.previousSibling) - ) { - $node.before('
    '); - } - - $node.before('
    '); - wym.setCaretBefore(node.previousSibling); - $node.remove(); -}; - -/** - editor._appendSiblingsUntilNextLiToPreviousLi - ============================================= - - This corrects the type of resulting DOM from issue #430 where the - contents of a `li` have been spilled to after that `li`. - - It only corrects the spillage itself and doesn't modify the new `li`. - - @param newLi This is the new 'li' that was created. It is supposed to - contain the caret. -*/ - -WYMeditor.editor.prototype._appendSiblingsUntilNextLiToPreviousLi = - function (newLi) { - - var $newLi = jQuery(newLi), - // The spilled nodes are a subset of these. - $parentContents = $newLi.parent().contents(), - // This is the `li` that spilled its contents. - $sadLi = $newLi.prevAll('li').first(), - // This is the next `li` after the newLi. If it exists, it marks the - // end of the spill. - $nextLi = $newLi.nextAll('li').first(), - // The spill start index is after the source `li`. - spillStart = $sadLi.index() + 1, - $spilled; - - if ($nextLi.length === 1) { - $spilled = $parentContents.slice(spillStart, $nextLi.index()); - } else { - // There are no `li` elements after our newLi. The spill ends at the - // end of its parent. - $spilled = $parentContents.slice(spillStart); - } - $sadLi.append($spilled); -}; - -/** - editor._correctOrphanedListItem - =============================== - - Ensure that the given ophaned list item has a proper list parent. - - Uses the sibling nodes to determine what kind of list should be used. Also - wraps sibling adjacent orphaned li nodes in the same list. - */ -WYMeditor.editor.prototype._correctOrphanedListItem = function (listNode) { - var prevAdjacentLis, - nextAdjacentLis, - $adjacentLis = jQuery(), - prevList, - prevNode; - - prevAdjacentLis = jQuery(listNode).prevContentsUntil(':not(li)'); - nextAdjacentLis = jQuery(listNode).nextContentsUntil(':not(li)'); - - // Merge the collections together - $adjacentLis = $adjacentLis.add(prevAdjacentLis); - $adjacentLis = $adjacentLis.add(listNode); - $adjacentLis = $adjacentLis.add(nextAdjacentLis); - - // Determine if we have a list node in which to insert all of our orphaned - // li's - prevNode = $adjacentLis[0].previousSibling; - if (prevNode && jQuery(prevNode).is('ol,ul')) { - prevList = prevNode; - } else { - // No previous existing list to use. Need to create one - $adjacentLis.before('
      '); - prevList = $adjacentLis.prev()[0]; - } - - // Insert all of the adjacent orphaned lists inside the new parent - jQuery(prevList).append($adjacentLis); -}; - -/** - editor._fixInvalidlyNestedList - ============================== - - This is the function that actually does the list correction. - _fixInvalidListNesting is just a helper function that first finds the root - of the list. - - Returns true if any correction was made. - - We use a reverse preorder traversal to navigate the DOM because we might be: - - * Making nodes children of their previous sibling (in the
        1. ...
      case) - * Adding nodes at the current level (wrapping any non-li node inside a ul/ol in a new li node) - - Adapted from code at: Tavs Dokkedahl from - http://www.jslab.dk/articles/non.recursive.preorder.traversal.part3 - */ -WYMeditor.editor.prototype._fixInvalidlyNestedList = function (listNode, alreadyCorrected) { - var rootNode = listNode, - currentNode = listNode, - wasCorrected = false, - previousSibling, - tagName, - ancestorNode, - nodesToMove, - targetLi, - lastContentNode, - spacerHtml = '
    1. '; - if (typeof alreadyCorrected !== 'undefined') { - wasCorrected = alreadyCorrected; - } - - while (currentNode) { - if (currentNode._wym_visited) { - // This node has already been visited. - // Remove mark for visited nodes - currentNode._wym_visited = false; - // Once we reach the root element again traversal - // is done and we can break - if (currentNode === rootNode) { - break; - } - if (currentNode.previousSibling) { - currentNode = currentNode.previousSibling; - } else { - currentNode = currentNode.parentNode; - } - } else { - // This is the first visit for this node - - // All non-li nodes must have an - // ancestor li node that's closer than any ol/ul ancestor node. - // Basically, everything needs to be inside an li node. - if (currentNode !== rootNode && !jQuery(currentNode).is('li')) { - // We have a non-li node. - // Ensure that we have an li ancestor before we have any ol/ul - // ancestors - - ancestorNode = currentNode; - while (ancestorNode.parentNode) { - ancestorNode = ancestorNode.parentNode; - if (jQuery(ancestorNode).is('li')) { - // Everything is ok. Hit an li before a ol/ul - break; - } - - if (ancestorNode.nodeType !== WYMeditor.NODE_TYPE.ELEMENT) { - // Our parent is outside a valid list structure. Stop at this node. - break; - } - tagName = ancestorNode.tagName.toLowerCase(); - if (tagName === 'ol' || tagName === 'ul') { - // We've hit a list container before any list item. - // This isn't valid html and causes editing problems. - // - // Convert the list to a valid structure that closely - // mimics the layout and behavior of invalidly nested - // content inside a list. The browser treats the - // content similar to how it would treat that same - // content separated by a
      within its previous - // sibling list item, so recreate that structure. - // - // The algorithm for performing this is basically: - // 1. Gather this and any previous siblings up until the - // previous li (if one exists) as content to move. - // 2. If we don't have any previous or subsequent li - // sibling, create a spacer li in which to insert all - // the gathered content. - // 3. Move all of the content to the previous li or the - // subsequent li (in that priority). - WYMeditor.console.log("Fixing orphaned list content"); - wasCorrected = true; - - // Gather this and previous sibling until the previous li - nodesToMove = [currentNode]; - previousSibling = currentNode; - targetLi = null; - while (previousSibling.previousSibling) { - previousSibling = previousSibling.previousSibling; - if (jQuery(previousSibling).is('li')) { - targetLi = previousSibling; - // We hit an li. Store it as the target in - // which to move the nodes - break; - } - nodesToMove.push(previousSibling); - } - - // We have our nodes ordered right to left and we need - // them left to right - nodesToMove.reverse(); - - // If there are no previous siblings, we can join the next li instead - if (!targetLi && nodesToMove.length === 1) { - if (jQuery(currentNode.nextSibling).is('li')) { - targetLi = currentNode.nextSibling; - } - } - - // If we still don't have an li in which to move, we - // need to create a spacer li - if (!targetLi) { - jQuery(nodesToMove[0]).before(spacerHtml); - targetLi = jQuery(nodesToMove[0]).prev()[0]; - } - - // Move all of our content inside the li we've chosen - // If the last content node inside the target li is - // text and so is the first content node to move, separate them - // with a
      to preserve the visual layout of them - // being on separate lines - lastContentNode = jQuery(targetLi).contents().last(); - if (lastContentNode.length === 1 && - lastContentNode[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - if (nodesToMove[0].nodeType === WYMeditor.NODE_TYPE.TEXT) { - jQuery(targetLi).append('
      '); - } - } - jQuery(targetLi).append(jQuery(nodesToMove)); - - break; - - } - // We're still traversing up a list structure. Keep going - } - } - - if (currentNode.lastChild) { - // Since we have childnodes, mark this as visited because - // we'll return later - currentNode._wym_visited = true; - currentNode = currentNode.lastChild; - } else if (currentNode.previousSibling) { - currentNode = currentNode.previousSibling; - } else { - currentNode = currentNode.parentNode; - } - } - } - - return wasCorrected; -}; - -/** - editor._getCommonParentList - =========================== - - Get the common parent ol/ul for the given li nodes. If the parent ol/ul for - each cell isn't the same, returns null. - - @param listItems An array of list item nodes to check for a common parent - @param getClosest If true, checks if the closest list parent to each list - node is the same. If false, checks if the furthest list - parent to each list node is the same. - */ -WYMeditor.editor.prototype._getCommonParentList = function (listItems, getClosest) { - var firstLi, - parentList, - rootList, - haveCommonParent = true; - - listItems = jQuery(listItems).filter('li'); - if (listItems.length === 0) { - return null; - } - firstLi = listItems[0]; - parentList = jQuery(firstLi).parents('ol,ul'); - parentList = (getClosest ? parentList.first() : parentList.last()); - - if (parentList.length === 0) { - return null; - } - rootList = parentList[0]; - - // Ensure that all of the li's have the same parent list - jQuery(listItems).each(function (index, elmnt) { - parentList = jQuery(elmnt).parents('ol,ul'); - parentList = (getClosest ? parentList.first() : parentList.last()); - if (parentList.length === 0 || parentList[0] !== rootList) { - haveCommonParent = false; - } - }); - - if (!haveCommonParent) { - return null; - } - return rootList; -}; - -/** - editor.deselect - =============== - - Removes seletion. -*/ -WYMeditor.editor.prototype.deselect = function () { - var wym = this; - - wym.selection().removeAllRanges(); - // Blur seems to be required for IE8. - wym.body().blur(); -}; - -/** - editor._getSelectedNodes - ======================== - - Returns an array of the selected and partially selected nodes. - - Returns false if there is not selection. - -Returns false if there is no selection. -*/ -WYMeditor.editor.prototype._getSelectedNodes = function () { - var wym = this, - selection = wym.selection(), - selectedNodes; - - if (wym.hasSelection() !== true) { - return false; - } - - selectedNodes = selection.getAllRanges() - .reduce(function (nodes, range) { - return nodes.concat(range.getNodes()); - }, []); - return selectedNodes; -}; - -/** - editor._getSelectedListItems - ============================ - - Determine which `li` nodes are "selected" from the user's standpoint. - - These are the `li` nodes that they would expect to be affected by an action - with the given selection. - - For a better understanding, comments are provided inside. - - @param selection A Rangy Selection object. -*/ -WYMeditor.editor.prototype._getSelectedListItems = function (selection) { - var wym = this, - $selectedContainer, - $selectedNodes, - $selectedLis; - - if (selection.isCollapsed) { - $selectedContainer = jQuery(wym.selectedContainer()); - - if ($selectedContainer.closest('li, table').is('table')) { - // Inside a table and not inside a list inside it. This prevents - // the inclusion of the list item that might be an ancestor of the - // table. - return []; - } - return $selectedContainer.closest('li'); - } - - // All the selected nodes in the selection's first range. - $selectedNodes = jQuery(wym._getSelectedNodes()); - - if ($selectedNodes.closest('li, table').filter('li').length === 0) { - // Selection is in a table before it is in a list. This prevents - // inclusion of the list item that the table may be contained - // in. - return []; - } - - // The technique is to get selected contents of the list items and then - // get their closest parent list items. So we don't want the list elements. - // Some list items may be empty and we do want those so we'll add them back - // later. - $selectedLis = $selectedNodes.not('li, ol, ul') - - // IE doesn't include the Rangy selection boundary `span` in the above - // `.getNodes`. This effects an edge case, where a `li` contains only - // that `span`. - .add($selectedNodes.find('.rangySelectionBoundary')) - - // Add back the text nodes because jQuery.not always excludes them. - .add( - $selectedNodes.filter( - function () { - return wym.nodeType === WYMeditor.NODE_TYPE.TEXT; - } - ) - ) - .closest('li') - - // Add `li`s that are selected and are empty. Because they didn't - // get found by `.closest`. We can safely add them because they don't - // contain other list items so surely if they are in the selection it is - // because the user wants to manipulate them. - .add($selectedNodes.filter('li:empty')) - - // Exclude list items that are children of table elements that are in the - // selection. - .not($selectedNodes.filter('table').find('li')); - - return jQuery.unique($selectedLis.get()); -}; - -/** - editor._selectionOnlyInList - =========================== - - Tests if all of the nodes within the passed selection are contained in one - list. Returns true if all of the nodes are within one list, and returns - false if otherwise. - - @param sel A selection to test for being entirely contained within one - list. -*/ -WYMeditor.editor.prototype._selectionOnlyInList = function (sel) { - var wym = this, - selStartNode, - selEndNode, - i; - - for (i = 0; i < sel.rangeCount; ++i) { - selStartNode = wym.findUp(sel.getRangeAt(i).startContainer, ['li']); - selEndNode = wym.findUp(sel.getRangeAt(i).endContainer, ['li']); - - // If the start or end node is not contained within a list item, return - // false. - if (!selStartNode || !selEndNode) { - return false; - } - - // If the two list items do not have a common parent list, return - // false. - if (!wym._getCommonParentList([selStartNode, selEndNode], false)) { - return false; - } - } - - return true; -}; - -/** - editor.indent - ============= - - Indent the selected list items via the dom. - - Only list items that have a common list will be indented. - */ -WYMeditor.editor.prototype.indent = function () { - var wym = this, - sel = wym.selection(), - listItems, - manipulationFunc, - i; - - // First, make sure this list is properly structured - manipulationFunc = function () { - var selection = wym.selection(), - selectedBlock = wym.get$CommonParent( - selection.anchorNode, - selection.focusNode - )[0], - potentialListBlock = wym.findUp( - selectedBlock, - ['ol', 'ul', 'li'] - ); - return wym._fixInvalidListNesting(potentialListBlock); - }; - if (wym.restoreSelectionAfterManipulation(manipulationFunc)) { - // We actually made some list correction - // Don't actually perform the action if we've potentially just changed - // the list, and maybe the list appearance as a result. - wym.registerModification(); - return true; - } - - // We just changed and restored the selection when possibly correcting the - // lists - sel = wym.selection(); - - // If all of the selected nodes are not contained within one list, don't - // perform the action. - if (!wym._selectionOnlyInList(sel)) { - return false; - } - - // Gather the li nodes the user means to affect based on their current - // selection - listItems = wym._getSelectedListItems(sel); - if (listItems.length === 0) { - return false; - } - - manipulationFunc = function () { - var domChanged = false; - - for (i = 0; i < listItems.length; i++) { - wym._indentSingleItem(listItems[i]); - domChanged = true; - } - - return domChanged; - }; - return wym.restoreSelectionAfterManipulation(manipulationFunc) && - wym.registerModification(); -}; - -/** - editor.outdent - ============== - - Outdent a list item, accounting for firefox bugs to ensure consistent - behavior and valid HTML. -*/ -WYMeditor.editor.prototype.outdent = function () { - var wym = this, - sel = wym.selection(), - listItems, - manipulationFunc, - i; - - // First, make sure this list is properly structured - manipulationFunc = function () { - var selection = wym.selection(), - selectedBlock = wym.get$CommonParent( - selection.anchorNode, - selection.focusNode - )[0], - potentialListBlock = wym.findUp( - selectedBlock, - ['ol', 'ul', 'li'] - ); - return wym._fixInvalidListNesting(potentialListBlock); - }; - if (wym.restoreSelectionAfterManipulation(manipulationFunc)) { - // We actually made some list correction - // Don't actually perform the action if we've potentially just changed - // the list, and maybe the list appearance as a result. - wym.registerModification(); - return true; - } - - // We just changed and restored the selection when possibly correcting the - // lists - sel = wym.selection(); - - // If all of the selected nodes are not contained within one list, don't - // perform the action. - if (!wym._selectionOnlyInList(sel)) { - return false; - } - - // Gather the li nodes the user means to affect based on their current - // selection - listItems = wym._getSelectedListItems(sel); - - if (listItems.length === 0) { - return false; - } - - manipulationFunc = function () { - var domChanged = false; - - for (i = 0; i < listItems.length; i++) { - wym._outdentSingleItem(listItems[i]); - domChanged = true; - } - - return domChanged; - }; - return wym.restoreSelectionAfterManipulation(manipulationFunc) && - wym.registerModification(); -}; - -/** - editor.restoreSelectionAfterManipulation - ======================================== - - A helper function to ensure that the selection is restored to the same - location after a potentially complicated DOM manipulation is performed. This - also handles the case where the DOM manipulation throws an error by cleaning - up any selection markers that were added to the DOM. - - `manipulationFunc` is a function that takes no arguments and performs the - manipulation. It should return `true` if changes were made that could have - potentially destroyed the selection. -*/ -WYMeditor.editor.prototype.restoreSelectionAfterManipulation = function (manipulationFunc) { - var wym = this, - savedSelection = rangy.saveSelection( - rangy.dom.getIframeWindow(wym._iframe) - ), - changesMade = true; - - // If something goes wrong, we don't want to leave selection markers - // floating around - try { - changesMade = manipulationFunc(); - if (changesMade) { - rangy.restoreSelection(savedSelection); - } else { - rangy.removeMarkers(savedSelection); - } - } catch (e) { - WYMeditor.console.error("Error during manipulation"); - WYMeditor.console.error(e); - rangy.removeMarkers(savedSelection); - } - - return changesMade; -}; - -/** - editor._insertOrderedList - ========================= - - Convert the selected block in to an ordered list. - - If the selection is already inside a list, switch the type of the nearest - parent list to an `
        `. If the selection is in a block element that can be a - valid list, place that block element's contents inside an ordered list. - - Pure dom implementation consistently cross-browser implementation of - `execCommand(InsertOrderedList)`. - */ -WYMeditor.editor.prototype._insertOrderedList = function () { - var wym = this, - manipulationFunc; - - // First, make sure this list is properly structured - manipulationFunc = function () { - // There is a design flaw here. Especially in the case where we may - // have multiple root-level lists or even `li` items (which shouldn't - // happen) selected. This code seems to make our tests pass but this - // should be considered broken. - var potentialListBlock = jQuery(wym._getSelectedNodes()) - .parents().addBack().filter('ol, ul, li').last()[0]; - potentialListBlock = potentialListBlock || wym.selectedContainer(); - return wym._fixInvalidListNesting(potentialListBlock); - }; - if (wym.restoreSelectionAfterManipulation(manipulationFunc)) { - // We actually made some list correction - // Don't actually perform the action if we've potentially just changed - // the list, and maybe the list appearance as a result. - wym.registerModification(); - return true; - } - - // Actually perform the list insertion - manipulationFunc = function () { - return wym.insertList('ol'); - }; - - return wym.restoreSelectionAfterManipulation(manipulationFunc) && - wym.registerModification(); -}; - -/** - editor._insertUnorderedList - =========================== - - Convert the selected block in to an unordered list. - - Exactly the same as `editor.insert_orderedlist` except with `
          ` instead. - - Pure dom implementation consistently cross-browser implementation of - `execCommand(InsertUnorderedList)`. - */ -WYMeditor.editor.prototype._insertUnorderedList = function () { - var wym = this, - manipulationFunc; - - // First, make sure this list is properly structured - manipulationFunc = function () { - // There is a design flaw here. Especially in the case where we may - // have multiple root-level lists or even `li` items (which shouldn't - // happen) selected. This code seems to make our tests pass but this - // should be considered broken. - var potentialListBlock = jQuery(wym._getSelectedNodes()) - .parents().addBack().filter('ol, ul, li').last()[0]; - potentialListBlock = potentialListBlock || wym.selectedContainer(); - return wym._fixInvalidListNesting(potentialListBlock); - }; - if (wym.restoreSelectionAfterManipulation(manipulationFunc)) { - // We actually made some list correction - // Don't actually perform the action if we've potentially just changed - // the list, and maybe the list appearance as a result. - wym.registerModification(); - return true; - } - - // Actually perform the list insertion - manipulationFunc = function () { - return wym.insertList('ul'); - }; - - return wym.restoreSelectionAfterManipulation(manipulationFunc) && - wym.registerModification(); -}; - -/** - editor.insertList - ================= - - This either manipulates existing lists or creates a new one. - - The action that will be performed depends on the contents of the - selection and their context. - - This can result in one of: - - 1. Changing the type of lists. - 2. Removing items from list. - 3. Creating a list. - 4. Nothing. - - If existing list items are selected this means either changing list type - or de-listing. Changing list type occurs when selected list items all share - a list of a different type than the requested. Removing items from lists - occurs when selected list items are all of the same type as the requested. - - If no list items are selected, then, if possible, a list will be created. - If not possible, no change is made. - - Returns `true` if a change was made, `false` otherwise. - - @param listType A string, representing the user's action, either 'ul' - or 'ol'. - */ -WYMeditor.editor.prototype.insertList = function (listType) { - var wym = this, - sel = wym.selection(), - listItems, - $listItems, - $parentListsOfDifferentType, - commonParentList, - potentialListBlock; - - listItems = wym._getSelectedListItems(sel); - if (listItems.length > 0) { - // We have existing list items selected. This means either changing - // their parent lists' types or de-listing. - - $listItems = jQuery(listItems); - - $parentListsOfDifferentType = $listItems - .parent(':not(' + listType + ')'); - if ($parentListsOfDifferentType.length > 0) { - // Some of the lists are of a different type than that which was - // requested. - - // Change list type only if selected list items share a common parent - // list. TODO: Change types over several lists: - // https://github.com/wymeditor/wymeditor/issues/541 - commonParentList = wym._getCommonParentList(listItems, true); - if (commonParentList) { - wym.changeListType(commonParentList, listType); - return true; - } - } else { - // List types are the same as requested. De-list. - wym._removeItemsFromList($listItems); - return true; - } - } - // Get a potential block element from selection that could be converted - // into a list: - // TODO: Use `_containerRules['root']` minus the ol/ul and - // `_containerRules['contentsCanConvertToList'] - potentialListBlock = wym.findUp( - wym.selectedContainer(), - WYMeditor.POTENTIAL_LIST_ELEMENTS - ); - if (potentialListBlock) { - wym.convertToList(potentialListBlock, listType); - return true; - } - // The user has something selected that wouldn't be a valid list - return false; -}; - -WYMeditor.editor.prototype.changeListType = function (list, listType) { - var wym = this; - // Wrap the contents in a new list of `listType` and remove the old list - // container. - return wym.switchTo(list, listType); -}; - -WYMeditor.editor.prototype.convertToList = function (blockElement, listType) { - var wym = this, - $blockElement = jQuery(blockElement), - newListHtml, - $newList; - - // ie6 doesn't support calling wrapInner with a dom node. Build html - newListHtml = '<' + listType + '>
        1. '; - - if (wym.findUp(blockElement, WYMeditor.ROOT_CONTAINERS) === blockElement) { - // TODO: Handle ol/ul elements, since these are now in the `root` - // containers list - - // This is a root container block, so we can just replace it with the - // list structure - $blockElement.wrapInner(newListHtml); - $newList = $blockElement.children(); - $newList.unwrap(); - - return $newList.get(0); - } - // We're converting a block that's not a root container, so we need to nest - // this list around its contents and NOT remove the container (eg. a td - // node). - $blockElement.wrapInner(newListHtml); - $newList = $blockElement.children(); - - return $newList.get(0); -}; - -/** - editor._removeItemsFromList - =========================== - - De-list the provided list items. - - @param listItems A jQuery object of list items. -*/ -WYMeditor.editor.prototype._removeItemsFromList = function ($listItems) { - var wym = this, - $listItem, - i, - j, - listItemChild, - $childNodesToTransfer, - k, - $childNodeToTransfer, - rootContainer = wym.documentStructureManager.structureRules - .defaultRootContainer, - attributes; - - // This is left here for future reference because it may or may not be a - // better behavior: - // It is reasonable to de-list only a subset of the provided list items. - // The subset are the list items which are not ancestors of any other list - // items. - //$listItems = $listItems.not($listItems.find('li')); - - for (i = 0; i < $listItems.length; i++) { - $listItem = $listItems.eq(i); - - // Determine the type of element this list item will be transformed - // into and call for this transformation. - if ($listItem.parent().parent('li, th, td').length === 1) { - // The list item will end up inside another list item or inside a - // table cell. Turn it into a `span`. - $listItem = jQuery( - wym.switchTo( - $listItem[0], - 'span', - false - ) - ); - } else { - // The list item will end up in the root of the document. Turn it - // into a default root container. - $listItem = jQuery( - wym.switchTo( - $listItem[0], - rootContainer, - false - ) - ); - } - // The transformation should be complete and the element is no longer - // a list item, hence we call it 'the de-listed element'. - - // Move the de-listed element according to its relation to its - // sibling nodes. - if ($listItem.parent().children().length === 1) { - // It is the only child in the list. - - $listItem.parent().before($listItem); - // Remove the list because it is empty. - $listItem.next().remove(); - - } else if ($listItem[0] === $listItem.parent().children().first()[0]) { - // It is not the only child. It is the first child. - - $listItem.parent().before($listItem); - } else if ( - $listItem[0] !== $listItem.parent().children().first()[0] && - $listItem[0] !== $listItem.parent().children().last()[0] - ) { - // It is not the first and not the last child. - $listItem.parent().before( - '<' + $listItem.parent()[0].tagName + '/>' - ); - jQuery($listItem.prevAll().toArray().reverse()) - .appendTo($listItem.parent().prev()); - $listItem.parent().before($listItem); - - } else if ($listItem[0] === $listItem.parent().children().last()[0]) { - // It is not the only child. It is the last child. - $listItem.parent().after($listItem); - } - // The de-listed element should now be at it's final destination. - // Now, deal with its contents. - for (j = 0; j < $listItem.contents().length; j++) { - listItemChild = $listItem.contents()[j]; - if ( - wym.isBlockNode(listItemChild) && - // Prevents a rangy selection boundary element from interfering. - listItemChild.className !== 'rangySelectionBoundary' && - listItemChild.tagName.toLowerCase() !== 'br' - ) { - // We have hit the first block child. From this child onward, - // the contents will be moved to after the de-listed element. - $childNodesToTransfer = $listItem.contents().slice(j); - if ( - $listItem[0].tagName.toLowerCase() === - rootContainer - ) { - // The destination of these nodes is the root element. - // Prepare them as such. - for (k = 0; k < $childNodesToTransfer.length; k++) { - $childNodeToTransfer = $childNodesToTransfer.eq(k); - if ( - $childNodeToTransfer[0] - .nodeType === WYMeditor.NODE_TYPE.TEXT - ) { - $childNodeToTransfer.wrap( - '<' + rootContainer + ' />' - ); - } else if ( - $childNodeToTransfer[0].tagName && - !(wym.isBlockNode($childNodeToTransfer[0])) && - $childNodeToTransfer[0].tagName - .toLowerCase() !== 'br' - ) { - wym.switchTo( - $childNodesToTransfer[k], - rootContainer, - false - ); - } - } - } - // The contents should be ready now. - $listItem.after($listItem.contents().slice(j)); - // The loop was for finding the first block element. - break; - } - } - // `br`s may have been transferred to the root container. They don't - // belong there. - wym.$body().children('br').remove(); - - if ($listItem[0].tagName.toLowerCase() === 'span') { - // Get rid of empty `span`s and ones that contain only `br`s. - if ( - $listItem.contents(':not(.rangySelectionBoundary)') - .length === 0 || - $listItem.contents(':not(.rangySelectionBoundary)').length === - $listItem.contents('br').length - ) { - // The Rangy selection boundary `span` may be inside. - $listItem.before($listItem.contents('.rangySelectionBoundary')); - $listItem.remove(); - } else { - // The `span` wasn't removed. - - // Add `br` elements that may be necessary because by turning - // a `li` element into a `span` element we turn a block - // type element into an inline type element. - if ( - $listItem[0].previousSibling && - $listItem[0].previousSibling.nodeType === WYMeditor - .NODE_TYPE.TEXT || - - $listItem.prevAll(':not(.rangySelectionBoundary)') - .length > 0 && - wym.isBlockNode( - $listItem.prevAll(':not(.rangySelectionBoundary)')[0] - ) === false - ) { - $listItem.before('
          '); - } - if ( - $listItem[0].nextSibling && - $listItem[0].nextSibling.nodeType === WYMeditor - .NODE_TYPE.TEXT || - - $listItem.nextAll(':not(.rangySelectionBoundary)') - .length > 0 && - wym.isBlockNode( - $listItem.nextAll(':not(.rangySelectionBoundary)')[0] - ) === false - ) { - $listItem.after('
          '); - } - - // If the de-listed element has no meaningful attributes, there is - // no use for it being a span. - attributes = $listItem[0].attributes; - wym.unwrapIfMeaninglessSpan($listItem[0]); - } - } - } - - // Reintroduce any necessary DOM-level corrections for editing purposes - wym.prepareDocForEditing(); -}; - -/** - editor.insertTable - ================== - - Insert a table at the current selection with the given number of rows - and columns and with the given caption and summary text. -*/ -WYMeditor.editor.prototype.insertTable = function (rows, columns, caption, summary) { - if ((rows <= 0) || (columns <= 0)) { - // We need rows and columns to make a table - - // TODO: It seems to me we should warn the user when zero columns and/or - // rows were entered. - return; - } - - var wym = this, - table = wym._doc.createElement(WYMeditor.TABLE), - newRow = null, - newCaption, - - x, - y, - container, - selectedNode; - - // Create the table caption - newCaption = table.createCaption(); - newCaption.innerHTML = caption; - - // Create the rows and cells - for (x = 0; x < rows; x += 1) { - newRow = table.insertRow(x); - for (y = 0; y < columns; y += 1) { - newRow.insertCell(y); - } - } - - if (summary !== "") { - // Only need to set the summary if we actually have a summary - jQuery(table).attr('summary', summary); - } - - // Find the currently-selected container - container = jQuery( - wym.findUp(wym.selectedContainer(), WYMeditor.POTENTIAL_TABLE_INSERT_ELEMENTS) - ).get(0); - - if (!container || !container.parentNode) { - // No valid selected container. Put the table at the end. - wym.$body().append(table); - - } else if (jQuery.inArray(container.nodeName.toLowerCase(), - WYMeditor.INLINE_TABLE_INSERTION_ELEMENTS) > -1) { - // Insert table after selection if container is allowed to have tables - // inserted inline. - selectedNode = wym.selection().focusNode; - - // If the selection is within a table, move the selection to the parent - // table to avoid nesting the tables. - if (jQuery.inArray(selectedNode.nodeName.toLowerCase(), - WYMeditor.SELECTABLE_TABLE_ELEMENTS) > -1 || - jQuery.inArray(selectedNode.parentNode.nodeName.toLowerCase(), - WYMeditor.SELECTABLE_TABLE_ELEMENTS) > -1) { - - while (selectedNode.nodeName.toLowerCase() !== WYMeditor.TABLE) { - selectedNode = selectedNode.parentNode; - } - } - - // If the list item itself is selected, append the table to it. If the - // selection is within the list item, put the table after it. Either - // way, this ensures the table will always be inserted within the list - // item. - if (selectedNode.nodeName.toLowerCase() === WYMeditor.LI) { - jQuery(selectedNode).append(table); - } else { - jQuery(selectedNode).after(table); - } - - } else { - // If the table is not allowed to be inserted inline with the - // container, insert it after the container. - jQuery(container).after(table); - } - - // Handle any browser-specific cleanup - wym._afterInsertTable(table); - wym.prepareDocForEditing(); - - wym.registerModification(); - return table; -}; - -/** - editor._afterInsertTable - ======================== - - Handle cleanup/normalization after inserting a table. Different browsers - need slightly different tweaks. -*/ -WYMeditor.editor.prototype._afterInsertTable = function () { -}; - -WYMeditor.editor.prototype._listen = function () { - var wym = this; - - jQuery(wym._doc).bind('paste', function () { - wym._handlePasteEvent(); - }); -}; - -WYMeditor.editor.prototype._handlePasteEvent = function () { - var wym = this; - - // The paste event happens *before* the paste actually occurs. - // Use a timer to delay execution until after whatever is being pasted has - // actually been added. - window.setTimeout( - function () { - jQuery(wym.element).trigger( - WYMeditor.EVENTS.postBlockMaybeCreated, - wym - ); - }, - 20 - ); -}; - -/** - WYMeditor.editor._selectSingleNode - ================================== - - Sets selection to a single node, exclusively. - Not public API because not tested enough. - For example, what happens when selecting containing element, this way? -*/ -WYMeditor.editor.prototype._selectSingleNode = function (node) { - var wym = this, - selection, - nodeRange; - - if (!node) { - throw "Expected a node"; - } - selection = wym.selection(); - nodeRange = rangy.createRangyRange(); - nodeRange.selectNode(node); - - selection.setSingleRange(nodeRange); -}; - -/** - WYMeditor.editor._initSkin - ========================== - - Apply the appropriate CSS class to "activate" that skin's CSS and call the - skin's javascript `init` method. -*/ -WYMeditor.editor.prototype._initSkin = function () { - var wym = this; - // Put the classname (ex. wym_skin_default) on wym_box - jQuery(wym._box).addClass("wym_skin_" + wym._options.skin); - - // Init the skin, if needed - if (typeof WYMeditor.SKINS[wym._options.skin] !== "undefined") { - if (typeof WYMeditor.SKINS[wym._options.skin].init === "function") { - WYMeditor.SKINS[wym._options.skin].init(wym); - } - } else { - WYMeditor.console.warn( - "Chosen skin _" + wym.options.skin + "_ not found." - ); - } -}; - -/** - WYMeditor.editor.body - ===================== - - Returns the document's body element. -*/ -WYMeditor.editor.prototype.body = function () { - var wym = this, - body; - - if (!wym._doc.body) { - throw "The document seems to have no body element."; - } - - body = wym._doc.body; - - if ( - !body.tagName || - body.tagName.toLowerCase() !== 'body' - ) { - throw "The document's body doesn't seem to be a `body` element."; - } - - return body; -}; - -/** - WYMEditor.editor.$body - ====================== - - Returns a jQuery object of the document's body element. -*/ -WYMeditor.editor.prototype.$body = function () { - var wym = this, - body; - - body = wym.body(); - return jQuery(body); -}; - -/** - WYMeditor.editor.doesElementContainSelection - ============================================ - - Returns ``true`` if the supplied element contains at least part of the - selection. - Otherwise returns ``false``. -*/ -WYMeditor.editor.prototype.doesElementContainSelection = function (element) { - var wym = this, - $element, - selectedContainer, - $selectedNodes, - i, - $selectedNodeAncestors, - j; - - if (wym.hasSelection() !== true) { - return false; - } - $element = jQuery(element); - - if (wym.selection().isCollapsed === true) { - selectedContainer = wym.selectedContainer(); - - if (element === selectedContainer) { - return true; - } - if ($element.has(selectedContainer).length > 0) { - return true; - } - return false; - } - - // For non-collapsed selections. - // We could have used the following, but it - // doesn't work in IE8. - // if ($element.has(wym._getSelectedNodes()).length > 0) { - // return true; - // } - $selectedNodes = jQuery(wym._getSelectedNodes()); - for (i = 0; i < $selectedNodes.length; i++) { - $selectedNodeAncestors = $selectedNodes.eq(i).parents(); - for (j = 0; j < $selectedNodeAncestors.length; j++) { - if ($selectedNodeAncestors[j] === element) { - return true; - } - } - } - - return false; -}; - -/*jslint maxlen: 90 */ -/* global -$ */ -"use strict"; - -/** - * WYMeditor.DocumentStructureManager - * ================================== - * - * This manager controls the rules for the subset of HTML that WYMeditor will - * allow the user to create. For technical users, there are justifiable reasons - * to use any in-spec HTML, but for users of WYMeditor (not implementors), the - * goal is make it intuitive for them to create the structured markup that will - * fit their needs. - * - * For example, while it's valid HTML to have a mix - * of DIV and P tags at the top level of a document, in practice, this is - * confusing for non-technical users. The DocumentStructureManager allows the - * WYMeditor implementor to standardize on P tags in the root of the document, - * which will automatically convert DIV tags in the root to P tags. - * - */ -WYMeditor.DocumentStructureManager = function (wym, defaultRootContainer) { - var dsm = this; - dsm._wym = wym; - dsm.structureRules = WYMeditor.DocumentStructureManager.DEFAULTS; - dsm.setDefaultRootContainer(defaultRootContainer); -}; - -jQuery.extend(WYMeditor.DocumentStructureManager, { - // Only these containers are allowed as valid `defaultRootContainer` - // options. - VALID_DEFAULT_ROOT_CONTAINERS : [ - "p", - "div" - ], - - // Cooresponding titles for use in the containers panel for the valid - // default root containers - DEFAULT_ROOT_CONTAINER_TITLES : { - p: "Paragraph", - div: "Division" - }, - - // These containers prevent the user from using up/down/enter/backspace - // to move above or below them, thus effectively blocking the creation - // of new blocks. We must use temporary spacer elements to correct this - // while the document is being edited. - CONTAINERS_BLOCKING_NAVIGATION : ["table", "blockquote", "pre"], - - - DEFAULTS : { - // By default, this container will be used for all root contents. This - // defines the container used when "enter" is pressed from the root and - // also which container wraps or replaces containers found at the root - // that aren't allowed. Only - // `DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS` are allowed - // here. Whichever you choose, the VALID_DEFAULT_ROOT_CONTAINERS will - // be automatically converted when found at the top level of your - // document. - defaultRootContainer: 'p', - - // These containers cannot be used as root containers. This includes - // any default root containers that are not the chosen default root - // container. By default, this is set to the list of valid root - // containers that are not the defaultRootContainer. - notValidRootContainers: ['div'], - - // Only these containers are allowed as a direct child of the body tag. - // All other containers located there will be wrapped in the - // `defaultRootContainer`, unless they're one of the tags in - // `convertIfRoot`. - validRootContainers: [ - 'p', - 'div', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'pre', - 'blockquote', - 'table', - 'ol', - 'ul' - ], - - // If these tags are found in the root, they'll be converted to the - // `defaultRootContainer` container instead of the default of being - // wrapped. - convertIfRootContainers: [ - 'div' - ], - - // The elements that are allowed to be turned in to lists. - validListConversionTargetContainers: [ - "p", - "div", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "pre", - "blockquote", - "td", - "th" - ], - - // For most block elements, the default behavior when a user attempts - // to convert it to a list is to convert that block to a ol/ul and wrap - // the contents in an li. For containers in `wrapContentsInList`, - // instead of converting the container, we should just wrap the - // contents of the container in a ul/ol + li. - wrapContentsInList: [ - 'td', - 'th' - ] - } -}); - -/** - * Set the default container created/used in the root. - * - * @param defaultRootContainer String A string representation of the tag to - * use. - */ -WYMeditor.DocumentStructureManager.prototype.setDefaultRootContainer = function -( - defaultRootContainer -) { - var dsm = this, - validContainers, - index, - DSManager; - - if (dsm.structureRules.defaultRootContainer === defaultRootContainer) { - // This is already our current configuration. No need to do the - // work again. - return; - } - - // Make sure the new container is one of the valid options - DSManager = WYMeditor.DocumentStructureManager; - validContainers = DSManager.VALID_DEFAULT_ROOT_CONTAINERS; - index = jQuery.inArray(defaultRootContainer, validContainers); - if (index === -1) { - throw new Error( - "a defaultRootContainer of '" + - defaultRootContainer + - "' is not supported" - ); - } - - dsm.structureRules.defaultRootContainer = defaultRootContainer; - - // No other possible option for default root containers is valid expect for - // the one choosen default root container - dsm.structureRules.notValidRootContainers = - WYMeditor.DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS; - dsm.structureRules.notValidRootContainers.splice(index, 1); - - dsm._adjustDefaultRootContainerUI(); - - // TODO: Actually do all of the switching required to move from p to div or - // from div to p for the topLevelContainer -}; - -/** - _adjustDefaultRootContainerUI - ============================= - - Adds a new link for the default root container to the containers panel in - the editor if needed, and removes any other links for valid default root - containers form the containers panel besides the link for the chosen - default root container. -*/ -WYMeditor.DocumentStructureManager.prototype._adjustDefaultRootContainerUI = function () { - var dsm = this, - wym = dsm._wym, - defaultRootContainer = dsm.structureRules.defaultRootContainer, - $containerItems, - $containerLink, - $newContainerItem, - containerName, - newContainerLinkNeeded, - newContainerLinkHtml, - i, - DSManager; - - $containerItems = jQuery(wym._box).find(wym._options.containersSelector) - .find('li'); - newContainerLinkNeeded = true; - - // Remove container links for any other valid default root container from - // the containers panel besides the link for the chosen default root - // container - for (i = 0; i < $containerItems.length; ++i) { - $containerLink = $containerItems.eq(i).find('a'); - containerName = $containerLink.attr('name').toLowerCase(); - if (jQuery.inArray(containerName, - dsm.structureRules.notValidRootContainers) > -1) { - $containerItems.eq(i).remove(); - } - if (containerName === defaultRootContainer) { - newContainerLinkNeeded = false; - } - } - - // Add new link for the default root container to the containers panel if - // needed - if (newContainerLinkNeeded) { - newContainerLinkHtml = wym._options.containersItemHtml; - newContainerLinkHtml = WYMeditor.Helper.replaceAllInStr( - newContainerLinkHtml, - WYMeditor.CONTAINER_NAME, - defaultRootContainer.toUpperCase() - ); - DSManager = WYMeditor.DocumentStructureManager; - newContainerLinkHtml = WYMeditor.Helper.replaceAllInStr( - newContainerLinkHtml, - WYMeditor.CONTAINER_TITLE, - DSManager.DEFAULT_ROOT_CONTAINER_TITLES[defaultRootContainer] - ); - newContainerLinkHtml = WYMeditor.Helper.replaceAllInStr( - newContainerLinkHtml, - WYMeditor.CONTAINER_CLASS, - "wym_containers_" + defaultRootContainer - ); - $newContainerItem = jQuery(newContainerLinkHtml); - $containerItems = jQuery(wym._box).find(wym._options.containersSelector) - .find('li'); - $containerItems.eq(0).before($newContainerItem); - - // Bind click event for the new link - $newContainerItem.find('a').click(function () { - var button = this; - wym.setRootContainer(jQuery(button).attr(WYMeditor.NAME)); - return false; - }); - } -}; - - -/* jshint maxlen:100 */ -"use strict"; - -/* - * # The Image Handler - * - * Give it an editor instance and it will make - * most of your image resizing dreams come true. - * - * ## IE8 Shenanigans - * - * When IE8 is not longer supported, - * `rem` could be used for more accurate UI element dimensions - * - * Dragging and dropping of images is not suggested in the UI. - * See the `_isImgDragDropAllowed` function - * and the `_onImgMousedown` function. - * - * ## IE9 Shenanigans - * - * Dragging and dropping of images is disabled. - * See the `_isImgDragDropAllowed` function. - * - * ## IE8-11 Shenanigans - * - * SVG images are not scaled. - * They are cropped. That's right. - * And applying style to them does not help, - * as well. Ideas are welcome. - * - * ## General Shenanigans (http://i.imgur.com/wbQ6U5C.jpg) - * - * This module is covered by only a few basic tests - * so any change must be meticulously manually tested - * in all the supported browsers - * by psychologically stable individuals. - * - * Dragging and dropping of images - * might produce undesired results on drop. - * Uncharted territory. - * - * In event handlers of events that - * are not expected to perform useful default actions - * `return false` is used to prevent any bad feelings - * towards unexpected browser behavior. - */ - -// the image handler class. -WYMeditor.ImageHandler = function (wym) { - var ih = this; - ih._wym = wym; - - ih._$resizeHandle = ih._createResizeHandle(); - - ih._$currentImageMarker = null; - - // references the image that - // has the resize handle placed on it - ih._$currentImg = null; - - // flags whether a resize operation is - // occurring at this moment - ih._resizingNow = false; - - ih._imgDragDropAllowed = WYMeditor.ImageHandler._isImgDragDropAllowed(); - - ih._addEventListeners(); - - return ih; -}; - -WYMeditor.ImageHandler._isImgDragDropAllowed = function () { - var browser = jQuery.browser; - if (browser.msie) { - if (browser.versionNumber <= 9) { - // dragging and dropping seems to not consistently work. - // the image would only some times get picked up by the mouse drag attempt. - // to prevent confusion - return false; - } - } - return true; -}; - -WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML = jQuery('
          ') - .addClass(WYMeditor.EDITOR_ONLY_CLASS) - .css({margin: 0, padding: 0}) - .attr('outerHTML'); - -WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML = [ - 'drag this to resize', - 'click on image to select' -].join(WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML); - -WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR = 'yellow'; - -// creates and returns -// a yet detached UI resize handle element -// in a jQuery object -WYMeditor.ImageHandler.prototype._createResizeHandle = function () { - var $handle = jQuery('
          '); - - // In IE11 it was very easy to - // accidentally enter into editing mode - // in the resize handle. - // This seamlessly prevents it. - $handle.attr('contentEditable', 'false'); - - $handle.html(WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML); - - $handle - .addClass(WYMeditor.RESIZE_HANDLE_CLASS) - .addClass(WYMeditor.EDITOR_ONLY_CLASS); - - $handle.css({ - margin: '0', - padding: '0', - - // when IE9 is no longer supported - // this could be `ns-resize` - cursor: 'row-resize', - - 'text-align': 'center', - - // this means that - // elements after the resize handle - // will not be pushed down because of its presence. - // we later use the `left` and `top` properties - // to keep the resize handle exactly - // below its current image - position: 'absolute', - - 'background-color': WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR, - - // override default iframe stylesheet - // so that a 'div' does not appear - 'background-image': 'none', - - // so that the text inside the resize handle - // fits in one line. - // in the theoretical future - // the more appropriate value would be - // `min-content` - 'min-width': '13em', - - width: '100%' - }); - - return $handle; -}; - -WYMeditor.ImageHandler.prototype._getCurrentImageMarker = function () { - var ih = this; - if ( - // a marker was not yet created - !ih._$currentImageMarker || - // a marker was destroyed via native edit - !ih._$currentImageMarker.length - ) { - ih._$currentImageMarker = ih._createCurrentImageMarker(); - } - return ih._$currentImageMarker; -}; - -WYMeditor.ImageHandler._IMAGE_MARKER_CLASS = 'wym-image-marker'; - -WYMeditor.ImageHandler.prototype._createCurrentImageMarker = function () { - return jQuery('
          ') - .addClass(WYMeditor.EDITOR_ONLY_CLASS) - .addClass(WYMeditor.ImageHandler._IMAGE_MARKER_CLASS) - .hide(); -}; - -WYMeditor.ImageHandler.prototype._addEventListeners = function () { - var ih = this; - var $doc = jQuery(ih._wym._doc); - - $doc.delegate( - 'img', 'mouseover', - ih._onImgMouseover.bind(ih) - ); - $doc.delegate( - 'img', 'click', - ih._onImgClick.bind(ih) - ); - $doc.delegate( - '.' + WYMeditor.RESIZE_HANDLE_CLASS, 'mousedown', - ih._onResizeHandleMousedown.bind(ih) - ); - $doc.delegate( - 'img', - 'mousedown', - ih._onImgMousedown.bind(ih) - ); - $doc.delegate( - 'img', - 'dragstart', - ih._onImgDragstart.bind(ih) - ); - $doc.bind( - 'mousemove', - ih._onMousemove.bind(ih) - ); - $doc.bind( - 'mouseup', - ih._onMouseup.bind(ih) - ); - ih._edited = new WYMeditor.EXTERNAL_MODULES.Edited( - $doc[0], - function () {}, // do not do anything with strictly sensible edits - ih._onAnyNativeEdit.bind(ih) // handle all edits - ); - $doc.delegate( - '.' + WYMeditor.RESIZE_HANDLE_CLASS, - 'click dblclick', - ih._onResizeHandleClickDblclick.bind(ih) - ); - // useful for debugging - if (false) { - ih._wym.$body().delegate( - '*', - WYMeditor.Helper.getAllEventTypes(ih._wym.$body()[0]), - ih._onAllEvents.bind(ih) - ); - } -}; - -WYMeditor.ImageHandler.prototype._onImgMouseover = function (evt) { - var ih = this; - var $img = jQuery(evt.target); - if ( - !$img.data('cE disabled') && - jQuery.browser.msie - ) { - // in IE8-11 it seems that the default cursor for images - // (in `designMode`) is 'move' (4 directions arrow) - // and simply setting a different cursor - // does not change that default. - // this works around the issue. - // the result is still not just any cursor we'd like, - // but only the 'default' cursor, - // which is better than the default 'move' cursor. - // this workaround does not seem to have obvious side effects - $img.attr('contentEditable', 'false'); - $img.data('cE disabled', true); - } - ih._setImgCursor($img); -}; - -WYMeditor.ImageHandler.prototype._setImgCursor = function ($img) { - var ih = this; - if (ih._wym.getSelectedImage() !== $img[0]) { - // hint that image is selectable by click - $img.css('cursor', 'pointer'); - return; - } - // image is selected - if (ih._imgDragDropAllowed) { - // in IE8-11 this does not work - // and the cursor remains 'default'. - // see the `_onImgMouseover` handler - $img.css('cursor', 'move'); - } else { - $img.css('cursor', 'default'); - } -}; - -WYMeditor.ImageHandler.prototype._onImgClick = function (evt) { - var ih = this; - - // firefox seems to natively select the image on mousedown - // this means that by the time this handler executes, - // the image is already selected. - // - // in IE8, by this point - // the image is always deselected, - // even if it was selected just before the click, - // because the mouse event itself - // causes the deselection of the image - // (see the `_selectImage` method). - // - // because of the above browser limitations, - // it is more simple to always select the image here, - // regardless of whether it is selected already or not - - ih._selectImage(evt.target); - ih._indicateOnResizeHandleThatImageIsSelected(); - return false; -}; - -WYMeditor.ImageHandler.prototype._selectImage = function (img) { - var ih = this; - var $img = jQuery(img); - - if (jQuery.browser.msie && jQuery.browser.versionNumber === 8) { - // in IE8 when the right side of an img is clicked - // (you can't make this up), - // any selection that was set on click is discarded. - // scheduling the image selection - // for after synchronous execution - // works around the issue - setTimeout(function () { - //ih._isAnImgSelected('IE8 ASYNC `_selectImage` (before select)'); // for debugging - ih._wym._selectSingleNode(img); - //ih._isAnImgSelected('IE8 ASYNC `_selectImage` (after select)'); // for debugging - }, 0); - } else { - //ih._isAnImgSelected('`_selectImage` (before select)'); // for debugging - ih._wym._selectSingleNode(img); - //ih._isAnImgSelected('`_selectImage` (after select)'); // for debugging - } - - ih._setImgCursor($img); -}; - -WYMeditor.ImageHandler.prototype._indicateOnResizeHandleThatImageIsSelected = function () { - var ih = this; - - var indication = 'image is selected'; - if (ih._imgDragDropAllowed) { - indication = [ - indication, - 'drag image to move it' - ].join(WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML); - } - - ih._$resizeHandle - .css('font-weight', 'bold') - .html(indication); - - // ideally, the above indication text would remain - // until the image is no longer selected. - // since it is not easy to detect when that happens, - // the indication text is replaced with the initial text - // after a short moment. - setTimeout(function () { - ih._$resizeHandle - .css('font-weight', 'normal') - .html(WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML); - }, 1000); -}; - -WYMeditor.ImageHandler.prototype._placeResizeHandleOnImg = function (img) { - var ih = this; - var IMAGE_PADDING = '0.8em'; - var $img = jQuery(img); - - ih._$currentImg = $img; - - ih._getCurrentImageMarker().insertAfter($img); - - // colored padding around the image and the handle - // visually marks the image - // that currently has the resize handle placed on it. - // it also makes it possible to resize very small images - // (see the `_detachResizeHandle` method) - $img.css({ - 'background-color': WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR, - - 'padding-top': IMAGE_PADDING, - 'padding-right': IMAGE_PADDING, - 'padding-bottom': '0', - 'padding-left': IMAGE_PADDING, - 'margin-top': '-' + IMAGE_PADDING, - 'margin-right': '-' + IMAGE_PADDING, - 'margin-bottom': '0', - 'margin-left': '-' + IMAGE_PADDING - }); - - // the resize handle, prepended to the body in this way, - // can be removed from the body using DOM manipulation - // such as setting the content with the `html` method. - // so we place it there in case that occurred. - // this could be done conditionally - // but there is practically no performance hit so keeping it simple - ih._$resizeHandle.prependTo(ih._wym.$body()); - - // it is important that the resize handle's offset - // is updated after the above style modification - // adds top padding to the image - // because that alters the image's outside height - ih._correctResizeHandleOffsetAndWidth(); - - ih._$resizeHandle.show(); -}; - -WYMeditor.ImageHandler.prototype._correctResizeHandleOffsetAndWidth = function () { - var ih = this; - - ih._$resizeHandle.css('max-width', ih._$currentImg.outerWidth()); - - var offset = ih._$currentImg.offset(); - - ih._$resizeHandle.css('left', offset.left); - - // the Y position of the first pixel after the image's outer Y dimension. - // in other words, just below the image's margin (if it had a margin) - var yAfterImg = offset.top + ih._$currentImg.outerHeight(); - - if (jQuery.browser.msie) { - // in IE8-11 there might be a visible 1 pixes gap - // between the image and the resize handle - // possibly this issue: - // https://github.com/jquery/jquery/issues/1724 - yAfterImg--; - } - - ih._$resizeHandle.css('top', yAfterImg); -}; - -WYMeditor.ImageHandler.prototype._onResizeHandleMousedown = function (evt) { - var ih = this; - - if (!ih._resizingNow) { - ih._startResize(evt.clientY); - } - return false; -}; - -WYMeditor.ImageHandler.prototype._startResize = function (startMouseY) { - var ih = this; - - ih._startMouseY = startMouseY; - ih._$currentImg.data('StartHeight', ih._$currentImg.height()); - ih._resizingNow = true; -}; - -WYMeditor.ImageHandler.prototype._onMousemove = function (evt) { - var ih = this; - - // default action for this event may be a `mousedown` and `mousemove` - // with the intention to select text - // or to drag (for later dropping of) content - // so be careful about preventing default - - if (!evt.target.tagName) { - // IE8 may fire such an event. - // what element was it fired on? - return; - } - - if (ih._resizingNow) { - // this is up high in this method for performance - ih._resizeImage(evt.clientY); - return false; - } - - if ( - evt.target.tagName.toLowerCase() === 'img' && - !ih._isResizeHandleAttached() - ) { - ih._placeResizeHandleOnImg(evt.target); - return false; - } - - if (!ih._isResizeHandleAttached()) { - return; - } - - // from this point on, this event handler is all about - // checking whether the resize handle should be detached - - if ( - !jQuery(evt.target).hasClass(WYMeditor.EDITOR_ONLY_CLASS) && - !ih._isCurrentImg(evt.target) - ) { - // this must be after the above check for whether resizing now - // because, while the resize operation does begin - // with the mouse pointing on the resize handle, - // the mouse might leave the resize handle during the resize operation. - // in that case, we would like the operation to continue - ih._detachResizeHandle(); - return; - } - - if (!ih._isCurrentImgAtMarker()) { - ih._detachResizeHandle(); - return; - } -}; - -WYMeditor.ImageHandler.prototype._isCurrentImgAtMarker = function () { - var ih = this; - var $marker = ih._$currentImageMarker; - if (!$marker.length) { - // the marker was removed by some DOM manipulation - return false; - } - var $img = ih._$currentImg; - var $imgPrevToMarker = $marker.prev('img'); - if ( - $img.length && - $imgPrevToMarker.length && - $imgPrevToMarker[0] === $img[0] - ) { - return true; - } - // this happens when: - // - // * the image was selected and - // * replaced by pasted content - // * replaced by character insertion from key press - // * removed with backspace/delete - // * caret was before/after image and delete/backspace pressed - // * the image was dragged and dropped somewhere - return false; -}; - -WYMeditor.ImageHandler.prototype._isResizeHandle = function (elem) { - return jQuery(elem).hasClass(WYMeditor.RESIZE_HANDLE_CLASS); -}; - -WYMeditor.ImageHandler.prototype._isCurrentImg = function (img) { - var ih = this; - return img === ih._$currentImg[0]; -}; - -WYMeditor.ImageHandler.prototype._resizeImage = function (currentMouseY) { - var ih = this; - var $img = ih._$currentImg; - - var dimensionsRatio = $img.data('DimensionsRatio'); - - if (!dimensionsRatio) { - // in order to prevent dimensions ratio corruption - var originalHeight = $img.height(); - var originalWidth = $img.width(); - dimensionsRatio = originalWidth / originalHeight; - $img.data('DimensionsRatio', dimensionsRatio); - } - - // calculate the new dimensions - var startHeight = $img.data('StartHeight'); - var newHeight = startHeight - ih._startMouseY + currentMouseY; - newHeight = newHeight > 0 ? newHeight : 0; - var newWidth = newHeight * dimensionsRatio; - - // update the dimensions - $img.attr('height', newHeight); - $img.attr('width', newWidth); - - ih._correctResizeHandleOffsetAndWidth(); -}; - -WYMeditor.ImageHandler.prototype._onMouseup = function () { - // this could be a case where - // there was a `mousedown` on a selection - // and then a `mouseup` without having moved the mouse. - // the default action would be - // to collapse the selection to a caret where the pointer is. - // we'd not like to prevent that - - var ih = this; - - if (ih._resizingNow) { - ih._stopResize(); - } -}; - -WYMeditor.ImageHandler.prototype._stopResize = function () { - var ih = this; - - ih._resizingNow = false; - ih._startMouseY = null; - ih._wym.registerModification(); -}; - -WYMeditor.ImageHandler.prototype._onImgMousedown = function (evt) { - var ih = this; - - if (jQuery.browser.msie && jQuery.browser.versionNumber === 11) { - // IE11 on image mousedown places native resize handles around the image. - // selecting the image both here and on `click` refrains from those handles - // completely and seemingly without side effects. - ih._selectImage(evt.target); - // another way to refrain from the handles is preventing default. - // but that would have an undesired side effect - // of not allowing dragging and dropping of images. - } - - // returning false here prevents drag of image - // except for in IE8 - return ih._imgDragDropAllowed; -}; - -WYMeditor.ImageHandler.prototype._onAnyNativeEdit = function () { - var ih = this; - // modifications possibly not have occurred yet. - // schedule immediate async in order to execute - // after the possible modifications may have occurred - setTimeout(ih._handlePossibleModification.bind(ih), 0); -}; - -WYMeditor.ImageHandler.prototype._handlePossibleModification = function () { - var ih = this; - - if (!ih._isResizeHandleAttached()) { - return; - } - - if (!ih._isCurrentImgAtMarker()) { - ih._detachResizeHandle(); - return; - } - - // any edit to the document might result - // in the image ending up in a different position than before. - // for example, inserting a character before the image - // pushes it to the right. - ih._correctResizeHandleOffsetAndWidth(); -}; - -WYMeditor.ImageHandler.prototype._isResizeHandleAttached = function () { - var ih = this; - var $handle = ih._getResizeHandle(); - return $handle && $handle.css('display') !== 'none'; -}; - -WYMeditor.ImageHandler.prototype._getResizeHandle = function () { - var ih = this; - var $handle = ih._wym.$body().find('.' + WYMeditor.RESIZE_HANDLE_CLASS); - return $handle.length ? $handle : false; -}; - -WYMeditor.ImageHandler.prototype._detachResizeHandle = function () { - var ih = this; - - ih._$currentImageMarker.detach(); - if ( - // the size of the image might be so small, - // that it would be hard to mouse over it - // in order to make the resize handle appear. - // in that case (an arbitrary number of pixels) - // leave the padding on, as it will allow - // easy mouse over the image, - // even when the image is 0 in size - ih._$currentImg.height() >= 16 && - ih._$currentImg.width() >= 16 - ) { - ih._$currentImg.css({padding: 0, margin: 0}); - } - ih._$currentImg = null; - ih._$resizeHandle.hide(); -}; - -WYMeditor.ImageHandler.prototype._onImgDragstart = function () { - var ih = this; - ih._detachResizeHandle(); -}; - -WYMeditor.ImageHandler.prototype._onResizeHandleClickDblclick = function () { - var ih = this; - - if (jQuery.browser.msie && jQuery.browser.versionNumber === 11) { - // in IE11 some mouse events on the resize handle - // result in native resize handles on it (eight small squares around it). - // trying to resize the resize handle using these native handles - // fails quite gracefully, as they seem to have no effect at all. - // it fails most likely due to prevented native actions - // in one of our event handlers. - // however, deselecting here completely prevents these handles - ih._wym.deselect(); - } - // prevents entering edit mode in the handle - return false; -}; - -// useful for debugging -WYMeditor.ImageHandler.prototype._isAnImgSelected = function (message) { - var ih = this; - message = message.toUpperCase(); - - function check(prefix) { - var result = ih._wym.getSelectedImage() ? '***YES***' : ''; - prefix = prefix ? prefix + ' ' : ''; - WYMeditor.console.log(prefix + message + ' ' + result); - } - - check('sync'); - - setTimeout(function () { - check('async'); - }, 0); -}; - -// for debugging -WYMeditor.ImageHandler._onAllEvents = function (evt) { - var ih = this; - - ih._isAnImgSelected([ - evt.type, - evt.target.tagName, - jQuery(evt.target).attr('className') - ].join(' ')); -}; - -/*jslint evil: true */ -/* global -$ */ -"use strict"; - -WYMeditor.WymClassGecko = function (wym) { - var wymClassGecko = this; - wymClassGecko._wym = wym; - wymClassGecko._class = "class"; -}; - -// Placeholder cell to allow content in TD cells for FF 3.5+ -WYMeditor.WymClassGecko.CELL_PLACEHOLDER = '
          '; - -// Firefox 3.5 and 3.6 require the CELL_PLACEHOLDER and 4.0 doesn't -WYMeditor.WymClassGecko.NEEDS_CELL_FIX = parseInt( - jQuery.browser.version, 10) === 1 && - jQuery.browser.version >= '1.9.1' && - jQuery.browser.version < '2.0'; - -WYMeditor.WymClassGecko.prototype._docEventQuirks = function () { - var wym = this; - var $doc = jQuery(wym._doc); - - $doc.keyup(wym._keyup.bind(wym)); - $doc.focus(function () { - // not providing _onBodyFocus here because it doesn't exist yet - wym.undoRedo._onBodyFocus(); - }); - $doc.click(wym._click.bind(wym)); -}; - -// Keyup handler, mainly used for cleanups -WYMeditor.WymClassGecko.prototype._keyup = function (evt) { - var wym = this, - container, - defaultRootContainer, - notValidRootContainers, - name, - parentName; - - notValidRootContainers = - wym.documentStructureManager.structureRules.notValidRootContainers; - defaultRootContainer = - wym.documentStructureManager.structureRules.defaultRootContainer; - container = null; - - // If the inputted key cannont create a block element and is not a command, - // check to make sure the selection is properly wrapped in a container - if (!wym.keyCanCreateBlockElement(evt.which) && - evt.which !== WYMeditor.KEY_CODE.CTRL && - evt.which !== WYMeditor.KEY_CODE.COMMAND && - !evt.metaKey && - !evt.ctrlKey) { - - container = wym.selectedContainer(); - name = container.tagName.toLowerCase(); - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - - // Fix forbidden root containers - if (wym.isForbiddenRootContainer(name)) { - name = parentName; - } - - // Replace text nodes with default root tags and make sure the - // container is valid if it is a root container - if (name === WYMeditor.BODY || - (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY)) { - - wym._exec( - WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK, - defaultRootContainer - ); - wym.prepareDocForEditing(); - } - } - - // If we potentially created a new block level element or moved to a new - // one, then we should ensure the container is valid and the formatting is - // proper. - if (wym.keyCanCreateBlockElement(evt.which)) { - // If the selected container is a root container, make sure it is not a - // different possible default root container than the chosen one. - container = wym.selectedContainer(); - name = container.tagName.toLowerCase(); - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - if (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY) { - wym._exec( - WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK, - defaultRootContainer - ); - } - - // Call for the check for--and possible correction of--issue #430. - wym._handlePotentialEnterInEmptyNestedLi(evt.which, container); - - // Fix formatting if necessary - wym.prepareDocForEditing(); - } -}; - -WYMeditor.WymClassGecko.prototype._click = function () { - var wym = this, - container = wym.selectedContainer(), - sel; - - if (WYMeditor.WymClassGecko.NEEDS_CELL_FIX === true) { - if (container && container.tagName.toLowerCase() === WYMeditor.TR) { - // Starting with FF 3.6, inserted tables need some content in their - // cells before they're editable - jQuery(WYMeditor.TD, wym._doc.body).append( - WYMeditor.WymClassGecko.CELL_PLACEHOLDER); - - // The user is still going to need to move out of and then back in - // to this cell if the table was inserted via an inner_html call - // (like via the manual HTML editor). - // TODO: Use rangy or some other selection library to consistently - // put the users selection out of and then back in this cell - // so that it appears to be instantly editable - // Once accomplished, can remove the _afterInsertTable handling - } - } - - if (container && container.tagName.toLowerCase() === WYMeditor.BODY) { - // A click in the body means there is no content at all, so we - // should automatically create a starter paragraph - sel = wym.selection(); - if (sel.isCollapsed === true) { - // If the selection isn't collapsed, we might have a selection that - // drags over the body, but we shouldn't turn everything in to a - // paragraph tag. Otherwise, double-clicking in the space to the - // right of an h2 tag would turn it in to a paragraph - wym._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK, WYMeditor.P); - } - } -}; - -WYMeditor.WymClassGecko.prototype._designModeQuirks = function () { - var wym = this; - // Handle any errors that might occur. - try { - wym._doc.execCommand("styleWithCSS", '', false); - wym._doc.execCommand("enableObjectResizing", false, false); - wym._doc.execCommand("enableInlineTableEditing", false, false); - } catch (e) {} -}; - -/* - * Fix new cell contents and ability to insert content at the front and end of - * the contents. - */ -WYMeditor.WymClassGecko.prototype._afterInsertTable = function (table) { - if (WYMeditor.WymClassGecko.NEEDS_CELL_FIX === true) { - // In certain FF versions, inserted tables need some content in their - // cells before they're editable, otherwise the user has to move focus - // in and then out of a cell first, even with our _click() hack - jQuery(table).find('td').each(function (index, element) { - jQuery(element).append(WYMeditor.WymClassGecko.CELL_PLACEHOLDER); - }); - } -}; - -/*jslint evil: true */ -/* global -$ */ -"use strict"; - -WYMeditor.WymClassWebKit = function (wym) { - var wymClassWebKit = this; - wymClassWebKit._wym = wym; - wymClassWebKit._class = "class"; -}; - -WYMeditor.WymClassWebKit.prototype._docEventQuirks = function () { - var wym = this; - - jQuery(wym._doc).bind("keyup", function (evt) { - wym._keyup(evt); - }); - - wym.keyboard.combokeys.bind( - "shift+enter", - // WebKit's shift+enter seems to create a new paragraph so we fix it - function () { - wym._exec(WYMeditor.EXEC_COMMANDS.INSERT_LINEBREAK); - return false; - } - ); - - wym.$body().bind("focus", function () { - wym.undoRedo._onBodyFocus(); - }); -}; - -// A `div` can be created by breaking out of a list in some cases. Issue #549. -WYMeditor.WymClassWebKit.prototype._inListBreakoutDiv = function (evtWhich) { - var wym = this, - $rootContainer = jQuery(wym.getRootContainer()); - - if ( - evtWhich === WYMeditor.KEY_CODE.ENTER && - $rootContainer.is('div') && - wym.documentStructureManager.defaultRootContainer !== 'div' && - $rootContainer.prev('ol, ul').length === 1 - ) { - return true; - } - return false; -}; - -// Checks whether this is issue #542. -WYMeditor.WymClassWebKit.prototype._isLiInLiAfterEnter = function (evtWhich) { - var wym = this, - nodeAfterSel = wym.nodeAfterSel(), - parentNode, - previousSibling, - previousSiblingChild, - previousPreviousSibling; - - if (evtWhich !== WYMeditor.KEY_CODE.ENTER) { - return false; - } - - if (!nodeAfterSel) { - return false; - } - - parentNode = nodeAfterSel.parentNode; - if (!parentNode) { - return false; - } - if (typeof parentNode.tagName !== 'string') { - return false; - } - if (parentNode.tagName.toLowerCase() !== 'li') { - return false; - } - - previousSibling = nodeAfterSel.previousSibling; - if (!previousSibling) { - return false; - } - if (typeof previousSibling.tagName !== 'string') { - return false; - } - if (previousSibling.tagName.toLowerCase() !== 'li') { - return false; - } - - if (previousSibling.childNodes.length !== 1) { - return false; - } - previousSiblingChild = previousSibling.childNodes[0]; - if (!previousSiblingChild) { - return false; - } - if (typeof previousSiblingChild.tagName !== 'string') { - return false; - } - if (previousSiblingChild.tagName.toLowerCase() !== 'br') { - return false; - } - - previousPreviousSibling = previousSibling.previousSibling; - if (!previousPreviousSibling) { - return false; - } - if (typeof previousPreviousSibling.tagName !== 'string') { - return false; - } - if ( - jQuery.inArray( - previousPreviousSibling.tagName.toLowerCase(), - ['ol', 'ul'] - ) === -1 - ) { - return false; - } - - return true; -}; - -// Fixes issue #542. -WYMeditor.WymClassWebKit.prototype - ._fixLiInLiAfterEnter = function () { - var wym = this, - nodeAfterSel = wym.nodeAfterSel(), - $errorLi = jQuery(nodeAfterSel.previousSibling), - $parentLi = $errorLi.parent('li'), - errorLiIndex = $parentLi.contents().index($errorLi), - $contentsAfterErrorLi = $parentLi.contents().slice(errorLiIndex + 1); - - $errorLi.remove(); - $parentLi.after('

        2. '); - $parentLi.next().append($contentsAfterErrorLi); - wym.setCaretBefore($parentLi.next('li').children().first('br')[0]); -}; - -// Keyup handler, mainly used for cleanups -WYMeditor.WymClassWebKit.prototype._keyup = function (evt) { - var wym = this, - container, - defaultRootContainer, - notValidRootContainers, - name, - parentName, - rootContainer; - - notValidRootContainers = - wym.documentStructureManager.structureRules.notValidRootContainers; - defaultRootContainer = - wym.documentStructureManager.structureRules.defaultRootContainer; - - // Fix to allow shift + return to insert a line break in older safari - if (jQuery.browser.version < 534.1) { - // Not needed in AT MAX chrome 6.0. Probably safe earlier - if (evt.which === WYMeditor.KEY_CODE.ENTER && evt.shiftKey) { - wym._exec('InsertLineBreak'); - } - } - - // If the inputted key cannont create a block element and is not a command, - // check to make sure the selection is properly wrapped in a container - if (!wym.keyCanCreateBlockElement(evt.which) && - evt.which !== WYMeditor.KEY_CODE.CTRL && - evt.which !== WYMeditor.KEY_CODE.COMMAND && - !evt.metaKey && - !evt.ctrlKey) { - - container = wym.selectedContainer(); - name = container.tagName.toLowerCase(); - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - - // Fix forbidden root containers - if (wym.isForbiddenRootContainer(name)) { - name = parentName; - } - - // Replace text nodes with default root tags and make sure the - // container is valid if it is a root container - if (name === WYMeditor.BODY || - (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY)) { - - wym._exec( - WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK, - defaultRootContainer - ); - wym.prepareDocForEditing(); - } - } - - // If we potentially created a new block level element or moved to a new - // one, then we should ensure the container is valid and the formatting is - // proper. - if (wym.keyCanCreateBlockElement(evt.which)) { - // If the selected container is a root container, make sure it is not a - // different possible default root container than the chosen one. - container = wym.selectedContainer(); - name = container.tagName.toLowerCase(); - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - if (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY) { - wym._exec( - WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK, - defaultRootContainer - ); - container = wym.selectedContainer(); - } - - // Issue #542 - if (wym._isLiInLiAfterEnter(evt.which, container)) { - wym._fixLiInLiAfterEnter(); - // Container may have changed. - container = wym.selectedContainer(); - return; - } - - // Call for the check for--and possible correction of--issue #430. - wym._handlePotentialEnterInEmptyNestedLi(evt.which, container); - - // Issue #549. - if (wym._inListBreakoutDiv(evt.which)) { - rootContainer = wym.switchTo( - wym.getRootContainer(), - defaultRootContainer - ); - wym.setCaretIn(rootContainer); - } - - // Fix formatting if necessary - wym.prepareDocForEditing(); - } -}; - -/* jshint evil: true */ -"use strict"; - -WYMeditor.WymClassBlink = function (wym) { - var wymClassBlink = this; - wymClassBlink._wym = wym; -}; - -jQuery.extend( - WYMeditor.WymClassBlink.prototype, - WYMeditor.WymClassWebKit.prototype -); - -/* jshint evil: true */ -"use strict"; - -WYMeditor.WymClassSafari = function (wym) { - var wymClassSafari = this; - wymClassSafari._wym = wym; -}; - -jQuery.extend( - WYMeditor.WymClassSafari.prototype, - WYMeditor.WymClassWebKit.prototype -); - -/*jslint evil: true */ -/* global rangy, -$ */ -"use strict"; - -WYMeditor.WymClassTridentPre7 = function (wym) { - var wymClassTridentPre7 = this; - wymClassTridentPre7._wym = wym; - wymClassTridentPre7._class = "className"; -}; - -WYMeditor.WymClassTridentPre7.prototype._onEditorIframeLoad = function (wym) { - wym._assignWymDoc(); - - if (wym._isDesignModeOn() === false) { - wym._doc.designMode = "On"; - } else { - // Pre-7 Trident Internet Explorer versions reload the Iframe when its - // designMode property is set to "on". So this will run on the second - // time this handler is called. - wym._afterDesignModeOn(); - } -}; - -WYMeditor.WymClassTridentPre7.prototype._assignWymDoc = function () { - var wym = this; - - wym._doc = wym._iframe.contentWindow.document; -}; - -WYMeditor.WymClassTridentPre7.prototype._docEventQuirks = function () { - var wym = this; - - wym._doc.onbeforedeactivate = function () { - wym._saveCaret(); - }; - jQuery(wym._doc).bind('keyup', function (evt) { - wym._keyup(evt); - }); - wym._doc.onkeyup = function () { - wym._saveCaret(); - }; - wym._doc.onclick = function () { - wym._saveCaret(); - }; - - wym.$body().bind("focus", function () { - wym.undoRedo._onBodyFocus(); - }); - - wym._doc.body.onbeforepaste = function () { - wym._iframe.contentWindow.event.returnValue = false; - }; - - wym._doc.body.onpaste = function () { - wym._iframe.contentWindow.event.returnValue = false; - wym.paste(window.clipboardData.getData("Text")); - }; - - // https://github.com/wymeditor/wymeditor/pull/641 - wym.$body().bind("dragend", function (evt) { - if (evt.target.tagName.toLowerCase() === WYMeditor.IMG) { - wym.deselect(); - } - }); - - wym._doc.oncontrolselect = function () { - // this prevents resize handles on various element - // such as images, at least in IE8 - return false; - }; -}; - -WYMeditor.WymClassTridentPre7.prototype._setButtonsUnselectable = function () { - // Mark UI buttons as unselectable (#203) - // Issue explained here: - // http://stackoverflow.com/questions/1470932 - var wym = this, - $buttons = wym.get$Buttons(); - - $buttons.attr('unselectable', 'on'); -}; - -WYMeditor.WymClassTridentPre7.prototype._uiQuirks = function () { - var wym = this; - if (jQuery.browser.versionNumber === 8) { - wym._setButtonsUnselectable(); - } -}; - -WYMeditor.WymClassTridentPre7.prototype._saveCaret = function () { - var wym = this, - nativeSelection = wym._doc.selection; - - if (nativeSelection.type === "None") { - return; - } - wym._doc.caretPos = nativeSelection.createRange(); -}; - -/** - _wrapWithContainer - ================== - - Wraps the passed node in a container of the passed type. Also, restores the - selection to being after the node within its new container. - - @param node A DOM node to be wrapped in a container - @param containerType A string of an HTML tag that specifies the container - type to use for wrapping the node. -*/ -WYMeditor.WymClassTridentPre7.prototype._wrapWithContainer = function ( - node, containerType -) { - var wym = this, - $wrappedNode, - selection, - range; - - $wrappedNode = jQuery(node).wrap('<' + containerType + ' />'); - selection = wym.selection(); - range = rangy.createRange(wym._doc); - range.selectNodeContents($wrappedNode[0]); - range.collapse(); - selection.setSingleRange(range); -}; - -WYMeditor.WymClassTridentPre7.prototype._keyup = function (evt) { - var wym = this, - container, - defaultRootContainer, - notValidRootContainers, - name, - parentName, - forbiddenMainContainer = false, - selectedNode; - - notValidRootContainers = - wym.documentStructureManager.structureRules.notValidRootContainers; - defaultRootContainer = - wym.documentStructureManager.structureRules.defaultRootContainer; - - // If the pressed key can't create a block element and is not a command, - // check to make sure the selection is properly wrapped in a container - if (!wym.keyCanCreateBlockElement(evt.which) && - evt.which !== WYMeditor.KEY_CODE.CTRL && - evt.which !== WYMeditor.KEY_CODE.COMMAND && - !evt.metaKey && - !evt.ctrlKey) { - - container = wym.selectedContainer(); - selectedNode = wym.selection().focusNode; - if (container !== null) { - name = container.tagName.toLowerCase(); - } - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - - // Fix forbidden root containers - if (wym.isForbiddenRootContainer(name)) { - name = parentName; - forbiddenMainContainer = true; - } - - // Wrap text nodes and forbidden root containers with default root node - // tags - if (name === WYMeditor.BODY && selectedNode.nodeName === "#text") { - // If we're in a forbidden root container, switch the selected node - // to its parent node so that we wrap the forbidden root container - // itself and not its inner text content - if (forbiddenMainContainer) { - selectedNode = selectedNode.parentNode; - } - wym._wrapWithContainer(selectedNode, defaultRootContainer); - wym.prepareDocForEditing(); - } - - if (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY) { - wym.switchTo(container, defaultRootContainer); - wym.prepareDocForEditing(); - } - } - - // If we potentially created a new block level element or moved to a new - // one, then we should ensure the container is valid and the formatting is - // proper. - if (wym.keyCanCreateBlockElement(evt.which)) { - // If the selected container is a root container, make sure it is not a - // different possible default root container than the chosen one. - container = wym.selectedContainer(); - name = container.tagName.toLowerCase(); - if (container.parentNode) { - parentName = container.parentNode.tagName.toLowerCase(); - } - if (jQuery.inArray(name, notValidRootContainers) > -1 && - parentName === WYMeditor.BODY) { - wym.switchTo(container, defaultRootContainer); - } - - // Call for the check for--and possible correction of--issue #430. - wym._handlePotentialEnterInEmptyNestedLi(evt.which, container); - - // IE8 bug https://github.com/wymeditor/wymeditor/issues/446 - if ( - evt.which === WYMeditor.KEY_CODE.BACKSPACE && - jQuery.browser.versionNumber === 8 && - container.parentNode && ( - parentName === 'ul' || - parentName === 'ol' - ) - ) { - wym._fixInvalidListNesting(container); - } - - // Fix formatting if necessary - wym.prepareDocForEditing(); - } -}; - -/* jshint evil: true */ -/* global -$ */ -"use strict"; - -/* This file is the custom code for Trident 7 and newer. At the time of writing - * this, it is only IE11. - */ - -WYMeditor.WymClassTrident7 = function (wym) { - var wymClassTrident7 = this; - wymClassTrident7._wym = wym; - wymClassTrident7._class = "class"; -}; - -jQuery.extend( - WYMeditor.WymClassTrident7.prototype, - WYMeditor.WymClassGecko.prototype -); - -jQuery.copyPropsFromObjectToObject( - WYMeditor.WymClassTridentPre7.prototype, - WYMeditor.WymClassTrident7.prototype, - [ - '_exec', - '_keyup', - '_wrapWithContainer' - ] -); - -// Some tests fail in what seems to be an edge case of selection corruption. -// This method makes those tests pass. -// It seems to be an issue with Rangy and IE11. -WYMeditor.WymClassTrident7.prototype.rawHtml = function (html) { - var wym = this; - - if (typeof html === "string") { - wym._doc.designMode = "off"; - wym.$body().html(html); - if (wym._isDesignModeOn() !== true) { - wym._enableDesignModeOnDocument(); - } - } else { - return wym.$body().html(); - } - return false; -}; - -WYMeditor.WymClassTrident7.prototype._docEventQuirks = function () { - var wym = this; - - jQuery(wym._doc).bind("keyup", function (evt) { - wym._keyup(evt); - }); - - // https://github.com/wymeditor/wymeditor/pull/641 - wym.$body().bind("dragend", function (evt) { - if (evt.target.tagName.toLowerCase() === WYMeditor.IMG) { - wym.deselect(); - } - }); - - wym.$body().bind("focus", function () { - wym.undoRedo._onBodyFocus(); - }); -}; - -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.foo = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, iterator, context) { - var result; - any(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); - each(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, iterator, context) { - return _.filter(obj, function(value, index, list) { - return !iterator.call(context, value, index, list); - }, context); - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); - each(obj, function(value, index, list) { - if (!(result = result && iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); - each(obj, function(value, index, list) { - if (result || (result = iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if the array or object contains a given value (using `===`). - // Aliased as `include`. - _.contains = _.include = function(obj, target) { - if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, function(value){ return value[key]; }); - }; - - // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - _.where = function(obj, attrs, first) { - if (_.isEmpty(attrs)) return first ? null : []; - return _[first ? 'find' : 'filter'](obj, function(value) { - for (var key in attrs) { - if (attrs[key] !== value[key]) return false; - } - return true; - }); - }; - - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - _.findWhere = function(obj, attrs) { - return _.where(obj, attrs, true); - }; - - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See: https://bugs.webkit.org/show_bug.cgi?id=80797 - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity, value: -Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed >= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity, value: Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Shuffle an array. - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - return _.isFunction(value) ? value : function(obj){ return obj[value]; }; - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, value, context) { - var iterator = lookupIterator(value); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - index : index, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index < right.index ? -1 : 1; - }), 'value'); - }; - - // An internal function used for aggregate "group by" operations. - var group = function(obj, value, context, behavior) { - var result = {}; - var iterator = lookupIterator(value || _.identity); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - (_.has(result, key) ? result[key] : (result[key] = [])).push(value); - }); - }; - - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key) { - if (!_.has(result, key)) result[key] = 0; - result[key]++; - }); - }; - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator, context) { - iterator = iterator == null ? _.identity : lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely convert anything iterable into a real, live array. - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); - return _.values(obj); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head` and `take`. The **guard** check - // allows it to work with `_.map`. - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; - }; - - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if (array == null) return void 0; - if ((n != null) && !guard) { - return slice.call(array, Math.max(array.length - n, 0)); - } else { - return array[array.length - 1]; - } - }; - - // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. - // Especially useful on the arguments object. Passing an **n** will return - // the rest N values in the array. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, _.identity); - }; - - // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { - each(input, function(value) { - if (_.isArray(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - - // Return a completely flattened version of an array. - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(concat.apply(ArrayProto, arguments)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var args = slice.call(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(args, "" + i); - } - return results; - }; - - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. - _.object = function(list, values) { - if (list == null) return {}; - var result = {}; - for (var i = 0, l = list.length; i < l; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, l = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < l; i++) if (array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var len = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(len); - - while(idx < len) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - _.bind = function(func, context) { - if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - var args = slice.call(arguments, 2); - return function() { - return func.apply(context, args.concat(slice.call(arguments))); - }; - }; - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. - _.partial = function(func) { - var args = slice.call(arguments, 1); - return function() { - return func.apply(this, args.concat(slice.call(arguments))); - }; - }; - - // Bind all of an object's methods to that object. Useful for ensuring that - // all callbacks defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length === 0) funcs = _.functions(obj); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. - _.throttle = function(func, wait) { - var context, args, timeout, result; - var previous = 0; - var later = function() { - previous = new Date; - timeout = null; - result = func.apply(context, args); - }; - return function() { - var now = new Date; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - timeout = null; - previous = now; - result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - _.debounce = function(func, wait, immediate) { - var timeout, result; - return function() { - var context = this, args = arguments; - var later = function() { - timeout = null; - if (!immediate) result = func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(context, args); - return result; - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return function() { - var args = [func]; - push.apply(args, arguments); - return wrapper.apply(this, args); - }; - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - if (times <= 0) return func(); - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = nativeKeys || function(obj) { - if (obj !== Object(obj)) throw new TypeError('Invalid object'); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - var values = []; - for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); - return values; - }; - - // Convert an object into a list of `[key, value]` pairs. - _.pairs = function(obj) { - var pairs = []; - for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); - return pairs; - }; - - // Invert the keys and values of an object. The values must be serializable. - _.invert = function(obj) { - var result = {}; - for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; - return result; - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - // Objects with different constructors are not equivalent, but `Object`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor))) { - return false; - } - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return result; - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; - }); - - // Define a fallback version of the method in browsers (ahem, IE), where - // there isn't any inspectable "Arguments" type. - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - } - - // Is a given object a finite number? - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - - // Is the given value `NaN`? (NaN is the only number which does not equal itself). - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - // Run a function **n** times. - _.times = function(n, iterator, context) { - var accum = Array(n); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; - }; - - // Return a random integer between min and max (inclusive). - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - - // List of HTML entities for escaping. - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '/': '/' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - - // Regexes containing the keys and values listed immediately above. - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - - // If the value of the named property is a function then invoke it; - // otherwise, return it. - _.result = function(object, property) { - if (object == null) return null; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name){ - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ''; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(text, data, settings) { - var render; - settings = _.defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - index = offset + match.length; - return match; - }); - source += "';\n"; - - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - - // Helper function to continue chaining intermediate results. - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); - -}).call(this); - -},{}],14:[function(require,module,exports){ -(function (global){ -/** - * @license - * Lo-Dash 2.4.2 (Custom Build) - * Build: `lodash modern -o ./dist/lodash.js` - * Copyright 2012-2013 The Dojo Foundation - * Based on Underscore.js 1.5.2 - * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - * Available under MIT license - */ -;(function() { - - /** Used as a safe reference for `undefined` in pre ES5 environments */ - var undefined; - - /** Used to pool arrays and objects used internally */ - var arrayPool = [], - objectPool = []; - - /** Used to generate unique IDs */ - var idCounter = 0; - - /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */ - var keyPrefix = +new Date + ''; - - /** Used as the size when optimizations are enabled for large arrays */ - var largeArraySize = 75; - - /** Used as the max size of the `arrayPool` and `objectPool` */ - var maxPoolSize = 40; - - /** Used to detect and test whitespace */ - var whitespace = ( - // whitespace - ' \t\x0B\f\xA0\ufeff' + - - // line terminators - '\n\r\u2028\u2029' + - - // unicode category "Zs" space separators - '\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' - ); - - /** Used to match empty string literals in compiled template source */ - var reEmptyStringLeading = /\b__p \+= '';/g, - reEmptyStringMiddle = /\b(__p \+=) '' \+/g, - reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; - - /** - * Used to match ES6 template delimiters - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals - */ - var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; - - /** Used to match regexp flags from their coerced string values */ - var reFlags = /\w*$/; - - /** Used to detected named functions */ - var reFuncName = /^\s*function[ \n\r\t]+\w/; - - /** Used to match "interpolate" template delimiters */ - var reInterpolate = /<%=([\s\S]+?)%>/g; - - /** Used to match leading whitespace and zeros to be removed */ - var reLeadingSpacesAndZeros = RegExp('^[' + whitespace + ']*0+(?=.$)'); - - /** Used to ensure capturing order of template delimiters */ - var reNoMatch = /($^)/; - - /** Used to detect functions containing a `this` reference */ - var reThis = /\bthis\b/; - - /** Used to match unescaped characters in compiled string literals */ - var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; - - /** Used to assign default `context` object properties */ - var contextProps = [ - 'Array', 'Boolean', 'Date', 'Function', 'Math', 'Number', 'Object', - 'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN', - 'parseInt', 'setTimeout' - ]; - - /** Used to make template sourceURLs easier to identify */ - var templateCounter = 0; - - /** `Object#toString` result shortcuts */ - var argsClass = '[object Arguments]', - arrayClass = '[object Array]', - boolClass = '[object Boolean]', - dateClass = '[object Date]', - funcClass = '[object Function]', - numberClass = '[object Number]', - objectClass = '[object Object]', - regexpClass = '[object RegExp]', - stringClass = '[object String]'; - - /** Used to identify object classifications that `_.clone` supports */ - var cloneableClasses = {}; - cloneableClasses[funcClass] = false; - cloneableClasses[argsClass] = cloneableClasses[arrayClass] = - cloneableClasses[boolClass] = cloneableClasses[dateClass] = - cloneableClasses[numberClass] = cloneableClasses[objectClass] = - cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true; - - /** Used as an internal `_.debounce` options object */ - var debounceOptions = { - 'leading': false, - 'maxWait': 0, - 'trailing': false - }; - - /** Used as the property descriptor for `__bindData__` */ - var descriptor = { - 'configurable': false, - 'enumerable': false, - 'value': null, - 'writable': false - }; - - /** Used to determine if values are of the language type Object */ - var objectTypes = { - 'boolean': false, - 'function': true, - 'object': true, - 'number': false, - 'string': false, - 'undefined': false - }; - - /** Used to escape characters for inclusion in compiled string literals */ - var stringEscapes = { - '\\': '\\', - "'": "'", - '\n': 'n', - '\r': 'r', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - /** Used as a reference to the global object */ - var root = (objectTypes[typeof window] && window) || this; - - /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; - - /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - - /** Detect the popular CommonJS extension `module.exports` */ - var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; - - /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ - var freeGlobal = objectTypes[typeof global] && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) { - root = freeGlobal; - } - - /*--------------------------------------------------------------------------*/ - - /** - * The base implementation of `_.indexOf` without support for binary searches - * or `fromIndex` constraints. - * - * @private - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {number} Returns the index of the matched value or `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - var index = (fromIndex || 0) - 1, - length = array ? array.length : 0; - - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * An implementation of `_.contains` for cache objects that mimics the return - * signature of `_.indexOf` by returning `0` if the value is found, else `-1`. - * - * @private - * @param {Object} cache The cache object to inspect. - * @param {*} value The value to search for. - * @returns {number} Returns `0` if `value` is found, else `-1`. - */ - function cacheIndexOf(cache, value) { - var type = typeof value; - cache = cache.cache; - - if (type == 'boolean' || value == null) { - return cache[value] ? 0 : -1; - } - if (type != 'number' && type != 'string') { - type = 'object'; - } - var key = type == 'number' ? value : keyPrefix + value; - cache = (cache = cache[type]) && cache[key]; - - return type == 'object' - ? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1) - : (cache ? 0 : -1); - } - - /** - * Adds a given value to the corresponding cache object. - * - * @private - * @param {*} value The value to add to the cache. - */ - function cachePush(value) { - var cache = this.cache, - type = typeof value; - - if (type == 'boolean' || value == null) { - cache[value] = true; - } else { - if (type != 'number' && type != 'string') { - type = 'object'; - } - var key = type == 'number' ? value : keyPrefix + value, - typeCache = cache[type] || (cache[type] = {}); - - if (type == 'object') { - (typeCache[key] || (typeCache[key] = [])).push(value); - } else { - typeCache[key] = true; - } - } - } - - /** - * Used by `_.max` and `_.min` as the default callback when a given - * collection is a string value. - * - * @private - * @param {string} value The character to inspect. - * @returns {number} Returns the code unit of given character. - */ - function charAtCallback(value) { - return value.charCodeAt(0); - } - - /** - * Used by `sortBy` to compare transformed `collection` elements, stable sorting - * them in ascending order. - * - * @private - * @param {Object} a The object to compare to `b`. - * @param {Object} b The object to compare to `a`. - * @returns {number} Returns the sort order indicator of `1` or `-1`. - */ - function compareAscending(a, b) { - var ac = a.criteria, - bc = b.criteria, - index = -1, - length = ac.length; - - while (++index < length) { - var value = ac[index], - other = bc[index]; - - if (value !== other) { - if (value > other || typeof value == 'undefined') { - return 1; - } - if (value < other || typeof other == 'undefined') { - return -1; - } - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to return the same value for - // `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247 - // - // This also ensures a stable sort in V8 and other engines. - // See http://code.google.com/p/v8/issues/detail?id=90 - return a.index - b.index; - } - - /** - * Creates a cache object to optimize linear searches of large arrays. - * - * @private - * @param {Array} [array=[]] The array to search. - * @returns {null|Object} Returns the cache object or `null` if caching should not be used. - */ - function createCache(array) { - var index = -1, - length = array.length, - first = array[0], - mid = array[(length / 2) | 0], - last = array[length - 1]; - - if (first && typeof first == 'object' && - mid && typeof mid == 'object' && last && typeof last == 'object') { - return false; - } - var cache = getObject(); - cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false; - - var result = getObject(); - result.array = array; - result.cache = cache; - result.push = cachePush; - - while (++index < length) { - result.push(array[index]); - } - return result; - } - - /** - * Used by `template` to escape characters for inclusion in compiled - * string literals. - * - * @private - * @param {string} match The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeStringChar(match) { - return '\\' + stringEscapes[match]; - } - - /** - * Gets an array from the array pool or creates a new one if the pool is empty. - * - * @private - * @returns {Array} The array from the pool. - */ - function getArray() { - return arrayPool.pop() || []; - } - - /** - * Gets an object from the object pool or creates a new one if the pool is empty. - * - * @private - * @returns {Object} The object from the pool. - */ - function getObject() { - return objectPool.pop() || { - 'array': null, - 'cache': null, - 'criteria': null, - 'false': false, - 'index': 0, - 'null': false, - 'number': null, - 'object': null, - 'push': null, - 'string': null, - 'true': false, - 'undefined': false, - 'value': null - }; - } - - /** - * Releases the given array back to the array pool. - * - * @private - * @param {Array} [array] The array to release. - */ - function releaseArray(array) { - array.length = 0; - if (arrayPool.length < maxPoolSize) { - arrayPool.push(array); - } - } - - /** - * Releases the given object back to the object pool. - * - * @private - * @param {Object} [object] The object to release. - */ - function releaseObject(object) { - var cache = object.cache; - if (cache) { - releaseObject(cache); - } - object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null; - if (objectPool.length < maxPoolSize) { - objectPool.push(object); - } - } - - /** - * Slices the `collection` from the `start` index up to, but not including, - * the `end` index. - * - * Note: This function is used instead of `Array#slice` to support node lists - * in IE < 9 and to ensure dense arrays are returned. - * - * @private - * @param {Array|Object|string} collection The collection to slice. - * @param {number} start The start index. - * @param {number} end The end index. - * @returns {Array} Returns the new array. - */ - function slice(array, start, end) { - start || (start = 0); - if (typeof end == 'undefined') { - end = array ? array.length : 0; - } - var index = -1, - length = end - start || 0, - result = Array(length < 0 ? 0 : length); - - while (++index < length) { - result[index] = array[start + index]; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Create a new `lodash` function using the given context object. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Object} [context=root] The context object. - * @returns {Function} Returns the `lodash` function. - */ - function runInContext(context) { - // Avoid issues with some ES3 environments that attempt to use values, named - // after built-in constructors like `Object`, for the creation of literals. - // ES5 clears this up by stating that literals must use built-in constructors. - // See http://es5.github.io/#x11.1.5. - context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root; - - /** Native constructor references */ - var Array = context.Array, - Boolean = context.Boolean, - Date = context.Date, - Function = context.Function, - Math = context.Math, - Number = context.Number, - Object = context.Object, - RegExp = context.RegExp, - String = context.String, - TypeError = context.TypeError; - - /** - * Used for `Array` method references. - * - * Normally `Array.prototype` would suffice, however, using an array literal - * avoids issues in Narwhal. - */ - var arrayRef = []; - - /** Used for native method references */ - var objectProto = Object.prototype; - - /** Used to restore the original `_` reference in `noConflict` */ - var oldDash = context._; - - /** Used to resolve the internal [[Class]] of values */ - var toString = objectProto.toString; - - /** Used to detect if a method is native */ - var reNative = RegExp('^' + - String(toString) - .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') - .replace(/toString| for [^\]]+/g, '.*?') + '$' - ); - - /** Native method shortcuts */ - var ceil = Math.ceil, - clearTimeout = context.clearTimeout, - floor = Math.floor, - fnToString = Function.prototype.toString, - getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf, - hasOwnProperty = objectProto.hasOwnProperty, - push = arrayRef.push, - setTimeout = context.setTimeout, - splice = arrayRef.splice, - unshift = arrayRef.unshift; - - /** Used to set meta data on functions */ - var defineProperty = (function() { - // IE 8 only accepts DOM elements - try { - var o = {}, - func = isNative(func = Object.defineProperty) && func, - result = func(o, o, o) && func; - } catch(e) { } - return result; - }()); - - /* Native method shortcuts for methods with the same name as other `lodash` methods */ - var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate, - nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray, - nativeIsFinite = context.isFinite, - nativeIsNaN = context.isNaN, - nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys, - nativeMax = Math.max, - nativeMin = Math.min, - nativeParseInt = context.parseInt, - nativeRandom = Math.random; - - /** Used to lookup a built-in constructor by [[Class]] */ - var ctorByClass = {}; - ctorByClass[arrayClass] = Array; - ctorByClass[boolClass] = Boolean; - ctorByClass[dateClass] = Date; - ctorByClass[funcClass] = Function; - ctorByClass[objectClass] = Object; - ctorByClass[numberClass] = Number; - ctorByClass[regexpClass] = RegExp; - ctorByClass[stringClass] = String; - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a `lodash` object which wraps the given value to enable intuitive - * method chaining. - * - * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: - * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, - * and `unshift` - * - * Chaining is supported in custom builds as long as the `value` method is - * implicitly or explicitly included in the build. - * - * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, - * `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`, - * `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, - * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, - * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, - * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, - * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`, - * `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, - * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, - * `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, - * and `zip` - * - * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`, - * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, - * `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, - * `template`, `unescape`, `uniqueId`, and `value` - * - * The wrapper functions `first` and `last` return wrapped values when `n` is - * provided, otherwise they return unwrapped values. - * - * Explicit chaining can be enabled by using the `_.chain` method. - * - * @name _ - * @constructor - * @category Chaining - * @param {*} value The value to wrap in a `lodash` instance. - * @returns {Object} Returns a `lodash` instance. - * @example - * - * var wrapped = _([1, 2, 3]); - * - * // returns an unwrapped value - * wrapped.reduce(function(sum, num) { - * return sum + num; - * }); - * // => 6 - * - * // returns a wrapped value - * var squares = wrapped.map(function(num) { - * return num * num; - * }); - * - * _.isArray(squares); - * // => false - * - * _.isArray(squares.value()); - * // => true - */ - function lodash(value) { - // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor - return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__')) - ? value - : new lodashWrapper(value); - } - - /** - * A fast path for creating `lodash` wrapper objects. - * - * @private - * @param {*} value The value to wrap in a `lodash` instance. - * @param {boolean} chainAll A flag to enable chaining for all methods - * @returns {Object} Returns a `lodash` instance. - */ - function lodashWrapper(value, chainAll) { - this.__chain__ = !!chainAll; - this.__wrapped__ = value; - } - // ensure `new lodashWrapper` is an instance of `lodash` - lodashWrapper.prototype = lodash.prototype; - - /** - * An object used to flag environments features. - * - * @static - * @memberOf _ - * @type Object - */ - var support = lodash.support = {}; - - /** - * Detect if functions can be decompiled by `Function#toString` - * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). - * - * @memberOf _.support - * @type boolean - */ - support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext); - - /** - * Detect if `Function#name` is supported (all but IE). - * - * @memberOf _.support - * @type boolean - */ - support.funcNames = typeof Function.name == 'string'; - - /** - * By default, the template delimiters used by Lo-Dash are similar to those in - * embedded Ruby (ERB). Change the following template settings to use alternative - * delimiters. - * - * @static - * @memberOf _ - * @type Object - */ - lodash.templateSettings = { - - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'escape': /<%-([\s\S]+?)%>/g, - - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'evaluate': /<%([\s\S]+?)%>/g, - - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type RegExp - */ - 'interpolate': reInterpolate, - - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type string - */ - 'variable': '', - - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type Object - */ - 'imports': { - - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type Function - */ - '_': lodash - } - }; - - /*--------------------------------------------------------------------------*/ - - /** - * The base implementation of `_.bind` that creates the bound function and - * sets its meta data. - * - * @private - * @param {Array} bindData The bind data array. - * @returns {Function} Returns the new bound function. - */ - function baseBind(bindData) { - var func = bindData[0], - partialArgs = bindData[2], - thisArg = bindData[4]; - - function bound() { - // `Function#bind` spec - // http://es5.github.io/#x15.3.4.5 - if (partialArgs) { - // avoid `arguments` object deoptimizations by using `slice` instead - // of `Array.prototype.slice.call` and not assigning `arguments` to a - // variable as a ternary expression - var args = slice(partialArgs); - push.apply(args, arguments); - } - // mimic the constructor's `return` behavior - // http://es5.github.io/#x13.2.2 - if (this instanceof bound) { - // ensure `new bound` is an instance of `func` - var thisBinding = baseCreate(func.prototype), - result = func.apply(thisBinding, args || arguments); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisArg, args || arguments); - } - setBindData(bound, bindData); - return bound; - } - - /** - * The base implementation of `_.clone` without argument juggling or support - * for `thisArg` binding. - * - * @private - * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates clones with source counterparts. - * @returns {*} Returns the cloned value. - */ - function baseClone(value, isDeep, callback, stackA, stackB) { - if (callback) { - var result = callback(value); - if (typeof result != 'undefined') { - return result; - } - } - // inspect [[Class]] - var isObj = isObject(value); - if (isObj) { - var className = toString.call(value); - if (!cloneableClasses[className]) { - return value; - } - var ctor = ctorByClass[className]; - switch (className) { - case boolClass: - case dateClass: - return new ctor(+value); - - case numberClass: - case stringClass: - return new ctor(value); - - case regexpClass: - result = ctor(value.source, reFlags.exec(value)); - result.lastIndex = value.lastIndex; - return result; - } - } else { - return value; - } - var isArr = isArray(value); - if (isDeep) { - // check for circular references and return corresponding clone - var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); - - var length = stackA.length; - while (length--) { - if (stackA[length] == value) { - return stackB[length]; - } - } - result = isArr ? ctor(value.length) : {}; - } - else { - result = isArr ? slice(value) : assign({}, value); - } - // add array properties assigned by `RegExp#exec` - if (isArr) { - if (hasOwnProperty.call(value, 'index')) { - result.index = value.index; - } - if (hasOwnProperty.call(value, 'input')) { - result.input = value.input; - } - } - // exit for shallow clone - if (!isDeep) { - return result; - } - // add the source value to the stack of traversed objects - // and associate it with its clone - stackA.push(value); - stackB.push(result); - - // recursively populate clone (susceptible to call stack limits) - (isArr ? forEach : forOwn)(value, function(objValue, key) { - result[key] = baseClone(objValue, isDeep, callback, stackA, stackB); - }); - - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } - return result; - } - - /** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ - function baseCreate(prototype, properties) { - return isObject(prototype) ? nativeCreate(prototype) : {}; - } - // fallback for browsers without `Object.create` - if (!nativeCreate) { - baseCreate = (function() { - function Object() {} - return function(prototype) { - if (isObject(prototype)) { - Object.prototype = prototype; - var result = new Object; - Object.prototype = null; - } - return result || context.Object(); - }; - }()); - } - - /** - * The base implementation of `_.createCallback` without support for creating - * "_.pluck" or "_.where" style callbacks. - * - * @private - * @param {*} [func=identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns a callback function. - */ - function baseCreateCallback(func, thisArg, argCount) { - if (typeof func != 'function') { - return identity; - } - // exit early for no `thisArg` or already bound by `Function#bind` - if (typeof thisArg == 'undefined' || !('prototype' in func)) { - return func; - } - var bindData = func.__bindData__; - if (typeof bindData == 'undefined') { - if (support.funcNames) { - bindData = !func.name; - } - bindData = bindData || !support.funcDecomp; - if (!bindData) { - var source = fnToString.call(func); - if (!support.funcNames) { - bindData = !reFuncName.test(source); - } - if (!bindData) { - // checks if `func` references the `this` keyword and stores the result - bindData = reThis.test(source); - setBindData(func, bindData); - } - } - } - // exit early if there are no `this` references or `func` is bound - if (bindData === false || (bindData !== true && bindData[1] & 1)) { - return func; - } - switch (argCount) { - case 1: return function(value) { - return func.call(thisArg, value); - }; - case 2: return function(a, b) { - return func.call(thisArg, a, b); - }; - case 3: return function(value, index, collection) { - return func.call(thisArg, value, index, collection); - }; - case 4: return function(accumulator, value, index, collection) { - return func.call(thisArg, accumulator, value, index, collection); - }; - } - return bind(func, thisArg); - } - - /** - * The base implementation of `createWrapper` that creates the wrapper and - * sets its meta data. - * - * @private - * @param {Array} bindData The bind data array. - * @returns {Function} Returns the new function. - */ - function baseCreateWrapper(bindData) { - var func = bindData[0], - bitmask = bindData[1], - partialArgs = bindData[2], - partialRightArgs = bindData[3], - thisArg = bindData[4], - arity = bindData[5]; - - var isBind = bitmask & 1, - isBindKey = bitmask & 2, - isCurry = bitmask & 4, - isCurryBound = bitmask & 8, - key = func; - - function bound() { - var thisBinding = isBind ? thisArg : this; - if (partialArgs) { - var args = slice(partialArgs); - push.apply(args, arguments); - } - if (partialRightArgs || isCurry) { - args || (args = slice(arguments)); - if (partialRightArgs) { - push.apply(args, partialRightArgs); - } - if (isCurry && args.length < arity) { - bitmask |= 16 & ~32; - return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); - } - } - args || (args = arguments); - if (isBindKey) { - func = thisBinding[key]; - } - if (this instanceof bound) { - thisBinding = baseCreate(func.prototype); - var result = func.apply(thisBinding, args); - return isObject(result) ? result : thisBinding; - } - return func.apply(thisBinding, args); - } - setBindData(bound, bindData); - return bound; - } - - /** - * The base implementation of `_.difference` that accepts a single array - * of values to exclude. - * - * @private - * @param {Array} array The array to process. - * @param {Array} [values] The array of values to exclude. - * @returns {Array} Returns a new array of filtered values. - */ - function baseDifference(array, values) { - var index = -1, - indexOf = getIndexOf(), - length = array ? array.length : 0, - isLarge = length >= largeArraySize && indexOf === baseIndexOf, - result = []; - - if (isLarge) { - var cache = createCache(values); - if (cache) { - indexOf = cacheIndexOf; - values = cache; - } else { - isLarge = false; - } - } - while (++index < length) { - var value = array[index]; - if (indexOf(values, value) < 0) { - result.push(value); - } - } - if (isLarge) { - releaseObject(values); - } - return result; - } - - /** - * The base implementation of `_.flatten` without support for callback - * shorthands or `thisArg` binding. - * - * @private - * @param {Array} array The array to flatten. - * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects. - * @param {number} [fromIndex=0] The index to start from. - * @returns {Array} Returns a new flattened array. - */ - function baseFlatten(array, isShallow, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, - length = array ? array.length : 0, - result = []; - - while (++index < length) { - var value = array[index]; - - if (value && typeof value == 'object' && typeof value.length == 'number' - && (isArray(value) || isArguments(value))) { - // recursively flatten arrays (susceptible to call stack limits) - if (!isShallow) { - value = baseFlatten(value, isShallow, isStrict); - } - var valIndex = -1, - valLength = value.length, - resIndex = result.length; - - result.length += valLength; - while (++valIndex < valLength) { - result[resIndex++] = value[valIndex]; - } - } else if (!isStrict) { - result.push(value); - } - } - return result; - } - - /** - * The base implementation of `_.isEqual`, without support for `thisArg` binding, - * that allows partial "_.where" style comparisons. - * - * @private - * @param {*} a The value to compare. - * @param {*} b The other value to compare. - * @param {Function} [callback] The function to customize comparing values. - * @param {Function} [isWhere=false] A flag to indicate performing partial comparisons. - * @param {Array} [stackA=[]] Tracks traversed `a` objects. - * @param {Array} [stackB=[]] Tracks traversed `b` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ - function baseIsEqual(a, b, callback, isWhere, stackA, stackB) { - // used to indicate that when comparing objects, `a` has at least the properties of `b` - if (callback) { - var result = callback(a, b); - if (typeof result != 'undefined') { - return !!result; - } - } - // exit early for identical values - if (a === b) { - // treat `+0` vs. `-0` as not equal - return a !== 0 || (1 / a == 1 / b); - } - var type = typeof a, - otherType = typeof b; - - // exit early for unlike primitive values - if (a === a && - !(a && objectTypes[type]) && - !(b && objectTypes[otherType])) { - return false; - } - // exit early for `null` and `undefined` avoiding ES3's Function#call behavior - // http://es5.github.io/#x15.3.4.4 - if (a == null || b == null) { - return a === b; - } - // compare [[Class]] names - var className = toString.call(a), - otherClass = toString.call(b); - - if (className == argsClass) { - className = objectClass; - } - if (otherClass == argsClass) { - otherClass = objectClass; - } - if (className != otherClass) { - return false; - } - switch (className) { - case boolClass: - case dateClass: - // coerce dates and booleans to numbers, dates to milliseconds and booleans - // to `1` or `0` treating invalid dates coerced to `NaN` as not equal - return +a == +b; - - case numberClass: - // treat `NaN` vs. `NaN` as equal - return (a != +a) - ? b != +b - // but treat `+0` vs. `-0` as not equal - : (a == 0 ? (1 / a == 1 / b) : a == +b); - - case regexpClass: - case stringClass: - // coerce regexes to strings (http://es5.github.io/#x15.10.6.4) - // treat string primitives and their corresponding object instances as equal - return a == String(b); - } - var isArr = className == arrayClass; - if (!isArr) { - // unwrap any `lodash` wrapped values - var aWrapped = hasOwnProperty.call(a, '__wrapped__'), - bWrapped = hasOwnProperty.call(b, '__wrapped__'); - - if (aWrapped || bWrapped) { - return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, callback, isWhere, stackA, stackB); - } - // exit for functions and DOM nodes - if (className != objectClass) { - return false; - } - // in older versions of Opera, `arguments` objects have `Array` constructors - var ctorA = a.constructor, - ctorB = b.constructor; - - // non `Object` object instances with different constructors are not equal - if (ctorA != ctorB && - !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) && - ('constructor' in a && 'constructor' in b) - ) { - return false; - } - } - // assume cyclic structures are equal - // the algorithm for detecting cyclic structures is adapted from ES 5.1 - // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) - var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); - - var length = stackA.length; - while (length--) { - if (stackA[length] == a) { - return stackB[length] == b; - } - } - var size = 0; - result = true; - - // add `a` and `b` to the stack of traversed objects - stackA.push(a); - stackB.push(b); - - // recursively compare objects and arrays (susceptible to call stack limits) - if (isArr) { - // compare lengths to determine if a deep comparison is necessary - length = a.length; - size = b.length; - result = size == length; - - if (result || isWhere) { - // deep compare the contents, ignoring non-numeric properties - while (size--) { - var index = length, - value = b[size]; - - if (isWhere) { - while (index--) { - if ((result = baseIsEqual(a[index], value, callback, isWhere, stackA, stackB))) { - break; - } - } - } else if (!(result = baseIsEqual(a[size], value, callback, isWhere, stackA, stackB))) { - break; - } - } - } - } - else { - // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys` - // which, in this case, is more costly - forIn(b, function(value, key, b) { - if (hasOwnProperty.call(b, key)) { - // count the number of properties. - size++; - // deep compare each property value. - return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, callback, isWhere, stackA, stackB)); - } - }); - - if (result && !isWhere) { - // ensure both objects have the same number of properties - forIn(a, function(value, key, a) { - if (hasOwnProperty.call(a, key)) { - // `size` will be `-1` if `a` has more properties than `b` - return (result = --size > -1); - } - }); - } - } - stackA.pop(); - stackB.pop(); - - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } - return result; - } - - /** - * The base implementation of `_.merge` without argument juggling or support - * for `thisArg` binding. - * - * @private - * @param {Object} object The destination object. - * @param {Object} source The source object. - * @param {Function} [callback] The function to customize merging properties. - * @param {Array} [stackA=[]] Tracks traversed source objects. - * @param {Array} [stackB=[]] Associates values with source counterparts. - */ - function baseMerge(object, source, callback, stackA, stackB) { - (isArray(source) ? forEach : forOwn)(source, function(source, key) { - var found, - isArr, - result = source, - value = object[key]; - - if (source && ((isArr = isArray(source)) || isPlainObject(source))) { - // avoid merging previously merged cyclic sources - var stackLength = stackA.length; - while (stackLength--) { - if ((found = stackA[stackLength] == source)) { - value = stackB[stackLength]; - break; - } - } - if (!found) { - var isShallow; - if (callback) { - result = callback(value, source); - if ((isShallow = typeof result != 'undefined')) { - value = result; - } - } - if (!isShallow) { - value = isArr - ? (isArray(value) ? value : []) - : (isPlainObject(value) ? value : {}); - } - // add `source` and associated `value` to the stack of traversed objects - stackA.push(source); - stackB.push(value); - - // recursively merge objects and arrays (susceptible to call stack limits) - if (!isShallow) { - baseMerge(value, source, callback, stackA, stackB); - } - } - } - else { - if (callback) { - result = callback(value, source); - if (typeof result == 'undefined') { - result = source; - } - } - if (typeof result != 'undefined') { - value = result; - } - } - object[key] = value; - }); - } - - /** - * The base implementation of `_.random` without argument juggling or support - * for returning floating-point numbers. - * - * @private - * @param {number} min The minimum possible value. - * @param {number} max The maximum possible value. - * @returns {number} Returns a random number. - */ - function baseRandom(min, max) { - return min + floor(nativeRandom() * (max - min + 1)); - } - - /** - * The base implementation of `_.uniq` without support for callback shorthands - * or `thisArg` binding. - * - * @private - * @param {Array} array The array to process. - * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function} [callback] The function called per iteration. - * @returns {Array} Returns a duplicate-value-free array. - */ - function baseUniq(array, isSorted, callback) { - var index = -1, - indexOf = getIndexOf(), - length = array ? array.length : 0, - result = []; - - var isLarge = !isSorted && length >= largeArraySize && indexOf === baseIndexOf, - seen = (callback || isLarge) ? getArray() : result; - - if (isLarge) { - var cache = createCache(seen); - indexOf = cacheIndexOf; - seen = cache; - } - while (++index < length) { - var value = array[index], - computed = callback ? callback(value, index, array) : value; - - if (isSorted - ? !index || seen[seen.length - 1] !== computed - : indexOf(seen, computed) < 0 - ) { - if (callback || isLarge) { - seen.push(computed); - } - result.push(value); - } - } - if (isLarge) { - releaseArray(seen.array); - releaseObject(seen); - } else if (callback) { - releaseArray(seen); - } - return result; - } - - /** - * Creates a function that aggregates a collection, creating an object composed - * of keys generated from the results of running each element of the collection - * through a callback. The given `setter` function sets the keys and values - * of the composed object. - * - * @private - * @param {Function} setter The setter function. - * @returns {Function} Returns the new aggregator function. - */ - function createAggregator(setter) { - return function(collection, callback, thisArg) { - var result = {}; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - setter(result, value, callback(value, index, collection), collection); - } - } else { - forOwn(collection, function(value, key, collection) { - setter(result, value, callback(value, key, collection), collection); - }); - } - return result; - }; - } - - /** - * Creates a function that, when called, either curries or invokes `func` - * with an optional `this` binding and partially applied arguments. - * - * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of method flags to compose. - * The bitmask may be composed of the following flags: - * 1 - `_.bind` - * 2 - `_.bindKey` - * 4 - `_.curry` - * 8 - `_.curry` (bound) - * 16 - `_.partial` - * 32 - `_.partialRight` - * @param {Array} [partialArgs] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [partialRightArgs] An array of arguments to append to those - * provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [arity] The arity of `func`. - * @returns {Function} Returns the new function. - */ - function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { - var isBind = bitmask & 1, - isBindKey = bitmask & 2, - isCurry = bitmask & 4, - isCurryBound = bitmask & 8, - isPartial = bitmask & 16, - isPartialRight = bitmask & 32; - - if (!isBindKey && !isFunction(func)) { - throw new TypeError; - } - if (isPartial && !partialArgs.length) { - bitmask &= ~16; - isPartial = partialArgs = false; - } - if (isPartialRight && !partialRightArgs.length) { - bitmask &= ~32; - isPartialRight = partialRightArgs = false; - } - var bindData = func && func.__bindData__; - if (bindData && bindData !== true) { - // clone `bindData` - bindData = slice(bindData); - if (bindData[2]) { - bindData[2] = slice(bindData[2]); - } - if (bindData[3]) { - bindData[3] = slice(bindData[3]); - } - // set `thisBinding` is not previously bound - if (isBind && !(bindData[1] & 1)) { - bindData[4] = thisArg; - } - // set if previously bound but not currently (subsequent curried functions) - if (!isBind && bindData[1] & 1) { - bitmask |= 8; - } - // set curried arity if not yet set - if (isCurry && !(bindData[1] & 4)) { - bindData[5] = arity; - } - // append partial left arguments - if (isPartial) { - push.apply(bindData[2] || (bindData[2] = []), partialArgs); - } - // append partial right arguments - if (isPartialRight) { - unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs); - } - // merge flags - bindData[1] |= bitmask; - return createWrapper.apply(null, bindData); - } - // fast path for `_.bind` - var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; - return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); - } - - /** - * Used by `escape` to convert characters to HTML entities. - * - * @private - * @param {string} match The matched character to escape. - * @returns {string} Returns the escaped character. - */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; - } - - /** - * Gets the appropriate "indexOf" function. If the `_.indexOf` method is - * customized, this method returns the custom method, otherwise it returns - * the `baseIndexOf` function. - * - * @private - * @returns {Function} Returns the "indexOf" function. - */ - function getIndexOf() { - var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result; - return result; - } - - /** - * Checks if `value` is a native function. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a native function, else `false`. - */ - function isNative(value) { - return typeof value == 'function' && reNative.test(value); - } - - /** - * Sets `this` binding data on a given function. - * - * @private - * @param {Function} func The function to set data on. - * @param {Array} value The data array to set. - */ - var setBindData = !defineProperty ? noop : function(func, value) { - descriptor.value = value; - defineProperty(func, '__bindData__', descriptor); - descriptor.value = null; - }; - - /** - * A fallback implementation of `isPlainObject` which checks if a given value - * is an object created by the `Object` constructor, assuming objects created - * by the `Object` constructor have no inherited enumerable properties and that - * there are no `Object.prototype` extensions. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - */ - function shimIsPlainObject(value) { - var ctor, - result; - - // avoid non Object objects, `arguments` objects, and DOM elements - if (!(value && toString.call(value) == objectClass) || - (ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor))) { - return false; - } - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - forIn(value, function(value, key) { - result = key; - }); - return typeof result == 'undefined' || hasOwnProperty.call(value, result); - } - - /** - * Used by `unescape` to convert HTML entities to characters. - * - * @private - * @param {string} match The matched character to unescape. - * @returns {string} Returns the unescaped character. - */ - function unescapeHtmlChar(match) { - return htmlUnescapes[match]; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Checks if `value` is an `arguments` object. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`. - * @example - * - * (function() { return _.isArguments(arguments); })(1, 2, 3); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ - function isArguments(value) { - return value && typeof value == 'object' && typeof value.length == 'number' && - toString.call(value) == argsClass || false; - } - - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - var isArray = nativeIsArray || function(value) { - return value && typeof value == 'object' && typeof value.length == 'number' && - toString.call(value) == arrayClass || false; - }; - - /** - * A fallback implementation of `Object.keys` which produces an array of the - * given object's own enumerable property names. - * - * @private - * @type Function - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names. - */ - var shimKeys = function(object) { - var index, iterable = object, result = []; - if (!iterable) return result; - if (!(objectTypes[typeof object])) return result; - for (index in iterable) { - if (hasOwnProperty.call(iterable, index)) { - result.push(index); - } - } - return result - }; - - /** - * Creates an array composed of the own enumerable property names of an object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names. - * @example - * - * _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - * // => ['one', 'two', 'three'] (property order is not guaranteed across environments) - */ - var keys = !nativeKeys ? shimKeys : function(object) { - if (!isObject(object)) { - return []; - } - return nativeKeys(object); - }; - - /** - * Used to convert characters to HTML entities: - * - * Though the `>` character is escaped for symmetry, characters like `>` and `/` - * don't require escaping in HTML and have no special meaning unless they're part - * of a tag or an unquoted attribute value. - * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact") - */ - var htmlEscapes = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - }; - - /** Used to convert HTML entities to characters */ - var htmlUnescapes = invert(htmlEscapes); - - /** Used to match HTML entities and HTML characters */ - var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'), - reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g'); - - /*--------------------------------------------------------------------------*/ - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object. Subsequent sources will overwrite property assignments of previous - * sources. If a callback is provided it will be executed to produce the - * assigned values. The callback is bound to `thisArg` and invoked with two - * arguments; (objectValue, sourceValue). - * - * @static - * @memberOf _ - * @type Function - * @alias extend - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param {Function} [callback] The function to customize assigning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the destination object. - * @example - * - * _.assign({ 'name': 'fred' }, { 'employer': 'slate' }); - * // => { 'name': 'fred', 'employer': 'slate' } - * - * var defaults = _.partialRight(_.assign, function(a, b) { - * return typeof a == 'undefined' ? b : a; - * }); - * - * var object = { 'name': 'barney' }; - * defaults(object, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } - */ - var assign = function(object, source, guard) { - var index, iterable = object, result = iterable; - if (!iterable) return result; - var args = arguments, - argsIndex = 0, - argsLength = typeof guard == 'number' ? 2 : args.length; - if (argsLength > 3 && typeof args[argsLength - 2] == 'function') { - var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2); - } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') { - callback = args[--argsLength]; - } - while (++argsIndex < argsLength) { - iterable = args[argsIndex]; - if (iterable && objectTypes[typeof iterable]) { - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]; - } - } - } - return result - }; - - /** - * Creates a clone of `value`. If `isDeep` is `true` nested objects will also - * be cloned, otherwise they will be assigned by reference. If a callback - * is provided it will be executed to produce the cloned values. If the - * callback returns `undefined` cloning will be handled by the method instead. - * The callback is bound to `thisArg` and invoked with one argument; (value). - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to clone. - * @param {boolean} [isDeep=false] Specify a deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the cloned value. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * var shallow = _.clone(characters); - * shallow[0] === characters[0]; - * // => true - * - * var deep = _.clone(characters, true); - * deep[0] === characters[0]; - * // => false - * - * _.mixin({ - * 'clone': _.partialRight(_.clone, function(value) { - * return _.isElement(value) ? value.cloneNode(false) : undefined; - * }) - * }); - * - * var clone = _.clone(document.body); - * clone.childNodes.length; - * // => 0 - */ - function clone(value, isDeep, callback, thisArg) { - // allows working with "Collections" methods without using their `index` - // and `collection` arguments for `isDeep` and `callback` - if (typeof isDeep != 'boolean' && isDeep != null) { - thisArg = callback; - callback = isDeep; - isDeep = false; - } - return baseClone(value, isDeep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); - } - - /** - * Creates a deep clone of `value`. If a callback is provided it will be - * executed to produce the cloned values. If the callback returns `undefined` - * cloning will be handled by the method instead. The callback is bound to - * `thisArg` and invoked with one argument; (value). - * - * Note: This method is loosely based on the structured clone algorithm. Functions - * and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and - * objects created by constructors other than `Object` are cloned to plain `Object` objects. - * See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to deep clone. - * @param {Function} [callback] The function to customize cloning values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the deep cloned value. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * var deep = _.cloneDeep(characters); - * deep[0] === characters[0]; - * // => false - * - * var view = { - * 'label': 'docs', - * 'node': element - * }; - * - * var clone = _.cloneDeep(view, function(value) { - * return _.isElement(value) ? value.cloneNode(true) : undefined; - * }); - * - * clone.node == view.node; - * // => false - */ - function cloneDeep(value, callback, thisArg) { - return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1)); - } - - /** - * Creates an object that inherits from the given `prototype` object. If a - * `properties` object is provided its own enumerable properties are assigned - * to the created object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} prototype The object to inherit from. - * @param {Object} [properties] The properties to assign to the object. - * @returns {Object} Returns the new object. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * function Circle() { - * Shape.call(this); - * } - * - * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); - * - * var circle = new Circle; - * circle instanceof Circle; - * // => true - * - * circle instanceof Shape; - * // => true - */ - function create(prototype, properties) { - var result = baseCreate(prototype); - return properties ? assign(result, properties) : result; - } - - /** - * Assigns own enumerable properties of source object(s) to the destination - * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property will be ignored. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param- {Object} [guard] Allows working with `_.reduce` without using its - * `key` and `object` arguments as sources. - * @returns {Object} Returns the destination object. - * @example - * - * var object = { 'name': 'barney' }; - * _.defaults(object, { 'name': 'fred', 'employer': 'slate' }); - * // => { 'name': 'barney', 'employer': 'slate' } - */ - var defaults = function(object, source, guard) { - var index, iterable = object, result = iterable; - if (!iterable) return result; - var args = arguments, - argsIndex = 0, - argsLength = typeof guard == 'number' ? 2 : args.length; - while (++argsIndex < argsLength) { - iterable = args[argsIndex]; - if (iterable && objectTypes[typeof iterable]) { - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - if (typeof result[index] == 'undefined') result[index] = iterable[index]; - } - } - } - return result - }; - - /** - * This method is like `_.findIndex` except that it returns the key of the - * first element that passes the callback check, instead of the element itself. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {string|undefined} Returns the key of the found element, else `undefined`. - * @example - * - * var characters = { - * 'barney': { 'age': 36, 'blocked': false }, - * 'fred': { 'age': 40, 'blocked': true }, - * 'pebbles': { 'age': 1, 'blocked': false } - * }; - * - * _.findKey(characters, function(chr) { - * return chr.age < 40; - * }); - * // => 'barney' (property order is not guaranteed across environments) - * - * // using "_.where" callback shorthand - * _.findKey(characters, { 'age': 1 }); - * // => 'pebbles' - * - * // using "_.pluck" callback shorthand - * _.findKey(characters, 'blocked'); - * // => 'fred' - */ - function findKey(object, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forOwn(object, function(value, key, object) { - if (callback(value, key, object)) { - result = key; - return false; - } - }); - return result; - } - - /** - * This method is like `_.findKey` except that it iterates over elements - * of a `collection` in the opposite order. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to search. - * @param {Function|Object|string} [callback=identity] The function called per - * iteration. If a property name or object is provided it will be used to - * create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {string|undefined} Returns the key of the found element, else `undefined`. - * @example - * - * var characters = { - * 'barney': { 'age': 36, 'blocked': true }, - * 'fred': { 'age': 40, 'blocked': false }, - * 'pebbles': { 'age': 1, 'blocked': true } - * }; - * - * _.findLastKey(characters, function(chr) { - * return chr.age < 40; - * }); - * // => returns `pebbles`, assuming `_.findKey` returns `barney` - * - * // using "_.where" callback shorthand - * _.findLastKey(characters, { 'age': 40 }); - * // => 'fred' - * - * // using "_.pluck" callback shorthand - * _.findLastKey(characters, 'blocked'); - * // => 'pebbles' - */ - function findLastKey(object, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forOwnRight(object, function(value, key, object) { - if (callback(value, key, object)) { - result = key; - return false; - } - }); - return result; - } - - /** - * Iterates over own and inherited enumerable properties of an object, - * executing the callback for each property. The callback is bound to `thisArg` - * and invoked with three arguments; (value, key, object). Callbacks may exit - * iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * Shape.prototype.move = function(x, y) { - * this.x += x; - * this.y += y; - * }; - * - * _.forIn(new Shape, function(value, key) { - * console.log(key); - * }); - * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) - */ - var forIn = function(collection, callback, thisArg) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - for (index in iterable) { - if (callback(iterable[index], index, collection) === false) return result; - } - return result - }; - - /** - * This method is like `_.forIn` except that it iterates over elements - * of a `collection` in the opposite order. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * Shape.prototype.move = function(x, y) { - * this.x += x; - * this.y += y; - * }; - * - * _.forInRight(new Shape, function(value, key) { - * console.log(key); - * }); - * // => logs 'move', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'move' - */ - function forInRight(object, callback, thisArg) { - var pairs = []; - - forIn(object, function(value, key) { - pairs.push(key, value); - }); - - var length = pairs.length; - callback = baseCreateCallback(callback, thisArg, 3); - while (length--) { - if (callback(pairs[length--], pairs[length], object) === false) { - break; - } - } - return object; - } - - /** - * Iterates over own enumerable properties of an object, executing the callback - * for each property. The callback is bound to `thisArg` and invoked with three - * arguments; (value, key, object). Callbacks may exit iteration early by - * explicitly returning `false`. - * - * @static - * @memberOf _ - * @type Function - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * console.log(key); - * }); - * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) - */ - var forOwn = function(collection, callback, thisArg) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - var ownIndex = -1, - ownProps = objectTypes[typeof iterable] && keys(iterable), - length = ownProps ? ownProps.length : 0; - - while (++ownIndex < length) { - index = ownProps[ownIndex]; - if (callback(iterable[index], index, collection) === false) return result; - } - return result - }; - - /** - * This method is like `_.forOwn` except that it iterates over elements - * of a `collection` in the opposite order. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns `object`. - * @example - * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * console.log(key); - * }); - * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' - */ - function forOwnRight(object, callback, thisArg) { - var props = keys(object), - length = props.length; - - callback = baseCreateCallback(callback, thisArg, 3); - while (length--) { - var key = props[length]; - if (callback(object[key], key, object) === false) { - break; - } - } - return object; - } - - /** - * Creates a sorted array of property names of all enumerable properties, - * own and inherited, of `object` that have function values. - * - * @static - * @memberOf _ - * @alias methods - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property names that have function values. - * @example - * - * _.functions(_); - * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] - */ - function functions(object) { - var result = []; - forIn(object, function(value, key) { - if (isFunction(value)) { - result.push(key); - } - }); - return result.sort(); - } - - /** - * Checks if the specified property name exists as a direct property of `object`, - * instead of an inherited property. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to check. - * @returns {boolean} Returns `true` if key is a direct property, else `false`. - * @example - * - * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); - * // => true - */ - function has(object, key) { - return object ? hasOwnProperty.call(object, key) : false; - } - - /** - * Creates an object composed of the inverted keys and values of the given object. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to invert. - * @returns {Object} Returns the created inverted object. - * @example - * - * _.invert({ 'first': 'fred', 'second': 'barney' }); - * // => { 'fred': 'first', 'barney': 'second' } - */ - function invert(object) { - var index = -1, - props = keys(object), - length = props.length, - result = {}; - - while (++index < length) { - var key = props[index]; - result[object[key]] = key; - } - return result; - } - - /** - * Checks if `value` is a boolean value. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`. - * @example - * - * _.isBoolean(null); - * // => false - */ - function isBoolean(value) { - return value === true || value === false || - value && typeof value == 'object' && toString.call(value) == boolClass || false; - } - - /** - * Checks if `value` is a date. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a date, else `false`. - * @example - * - * _.isDate(new Date); - * // => true - */ - function isDate(value) { - return value && typeof value == 'object' && toString.call(value) == dateClass || false; - } - - /** - * Checks if `value` is a DOM element. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`. - * @example - * - * _.isElement(document.body); - * // => true - */ - function isElement(value) { - return value && value.nodeType === 1 || false; - } - - /** - * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a - * length of `0` and objects with no own enumerable properties are considered - * "empty". - * - * @static - * @memberOf _ - * @category Objects - * @param {Array|Object|string} value The value to inspect. - * @returns {boolean} Returns `true` if the `value` is empty, else `false`. - * @example - * - * _.isEmpty([1, 2, 3]); - * // => false - * - * _.isEmpty({}); - * // => true - * - * _.isEmpty(''); - * // => true - */ - function isEmpty(value) { - var result = true; - if (!value) { - return result; - } - var className = toString.call(value), - length = value.length; - - if ((className == arrayClass || className == stringClass || className == argsClass ) || - (className == objectClass && typeof length == 'number' && isFunction(value.splice))) { - return !length; - } - forOwn(value, function() { - return (result = false); - }); - return result; - } - - /** - * Performs a deep comparison between two values to determine if they are - * equivalent to each other. If a callback is provided it will be executed - * to compare values. If the callback returns `undefined` comparisons will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with two arguments; (a, b). - * - * @static - * @memberOf _ - * @category Objects - * @param {*} a The value to compare. - * @param {*} b The other value to compare. - * @param {Function} [callback] The function to customize comparing values. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'name': 'fred' }; - * var copy = { 'name': 'fred' }; - * - * object == copy; - * // => false - * - * _.isEqual(object, copy); - * // => true - * - * var words = ['hello', 'goodbye']; - * var otherWords = ['hi', 'goodbye']; - * - * _.isEqual(words, otherWords, function(a, b) { - * var reGreet = /^(?:hello|hi)$/i, - * aGreet = _.isString(a) && reGreet.test(a), - * bGreet = _.isString(b) && reGreet.test(b); - * - * return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; - * }); - * // => true - */ - function isEqual(a, b, callback, thisArg) { - return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2)); - } - - /** - * Checks if `value` is, or can be coerced to, a finite number. - * - * Note: This is not the same as native `isFinite` which will return true for - * booleans and empty strings. See http://es5.github.io/#x15.1.2.5. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is finite, else `false`. - * @example - * - * _.isFinite(-101); - * // => true - * - * _.isFinite('10'); - * // => true - * - * _.isFinite(true); - * // => false - * - * _.isFinite(''); - * // => false - * - * _.isFinite(Infinity); - * // => false - */ - function isFinite(value) { - return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value)); - } - - /** - * Checks if `value` is a function. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - */ - function isFunction(value) { - return typeof value == 'function'; - } - - /** - * Checks if `value` is the language type of Object. - * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(1); - * // => false - */ - function isObject(value) { - // check if the value is the ECMAScript language type of Object - // http://es5.github.io/#x8 - // and avoid a V8 bug - // http://code.google.com/p/v8/issues/detail?id=2291 - return !!(value && objectTypes[typeof value]); - } - - /** - * Checks if `value` is `NaN`. - * - * Note: This is not the same as native `isNaN` which will return `true` for - * `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `NaN`, else `false`. - * @example - * - * _.isNaN(NaN); - * // => true - * - * _.isNaN(new Number(NaN)); - * // => true - * - * isNaN(undefined); - * // => true - * - * _.isNaN(undefined); - * // => false - */ - function isNaN(value) { - // `NaN` as a primitive is the only value that is not equal to itself - // (perform the [[Class]] check first to avoid errors with some host objects in IE) - return isNumber(value) && value != +value; - } - - /** - * Checks if `value` is `null`. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `null`, else `false`. - * @example - * - * _.isNull(null); - * // => true - * - * _.isNull(undefined); - * // => false - */ - function isNull(value) { - return value === null; - } - - /** - * Checks if `value` is a number. - * - * Note: `NaN` is considered a number. See http://es5.github.io/#x8.5. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a number, else `false`. - * @example - * - * _.isNumber(8.4 * 5); - * // => true - */ - function isNumber(value) { - return typeof value == 'number' || - value && typeof value == 'object' && toString.call(value) == numberClass || false; - } - - /** - * Checks if `value` is an object created by the `Object` constructor. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. - * @example - * - * function Shape() { - * this.x = 0; - * this.y = 0; - * } - * - * _.isPlainObject(new Shape); - * // => false - * - * _.isPlainObject([1, 2, 3]); - * // => false - * - * _.isPlainObject({ 'x': 0, 'y': 0 }); - * // => true - */ - var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { - if (!(value && toString.call(value) == objectClass)) { - return false; - } - var valueOf = value.valueOf, - objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); - - return objProto - ? (value == objProto || getPrototypeOf(value) == objProto) - : shimIsPlainObject(value); - }; - - /** - * Checks if `value` is a regular expression. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`. - * @example - * - * _.isRegExp(/fred/); - * // => true - */ - function isRegExp(value) { - return value && typeof value == 'object' && toString.call(value) == regexpClass || false; - } - - /** - * Checks if `value` is a string. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is a string, else `false`. - * @example - * - * _.isString('fred'); - * // => true - */ - function isString(value) { - return typeof value == 'string' || - value && typeof value == 'object' && toString.call(value) == stringClass || false; - } - - /** - * Checks if `value` is `undefined`. - * - * @static - * @memberOf _ - * @category Objects - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`. - * @example - * - * _.isUndefined(void 0); - * // => true - */ - function isUndefined(value) { - return typeof value == 'undefined'; - } - - /** - * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through the callback. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new object with values of the results of each `callback` execution. - * @example - * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; }); - * // => { 'a': 3, 'b': 6, 'c': 9 } - * - * var characters = { - * 'fred': { 'name': 'fred', 'age': 40 }, - * 'pebbles': { 'name': 'pebbles', 'age': 1 } - * }; - * - * // using "_.pluck" callback shorthand - * _.mapValues(characters, 'age'); - * // => { 'fred': 40, 'pebbles': 1 } - */ - function mapValues(object, callback, thisArg) { - var result = {}; - callback = lodash.createCallback(callback, thisArg, 3); - - forOwn(object, function(value, key, object) { - result[key] = callback(value, key, object); - }); - return result; - } - - /** - * Recursively merges own enumerable properties of the source object(s), that - * don't resolve to `undefined` into the destination object. Subsequent sources - * will overwrite property assignments of previous sources. If a callback is - * provided it will be executed to produce the merged values of the destination - * and source properties. If the callback returns `undefined` merging will - * be handled by the method instead. The callback is bound to `thisArg` and - * invoked with two arguments; (objectValue, sourceValue). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The destination object. - * @param {...Object} [source] The source objects. - * @param {Function} [callback] The function to customize merging properties. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the destination object. - * @example - * - * var names = { - * 'characters': [ - * { 'name': 'barney' }, - * { 'name': 'fred' } - * ] - * }; - * - * var ages = { - * 'characters': [ - * { 'age': 36 }, - * { 'age': 40 } - * ] - * }; - * - * _.merge(names, ages); - * // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] } - * - * var food = { - * 'fruits': ['apple'], - * 'vegetables': ['beet'] - * }; - * - * var otherFood = { - * 'fruits': ['banana'], - * 'vegetables': ['carrot'] - * }; - * - * _.merge(food, otherFood, function(a, b) { - * return _.isArray(a) ? a.concat(b) : undefined; - * }); - * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] } - */ - function merge(object) { - var args = arguments, - length = 2; - - if (!isObject(object)) { - return object; - } - // allows working with `_.reduce` and `_.reduceRight` without using - // their `index` and `collection` arguments - if (typeof args[2] != 'number') { - length = args.length; - } - if (length > 3 && typeof args[length - 2] == 'function') { - var callback = baseCreateCallback(args[--length - 1], args[length--], 2); - } else if (length > 2 && typeof args[length - 1] == 'function') { - callback = args[--length]; - } - var sources = slice(arguments, 1, length), - index = -1, - stackA = getArray(), - stackB = getArray(); - - while (++index < length) { - baseMerge(object, sources[index], callback, stackA, stackB); - } - releaseArray(stackA); - releaseArray(stackB); - return object; - } - - /** - * Creates a shallow clone of `object` excluding the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If a callback is provided it will be executed for each - * property of `object` omitting the properties the callback returns truey - * for. The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The source object. - * @param {Function|...string|string[]} [callback] The properties to omit or the - * function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns an object without the omitted properties. - * @example - * - * _.omit({ 'name': 'fred', 'age': 40 }, 'age'); - * // => { 'name': 'fred' } - * - * _.omit({ 'name': 'fred', 'age': 40 }, function(value) { - * return typeof value == 'number'; - * }); - * // => { 'name': 'fred' } - */ - function omit(object, callback, thisArg) { - var result = {}; - if (typeof callback != 'function') { - var props = []; - forIn(object, function(value, key) { - props.push(key); - }); - props = baseDifference(props, baseFlatten(arguments, true, false, 1)); - - var index = -1, - length = props.length; - - while (++index < length) { - var key = props[index]; - result[key] = object[key]; - } - } else { - callback = lodash.createCallback(callback, thisArg, 3); - forIn(object, function(value, key, object) { - if (!callback(value, key, object)) { - result[key] = value; - } - }); - } - return result; - } - - /** - * Creates a two dimensional array of an object's key-value pairs, - * i.e. `[[key1, value1], [key2, value2]]`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns new array of key-value pairs. - * @example - * - * _.pairs({ 'barney': 36, 'fred': 40 }); - * // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments) - */ - function pairs(object) { - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); - - while (++index < length) { - var key = props[index]; - result[index] = [key, object[key]]; - } - return result; - } - - /** - * Creates a shallow clone of `object` composed of the specified properties. - * Property names may be specified as individual arguments or as arrays of - * property names. If a callback is provided it will be executed for each - * property of `object` picking the properties the callback returns truey - * for. The callback is bound to `thisArg` and invoked with three arguments; - * (value, key, object). - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The source object. - * @param {Function|...string|string[]} [callback] The function called per - * iteration or property names to pick, specified as individual property - * names or arrays of property names. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns an object composed of the picked properties. - * @example - * - * _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name'); - * // => { 'name': 'fred' } - * - * _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) { - * return key.charAt(0) != '_'; - * }); - * // => { 'name': 'fred' } - */ - function pick(object, callback, thisArg) { - var result = {}; - if (typeof callback != 'function') { - var index = -1, - props = baseFlatten(arguments, true, false, 1), - length = isObject(object) ? props.length : 0; - - while (++index < length) { - var key = props[index]; - if (key in object) { - result[key] = object[key]; - } - } - } else { - callback = lodash.createCallback(callback, thisArg, 3); - forIn(object, function(value, key, object) { - if (callback(value, key, object)) { - result[key] = value; - } - }); - } - return result; - } - - /** - * An alternative to `_.reduce` this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable properties through a callback, with each callback execution - * potentially mutating the `accumulator` object. The callback is bound to - * `thisArg` and invoked with four arguments; (accumulator, value, key, object). - * Callbacks may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Array|Object} object The object to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) { - * num *= num; - * if (num % 2) { - * return result.push(num) < 3; - * } - * }); - * // => [1, 9, 25] - * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; - * }); - * // => { 'a': 3, 'b': 6, 'c': 9 } - */ - function transform(object, callback, accumulator, thisArg) { - var isArr = isArray(object); - if (accumulator == null) { - if (isArr) { - accumulator = []; - } else { - var ctor = object && object.constructor, - proto = ctor && ctor.prototype; - - accumulator = baseCreate(proto); - } - } - if (callback) { - callback = lodash.createCallback(callback, thisArg, 4); - (isArr ? forEach : forOwn)(object, function(value, index, object) { - return callback(accumulator, value, index, object); - }); - } - return accumulator; - } - - /** - * Creates an array composed of the own enumerable property values of `object`. - * - * @static - * @memberOf _ - * @category Objects - * @param {Object} object The object to inspect. - * @returns {Array} Returns an array of property values. - * @example - * - * _.values({ 'one': 1, 'two': 2, 'three': 3 }); - * // => [1, 2, 3] (property order is not guaranteed across environments) - */ - function values(object) { - var index = -1, - props = keys(object), - length = props.length, - result = Array(length); - - while (++index < length) { - result[index] = object[props[index]]; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates an array of elements from the specified indexes, or keys, of the - * `collection`. Indexes may be specified as individual arguments or as arrays - * of indexes. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {...(number|number[]|string|string[])} [index] The indexes of `collection` - * to retrieve, specified as individual indexes or arrays of indexes. - * @returns {Array} Returns a new array of elements corresponding to the - * provided indexes. - * @example - * - * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); - * // => ['a', 'c', 'e'] - * - * _.at(['fred', 'barney', 'pebbles'], 0, 2); - * // => ['fred', 'pebbles'] - */ - function at(collection) { - var args = arguments, - index = -1, - props = baseFlatten(args, true, false, 1), - length = (args[2] && args[2][args[1]] === collection) ? 1 : props.length, - result = Array(length); - - while(++index < length) { - result[index] = collection[props[index]]; - } - return result; - } - - /** - * Checks if a given value is present in a collection using strict equality - * for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the - * offset from the end of the collection. - * - * @static - * @memberOf _ - * @alias include - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {*} target The value to check for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if the `target` element is found, else `false`. - * @example - * - * _.contains([1, 2, 3], 1); - * // => true - * - * _.contains([1, 2, 3], 1, 2); - * // => false - * - * _.contains({ 'name': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.contains('pebbles', 'eb'); - * // => true - */ - function contains(collection, target, fromIndex) { - var index = -1, - indexOf = getIndexOf(), - length = collection ? collection.length : 0, - result = false; - - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; - if (isArray(collection)) { - result = indexOf(collection, target, fromIndex) > -1; - } else if (typeof length == 'number') { - result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1; - } else { - forOwn(collection, function(value) { - if (++index >= fromIndex) { - return !(result = value === target); - } - }); - } - return result; - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of `collection` through the callback. The corresponding value - * of each key is the number of times the key was returned by the callback. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); - * // => { '4': 1, '6': 2 } - * - * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); - * // => { '4': 1, '6': 2 } - * - * _.countBy(['one', 'two', 'three'], 'length'); - * // => { '3': 2, '5': 1 } - */ - var countBy = createAggregator(function(result, value, key) { - (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); - }); - - /** - * Checks if the given callback returns truey value for **all** elements of - * a collection. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias all - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if all elements passed the callback check, - * else `false`. - * @example - * - * _.every([true, 1, null, 'yes']); - * // => false - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.every(characters, 'age'); - * // => true - * - * // using "_.where" callback shorthand - * _.every(characters, { 'age': 36 }); - * // => false - */ - function every(collection, callback, thisArg) { - var result = true; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - if (!(result = !!callback(collection[index], index, collection))) { - break; - } - } - } else { - forOwn(collection, function(value, index, collection) { - return (result = !!callback(value, index, collection)); - }); - } - return result; - } - - /** - * Iterates over elements of a collection, returning an array of all elements - * the callback returns truey for. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias select - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of elements that passed the callback check. - * @example - * - * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - * // => [2, 4, 6] - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.filter(characters, 'blocked'); - * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] - * - * // using "_.where" callback shorthand - * _.filter(characters, { 'age': 36 }); - * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] - */ - function filter(collection, callback, thisArg) { - var result = []; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - if (callback(value, index, collection)) { - result.push(value); - } - } - } else { - forOwn(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result.push(value); - } - }); - } - return result; - } - - /** - * Iterates over elements of a collection, returning the first element that - * the callback returns truey for. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias detect, findWhere - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the found element, else `undefined`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true }, - * { 'name': 'pebbles', 'age': 1, 'blocked': false } - * ]; - * - * _.find(characters, function(chr) { - * return chr.age < 40; - * }); - * // => { 'name': 'barney', 'age': 36, 'blocked': false } - * - * // using "_.where" callback shorthand - * _.find(characters, { 'age': 1 }); - * // => { 'name': 'pebbles', 'age': 1, 'blocked': false } - * - * // using "_.pluck" callback shorthand - * _.find(characters, 'blocked'); - * // => { 'name': 'fred', 'age': 40, 'blocked': true } - */ - function find(collection, callback, thisArg) { - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - var value = collection[index]; - if (callback(value, index, collection)) { - return value; - } - } - } else { - var result; - forOwn(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; - } - }); - return result; - } - } - - /** - * This method is like `_.find` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the found element, else `undefined`. - * @example - * - * _.findLast([1, 2, 3, 4], function(num) { - * return num % 2 == 1; - * }); - * // => 3 - */ - function findLast(collection, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - forEachRight(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; - } - }); - return result; - } - - /** - * Iterates over elements of a collection, executing the callback for each - * element. The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). Callbacks may exit iteration early by - * explicitly returning `false`. - * - * Note: As with other "Collections" methods, objects with a `length` property - * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` - * may be used for object iteration. - * - * @static - * @memberOf _ - * @alias each - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); - * // => logs each number and returns '1,2,3' - * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - * // => logs each number and returns the object (property order is not guaranteed across environments) - */ - function forEach(collection, callback, thisArg) { - var index = -1, - length = collection ? collection.length : 0; - - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { - while (++index < length) { - if (callback(collection[index], index, collection) === false) { - break; - } - } - } else { - forOwn(collection, callback); - } - return collection; - } - - /** - * This method is like `_.forEach` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @alias eachRight - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - * @example - * - * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); - * // => logs each number from right to left and returns '3,2,1' - */ - function forEachRight(collection, callback, thisArg) { - var length = collection ? collection.length : 0; - callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - if (typeof length == 'number') { - while (length--) { - if (callback(collection[length], length, collection) === false) { - break; - } - } - } else { - var props = keys(collection); - length = props.length; - forOwn(collection, function(value, key, collection) { - key = props ? props[--length] : --length; - return callback(collection[key], key, collection); - }); - } - return collection; - } - - /** - * Creates an object composed of keys generated from the results of running - * each element of a collection through the callback. The corresponding value - * of each key is an array of the elements responsible for generating the key. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false` - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); - * // => { '4': [4.2], '6': [6.1, 6.4] } - * - * // using "_.pluck" callback shorthand - * _.groupBy(['one', 'two', 'three'], 'length'); - * // => { '3': ['one', 'two'], '5': ['three'] } - */ - var groupBy = createAggregator(function(result, value, key) { - (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); - }); - - /** - * Creates an object composed of keys generated from the results of running - * each element of the collection through the given callback. The corresponding - * value of each key is the last element responsible for generating the key. - * The callback is bound to `thisArg` and invoked with three arguments; - * (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Object} Returns the composed aggregate object. - * @example - * - * var keys = [ - * { 'dir': 'left', 'code': 97 }, - * { 'dir': 'right', 'code': 100 } - * ]; - * - * _.indexBy(keys, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - * - * _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String); - * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } - */ - var indexBy = createAggregator(function(result, value, key) { - result[key] = value; - }); - - /** - * Invokes the method named by `methodName` on each element in the `collection` - * returning an array of the results of each invoked method. Additional arguments - * will be provided to each invoked method. If `methodName` is a function it - * will be invoked for, and `this` bound to, each element in the `collection`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|string} methodName The name of the method to invoke or - * the function invoked per iteration. - * @param {...*} [arg] Arguments to invoke the method with. - * @returns {Array} Returns a new array of the results of each invoked method. - * @example - * - * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); - * // => [[1, 5, 7], [1, 2, 3]] - * - * _.invoke([123, 456], String.prototype.split, ''); - * // => [['1', '2', '3'], ['4', '5', '6']] - */ - function invoke(collection, methodName) { - var args = slice(arguments, 2), - index = -1, - isFunc = typeof methodName == 'function', - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - forEach(collection, function(value) { - result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args); - }); - return result; - } - - /** - * Creates an array of values by running each element in the collection - * through the callback. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias collect - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of the results of each `callback` execution. - * @example - * - * _.map([1, 2, 3], function(num) { return num * 3; }); - * // => [3, 6, 9] - * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); - * // => [3, 6, 9] (property order is not guaranteed across environments) - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.map(characters, 'name'); - * // => ['barney', 'fred'] - */ - function map(collection, callback, thisArg) { - var index = -1, - length = collection ? collection.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - if (typeof length == 'number') { - var result = Array(length); - while (++index < length) { - result[index] = callback(collection[index], index, collection); - } - } else { - result = []; - forOwn(collection, function(value, key, collection) { - result[++index] = callback(value, key, collection); - }); - } - return result; - } - - /** - * Retrieves the maximum value of a collection. If the collection is empty or - * falsey `-Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the maximum value. - * @example - * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.max(characters, function(chr) { return chr.age; }); - * // => { 'name': 'fred', 'age': 40 }; - * - * // using "_.pluck" callback shorthand - * _.max(characters, 'age'); - * // => { 'name': 'fred', 'age': 40 }; - */ - function max(collection, callback, thisArg) { - var computed = -Infinity, - result = computed; - - // allows working with functions like `_.map` without using - // their `index` argument as a callback - if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { - callback = null; - } - if (callback == null && isArray(collection)) { - var index = -1, - length = collection.length; - - while (++index < length) { - var value = collection[index]; - if (value > result) { - result = value; - } - } - } else { - callback = (callback == null && isString(collection)) - ? charAtCallback - : lodash.createCallback(callback, thisArg, 3); - - forEach(collection, function(value, index, collection) { - var current = callback(value, index, collection); - if (current > computed) { - computed = current; - result = value; - } - }); - } - return result; - } - - /** - * Retrieves the minimum value of a collection. If the collection is empty or - * falsey `Infinity` is returned. If a callback is provided it will be executed - * for each value in the collection to generate the criterion by which the value - * is ranked. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the minimum value. - * @example - * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.min(characters, function(chr) { return chr.age; }); - * // => { 'name': 'barney', 'age': 36 }; - * - * // using "_.pluck" callback shorthand - * _.min(characters, 'age'); - * // => { 'name': 'barney', 'age': 36 }; - */ - function min(collection, callback, thisArg) { - var computed = Infinity, - result = computed; - - // allows working with functions like `_.map` without using - // their `index` argument as a callback - if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) { - callback = null; - } - if (callback == null && isArray(collection)) { - var index = -1, - length = collection.length; - - while (++index < length) { - var value = collection[index]; - if (value < result) { - result = value; - } - } - } else { - callback = (callback == null && isString(collection)) - ? charAtCallback - : lodash.createCallback(callback, thisArg, 3); - - forEach(collection, function(value, index, collection) { - var current = callback(value, index, collection); - if (current < computed) { - computed = current; - result = value; - } - }); - } - return result; - } - - /** - * Retrieves the value of a specified property from all elements in the collection. - * - * @static - * @memberOf _ - * @type Function - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {string} property The name of the property to pluck. - * @returns {Array} Returns a new array of property values. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * _.pluck(characters, 'name'); - * // => ['barney', 'fred'] - */ - var pluck = map; - - /** - * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through the callback, where each successive - * callback execution consumes the return value of the previous execution. If - * `accumulator` is not provided the first element of the collection will be - * used as the initial `accumulator` value. The callback is bound to `thisArg` - * and invoked with four arguments; (accumulator, value, index|key, collection). - * - * @static - * @memberOf _ - * @alias foldl, inject - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] Initial value of the accumulator. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var sum = _.reduce([1, 2, 3], function(sum, num) { - * return sum + num; - * }); - * // => 6 - * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { - * result[key] = num * 3; - * return result; - * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } - */ - function reduce(collection, callback, accumulator, thisArg) { - if (!collection) return accumulator; - var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); - - var index = -1, - length = collection.length; - - if (typeof length == 'number') { - if (noaccum) { - accumulator = collection[++index]; - } - while (++index < length) { - accumulator = callback(accumulator, collection[index], index, collection); - } - } else { - forOwn(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback(accumulator, value, index, collection) - }); - } - return accumulator; - } - - /** - * This method is like `_.reduce` except that it iterates over elements - * of a `collection` from right to left. - * - * @static - * @memberOf _ - * @alias foldr - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [accumulator] Initial value of the accumulator. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the accumulated value. - * @example - * - * var list = [[0, 1], [2, 3], [4, 5]]; - * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); - * // => [4, 5, 2, 3, 0, 1] - */ - function reduceRight(collection, callback, accumulator, thisArg) { - var noaccum = arguments.length < 3; - callback = lodash.createCallback(callback, thisArg, 4); - forEachRight(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback(accumulator, value, index, collection); - }); - return accumulator; - } - - /** - * The opposite of `_.filter` this method returns the elements of a - * collection that the callback does **not** return truey for. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of elements that failed the callback check. - * @example - * - * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - * // => [1, 3, 5] - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.reject(characters, 'blocked'); - * // => [{ 'name': 'barney', 'age': 36, 'blocked': false }] - * - * // using "_.where" callback shorthand - * _.reject(characters, { 'age': 36 }); - * // => [{ 'name': 'fred', 'age': 40, 'blocked': true }] - */ - function reject(collection, callback, thisArg) { - callback = lodash.createCallback(callback, thisArg, 3); - return filter(collection, function(value, index, collection) { - return !callback(value, index, collection); - }); - } - - /** - * Retrieves a random element or `n` random elements from a collection. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to sample. - * @param {number} [n] The number of elements to sample. - * @param- {Object} [guard] Allows working with functions like `_.map` - * without using their `index` arguments as `n`. - * @returns {Array} Returns the random sample(s) of `collection`. - * @example - * - * _.sample([1, 2, 3, 4]); - * // => 2 - * - * _.sample([1, 2, 3, 4], 2); - * // => [3, 1] - */ - function sample(collection, n, guard) { - if (collection && typeof collection.length != 'number') { - collection = values(collection); - } - if (n == null || guard) { - return collection ? collection[baseRandom(0, collection.length - 1)] : undefined; - } - var result = shuffle(collection); - result.length = nativeMin(nativeMax(0, n), result.length); - return result; - } - - /** - * Creates an array of shuffled values, using a version of the Fisher-Yates - * shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to shuffle. - * @returns {Array} Returns a new shuffled collection. - * @example - * - * _.shuffle([1, 2, 3, 4, 5, 6]); - * // => [4, 1, 6, 3, 5, 2] - */ - function shuffle(collection) { - var index = -1, - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - forEach(collection, function(value) { - var rand = baseRandom(0, ++index); - result[index] = result[rand]; - result[rand] = value; - }); - return result; - } - - /** - * Gets the size of the `collection` by returning `collection.length` for arrays - * and array-like objects or the number of own enumerable properties for objects. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to inspect. - * @returns {number} Returns `collection.length` or number of own enumerable properties. - * @example - * - * _.size([1, 2]); - * // => 2 - * - * _.size({ 'one': 1, 'two': 2, 'three': 3 }); - * // => 3 - * - * _.size('pebbles'); - * // => 7 - */ - function size(collection) { - var length = collection ? collection.length : 0; - return typeof length == 'number' ? length : keys(collection).length; - } - - /** - * Checks if the callback returns a truey value for **any** element of a - * collection. The function returns as soon as it finds a passing value and - * does not iterate over the entire collection. The callback is bound to - * `thisArg` and invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias any - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {boolean} Returns `true` if any element passed the callback check, - * else `false`. - * @example - * - * _.some([null, 0, 'yes', false], Boolean); - * // => true - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true } - * ]; - * - * // using "_.pluck" callback shorthand - * _.some(characters, 'blocked'); - * // => true - * - * // using "_.where" callback shorthand - * _.some(characters, { 'age': 1 }); - * // => false - */ - function some(collection, callback, thisArg) { - var result; - callback = lodash.createCallback(callback, thisArg, 3); - - var index = -1, - length = collection ? collection.length : 0; - - if (typeof length == 'number') { - while (++index < length) { - if ((result = callback(collection[index], index, collection))) { - break; - } - } - } else { - forOwn(collection, function(value, index, collection) { - return !(result = callback(value, index, collection)); - }); - } - return !!result; - } - - /** - * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through the callback. This method - * performs a stable sort, that is, it will preserve the original sort order - * of equal elements. The callback is bound to `thisArg` and invoked with - * three arguments; (value, index|key, collection). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an array of property names is provided for `callback` the collection - * will be sorted by each property value. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of sorted elements. - * @example - * - * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); - * // => [3, 1, 2] - * - * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); - * // => [3, 1, 2] - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 }, - * { 'name': 'barney', 'age': 26 }, - * { 'name': 'fred', 'age': 30 } - * ]; - * - * // using "_.pluck" callback shorthand - * _.map(_.sortBy(characters, 'age'), _.values); - * // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]] - * - * // sorting by multiple properties - * _.map(_.sortBy(characters, ['name', 'age']), _.values); - * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] - */ - function sortBy(collection, callback, thisArg) { - var index = -1, - isArr = isArray(callback), - length = collection ? collection.length : 0, - result = Array(typeof length == 'number' ? length : 0); - - if (!isArr) { - callback = lodash.createCallback(callback, thisArg, 3); - } - forEach(collection, function(value, key, collection) { - var object = result[++index] = getObject(); - if (isArr) { - object.criteria = map(callback, function(key) { return value[key]; }); - } else { - (object.criteria = getArray())[0] = callback(value, key, collection); - } - object.index = index; - object.value = value; - }); - - length = result.length; - result.sort(compareAscending); - while (length--) { - var object = result[length]; - result[length] = object.value; - if (!isArr) { - releaseArray(object.criteria); - } - releaseObject(object); - } - return result; - } - - /** - * Converts the `collection` to an array. - * - * @static - * @memberOf _ - * @category Collections - * @param {Array|Object|string} collection The collection to convert. - * @returns {Array} Returns the new converted array. - * @example - * - * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); - * // => [2, 3, 4] - */ - function toArray(collection) { - if (collection && typeof collection.length == 'number') { - return slice(collection); - } - return values(collection); - } - - /** - * Performs a deep comparison of each element in a `collection` to the given - * `properties` object, returning an array of all elements that have equivalent - * property values. - * - * @static - * @memberOf _ - * @type Function - * @category Collections - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Object} props The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given properties. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }, - * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } - * ]; - * - * _.where(characters, { 'age': 36 }); - * // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }] - * - * _.where(characters, { 'pets': ['dino'] }); - * // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }] - */ - var where = filter; - - /*--------------------------------------------------------------------------*/ - - /** - * Creates an array with all falsey values removed. The values `false`, `null`, - * `0`, `""`, `undefined`, and `NaN` are all falsey. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to compact. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.compact([0, 1, false, 2, '', 3]); - * // => [1, 2, 3] - */ - function compact(array) { - var index = -1, - length = array ? array.length : 0, - result = []; - - while (++index < length) { - var value = array[index]; - if (value) { - result.push(value); - } - } - return result; - } - - /** - * Creates an array excluding all values of the provided arrays using strict - * equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to process. - * @param {...Array} [values] The arrays of values to exclude. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - * // => [1, 3, 4] - */ - function difference(array) { - return baseDifference(array, baseFlatten(arguments, true, true, 1)); - } - - /** - * This method is like `_.find` except that it returns the index of the first - * element that passes the callback check, instead of the element itself. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': false }, - * { 'name': 'fred', 'age': 40, 'blocked': true }, - * { 'name': 'pebbles', 'age': 1, 'blocked': false } - * ]; - * - * _.findIndex(characters, function(chr) { - * return chr.age < 20; - * }); - * // => 2 - * - * // using "_.where" callback shorthand - * _.findIndex(characters, { 'age': 36 }); - * // => 0 - * - * // using "_.pluck" callback shorthand - * _.findIndex(characters, 'blocked'); - * // => 1 - */ - function findIndex(array, callback, thisArg) { - var index = -1, - length = array ? array.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length) { - if (callback(array[index], index, array)) { - return index; - } - } - return -1; - } - - /** - * This method is like `_.findIndex` except that it iterates over elements - * of a `collection` from right to left. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index of the found element, else `-1`. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36, 'blocked': true }, - * { 'name': 'fred', 'age': 40, 'blocked': false }, - * { 'name': 'pebbles', 'age': 1, 'blocked': true } - * ]; - * - * _.findLastIndex(characters, function(chr) { - * return chr.age > 30; - * }); - * // => 1 - * - * // using "_.where" callback shorthand - * _.findLastIndex(characters, { 'age': 36 }); - * // => 0 - * - * // using "_.pluck" callback shorthand - * _.findLastIndex(characters, 'blocked'); - * // => 2 - */ - function findLastIndex(array, callback, thisArg) { - var length = array ? array.length : 0; - callback = lodash.createCallback(callback, thisArg, 3); - while (length--) { - if (callback(array[length], length, array)) { - return length; - } - } - return -1; - } - - /** - * Gets the first element or first `n` elements of an array. If a callback - * is provided elements at the beginning of the array are returned as long - * as the callback returns truey. The callback is bound to `thisArg` and - * invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias head, take - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback] The function called - * per element or the number of elements to return. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the first element(s) of `array`. - * @example - * - * _.first([1, 2, 3]); - * // => 1 - * - * _.first([1, 2, 3], 2); - * // => [1, 2] - * - * _.first([1, 2, 3], function(num) { - * return num < 3; - * }); - * // => [1, 2] - * - * var characters = [ - * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.first(characters, 'blocked'); - * // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }] - * - * // using "_.where" callback shorthand - * _.pluck(_.first(characters, { 'employer': 'slate' }), 'name'); - * // => ['barney', 'fred'] - */ - function first(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = -1; - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length && callback(array[index], index, array)) { - n++; - } - } else { - n = callback; - if (n == null || thisArg) { - return array ? array[0] : undefined; - } - } - return slice(array, 0, nativeMin(nativeMax(0, n), length)); - } - - /** - * Flattens a nested array (the nesting can be to any depth). If `isShallow` - * is truey, the array will only be flattened a single level. If a callback - * is provided each element of the array is passed through the callback before - * flattening. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to flatten. - * @param {boolean} [isShallow=false] A flag to restrict flattening to a single level. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new flattened array. - * @example - * - * _.flatten([1, [2], [3, [[4]]]]); - * // => [1, 2, 3, 4]; - * - * _.flatten([1, [2], [3, [[4]]]], true); - * // => [1, 2, 3, [[4]]]; - * - * var characters = [ - * { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] }, - * { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] } - * ]; - * - * // using "_.pluck" callback shorthand - * _.flatten(characters, 'pets'); - * // => ['hoppy', 'baby puss', 'dino'] - */ - function flatten(array, isShallow, callback, thisArg) { - // juggle arguments - if (typeof isShallow != 'boolean' && isShallow != null) { - thisArg = callback; - callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow; - isShallow = false; - } - if (callback != null) { - array = map(array, callback, thisArg); - } - return baseFlatten(array, isShallow); - } - - /** - * Gets the index at which the first occurrence of `value` is found using - * strict equality for comparisons, i.e. `===`. If the array is already sorted - * providing `true` for `fromIndex` will run a faster binary search. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {boolean|number} [fromIndex=0] The index to search from or `true` - * to perform a binary search on a sorted array. - * @returns {number} Returns the index of the matched value or `-1`. - * @example - * - * _.indexOf([1, 2, 3, 1, 2, 3], 2); - * // => 1 - * - * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 4 - * - * _.indexOf([1, 1, 2, 2, 3, 3], 2, true); - * // => 2 - */ - function indexOf(array, value, fromIndex) { - if (typeof fromIndex == 'number') { - var length = array ? array.length : 0; - fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); - } else if (fromIndex) { - var index = sortedIndex(array, value); - return array[index] === value ? index : -1; - } - return baseIndexOf(array, value, fromIndex); - } - - /** - * Gets all but the last element or last `n` elements of an array. If a - * callback is provided elements at the end of the array are excluded from - * the result as long as the callback returns truey. The callback is bound - * to `thisArg` and invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback=1] The function called - * per element or the number of elements to exclude. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a slice of `array`. - * @example - * - * _.initial([1, 2, 3]); - * // => [1, 2] - * - * _.initial([1, 2, 3], 2); - * // => [1] - * - * _.initial([1, 2, 3], function(num) { - * return num > 1; - * }); - * // => [1] - * - * var characters = [ - * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.initial(characters, 'blocked'); - * // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }] - * - * // using "_.where" callback shorthand - * _.pluck(_.initial(characters, { 'employer': 'na' }), 'name'); - * // => ['barney', 'fred'] - */ - function initial(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = length; - callback = lodash.createCallback(callback, thisArg, 3); - while (index-- && callback(array[index], index, array)) { - n++; - } - } else { - n = (callback == null || thisArg) ? 1 : callback || n; - } - return slice(array, 0, nativeMin(nativeMax(0, length - n), length)); - } - - /** - * Creates an array of unique values present in all provided arrays using - * strict equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of shared values. - * @example - * - * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2] - */ - function intersection() { - var args = [], - argsIndex = -1, - argsLength = arguments.length, - caches = getArray(), - indexOf = getIndexOf(), - trustIndexOf = indexOf === baseIndexOf, - seen = getArray(); - - while (++argsIndex < argsLength) { - var value = arguments[argsIndex]; - if (isArray(value) || isArguments(value)) { - args.push(value); - caches.push(trustIndexOf && value.length >= largeArraySize && - createCache(argsIndex ? args[argsIndex] : seen)); - } - } - var array = args[0], - index = -1, - length = array ? array.length : 0, - result = []; - - outer: - while (++index < length) { - var cache = caches[0]; - value = array[index]; - - if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) { - argsIndex = argsLength; - (cache || seen).push(value); - while (--argsIndex) { - cache = caches[argsIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { - continue outer; - } - } - result.push(value); - } - } - while (argsLength--) { - cache = caches[argsLength]; - if (cache) { - releaseObject(cache); - } - } - releaseArray(caches); - releaseArray(seen); - return result; - } - - /** - * Gets the last element or last `n` elements of an array. If a callback is - * provided elements at the end of the array are returned as long as the - * callback returns truey. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback] The function called - * per element or the number of elements to return. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {*} Returns the last element(s) of `array`. - * @example - * - * _.last([1, 2, 3]); - * // => 3 - * - * _.last([1, 2, 3], 2); - * // => [2, 3] - * - * _.last([1, 2, 3], function(num) { - * return num > 1; - * }); - * // => [2, 3] - * - * var characters = [ - * { 'name': 'barney', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.pluck(_.last(characters, 'blocked'), 'name'); - * // => ['fred', 'pebbles'] - * - * // using "_.where" callback shorthand - * _.last(characters, { 'employer': 'na' }); - * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] - */ - function last(array, callback, thisArg) { - var n = 0, - length = array ? array.length : 0; - - if (typeof callback != 'number' && callback != null) { - var index = length; - callback = lodash.createCallback(callback, thisArg, 3); - while (index-- && callback(array[index], index, array)) { - n++; - } - } else { - n = callback; - if (n == null || thisArg) { - return array ? array[length - 1] : undefined; - } - } - return slice(array, nativeMax(0, length - n)); - } - - /** - * Gets the index at which the last occurrence of `value` is found using strict - * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used - * as the offset from the end of the collection. - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} [fromIndex=array.length-1] The index to search from. - * @returns {number} Returns the index of the matched value or `-1`. - * @example - * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); - * // => 4 - * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 1 - */ - function lastIndexOf(array, value, fromIndex) { - var index = array ? array.length : 0; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1; - } - while (index--) { - if (array[index] === value) { - return index; - } - } - return -1; - } - - /** - * Removes all provided values from the given array using strict equality for - * comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to modify. - * @param {...*} [value] The values to remove. - * @returns {Array} Returns `array`. - * @example - * - * var array = [1, 2, 3, 1, 2, 3]; - * _.pull(array, 2, 3); - * console.log(array); - * // => [1, 1] - */ - function pull(array) { - var args = arguments, - argsIndex = 0, - argsLength = args.length, - length = array ? array.length : 0; - - while (++argsIndex < argsLength) { - var index = -1, - value = args[argsIndex]; - while (++index < length) { - if (array[index] === value) { - splice.call(array, index--, 1); - length--; - } - } - } - return array; - } - - /** - * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to but not including `end`. If `start` is less than `stop` a - * zero-length range is created unless a negative `step` is specified. - * - * @static - * @memberOf _ - * @category Arrays - * @param {number} [start=0] The start of the range. - * @param {number} end The end of the range. - * @param {number} [step=1] The value to increment or decrement by. - * @returns {Array} Returns a new range array. - * @example - * - * _.range(4); - * // => [0, 1, 2, 3] - * - * _.range(1, 5); - * // => [1, 2, 3, 4] - * - * _.range(0, 20, 5); - * // => [0, 5, 10, 15] - * - * _.range(0, -4, -1); - * // => [0, -1, -2, -3] - * - * _.range(1, 4, 0); - * // => [1, 1, 1] - * - * _.range(0); - * // => [] - */ - function range(start, end, step) { - start = +start || 0; - step = typeof step == 'number' ? step : (+step || 1); - - if (end == null) { - end = start; - start = 0; - } - // use `Array(length)` so engines like Chakra and V8 avoid slower modes - // http://youtu.be/XAqIpGU8ZZk#t=17m25s - var index = -1, - length = nativeMax(0, ceil((end - start) / (step || 1))), - result = Array(length); - - while (++index < length) { - result[index] = start; - start += step; - } - return result; - } - - /** - * Removes all elements from an array that the callback returns truey for - * and returns an array of removed elements. The callback is bound to `thisArg` - * and invoked with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to modify. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a new array of removed elements. - * @example - * - * var array = [1, 2, 3, 4, 5, 6]; - * var evens = _.remove(array, function(num) { return num % 2 == 0; }); - * - * console.log(array); - * // => [1, 3, 5] - * - * console.log(evens); - * // => [2, 4, 6] - */ - function remove(array, callback, thisArg) { - var index = -1, - length = array ? array.length : 0, - result = []; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length) { - var value = array[index]; - if (callback(value, index, array)) { - result.push(value); - splice.call(array, index--, 1); - length--; - } - } - return result; - } - - /** - * The opposite of `_.initial` this method gets all but the first element or - * first `n` elements of an array. If a callback function is provided elements - * at the beginning of the array are excluded from the result as long as the - * callback returns truey. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias drop, tail - * @category Arrays - * @param {Array} array The array to query. - * @param {Function|Object|number|string} [callback=1] The function called - * per element or the number of elements to exclude. If a property name or - * object is provided it will be used to create a "_.pluck" or "_.where" - * style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a slice of `array`. - * @example - * - * _.rest([1, 2, 3]); - * // => [2, 3] - * - * _.rest([1, 2, 3], 2); - * // => [3] - * - * _.rest([1, 2, 3], function(num) { - * return num < 3; - * }); - * // => [3] - * - * var characters = [ - * { 'name': 'barney', 'blocked': true, 'employer': 'slate' }, - * { 'name': 'fred', 'blocked': false, 'employer': 'slate' }, - * { 'name': 'pebbles', 'blocked': true, 'employer': 'na' } - * ]; - * - * // using "_.pluck" callback shorthand - * _.pluck(_.rest(characters, 'blocked'), 'name'); - * // => ['fred', 'pebbles'] - * - * // using "_.where" callback shorthand - * _.rest(characters, { 'employer': 'slate' }); - * // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }] - */ - function rest(array, callback, thisArg) { - if (typeof callback != 'number' && callback != null) { - var n = 0, - index = -1, - length = array ? array.length : 0; - - callback = lodash.createCallback(callback, thisArg, 3); - while (++index < length && callback(array[index], index, array)) { - n++; - } - } else { - n = (callback == null || thisArg) ? 1 : nativeMax(0, callback); - } - return slice(array, n); - } - - /** - * Uses a binary search to determine the smallest index at which a value - * should be inserted into a given sorted array in order to maintain the sort - * order of the array. If a callback is provided it will be executed for - * `value` and each element of `array` to compute their sort ranking. The - * callback is bound to `thisArg` and invoked with one argument; (value). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to inspect. - * @param {*} value The value to evaluate. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {number} Returns the index at which `value` should be inserted - * into `array`. - * @example - * - * _.sortedIndex([20, 30, 50], 40); - * // => 2 - * - * // using "_.pluck" callback shorthand - * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); - * // => 2 - * - * var dict = { - * 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } - * }; - * - * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - * return dict.wordToNumber[word]; - * }); - * // => 2 - * - * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - * return this.wordToNumber[word]; - * }, dict); - * // => 2 - */ - function sortedIndex(array, value, callback, thisArg) { - var low = 0, - high = array ? array.length : low; - - // explicitly reference `identity` for better inlining in Firefox - callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity; - value = callback(value); - - while (low < high) { - var mid = (low + high) >>> 1; - (callback(array[mid]) < value) - ? low = mid + 1 - : high = mid; - } - return low; - } - - /** - * Creates an array of unique values, in order, of the provided arrays using - * strict equality for comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of combined values. - * @example - * - * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2, 3, 5, 4] - */ - function union() { - return baseUniq(baseFlatten(arguments, true, true)); - } - - /** - * Creates a duplicate-value-free version of an array using strict equality - * for comparisons, i.e. `===`. If the array is sorted, providing - * `true` for `isSorted` will use a faster algorithm. If a callback is provided - * each element of `array` is passed through the callback before uniqueness - * is computed. The callback is bound to `thisArg` and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for `callback` the created "_.pluck" style - * callback will return the property value of the given element. - * - * If an object is provided for `callback` the created "_.where" style callback - * will return `true` for elements that have the properties of the given object, - * else `false`. - * - * @static - * @memberOf _ - * @alias unique - * @category Arrays - * @param {Array} array The array to process. - * @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted. - * @param {Function|Object|string} [callback=identity] The function called - * per iteration. If a property name or object is provided it will be used - * to create a "_.pluck" or "_.where" style callback, respectively. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array} Returns a duplicate-value-free array. - * @example - * - * _.uniq([1, 2, 1, 3, 1]); - * // => [1, 2, 3] - * - * _.uniq([1, 1, 2, 2, 3], true); - * // => [1, 2, 3] - * - * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); - * // => ['A', 'b', 'C'] - * - * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2.5, 3] - * - * // using "_.pluck" callback shorthand - * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - * // => [{ 'x': 1 }, { 'x': 2 }] - */ - function uniq(array, isSorted, callback, thisArg) { - // juggle arguments - if (typeof isSorted != 'boolean' && isSorted != null) { - thisArg = callback; - callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted; - isSorted = false; - } - if (callback != null) { - callback = lodash.createCallback(callback, thisArg, 3); - } - return baseUniq(array, isSorted, callback); - } - - /** - * Creates an array excluding all provided values using strict equality for - * comparisons, i.e. `===`. - * - * @static - * @memberOf _ - * @category Arrays - * @param {Array} array The array to filter. - * @param {...*} [value] The values to exclude. - * @returns {Array} Returns a new array of filtered values. - * @example - * - * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - * // => [2, 3, 4] - */ - function without(array) { - return baseDifference(array, slice(arguments, 1)); - } - - /** - * Creates an array that is the symmetric difference of the provided arrays. - * See http://en.wikipedia.org/wiki/Symmetric_difference. - * - * @static - * @memberOf _ - * @category Arrays - * @param {...Array} [array] The arrays to inspect. - * @returns {Array} Returns an array of values. - * @example - * - * _.xor([1, 2, 3], [5, 2, 1, 4]); - * // => [3, 5, 4] - * - * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); - * // => [1, 4, 5] - */ - function xor() { - var index = -1, - length = arguments.length; - - while (++index < length) { - var array = arguments[index]; - if (isArray(array) || isArguments(array)) { - var result = result - ? baseUniq(baseDifference(result, array).concat(baseDifference(array, result))) - : array; - } - } - return result || []; - } - - /** - * Creates an array of grouped elements, the first of which contains the first - * elements of the given arrays, the second of which contains the second - * elements of the given arrays, and so on. - * - * @static - * @memberOf _ - * @alias unzip - * @category Arrays - * @param {...Array} [array] Arrays to process. - * @returns {Array} Returns a new array of grouped elements. - * @example - * - * _.zip(['fred', 'barney'], [30, 40], [true, false]); - * // => [['fred', 30, true], ['barney', 40, false]] - */ - function zip() { - var array = arguments.length > 1 ? arguments : arguments[0], - index = -1, - length = array ? max(pluck(array, 'length')) : 0, - result = Array(length < 0 ? 0 : length); - - while (++index < length) { - result[index] = pluck(array, index); - } - return result; - } - - /** - * Creates an object composed from arrays of `keys` and `values`. Provide - * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` - * or two arrays, one of `keys` and one of corresponding `values`. - * - * @static - * @memberOf _ - * @alias object - * @category Arrays - * @param {Array} keys The array of keys. - * @param {Array} [values=[]] The array of values. - * @returns {Object} Returns an object composed of the given keys and - * corresponding values. - * @example - * - * _.zipObject(['fred', 'barney'], [30, 40]); - * // => { 'fred': 30, 'barney': 40 } - */ - function zipObject(keys, values) { - var index = -1, - length = keys ? keys.length : 0, - result = {}; - - if (!values && length && !isArray(keys[0])) { - values = []; - } - while (++index < length) { - var key = keys[index]; - if (values) { - result[key] = values[index]; - } else if (key) { - result[key[0]] = key[1]; - } - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a function that executes `func`, with the `this` binding and - * arguments of the created function, only after being called `n` times. - * - * @static - * @memberOf _ - * @category Functions - * @param {number} n The number of times the function must be called before - * `func` is executed. - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var saves = ['profile', 'settings']; - * - * var done = _.after(saves.length, function() { - * console.log('Done saving!'); - * }); - * - * _.forEach(saves, function(type) { - * asyncSave({ 'type': type, 'complete': done }); - * }); - * // => logs 'Done saving!', after all saves have completed - */ - function after(n, func) { - if (!isFunction(func)) { - throw new TypeError; - } - return function() { - if (--n < 1) { - return func.apply(this, arguments); - } - }; - } - - /** - * Creates a function that, when called, invokes `func` with the `this` - * binding of `thisArg` and prepends any additional `bind` arguments to those - * provided to the bound function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var func = function(greeting) { - * return greeting + ' ' + this.name; - * }; - * - * func = _.bind(func, { 'name': 'fred' }, 'hi'); - * func(); - * // => 'hi fred' - */ - function bind(func, thisArg) { - return arguments.length > 2 - ? createWrapper(func, 17, slice(arguments, 2), null, thisArg) - : createWrapper(func, 1, null, null, thisArg); - } - - /** - * Binds methods of an object to the object itself, overwriting the existing - * method. Method names may be specified as individual arguments or as arrays - * of method names. If no method names are provided all the function properties - * of `object` will be bound. - * - * @static - * @memberOf _ - * @category Functions - * @param {Object} object The object to bind and assign the bound methods to. - * @param {...string} [methodName] The object method names to - * bind, specified as individual method names or arrays of method names. - * @returns {Object} Returns `object`. - * @example - * - * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } - * }; - * - * _.bindAll(view); - * jQuery('#docs').on('click', view.onClick); - * // => logs 'clicked docs', when the button is clicked - */ - function bindAll(object) { - var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), - index = -1, - length = funcs.length; - - while (++index < length) { - var key = funcs[index]; - object[key] = createWrapper(object[key], 1, null, null, object); - } - return object; - } - - /** - * Creates a function that, when called, invokes the method at `object[key]` - * and prepends any additional `bindKey` arguments to those provided to the bound - * function. This method differs from `_.bind` by allowing bound functions to - * reference methods that will be redefined or don't yet exist. - * See http://michaux.ca/articles/lazy-function-definition-pattern. - * - * @static - * @memberOf _ - * @category Functions - * @param {Object} object The object the method belongs to. - * @param {string} key The key of the method. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new bound function. - * @example - * - * var object = { - * 'name': 'fred', - * 'greet': function(greeting) { - * return greeting + ' ' + this.name; - * } - * }; - * - * var func = _.bindKey(object, 'greet', 'hi'); - * func(); - * // => 'hi fred' - * - * object.greet = function(greeting) { - * return greeting + 'ya ' + this.name + '!'; - * }; - * - * func(); - * // => 'hiya fred!' - */ - function bindKey(object, key) { - return arguments.length > 2 - ? createWrapper(key, 19, slice(arguments, 2), null, object) - : createWrapper(key, 3, null, null, object); - } - - /** - * Creates a function that is the composition of the provided functions, - * where each function consumes the return value of the function that follows. - * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. - * Each function is executed with the `this` binding of the composed function. - * - * @static - * @memberOf _ - * @category Functions - * @param {...Function} [func] Functions to compose. - * @returns {Function} Returns the new composed function. - * @example - * - * var realNameMap = { - * 'pebbles': 'penelope' - * }; - * - * var format = function(name) { - * name = realNameMap[name.toLowerCase()] || name; - * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); - * }; - * - * var greet = function(formatted) { - * return 'Hiya ' + formatted + '!'; - * }; - * - * var welcome = _.compose(greet, format); - * welcome('pebbles'); - * // => 'Hiya Penelope!' - */ - function compose() { - var funcs = arguments, - length = funcs.length; - - while (length--) { - if (!isFunction(funcs[length])) { - throw new TypeError; - } - } - return function() { - var args = arguments, - length = funcs.length; - - while (length--) { - args = [funcs[length].apply(this, args)]; - } - return args[0]; - }; - } - - /** - * Creates a function which accepts one or more arguments of `func` that when - * invoked either executes `func` returning its result, if all `func` arguments - * have been provided, or returns a function that accepts one or more of the - * remaining `func` arguments, and so on. The arity of `func` can be specified - * if `func.length` is not sufficient. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to curry. - * @param {number} [arity=func.length] The arity of `func`. - * @returns {Function} Returns the new curried function. - * @example - * - * var curried = _.curry(function(a, b, c) { - * console.log(a + b + c); - * }); - * - * curried(1)(2)(3); - * // => 6 - * - * curried(1, 2)(3); - * // => 6 - * - * curried(1, 2, 3); - * // => 6 - */ - function curry(func, arity) { - arity = typeof arity == 'number' ? arity : (+arity || func.length); - return createWrapper(func, 4, null, null, null, arity); - } - - /** - * Creates a function that will delay the execution of `func` until after - * `wait` milliseconds have elapsed since the last time it was invoked. - * Provide an options object to indicate that `func` should be invoked on - * the leading and/or trailing edge of the `wait` timeout. Subsequent calls - * to the debounced function will return the result of the last `func` call. - * - * Note: If `leading` and `trailing` options are `true` `func` will be called - * on the trailing edge of the timeout only if the the debounced function is - * invoked more than once during the `wait` timeout. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to debounce. - * @param {number} wait The number of milliseconds to delay. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout. - * @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called. - * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // avoid costly calculations while the window size is in flux - * var lazyLayout = _.debounce(calculateLayout, 150); - * jQuery(window).on('resize', lazyLayout); - * - * // execute `sendMail` when the click event is fired, debouncing subsequent calls - * jQuery('#postbox').on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * }); - * - * // ensure `batchLog` is executed once after 1 second of debounced calls - * var source = new EventSource('/stream'); - * source.addEventListener('message', _.debounce(batchLog, 250, { - * 'maxWait': 1000 - * }, false); - */ - function debounce(func, wait, options) { - var args, - maxTimeoutId, - result, - stamp, - thisArg, - timeoutId, - trailingCall, - lastCalled = 0, - maxWait = false, - trailing = true; - - if (!isFunction(func)) { - throw new TypeError; - } - wait = nativeMax(0, wait) || 0; - if (options === true) { - var leading = true; - trailing = false; - } else if (isObject(options)) { - leading = options.leading; - maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); - trailing = 'trailing' in options ? options.trailing : trailing; - } - var delayed = function() { - var remaining = wait - (now() - stamp); - if (remaining <= 0) { - if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - } - var isCalled = trailingCall; - maxTimeoutId = timeoutId = trailingCall = undefined; - if (isCalled) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - } - } else { - timeoutId = setTimeout(delayed, remaining); - } - }; - - var maxDelayed = function() { - if (timeoutId) { - clearTimeout(timeoutId); - } - maxTimeoutId = timeoutId = trailingCall = undefined; - if (trailing || (maxWait !== wait)) { - lastCalled = now(); - result = func.apply(thisArg, args); - if (!timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - } - }; - - return function() { - args = arguments; - stamp = now(); - thisArg = this; - trailingCall = trailing && (timeoutId || !leading); - - if (maxWait === false) { - var leadingCall = leading && !timeoutId; - } else { - if (!maxTimeoutId && !leading) { - lastCalled = stamp; - } - var remaining = maxWait - (stamp - lastCalled), - isCalled = remaining <= 0; - - if (isCalled) { - if (maxTimeoutId) { - maxTimeoutId = clearTimeout(maxTimeoutId); - } - lastCalled = stamp; - result = func.apply(thisArg, args); - } - else if (!maxTimeoutId) { - maxTimeoutId = setTimeout(maxDelayed, remaining); - } - } - if (isCalled && timeoutId) { - timeoutId = clearTimeout(timeoutId); - } - else if (!timeoutId && wait !== maxWait) { - timeoutId = setTimeout(delayed, wait); - } - if (leadingCall) { - isCalled = true; - result = func.apply(thisArg, args); - } - if (isCalled && !timeoutId && !maxTimeoutId) { - args = thisArg = null; - } - return result; - }; - } - - /** - * Defers executing the `func` function until the current call stack has cleared. - * Additional arguments will be provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to defer. - * @param {...*} [arg] Arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.defer(function(text) { console.log(text); }, 'deferred'); - * // logs 'deferred' after one or more milliseconds - */ - function defer(func) { - if (!isFunction(func)) { - throw new TypeError; - } - var args = slice(arguments, 1); - return setTimeout(function() { func.apply(undefined, args); }, 1); - } - - /** - * Executes the `func` function after `wait` milliseconds. Additional arguments - * will be provided to `func` when it is invoked. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to delay. - * @param {number} wait The number of milliseconds to delay execution. - * @param {...*} [arg] Arguments to invoke the function with. - * @returns {number} Returns the timer id. - * @example - * - * _.delay(function(text) { console.log(text); }, 1000, 'later'); - * // => logs 'later' after one second - */ - function delay(func, wait) { - if (!isFunction(func)) { - throw new TypeError; - } - var args = slice(arguments, 2); - return setTimeout(function() { func.apply(undefined, args); }, wait); - } - - /** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided it will be used to determine the cache key for storing the result - * based on the arguments provided to the memoized function. By default, the - * first argument provided to the memoized function is used as the cache key. - * The `func` is executed with the `this` binding of the memoized function. - * The result cache is exposed as the `cache` property on the memoized function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] A function used to resolve the cache key. - * @returns {Function} Returns the new memoizing function. - * @example - * - * var fibonacci = _.memoize(function(n) { - * return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); - * }); - * - * fibonacci(9) - * // => 34 - * - * var data = { - * 'fred': { 'name': 'fred', 'age': 40 }, - * 'pebbles': { 'name': 'pebbles', 'age': 1 } - * }; - * - * // modifying the result cache - * var get = _.memoize(function(name) { return data[name]; }, _.identity); - * get('pebbles'); - * // => { 'name': 'pebbles', 'age': 1 } - * - * get.cache.pebbles.name = 'penelope'; - * get('pebbles'); - * // => { 'name': 'penelope', 'age': 1 } - */ - function memoize(func, resolver) { - if (!isFunction(func)) { - throw new TypeError; - } - var memoized = function() { - var cache = memoized.cache, - key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0]; - - return hasOwnProperty.call(cache, key) - ? cache[key] - : (cache[key] = func.apply(this, arguments)); - } - memoized.cache = {}; - return memoized; - } - - /** - * Creates a function that is restricted to execute `func` once. Repeat calls to - * the function will return the value of the first call. The `func` is executed - * with the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to restrict. - * @returns {Function} Returns the new restricted function. - * @example - * - * var initialize = _.once(createApplication); - * initialize(); - * initialize(); - * // `initialize` executes `createApplication` once - */ - function once(func) { - var ran, - result; - - if (!isFunction(func)) { - throw new TypeError; - } - return function() { - if (ran) { - return result; - } - ran = true; - result = func.apply(this, arguments); - - // clear the `func` variable so the function may be garbage collected - func = null; - return result; - }; - } - - /** - * Creates a function that, when called, invokes `func` with any additional - * `partial` arguments prepended to those provided to the new function. This - * method is similar to `_.bind` except it does **not** alter the `this` binding. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var greet = function(greeting, name) { return greeting + ' ' + name; }; - * var hi = _.partial(greet, 'hi'); - * hi('fred'); - * // => 'hi fred' - */ - function partial(func) { - return createWrapper(func, 16, slice(arguments, 1)); - } - - /** - * This method is like `_.partial` except that `partial` arguments are - * appended to those provided to the new function. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to partially apply arguments to. - * @param {...*} [arg] Arguments to be partially applied. - * @returns {Function} Returns the new partially applied function. - * @example - * - * var defaultsDeep = _.partialRight(_.merge, _.defaults); - * - * var options = { - * 'variable': 'data', - * 'imports': { 'jq': $ } - * }; - * - * defaultsDeep(options, _.templateSettings); - * - * options.variable - * // => 'data' - * - * options.imports - * // => { '_': _, 'jq': $ } - */ - function partialRight(func) { - return createWrapper(func, 32, null, slice(arguments, 1)); - } - - /** - * Creates a function that, when executed, will only call the `func` function - * at most once per every `wait` milliseconds. Provide an options object to - * indicate that `func` should be invoked on the leading and/or trailing edge - * of the `wait` timeout. Subsequent calls to the throttled function will - * return the result of the last `func` call. - * - * Note: If `leading` and `trailing` options are `true` `func` will be called - * on the trailing edge of the timeout only if the the throttled function is - * invoked more than once during the `wait` timeout. - * - * @static - * @memberOf _ - * @category Functions - * @param {Function} func The function to throttle. - * @param {number} wait The number of milliseconds to throttle executions to. - * @param {Object} [options] The options object. - * @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout. - * @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // avoid excessively updating the position while scrolling - * var throttled = _.throttle(updatePosition, 100); - * jQuery(window).on('scroll', throttled); - * - * // execute `renewToken` when the click event is fired, but not more than once every 5 minutes - * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { - * 'trailing': false - * })); - */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (!isFunction(func)) { - throw new TypeError; - } - if (options === false) { - leading = false; - } else if (isObject(options)) { - leading = 'leading' in options ? options.leading : leading; - trailing = 'trailing' in options ? options.trailing : trailing; - } - debounceOptions.leading = leading; - debounceOptions.maxWait = wait; - debounceOptions.trailing = trailing; - - return debounce(func, wait, debounceOptions); - } - - /** - * Creates a function that provides `value` to the wrapper function as its - * first argument. Additional arguments provided to the function are appended - * to those provided to the wrapper function. The wrapper is executed with - * the `this` binding of the created function. - * - * @static - * @memberOf _ - * @category Functions - * @param {*} value The value to wrap. - * @param {Function} wrapper The wrapper function. - * @returns {Function} Returns the new function. - * @example - * - * var p = _.wrap(_.escape, function(func, text) { - * return '

          ' + func(text) + '

          '; - * }); - * - * p('Fred, Wilma, & Pebbles'); - * // => '

          Fred, Wilma, & Pebbles

          ' - */ - function wrap(value, wrapper) { - return createWrapper(wrapper, 16, [value]); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new function. - * @example - * - * var object = { 'name': 'fred' }; - * var getter = _.constant(object); - * getter() === object; - * // => true - */ - function constant(value) { - return function() { - return value; - }; - } - - /** - * Produces a callback bound to an optional `thisArg`. If `func` is a property - * name the created callback will return the property value for a given element. - * If `func` is an object the created callback will return `true` for elements - * that contain the equivalent object properties, otherwise it will return `false`. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} [func=identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of the created callback. - * @param {number} [argCount] The number of arguments the callback accepts. - * @returns {Function} Returns a callback function. - * @example - * - * var characters = [ - * { 'name': 'barney', 'age': 36 }, - * { 'name': 'fred', 'age': 40 } - * ]; - * - * // wrap to create custom callback shorthands - * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) { - * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback); - * return !match ? func(callback, thisArg) : function(object) { - * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; - * }; - * }); - * - * _.filter(characters, 'age__gt38'); - * // => [{ 'name': 'fred', 'age': 40 }] - */ - function createCallback(func, thisArg, argCount) { - var type = typeof func; - if (func == null || type == 'function') { - return baseCreateCallback(func, thisArg, argCount); - } - // handle "_.pluck" style callback shorthands - if (type != 'object') { - return property(func); - } - var props = keys(func), - key = props[0], - a = func[key]; - - // handle "_.where" style callback shorthands - if (props.length == 1 && a === a && !isObject(a)) { - // fast path the common case of providing an object with a single - // property containing a primitive value - return function(object) { - var b = object[key]; - return a === b && (a !== 0 || (1 / a == 1 / b)); - }; - } - return function(object) { - var length = props.length, - result = false; - - while (length--) { - if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) { - break; - } - } - return result; - }; - } - - /** - * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their - * corresponding HTML entities. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} string The string to escape. - * @returns {string} Returns the escaped string. - * @example - * - * _.escape('Fred, Wilma, & Pebbles'); - * // => 'Fred, Wilma, & Pebbles' - */ - function escape(string) { - return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); - } - - /** - * This method returns the first argument provided to it. - * - * @static - * @memberOf _ - * @category Utilities - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'name': 'fred' }; - * _.identity(object) === object; - * // => true - */ - function identity(value) { - return value; - } - - /** - * Adds function properties of a source object to the destination object. - * If `object` is a function methods will be added to its prototype as well. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Function|Object} [object=lodash] object The destination object. - * @param {Object} source The object of functions to add. - * @param {Object} [options] The options object. - * @param {boolean} [options.chain=true] Specify whether the functions added are chainable. - * @example - * - * function capitalize(string) { - * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - * } - * - * _.mixin({ 'capitalize': capitalize }); - * _.capitalize('fred'); - * // => 'Fred' - * - * _('fred').capitalize().value(); - * // => 'Fred' - * - * _.mixin({ 'capitalize': capitalize }, { 'chain': false }); - * _('fred').capitalize(); - * // => 'Fred' - */ - function mixin(object, source, options) { - var chain = true, - methodNames = source && functions(source); - - if (!source || (!options && !methodNames.length)) { - if (options == null) { - options = source; - } - ctor = lodashWrapper; - source = object; - object = lodash; - methodNames = functions(source); - } - if (options === false) { - chain = false; - } else if (isObject(options) && 'chain' in options) { - chain = options.chain; - } - var ctor = object, - isFunc = isFunction(ctor); - - forEach(methodNames, function(methodName) { - var func = object[methodName] = source[methodName]; - if (isFunc) { - ctor.prototype[methodName] = function() { - var chainAll = this.__chain__, - value = this.__wrapped__, - args = [value]; - - push.apply(args, arguments); - var result = func.apply(object, args); - if (chain || chainAll) { - if (value === result && isObject(result)) { - return this; - } - result = new ctor(result); - result.__chain__ = chainAll; - } - return result; - }; - } - }); - } - - /** - * Reverts the '_' variable to its previous value and returns a reference to - * the `lodash` function. - * - * @static - * @memberOf _ - * @category Utilities - * @returns {Function} Returns the `lodash` function. - * @example - * - * var lodash = _.noConflict(); - */ - function noConflict() { - context._ = oldDash; - return this; - } - - /** - * A no-operation function. - * - * @static - * @memberOf _ - * @category Utilities - * @example - * - * var object = { 'name': 'fred' }; - * _.noop(object) === undefined; - * // => true - */ - function noop() { - // no operation performed - } - - /** - * Gets the number of milliseconds that have elapsed since the Unix epoch - * (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @category Utilities - * @example - * - * var stamp = _.now(); - * _.defer(function() { console.log(_.now() - stamp); }); - * // => logs the number of milliseconds it took for the deferred function to be called - */ - var now = isNative(now = Date.now) && now || function() { - return new Date().getTime(); - }; - - /** - * Converts the given value into an integer of the specified radix. - * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the - * `value` is a hexadecimal, in which case a `radix` of `16` is used. - * - * Note: This method avoids differences in native ES3 and ES5 `parseInt` - * implementations. See http://es5.github.io/#E. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} value The value to parse. - * @param {number} [radix] The radix used to interpret the value to parse. - * @returns {number} Returns the new integer value. - * @example - * - * _.parseInt('08'); - * // => 8 - */ - var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) { - // Firefox < 21 and Opera < 15 follow the ES3 specified implementation of `parseInt` - return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0); - }; - - /** - * Creates a "_.pluck" style function, which returns the `key` value of a - * given object. - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} key The name of the property to retrieve. - * @returns {Function} Returns the new function. - * @example - * - * var characters = [ - * { 'name': 'fred', 'age': 40 }, - * { 'name': 'barney', 'age': 36 } - * ]; - * - * var getName = _.property('name'); - * - * _.map(characters, getName); - * // => ['barney', 'fred'] - * - * _.sortBy(characters, getName); - * // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] - */ - function property(key) { - return function(object) { - return object[key]; - }; - } - - /** - * Produces a random number between `min` and `max` (inclusive). If only one - * argument is provided a number between `0` and the given number will be - * returned. If `floating` is truey or either `min` or `max` are floats a - * floating-point number will be returned instead of an integer. - * - * @static - * @memberOf _ - * @category Utilities - * @param {number} [min=0] The minimum possible value. - * @param {number} [max=1] The maximum possible value. - * @param {boolean} [floating=false] Specify returning a floating-point number. - * @returns {number} Returns a random number. - * @example - * - * _.random(0, 5); - * // => an integer between 0 and 5 - * - * _.random(5); - * // => also an integer between 0 and 5 - * - * _.random(5, true); - * // => a floating-point number between 0 and 5 - * - * _.random(1.2, 5.2); - * // => a floating-point number between 1.2 and 5.2 - */ - function random(min, max, floating) { - var noMin = min == null, - noMax = max == null; - - if (floating == null) { - if (typeof min == 'boolean' && noMax) { - floating = min; - min = 1; - } - else if (!noMax && typeof max == 'boolean') { - floating = max; - noMax = true; - } - } - if (noMin && noMax) { - max = 1; - } - min = +min || 0; - if (noMax) { - max = min; - min = 0; - } else { - max = +max || 0; - } - if (floating || min % 1 || max % 1) { - var rand = nativeRandom(); - return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1)))), max); - } - return baseRandom(min, max); - } - - /** - * Resolves the value of property `key` on `object`. If `key` is a function - * it will be invoked with the `this` binding of `object` and its result returned, - * else the property value is returned. If `object` is falsey then `undefined` - * is returned. - * - * @static - * @memberOf _ - * @category Utilities - * @param {Object} object The object to inspect. - * @param {string} key The name of the property to resolve. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { - * 'cheese': 'crumpets', - * 'stuff': function() { - * return 'nonsense'; - * } - * }; - * - * _.result(object, 'cheese'); - * // => 'crumpets' - * - * _.result(object, 'stuff'); - * // => 'nonsense' - */ - function result(object, key) { - if (object) { - var value = object[key]; - return isFunction(value) ? object[key]() : value; - } - } - - /** - * A micro-templating method that handles arbitrary delimiters, preserves - * whitespace, and correctly escapes quotes within interpolated code. - * - * Note: In the development build, `_.template` utilizes sourceURLs for easier - * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl - * - * For more information on precompiling templates see: - * https://lodash.com/custom-builds - * - * For more information on Chrome extension sandboxes see: - * http://developer.chrome.com/stable/extensions/sandboxingEval.html - * - * @static - * @memberOf _ - * @category Utilities - * @param {string} text The template text. - * @param {Object} data The data object used to populate the text. - * @param {Object} [options] The options object. - * @param {RegExp} [options.escape] The "escape" delimiter. - * @param {RegExp} [options.evaluate] The "evaluate" delimiter. - * @param {Object} [options.imports] An object to import into the template as local variables. - * @param {RegExp} [options.interpolate] The "interpolate" delimiter. - * @param {string} [sourceURL] The sourceURL of the template's compiled source. - * @param {string} [variable] The data object variable name. - * @returns {Function|string} Returns a compiled function when no `data` object - * is given, else it returns the interpolated text. - * @example - * - * // using the "interpolate" delimiter to create a compiled template - * var compiled = _.template('hello <%= name %>'); - * compiled({ 'name': 'fred' }); - * // => 'hello fred' - * - * // using the "escape" delimiter to escape HTML in data property values - * _.template('<%- value %>', { 'value': '", 'Script'); -}; - -WYMeditor.XhtmlLexer.prototype.addCssTokens = function(scope) { - this.addEntryPattern("", 'Css'); -}; - -WYMeditor.XhtmlLexer.prototype.addTagTokens = function(scope) { - this.addSpecialPattern("<\\s*[a-z0-9:\-]+\\s*/>", scope, 'SelfClosingTag'); - this.addSpecialPattern("<\\s*[a-z0-9:\-]+\\s*>", scope, 'OpeningTag'); - this.addEntryPattern("<[a-z0-9:\-]+"+'[\\\/ \\\>]+', scope, 'OpeningTag'); - this.addInTagDeclarationTokens('OpeningTag'); - - this.addSpecialPattern("", scope, 'ClosingTag'); - -}; - -WYMeditor.XhtmlLexer.prototype.addInTagDeclarationTokens = function(scope) { - this.addSpecialPattern('\\s+', scope, 'Ignore'); - - this.addAttributeTokens(scope); - - this.addExitPattern('/>', scope); - this.addExitPattern('>', scope); - -}; - -WYMeditor.XhtmlLexer.prototype.addAttributeTokens = function(scope) { - this.addSpecialPattern("\\s*[a-z-_0-9]*:?[a-z-_0-9]+\\s*(?=\=)\\s*", scope, 'TagAttributes'); - - this.addEntryPattern('=\\s*"', scope, 'DoubleQuotedAttribute'); - this.addPattern("\\\\\"", 'DoubleQuotedAttribute'); - this.addExitPattern('"', 'DoubleQuotedAttribute'); - - this.addEntryPattern("=\\s*'", scope, 'SingleQuotedAttribute'); - this.addPattern("\\\\'", 'SingleQuotedAttribute'); - this.addExitPattern("'", 'SingleQuotedAttribute'); - - this.addSpecialPattern('=\\s*[^>\\s]*', scope, 'UnquotedAttribute'); -}; - - -/** -* XHTML Parser. -* -* This XHTML parser will trigger the events available on on -* current SaxListener -* -* @author Bermi Ferrer (http://bermi.org) -*/ -WYMeditor.XhtmlParser = function(Listener, mode) { - mode = mode || 'Text'; - this._Lexer = new WYMeditor.XhtmlLexer(this); - this._Listener = Listener; - this._mode = mode; - this._matches = []; - this._last_match = ''; - this._current_match = ''; - - return this; -}; - -WYMeditor.XhtmlParser.prototype.parse = function(raw) { - this._Lexer.parse(this.beforeParsing(raw)); - return this.afterParsing(this._Listener.getResult()); -}; - -WYMeditor.XhtmlParser.prototype.beforeParsing = function(raw) { - if (raw.match(/class="MsoNormal"/) || raw.match(/ns = "urn:schemas-microsoft-com/)) { - // Useful for cleaning up content pasted from other sources (MSWord) - this._Listener.avoidStylingTagsAndAttributes(); - } - - return this._Listener.beforeParsing(raw); -}; - -WYMeditor.XhtmlParser.prototype.afterParsing = function(parsed) { - if (this._Listener._avoiding_tags_implicitly) { - this._Listener.allowStylingTagsAndAttributes(); - } - return this._Listener.afterParsing(parsed); -}; - - -WYMeditor.XhtmlParser.prototype.Ignore = function(match, state) { - return true; -}; - -WYMeditor.XhtmlParser.prototype.Text = function(text) { - this._Listener.addContent(text); - return true; -}; - -WYMeditor.XhtmlParser.prototype.Comment = function(match, status) { - return this._addNonTagBlock(match, status, 'addComment'); -}; - -WYMeditor.XhtmlParser.prototype.Script = function(match, status) { - return this._addNonTagBlock(match, status, 'addScript'); -}; - -WYMeditor.XhtmlParser.prototype.Css = function(match, status) { - return this._addNonTagBlock(match, status, 'addCss'); -}; - -WYMeditor.XhtmlParser.prototype._addNonTagBlock = function(match, state, type) { - switch (state) { - case WYMeditor.LEXER_ENTER: - this._non_tag = match; - break; - case WYMeditor.LEXER_UNMATCHED: - this._non_tag += match; - break; - case WYMeditor.LEXER_EXIT: - switch(type) { - case 'addComment': - this._Listener.addComment(this._non_tag+match); - break; - case 'addScript': - this._Listener.addScript(this._non_tag+match); - break; - case 'addCss': - this._Listener.addCss(this._non_tag+match); - break; - default: - break; - } - break; - default: - break; - } - return true; -}; - -WYMeditor.XhtmlParser.prototype.SelfClosingTag = function(match, state) { - var result = this.OpeningTag(match, state); - var tag = this.normalizeTag(match); - return this.ClosingTag(match, state); -}; - -WYMeditor.XhtmlParser.prototype.OpeningTag = function(match, state) { - switch (state){ - case WYMeditor.LEXER_ENTER: - this._tag = this.normalizeTag(match); - this._tag_attributes = {}; - break; - case WYMeditor.LEXER_SPECIAL: - this._callOpenTagListener(this.normalizeTag(match)); - break; - case WYMeditor.LEXER_EXIT: - this._callOpenTagListener(this._tag, this._tag_attributes); - break; - default: - break; - } - return true; -}; - -WYMeditor.XhtmlParser.prototype.ClosingTag = function(match, state) { - this._callCloseTagListener(this.normalizeTag(match)); - return true; -}; - -WYMeditor.XhtmlParser.prototype._callOpenTagListener = function(tag, attributes) { - attributes = attributes || {}; - this.autoCloseUnclosedBeforeNewOpening(tag); - - if (this._Listener.isBlockTag(tag)) { - this._Listener._tag_stack.push(tag); - this._Listener.fixNestingBeforeOpeningBlockTag(tag, attributes); - this._Listener.openBlockTag(tag, attributes); - this._increaseOpenTagCounter(tag); - } else if (this._Listener.isInlineTag(tag)) { - this._Listener.inlineTag(tag, attributes); - } else { - this._Listener.openUnknownTag(tag, attributes); - this._increaseOpenTagCounter(tag); - } - this._Listener.last_tag = tag; - this._Listener.last_tag_opened = true; - this._Listener.last_tag_attributes = attributes; -}; - -WYMeditor.XhtmlParser.prototype._callCloseTagListener = function(tag) { - if (this._decreaseOpenTagCounter(tag)) { - this.autoCloseUnclosedBeforeTagClosing(tag); - - if (this._Listener.isBlockTag(tag)) { - var expected_tag = this._Listener._tag_stack.pop(); - if (expected_tag === false) { - return; - } else if (expected_tag !== tag) { - // If we are expecting extra block closing tags, put the - // expected tag back on the tag stack. - if (this._Listener._extraBlockClosingTags) { - this._Listener._tag_stack.push(expected_tag); - this._Listener.removedExtraBlockClosingTag(); - return; - } - - tag = expected_tag; - } - this._Listener.closeBlockTag(tag); - } - } else { - if(!this._Listener.isInlineTag(tag)) { - this._Listener.closeUnopenedTag(tag); - } - } - - this._Listener.last_tag = tag; - this._Listener.last_tag_opened = false; -}; - -WYMeditor.XhtmlParser.prototype._increaseOpenTagCounter = function(tag) { - this._Listener._open_tags[tag] = this._Listener._open_tags[tag] || 0; - this._Listener._open_tags[tag]++; -}; - -WYMeditor.XhtmlParser.prototype._decreaseOpenTagCounter = function(tag) { - if (this._Listener._open_tags[tag]) { - this._Listener._open_tags[tag]--; - if (this._Listener._open_tags[tag] === 0) { - this._Listener._open_tags[tag] = undefined; - } - return true; - } - return false; -}; - -WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeNewOpening = function(new_tag) { - this._autoCloseUnclosed(new_tag, false); -}; - -WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeTagClosing = function(tag) { - this._autoCloseUnclosed(tag, true); -}; - -WYMeditor.XhtmlParser.prototype._autoCloseUnclosed = function(new_tag, closing) { - closing = closing || false; - if (this._Listener._open_tags) { - for (var tag in this._Listener._open_tags) { - if (this._Listener.shouldCloseTagAutomatically(tag, new_tag, closing)) { - this._callCloseTagListener(tag, true); - } - } - } -}; - -WYMeditor.XhtmlParser.prototype.getTagReplacements = function() { - return this._Listener.getTagReplacements(); -}; - -WYMeditor.XhtmlParser.prototype.normalizeTag = function(tag) { - tag = tag.replace(/^([\s<\/>]*)|([\s<\/>]*)$/gm,'').toLowerCase(); - var tags = this._Listener.getTagReplacements(); - if (tags[tag]) { - return tags[tag]; - } - return tag; -}; - -WYMeditor.XhtmlParser.prototype.TagAttributes = function(match, state) { - if (WYMeditor.LEXER_SPECIAL == state) { - this._current_attribute = match; - } - return true; -}; - -WYMeditor.XhtmlParser.prototype.DoubleQuotedAttribute = function(match, state) { - if (WYMeditor.LEXER_UNMATCHED == state) { - this._tag_attributes[this._current_attribute] = match; - } - return true; -}; - -WYMeditor.XhtmlParser.prototype.SingleQuotedAttribute = function(match, state) { - if (WYMeditor.LEXER_UNMATCHED == state) { - this._tag_attributes[this._current_attribute] = match; - } - return true; -}; - -WYMeditor.XhtmlParser.prototype.UnquotedAttribute = function(match, state) { - this._tag_attributes[this._current_attribute] = match.replace(/^=/,''); - return true; -}; - - -/** -* XHTML Sax parser. -* -* @author Bermi Ferrer (http://bermi.org) -*/ -WYMeditor.XhtmlSaxListener = function() { - this.output = ''; - this.helper = new WYMeditor.XmlHelper(); - this._open_tags = {}; - this.validator = WYMeditor.XhtmlValidator; - this._tag_stack = []; - this.avoided_tags = []; - this._insert_before_closing = []; - this._insert_after_closing = []; - this._last_node_was_text = false; - this._consecutive_brs = 0; - - // A string of the tag name of the last open tag added to the output. - this._lastAddedOpenTag = ''; - - // A boolean that should be set to true when the parser is within a list - // item and that should be set to false when the parser is no longer - // withing a list item. - this._insideLI = false; - - // An array of tags that should have their contents unwrapped if the tag is - // within a list item. - this.tagsToUnwrapInLists = - WYMeditor.DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS; - - // If any of these inline tags is found in the root, just remove them. - this._rootInlineTagsToRemove = ['br']; - - // A counter to keep track of the number of extra block closing tags that - // should be expected by the parser because of the removal of that - // element's opening tag. - this._extraBlockClosingTags = 0; - - this._insideTagToRemove = false; - // A boolean that indicates if a spacer line break should be added before - // the next element in a list item to preserve spacing because of the - // unwrapping of a block tag before the element. - this._addSpacerBeforeElementInLI = false; - - // This flag is set to true if the parser is currently inside a tag flagged - // for removal. Nothing will be added to the output while this flag is set - // to true. - this._insideTagToRemove = false; - - // If the last tag was not added to the output, this flag is set to true. - // This is needed because if we are trying to fix an invalid tag by nesting - // it in the last outputted tag as in the case of some invalid lists, if - // the last tag was removed, the invalid tag should just be removed as well - // instead of trying to fix it by nesting it in a tag that was already - // removed from the output. - this._lastTagRemoved = false; - - // When correcting invalid list nesting, situations can occur that will - // result in an extra closing LI tags coming up later in the parser. When - // one of these situations occurs, this counter is incremented so that it - // can be referenced to find how many extra LI closing tags to expect. This - // counter should be decremented everytime one of these extra LI closing - // tags is removed. - this._extraLIClosingTags = 0; - - // This is for storage of a tag's index in the tag stack so that the - // Listener can use it to check for when the tag has been closed (i.e. when - // the top of the tag stack is at the stored index again). - this._removedTagStackIndex = 0; - - this.entities = { - ' ':' ','¡':'¡','¢':'¢', - '£':'£','¤':'¤','¥':'¥', - '¦':'¦','§':'§','¨':'¨', - '©':'©','ª':'ª','«':'«', - '¬':'¬','­':'­','®':'®', - '¯':'¯','°':'°','±':'±', - '²':'²','³':'³','´':'´', - 'µ':'µ','¶':'¶','·':'·', - '¸':'¸','¹':'¹','º':'º', - '»':'»','¼':'¼','½':'½', - '¾':'¾','¿':'¿','À':'À', - 'Á':'Á','Â':'Â','Ã':'Ã', - 'Ä':'Ä','Å':'Å','Æ':'Æ', - 'Ç':'Ç','È':'È','É':'É', - 'Ê':'Ê','Ë':'Ë','Ì':'Ì', - 'Í':'Í','Î':'Î','Ï':'Ï', - 'Ð':'Ð','Ñ':'Ñ','Ò':'Ò', - 'Ó':'Ó','Ô':'Ô','Õ':'Õ', - 'Ö':'Ö','×':'×','Ø':'Ø', - 'Ù':'Ù','Ú':'Ú','Û':'Û', - 'Ü':'Ü','Ý':'Ý','Þ':'Þ', - 'ß':'ß','à':'à','á':'á', - 'â':'â','ã':'ã','ä':'ä', - 'å':'å','æ':'æ','ç':'ç', - 'è':'è','é':'é','ê':'ê', - 'ë':'ë','ì':'ì','í':'í', - 'î':'î','ï':'ï','ð':'ð', - 'ñ':'ñ','ò':'ò','ó':'ó', - 'ô':'ô','õ':'õ','ö':'ö', - '÷':'÷','ø':'ø','ù':'ù', - 'ú':'ú','û':'û','ü':'ü', - 'ý':'ý','þ':'þ','ÿ':'ÿ', - 'Œ':'Œ','œ':'œ','Š':'Š', - 'š':'š','Ÿ':'Ÿ','ƒ':'ƒ', - 'ˆ':'ˆ','˜':'˜','Α':'Α', - 'Β':'Β','Γ':'Γ','Δ':'Δ', - 'Ε':'Ε','Ζ':'Ζ','Η':'Η', - 'Θ':'Θ','Ι':'Ι','Κ':'Κ', - 'Λ':'Λ','Μ':'Μ','Ν':'Ν', - 'Ξ':'Ξ','Ο':'Ο','Π':'Π', - 'Ρ':'Ρ','Σ':'Σ','Τ':'Τ', - 'Υ':'Υ','Φ':'Φ','Χ':'Χ', - 'Ψ':'Ψ','Ω':'Ω','α':'α', - 'β':'β','γ':'γ','δ':'δ', - 'ε':'ε','ζ':'ζ','η':'η', - 'θ':'θ','ι':'ι','κ':'κ', - 'λ':'λ','μ':'μ','ν':'ν', - 'ξ':'ξ','ο':'ο','π':'π', - 'ρ':'ρ','ς':'ς','σ':'σ', - 'τ':'τ','υ':'υ','φ':'φ', - 'χ':'χ','ψ':'ψ','ω':'ω', - 'ϑ':'ϑ','ϒ':'ϒ','ϖ':'ϖ', - ' ':' ',' ':' ',' ':' ', - '‌':'‌','‍':'‍','‎':'‎', - '‏':'‏','–':'–','—':'—', - '‘':'‘','’':'’','‚':'‚', - '“':'“','”':'”','„':'„', - '†':'†','‡':'‡','•':'•', - '…':'…','‰':'‰','′':'′', - '″':'″','‹':'‹','›':'›', - '‾':'‾','⁄':'⁄','€':'€', - 'ℑ':'ℑ','℘':'℘','ℜ':'ℜ', - '™':'™','ℵ':'ℵ','←':'←', - '↑':'↑','→':'→','↓':'↓', - '↔':'↔','↵':'↵','⇐':'⇐', - '⇑':'⇑','⇒':'⇒','⇓':'⇓', - '⇔':'⇔','∀':'∀','∂':'∂', - '∃':'∃','∅':'∅','∇':'∇', - '∈':'∈','∉':'∉','∋':'∋', - '∏':'∏','∑':'∑','−':'−', - '∗':'∗','√':'√','∝':'∝', - '∞':'∞','∠':'∠','∧':'∧', - '∨':'∨','∩':'∩','∪':'∪', - '∫':'∫','∴':'∴','∼':'∼', - '≅':'≅','≈':'≈','≠':'≠', - '≡':'≡','≤':'≤','≥':'≥', - '⊂':'⊂','⊃':'⊃','⊄':'⊄', - '⊆':'⊆','⊇':'⊇','⊕':'⊕', - '⊗':'⊗','⊥':'⊥','⋅':'⋅', - '⌈':'⌈','⌉':'⌉','⌊':'⌊', - '⌋':'⌋','⟨':'〈','⟩':'〉', - '◊':'◊','♠':'♠','♣':'♣', - '♥':'♥','♦':'♦'}; - - this.block_tags = [ - "a", "abbr", "acronym", "address", "area", "b", - "base", "bdo", "big", "blockquote", "body", "button", - "caption", "cite", "code", "colgroup", "dd", "del", "div", - "dfn", "dl", "dt", "em", "fieldset", "form", "head", "h1", "h2", - "h3", "h4", "h5", "h6", "html", "i", "iframe", "ins", - "kbd", "label", "legend", "li", "map", "noscript", - "object", "ol", "optgroup", "option", "p", "param", "pre", "q", - "samp", "script", "select", "small", "span", "strong", "style", - "sub", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", - "thead", "title", "tr", "tt", "ul", "var", "extends"]; - - - this.inline_tags = ["br", "col", "hr", "img", "input"]; - - return this; -}; - -WYMeditor.XhtmlSaxListener.prototype.shouldCloseTagAutomatically = function(tag, now_on_tag, closing) { - if (tag != 'td' && tag != 'option') { - // We only attempt auto-closing for these tags - return false; - } - var openCount = this._open_tags[tag]; - if (!openCount) { - /// If there are no open tags, it would be pretty silly to try and close the tag - return false; - } - - if (tag == 'td') { - var openTrCount = this._open_tags['tr'] || 0; - // We use count instead of existence to handle nested tables/rows - if (!closing && now_on_tag === 'td' && openCount >= openTrCount) { - return true; - } - if (closing && now_on_tag == 'tr' && openCount > openTrCount) { - return true; - } - } else if (tag == 'option') { - if ((closing && now_on_tag == 'select') || (!closing && now_on_tag == 'option')) { - return true; - } - } - return false; -}; - -WYMeditor.XhtmlSaxListener.prototype.beforeParsing = function(raw) { - this.output = ''; - - // Reset attributes that might bleed over between parsing - this._insert_before_closing = []; - this._insert_after_closing = []; - this._open_tags = {}; - this._tag_stack = []; - this._last_node_was_text = false; - this._lastTagRemoved = false; - this._insideTagToRemove = false; - this.last_tag = null; - - return raw; -}; - -WYMeditor.XhtmlSaxListener.prototype.afterParsing = function(xhtml) { - xhtml = this.replaceNamedEntities(xhtml); - xhtml = this.joinRepeatedEntities(xhtml); - xhtml = this.removeEmptyTags(xhtml); - xhtml = this.removeBrInPre(xhtml); - - return xhtml; -}; - -WYMeditor.XhtmlSaxListener.prototype.replaceNamedEntities = function(xhtml) { - for (var entity in this.entities) { - xhtml = xhtml.replace(new RegExp(entity, 'g'), this.entities[entity]); - } - return xhtml; -}; - -WYMeditor.XhtmlSaxListener.prototype.joinRepeatedEntities = function(xhtml) { - var tags = 'em|strong|sub|sup|acronym|pre|del|address'; - return xhtml.replace(new RegExp('<\/('+tags+')><\\1>' ,''), ''). - replace( - new RegExp('(\s*<('+tags+')>\s*){2}(.*)(\s*<\/\\2>\s*){2}' ,''), - '<\$2>\$3<\$2>'); -}; - -WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags = function(xhtml) { - return xhtml.replace( - new RegExp( - '<('+this.block_tags.join("|"). - replace(/\|td/,''). - replace(/\|th/, '') + - ')>(
          | | |\\s)*<\/\\1>' ,'g'), - ''); -}; - -WYMeditor.XhtmlSaxListener.prototype.removeBrInPre = function(xhtml) { - var matches = xhtml.match(new RegExp(']*>(.*?)<\/pre>','gmi')); - if (matches) { - for (var i=0; i', 'g'), String.fromCharCode(13,10))); - } - } - return xhtml; -}; - -WYMeditor.XhtmlSaxListener.prototype.getResult = function() { - return this.output; -}; - -WYMeditor.XhtmlSaxListener.prototype.getTagReplacements = function() { - return {'b':'strong', 'i':'em'}; -}; - -WYMeditor.XhtmlSaxListener.prototype.getTagForStyle = function (style) { - if (/sub/.test(style)) { - return 'sub'; - } else if (/super/.test(style)) { - return 'sup'; - } else if (/bold/.test(style)) { - return 'strong'; - } else if (/italic/.test(style)) { - return 'em'; - } - - return false; -}; - -WYMeditor.XhtmlSaxListener.prototype.addContent = function(text) { - if (this.last_tag && this.last_tag == 'li') { - // We should strip trailing newlines from text inside li tags because - // IE adds random significant newlines inside nested lists - text = text.replace(/(\r|\n|\r\n)+$/g, ''); - - // Let's also normalize multiple newlines down to a single space - text = text.replace(/(\r|\n|\r\n)+/g, ' '); - } - if (text.replace(/^\s+|\s+$/g, '').length > 0) { - // Don't count it as text if it's empty - this._last_node_was_text = true; - if (this._addSpacerBeforeElementInLI) { - this.output += '
          '; - this._addSpacerBeforeElementInLI = false; - } - } - if (!this._insideTagToRemove) { - this.output += text; - } -}; - -WYMeditor.XhtmlSaxListener.prototype.addComment = function(text) { - if (this.remove_comments || this._insideTagToRemove) { - return; - } - this.output += text; -}; - -WYMeditor.XhtmlSaxListener.prototype.addScript = function(text) { - if (this.remove_scripts || this._insideTagToRemove) { - return; - } - this.output += text; -}; - -WYMeditor.XhtmlSaxListener.prototype.addCss = function(text) { - if (this.remove_embeded_styles || this._insideTagToRemove) { - return; - } - this.output += text; -}; - -WYMeditor.XhtmlSaxListener.prototype.openBlockTag = function(tag, attributes) { - var lastNodeWasText = this._last_node_was_text; - this._last_node_was_text = false; - - if (this._insideTagToRemove) { - // If we're currently in a block marked for removal, don't add it to - // the output. - return; - } - if (this._shouldRemoveTag(tag, attributes)) { - // If this tag is marked for removal, set a flag signifying that - // we're in a tag to remove and mark the position in the tag stack - // of this tag so that we know when we've reached the end of it. - this._insideTagToRemove = true; - this._removedTagStackIndex = this._tag_stack.length - 1; - return; - } - - // If we're currently inside an LI and this tag is not allowed inside - // an LI, unwrap the tag by not adding it to the output. - if (this._insideLI && jQuery.inArray(tag, this.tagsToUnwrapInLists) > -1) { - if (this._lastAddedOpenTag !== 'li' || lastNodeWasText) { - // If there was content inside the LI before this unwrapped block, - // insert a line break so that the content retains its spacing. - this.output += '
          '; - this._addSpacerBeforeElementInLI = false; - } - this._tag_stack.pop(); - this._extraBlockClosingTags++; - return; - } - - // Add a line break spacer before adding the open block tag if necessary - // and if the tag is not a list element. - if (this._addSpacerBeforeElementInLI && - tag !== 'li' && - jQuery.inArray(tag, WYMeditor.LIST_TYPE_ELEMENTS) === -1) { - this.output += '
          '; - this._addSpacerBeforeElementInLI = false; - } - - attributes = this.validator.getValidTagAttributes(tag, attributes); - attributes = this.removeUnwantedClasses(attributes); - - // Handle Mozilla and Safari styled spans - if (tag === 'span' && attributes.style) { - var new_tag = this.getTagForStyle(attributes.style); - if (new_tag) { - tag = new_tag; - this._tag_stack.pop(); - this._tag_stack.push(tag); - attributes.style = ''; - } - } - - if (tag === 'li') { - this._insideLI = true; - this._addSpacerBeforeElementInLI = false; - } - - this.output += this.helper.tag(tag, attributes, true); - this._lastAddedOpenTag = tag; - this._lastTagRemoved = false; -}; - -WYMeditor.XhtmlSaxListener.prototype.inlineTag = function(tag, attributes) { - if (this._insideTagToRemove || this._shouldRemoveTag(tag, attributes)) { - // If we're currently in a block marked for removal or if this tag is - // marked for removal, don't add it to the output. - return; - } - this._last_node_was_text = false; - - attributes = this.validator.getValidTagAttributes(tag, attributes); - attributes = this.removeUnwantedClasses(attributes); - this.output += this.helper.tag(tag, attributes); - this._lastTagRemoved = false; -}; - -WYMeditor.XhtmlSaxListener.prototype.openUnknownTag = function(tag, attributes) { - //this.output += this.helper.tag(tag, attributes, true); -}; - -WYMeditor.XhtmlSaxListener.prototype.closeBlockTag = function(tag) { - this._last_node_was_text = false; - if (this._insideTagToRemove) { - if (this._tag_stack.length === this._removedTagStackIndex) { - // If we've reached the index in the tag stack were the tag to be - // removed started, we're no longer inside that tag and can turn - // the insideTagToRemove flag off. - this._insideTagToRemove = false; - } - this._lastTagRemoved = true; - return; - } - - if (tag === 'li') { - this._insideLI = false; - this._addSpacerBeforeElementInLI = false; - } - if (jQuery.inArray(tag, WYMeditor.LIST_TYPE_ELEMENTS) > -1) { - this._insideLI = false; - } - - this.output = this.output + - this._getClosingTagContent('before', tag) + - "" + - this._getClosingTagContent('after', tag); -}; - -WYMeditor.XhtmlSaxListener.prototype.removedExtraBlockClosingTag = function () { - this._extraBlockClosingTags--; - this._addSpacerBeforeElementInLI = true; - this._last_node_was_text = false; -}; - -WYMeditor.XhtmlSaxListener.prototype.closeUnknownTag = function(tag) { - //this.output += ""; -}; - -WYMeditor.XhtmlSaxListener.prototype.closeUnopenedTag = function(tag) { - this._last_node_was_text = false; - if (this._insideTagToRemove) { - return; - } - - if (tag === 'li' && this._extraLIClosingTags) { - this._extraLIClosingTags--; - } else { - this.output += ""; - } -}; - -WYMeditor.XhtmlSaxListener.prototype.avoidStylingTagsAndAttributes = function() { - this.avoided_tags = ['div','span']; - this.validator.skiped_attributes = ['style']; - this.validator.skiped_attribute_values = ['MsoNormal','main1']; // MS Word attributes for class - this._avoiding_tags_implicitly = true; -}; - -WYMeditor.XhtmlSaxListener.prototype.allowStylingTagsAndAttributes = function() { - this.avoided_tags = []; - this.validator.skiped_attributes = []; - this.validator.skiped_attribute_values = []; - this._avoiding_tags_implicitly = false; -}; - -WYMeditor.XhtmlSaxListener.prototype.isBlockTag = function(tag) { - return !WYMeditor.Helper.arrayContains(this.avoided_tags, tag) && - WYMeditor.Helper.arrayContains(this.block_tags, tag); -}; - -WYMeditor.XhtmlSaxListener.prototype.isInlineTag = function(tag) { - return !WYMeditor.Helper.arrayContains(this.avoided_tags, tag) && - WYMeditor.Helper.arrayContains(this.inline_tags, tag); -}; - -WYMeditor.XhtmlSaxListener.prototype.insertContentAfterClosingTag = function(tag, content) { - this._insertContentWhenClosingTag('after', tag, content); -}; - -WYMeditor.XhtmlSaxListener.prototype.insertContentBeforeClosingTag = function(tag, content) { - this._insertContentWhenClosingTag('before', tag, content); -}; - -/* - removeUnwantedClasses - ===================== - - Removes the unwanted classes specified in the - WYMeditor.CLASSES_REMOVED_BY_PARSER constant from the passed attributes - object and returns the attributes object after the removals. The passed - attributes object should be in a format with attribute names as properties - and those attributes' values as those properties' values. The class - matching for removal is case insensitive. -*/ -WYMeditor.XhtmlSaxListener.prototype.removeUnwantedClasses = function(attributes) { - var pattern, - i; - - if (!attributes["class"]) { - return attributes; - } - - for (i = 0; i < WYMeditor.CLASSES_REMOVED_BY_PARSER.length; ++i) { - pattern = new RegExp('(^|\\s)' + WYMeditor.CLASSES_REMOVED_BY_PARSER[i] + - '($|\\s)', 'gi'); - attributes["class"] = attributes["class"].replace(pattern, '$1'); - } - - // Remove possible trailing space that could have been left over if the - // last class was removed - attributes["class"] = attributes["class"].replace(/\s$/, ''); - return attributes; -}; - -WYMeditor.XhtmlSaxListener.prototype.fixNestingBeforeOpeningBlockTag = function(tag, attributes) { - if (!this._last_node_was_text && (tag == 'ul' || tag == 'ol') && this.last_tag && - !this.last_tag_opened && this.last_tag == 'li') { - // We have a
          1. ... situation. The new list should be a - // child of the li tag. Not a sibling. - - if (this._lastTagRemoved) { - // If the previous li tag was removed, the new list should be - // removed with it. - this._insideTagToRemove = true; - this._removedTagStackIndex = this._tag_stack.length - 1; - } else if (!this._shouldRemoveTag(tag, attributes)){ - // If this tag is not going to be removed, remove the last closing - // li tag - this.output = this.output.replace(/<\/li>\s*$/, ''); - this.insertContentAfterClosingTag(tag, ''); - } - } else if ((tag == 'ul' || tag == 'ol') && this.last_tag && - this.last_tag_opened && (this.last_tag == 'ul' || this.last_tag == 'ol')) { - // We have a ... situation. The new list should be have - // a li tag parent and shouldn't be directly nested. - - // If this tag is not going to be removed, add an opening li tag before - // and after this tag - if (!this._shouldRemoveTag(tag, attributes)) { - this.output += this.helper.tag('li', {}, true); - this.insertContentAfterClosingTag(tag, ''); - } - this._last_node_was_text = false; - } else if (tag == 'li') { - // Closest open tag that's not this tag - if (this._tag_stack.length >= 2) { - var closestOpenTag = this._tag_stack[this._tag_stack.length - 2]; - if (closestOpenTag == 'li' && !this._shouldRemoveTag(tag, attributes)){ - // Pop the tag off of the stack to indicate we closed it - this._open_tags.li -= 1; - if (this._open_tags.li === 0) { - this._open_tags.li = undefined; - } - this._tag_stack.splice(this._tag_stack.length - 2, 1); - this._last_node_was_text = false; - - if (!this._insideTagToRemove) { - // If not inside a tag to remove, close the outer LI now - // before adding the LI that was nested within it to the - // output. - this.output += ''; - } else if (this._tag_stack.length - 1 === - this._removedTagStackIndex) { - // If the outer LI was the start of a block to be removed, - // reset the flag for removing a tag. - this._insideTagToRemove = false; - this._lastTagRemoved = true; - this._extraLIClosingTags++; - } - } - } - // Opening a new li tag while another li tag is still open. - // LI tags aren't allowed to be nested within eachother - // It probably means we forgot to close the last LI tag - //return true; - } -}; - -WYMeditor.XhtmlSaxListener.prototype._insertContentWhenClosingTag = function(position, tag, content) { - if (!this['_insert_'+position+'_closing']) { - this['_insert_'+position+'_closing'] = []; - } - if (!this['_insert_'+position+'_closing'][tag]) { - this['_insert_'+position+'_closing'][tag] = []; - } - this['_insert_'+position+'_closing'][tag].push(content); -}; - -WYMeditor.XhtmlSaxListener.prototype._getClosingTagContent = function(position, tag) { - if (this['_insert_'+position+'_closing'] && - this['_insert_'+position+'_closing'][tag] && - this['_insert_'+position+'_closing'][tag].length > 0) { - return this['_insert_'+position+'_closing'][tag].pop(); - } - return ''; -}; - -/* - _shouldRemoveTag - ================ - - Specifies if the passed tag with the passed attributes should be removed - from the output or not, based on the current state. -*/ -WYMeditor.XhtmlSaxListener.prototype._shouldRemoveTag = function(tag, attributes) { - if (this._isEditorOnlyTag(tag, attributes)) { - return true; - } - if (this._isRootInlineTagToRemove(tag, attributes, this._tag_stack)) { - return true; - } - if (this._isThirdConsecutiveBrWithNoAttributes(tag, attributes)) { - return true; - } - - return false; -}; - -/* - _isEditorOnlyTag - ================ - - Is the passed-in tag, as evaluated in the current state, a tag that should - only exist in the editor, but not in the final output. Editor-only tags - exist to aid with manipulation and browser-bug workarounds, but aren't - actual content that should be kept in the authoritative HTML. -*/ -WYMeditor.XhtmlSaxListener.prototype._isEditorOnlyTag = function(tag, attributes) { - var classes; - - if (!attributes["class"]) { - return false; - } - - classes = attributes["class"].split(" "); - if (WYMeditor.Helper.arrayContains(classes, WYMeditor.EDITOR_ONLY_CLASS)) { - return true; - } - return false; -}; - -/* - Is this tag one of the tags that should be removed if found at the root. -*/ -WYMeditor.XhtmlSaxListener.prototype._isRootInlineTagToRemove = function( - tag, attributes, currentTagStack -) { - if (!this.isInlineTag(tag)) { - return false; - } - if (currentTagStack.length > 0) { - // We're not at the root - return false; - } - - if (WYMeditor.Helper.arrayContains(this._rootInlineTagsToRemove, tag)) { - return true; - } - return false; -}; - -/* - Is this tag a third consecutive `br` element that has no attributes. -*/ -WYMeditor.XhtmlSaxListener.prototype - ._isThirdConsecutiveBrWithNoAttributes = function (tag, attributes) { - var key; - if (tag !== 'br') { - this._consecutive_brs = 0; - return false; - } - if ( - this._consecutive_brs !== 0 && - this._last_node_was_text - ) { - this._consecutive_brs = 0; - return false; - } - for (key in attributes) { - if (attributes.hasOwnProperty(key)) { - this._consecutive_brs = 0; - return false; - } - } - this._consecutive_brs ++; - if (this._consecutive_brs > 2) { - return true; - } - return false; -}; - -/** -* XhtmlValidator for validating tag attributes -* -* @author Bermi Ferrer - http://bermi.org -*/ -WYMeditor.XhtmlValidator = { - "_attributes": - { - "core": - { - "except":[ - "base", - "head", - "html", - "meta", - "param", - "script", - "style", - "title" - ], - "attributes":[ - "class", - "id", - "title", - "accesskey", - "tabindex", - "/^data-.*/" - ] - }, - "styleAttr": - { - "except":[ - "img" - ], - "attributes":[ - "style" - ] - }, - "language": - { - "except":[ - "base", - "br", - "hr", - "iframe", - "param", - "script" - ], - "attributes": - { - "dir":[ - "ltr", - "rtl" - ], - "0":"lang", - "1":"xml:lang" - } - }, - "keyboard": - { - "attributes": - { - "accesskey":/^(\w){1}$/, - "tabindex":/^(\d)+$/ - } - } - }, - "_events": - { - "window": - { - "only":[ - "body" - ], - "attributes":[ - "onload", - "onunload" - ] - }, - "form": - { - "only":[ - "form", - "input", - "textarea", - "select", - "a", - "label", - "button" - ], - "attributes":[ - "onchange", - "onsubmit", - "onreset", - "onselect", - "onblur", - "onfocus" - ] - }, - "keyboard": - { - "except":[ - "base", - "bdo", - "br", - "frame", - "frameset", - "head", - "html", - "iframe", - "meta", - "param", - "script", - "style", - "title" - ], - "attributes":[ - "onkeydown", - "onkeypress", - "onkeyup" - ] - }, - "mouse": - { - "except":[ - "base", - "bdo", - "br", - "head", - "html", - "meta", - "param", - "script", - "style", - "title" - ], - "attributes":[ - "onclick", - "ondblclick", - "onmousedown", - "onmousemove", - "onmouseover", - "onmouseout", - "onmouseup" - ] - } - }, - "_tags": - { - "a": - { - "attributes": - { - "0":"charset", - "1":"coords", - "2":"href", - "3":"hreflang", - "4":"name", - "5":"rel", - "6":"rev", - "shape":/^(rect|rectangle|circ|circle|poly|polygon)$/, - "7":"type" - } - }, - "0":"abbr", - "1":"acronym", - "2":"address", - "area": - { - "attributes": - { - "0":"alt", - "1":"coords", - "2":"href", - "nohref":/^(true|false)$/, - "shape":/^(rect|rectangle|circ|circle|poly|polygon)$/ - }, - "required":[ - "alt" - ] - }, - "3":"b", - "base": - { - "attributes":[ - "href" - ], - "required":[ - "href" - ] - }, - "bdo": - { - "attributes": - { - "dir":/^(ltr|rtl)$/ - }, - "required":[ - "dir" - ] - }, - "4":"big", - "blockquote": - { - "attributes":[ - "cite" - ] - }, - "5":"body", - "6":"br", - "button": - { - "attributes": - { - "disabled":/^(disabled)$/, - "type":/^(button|reset|submit)$/, - "0":"value" - }, - "inside":"form" - }, - "7":"caption", - "8":"cite", - "9":"code", - "col": - { - "attributes": - { - "align":/^(right|left|center|justify)$/, - "0":"char", - "1":"charoff", - "span":/^(\d)+$/, - "valign":/^(top|middle|bottom|baseline)$/, - "2":"width" - }, - "inside":"colgroup" - }, - "colgroup": - { - "attributes": - { - "align":/^(right|left|center|justify)$/, - "0":"char", - "1":"charoff", - "span":/^(\d)+$/, - "valign":/^(top|middle|bottom|baseline)$/, - "2":"width" - } - }, - "10":"dd", - "del": - { - "attributes": - { - "0":"cite", - "datetime":/^([0-9]){8}/ - } - }, - "11":"div", - "12":"dfn", - "13":"dl", - "14":"dt", - "15":"em", - "fieldset": - { - "inside":"form" - }, - "form": - { - "attributes": - { - "0":"action", - "1":"accept", - "2":"accept-charset", - "3":"enctype", - "method":/^(get|post)$/ - }, - "required":[ - "action" - ] - }, - "head": - { - "attributes":[ - "profile" - ] - }, - "16":"h1", - "17":"h2", - "18":"h3", - "19":"h4", - "20":"h5", - "21":"h6", - "22":"hr", - "html": - { - "attributes":[ - "xmlns" - ] - }, - "23":"i", - "img": - { - "attributes":[ - "alt", - "src", - "height", - "ismap", - "longdesc", - "usemap", - "width" - ], - "required":[ - "alt", - "src" - ] - }, - "input": - { - "attributes": - { - "0":"accept", - "1":"alt", - "checked":/^(checked)$/, - "disabled":/^(disabled)$/, - "maxlength":/^(\d)+$/, - "2":"name", - "readonly":/^(readonly)$/, - "size":/^(\d)+$/, - "3":"src", - "type":/^(button|checkbox|file|hidden|image|password|radio|reset|submit|text)$/, - "4":"value" - }, - "inside":"form" - }, - "ins": - { - "attributes": - { - "0":"cite", - "datetime":/^([0-9]){8}/ - } - }, - "24":"kbd", - "label": - { - "attributes":[ - "for" - ], - "inside":"form" - }, - "25":"legend", - "26":"li", - "link": - { - "attributes": - { - "0":"charset", - "1":"href", - "2":"hreflang", - "media":/^(all|braille|print|projection|screen|speech|,|;| )+$/i, - //next comment line required by Opera! - /*"rel":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,*/ - "rel":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i, - "rev":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i, - "3":"type" - }, - "inside":"head" - }, - "map": - { - "attributes":[ - "id", - "name" - ], - "required":[ - "id" - ] - }, - "meta": - { - "attributes": - { - "0":"content", - "http-equiv":/^(content\-type|expires|refresh|set\-cookie)$/i, - "1":"name", - "2":"scheme" - }, - "required":[ - "content" - ] - }, - "27":"noscript", - "object": - { - "attributes":[ - "archive", - "classid", - "codebase", - "codetype", - "data", - "declare", - "height", - "name", - "standby", - "type", - "usemap", - "width" - ] - }, - "28":"ol", - "optgroup": - { - "attributes": - { - "0":"label", - "disabled": /^(disabled)$/ - }, - "required":[ - "label" - ] - }, - "option": - { - "attributes": - { - "0":"label", - "disabled":/^(disabled)$/, - "selected":/^(selected)$/, - "1":"value" - }, - "inside":"select" - }, - "29":"p", - "param": - { - "attributes": - { - "0":"type", - "valuetype":/^(data|ref|object)$/, - "1":"valuetype", - "2":"value" - }, - "required":[ - "name" - ] - }, - "30":"pre", - "q": - { - "attributes":[ - "cite" - ] - }, - "31":"samp", - "script": - { - "attributes": - { - "type":/^(text\/ecmascript|text\/javascript|text\/jscript|text\/vbscript|text\/vbs|text\/xml)$/, - "0":"charset", - "defer":/^(defer)$/, - "1":"src" - }, - "required":[ - "type" - ] - }, - "select": - { - "attributes": - { - "disabled":/^(disabled)$/, - "multiple":/^(multiple)$/, - "0":"name", - "1":"size" - }, - "inside":"form" - }, - "32":"small", - "33":"span", - "34":"strong", - "style": - { - "attributes": - { - "0":"type", - "media":/^(screen|tty|tv|projection|handheld|print|braille|aural|all)$/ - }, - "required":[ - "type" - ] - }, - "35":"sub", - "36":"sup", - "table": - { - "attributes": - { - "0":"border", - "1":"cellpadding", - "2":"cellspacing", - "frame":/^(void|above|below|hsides|lhs|rhs|vsides|box|border)$/, - "rules":/^(none|groups|rows|cols|all)$/, - "3":"summary", - "4":"width" - } - }, - "tbody": - { - "attributes": - { - "align":/^(right|left|center|justify)$/, - "0":"char", - "1":"charoff", - "valign":/^(top|middle|bottom|baseline)$/ - } - }, - "td": - { - "attributes": - { - "0":"abbr", - "align":/^(left|right|center|justify|char)$/, - "1":"axis", - "2":"char", - "3":"charoff", - "colspan":/^(\d)+$/, - "4":"headers", - "rowspan":/^(\d)+$/, - "scope":/^(col|colgroup|row|rowgroup)$/, - "valign":/^(top|middle|bottom|baseline)$/ - } - }, - "textarea": - { - "attributes":[ - "cols", - "rows", - "disabled", - "name", - "readonly" - ], - "required":[ - "cols", - "rows" - ], - "inside":"form" - }, - "tfoot": - { - "attributes": - { - "align":/^(right|left|center|justify)$/, - "0":"char", - "1":"charoff", - "valign":/^(top|middle|bottom)$/, - "2":"baseline" - } - }, - "th": - { - "attributes": - { - "0":"abbr", - "align":/^(left|right|center|justify|char)$/, - "1":"axis", - "2":"char", - "3":"charoff", - "colspan":/^(\d)+$/, - "4":"headers", - "rowspan":/^(\d)+$/, - "scope":/^(col|colgroup|row|rowgroup)$/, - "valign":/^(top|middle|bottom|baseline)$/ - } - }, - "thead": - { - "attributes": - { - "align":/^(right|left|center|justify)$/, - "0":"char", - "1":"charoff", - "valign":/^(top|middle|bottom|baseline)$/ - } - }, - "37":"title", - "tr": - { - "attributes": - { - "align":/^(right|left|center|justify|char)$/, - "0":"char", - "1":"charoff", - "valign":/^(top|middle|bottom|baseline)$/ - } - }, - "38":"tt", - "39":"ul", - "40":"var" - }, - - // Temporary skiped attributes - skiped_attributes : [], - skiped_attribute_values : [], - - getValidTagAttributes: function(tag, attributes) - { - var valid_attributes = {}; - var possible_attributes = this.getPossibleTagAttributes(tag); - for(var attribute in attributes) { - var value = attributes[attribute]; - attribute = attribute.toLowerCase(); // ie8 uses colSpan - var h = WYMeditor.Helper; - if(!h.arrayContains(this.skiped_attributes, attribute) && !h.arrayContains(this.skiped_attribute_values, value)){ - if (typeof value != 'function' && h.arrayContains(possible_attributes, attribute)) { - if (this.doesAttributeNeedsValidation(tag, attribute)) { - if(this.validateAttribute(tag, attribute, value)){ - valid_attributes[attribute] = value; - } - }else{ - valid_attributes[attribute] = value; - } - } else { - jQuery.each(possible_attributes, function() { - if(this.match(/\/(.*)\//)) { - regex = new RegExp(this.match(/\/(.*)\//)[1]); - if(regex.test(attribute)) { - valid_attributes[attribute] = value; - } - } - }); - } - } - } - return valid_attributes; - }, - getUniqueAttributesAndEventsForTag : function(tag) - { - var result = []; - - if (this._tags[tag] && this._tags[tag].attributes) { - for (var k in this._tags[tag].attributes) { - result.push(parseInt(k, 10) == k ? this._tags[tag].attributes[k] : k); - } - } - return result; - }, -getDefaultAttributesAndEventsForTags : function() -{ - var result = []; - for (var key in this._events){ - result.push(this._events[key]); - } - for (key in this._attributes){ - result.push(this._attributes[key]); - } - return result; -}, -isValidTag : function(tag) -{ - if(this._tags[tag]){ - return true; - } - for(var key in this._tags){ - if(this._tags[key] == tag){ - return true; - } - } - return false; -}, -getDefaultAttributesAndEventsForTag : function(tag) -{ - var default_attributes = []; - if (this.isValidTag(tag)) { - var default_attributes_and_events = this.getDefaultAttributesAndEventsForTags(); - - for(var key in default_attributes_and_events) { - var defaults = default_attributes_and_events[key]; - if(typeof defaults == 'object'){ - var h = WYMeditor.Helper; - if ((defaults['except'] && h.arrayContains(defaults['except'], tag)) || (defaults['only'] && !h.arrayContains(defaults['only'], tag))) { - continue; - } - - var tag_defaults = defaults['attributes'] ? defaults['attributes'] : defaults['events']; - for(var k in tag_defaults) { - default_attributes.push(typeof tag_defaults[k] != 'string' ? k : tag_defaults[k]); - } -} -} -} -return default_attributes; -}, -doesAttributeNeedsValidation: function(tag, attribute) -{ - return this._tags[tag] && ((this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute]) || (this._tags[tag]['required'] && - WYMeditor.Helper.arrayContains(this._tags[tag]['required'], attribute))); -}, -validateAttribute : function(tag, attribute, value) -{ - if ( this._tags[tag] && - (this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute] && value.length > 0 && !value.match(this._tags[tag]['attributes'][attribute])) || // invalid format - (this._tags[tag] && this._tags[tag]['required'] && WYMeditor.Helper.arrayContains(this._tags[tag]['required'], attribute) && value.length === 0)) // required attribute - { - return false; - } - return typeof this._tags[tag] != 'undefined'; -}, -getPossibleTagAttributes : function(tag) -{ - if (!this._possible_tag_attributes) { - this._possible_tag_attributes = {}; - } - if (!this._possible_tag_attributes[tag]) { - this._possible_tag_attributes[tag] = this.getUniqueAttributesAndEventsForTag(tag).concat(this.getDefaultAttributesAndEventsForTag(tag)); - } - return this._possible_tag_attributes[tag]; -} -}; - - -/********** XHTML LEXER/PARSER **********/ - -/* -* @name xml -* @description Use these methods to generate XML and XHTML compliant tags and -* escape tag attributes correctly -* @author Bermi Ferrer - http://bermi.org -* @author David Heinemeier Hansson http://loudthinking.com -*/ -WYMeditor.XmlHelper = function() -{ - this._entitiesDiv = document.createElement('div'); - return this; -}; - - -/* -* @name tag -* @description -* Returns an empty HTML tag of type *name* which by default is XHTML -* compliant. Setting *open* to true will create an open tag compatible -* with HTML 4.0 and below. Add HTML attributes by passing an attributes -* array to *options*. For attributes with no value like (disabled and -* readonly), give it a value of true in the *options* array. -* -* Examples: -* -* this.tag('br') -* # =>
            -* this.tag ('br', false, true) -* # =>
            -* this.tag ('input', jQuery({type:'text',disabled:true }) ) -* # => -*/ -WYMeditor.XmlHelper.prototype.tag = function(name, options, open) -{ - options = options || false; - open = open || false; - return '<'+name+(options ? this.tagOptions(options) : '')+(open ? '>' : ' />'); -}; - -/* -* @name contentTag -* @description -* Returns a XML block tag of type *name* surrounding the *content*. Add -* XML attributes by passing an attributes array to *options*. For attributes -* with no value like (disabled and readonly), give it a value of true in -* the *options* array. You can use symbols or strings for the attribute names. -* -* this.contentTag ('p', 'Hello world!' ) -* # =>

            Hello world!

            -* this.contentTag('div', this.contentTag('p', "Hello world!"), jQuery({class : "strong"})) -* # =>

            Hello world!

            -* this.contentTag("select", options, jQuery({multiple : true})) -* # => -*/ -WYMeditor.XmlHelper.prototype.contentTag = function(name, content, options) -{ - options = options || false; - return '<'+name+(options ? this.tagOptions(options) : '')+'>'+content+''; -}; - -/* -* @name cdataSection -* @description -* Returns a CDATA section for the given +content+. CDATA sections -* are used to escape blocks of text containing characters which would -* otherwise be recognized as markup. CDATA sections begin with the string -* <![CDATA[ and } with (and may not contain) the string -* ]]>. -*/ -WYMeditor.XmlHelper.prototype.cdataSection = function(content) -{ - return ''; -}; - - -/* -* @name escapeOnce -* @description -* Returns the escaped +xml+ without affecting existing escaped entities. -* -* this.escapeOnce( "1 > 2 & 3") -* # => "1 > 2 & 3" -*/ -WYMeditor.XmlHelper.prototype.escapeOnce = function(xml) -{ - return this._fixDoubleEscape(this.escapeEntities(xml)); -}; - -/* -* @name _fixDoubleEscape -* @description -* Fix double-escaped entities, such as &amp;, &#123;, etc. -*/ -WYMeditor.XmlHelper.prototype._fixDoubleEscape = function(escaped) -{ - return escaped.replace(/&([a-z]+|(#\d+));/ig, "&$1;"); -}; - -/* -* @name tagOptions -* @description -* Takes an array like the one generated by Tag.parseAttributes -* [["src", "http://www.editam.com/?a=b&c=d&f=g"], ["title", "Editam, CMS"]] -* or an object like {src:"http://www.editam.com/?a=b&c=d&f=g", title:"Editam, CMS"} -* and returns a string properly escaped like -* ' src = "http://www.editam.com/?a=b&c=d&f=g" title = "Editam, <Simplified> CMS"' -* which is valid for strict XHTML -*/ -WYMeditor.XmlHelper.prototype.tagOptions = function(options) -{ - var xml = this; - xml._formated_options = ''; - - for (var key in options) { - var formated_options = ''; - var value = options[key]; - if(typeof value != 'function' && value.length > 0) { - - if(parseInt(key, 10) == key && typeof value == 'object'){ - key = value.shift(); - value = value.pop(); - } - if(key !== '' && value !== ''){ - xml._formated_options += ' '+key+'="'+xml.escapeOnce(value)+'"'; - } -} -} -return xml._formated_options; -}; - -/* -* @name escapeEntities -* @description -* Escapes XML/HTML entities <, >, & and ". If seccond parameter is set to false it -* will not escape ". If set to true it will also escape ' -*/ -WYMeditor.XmlHelper.prototype.escapeEntities = function(string, escape_quotes) -{ - this._entitiesDiv.innerHTML = string; - this._entitiesDiv.textContent = string; - var result = this._entitiesDiv.innerHTML; - if(typeof escape_quotes == 'undefined'){ - if(escape_quotes !== false) result = result.replace('"', '"'); - if(escape_quotes === true) result = result.replace('"', '''); - } - return result; -}; - -/* -* Parses a string conatining tag attributes and values an returns an array formated like -* [["src", "http://www.editam.com"], ["title", "Editam, Simplified CMS"]] -*/ -WYMeditor.XmlHelper.prototype.parseAttributes = function(tag_attributes) -{ - // Use a compounded regex to match single quoted, double quoted and unquoted attribute pairs - var result = []; - var matches = tag_attributes.split(/((=\s*")(")("))|((=\s*\')(\')(\'))|((=\s*[^>\s]*))/g); - if(matches.toString() != tag_attributes){ - for (var k in matches) { - var v = matches[k]; - if(typeof v != 'function' && v.length !== 0){ - var re = new RegExp('(\\w+)\\s*'+v); - var match = tag_attributes.match(re); - if(match) { - var value = v.replace(/^[\s=]+/, ""); - var delimiter = value.charAt(0); - delimiter = delimiter == '"' ? '"' : (delimiter=="'"?"'":''); - if(delimiter !== ''){ - value = delimiter == '"' ? value.replace(/^"|"+$/g, '') : value.replace(/^'|'+$/g, ''); - } - tag_attributes = tag_attributes.replace(match[0],''); - result.push([match[1] , value]); - } - } - } - } - return result; -}; - -WYMeditor.STRINGS.bg = { - Strong: 'Получер', - Emphasis: 'Курсив', - Superscript: 'Горен индекс', - Subscript: 'Долен индекс', - Ordered_List: 'Подреден списък', - Unordered_List: 'Неподреден списък', - Indent: 'Блок навътре', - Outdent: 'Блок навън', - Undo: 'Стъпка назад', - Redo: 'Стъпка напред', - Link: 'Създай хипервръзка', - Unlink: 'Премахни хипервръзката', - Image: 'Изображение', - Table: 'Таблица', - HTML: 'HTML', - Paragraph: 'Абзац', - Heading_1: 'Заглавие 1', - Heading_2: 'Заглавие 2', - Heading_3: 'Заглавие 3', - Heading_4: 'Заглавие 4', - Heading_5: 'Заглавие 5', - Heading_6: 'Заглавие 6', - Preformatted: 'Преформатиран', - Blockquote: 'Цитат', - Table_Header: 'Заглавие на таблицата', - URL: 'URL', - Title: 'Заглавие', - Alternative_Text: 'Алтернативен текст', - Caption: 'Етикет', - Summary: 'Общо', - Number_Of_Rows: 'Брой редове', - Number_Of_Cols: 'Брой колони', - Submit: 'Изпрати', - Cancel: 'Отмени', - Choose: 'Затвори', - Preview: 'Предварителен преглед', - Paste_From_Word: 'Вмъкни от MS WORD', - Tools: 'Инструменти', - Containers: 'Контейнери', - Classes: 'Класове', - Status: 'Статус', - Source_Code: 'Източник, код' -}; - - -WYMeditor.STRINGS.ca = { - Strong: 'Ressaltar', - Emphasis: 'Emfatitzar', - Superscript: 'Superindex', - Subscript: 'Subindex', - Ordered_List: 'Llistat ordenat', - Unordered_List: 'Llistat sense ordenar', - Indent: 'Indentat', - Outdent: 'Sense indentar', - Undo: 'Desfer', - Redo: 'Refer', - Link: 'Enllaçar', - Unlink: 'Eliminar enllaç', - Image: 'Imatge', - Table: 'Taula', - HTML: 'HTML', - Paragraph: 'Paràgraf', - Heading_1: 'Capçalera 1', - Heading_2: 'Capçalera 2', - Heading_3: 'Capçalera 3', - Heading_4: 'Capçalera 4', - Heading_5: 'Capçalera 5', - Heading_6: 'Capçalera 6', - Preformatted: 'Pre-formatejat', - Blockquote: 'Cita', - Table_Header: 'Capçalera de la taula', - URL: 'URL', - Title: 'Títol', - Alternative_Text: 'Text alternatiu', - Caption: 'Llegenda', - Summary: 'Summary', - Number_Of_Rows: 'Nombre de files', - Number_Of_Cols: 'Nombre de columnes', - Submit: 'Enviar', - Cancel: 'Cancel·lar', - Choose: 'Triar', - Preview: 'Vista prèvia', - Paste_From_Word: 'Pegar des de Word', - Tools: 'Eines', - Containers: 'Contenidors', - Classes: 'Classes', - Status: 'Estat', - Source_Code: 'Codi font' -}; - - -WYMeditor.STRINGS.cs = { - Strong: 'Tučné', - Emphasis: 'Kurzíva', - Superscript: 'Horní index', - Subscript: 'Dolní index', - Ordered_List: 'Číslovaný seznam', - Unordered_List: 'Nečíslovaný seznam', - Indent: 'Zvětšit odsazení', - Outdent: 'Zmenšit odsazení', - Undo: 'Zpět', - Redo: 'Znovu', - Link: 'Vytvořit odkaz', - Unlink: 'Zrušit odkaz', - Image: 'Obrázek', - Table: 'Tabulka', - HTML: 'HTML', - Paragraph: 'Odstavec', - Heading_1: 'Nadpis 1. úrovně', - Heading_2: 'Nadpis 2. úrovně', - Heading_3: 'Nadpis 3. úrovně', - Heading_4: 'Nadpis 4. úrovně', - Heading_5: 'Nadpis 5. úrovně', - Heading_6: 'Nadpis 6. úrovně', - Preformatted: 'Předformátovaný text', - Blockquote: 'Citace', - Table_Header: 'Hlavičková buňka tabulky', - URL: 'Adresa', - Title: 'Text po najetí myší', - Alternative_Text: 'Text pro případ nezobrazení obrázku', - Caption: 'Titulek tabulky', - Summary: 'Shrnutí obsahu', - Number_Of_Rows: 'Počet řádek', - Number_Of_Cols: 'Počet sloupců', - Submit: 'Vytvořit', - Cancel: 'Zrušit', - Choose: 'Vybrat', - Preview: 'Náhled', - Paste_From_Word: 'Vložit z Wordu', - Tools: 'Nástroje', - Containers: 'Typy obsahu', - Classes: 'Třídy', - Status: 'Stav', - Source_Code: 'Zdrojový kód' -}; - - -WYMeditor.STRINGS.cy = { - Strong: 'Bras', - Emphasis: 'Italig', - Superscript: 'Uwchsgript', - Subscript: 'Is-sgript', - Ordered_List: 'Rhestr mewn Trefn', - Unordered_List: 'Pwyntiau Bwled', - Indent: 'Mewnoli', - Outdent: 'Alloli', - Undo: 'Dadwneud', - Redo: 'Ailwneud', - Link: 'Cysylltu', - Unlink: 'Datgysylltu', - Image: 'Delwedd', - Table: 'Tabl', - HTML: 'HTML', - Paragraph: 'Paragraff', - Heading_1: 'Pennawd 1', - Heading_2: 'Pennawd 2', - Heading_3: 'Pennawd 3', - Heading_4: 'Pennawd 4', - Heading_5: 'Pennawd 5', - Heading_6: 'Pennawd 6', - Preformatted: 'Rhagfformat', - Blockquote: 'Bloc Dyfyniad', - Table_Header: 'Pennyn Tabl', - URL: 'URL', - Title: 'Teitl', - Alternative_Text: 'Testun Amgen', - Caption: 'Pennawd', - Summary: 'Crynodeb', - Number_Of_Rows: 'Nifer y rhesi', - Number_Of_Cols: 'Nifer y colofnau', - Submit: 'Anfon', - Cancel: 'Diddymu', - Choose: 'Dewis', - Preview: 'Rhagolwg', - Paste_From_Word: 'Gludo o Word', - Tools: 'Offer', - Containers: 'Cynhwysyddion', - Classes: 'Dosbarthiadau', - Status: 'Statws', - Source_Code: 'Cod ffynhonnell' -}; - - -WYMeditor.STRINGS['da'] = { - Strong: 'Fed', - Emphasis: 'Skrå', - Superscript: 'Superscript', - Subscript: 'Subscript', - Ordered_List: 'Ordnet liste', - Unordered_List: 'Uordnet liste', - Indent: 'Indrykke', - Outdent: 'Udrykke', - Undo: 'Fortryd', - Redo: 'Fortryd', - Link: 'Link', - Unlink: 'Fjern link', - Image: 'Billede', - Table: 'Tabel', - HTML: 'HTML', - Paragraph: 'Paragraf', - Heading_1: 'Overskrift 1', - Heading_2: 'Overskrift 2', - Heading_3: 'Overskrift 3', - Heading_4: 'Overskrift 4', - Heading_5: 'Overskrift 5', - Heading_6: 'Overskrift 6', - Preformatted: 'Forudformateret', - Blockquote: 'Citat', - Table_Header: 'Tabel Overskrift', - URL: 'URL', - Title: 'Titel', - Alternative_Text: 'Alternativ tekst', - Caption: 'Billedtekst', - Summary: 'Resumé', - Number_Of_Rows: 'Antal rækker', - Number_Of_Cols: 'Antal kolonner', - Submit: 'Indsend', - Cancel: 'Afbryd', - Choose: 'Vælg', - Preview: 'Forhåndsvisning', - Paste_From_Word: 'Indsæt fra Word', - Tools: 'Værktøjer', - Containers: 'Containere', - Classes: 'Klasser', - Status: 'Status', - Source_Code: 'Kildekode' -}; - - -WYMeditor.STRINGS.de = { - Strong: 'Fett', - Emphasis: 'Kursiv', - Superscript: 'Text hochstellen', - Subscript: 'Text tiefstellen', - Ordered_List: 'Geordnete Liste einfügen', - Unordered_List: 'Ungeordnete Liste einfügen', - Indent: 'Einzug erhöhen', - Outdent: 'Einzug vermindern', - Undo: 'Befehle rückgängig machen', - Redo: 'Befehle wiederherstellen', - Link: 'Hyperlink einfügen', - Unlink: 'Hyperlink entfernen', - Image: 'Bild einfügen', - Table: 'Tabelle einfügen', - HTML: 'HTML anzeigen/verstecken', - Paragraph: 'Absatz', - Heading_1: 'Überschrift 1', - Heading_2: 'Überschrift 2', - Heading_3: 'Überschrift 3', - Heading_4: 'Überschrift 4', - Heading_5: 'Überschrift 5', - Heading_6: 'Überschrift 6', - Preformatted: 'Vorformatiert', - Blockquote: 'Zitat', - Table_Header: 'Tabellenüberschrift', - URL: 'URL', - Title: 'Titel', - Alternative_Text: 'Alternativer Text', - Caption: 'Tabellenüberschrift', - Summary: 'Summary', - Number_Of_Rows: 'Anzahl Zeilen', - Number_Of_Cols: 'Anzahl Spalten', - Submit: 'Absenden', - Cancel: 'Abbrechen', - Choose: 'Auswählen', - Preview: 'Vorschau', - Paste_From_Word: 'Aus Word einfügen', - Tools: 'Werkzeuge', - Containers: 'Inhaltstyp', - Classes: 'Klassen', - Status: 'Status', - Source_Code: 'Quellcode' -}; - - -WYMeditor.STRINGS.en = { - Strong: 'Strong', - Emphasis: 'Emphasis', - Superscript: 'Superscript', - Subscript: 'Subscript', - Ordered_List: 'Ordered List', - Unordered_List: 'Unordered List', - Indent: 'Indent', - Outdent: 'Outdent', - Undo: 'Undo', - Redo: 'Redo', - Link: 'Link', - Unlink: 'Unlink', - Image: 'Image', - Table: 'Table', - HTML: 'HTML', - Paragraph: 'Paragraph', - Heading_1: 'Heading 1', - Heading_2: 'Heading 2', - Heading_3: 'Heading 3', - Heading_4: 'Heading 4', - Heading_5: 'Heading 5', - Heading_6: 'Heading 6', - Preformatted: 'Preformatted', - Blockquote: 'Blockquote', - Table_Header: 'Table Header', - URL: 'URL', - Title: 'Title', - Relationship: 'Relationship', - Alternative_Text: 'Alternative text', - Caption: 'Caption', - Summary: 'Summary', - Number_Of_Rows: 'Number of rows', - Number_Of_Cols: 'Number of cols', - Submit: 'Submit', - Cancel: 'Cancel', - Choose: 'Choose', - Preview: 'Preview', - Paste_From_Word: 'Paste from Word', - Tools: 'Tools', - Containers: 'Formatting', - Classes: 'Style', - Status: 'Status', - Source_Code: 'Source code' -}; - -WYMeditor.STRINGS.es = { - Strong: 'Resaltar', - Emphasis: 'Enfatizar', - Superscript: 'Superindice', - Subscript: 'Subindice', - Ordered_List: 'Lista ordenada', - Unordered_List: 'Lista sin ordenar', - Indent: 'Indentado', - Outdent: 'Sin indentar', - Undo: 'Deshacer', - Redo: 'Rehacer', - Link: 'Enlazar', - Unlink: 'Eliminar enlace', - Image: 'Imagen', - Table: 'Tabla', - HTML: 'HTML', - Paragraph: 'Párrafo', - Heading_1: 'Cabecera 1', - Heading_2: 'Cabecera 2', - Heading_3: 'Cabecera 3', - Heading_4: 'Cabecera 4', - Heading_5: 'Cabecera 5', - Heading_6: 'Cabecera 6', - Preformatted: 'Preformateado', - Blockquote: 'Cita', - Table_Header: 'Cabecera de la tabla', - URL: 'URL', - Title: 'Título', - Alternative_Text: 'Texto alternativo', - Caption: 'Leyenda', - Summary: 'Summary', - Number_Of_Rows: 'Número de filas', - Number_Of_Cols: 'Número de columnas', - Submit: 'Enviar', - Cancel: 'Cancelar', - Choose: 'Seleccionar', - Preview: 'Vista previa', - Paste_From_Word: 'Pegar desde Word', - Tools: 'Herramientas', - Containers: 'Contenedores', - Classes: 'Clases', - Status: 'Estado', - Source_Code: 'Código fuente' -}; - - -//Translation To Persian: Ghassem Tofighi (http://ght.ir) -WYMeditor.STRINGS.fa = { - Strong: 'پررنگ',//Strong - Emphasis: 'ایتالیک',//Emphasis - Superscript: 'بالانويس‌ ',//Superscript - Subscript: 'زيرنويس‌',//Subscript - Ordered_List: 'لیست مرتب',//Ordered List - Unordered_List: 'لیست نامرتب',//Unordered List - Indent: 'افزودن دندانه',//Indent - Outdent: 'کاهش دندانه',//Outdent - Undo: 'واگردانی',//Undo - Redo: 'تکرار',//Redo - Link: 'ساختن پیوند',//Link - Unlink: 'برداشتن پیوند',//Unlink - Image: 'تصویر',//Image - Table: 'جدول',//Table - HTML: 'HTML',//HTML - Paragraph: 'پاراگراف',//Paragraph - Heading_1: 'سرتیتر ۱',//Heading 1 - Heading_2: 'سرتیتر ۲',//Heading 2 - Heading_3: 'سرتیتر ۳',//Heading 3 - Heading_4: 'سرتیتر ۴',//Heading 4 - Heading_5: 'سرتیتر ۵',//Heading 5 - Heading_6: 'سرتیتر ۶',//Heading 6 - Preformatted: 'قالب آماده',//Preformatted - Blockquote: 'نقل قول',//Blockquote - Table_Header: 'سرجدول',//Table Header - URL: 'آدرس اینترنتی',//URL - Title: 'عنوان',//Title - Alternative_Text: 'متن جایگزین',//Alternative text - Caption: 'عنوان',//Caption - Summary: 'Summary', - Number_Of_Rows: 'تعداد سطرها',//Number of rows - Number_Of_Cols: 'تعداد ستون‌ها',//Number of cols - Submit: 'فرستادن',//Submit - Cancel: 'لغو',//Cancel - Choose: 'انتخاب',//Choose - Preview: 'پیش‌نمایش',//Preview - Paste_From_Word: 'انتقال از ورد',//Paste from Word - Tools: 'ابزار',//Tools - Containers: '‌قالب‌ها',//Containers - Classes: 'کلاس‌ها',//Classes - Status: 'وضعیت',//Status - Source_Code: 'کد مبدأ'//Source code -}; - - -WYMeditor.STRINGS.fi = { - Strong: 'Lihavoitu', - Emphasis: 'Korostus', - Superscript: 'Yläindeksi', - Subscript: 'Alaindeksi', - Ordered_List: 'Numeroitu lista', - Unordered_List: 'Luettelomerkit', - Indent: 'Suurenna sisennystä', - Outdent: 'Pienennä sisennystä', - Undo: 'Kumoa', - Redo: 'Toista', - Link: 'Linkitä', - Unlink: 'Poista linkitys', - Image: 'Kuva', - Table: 'Taulukko', - HTML: 'HTML', - Paragraph: 'Kappale', - Heading_1: 'Otsikko 1', - Heading_2: 'Otsikko 2', - Heading_3: 'Otsikko 3', - Heading_4: 'Otsikko 4', - Heading_5: 'Otsikko 5', - Heading_6: 'Otsikko 6', - Preformatted: 'Esimuotoilu', - Blockquote: 'Sitaatti', - Table_Header: 'Taulukon otsikko', - URL: 'URL', - Title: 'Otsikko', - Alternative_Text: 'Vaihtoehtoinen teksti', - Caption: 'Kuvateksti', - Summary: 'Yhteenveto', - Number_Of_Rows: 'Rivien määrä', - Number_Of_Cols: 'Palstojen määrä', - Submit: 'Lähetä', - Cancel: 'Peruuta', - Choose: 'Valitse', - Preview: 'Esikatsele', - Paste_From_Word: 'Tuo Wordista', - Tools: 'Työkalut', - Containers: 'Muotoilut', - Classes: 'Luokat', - Status: 'Tila', - Source_Code: 'Lähdekoodi' -}; - -WYMeditor.STRINGS.fr = { - Strong: 'Mise en évidence', - Emphasis: 'Emphase', - Superscript: 'Exposant', - Subscript: 'Indice', - Ordered_List: 'Liste Ordonnée', - Unordered_List: 'Liste Non-Ordonnée', - Indent: 'Imbriqué', - Outdent: 'Non-imbriqué', - Undo: 'Annuler', - Redo: 'Rétablir', - Link: 'Lien', - Unlink: 'Supprimer le Lien', - Image: 'Image', - Table: 'Tableau', - HTML: 'HTML', - Paragraph: 'Paragraphe', - Heading_1: 'Titre 1', - Heading_2: 'Titre 2', - Heading_3: 'Titre 3', - Heading_4: 'Titre 4', - Heading_5: 'Titre 5', - Heading_6: 'Titre 6', - Preformatted: 'Pré-formatté', - Blockquote: 'Citation', - Table_Header: 'Cellule de titre', - URL: 'URL', - Title: 'Titre', - Alternative_Text: 'Texte alternatif', - Caption: 'Légende', - Summary: 'Résumé', - Number_Of_Rows: 'Nombre de lignes', - Number_Of_Cols: 'Nombre de colonnes', - Submit: 'Envoyer', - Cancel: 'Annuler', - Choose: 'Choisir', - Preview: 'Prévisualisation', - Paste_From_Word: 'Copier depuis Word', - Tools: 'Outils', - Containers: 'Type de texte', - Classes: 'Type de contenu', - Status: 'Infos', - Source_Code: 'Code source' -}; - - -WYMeditor.STRINGS.gl = { - Strong: 'Moita énfase', - Emphasis: 'Énfase', - Superscript: 'Superíndice', - Subscript: 'Subíndice', - Ordered_List: 'Lista ordenada', - Unordered_List: 'Lista sen ordenar', - Indent: 'Aniñar', - Outdent: 'Desaniñar', - Undo: 'Desfacer', - Redo: 'Refacer', - Link: 'Ligazón', - Unlink: 'Desligar', - Image: 'Imaxe', - Table: 'Táboa', - HTML: 'HTML', - Paragraph: 'Parágrafo', - Heading_1: 'Título 1', - Heading_2: 'Título 2', - Heading_3: 'Título 3', - Heading_4: 'Título 4', - Heading_5: 'Título 5', - Heading_6: 'Título 6', - Preformatted: 'Preformatado', - Blockquote: 'Cita en parágrafo', - Table_Header: 'Cabeceira da táboa', - URL: 'URL', - Title: 'Título', - Alternative_Text: 'Texto alternativo', - Caption: 'Título', - Summary: 'Resumo', - Number_Of_Rows: 'Número de filas', - Number_Of_Cols: 'Número de columnas', - Submit: 'Enviar', - Cancel: 'Cancelar', - Choose: 'Escoller', - Preview: 'Previsualizar', - Paste_From_Word: 'Colar dende Word', - Tools: 'Ferramentas', - Containers: 'Contenedores', - Classes: 'Clases', - Status: 'Estado', - Source_Code: 'Código fonte' -}; - - -WYMeditor.STRINGS.he = { - Strong: 'חזק', - Emphasis: 'מובלט', - Superscript: 'כתב עילי', - Subscript: 'כתב תחתי', - Ordered_List: 'רשימה ממוספרת', - Unordered_List: 'רשימה לא ממוספרת', - Indent: 'הזחה פנימה', - Outdent: 'הזחה החוצה', - Undo: 'בטל פעולה', - Redo: 'בצע מחדש פעולה', - Link: 'קישור', - Unlink: 'בטל קישור', - Image: 'תמונה', - Table: 'טבלה', - HTML: 'קוד HTML', - Paragraph: 'פסקה', - Heading_1: 'כותרת 1 ; תג <h1>', - Heading_2: 'כותרת 2 ; תג <h2>', - Heading_3: 'כותרת 3 ; תג <h3>', - Heading_4: 'כותרת 4 ; תג <h4>', - Heading_5: 'כותרת 5 ; תג <h5>', - Heading_6: 'כותרת 6 ; תג <h6>', - Preformatted: 'משמר רווחים', - Blockquote: 'ציטוט', - Table_Header: 'כותרת טבלה', - URL: 'קישור (URL)', - Title: 'כותרת', - Alternative_Text: 'טקסט חלופי', - Caption: 'כותרת', - Summary: 'סיכום', - Number_Of_Rows: 'מספר שורות', - Number_Of_Cols: 'מספר טורים', - Submit: 'שלח', - Cancel: 'בטל', - Choose: 'בחר', - Preview: 'תצוגה מקדימה', - Paste_From_Word: 'העתק מ-Word', - Tools: 'כלים', - Containers: 'מיכלים', - Classes: 'מחלקות', - Status: 'מצב', - Source_Code: 'קוד מקור' -}; - - -WYMeditor.STRINGS.hr = { - Strong: 'Podebljano', - Emphasis: 'Naglašeno', - Superscript: 'Iznad', - Subscript: 'Ispod', - Ordered_List: 'Pobrojana lista', - Unordered_List: 'Nepobrojana lista', - Indent: 'Uvuci', - Outdent: 'Izvuci', - Undo: 'Poništi promjenu', - Redo: 'Ponovno promjeni', - Link: 'Hiperveza', - Unlink: 'Ukloni hipervezu', - Image: 'Slika', - Table: 'Tablica', - HTML: 'HTML', - Paragraph: 'Paragraf', - Heading_1: 'Naslov 1', - Heading_2: 'Naslov 2', - Heading_3: 'Naslov 3', - Heading_4: 'Naslov 4', - Heading_5: 'Naslov 5', - Heading_6: 'Naslov 6', - Preformatted: 'Unaprijed formatirano', - Blockquote: 'Citat', - Table_Header: 'Zaglavlje tablice', - URL: 'URL', - Title: 'Naslov', - Alternative_Text: 'Alternativni tekst', - Caption: 'Zaglavlje', - Summary: 'Sažetak', - Number_Of_Rows: 'Broj redova', - Number_Of_Cols: 'Broj kolona', - Submit: 'Snimi', - Cancel: 'Odustani', - Choose: 'Izaberi', - Preview: 'Pregled', - Paste_From_Word: 'Zalijepi iz Word-a', - Tools: 'Alati', - Containers: 'Kontejneri', - Classes: 'Klase', - Status: 'Status', - Source_Code: 'Izvorni kod' -}; - - -WYMeditor.STRINGS.hu = { - Strong: 'Félkövér', - Emphasis: 'Kiemelt', - Superscript: 'Felső index', - Subscript: 'Alsó index', - Ordered_List: 'Rendezett lista', - Unordered_List: 'Rendezetlen lista', - Indent: 'Bekezdés', - Outdent: 'Bekezdés törlése', - Undo: 'Visszavon', - Redo: 'Visszaállít', - Link: 'Link', - Unlink: 'Link törlése', - Image: 'Kép', - Table: 'Tábla', - HTML: 'HTML', - Paragraph: 'Bekezdés', - Heading_1: 'Címsor 1', - Heading_2: 'Címsor 2', - Heading_3: 'Címsor 3', - Heading_4: 'Címsor 4', - Heading_5: 'Címsor 5', - Heading_6: 'Címsor 6', - Preformatted: 'Előformázott', - Blockquote: 'Idézet', - Table_Header: 'Tábla Fejléc', - URL: 'Webcím', - Title: 'Megnevezés', - Alternative_Text: 'Alternatív szöveg', - Caption: 'Fejléc', - Summary: 'Summary', - Number_Of_Rows: 'Sorok száma', - Number_Of_Cols: 'Oszlopok száma', - Submit: 'Elküld', - Cancel: 'Mégsem', - Choose: 'Választ', - Preview: 'Előnézet', - Paste_From_Word: 'Másolás Word-ból', - Tools: 'Eszközök', - Containers: 'Tartalmak', - Classes: 'Osztályok', - Status: 'Állapot', - Source_Code: 'Forráskód' -}; - - -WYMeditor.STRINGS.it = { - Strong: 'Grassetto', - Emphasis: 'Corsetto', - Superscript: 'Apice', - Subscript: 'Pedice', - Ordered_List: 'Lista Ordinata', - Unordered_List: 'Lista Puntata', - Indent: 'Indenta', - Outdent: 'Caccia', - Undo: 'Indietro', - Redo: 'Avanti', - Link: 'Inserisci Link', - Unlink: 'Togli Link', - Image: 'Inserisci Immagine', - Table: 'Inserisci Tabella', - HTML: 'HTML', - Paragraph: 'Paragrafo', - Heading_1: 'Heading 1', - Heading_2: 'Heading 2', - Heading_3: 'Heading 3', - Heading_4: 'Heading 4', - Heading_5: 'Heading 5', - Heading_6: 'Heading 6', - Preformatted: 'Preformattato', - Blockquote: 'Blockquote', - Table_Header: 'Header Tabella', - URL: 'Indirizzo', - Title: 'Titolo', - Alternative_Text: 'Testo Alternativo', - Caption: 'Caption', - Summary: 'Summary', - Number_Of_Rows: 'Numero di Righe', - Number_Of_Cols: 'Numero di Colonne', - Submit: 'Invia', - Cancel: 'Cancella', - Choose: 'Scegli', - Preview: 'Anteprima', - Paste_From_Word: 'Incolla', - Tools: 'Tools', - Containers: 'Contenitori', - Classes: 'Classi', - Status: 'Stato', - Source_Code: 'Codice Sorgente' -}; - - -WYMeditor.STRINGS.ja = { - Strong: '強調', - Emphasis: '強調', - Superscript: '上付き', - Subscript: '下付き', - Ordered_List: '番号付きリスト', - Unordered_List: '番号無リスト', - Indent: 'インデントを増やす', - Outdent: 'インデントを減らす', - Undo: '元に戻す', - Redo: 'やり直す', - Link: 'リンク', - Unlink: 'リンク取消', - Image: '画像', - Table: 'テーブル', - HTML: 'HTML', - Paragraph: '段落', - Heading_1: '見出し 1', - Heading_2: '見出し 2', - Heading_3: '見出し 3', - Heading_4: '見出し 4', - Heading_5: '見出し 5', - Heading_6: '見出し 6', - Preformatted: '整形済みテキスト', - Blockquote: '引用文', - Table_Header: '表見出し', - URL: 'URL', - Title: 'タイトル', - Alternative_Text: '代替テキスト', - Caption: 'キャプション', - Summary: 'サマリー', - Number_Of_Rows: '行数', - Number_Of_Cols: '列数', - Submit: '送信', - Cancel: 'キャンセル', - Choose: '選択', - Preview: 'プレビュー', - Paste_From_Word: '貼り付け', - Tools: 'ツール', - Containers: 'コンテナ', - Classes: 'クラス', - Status: 'ステータス', - Source_Code: 'ソースコード' -}; - -WYMeditor.STRINGS.lt = { - Strong: 'Pusjuodis', - Emphasis: 'Kursyvas', - Superscript: 'Viršutinis indeksas', - Subscript: 'Apatinis indeksas', - Ordered_List: 'Numeruotas sąrašas', - Unordered_List: 'Suženklintas sąrašas', - Indent: 'Padidinti įtrauką', - Outdent: 'Sumažinti įtrauką', - Undo: 'Atšaukti', - Redo: 'Atstatyti', - Link: 'Nuoroda', - Unlink: 'Panaikinti nuorodą', - Image: 'Vaizdas', - Table: 'Lentelė', - HTML: 'HTML', - Paragraph: 'Paragrafas', - Heading_1: 'Antraštinis 1', - Heading_2: 'Antraštinis 2', - Heading_3: 'Antraštinis 3', - Heading_4: 'Antraštinis 4', - Heading_5: 'Antraštinis 5', - Heading_6: 'Antraštinis 6', - Preformatted: 'Formuotas', - Blockquote: 'Citata', - Table_Header: 'Lentelės antraštė', - URL: 'URL', - Title: 'Antraštinis tekstas', - Relationship: 'Sąryšis', - Alternative_Text: 'Alternatyvus tekstas', - Caption: 'Antraštė', - Summary: 'Santrauka', - Number_Of_Rows: 'Eilučių skaičius', - Number_Of_Cols: 'Stulpelių skaičius', - Submit: 'Išsaugoti', - Cancel: 'Nutraukti', - Choose: 'Rinktis', - Preview: 'Peržiūra', - Paste_From_Word: 'Įkelti iš MS Word', - Tools: 'Įrankiai', - Containers: 'Stiliai', - Classes: 'Klasės', - Status: 'Statusas', - Source_Code: 'Išeities tekstas' -}; -WYMeditor.STRINGS.nb = { - Strong: 'Fet', - Emphasis: 'Uthevet', - Superscript: 'Opphøyet', - Subscript: 'Nedsenket', - Ordered_List: 'Nummerert liste', - Unordered_List: 'Punktliste', - Indent: 'Rykk inn', - Outdent: 'Rykk ut', - Undo: 'Angre', - Redo: 'Gjenta', - Link: 'Lenke', - Unlink: 'Ta bort lenken', - Image: 'Bilde', - Table: 'Tabell', - HTML: 'HTML', - Paragraph: 'Avsnitt', - Heading_1: 'Overskrift 1', - Heading_2: 'Overskrift 2', - Heading_3: 'Overskrift 3', - Heading_4: 'Overskrift 4', - Heading_5: 'Overskrift 5', - Heading_6: 'Overskrift 6', - Preformatted: 'Preformatert', - Blockquote: 'Sitat', - Table_Header: 'Tabelloverskrift', - URL: 'URL', - Title: 'Tittel', - Alternative_Text: 'Alternativ tekst', - Caption: 'Overskrift', - Summary: 'Sammendrag', - Number_Of_Rows: 'Antall rader', - Number_Of_Cols: 'Antall kolonner', - Submit: 'Ok', - Cancel: 'Avbryt', - Choose: 'Velg', - Preview: 'Forhåndsvis', - Paste_From_Word: 'Lim inn fra Word', - Tools: 'Verktøy', - Containers: 'Formatering', - Classes: 'Klasser', - Status: 'Status', - Source_Code: 'Kildekode' -}; - - -WYMeditor.STRINGS.nl = { - Strong: 'Sterk benadrukken', - Emphasis: 'Benadrukken', - Superscript: 'Bovenschrift', - Subscript: 'Onderschrift', - Ordered_List: 'Geordende lijst', - Unordered_List: 'Ongeordende lijst', - Indent: 'Inspringen', - Outdent: 'Terugspringen', - Undo: 'Ongedaan maken', - Redo: 'Opnieuw uitvoeren', - Link: 'Linken', - Unlink: 'Ontlinken', - Image: 'Afbeelding', - Table: 'Tabel', - HTML: 'HTML', - Paragraph: 'Paragraaf', - Heading_1: 'Kop 1', - Heading_2: 'Kop 2', - Heading_3: 'Kop 3', - Heading_4: 'Kop 4', - Heading_5: 'Kop 5', - Heading_6: 'Kop 6', - Preformatted: 'Voorgeformatteerd', - Blockquote: 'Citaat', - Table_Header: 'Tabel-kop', - URL: 'URL', - Title: 'Titel', - Relationship: 'Relatie', - Alternative_Text: 'Alternatieve tekst', - Caption: 'Bijschrift', - Summary: 'Summary', - Number_Of_Rows: 'Aantal rijen', - Number_Of_Cols: 'Aantal kolommen', - Submit: 'Versturen', - Cancel: 'Annuleren', - Choose: 'Kiezen', - Preview: 'Voorbeeld bekijken', - Paste_From_Word: 'Plakken uit Word', - Tools: 'Hulpmiddelen', - Containers: 'Teksttypes', - Classes: 'Klassen', - Status: 'Status', - Source_Code: 'Broncode' -}; -WYMeditor.STRINGS.nn = { - Strong: 'Feit', - Emphasis: 'Utheva', - Superscript: 'Opphøgd', - Subscript: 'Nedsenka', - Ordered_List: 'Nummerert liste', - Unordered_List: 'Punktliste', - Indent: 'Rykk inn', - Outdent: 'Rykk ut', - Undo: 'Angre', - Redo: 'Gjentaka', - Link: 'Lenkje', - Unlink: 'Ta bort lenkja', - Image: 'Bilete', - Table: 'Tabell', - HTML: 'HTML', - Paragraph: 'Avsnitt', - Heading_1: 'Overskrift 1', - Heading_2: 'Overskrift 2', - Heading_3: 'Overskrift 3', - Heading_4: 'Overskrift 4', - Heading_5: 'Overskrift 5', - Heading_6: 'Overskrift 6', - Preformatted: 'Preformatert', - Blockquote: 'Sitat', - Table_Header: 'Tabelloverskrift', - URL: 'URL', - Title: 'Tittel', - Alternative_Text: 'Alternativ tekst', - Caption: 'Overskrift', - Summary: 'Samandrag', - Number_Of_Rows: 'Tal på rader', - Number_Of_Cols: 'Tal på kolonnar', - Submit: 'Ok', - Cancel: 'Avbryt', - Choose: 'Vel', - Preview: 'Førehandsvis', - Paste_From_Word: 'Lim inn frå Word', - Tools: 'Verkty', - Containers: 'Formatering', - Classes: 'Klassar', - Status: 'Status', - Source_Code: 'Kjeldekode' -}; - - -WYMeditor.STRINGS.pl = { - Strong: 'Nacisk', - Emphasis: 'Emfaza', - Superscript: 'Indeks górny', - Subscript: 'Indeks dolny', - Ordered_List: 'Lista numerowana', - Unordered_List: 'Lista wypunktowana', - Indent: 'Zwiększ wcięcie', - Outdent: 'Zmniejsz wcięcie', - Undo: 'Cofnij', - Redo: 'Ponów', - Link: 'Wstaw link', - Unlink: 'Usuń link', - Image: 'Obraz', - Table: 'Tabela', - HTML: 'Źródło HTML', - Paragraph: 'Akapit', - Heading_1: 'Nagłówek 1', - Heading_2: 'Nagłówek 2', - Heading_3: 'Nagłówek 3', - Heading_4: 'Nagłówek 4', - Heading_5: 'Nagłówek 5', - Heading_6: 'Nagłówek 6', - Preformatted: 'Preformatowany', - Blockquote: 'Cytat blokowy', - Table_Header: 'Nagłówek tabeli', - URL: 'URL', - Title: 'Tytuł', - Alternative_Text: 'Tekst alternatywny', - Caption: 'Tytuł tabeli', - Summary: 'Summary', - Number_Of_Rows: 'Liczba wierszy', - Number_Of_Cols: 'Liczba kolumn', - Submit: 'Wyślij', - Cancel: 'Anuluj', - Choose: 'Wybierz', - Preview: 'Podgląd', - Paste_From_Word: 'Wklej z Worda', - Tools: 'Narzędzia', - Containers: 'Format', - Classes: 'Styl', - Status: 'Status', - Source_Code: 'Kod źródłowy' -}; - - -WYMeditor.STRINGS['pt-br'] = { - Strong: 'Resaltar', - Emphasis: 'Enfatizar', - Superscript: 'Sobre escrito', - Subscript: 'Sub escrito ', - Ordered_List: 'Lista ordenada', - Unordered_List: 'Lista desordenada', - Indent: 'Indentado', - Outdent: 'Desidentar', - Undo: 'Desfazer', - Redo: 'Refazer', - Link: 'Link', - Unlink: 'Remover Link', - Image: 'Imagem', - Table: 'Tabela', - HTML: 'HTML', - Paragraph: 'Parágrafo', - Heading_1: 'Título 1', - Heading_2: 'Título 2', - Heading_3: 'Título 3', - Heading_4: 'Título 4', - Heading_5: 'Título 5', - Heading_6: 'Título 6', - Preformatted: 'Preformatado', - Blockquote: 'Citação', - Table_Header: 'Título de tabela', - URL: 'URL', - Title: 'Título', - Alternative_Text: 'Texto alternativo', - Caption: 'Legenda', - Summary: 'Summary', - Number_Of_Rows: 'Número de linhas', - Number_Of_Cols: 'Número de colunas', - Submit: 'Enviar', - Cancel: 'Cancelar', - Choose: 'Selecionar', - Preview: 'Previsualizar', - Paste_From_Word: 'Copiar do Word', - Tools: 'Ferramentas', - Containers: 'Conteneiners', - Classes: 'Classes', - Status: 'Estado', - Source_Code: 'Código fonte' -}; - - -WYMeditor.STRINGS.pt = { - Strong: 'Negrito', - Emphasis: 'Itálico', - Superscript: 'Sobrescrito', - Subscript: 'Subsescrito', - Ordered_List: 'Lista Numerada', - Unordered_List: 'Lista Marcada', - Indent: 'Aumentar Indentaçã', - Outdent: 'Diminuir Indentaçã', - Undo: 'Desfazer', - Redo: 'Restaurar', - Link: 'Link', - Unlink: 'Tirar link', - Image: 'Imagem', - Table: 'Tabela', - HTML: 'HTML', - Paragraph: 'Parágrafo', - Heading_1: 'Título 1', - Heading_2: 'Título 2', - Heading_3: 'Título 3', - Heading_4: 'Título 4', - Heading_5: 'Título 5', - Heading_6: 'Título 6', - Preformatted: 'Pré-formatado', - Blockquote: 'Citação', - Table_Header: 'Cabeçalho Tabela', - URL: 'URL', - Title: 'Título', - Alternative_Text: 'Texto Alterativo', - Caption: 'Título Tabela', - Summary: 'Summary', - Number_Of_Rows: 'Número de Linhas', - Number_Of_Cols: 'Número de Colunas', - Submit: 'Enviar', - Cancel: 'Cancelar', - Choose: 'Escolha', - Preview: 'Prever', - Paste_From_Word: 'Colar do Word', - Tools: 'Ferramentas', - Containers: 'Containers', - Classes: 'Classes', - Status: 'Status', - Source_Code: 'Código Fonte' -}; - - -WYMeditor.STRINGS.ru = { - Strong: 'Жирный', - Emphasis: 'Наклонный', - Superscript: 'Надстрочный', - Subscript: 'Подстрочный', - Ordered_List: 'Нумерованый список', - Unordered_List: 'Ненумерованый список', - Indent: 'Увеличить отступ', - Outdent: 'Уменьшить отступ', - Undo: 'Отменить', - Redo: 'Повторить', - Link: 'Ссылка', - Unlink: 'Удалить ссылку', - Image: 'Изображение', - Table: 'Таблица', - HTML: 'Править HTML', - Paragraph: 'Параграф', - Heading_1: 'Заголовок 1', - Heading_2: 'Заголовок 2', - Heading_3: 'Заголовок 3', - Heading_4: 'Заголовок 4', - Heading_5: 'Заголовок 5', - Heading_6: 'Заголовок 6', - Preformatted: 'Preformatted', - Blockquote: 'Цитата', - Table_Header: 'Заголовок таблицы', - URL: 'URL', - Title: 'Заголовок', - Alternative_Text: 'Альтернативный текст', - Caption: 'Надпись', - Summary: 'Summary', - Number_Of_Rows: 'Кол-во строк', - Number_Of_Cols: 'Кол-во столбцов', - Submit: 'Отправить', - Cancel: 'Отмена', - Choose: 'Выбор', - Preview: 'Просмотр', - Paste_From_Word: 'Вставить из Word', - Tools: 'Инструменты', - Containers: 'Контейнеры', - Classes: 'Классы', - Status: 'Статус', - Source_Code: 'Исходный код' -}; - - -WYMeditor.STRINGS.sk = { - Strong: 'Tučné', - Emphasis: 'Kurzíva', - Superscript: 'Horný index', - Subscript: 'Dolný index', - Ordered_List: 'Číslovaný zoznam', - Unordered_List: 'Nečíslovaný zoznam', - Indent: 'Zväčšiť odsadenie', - Outdent: 'Zmenšiť odsadenie', - Undo: 'Vrátiť', - Redo: 'Opakovať', - Link: 'Vytvoriť odkaz', - Unlink: 'Zrušiť odkaz', - Image: 'Obrázok', - Table: 'Tabuľka', - HTML: 'HTML', - Paragraph: 'Odstavec', - Heading_1: 'Nadpis 1. úrovne', - Heading_2: 'Nadpis 2. úrovne', - Heading_3: 'Nadpis 3. úrovne', - Heading_4: 'Nadpis 4. úrovne', - Heading_5: 'Nadpis 5. úrovne', - Heading_6: 'Nadpis 6. úrovne', - Preformatted: 'Predformátovaný text', - Blockquote: 'Citácia', - Table_Header: 'Hlavička tabuľky', - URL: 'URL adresa', - Title: 'Titulok', - Alternative_Text: 'Alternatívny text', - Caption: 'Titulok tabuľky', - Summary: 'Zhrnutie obsahu', - Number_Of_Rows: 'Počet riadkov', - Number_Of_Cols: 'Počet stĺpcov', - Submit: 'Odoslať', - Cancel: 'Zrušiť', - Choose: 'Vybrať', - Preview: 'Náhľad', - Paste_From_Word: 'Vložiť z Wordu', - Tools: 'Nástroje', - Containers: 'Typy obsahu', - Classes: 'Triedy', - Status: 'Stav', - Source_Code: 'Zdrojový kód' -}; - - -WYMeditor.STRINGS.sv = { - Strong: 'Viktigt', - Emphasis: 'Betoning', - Superscript: 'Upphöjt', - Subscript: 'Nedsänkt', - Ordered_List: 'Nummerlista', - Unordered_List: 'Punktlista', - Indent: 'Indrag', - Outdent: 'Utdrag', - Undo: 'Ångra', - Redo: 'Gör om', - Link: 'Länk', - Unlink: 'Ta bort länk', - Image: 'Bild', - Table: 'Tabell', - HTML: 'HTML', - Paragraph: 'Paragraf', - Heading_1: 'Rubrik 1', - Heading_2: 'Rubrik 2', - Heading_3: 'Rubrik 3', - Heading_4: 'Rubrik 4', - Heading_5: 'Rubrik 5', - Heading_6: 'Rubrik 6', - Preformatted: 'Förformaterad', - Blockquote: 'Blockcitat', - Table_Header: 'Tabellrubrik', - URL: 'URL', - Title: 'Titel', - Relationship: 'Relation', - Alternative_Text: 'Alternativ text', - Caption: 'Överskrift', - Summary: 'Summary', - Number_Of_Rows: 'Antal rader', - Number_Of_Cols: 'Antal kolumner', - Submit: 'Skicka', - Cancel: 'Avbryt', - Choose: 'Välj', - Preview: 'Förhandsgranska', - Paste_From_Word: 'Klistra in från Word', - Tools: 'Verktyg', - Containers: 'Formatering', - Classes: 'Klasser', - Status: 'Status', - Source_Code: 'Källkod' -}; - - -WYMeditor.STRINGS.tr = { - Strong: 'Kalın', - Emphasis: 'Vurgu', - Superscript: 'Üstsimge', - Subscript: 'Altsimge', - Ordered_List: 'Sıralı List', - Unordered_List: 'Sırasız List', - Indent: 'Girintile', - Outdent: 'Çıkıntıla', - Undo: 'Geri Al', - Redo: 'Yinele', - Link: 'Bağlantı', - Unlink: 'Bağlantıyı Kaldır', - Image: 'Resim', - Table: 'Tablo', - HTML: 'HTML', - Paragraph: 'Parağraf', - Heading_1: 'Başlık 1', - Heading_2: 'Başlık 2', - Heading_3: 'Başlık 3', - Heading_4: 'Başlık 4', - Heading_5: 'Başlık 5', - Heading_6: 'Başlık 6', - Preformatted: 'Önceden Formatlı', - Blockquote: 'Alıntı', - Table_Header: 'Tablo Başlığı', - URL: 'URL', - Title: 'Başlık', - Alternative_Text: 'Alternatif Metin', - Caption: 'Etiket', - Summary: 'Özet', - Number_Of_Rows: 'Satır sayısı', - Number_Of_Cols: 'Sütun sayısı', - Submit: 'Gönder', - Cancel: 'İptal', - Choose: 'Seç', - Preview: 'Önizleme', - Paste_From_Word: 'Word\'den yapıştır', - Tools: 'Araçlar', - Containers: 'Kapsayıcılar', - Classes: 'Sınıflar', - Status: 'Durum', - Source_Code: 'Kaynak Kodu' -}; - - -WYMeditor.STRINGS.zh_cn = { - Strong: '加粗', - Emphasis: '斜体', - Superscript: '上标', - Subscript: '下标', - Ordered_List: '有序列表', - Unordered_List: '无序列表', - Indent: '增加缩进', - Outdent: '减少缩进', - Undo: '撤消', - Redo: '重做', - Link: '链接', - Unlink: '取消链接', - Image: '图片', - Table: '表格', - HTML: 'HTML源代码', - Paragraph: '段落', - Heading_1: '标题 1', - Heading_2: '标题 2', - Heading_3: '标题 3', - Heading_4: '标题 4', - Heading_5: '标题 5', - Heading_6: '标题 6', - Preformatted: '原始文本', - Blockquote: '引语', - Table_Header: '表头', - URL: '地址', - Title: '提示文字', - Alternative_Text: '失效文字', - Caption: '标题', - Summary: 'Summary', - Number_Of_Rows: '行数', - Number_Of_Cols: '列数', - Submit: '提交', - Cancel: '放弃', - Choose: '选择', - Preview: '预览', - Paste_From_Word: '从Word粘贴纯文本', - Tools: '工具', - Containers: '容器', - Classes: '预定义样式', - Status: '状态', - Source_Code: '源代码', - Attachment: '附件', - NewParagraph: '新段落' -}; - - -WYMeditor.STRINGS.zh_tw = { - Strong: '加粗', - Emphasis: '斜體', - Superscript: '上標', - Subscript: '下標', - Ordered_List: '有序列表', - Unordered_List: '無序列表', - Indent: '增加縮排', - Outdent: '減少縮排', - Undo: '取消', - Redo: '重做', - Link: '鏈結', - Unlink: '取消鏈結', - Image: '圖片', - Table: '表格', - HTML: 'HTML 源代碼', - Paragraph: '段落', - Heading_1: '標題 1', - Heading_2: '標題 2', - Heading_3: '標題 3', - Heading_4: '標題 4', - Heading_5: '標題 5', - Heading_6: '標題 6', - Preformatted: '原始文本', - Blockquote: '引語', - Table_Header: '表格頂部', - URL: '地址', - Title: '提示文字', - Alternative_Text: '失效文字', - Caption: '主題', - Summary: '大綱', - Number_Of_Rows: '行數', - Number_Of_Cols: '列數', - Submit: '提交', - Cancel: '放棄', - Choose: '選擇', - Preview: '預覽', - Paste_From_Word: '從Word複制純文本', - Tools: '工具', - Containers: '容器', - Classes: '預定義樣式', - Status: '狀態', - Source_Code: '源代碼', - Attachment: '附件', - NewParagraph: '新段落' -}; - -/** - * @license Rangy, a cross-browser JavaScript range and selection library - * http://code.google.com/p/rangy/ - * - * Copyright 2011, Tim Down - * Licensed under the MIT license. - * Version: 1.2.2 - * Build date: 13 November 2011 - */ -window['rangy'] = (function() { - - - var OBJECT = "object", FUNCTION = "function", UNDEFINED = "undefined"; - - var domRangeProperties = ["startContainer", "startOffset", "endContainer", "endOffset", "collapsed", - "commonAncestorContainer", "START_TO_START", "START_TO_END", "END_TO_START", "END_TO_END"]; - - var domRangeMethods = ["setStart", "setStartBefore", "setStartAfter", "setEnd", "setEndBefore", - "setEndAfter", "collapse", "selectNode", "selectNodeContents", "compareBoundaryPoints", "deleteContents", - "extractContents", "cloneContents", "insertNode", "surroundContents", "cloneRange", "toString", "detach"]; - - var textRangeProperties = ["boundingHeight", "boundingLeft", "boundingTop", "boundingWidth", "htmlText", "text"]; - - // Subset of TextRange's full set of methods that we're interested in - var textRangeMethods = ["collapse", "compareEndPoints", "duplicate", "getBookmark", "moveToBookmark", - "moveToElementText", "parentElement", "pasteHTML", "select", "setEndPoint", "getBoundingClientRect"]; - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Trio of functions taken from Peter Michaux's article: - // http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting - function isHostMethod(o, p) { - var t = typeof o[p]; - return t == FUNCTION || (!!(t == OBJECT && o[p])) || t == "unknown"; - } - - function isHostObject(o, p) { - return !!(typeof o[p] == OBJECT && o[p]); - } - - function isHostProperty(o, p) { - return typeof o[p] != UNDEFINED; - } - - // Creates a convenience function to save verbose repeated calls to tests functions - function createMultiplePropertyTest(testFunc) { - return function(o, props) { - var i = props.length; - while (i--) { - if (!testFunc(o, props[i])) { - return false; - } - } - return true; - }; - } - - // Next trio of functions are a convenience to save verbose repeated calls to previous two functions - var areHostMethods = createMultiplePropertyTest(isHostMethod); - var areHostObjects = createMultiplePropertyTest(isHostObject); - var areHostProperties = createMultiplePropertyTest(isHostProperty); - - function isTextRange(range) { - return range && areHostMethods(range, textRangeMethods) && areHostProperties(range, textRangeProperties); - } - - var api = { - version: "1.2.2", - initialized: false, - supported: true, - - util: { - isHostMethod: isHostMethod, - isHostObject: isHostObject, - isHostProperty: isHostProperty, - areHostMethods: areHostMethods, - areHostObjects: areHostObjects, - areHostProperties: areHostProperties, - isTextRange: isTextRange - }, - - features: {}, - - modules: {}, - config: { - alertOnWarn: false, - preferTextRange: false - } - }; - - function fail(reason) { - window.alert("Rangy not supported in your browser. Reason: " + reason); - api.initialized = true; - api.supported = false; - } - - api.fail = fail; - - function warn(msg) { - var warningMessage = "Rangy warning: " + msg; - if (api.config.alertOnWarn) { - window.alert(warningMessage); - } else if (typeof window.console != UNDEFINED && typeof window.console.log != UNDEFINED) { - window.console.log(warningMessage); - } - } - - api.warn = warn; - - if ({}.hasOwnProperty) { - api.util.extend = function(o, props) { - for (var i in props) { - if (props.hasOwnProperty(i)) { - o[i] = props[i]; - } - } - }; - } else { - fail("hasOwnProperty not supported"); - } - - var initListeners = []; - var moduleInitializers = []; - - // Initialization - function init() { - if (api.initialized) { - return; - } - var testRange; - var implementsDomRange = false, implementsTextRange = false; - - // First, perform basic feature tests - - if (isHostMethod(document, "createRange")) { - testRange = document.createRange(); - if (areHostMethods(testRange, domRangeMethods) && areHostProperties(testRange, domRangeProperties)) { - implementsDomRange = true; - } - testRange.detach(); - } - - var body = isHostObject(document, "body") ? document.body : document.getElementsByTagName("body")[0]; - - if (body && isHostMethod(body, "createTextRange")) { - testRange = body.createTextRange(); - if (isTextRange(testRange)) { - implementsTextRange = true; - } - } - - if (!implementsDomRange && !implementsTextRange) { - fail("Neither Range nor TextRange are implemented"); - } - - api.initialized = true; - api.features = { - implementsDomRange: implementsDomRange, - implementsTextRange: implementsTextRange - }; - - // Initialize modules and call init listeners - var allListeners = moduleInitializers.concat(initListeners); - for (var i = 0, len = allListeners.length; i < len; ++i) { - try { - allListeners[i](api); - } catch (ex) { - if (isHostObject(window, "console") && isHostMethod(window.console, "log")) { - window.console.log("Init listener threw an exception. Continuing.", ex); - } - - } - } - } - - // Allow external scripts to initialize this library in case it's loaded after the document has loaded - api.init = init; - - // Execute listener immediately if already initialized - api.addInitListener = function(listener) { - if (api.initialized) { - listener(api); - } else { - initListeners.push(listener); - } - }; - - var createMissingNativeApiListeners = []; - - api.addCreateMissingNativeApiListener = function(listener) { - createMissingNativeApiListeners.push(listener); - }; - - function createMissingNativeApi(win) { - win = win || window; - init(); - - // Notify listeners - for (var i = 0, len = createMissingNativeApiListeners.length; i < len; ++i) { - createMissingNativeApiListeners[i](win); - } - } - - api.createMissingNativeApi = createMissingNativeApi; - - /** - * @constructor - */ - function Module(name) { - this.name = name; - this.initialized = false; - this.supported = false; - } - - Module.prototype.fail = function(reason) { - this.initialized = true; - this.supported = false; - - throw new Error("Module '" + this.name + "' failed to load: " + reason); - }; - - Module.prototype.warn = function(msg) { - api.warn("Module " + this.name + ": " + msg); - }; - - Module.prototype.createError = function(msg) { - return new Error("Error in Rangy " + this.name + " module: " + msg); - }; - - api.createModule = function(name, initFunc) { - var module = new Module(name); - api.modules[name] = module; - - moduleInitializers.push(function(api) { - initFunc(api, module); - module.initialized = true; - module.supported = true; - }); - }; - - api.requireModules = function(modules) { - for (var i = 0, len = modules.length, module, moduleName; i < len; ++i) { - moduleName = modules[i]; - module = api.modules[moduleName]; - if (!module || !(module instanceof Module)) { - throw new Error("Module '" + moduleName + "' not found"); - } - if (!module.supported) { - throw new Error("Module '" + moduleName + "' not supported"); - } - } - }; - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Wait for document to load before running tests - - var docReady = false; - - var loadHandler = function(e) { - - if (!docReady) { - docReady = true; - if (!api.initialized) { - init(); - } - } - }; - - // Test whether we have window and document objects that we will need - if (typeof window == UNDEFINED) { - fail("No window found"); - return; - } - if (typeof document == UNDEFINED) { - fail("No document found"); - return; - } - - if (isHostMethod(document, "addEventListener")) { - document.addEventListener("DOMContentLoaded", loadHandler, false); - } - - // Add a fallback in case the DOMContentLoaded event isn't supported - if (isHostMethod(window, "addEventListener")) { - window.addEventListener("load", loadHandler, false); - } else if (isHostMethod(window, "attachEvent")) { - window.attachEvent("onload", loadHandler); - } else { - fail("Window does not have required addEventListener or attachEvent method"); - } - - return api; -})(); -rangy.createModule("DomUtil", function(api, module) { - - var UNDEF = "undefined"; - var util = api.util; - - // Perform feature tests - if (!util.areHostMethods(document, ["createDocumentFragment", "createElement", "createTextNode"])) { - module.fail("document missing a Node creation method"); - } - - if (!util.isHostMethod(document, "getElementsByTagName")) { - module.fail("document missing getElementsByTagName method"); - } - - var el = document.createElement("div"); - if (!util.areHostMethods(el, ["insertBefore", "appendChild", "cloneNode"] || - !util.areHostObjects(el, ["previousSibling", "nextSibling", "childNodes", "parentNode"]))) { - module.fail("Incomplete Element implementation"); - } - - // innerHTML is required for Range's createContextualFragment method - if (!util.isHostProperty(el, "innerHTML")) { - module.fail("Element is missing innerHTML property"); - } - - var textNode = document.createTextNode("test"); - if (!util.areHostMethods(textNode, ["splitText", "deleteData", "insertData", "appendData", "cloneNode"] || - !util.areHostObjects(el, ["previousSibling", "nextSibling", "childNodes", "parentNode"]) || - !util.areHostProperties(textNode, ["data"]))) { - module.fail("Incomplete Text Node implementation"); - } - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Removed use of indexOf because of a bizarre bug in Opera that is thrown in one of the Acid3 tests. I haven't been - // able to replicate it outside of the test. The bug is that indexOf returns -1 when called on an Array that - // contains just the document as a single element and the value searched for is the document. - var arrayContains = /*Array.prototype.indexOf ? - function(arr, val) { - return arr.indexOf(val) > -1; - }:*/ - - function(arr, val) { - var i = arr.length; - while (i--) { - if (arr[i] === val) { - return true; - } - } - return false; - }; - - // Opera 11 puts HTML elements in the null namespace, it seems, and IE 7 has undefined namespaceURI - function isHtmlNamespace(node) { - var ns; - return typeof node.namespaceURI == UNDEF || ((ns = node.namespaceURI) === null || ns == "http://www.w3.org/1999/xhtml"); - } - - function parentElement(node) { - var parent = node.parentNode; - return (parent.nodeType == 1) ? parent : null; - } - - function getNodeIndex(node) { - var i = 0; - while( (node = node.previousSibling) ) { - i++; - } - return i; - } - - function getNodeLength(node) { - var childNodes; - return isCharacterDataNode(node) ? node.length : ((childNodes = node.childNodes) ? childNodes.length : 0); - } - - function getCommonAncestor(node1, node2) { - var ancestors = [], n; - for (n = node1; n; n = n.parentNode) { - ancestors.push(n); - } - - for (n = node2; n; n = n.parentNode) { - if (arrayContains(ancestors, n)) { - return n; - } - } - - return null; - } - - function isAncestorOf(ancestor, descendant, selfIsAncestor) { - var n = selfIsAncestor ? descendant : descendant.parentNode; - while (n) { - if (n === ancestor) { - return true; - } else { - n = n.parentNode; - } - } - return false; - } - - function getClosestAncestorIn(node, ancestor, selfIsAncestor) { - var p, n = selfIsAncestor ? node : node.parentNode; - while (n) { - p = n.parentNode; - if (p === ancestor) { - return n; - } - n = p; - } - return null; - } - - function isCharacterDataNode(node) { - var t = node.nodeType; - return t == 3 || t == 4 || t == 8 ; // Text, CDataSection or Comment - } - - function insertAfter(node, precedingNode) { - var nextNode = precedingNode.nextSibling, parent = precedingNode.parentNode; - if (nextNode) { - parent.insertBefore(node, nextNode); - } else { - parent.appendChild(node); - } - return node; - } - - // Note that we cannot use splitText() because it is bugridden in IE 9. - function splitDataNode(node, index) { - var newNode = node.cloneNode(false); - newNode.deleteData(0, index); - node.deleteData(index, node.length - index); - insertAfter(newNode, node); - return newNode; - } - - function getDocument(node) { - if (node.nodeType == 9) { - return node; - } else if (typeof node.ownerDocument != UNDEF) { - return node.ownerDocument; - } else if (typeof node.document != UNDEF) { - return node.document; - } else if (node.parentNode) { - return getDocument(node.parentNode); - } else { - throw new Error("getDocument: no document found for node"); - } - } - - function getWindow(node) { - var doc = getDocument(node); - if (typeof doc.defaultView != UNDEF) { - return doc.defaultView; - } else if (typeof doc.parentWindow != UNDEF) { - return doc.parentWindow; - } else { - throw new Error("Cannot get a window object for node"); - } - } - - function getIframeDocument(iframeEl) { - if (typeof iframeEl.contentDocument != UNDEF) { - return iframeEl.contentDocument; - } else if (typeof iframeEl.contentWindow != UNDEF) { - return iframeEl.contentWindow.document; - } else { - throw new Error("getIframeWindow: No Document object found for iframe element"); - } - } - - function getIframeWindow(iframeEl) { - if (typeof iframeEl.contentWindow != UNDEF) { - return iframeEl.contentWindow; - } else if (typeof iframeEl.contentDocument != UNDEF) { - return iframeEl.contentDocument.defaultView; - } else { - throw new Error("getIframeWindow: No Window object found for iframe element"); - } - } - - function getBody(doc) { - return util.isHostObject(doc, "body") ? doc.body : doc.getElementsByTagName("body")[0]; - } - - function getRootContainer(node) { - var parent; - while ( (parent = node.parentNode) ) { - node = parent; - } - return node; - } - - function comparePoints(nodeA, offsetA, nodeB, offsetB) { - // See http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Comparing - var nodeC, root, childA, childB, n; - if (nodeA == nodeB) { - - // Case 1: nodes are the same - return offsetA === offsetB ? 0 : (offsetA < offsetB) ? -1 : 1; - } else if ( (nodeC = getClosestAncestorIn(nodeB, nodeA, true)) ) { - - // Case 2: node C (container B or an ancestor) is a child node of A - return offsetA <= getNodeIndex(nodeC) ? -1 : 1; - } else if ( (nodeC = getClosestAncestorIn(nodeA, nodeB, true)) ) { - - // Case 3: node C (container A or an ancestor) is a child node of B - return getNodeIndex(nodeC) < offsetB ? -1 : 1; - } else { - - // Case 4: containers are siblings or descendants of siblings - root = getCommonAncestor(nodeA, nodeB); - childA = (nodeA === root) ? root : getClosestAncestorIn(nodeA, root, true); - childB = (nodeB === root) ? root : getClosestAncestorIn(nodeB, root, true); - - if (childA === childB) { - // This shouldn't be possible - - throw new Error("comparePoints got to case 4 and childA and childB are the same!"); - } else { - n = root.firstChild; - while (n) { - if (n === childA) { - return -1; - } else if (n === childB) { - return 1; - } - n = n.nextSibling; - } - throw new Error("Should not be here!"); - } - } - } - - function fragmentFromNodeChildren(node) { - var fragment = getDocument(node).createDocumentFragment(), child; - while ( (child = node.firstChild) ) { - fragment.appendChild(child); - } - return fragment; - } - - function inspectNode(node) { - if (!node) { - return "[No node]"; - } - if (isCharacterDataNode(node)) { - return '"' + node.data + '"'; - } else if (node.nodeType == 1) { - var idAttr = node.id ? ' id="' + node.id + '"' : ""; - return "<" + node.nodeName + idAttr + ">[" + node.childNodes.length + "]"; - } else { - return node.nodeName; - } - } - - /** - * @constructor - */ - function NodeIterator(root) { - this.root = root; - this._next = root; - } - - NodeIterator.prototype = { - _current: null, - - hasNext: function() { - return !!this._next; - }, - - next: function() { - var n = this._current = this._next; - var child, next; - if (this._current) { - child = n.firstChild; - if (child) { - this._next = child; - } else { - next = null; - while ((n !== this.root) && !(next = n.nextSibling)) { - n = n.parentNode; - } - this._next = next; - } - } - return this._current; - }, - - detach: function() { - this._current = this._next = this.root = null; - } - }; - - function createIterator(root) { - return new NodeIterator(root); - } - - /** - * @constructor - */ - function DomPosition(node, offset) { - this.node = node; - this.offset = offset; - } - - DomPosition.prototype = { - equals: function(pos) { - return this.node === pos.node & this.offset == pos.offset; - }, - - inspect: function() { - return "[DomPosition(" + inspectNode(this.node) + ":" + this.offset + ")]"; - } - }; - - /** - * @constructor - */ - function DOMException(codeName) { - this.code = this[codeName]; - this.codeName = codeName; - this.message = "DOMException: " + this.codeName; - } - - DOMException.prototype = { - INDEX_SIZE_ERR: 1, - HIERARCHY_REQUEST_ERR: 3, - WRONG_DOCUMENT_ERR: 4, - NO_MODIFICATION_ALLOWED_ERR: 7, - NOT_FOUND_ERR: 8, - NOT_SUPPORTED_ERR: 9, - INVALID_STATE_ERR: 11 - }; - - DOMException.prototype.toString = function() { - return this.message; - }; - - api.dom = { - arrayContains: arrayContains, - isHtmlNamespace: isHtmlNamespace, - parentElement: parentElement, - getNodeIndex: getNodeIndex, - getNodeLength: getNodeLength, - getCommonAncestor: getCommonAncestor, - isAncestorOf: isAncestorOf, - getClosestAncestorIn: getClosestAncestorIn, - isCharacterDataNode: isCharacterDataNode, - insertAfter: insertAfter, - splitDataNode: splitDataNode, - getDocument: getDocument, - getWindow: getWindow, - getIframeWindow: getIframeWindow, - getIframeDocument: getIframeDocument, - getBody: getBody, - getRootContainer: getRootContainer, - comparePoints: comparePoints, - inspectNode: inspectNode, - fragmentFromNodeChildren: fragmentFromNodeChildren, - createIterator: createIterator, - DomPosition: DomPosition - }; - - api.DOMException = DOMException; -});rangy.createModule("DomRange", function(api, module) { - api.requireModules( ["DomUtil"] ); - - - var dom = api.dom; - var DomPosition = dom.DomPosition; - var DOMException = api.DOMException; - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Utility functions - - function isNonTextPartiallySelected(node, range) { - return (node.nodeType != 3) && - (dom.isAncestorOf(node, range.startContainer, true) || dom.isAncestorOf(node, range.endContainer, true)); - } - - function getRangeDocument(range) { - return dom.getDocument(range.startContainer); - } - - function dispatchEvent(range, type, args) { - var listeners = range._listeners[type]; - if (listeners) { - for (var i = 0, len = listeners.length; i < len; ++i) { - listeners[i].call(range, {target: range, args: args}); - } - } - } - - function getBoundaryBeforeNode(node) { - return new DomPosition(node.parentNode, dom.getNodeIndex(node)); - } - - function getBoundaryAfterNode(node) { - return new DomPosition(node.parentNode, dom.getNodeIndex(node) + 1); - } - - function insertNodeAtPosition(node, n, o) { - var firstNodeInserted = node.nodeType == 11 ? node.firstChild : node; - if (dom.isCharacterDataNode(n)) { - if (o == n.length) { - dom.insertAfter(node, n); - } else { - n.parentNode.insertBefore(node, o == 0 ? n : dom.splitDataNode(n, o)); - } - } else if (o >= n.childNodes.length) { - n.appendChild(node); - } else { - n.insertBefore(node, n.childNodes[o]); - } - return firstNodeInserted; - } - - function cloneSubtree(iterator) { - var partiallySelected; - for (var node, frag = getRangeDocument(iterator.range).createDocumentFragment(), subIterator; node = iterator.next(); ) { - partiallySelected = iterator.isPartiallySelectedSubtree(); - - node = node.cloneNode(!partiallySelected); - if (partiallySelected) { - subIterator = iterator.getSubtreeIterator(); - node.appendChild(cloneSubtree(subIterator)); - subIterator.detach(true); - } - - if (node.nodeType == 10) { // DocumentType - throw new DOMException("HIERARCHY_REQUEST_ERR"); - } - frag.appendChild(node); - } - return frag; - } - - function iterateSubtree(rangeIterator, func, iteratorState) { - var it, n; - iteratorState = iteratorState || { stop: false }; - for (var node, subRangeIterator; node = rangeIterator.next(); ) { - //log.debug("iterateSubtree, partially selected: " + rangeIterator.isPartiallySelectedSubtree(), nodeToString(node)); - if (rangeIterator.isPartiallySelectedSubtree()) { - // The node is partially selected by the Range, so we can use a new RangeIterator on the portion of the - // node selected by the Range. - if (func(node) === false) { - iteratorState.stop = true; - return; - } else { - subRangeIterator = rangeIterator.getSubtreeIterator(); - iterateSubtree(subRangeIterator, func, iteratorState); - subRangeIterator.detach(true); - if (iteratorState.stop) { - return; - } - } - } else { - // The whole node is selected, so we can use efficient DOM iteration to iterate over the node and its - // descendant - it = dom.createIterator(node); - while ( (n = it.next()) ) { - if (func(n) === false) { - iteratorState.stop = true; - return; - } - } - } - } - } - - function deleteSubtree(iterator) { - var subIterator; - while (iterator.next()) { - if (iterator.isPartiallySelectedSubtree()) { - subIterator = iterator.getSubtreeIterator(); - deleteSubtree(subIterator); - subIterator.detach(true); - } else { - iterator.remove(); - } - } - } - - function extractSubtree(iterator) { - - for (var node, frag = getRangeDocument(iterator.range).createDocumentFragment(), subIterator; node = iterator.next(); ) { - - - if (iterator.isPartiallySelectedSubtree()) { - node = node.cloneNode(false); - subIterator = iterator.getSubtreeIterator(); - node.appendChild(extractSubtree(subIterator)); - subIterator.detach(true); - } else { - iterator.remove(); - } - if (node.nodeType == 10) { // DocumentType - throw new DOMException("HIERARCHY_REQUEST_ERR"); - } - frag.appendChild(node); - } - return frag; - } - - function getNodesInRange(range, nodeTypes, filter) { - //log.info("getNodesInRange, " + nodeTypes.join(",")); - var filterNodeTypes = !!(nodeTypes && nodeTypes.length), regex; - var filterExists = !!filter; - if (filterNodeTypes) { - regex = new RegExp("^(" + nodeTypes.join("|") + ")$"); - } - - var nodes = []; - iterateSubtree(new RangeIterator(range, false), function(node) { - if ((!filterNodeTypes || regex.test(node.nodeType)) && (!filterExists || filter(node))) { - nodes.push(node); - } - }); - return nodes; - } - - function inspect(range) { - var name = (typeof range.getName == "undefined") ? "Range" : range.getName(); - return "[" + name + "(" + dom.inspectNode(range.startContainer) + ":" + range.startOffset + ", " + - dom.inspectNode(range.endContainer) + ":" + range.endOffset + ")]"; - } - - /*----------------------------------------------------------------------------------------------------------------*/ - - // RangeIterator code partially borrows from IERange by Tim Ryan (http://github.com/timcameronryan/IERange) - - /** - * @constructor - */ - function RangeIterator(range, clonePartiallySelectedTextNodes) { - this.range = range; - this.clonePartiallySelectedTextNodes = clonePartiallySelectedTextNodes; - - - - if (!range.collapsed) { - this.sc = range.startContainer; - this.so = range.startOffset; - this.ec = range.endContainer; - this.eo = range.endOffset; - var root = range.commonAncestorContainer; - - if (this.sc === this.ec && dom.isCharacterDataNode(this.sc)) { - this.isSingleCharacterDataNode = true; - this._first = this._last = this._next = this.sc; - } else { - this._first = this._next = (this.sc === root && !dom.isCharacterDataNode(this.sc)) ? - this.sc.childNodes[this.so] : dom.getClosestAncestorIn(this.sc, root, true); - this._last = (this.ec === root && !dom.isCharacterDataNode(this.ec)) ? - this.ec.childNodes[this.eo - 1] : dom.getClosestAncestorIn(this.ec, root, true); - } - - } - } - - RangeIterator.prototype = { - _current: null, - _next: null, - _first: null, - _last: null, - isSingleCharacterDataNode: false, - - reset: function() { - this._current = null; - this._next = this._first; - }, - - hasNext: function() { - return !!this._next; - }, - - next: function() { - // Move to next node - var current = this._current = this._next; - if (current) { - this._next = (current !== this._last) ? current.nextSibling : null; - - // Check for partially selected text nodes - if (dom.isCharacterDataNode(current) && this.clonePartiallySelectedTextNodes) { - if (current === this.ec) { - - (current = current.cloneNode(true)).deleteData(this.eo, current.length - this.eo); - } - if (this._current === this.sc) { - - (current = current.cloneNode(true)).deleteData(0, this.so); - } - } - } - - return current; - }, - - remove: function() { - var current = this._current, start, end; - - if (dom.isCharacterDataNode(current) && (current === this.sc || current === this.ec)) { - start = (current === this.sc) ? this.so : 0; - end = (current === this.ec) ? this.eo : current.length; - if (start != end) { - current.deleteData(start, end - start); - } - } else { - if (current.parentNode) { - current.parentNode.removeChild(current); - } else { - - } - } - }, - - // Checks if the current node is partially selected - isPartiallySelectedSubtree: function() { - var current = this._current; - return isNonTextPartiallySelected(current, this.range); - }, - - getSubtreeIterator: function() { - var subRange; - if (this.isSingleCharacterDataNode) { - subRange = this.range.cloneRange(); - subRange.collapse(); - } else { - subRange = new Range(getRangeDocument(this.range)); - var current = this._current; - var startContainer = current, startOffset = 0, endContainer = current, endOffset = dom.getNodeLength(current); - - if (dom.isAncestorOf(current, this.sc, true)) { - startContainer = this.sc; - startOffset = this.so; - } - if (dom.isAncestorOf(current, this.ec, true)) { - endContainer = this.ec; - endOffset = this.eo; - } - - updateBoundaries(subRange, startContainer, startOffset, endContainer, endOffset); - } - return new RangeIterator(subRange, this.clonePartiallySelectedTextNodes); - }, - - detach: function(detachRange) { - if (detachRange) { - this.range.detach(); - } - this.range = this._current = this._next = this._first = this._last = this.sc = this.so = this.ec = this.eo = null; - } - }; - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Exceptions - - /** - * @constructor - */ - function RangeException(codeName) { - this.code = this[codeName]; - this.codeName = codeName; - this.message = "RangeException: " + this.codeName; - } - - RangeException.prototype = { - BAD_BOUNDARYPOINTS_ERR: 1, - INVALID_NODE_TYPE_ERR: 2 - }; - - RangeException.prototype.toString = function() { - return this.message; - }; - - /*----------------------------------------------------------------------------------------------------------------*/ - - /** - * Currently iterates through all nodes in the range on creation until I think of a decent way to do it - * TODO: Look into making this a proper iterator, not requiring preloading everything first - * @constructor - */ - function RangeNodeIterator(range, nodeTypes, filter) { - this.nodes = getNodesInRange(range, nodeTypes, filter); - this._next = this.nodes[0]; - this._position = 0; - } - - RangeNodeIterator.prototype = { - _current: null, - - hasNext: function() { - return !!this._next; - }, - - next: function() { - this._current = this._next; - this._next = this.nodes[ ++this._position ]; - return this._current; - }, - - detach: function() { - this._current = this._next = this.nodes = null; - } - }; - - var beforeAfterNodeTypes = [1, 3, 4, 5, 7, 8, 10]; - var rootContainerNodeTypes = [2, 9, 11]; - var readonlyNodeTypes = [5, 6, 10, 12]; - var insertableNodeTypes = [1, 3, 4, 5, 7, 8, 10, 11]; - var surroundNodeTypes = [1, 3, 4, 5, 7, 8]; - - function createAncestorFinder(nodeTypes) { - return function(node, selfIsAncestor) { - var t, n = selfIsAncestor ? node : node.parentNode; - while (n) { - t = n.nodeType; - if (dom.arrayContains(nodeTypes, t)) { - return n; - } - n = n.parentNode; - } - return null; - }; - } - - var getRootContainer = dom.getRootContainer; - var getDocumentOrFragmentContainer = createAncestorFinder( [9, 11] ); - var getReadonlyAncestor = createAncestorFinder(readonlyNodeTypes); - var getDocTypeNotationEntityAncestor = createAncestorFinder( [6, 10, 12] ); - - function assertNoDocTypeNotationEntityAncestor(node, allowSelf) { - if (getDocTypeNotationEntityAncestor(node, allowSelf)) { - throw new RangeException("INVALID_NODE_TYPE_ERR"); - } - } - - function assertNotDetached(range) { - if (!range.startContainer) { - throw new DOMException("INVALID_STATE_ERR"); - } - } - - function assertValidNodeType(node, invalidTypes) { - if (!dom.arrayContains(invalidTypes, node.nodeType)) { - throw new RangeException("INVALID_NODE_TYPE_ERR"); - } - } - - function assertValidOffset(node, offset) { - if (offset < 0 || offset > (dom.isCharacterDataNode(node) ? node.length : node.childNodes.length)) { - throw new DOMException("INDEX_SIZE_ERR"); - } - } - - function assertSameDocumentOrFragment(node1, node2) { - if (getDocumentOrFragmentContainer(node1, true) !== getDocumentOrFragmentContainer(node2, true)) { - throw new DOMException("WRONG_DOCUMENT_ERR"); - } - } - - function assertNodeNotReadOnly(node) { - if (getReadonlyAncestor(node, true)) { - throw new DOMException("NO_MODIFICATION_ALLOWED_ERR"); - } - } - - function assertNode(node, codeName) { - if (!node) { - throw new DOMException(codeName); - } - } - - function isOrphan(node) { - return !dom.arrayContains(rootContainerNodeTypes, node.nodeType) && !getDocumentOrFragmentContainer(node, true); - } - - function isValidOffset(node, offset) { - return offset <= (dom.isCharacterDataNode(node) ? node.length : node.childNodes.length); - } - - function assertRangeValid(range) { - assertNotDetached(range); - if (isOrphan(range.startContainer) || isOrphan(range.endContainer) || - !isValidOffset(range.startContainer, range.startOffset) || - !isValidOffset(range.endContainer, range.endOffset)) { - throw new Error("Range error: Range is no longer valid after DOM mutation (" + range.inspect() + ")"); - } - } - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Test the browser's innerHTML support to decide how to implement createContextualFragment - var styleEl = document.createElement("style"); - var htmlParsingConforms = false; - try { - styleEl.innerHTML = "x"; - htmlParsingConforms = (styleEl.firstChild.nodeType == 3); // Opera incorrectly creates an element node - } catch (e) { - // IE 6 and 7 throw - } - - api.features.htmlParsingConforms = htmlParsingConforms; - - var createContextualFragment = htmlParsingConforms ? - - // Implementation as per HTML parsing spec, trusting in the browser's implementation of innerHTML. See - // discussion and base code for this implementation at issue 67. - // Spec: http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface - // Thanks to Aleks Williams. - function(fragmentStr) { - // "Let node the context object's start's node." - var node = this.startContainer; - var doc = dom.getDocument(node); - - // "If the context object's start's node is null, raise an INVALID_STATE_ERR - // exception and abort these steps." - if (!node) { - throw new DOMException("INVALID_STATE_ERR"); - } - - // "Let element be as follows, depending on node's interface:" - // Document, Document Fragment: null - var el = null; - - // "Element: node" - if (node.nodeType == 1) { - el = node; - - // "Text, Comment: node's parentElement" - } else if (dom.isCharacterDataNode(node)) { - el = dom.parentElement(node); - } - - // "If either element is null or element's ownerDocument is an HTML document - // and element's local name is "html" and element's namespace is the HTML - // namespace" - if (el === null || ( - el.nodeName == "HTML" - && dom.isHtmlNamespace(dom.getDocument(el).documentElement) - && dom.isHtmlNamespace(el) - )) { - - // "let element be a new Element with "body" as its local name and the HTML - // namespace as its namespace."" - el = doc.createElement("body"); - } else { - el = el.cloneNode(false); - } - - // "If the node's document is an HTML document: Invoke the HTML fragment parsing algorithm." - // "If the node's document is an XML document: Invoke the XML fragment parsing algorithm." - // "In either case, the algorithm must be invoked with fragment as the input - // and element as the context element." - el.innerHTML = fragmentStr; - - // "If this raises an exception, then abort these steps. Otherwise, let new - // children be the nodes returned." - - // "Let fragment be a new DocumentFragment." - // "Append all new children to fragment." - // "Return fragment." - return dom.fragmentFromNodeChildren(el); - } : - - // In this case, innerHTML cannot be trusted, so fall back to a simpler, non-conformant implementation that - // previous versions of Rangy used (with the exception of using a body element rather than a div) - function(fragmentStr) { - assertNotDetached(this); - var doc = getRangeDocument(this); - var el = doc.createElement("body"); - el.innerHTML = fragmentStr; - - return dom.fragmentFromNodeChildren(el); - }; - - /*----------------------------------------------------------------------------------------------------------------*/ - - var rangeProperties = ["startContainer", "startOffset", "endContainer", "endOffset", "collapsed", - "commonAncestorContainer"]; - - var s2s = 0, s2e = 1, e2e = 2, e2s = 3; - var n_b = 0, n_a = 1, n_b_a = 2, n_i = 3; - - function RangePrototype() {} - - RangePrototype.prototype = { - attachListener: function(type, listener) { - this._listeners[type].push(listener); - }, - - compareBoundaryPoints: function(how, range) { - assertRangeValid(this); - assertSameDocumentOrFragment(this.startContainer, range.startContainer); - - var nodeA, offsetA, nodeB, offsetB; - var prefixA = (how == e2s || how == s2s) ? "start" : "end"; - var prefixB = (how == s2e || how == s2s) ? "start" : "end"; - nodeA = this[prefixA + "Container"]; - offsetA = this[prefixA + "Offset"]; - nodeB = range[prefixB + "Container"]; - offsetB = range[prefixB + "Offset"]; - return dom.comparePoints(nodeA, offsetA, nodeB, offsetB); - }, - - insertNode: function(node) { - assertRangeValid(this); - assertValidNodeType(node, insertableNodeTypes); - assertNodeNotReadOnly(this.startContainer); - - if (dom.isAncestorOf(node, this.startContainer, true)) { - throw new DOMException("HIERARCHY_REQUEST_ERR"); - } - - // No check for whether the container of the start of the Range is of a type that does not allow - // children of the type of node: the browser's DOM implementation should do this for us when we attempt - // to add the node - - var firstNodeInserted = insertNodeAtPosition(node, this.startContainer, this.startOffset); - this.setStartBefore(firstNodeInserted); - }, - - cloneContents: function() { - assertRangeValid(this); - - var clone, frag; - if (this.collapsed) { - return getRangeDocument(this).createDocumentFragment(); - } else { - if (this.startContainer === this.endContainer && dom.isCharacterDataNode(this.startContainer)) { - clone = this.startContainer.cloneNode(true); - clone.data = clone.data.slice(this.startOffset, this.endOffset); - frag = getRangeDocument(this).createDocumentFragment(); - frag.appendChild(clone); - return frag; - } else { - var iterator = new RangeIterator(this, true); - clone = cloneSubtree(iterator); - iterator.detach(); - } - return clone; - } - }, - - canSurroundContents: function() { - assertRangeValid(this); - assertNodeNotReadOnly(this.startContainer); - assertNodeNotReadOnly(this.endContainer); - - // Check if the contents can be surrounded. Specifically, this means whether the range partially selects - // no non-text nodes. - var iterator = new RangeIterator(this, true); - var boundariesInvalid = (iterator._first && (isNonTextPartiallySelected(iterator._first, this)) || - (iterator._last && isNonTextPartiallySelected(iterator._last, this))); - iterator.detach(); - return !boundariesInvalid; - }, - - surroundContents: function(node) { - assertValidNodeType(node, surroundNodeTypes); - - if (!this.canSurroundContents()) { - throw new RangeException("BAD_BOUNDARYPOINTS_ERR"); - } - - // Extract the contents - var content = this.extractContents(); - - // Clear the children of the node - if (node.hasChildNodes()) { - while (node.lastChild) { - node.removeChild(node.lastChild); - } - } - - // Insert the new node and add the extracted contents - insertNodeAtPosition(node, this.startContainer, this.startOffset); - node.appendChild(content); - - this.selectNode(node); - }, - - cloneRange: function() { - assertRangeValid(this); - var range = new Range(getRangeDocument(this)); - var i = rangeProperties.length, prop; - while (i--) { - prop = rangeProperties[i]; - range[prop] = this[prop]; - } - return range; - }, - - toString: function() { - assertRangeValid(this); - var sc = this.startContainer; - if (sc === this.endContainer && dom.isCharacterDataNode(sc)) { - return (sc.nodeType == 3 || sc.nodeType == 4) ? sc.data.slice(this.startOffset, this.endOffset) : ""; - } else { - var textBits = [], iterator = new RangeIterator(this, true); - - iterateSubtree(iterator, function(node) { - // Accept only text or CDATA nodes, not comments - - if (node.nodeType == 3 || node.nodeType == 4) { - textBits.push(node.data); - } - }); - iterator.detach(); - return textBits.join(""); - } - }, - - // The methods below are all non-standard. The following batch were introduced by Mozilla but have since - // been removed from Mozilla. - - compareNode: function(node) { - assertRangeValid(this); - - var parent = node.parentNode; - var nodeIndex = dom.getNodeIndex(node); - - if (!parent) { - throw new DOMException("NOT_FOUND_ERR"); - } - - var startComparison = this.comparePoint(parent, nodeIndex), - endComparison = this.comparePoint(parent, nodeIndex + 1); - - if (startComparison < 0) { // Node starts before - return (endComparison > 0) ? n_b_a : n_b; - } else { - return (endComparison > 0) ? n_a : n_i; - } - }, - - comparePoint: function(node, offset) { - assertRangeValid(this); - assertNode(node, "HIERARCHY_REQUEST_ERR"); - assertSameDocumentOrFragment(node, this.startContainer); - - if (dom.comparePoints(node, offset, this.startContainer, this.startOffset) < 0) { - return -1; - } else if (dom.comparePoints(node, offset, this.endContainer, this.endOffset) > 0) { - return 1; - } - return 0; - }, - - createContextualFragment: createContextualFragment, - - toHtml: function() { - assertRangeValid(this); - var container = getRangeDocument(this).createElement("div"); - container.appendChild(this.cloneContents()); - return container.innerHTML; - }, - - // touchingIsIntersecting determines whether this method considers a node that borders a range intersects - // with it (as in WebKit) or not (as in Gecko pre-1.9, and the default) - intersectsNode: function(node, touchingIsIntersecting) { - assertRangeValid(this); - assertNode(node, "NOT_FOUND_ERR"); - if (dom.getDocument(node) !== getRangeDocument(this)) { - return false; - } - - var parent = node.parentNode, offset = dom.getNodeIndex(node); - assertNode(parent, "NOT_FOUND_ERR"); - - var startComparison = dom.comparePoints(parent, offset, this.endContainer, this.endOffset), - endComparison = dom.comparePoints(parent, offset + 1, this.startContainer, this.startOffset); - - return touchingIsIntersecting ? startComparison <= 0 && endComparison >= 0 : startComparison < 0 && endComparison > 0; - }, - - - isPointInRange: function(node, offset) { - assertRangeValid(this); - assertNode(node, "HIERARCHY_REQUEST_ERR"); - assertSameDocumentOrFragment(node, this.startContainer); - - return (dom.comparePoints(node, offset, this.startContainer, this.startOffset) >= 0) && - (dom.comparePoints(node, offset, this.endContainer, this.endOffset) <= 0); - }, - - // The methods below are non-standard and invented by me. - - // Sharing a boundary start-to-end or end-to-start does not count as intersection. - intersectsRange: function(range, touchingIsIntersecting) { - assertRangeValid(this); - - if (getRangeDocument(range) != getRangeDocument(this)) { - throw new DOMException("WRONG_DOCUMENT_ERR"); - } - - var startComparison = dom.comparePoints(this.startContainer, this.startOffset, range.endContainer, range.endOffset), - endComparison = dom.comparePoints(this.endContainer, this.endOffset, range.startContainer, range.startOffset); - - return touchingIsIntersecting ? startComparison <= 0 && endComparison >= 0 : startComparison < 0 && endComparison > 0; - }, - - intersection: function(range) { - if (this.intersectsRange(range)) { - var startComparison = dom.comparePoints(this.startContainer, this.startOffset, range.startContainer, range.startOffset), - endComparison = dom.comparePoints(this.endContainer, this.endOffset, range.endContainer, range.endOffset); - - var intersectionRange = this.cloneRange(); - - if (startComparison == -1) { - intersectionRange.setStart(range.startContainer, range.startOffset); - } - if (endComparison == 1) { - intersectionRange.setEnd(range.endContainer, range.endOffset); - } - return intersectionRange; - } - return null; - }, - - union: function(range) { - if (this.intersectsRange(range, true)) { - var unionRange = this.cloneRange(); - if (dom.comparePoints(range.startContainer, range.startOffset, this.startContainer, this.startOffset) == -1) { - unionRange.setStart(range.startContainer, range.startOffset); - } - if (dom.comparePoints(range.endContainer, range.endOffset, this.endContainer, this.endOffset) == 1) { - unionRange.setEnd(range.endContainer, range.endOffset); - } - return unionRange; - } else { - throw new RangeException("Ranges do not intersect"); - } - }, - - containsNode: function(node, allowPartial) { - if (allowPartial) { - return this.intersectsNode(node, false); - } else { - return this.compareNode(node) == n_i; - } - }, - - containsNodeContents: function(node) { - return this.comparePoint(node, 0) >= 0 && this.comparePoint(node, dom.getNodeLength(node)) <= 0; - }, - - containsRange: function(range) { - return this.intersection(range).equals(range); - }, - - containsNodeText: function(node) { - var nodeRange = this.cloneRange(); - nodeRange.selectNode(node); - var textNodes = nodeRange.getNodes([3]); - if (textNodes.length > 0) { - nodeRange.setStart(textNodes[0], 0); - var lastTextNode = textNodes.pop(); - nodeRange.setEnd(lastTextNode, lastTextNode.length); - var contains = this.containsRange(nodeRange); - nodeRange.detach(); - return contains; - } else { - return this.containsNodeContents(node); - } - }, - - createNodeIterator: function(nodeTypes, filter) { - assertRangeValid(this); - return new RangeNodeIterator(this, nodeTypes, filter); - }, - - getNodes: function(nodeTypes, filter) { - assertRangeValid(this); - return getNodesInRange(this, nodeTypes, filter); - }, - - getDocument: function() { - return getRangeDocument(this); - }, - - collapseBefore: function(node) { - assertNotDetached(this); - - this.setEndBefore(node); - this.collapse(false); - }, - - collapseAfter: function(node) { - assertNotDetached(this); - - this.setStartAfter(node); - this.collapse(true); - }, - - getName: function() { - return "DomRange"; - }, - - equals: function(range) { - return Range.rangesEqual(this, range); - }, - - inspect: function() { - return inspect(this); - } - }; - - function copyComparisonConstantsToObject(obj) { - obj.START_TO_START = s2s; - obj.START_TO_END = s2e; - obj.END_TO_END = e2e; - obj.END_TO_START = e2s; - - obj.NODE_BEFORE = n_b; - obj.NODE_AFTER = n_a; - obj.NODE_BEFORE_AND_AFTER = n_b_a; - obj.NODE_INSIDE = n_i; - } - - function copyComparisonConstants(constructor) { - copyComparisonConstantsToObject(constructor); - copyComparisonConstantsToObject(constructor.prototype); - } - - function createRangeContentRemover(remover, boundaryUpdater) { - return function() { - assertRangeValid(this); - - var sc = this.startContainer, so = this.startOffset, root = this.commonAncestorContainer; - - var iterator = new RangeIterator(this, true); - - // Work out where to position the range after content removal - var node, boundary; - if (sc !== root) { - node = dom.getClosestAncestorIn(sc, root, true); - boundary = getBoundaryAfterNode(node); - sc = boundary.node; - so = boundary.offset; - } - - // Check none of the range is read-only - iterateSubtree(iterator, assertNodeNotReadOnly); - - iterator.reset(); - - // Remove the content - var returnValue = remover(iterator); - iterator.detach(); - - // Move to the new position - boundaryUpdater(this, sc, so, sc, so); - - return returnValue; - }; - } - - function createPrototypeRange(constructor, boundaryUpdater, detacher) { - function createBeforeAfterNodeSetter(isBefore, isStart) { - return function(node) { - assertNotDetached(this); - assertValidNodeType(node, beforeAfterNodeTypes); - assertValidNodeType(getRootContainer(node), rootContainerNodeTypes); - - var boundary = (isBefore ? getBoundaryBeforeNode : getBoundaryAfterNode)(node); - (isStart ? setRangeStart : setRangeEnd)(this, boundary.node, boundary.offset); - }; - } - - function setRangeStart(range, node, offset) { - var ec = range.endContainer, eo = range.endOffset; - if (node !== range.startContainer || offset !== range.startOffset) { - // Check the root containers of the range and the new boundary, and also check whether the new boundary - // is after the current end. In either case, collapse the range to the new position - if (getRootContainer(node) != getRootContainer(ec) || dom.comparePoints(node, offset, ec, eo) == 1) { - ec = node; - eo = offset; - } - boundaryUpdater(range, node, offset, ec, eo); - } - } - - function setRangeEnd(range, node, offset) { - var sc = range.startContainer, so = range.startOffset; - if (node !== range.endContainer || offset !== range.endOffset) { - // Check the root containers of the range and the new boundary, and also check whether the new boundary - // is after the current end. In either case, collapse the range to the new position - if (getRootContainer(node) != getRootContainer(sc) || dom.comparePoints(node, offset, sc, so) == -1) { - sc = node; - so = offset; - } - boundaryUpdater(range, sc, so, node, offset); - } - } - - function setRangeStartAndEnd(range, node, offset) { - if (node !== range.startContainer || offset !== range.startOffset || node !== range.endContainer || offset !== range.endOffset) { - boundaryUpdater(range, node, offset, node, offset); - } - } - - constructor.prototype = new RangePrototype(); - - api.util.extend(constructor.prototype, { - setStart: function(node, offset) { - assertNotDetached(this); - assertNoDocTypeNotationEntityAncestor(node, true); - assertValidOffset(node, offset); - - setRangeStart(this, node, offset); - }, - - setEnd: function(node, offset) { - assertNotDetached(this); - assertNoDocTypeNotationEntityAncestor(node, true); - assertValidOffset(node, offset); - - setRangeEnd(this, node, offset); - }, - - setStartBefore: createBeforeAfterNodeSetter(true, true), - setStartAfter: createBeforeAfterNodeSetter(false, true), - setEndBefore: createBeforeAfterNodeSetter(true, false), - setEndAfter: createBeforeAfterNodeSetter(false, false), - - collapse: function(isStart) { - assertRangeValid(this); - if (isStart) { - boundaryUpdater(this, this.startContainer, this.startOffset, this.startContainer, this.startOffset); - } else { - boundaryUpdater(this, this.endContainer, this.endOffset, this.endContainer, this.endOffset); - } - }, - - selectNodeContents: function(node) { - // This doesn't seem well specified: the spec talks only about selecting the node's contents, which - // could be taken to mean only its children. However, browsers implement this the same as selectNode for - // text nodes, so I shall do likewise - assertNotDetached(this); - assertNoDocTypeNotationEntityAncestor(node, true); - - boundaryUpdater(this, node, 0, node, dom.getNodeLength(node)); - }, - - selectNode: function(node) { - assertNotDetached(this); - assertNoDocTypeNotationEntityAncestor(node, false); - assertValidNodeType(node, beforeAfterNodeTypes); - - var start = getBoundaryBeforeNode(node), end = getBoundaryAfterNode(node); - boundaryUpdater(this, start.node, start.offset, end.node, end.offset); - }, - - extractContents: createRangeContentRemover(extractSubtree, boundaryUpdater), - - deleteContents: createRangeContentRemover(deleteSubtree, boundaryUpdater), - - canSurroundContents: function() { - assertRangeValid(this); - assertNodeNotReadOnly(this.startContainer); - assertNodeNotReadOnly(this.endContainer); - - // Check if the contents can be surrounded. Specifically, this means whether the range partially selects - // no non-text nodes. - var iterator = new RangeIterator(this, true); - var boundariesInvalid = (iterator._first && (isNonTextPartiallySelected(iterator._first, this)) || - (iterator._last && isNonTextPartiallySelected(iterator._last, this))); - iterator.detach(); - return !boundariesInvalid; - }, - - detach: function() { - detacher(this); - }, - - splitBoundaries: function() { - assertRangeValid(this); - - - var sc = this.startContainer, so = this.startOffset, ec = this.endContainer, eo = this.endOffset; - var startEndSame = (sc === ec); - - if (dom.isCharacterDataNode(ec) && eo > 0 && eo < ec.length) { - dom.splitDataNode(ec, eo); - - } - - if (dom.isCharacterDataNode(sc) && so > 0 && so < sc.length) { - - sc = dom.splitDataNode(sc, so); - if (startEndSame) { - eo -= so; - ec = sc; - } else if (ec == sc.parentNode && eo >= dom.getNodeIndex(sc)) { - eo++; - } - so = 0; - - } - boundaryUpdater(this, sc, so, ec, eo); - }, - - normalizeBoundaries: function() { - assertRangeValid(this); - - var sc = this.startContainer, so = this.startOffset, ec = this.endContainer, eo = this.endOffset; - - var mergeForward = function(node) { - var sibling = node.nextSibling; - if (sibling && sibling.nodeType == node.nodeType) { - ec = node; - eo = node.length; - node.appendData(sibling.data); - sibling.parentNode.removeChild(sibling); - } - }; - - var mergeBackward = function(node) { - var sibling = node.previousSibling; - if (sibling && sibling.nodeType == node.nodeType) { - sc = node; - var nodeLength = node.length; - so = sibling.length; - node.insertData(0, sibling.data); - sibling.parentNode.removeChild(sibling); - if (sc == ec) { - eo += so; - ec = sc; - } else if (ec == node.parentNode) { - var nodeIndex = dom.getNodeIndex(node); - if (eo == nodeIndex) { - ec = node; - eo = nodeLength; - } else if (eo > nodeIndex) { - eo--; - } - } - } - }; - - var normalizeStart = true; - - if (dom.isCharacterDataNode(ec)) { - if (ec.length == eo) { - mergeForward(ec); - } - } else { - if (eo > 0) { - var endNode = ec.childNodes[eo - 1]; - if (endNode && dom.isCharacterDataNode(endNode)) { - mergeForward(endNode); - } - } - normalizeStart = !this.collapsed; - } - - if (normalizeStart) { - if (dom.isCharacterDataNode(sc)) { - if (so == 0) { - mergeBackward(sc); - } - } else { - if (so < sc.childNodes.length) { - var startNode = sc.childNodes[so]; - if (startNode && dom.isCharacterDataNode(startNode)) { - mergeBackward(startNode); - } - } - } - } else { - sc = ec; - so = eo; - } - - boundaryUpdater(this, sc, so, ec, eo); - }, - - collapseToPoint: function(node, offset) { - assertNotDetached(this); - - assertNoDocTypeNotationEntityAncestor(node, true); - assertValidOffset(node, offset); - - setRangeStartAndEnd(this, node, offset); - } - }); - - copyComparisonConstants(constructor); - } - - /*----------------------------------------------------------------------------------------------------------------*/ - - // Updates commonAncestorContainer and collapsed after boundary change - function updateCollapsedAndCommonAncestor(range) { - range.collapsed = (range.startContainer === range.endContainer && range.startOffset === range.endOffset); - range.commonAncestorContainer = range.collapsed ? - range.startContainer : dom.getCommonAncestor(range.startContainer, range.endContainer); - } - - function updateBoundaries(range, startContainer, startOffset, endContainer, endOffset) { - var startMoved = (range.startContainer !== startContainer || range.startOffset !== startOffset); - var endMoved = (range.endContainer !== endContainer || range.endOffset !== endOffset); - - range.startContainer = startContainer; - range.startOffset = startOffset; - range.endContainer = endContainer; - range.endOffset = endOffset; - - updateCollapsedAndCommonAncestor(range); - dispatchEvent(range, "boundarychange", {startMoved: startMoved, endMoved: endMoved}); - } - - function detach(range) { - assertNotDetached(range); - range.startContainer = range.startOffset = range.endContainer = range.endOffset = null; - range.collapsed = range.commonAncestorContainer = null; - dispatchEvent(range, "detach", null); - range._listeners = null; - } - - /** - * @constructor - */ - function Range(doc) { - this.startContainer = doc; - this.startOffset = 0; - this.endContainer = doc; - this.endOffset = 0; - this._listeners = { - boundarychange: [], - detach: [] - }; - updateCollapsedAndCommonAncestor(this); - } - - createPrototypeRange(Range, updateBoundaries, detach); - - api.rangePrototype = RangePrototype.prototype; - - Range.rangeProperties = rangeProperties; - Range.RangeIterator = RangeIterator; - Range.copyComparisonConstants = copyComparisonConstants; - Range.createPrototypeRange = createPrototypeRange; - Range.inspect = inspect; - Range.getRangeDocument = getRangeDocument; - Range.rangesEqual = function(r1, r2) { - return r1.startContainer === r2.startContainer && - r1.startOffset === r2.startOffset && - r1.endContainer === r2.endContainer && - r1.endOffset === r2.endOffset; - }; - - api.DomRange = Range; - api.RangeException = RangeException; -});rangy.createModule("WrappedRange", function(api, module) { - api.requireModules( ["DomUtil", "DomRange"] ); - - /** - * @constructor - */ - var WrappedRange; - var dom = api.dom; - var DomPosition = dom.DomPosition; - var DomRange = api.DomRange; - - - - /*----------------------------------------------------------------------------------------------------------------*/ - - /* - This is a workaround for a bug where IE returns the wrong container element from the TextRange's parentElement() - method. For example, in the following (where pipes denote the selection boundaries): - -
            • | a
            • b |
            - - var range = document.selection.createRange(); - alert(range.parentElement().id); // Should alert "ul" but alerts "b" - - This method returns the common ancestor node of the following: - - the parentElement() of the textRange - - the parentElement() of the textRange after calling collapse(true) - - the parentElement() of the textRange after calling collapse(false) - */ - function getTextRangeContainerElement(textRange) { - var parentEl = textRange.parentElement(); - - var range = textRange.duplicate(); - range.collapse(true); - var startEl = range.parentElement(); - range = textRange.duplicate(); - range.collapse(false); - var endEl = range.parentElement(); - var startEndContainer = (startEl == endEl) ? startEl : dom.getCommonAncestor(startEl, endEl); - - return startEndContainer == parentEl ? startEndContainer : dom.getCommonAncestor(parentEl, startEndContainer); - } - - function textRangeIsCollapsed(textRange) { - return textRange.compareEndPoints("StartToEnd", textRange) == 0; - } - - // Gets the boundary of a TextRange expressed as a node and an offset within that node. This function started out as - // an improved version of code found in Tim Cameron Ryan's IERange (http://code.google.com/p/ierange/) but has - // grown, fixing problems with line breaks in preformatted text, adding workaround for IE TextRange bugs, handling - // for inputs and images, plus optimizations. - function getTextRangeBoundaryPosition(textRange, wholeRangeContainerElement, isStart, isCollapsed) { - var workingRange = textRange.duplicate(); - - workingRange.collapse(isStart); - var containerElement = workingRange.parentElement(); - - // Sometimes collapsing a TextRange that's at the start of a text node can move it into the previous node, so - // check for that - // TODO: Find out when. Workaround for wholeRangeContainerElement may break this - if (!dom.isAncestorOf(wholeRangeContainerElement, containerElement, true)) { - containerElement = wholeRangeContainerElement; - - } - - - - // Deal with nodes that cannot "contain rich HTML markup". In practice, this means form inputs, images and - // similar. See http://msdn.microsoft.com/en-us/library/aa703950%28VS.85%29.aspx - if (!containerElement.canHaveHTML) { - return new DomPosition(containerElement.parentNode, dom.getNodeIndex(containerElement)); - } - - var workingNode = dom.getDocument(containerElement).createElement("span"); - var comparison, workingComparisonType = isStart ? "StartToStart" : "StartToEnd"; - var previousNode, nextNode, boundaryPosition, boundaryNode; - - // Move the working range through the container's children, starting at the end and working backwards, until the - // working range reaches or goes past the boundary we're interested in - do { - containerElement.insertBefore(workingNode, workingNode.previousSibling); - workingRange.moveToElementText(workingNode); - } while ( (comparison = workingRange.compareEndPoints(workingComparisonType, textRange)) > 0 && - workingNode.previousSibling); - - // We've now reached or gone past the boundary of the text range we're interested in - // so have identified the node we want - boundaryNode = workingNode.nextSibling; - - if (comparison == -1 && boundaryNode && dom.isCharacterDataNode(boundaryNode)) { - // This is a character data node (text, comment, cdata). The working range is collapsed at the start of the - // node containing the text range's boundary, so we move the end of the working range to the boundary point - // and measure the length of its text to get the boundary's offset within the node. - workingRange.setEndPoint(isStart ? "EndToStart" : "EndToEnd", textRange); - - - var offset; - - if (/[\r\n]/.test(boundaryNode.data)) { - /* - For the particular case of a boundary within a text node containing line breaks (within a
             element,
            -                for example), we need a slightly complicated approach to get the boundary's offset in IE. The facts:
            -
            -                - Each line break is represented as \r in the text node's data/nodeValue properties
            -                - Each line break is represented as \r\n in the TextRange's 'text' property
            -                - The 'text' property of the TextRange does not contain trailing line breaks
            -
            -                To get round the problem presented by the final fact above, we can use the fact that TextRange's
            -                moveStart() and moveEnd() methods return the actual number of characters moved, which is not necessarily
            -                the same as the number of characters it was instructed to move. The simplest approach is to use this to
            -                store the characters moved when moving both the start and end of the range to the start of the document
            -                body and subtracting the start offset from the end offset (the "move-negative-gazillion" method).
            -                However, this is extremely slow when the document is large and the range is near the end of it. Clearly
            -                doing the mirror image (i.e. moving the range boundaries to the end of the document) has the same
            -                problem.
            -
            -                Another approach that works is to use moveStart() to move the start boundary of the range up to the end
            -                boundary one character at a time and incrementing a counter with the value returned by the moveStart()
            -                call. However, the check for whether the start boundary has reached the end boundary is expensive, so
            -                this method is slow (although unlike "move-negative-gazillion" is largely unaffected by the location of
            -                the range within the document).
            -
            -                The method below is a hybrid of the two methods above. It uses the fact that a string containing the
            -                TextRange's 'text' property with each \r\n converted to a single \r character cannot be longer than the
            -                text of the TextRange, so the start of the range is moved that length initially and then a character at
            -                a time to make up for any trailing line breaks not contained in the 'text' property. This has good
            -                performance in most situations compared to the previous two methods.
            -                */
            -                var tempRange = workingRange.duplicate();
            -                var rangeLength = tempRange.text.replace(/\r\n/g, "\r").length;
            -
            -                offset = tempRange.moveStart("character", rangeLength);
            -                while ( (comparison = tempRange.compareEndPoints("StartToEnd", tempRange)) == -1) {
            -                    offset++;
            -                    tempRange.moveStart("character", 1);
            -                }
            -            } else {
            -                offset = workingRange.text.length;
            -            }
            -            boundaryPosition = new DomPosition(boundaryNode, offset);
            -        } else {
            -
            -
            -            // If the boundary immediately follows a character data node and this is the end boundary, we should favour
            -            // a position within that, and likewise for a start boundary preceding a character data node
            -            previousNode = (isCollapsed || !isStart) && workingNode.previousSibling;
            -            nextNode = (isCollapsed || isStart) && workingNode.nextSibling;
            -
            -
            -
            -            if (nextNode && dom.isCharacterDataNode(nextNode)) {
            -                boundaryPosition = new DomPosition(nextNode, 0);
            -            } else if (previousNode && dom.isCharacterDataNode(previousNode)) {
            -                boundaryPosition = new DomPosition(previousNode, previousNode.length);
            -            } else {
            -                boundaryPosition = new DomPosition(containerElement, dom.getNodeIndex(workingNode));
            -            }
            -        }
            -
            -        // Clean up
            -        workingNode.parentNode.removeChild(workingNode);
            -
            -        return boundaryPosition;
            -    }
            -
            -    // Returns a TextRange representing the boundary of a TextRange expressed as a node and an offset within that node.
            -    // This function started out as an optimized version of code found in Tim Cameron Ryan's IERange
            -    // (http://code.google.com/p/ierange/)
            -    function createBoundaryTextRange(boundaryPosition, isStart) {
            -        var boundaryNode, boundaryParent, boundaryOffset = boundaryPosition.offset;
            -        var doc = dom.getDocument(boundaryPosition.node);
            -        var workingNode, childNodes, workingRange = doc.body.createTextRange();
            -        var nodeIsDataNode = dom.isCharacterDataNode(boundaryPosition.node);
            -
            -        if (nodeIsDataNode) {
            -            boundaryNode = boundaryPosition.node;
            -            boundaryParent = boundaryNode.parentNode;
            -        } else {
            -            childNodes = boundaryPosition.node.childNodes;
            -            boundaryNode = (boundaryOffset < childNodes.length) ? childNodes[boundaryOffset] : null;
            -            boundaryParent = boundaryPosition.node;
            -        }
            -
            -        // Position the range immediately before the node containing the boundary
            -        workingNode = doc.createElement("span");
            -
            -        // Making the working element non-empty element persuades IE to consider the TextRange boundary to be within the
            -        // element rather than immediately before or after it, which is what we want
            -        workingNode.innerHTML = "&#feff;";
            -
            -        // insertBefore is supposed to work like appendChild if the second parameter is null. However, a bug report
            -        // for IERange suggests that it can crash the browser: http://code.google.com/p/ierange/issues/detail?id=12
            -        if (boundaryNode) {
            -            boundaryParent.insertBefore(workingNode, boundaryNode);
            -        } else {
            -            boundaryParent.appendChild(workingNode);
            -        }
            -
            -        workingRange.moveToElementText(workingNode);
            -        workingRange.collapse(!isStart);
            -
            -        // Clean up
            -        boundaryParent.removeChild(workingNode);
            -
            -        // Move the working range to the text offset, if required
            -        if (nodeIsDataNode) {
            -            workingRange[isStart ? "moveStart" : "moveEnd"]("character", boundaryOffset);
            -        }
            -
            -        return workingRange;
            -    }
            -
            -    /*----------------------------------------------------------------------------------------------------------------*/
            -
            -    if (api.features.implementsDomRange && (!api.features.implementsTextRange || !api.config.preferTextRange)) {
            -        // This is a wrapper around the browser's native DOM Range. It has two aims:
            -        // - Provide workarounds for specific browser bugs
            -        // - provide convenient extensions, which are inherited from Rangy's DomRange
            -
            -        (function() {
            -            var rangeProto;
            -            var rangeProperties = DomRange.rangeProperties;
            -            var canSetRangeStartAfterEnd;
            -
            -            function updateRangeProperties(range) {
            -                var i = rangeProperties.length, prop;
            -                while (i--) {
            -                    prop = rangeProperties[i];
            -                    range[prop] = range.nativeRange[prop];
            -                }
            -            }
            -
            -            function updateNativeRange(range, startContainer, startOffset, endContainer,endOffset) {
            -                var startMoved = (range.startContainer !== startContainer || range.startOffset != startOffset);
            -                var endMoved = (range.endContainer !== endContainer || range.endOffset != endOffset);
            -
            -                // Always set both boundaries for the benefit of IE9 (see issue 35)
            -                if (startMoved || endMoved) {
            -                    range.setEnd(endContainer, endOffset);
            -                    range.setStart(startContainer, startOffset);
            -                }
            -            }
            -
            -            function detach(range) {
            -                range.nativeRange.detach();
            -                range.detached = true;
            -                var i = rangeProperties.length, prop;
            -                while (i--) {
            -                    prop = rangeProperties[i];
            -                    range[prop] = null;
            -                }
            -            }
            -
            -            var createBeforeAfterNodeSetter;
            -
            -            WrappedRange = function(range) {
            -                if (!range) {
            -                    throw new Error("Range must be specified");
            -                }
            -                this.nativeRange = range;
            -                updateRangeProperties(this);
            -            };
            -
            -            DomRange.createPrototypeRange(WrappedRange, updateNativeRange, detach);
            -
            -            rangeProto = WrappedRange.prototype;
            -
            -            rangeProto.selectNode = function(node) {
            -                this.nativeRange.selectNode(node);
            -                updateRangeProperties(this);
            -            };
            -
            -            rangeProto.deleteContents = function() {
            -                this.nativeRange.deleteContents();
            -                updateRangeProperties(this);
            -            };
            -
            -            rangeProto.extractContents = function() {
            -                var frag = this.nativeRange.extractContents();
            -                updateRangeProperties(this);
            -                return frag;
            -            };
            -
            -            rangeProto.cloneContents = function() {
            -                return this.nativeRange.cloneContents();
            -            };
            -
            -            // TODO: Until I can find a way to programmatically trigger the Firefox bug (apparently long-standing, still
            -            // present in 3.6.8) that throws "Index or size is negative or greater than the allowed amount" for
            -            // insertNode in some circumstances, all browsers will have to use the Rangy's own implementation of
            -            // insertNode, which works but is almost certainly slower than the native implementation.
            -/*
            -            rangeProto.insertNode = function(node) {
            -                this.nativeRange.insertNode(node);
            -                updateRangeProperties(this);
            -            };
            -*/
            -
            -            rangeProto.surroundContents = function(node) {
            -                this.nativeRange.surroundContents(node);
            -                updateRangeProperties(this);
            -            };
            -
            -            rangeProto.collapse = function(isStart) {
            -                this.nativeRange.collapse(isStart);
            -                updateRangeProperties(this);
            -            };
            -
            -            rangeProto.cloneRange = function() {
            -                return new WrappedRange(this.nativeRange.cloneRange());
            -            };
            -
            -            rangeProto.refresh = function() {
            -                updateRangeProperties(this);
            -            };
            -
            -            rangeProto.toString = function() {
            -                return this.nativeRange.toString();
            -            };
            -
            -            // Create test range and node for feature detection
            -
            -            var testTextNode = document.createTextNode("test");
            -            dom.getBody(document).appendChild(testTextNode);
            -            var range = document.createRange();
            -
            -            /*--------------------------------------------------------------------------------------------------------*/
            -
            -            // Test for Firefox 2 bug that prevents moving the start of a Range to a point after its current end and
            -            // correct for it
            -
            -            range.setStart(testTextNode, 0);
            -            range.setEnd(testTextNode, 0);
            -
            -            try {
            -                range.setStart(testTextNode, 1);
            -                canSetRangeStartAfterEnd = true;
            -
            -                rangeProto.setStart = function(node, offset) {
            -                    this.nativeRange.setStart(node, offset);
            -                    updateRangeProperties(this);
            -                };
            -
            -                rangeProto.setEnd = function(node, offset) {
            -                    this.nativeRange.setEnd(node, offset);
            -                    updateRangeProperties(this);
            -                };
            -
            -                createBeforeAfterNodeSetter = function(name) {
            -                    return function(node) {
            -                        this.nativeRange[name](node);
            -                        updateRangeProperties(this);
            -                    };
            -                };
            -
            -            } catch(ex) {
            -
            -
            -                canSetRangeStartAfterEnd = false;
            -
            -                rangeProto.setStart = function(node, offset) {
            -                    try {
            -                        this.nativeRange.setStart(node, offset);
            -                    } catch (ex) {
            -                        this.nativeRange.setEnd(node, offset);
            -                        this.nativeRange.setStart(node, offset);
            -                    }
            -                    updateRangeProperties(this);
            -                };
            -
            -                rangeProto.setEnd = function(node, offset) {
            -                    try {
            -                        this.nativeRange.setEnd(node, offset);
            -                    } catch (ex) {
            -                        this.nativeRange.setStart(node, offset);
            -                        this.nativeRange.setEnd(node, offset);
            -                    }
            -                    updateRangeProperties(this);
            -                };
            -
            -                createBeforeAfterNodeSetter = function(name, oppositeName) {
            -                    return function(node) {
            -                        try {
            -                            this.nativeRange[name](node);
            -                        } catch (ex) {
            -                            this.nativeRange[oppositeName](node);
            -                            this.nativeRange[name](node);
            -                        }
            -                        updateRangeProperties(this);
            -                    };
            -                };
            -            }
            -
            -            rangeProto.setStartBefore = createBeforeAfterNodeSetter("setStartBefore", "setEndBefore");
            -            rangeProto.setStartAfter = createBeforeAfterNodeSetter("setStartAfter", "setEndAfter");
            -            rangeProto.setEndBefore = createBeforeAfterNodeSetter("setEndBefore", "setStartBefore");
            -            rangeProto.setEndAfter = createBeforeAfterNodeSetter("setEndAfter", "setStartAfter");
            -
            -            /*--------------------------------------------------------------------------------------------------------*/
            -
            -            // Test for and correct Firefox 2 behaviour with selectNodeContents on text nodes: it collapses the range to
            -            // the 0th character of the text node
            -            range.selectNodeContents(testTextNode);
            -            if (range.startContainer == testTextNode && range.endContainer == testTextNode &&
            -                    range.startOffset == 0 && range.endOffset == testTextNode.length) {
            -                rangeProto.selectNodeContents = function(node) {
            -                    this.nativeRange.selectNodeContents(node);
            -                    updateRangeProperties(this);
            -                };
            -            } else {
            -                rangeProto.selectNodeContents = function(node) {
            -                    this.setStart(node, 0);
            -                    this.setEnd(node, DomRange.getEndOffset(node));
            -                };
            -            }
            -
            -            /*--------------------------------------------------------------------------------------------------------*/
            -
            -            // Test for WebKit bug that has the beahviour of compareBoundaryPoints round the wrong way for constants
            -            // START_TO_END and END_TO_START: https://bugs.webkit.org/show_bug.cgi?id=20738
            -
            -            range.selectNodeContents(testTextNode);
            -            range.setEnd(testTextNode, 3);
            -
            -            var range2 = document.createRange();
            -            range2.selectNodeContents(testTextNode);
            -            range2.setEnd(testTextNode, 4);
            -            range2.setStart(testTextNode, 2);
            -
            -            if (range.compareBoundaryPoints(range.START_TO_END, range2) == -1 &
            -                    range.compareBoundaryPoints(range.END_TO_START, range2) == 1) {
            -                // This is the wrong way round, so correct for it
            -
            -
            -                rangeProto.compareBoundaryPoints = function(type, range) {
            -                    range = range.nativeRange || range;
            -                    if (type == range.START_TO_END) {
            -                        type = range.END_TO_START;
            -                    } else if (type == range.END_TO_START) {
            -                        type = range.START_TO_END;
            -                    }
            -                    return this.nativeRange.compareBoundaryPoints(type, range);
            -                };
            -            } else {
            -                rangeProto.compareBoundaryPoints = function(type, range) {
            -                    return this.nativeRange.compareBoundaryPoints(type, range.nativeRange || range);
            -                };
            -            }
            -
            -            /*--------------------------------------------------------------------------------------------------------*/
            -
            -            // Test for existence of createContextualFragment and delegate to it if it exists
            -            if (api.util.isHostMethod(range, "createContextualFragment")) {
            -                rangeProto.createContextualFragment = function(fragmentStr) {
            -                    return this.nativeRange.createContextualFragment(fragmentStr);
            -                };
            -            }
            -
            -            /*--------------------------------------------------------------------------------------------------------*/
            -
            -            // Clean up
            -            dom.getBody(document).removeChild(testTextNode);
            -            range.detach();
            -            range2.detach();
            -        })();
            -
            -        api.createNativeRange = function(doc) {
            -            doc = doc || document;
            -            return doc.createRange();
            -        };
            -    } else if (api.features.implementsTextRange) {
            -        // This is a wrapper around a TextRange, providing full DOM Range functionality using rangy's DomRange as a
            -        // prototype
            -
            -        WrappedRange = function(textRange) {
            -            this.textRange = textRange;
            -            this.refresh();
            -        };
            -
            -        WrappedRange.prototype = new DomRange(document);
            -
            -        WrappedRange.prototype.refresh = function() {
            -            var start, end;
            -
            -            // TextRange's parentElement() method cannot be trusted. getTextRangeContainerElement() works around that.
            -            var rangeContainerElement = getTextRangeContainerElement(this.textRange);
            -
            -            if (textRangeIsCollapsed(this.textRange)) {
            -                end = start = getTextRangeBoundaryPosition(this.textRange, rangeContainerElement, true, true);
            -            } else {
            -
            -                start = getTextRangeBoundaryPosition(this.textRange, rangeContainerElement, true, false);
            -                end = getTextRangeBoundaryPosition(this.textRange, rangeContainerElement, false, false);
            -            }
            -
            -            this.setStart(start.node, start.offset);
            -            this.setEnd(end.node, end.offset);
            -        };
            -
            -        DomRange.copyComparisonConstants(WrappedRange);
            -
            -        // Add WrappedRange as the Range property of the global object to allow expression like Range.END_TO_END to work
            -        var globalObj = (function() { return this; })();
            -        if (typeof globalObj.Range == "undefined") {
            -            globalObj.Range = WrappedRange;
            -        }
            -
            -        api.createNativeRange = function(doc) {
            -            doc = doc || document;
            -            return doc.body.createTextRange();
            -        };
            -    }
            -
            -    if (api.features.implementsTextRange) {
            -        WrappedRange.rangeToTextRange = function(range) {
            -            if (range.collapsed) {
            -                var tr = createBoundaryTextRange(new DomPosition(range.startContainer, range.startOffset), true);
            -
            -
            -
            -                return tr;
            -
            -                //return createBoundaryTextRange(new DomPosition(range.startContainer, range.startOffset), true);
            -            } else {
            -                var startRange = createBoundaryTextRange(new DomPosition(range.startContainer, range.startOffset), true);
            -                var endRange = createBoundaryTextRange(new DomPosition(range.endContainer, range.endOffset), false);
            -                var textRange = dom.getDocument(range.startContainer).body.createTextRange();
            -                textRange.setEndPoint("StartToStart", startRange);
            -                textRange.setEndPoint("EndToEnd", endRange);
            -                return textRange;
            -            }
            -        };
            -    }
            -
            -    WrappedRange.prototype.getName = function() {
            -        return "WrappedRange";
            -    };
            -
            -    api.WrappedRange = WrappedRange;
            -
            -    api.createRange = function(doc) {
            -        doc = doc || document;
            -        return new WrappedRange(api.createNativeRange(doc));
            -    };
            -
            -    api.createRangyRange = function(doc) {
            -        doc = doc || document;
            -        return new DomRange(doc);
            -    };
            -
            -    api.createIframeRange = function(iframeEl) {
            -        return api.createRange(dom.getIframeDocument(iframeEl));
            -    };
            -
            -    api.createIframeRangyRange = function(iframeEl) {
            -        return api.createRangyRange(dom.getIframeDocument(iframeEl));
            -    };
            -
            -    api.addCreateMissingNativeApiListener(function(win) {
            -        var doc = win.document;
            -        if (typeof doc.createRange == "undefined") {
            -            doc.createRange = function() {
            -                return api.createRange(this);
            -            };
            -        }
            -        doc = win = null;
            -    });
            -});rangy.createModule("WrappedSelection", function(api, module) {
            -    // This will create a selection object wrapper that follows the Selection object found in the WHATWG draft DOM Range
            -    // spec (http://html5.org/specs/dom-range.html)
            -
            -    api.requireModules( ["DomUtil", "DomRange", "WrappedRange"] );
            -
            -    api.config.checkSelectionRanges = true;
            -
            -    var BOOLEAN = "boolean",
            -        windowPropertyName = "_rangySelection",
            -        dom = api.dom,
            -        util = api.util,
            -        DomRange = api.DomRange,
            -        WrappedRange = api.WrappedRange,
            -        DOMException = api.DOMException,
            -        DomPosition = dom.DomPosition,
            -        getSelection,
            -        selectionIsCollapsed,
            -        CONTROL = "Control";
            -
            -
            -
            -    function getWinSelection(winParam) {
            -        return (winParam || window).getSelection();
            -    }
            -
            -    function getDocSelection(winParam) {
            -        return (winParam || window).document.selection;
            -    }
            -
            -    // Test for the Range/TextRange and Selection features required
            -    // Test for ability to retrieve selection
            -    var implementsWinGetSelection = api.util.isHostMethod(window, "getSelection"),
            -        implementsDocSelection = api.util.isHostObject(document, "selection");
            -
            -    var useDocumentSelection = implementsDocSelection && (!implementsWinGetSelection || api.config.preferTextRange);
            -
            -    if (useDocumentSelection) {
            -        getSelection = getDocSelection;
            -        api.isSelectionValid = function(winParam) {
            -            var doc = (winParam || window).document, nativeSel = doc.selection;
            -
            -            // Check whether the selection TextRange is actually contained within the correct document
            -            return (nativeSel.type != "None" || dom.getDocument(nativeSel.createRange().parentElement()) == doc);
            -        };
            -    } else if (implementsWinGetSelection) {
            -        getSelection = getWinSelection;
            -        api.isSelectionValid = function() {
            -            return true;
            -        };
            -    } else {
            -        module.fail("Neither document.selection or window.getSelection() detected.");
            -    }
            -
            -    api.getNativeSelection = getSelection;
            -
            -    var testSelection = getSelection();
            -    var testRange = api.createNativeRange(document);
            -    var body = dom.getBody(document);
            -
            -    // Obtaining a range from a selection
            -    var selectionHasAnchorAndFocus = util.areHostObjects(testSelection, ["anchorNode", "focusNode"] &&
            -                                     util.areHostProperties(testSelection, ["anchorOffset", "focusOffset"]));
            -    api.features.selectionHasAnchorAndFocus = selectionHasAnchorAndFocus;
            -
            -    // Test for existence of native selection extend() method
            -    var selectionHasExtend = util.isHostMethod(testSelection, "extend");
            -    api.features.selectionHasExtend = selectionHasExtend;
            -
            -    // Test if rangeCount exists
            -    var selectionHasRangeCount = (typeof testSelection.rangeCount == "number");
            -    api.features.selectionHasRangeCount = selectionHasRangeCount;
            -
            -    var selectionSupportsMultipleRanges = false;
            -    var collapsedNonEditableSelectionsSupported = true;
            -
            -    if (util.areHostMethods(testSelection, ["addRange", "getRangeAt", "removeAllRanges"]) &&
            -            typeof testSelection.rangeCount == "number" && api.features.implementsDomRange) {
            -
            -        (function() {
            -            var iframe = document.createElement("iframe");
            -            body.appendChild(iframe);
            -
            -            var iframeDoc = dom.getIframeDocument(iframe);
            -            iframeDoc.open();
            -            iframeDoc.write("12");
            -            iframeDoc.close();
            -
            -            var sel = dom.getIframeWindow(iframe).getSelection();
            -            var docEl = iframeDoc.documentElement;
            -            var iframeBody = docEl.lastChild, textNode = iframeBody.firstChild;
            -
            -            // Test whether the native selection will allow a collapsed selection within a non-editable element
            -            var r1 = iframeDoc.createRange();
            -            r1.setStart(textNode, 1);
            -            r1.collapse(true);
            -            sel.addRange(r1);
            -            collapsedNonEditableSelectionsSupported = (sel.rangeCount == 1);
            -            sel.removeAllRanges();
            -
            -            // Test whether the native selection is capable of supporting multiple ranges
            -            var r2 = r1.cloneRange();
            -            r1.setStart(textNode, 0);
            -            r2.setEnd(textNode, 2);
            -            sel.addRange(r1);
            -            sel.addRange(r2);
            -
            -            selectionSupportsMultipleRanges = (sel.rangeCount == 2);
            -
            -            // Clean up
            -            r1.detach();
            -            r2.detach();
            -
            -            body.removeChild(iframe);
            -        })();
            -    }
            -
            -    api.features.selectionSupportsMultipleRanges = selectionSupportsMultipleRanges;
            -    api.features.collapsedNonEditableSelectionsSupported = collapsedNonEditableSelectionsSupported;
            -
            -    // ControlRanges
            -    var implementsControlRange = false, testControlRange;
            -
            -    if (body && util.isHostMethod(body, "createControlRange")) {
            -        testControlRange = body.createControlRange();
            -        if (util.areHostProperties(testControlRange, ["item", "add"])) {
            -            implementsControlRange = true;
            -        }
            -    }
            -    api.features.implementsControlRange = implementsControlRange;
            -
            -    // Selection collapsedness
            -    if (selectionHasAnchorAndFocus) {
            -        selectionIsCollapsed = function(sel) {
            -            return sel.anchorNode === sel.focusNode && sel.anchorOffset === sel.focusOffset;
            -        };
            -    } else {
            -        selectionIsCollapsed = function(sel) {
            -            return sel.rangeCount ? sel.getRangeAt(sel.rangeCount - 1).collapsed : false;
            -        };
            -    }
            -
            -    function updateAnchorAndFocusFromRange(sel, range, backwards) {
            -        var anchorPrefix = backwards ? "end" : "start", focusPrefix = backwards ? "start" : "end";
            -        sel.anchorNode = range[anchorPrefix + "Container"];
            -        sel.anchorOffset = range[anchorPrefix + "Offset"];
            -        sel.focusNode = range[focusPrefix + "Container"];
            -        sel.focusOffset = range[focusPrefix + "Offset"];
            -    }
            -
            -    function updateAnchorAndFocusFromNativeSelection(sel) {
            -        var nativeSel = sel.nativeSelection;
            -        sel.anchorNode = nativeSel.anchorNode;
            -        sel.anchorOffset = nativeSel.anchorOffset;
            -        sel.focusNode = nativeSel.focusNode;
            -        sel.focusOffset = nativeSel.focusOffset;
            -    }
            -
            -    function updateEmptySelection(sel) {
            -        sel.anchorNode = sel.focusNode = null;
            -        sel.anchorOffset = sel.focusOffset = 0;
            -        sel.rangeCount = 0;
            -        sel.isCollapsed = true;
            -        sel._ranges.length = 0;
            -    }
            -
            -    function getNativeRange(range) {
            -        var nativeRange;
            -        if (range instanceof DomRange) {
            -            nativeRange = range._selectionNativeRange;
            -            if (!nativeRange) {
            -                nativeRange = api.createNativeRange(dom.getDocument(range.startContainer));
            -                nativeRange.setEnd(range.endContainer, range.endOffset);
            -                nativeRange.setStart(range.startContainer, range.startOffset);
            -                range._selectionNativeRange = nativeRange;
            -                range.attachListener("detach", function() {
            -
            -                    this._selectionNativeRange = null;
            -                });
            -            }
            -        } else if (range instanceof WrappedRange) {
            -            nativeRange = range.nativeRange;
            -        } else if (api.features.implementsDomRange && (range instanceof dom.getWindow(range.startContainer).Range)) {
            -            nativeRange = range;
            -        }
            -        return nativeRange;
            -    }
            -
            -    function rangeContainsSingleElement(rangeNodes) {
            -        if (!rangeNodes.length || rangeNodes[0].nodeType != 1) {
            -            return false;
            -        }
            -        for (var i = 1, len = rangeNodes.length; i < len; ++i) {
            -            if (!dom.isAncestorOf(rangeNodes[0], rangeNodes[i])) {
            -                return false;
            -            }
            -        }
            -        return true;
            -    }
            -
            -    function getSingleElementFromRange(range) {
            -        var nodes = range.getNodes();
            -        if (!rangeContainsSingleElement(nodes)) {
            -            throw new Error("getSingleElementFromRange: range " + range.inspect() + " did not consist of a single element");
            -        }
            -        return nodes[0];
            -    }
            -
            -    function isTextRange(range) {
            -        return !!range && typeof range.text != "undefined";
            -    }
            -
            -    function updateFromTextRange(sel, range) {
            -        // Create a Range from the selected TextRange
            -        var wrappedRange = new WrappedRange(range);
            -        sel._ranges = [wrappedRange];
            -
            -        updateAnchorAndFocusFromRange(sel, wrappedRange, false);
            -        sel.rangeCount = 1;
            -        sel.isCollapsed = wrappedRange.collapsed;
            -    }
            -
            -    function updateControlSelection(sel) {
            -        // Update the wrapped selection based on what's now in the native selection
            -        sel._ranges.length = 0;
            -        if (sel.docSelection.type == "None") {
            -            updateEmptySelection(sel);
            -        } else {
            -            var controlRange = sel.docSelection.createRange();
            -            if (isTextRange(controlRange)) {
            -                // This case (where the selection type is "Control" and calling createRange() on the selection returns
            -                // a TextRange) can happen in IE 9. It happens, for example, when all elements in the selected
            -                // ControlRange have been removed from the ControlRange and removed from the document.
            -                updateFromTextRange(sel, controlRange);
            -            } else {
            -                sel.rangeCount = controlRange.length;
            -                var range, doc = dom.getDocument(controlRange.item(0));
            -                for (var i = 0; i < sel.rangeCount; ++i) {
            -                    range = api.createRange(doc);
            -                    range.selectNode(controlRange.item(i));
            -                    sel._ranges.push(range);
            -                }
            -                sel.isCollapsed = sel.rangeCount == 1 && sel._ranges[0].collapsed;
            -                updateAnchorAndFocusFromRange(sel, sel._ranges[sel.rangeCount - 1], false);
            -            }
            -        }
            -    }
            -
            -    function addRangeToControlSelection(sel, range) {
            -        var controlRange = sel.docSelection.createRange();
            -        var rangeElement = getSingleElementFromRange(range);
            -
            -        // Create a new ControlRange containing all the elements in the selected ControlRange plus the element
            -        // contained by the supplied range
            -        var doc = dom.getDocument(controlRange.item(0));
            -        var newControlRange = dom.getBody(doc).createControlRange();
            -        for (var i = 0, len = controlRange.length; i < len; ++i) {
            -            newControlRange.add(controlRange.item(i));
            -        }
            -        try {
            -            newControlRange.add(rangeElement);
            -        } catch (ex) {
            -            throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)");
            -        }
            -        newControlRange.select();
            -
            -        // Update the wrapped selection based on what's now in the native selection
            -        updateControlSelection(sel);
            -    }
            -
            -    var getSelectionRangeAt;
            -
            -    if (util.isHostMethod(testSelection,  "getRangeAt")) {
            -        getSelectionRangeAt = function(sel, index) {
            -            try {
            -                return sel.getRangeAt(index);
            -            } catch(ex) {
            -                return null;
            -            }
            -        };
            -    } else if (selectionHasAnchorAndFocus) {
            -        getSelectionRangeAt = function(sel) {
            -            var doc = dom.getDocument(sel.anchorNode);
            -            var range = api.createRange(doc);
            -            range.setStart(sel.anchorNode, sel.anchorOffset);
            -            range.setEnd(sel.focusNode, sel.focusOffset);
            -
            -            // Handle the case when the selection was selected backwards (from the end to the start in the
            -            // document)
            -            if (range.collapsed !== this.isCollapsed) {
            -                range.setStart(sel.focusNode, sel.focusOffset);
            -                range.setEnd(sel.anchorNode, sel.anchorOffset);
            -            }
            -
            -            return range;
            -        };
            -    }
            -
            -    /**
            -     * @constructor
            -     */
            -    function WrappedSelection(selection, docSelection, win) {
            -        this.nativeSelection = selection;
            -        this.docSelection = docSelection;
            -        this._ranges = [];
            -        this.win = win;
            -        this.refresh();
            -    }
            -
            -    api.getSelection = function(win) {
            -        win = win || window;
            -        var sel = win[windowPropertyName];
            -        var nativeSel = getSelection(win), docSel = implementsDocSelection ? getDocSelection(win) : null;
            -        if (sel) {
            -            sel.nativeSelection = nativeSel;
            -            sel.docSelection = docSel;
            -            sel.refresh(win);
            -        } else {
            -            sel = new WrappedSelection(nativeSel, docSel, win);
            -            win[windowPropertyName] = sel;
            -        }
            -        return sel;
            -    };
            -
            -    api.getIframeSelection = function(iframeEl) {
            -        return api.getSelection(dom.getIframeWindow(iframeEl));
            -    };
            -
            -    var selProto = WrappedSelection.prototype;
            -
            -    function createControlSelection(sel, ranges) {
            -        // Ensure that the selection becomes of type "Control"
            -        var doc = dom.getDocument(ranges[0].startContainer);
            -        var controlRange = dom.getBody(doc).createControlRange();
            -        for (var i = 0, el; i < rangeCount; ++i) {
            -            el = getSingleElementFromRange(ranges[i]);
            -            try {
            -                controlRange.add(el);
            -            } catch (ex) {
            -                throw new Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)");
            -            }
            -        }
            -        controlRange.select();
            -
            -        // Update the wrapped selection based on what's now in the native selection
            -        updateControlSelection(sel);
            -    }
            -
            -    // Selecting a range
            -    if (!useDocumentSelection && selectionHasAnchorAndFocus && util.areHostMethods(testSelection, ["removeAllRanges", "addRange"])) {
            -        selProto.removeAllRanges = function() {
            -            this.nativeSelection.removeAllRanges();
            -            updateEmptySelection(this);
            -        };
            -
            -        var addRangeBackwards = function(sel, range) {
            -            var doc = DomRange.getRangeDocument(range);
            -            var endRange = api.createRange(doc);
            -            endRange.collapseToPoint(range.endContainer, range.endOffset);
            -            sel.nativeSelection.addRange(getNativeRange(endRange));
            -            sel.nativeSelection.extend(range.startContainer, range.startOffset);
            -            sel.refresh();
            -        };
            -
            -        if (selectionHasRangeCount) {
            -            selProto.addRange = function(range, backwards) {
            -                if (implementsControlRange && implementsDocSelection && this.docSelection.type == CONTROL) {
            -                    addRangeToControlSelection(this, range);
            -                } else {
            -                    if (backwards && selectionHasExtend) {
            -                        addRangeBackwards(this, range);
            -                    } else {
            -                        var previousRangeCount;
            -                        if (selectionSupportsMultipleRanges) {
            -                            previousRangeCount = this.rangeCount;
            -                        } else {
            -                            this.removeAllRanges();
            -                            previousRangeCount = 0;
            -                        }
            -                        this.nativeSelection.addRange(getNativeRange(range));
            -
            -                        // Check whether adding the range was successful
            -                        this.rangeCount = this.nativeSelection.rangeCount;
            -
            -                        if (this.rangeCount == previousRangeCount + 1) {
            -                            // The range was added successfully
            -
            -                            // Check whether the range that we added to the selection is reflected in the last range extracted from
            -                            // the selection
            -                            if (api.config.checkSelectionRanges) {
            -                                var nativeRange = getSelectionRangeAt(this.nativeSelection, this.rangeCount - 1);
            -                                if (nativeRange && !DomRange.rangesEqual(nativeRange, range)) {
            -                                    // Happens in WebKit with, for example, a selection placed at the start of a text node
            -                                    range = new WrappedRange(nativeRange);
            -                                }
            -                            }
            -                            this._ranges[this.rangeCount - 1] = range;
            -                            updateAnchorAndFocusFromRange(this, range, selectionIsBackwards(this.nativeSelection));
            -                            this.isCollapsed = selectionIsCollapsed(this);
            -                        } else {
            -                            // The range was not added successfully. The simplest thing is to refresh
            -                            this.refresh();
            -                        }
            -                    }
            -                }
            -            };
            -        } else {
            -            selProto.addRange = function(range, backwards) {
            -                if (backwards && selectionHasExtend) {
            -                    addRangeBackwards(this, range);
            -                } else {
            -                    this.nativeSelection.addRange(getNativeRange(range));
            -                    this.refresh();
            -                }
            -            };
            -        }
            -
            -        selProto.setRanges = function(ranges) {
            -            if (implementsControlRange && ranges.length > 1) {
            -                createControlSelection(this, ranges);
            -            } else {
            -                this.removeAllRanges();
            -                for (var i = 0, len = ranges.length; i < len; ++i) {
            -                    this.addRange(ranges[i]);
            -                }
            -            }
            -        };
            -    } else if (util.isHostMethod(testSelection, "empty") && util.isHostMethod(testRange, "select") &&
            -               implementsControlRange && useDocumentSelection) {
            -
            -        selProto.removeAllRanges = function() {
            -            // Added try/catch as fix for issue #21
            -            try {
            -                this.docSelection.empty();
            -
            -                // Check for empty() not working (issue #24)
            -                if (this.docSelection.type != "None") {
            -                    // Work around failure to empty a control selection by instead selecting a TextRange and then
            -                    // calling empty()
            -                    var doc;
            -                    if (this.anchorNode) {
            -                        doc = dom.getDocument(this.anchorNode);
            -                    } else if (this.docSelection.type == CONTROL) {
            -                        var controlRange = this.docSelection.createRange();
            -                        if (controlRange.length) {
            -                            doc = dom.getDocument(controlRange.item(0)).body.createTextRange();
            -                        }
            -                    }
            -                    if (doc) {
            -                        var textRange = doc.body.createTextRange();
            -                        textRange.select();
            -                        this.docSelection.empty();
            -                    }
            -                }
            -            } catch(ex) {}
            -            updateEmptySelection(this);
            -        };
            -
            -        selProto.addRange = function(range) {
            -            if (this.docSelection.type == CONTROL) {
            -                addRangeToControlSelection(this, range);
            -            } else {
            -                WrappedRange.rangeToTextRange(range).select();
            -                this._ranges[0] = range;
            -                this.rangeCount = 1;
            -                this.isCollapsed = this._ranges[0].collapsed;
            -                updateAnchorAndFocusFromRange(this, range, false);
            -            }
            -        };
            -
            -        selProto.setRanges = function(ranges) {
            -            this.removeAllRanges();
            -            var rangeCount = ranges.length;
            -            if (rangeCount > 1) {
            -                createControlSelection(this, ranges);
            -            } else if (rangeCount) {
            -                this.addRange(ranges[0]);
            -            }
            -        };
            -    } else {
            -        module.fail("No means of selecting a Range or TextRange was found");
            -        return false;
            -    }
            -
            -    selProto.getRangeAt = function(index) {
            -        if (index < 0 || index >= this.rangeCount) {
            -            throw new DOMException("INDEX_SIZE_ERR");
            -        } else {
            -            return this._ranges[index];
            -        }
            -    };
            -
            -    var refreshSelection;
            -
            -    if (useDocumentSelection) {
            -        refreshSelection = function(sel) {
            -            var range;
            -            if (api.isSelectionValid(sel.win)) {
            -                range = sel.docSelection.createRange();
            -            } else {
            -                range = dom.getBody(sel.win.document).createTextRange();
            -                range.collapse(true);
            -            }
            -
            -
            -            if (sel.docSelection.type == CONTROL) {
            -                updateControlSelection(sel);
            -            } else if (isTextRange(range)) {
            -                updateFromTextRange(sel, range);
            -            } else {
            -                updateEmptySelection(sel);
            -            }
            -        };
            -    } else if (util.isHostMethod(testSelection, "getRangeAt") && typeof testSelection.rangeCount == "number") {
            -        refreshSelection = function(sel) {
            -            if (implementsControlRange && implementsDocSelection && sel.docSelection.type == CONTROL) {
            -                updateControlSelection(sel);
            -            } else {
            -                sel._ranges.length = sel.rangeCount = sel.nativeSelection.rangeCount;
            -                if (sel.rangeCount) {
            -                    for (var i = 0, len = sel.rangeCount; i < len; ++i) {
            -                        sel._ranges[i] = new api.WrappedRange(sel.nativeSelection.getRangeAt(i));
            -                    }
            -                    updateAnchorAndFocusFromRange(sel, sel._ranges[sel.rangeCount - 1], selectionIsBackwards(sel.nativeSelection));
            -                    sel.isCollapsed = selectionIsCollapsed(sel);
            -                } else {
            -                    updateEmptySelection(sel);
            -                }
            -            }
            -        };
            -    } else if (selectionHasAnchorAndFocus && typeof testSelection.isCollapsed == BOOLEAN && typeof testRange.collapsed == BOOLEAN && api.features.implementsDomRange) {
            -        refreshSelection = function(sel) {
            -            var range, nativeSel = sel.nativeSelection;
            -            if (nativeSel.anchorNode) {
            -                range = getSelectionRangeAt(nativeSel, 0);
            -                sel._ranges = [range];
            -                sel.rangeCount = 1;
            -                updateAnchorAndFocusFromNativeSelection(sel);
            -                sel.isCollapsed = selectionIsCollapsed(sel);
            -            } else {
            -                updateEmptySelection(sel);
            -            }
            -        };
            -    } else {
            -        module.fail("No means of obtaining a Range or TextRange from the user's selection was found");
            -        return false;
            -    }
            -
            -    selProto.refresh = function(checkForChanges) {
            -        var oldRanges = checkForChanges ? this._ranges.slice(0) : null;
            -        refreshSelection(this);
            -        if (checkForChanges) {
            -            var i = oldRanges.length;
            -            if (i != this._ranges.length) {
            -                return false;
            -            }
            -            while (i--) {
            -                if (!DomRange.rangesEqual(oldRanges[i], this._ranges[i])) {
            -                    return false;
            -                }
            -            }
            -            return true;
            -        }
            -    };
            -
            -    // Removal of a single range
            -    var removeRangeManually = function(sel, range) {
            -        var ranges = sel.getAllRanges(), removed = false;
            -        sel.removeAllRanges();
            -        for (var i = 0, len = ranges.length; i < len; ++i) {
            -            if (removed || range !== ranges[i]) {
            -                sel.addRange(ranges[i]);
            -            } else {
            -                // According to the draft WHATWG Range spec, the same range may be added to the selection multiple
            -                // times. removeRange should only remove the first instance, so the following ensures only the first
            -                // instance is removed
            -                removed = true;
            -            }
            -        }
            -        if (!sel.rangeCount) {
            -            updateEmptySelection(sel);
            -        }
            -    };
            -
            -    if (implementsControlRange) {
            -        selProto.removeRange = function(range) {
            -            if (this.docSelection.type == CONTROL) {
            -                var controlRange = this.docSelection.createRange();
            -                var rangeElement = getSingleElementFromRange(range);
            -
            -                // Create a new ControlRange containing all the elements in the selected ControlRange minus the
            -                // element contained by the supplied range
            -                var doc = dom.getDocument(controlRange.item(0));
            -                var newControlRange = dom.getBody(doc).createControlRange();
            -                var el, removed = false;
            -                for (var i = 0, len = controlRange.length; i < len; ++i) {
            -                    el = controlRange.item(i);
            -                    if (el !== rangeElement || removed) {
            -                        newControlRange.add(controlRange.item(i));
            -                    } else {
            -                        removed = true;
            -                    }
            -                }
            -                newControlRange.select();
            -
            -                // Update the wrapped selection based on what's now in the native selection
            -                updateControlSelection(this);
            -            } else {
            -                removeRangeManually(this, range);
            -            }
            -        };
            -    } else {
            -        selProto.removeRange = function(range) {
            -            removeRangeManually(this, range);
            -        };
            -    }
            -
            -    // Detecting if a selection is backwards
            -    var selectionIsBackwards;
            -    if (!useDocumentSelection && selectionHasAnchorAndFocus && api.features.implementsDomRange) {
            -        selectionIsBackwards = function(sel) {
            -            var backwards = false;
            -            if (sel.anchorNode) {
            -                backwards = (dom.comparePoints(sel.anchorNode, sel.anchorOffset, sel.focusNode, sel.focusOffset) == 1);
            -            }
            -            return backwards;
            -        };
            -
            -        selProto.isBackwards = function() {
            -            return selectionIsBackwards(this);
            -        };
            -    } else {
            -        selectionIsBackwards = selProto.isBackwards = function() {
            -            return false;
            -        };
            -    }
            -
            -    // Selection text
            -    // This is conformant to the new WHATWG DOM Range draft spec but differs from WebKit and Mozilla's implementation
            -    selProto.toString = function() {
            -
            -        var rangeTexts = [];
            -        for (var i = 0, len = this.rangeCount; i < len; ++i) {
            -            rangeTexts[i] = "" + this._ranges[i];
            -        }
            -        return rangeTexts.join("");
            -    };
            -
            -    function assertNodeInSameDocument(sel, node) {
            -        if (sel.anchorNode && (dom.getDocument(sel.anchorNode) !== dom.getDocument(node))) {
            -            throw new DOMException("WRONG_DOCUMENT_ERR");
            -        }
            -    }
            -
            -    // No current browsers conform fully to the HTML 5 draft spec for this method, so Rangy's own method is always used
            -    selProto.collapse = function(node, offset) {
            -        assertNodeInSameDocument(this, node);
            -        var range = api.createRange(dom.getDocument(node));
            -        range.collapseToPoint(node, offset);
            -        this.removeAllRanges();
            -        this.addRange(range);
            -        this.isCollapsed = true;
            -    };
            -
            -    selProto.collapseToStart = function() {
            -        if (this.rangeCount) {
            -            var range = this._ranges[0];
            -            this.collapse(range.startContainer, range.startOffset);
            -        } else {
            -            throw new DOMException("INVALID_STATE_ERR");
            -        }
            -    };
            -
            -    selProto.collapseToEnd = function() {
            -        if (this.rangeCount) {
            -            var range = this._ranges[this.rangeCount - 1];
            -            this.collapse(range.endContainer, range.endOffset);
            -        } else {
            -            throw new DOMException("INVALID_STATE_ERR");
            -        }
            -    };
            -
            -    // The HTML 5 spec is very specific on how selectAllChildren should be implemented so the native implementation is
            -    // never used by Rangy.
            -    selProto.selectAllChildren = function(node) {
            -        assertNodeInSameDocument(this, node);
            -        var range = api.createRange(dom.getDocument(node));
            -        range.selectNodeContents(node);
            -        this.removeAllRanges();
            -        this.addRange(range);
            -    };
            -
            -    selProto.deleteFromDocument = function() {
            -        // Sepcial behaviour required for Control selections
            -        if (implementsControlRange && implementsDocSelection && this.docSelection.type == CONTROL) {
            -            var controlRange = this.docSelection.createRange();
            -            var element;
            -            while (controlRange.length) {
            -                element = controlRange.item(0);
            -                controlRange.remove(element);
            -                element.parentNode.removeChild(element);
            -            }
            -            this.refresh();
            -        } else if (this.rangeCount) {
            -            var ranges = this.getAllRanges();
            -            this.removeAllRanges();
            -            for (var i = 0, len = ranges.length; i < len; ++i) {
            -                ranges[i].deleteContents();
            -            }
            -            // The HTML5 spec says nothing about what the selection should contain after calling deleteContents on each
            -            // range. Firefox moves the selection to where the final selected range was, so we emulate that
            -            this.addRange(ranges[len - 1]);
            -        }
            -    };
            -
            -    // The following are non-standard extensions
            -    selProto.getAllRanges = function() {
            -        return this._ranges.slice(0);
            -    };
            -
            -    selProto.setSingleRange = function(range) {
            -        this.setRanges( [range] );
            -    };
            -
            -    selProto.containsNode = function(node, allowPartial) {
            -        for (var i = 0, len = this._ranges.length; i < len; ++i) {
            -            if (this._ranges[i].containsNode(node, allowPartial)) {
            -                return true;
            -            }
            -        }
            -        return false;
            -    };
            -
            -    selProto.toHtml = function() {
            -        var html = "";
            -        if (this.rangeCount) {
            -            var container = DomRange.getRangeDocument(this._ranges[0]).createElement("div");
            -            for (var i = 0, len = this._ranges.length; i < len; ++i) {
            -                container.appendChild(this._ranges[i].cloneContents());
            -            }
            -            html = container.innerHTML;
            -        }
            -        return html;
            -    };
            -
            -    function inspect(sel) {
            -        var rangeInspects = [];
            -        var anchor = new DomPosition(sel.anchorNode, sel.anchorOffset);
            -        var focus = new DomPosition(sel.focusNode, sel.focusOffset);
            -        var name = (typeof sel.getName == "function") ? sel.getName() : "Selection";
            -
            -        if (typeof sel.rangeCount != "undefined") {
            -            for (var i = 0, len = sel.rangeCount; i < len; ++i) {
            -                rangeInspects[i] = DomRange.inspect(sel.getRangeAt(i));
            -            }
            -        }
            -        return "[" + name + "(Ranges: " + rangeInspects.join(", ") +
            -                ")(anchor: " + anchor.inspect() + ", focus: " + focus.inspect() + "]";
            -
            -    }
            -
            -    selProto.getName = function() {
            -        return "WrappedSelection";
            -    };
            -
            -    selProto.inspect = function() {
            -        return inspect(this);
            -    };
            -
            -    selProto.detach = function() {
            -        this.win[windowPropertyName] = null;
            -        this.win = this.anchorNode = this.focusNode = null;
            -    };
            -
            -    WrappedSelection.inspect = inspect;
            -
            -    api.Selection = WrappedSelection;
            -
            -    api.selectionPrototype = selProto;
            -
            -    api.addCreateMissingNativeApiListener(function(win) {
            -        if (typeof win.getSelection == "undefined") {
            -            win.getSelection = function() {
            -                return api.getSelection(this);
            -            };
            -        }
            -        win = null;
            -    });
            -});
            -
            -/**
            - * @license Selection save and restore module for Rangy.
            - * Saves and restores user selections using marker invisible elements in the DOM.
            - *
            - * Part of Rangy, a cross-browser JavaScript range and selection library
            - * http://code.google.com/p/rangy/
            - *
            - * Depends on Rangy core.
            - *
            - * Copyright 2011, Tim Down
            - * Licensed under the MIT license.
            - * Version: 1.2.2
            - * Build date: 13 November 2011
            - */
            -rangy.createModule("SaveRestore", function(api, module) {
            -    api.requireModules( ["DomUtil", "DomRange", "WrappedRange"] );
            -
            -    var dom = api.dom;
            -
            -    var markerTextChar = "\ufeff";
            -
            -    function gEBI(id, doc) {
            -        return (doc || document).getElementById(id);
            -    }
            -
            -    function insertRangeBoundaryMarker(range, atStart) {
            -        var markerId = "selectionBoundary_" + (+new Date()) + "_" + ("" + Math.random()).slice(2);
            -        var markerEl;
            -        var doc = dom.getDocument(range.startContainer);
            -
            -        // Clone the Range and collapse to the appropriate boundary point
            -        var boundaryRange = range.cloneRange();
            -        boundaryRange.collapse(atStart);
            -
            -        // Create the marker element containing a single invisible character using DOM methods and insert it
            -        markerEl = doc.createElement("span");
            -        markerEl.id = markerId;
            -        markerEl.style.lineHeight = "0";
            -        markerEl.style.display = "none";
            -        markerEl.className = "rangySelectionBoundary";
            -        markerEl.appendChild(doc.createTextNode(markerTextChar));
            -
            -        boundaryRange.insertNode(markerEl);
            -        boundaryRange.detach();
            -        return markerEl;
            -    }
            -
            -    function setRangeBoundary(doc, range, markerId, atStart) {
            -        var markerEl = gEBI(markerId, doc);
            -        if (markerEl) {
            -            range[atStart ? "setStartBefore" : "setEndBefore"](markerEl);
            -            markerEl.parentNode.removeChild(markerEl);
            -        } else {
            -            module.warn("Marker element has been removed. Cannot restore selection.");
            -        }
            -    }
            -
            -    function compareRanges(r1, r2) {
            -        return r2.compareBoundaryPoints(r1.START_TO_START, r1);
            -    }
            -
            -    function saveSelection(win) {
            -        win = win || window;
            -        var doc = win.document;
            -        if (!api.isSelectionValid(win)) {
            -            module.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus.");
            -            return;
            -        }
            -        var sel = api.getSelection(win);
            -        var ranges = sel.getAllRanges();
            -        var rangeInfos = [], startEl, endEl, range;
            -
            -        // Order the ranges by position within the DOM, latest first
            -        ranges.sort(compareRanges);
            -
            -        for (var i = 0, len = ranges.length; i < len; ++i) {
            -            range = ranges[i];
            -            if (range.collapsed) {
            -                endEl = insertRangeBoundaryMarker(range, false);
            -                rangeInfos.push({
            -                    markerId: endEl.id,
            -                    collapsed: true
            -                });
            -            } else {
            -                endEl = insertRangeBoundaryMarker(range, false);
            -                startEl = insertRangeBoundaryMarker(range, true);
            -
            -                rangeInfos[i] = {
            -                    startMarkerId: startEl.id,
            -                    endMarkerId: endEl.id,
            -                    collapsed: false,
            -                    backwards: ranges.length == 1 && sel.isBackwards()
            -                };
            -            }
            -        }
            -
            -        // Now that all the markers are in place and DOM manipulation over, adjust each range's boundaries to lie
            -        // between its markers
            -        for (i = len - 1; i >= 0; --i) {
            -            range = ranges[i];
            -            if (range.collapsed) {
            -                range.collapseBefore(gEBI(rangeInfos[i].markerId, doc));
            -            } else {
            -                range.setEndBefore(gEBI(rangeInfos[i].endMarkerId, doc));
            -                range.setStartAfter(gEBI(rangeInfos[i].startMarkerId, doc));
            -            }
            -        }
            -
            -        // Ensure current selection is unaffected
            -        sel.setRanges(ranges);
            -        return {
            -            win: win,
            -            doc: doc,
            -            rangeInfos: rangeInfos,
            -            restored: false
            -        };
            -    }
            -
            -    function restoreSelection(savedSelection, preserveDirection) {
            -        if (!savedSelection.restored) {
            -            var rangeInfos = savedSelection.rangeInfos;
            -            var sel = api.getSelection(savedSelection.win);
            -            var ranges = [];
            -
            -            // Ranges are in reverse order of appearance in the DOM. We want to restore earliest first to avoid
            -            // normalization affecting previously restored ranges.
            -            for (var len = rangeInfos.length, i = len - 1, rangeInfo, range; i >= 0; --i) {
            -                rangeInfo = rangeInfos[i];
            -                range = api.createRange(savedSelection.doc);
            -                if (rangeInfo.collapsed) {
            -                    var markerEl = gEBI(rangeInfo.markerId, savedSelection.doc);
            -                    if (markerEl) {
            -                        markerEl.style.display = "inline";
            -                        var previousNode = markerEl.previousSibling;
            -
            -                        // Workaround for issue 17
            -                        if (previousNode && previousNode.nodeType == 3) {
            -                            markerEl.parentNode.removeChild(markerEl);
            -                            range.collapseToPoint(previousNode, previousNode.length);
            -                        } else {
            -                            range.collapseBefore(markerEl);
            -                            markerEl.parentNode.removeChild(markerEl);
            -                        }
            -                    } else {
            -                        module.warn("Marker element has been removed. Cannot restore selection.");
            -                    }
            -                } else {
            -                    setRangeBoundary(savedSelection.doc, range, rangeInfo.startMarkerId, true);
            -                    setRangeBoundary(savedSelection.doc, range, rangeInfo.endMarkerId, false);
            -                }
            -
            -                // Normalizing range boundaries is only viable if the selection contains only one range. For example,
            -                // if the selection contained two ranges that were both contained within the same single text node,
            -                // both would alter the same text node when restoring and break the other range.
            -                if (len == 1) {
            -                    range.normalizeBoundaries();
            -                }
            -                ranges[i] = range;
            -            }
            -            if (len == 1 && preserveDirection && api.features.selectionHasExtend && rangeInfos[0].backwards) {
            -                sel.removeAllRanges();
            -                sel.addRange(ranges[0], true);
            -            } else {
            -                sel.setRanges(ranges);
            -            }
            -
            -            savedSelection.restored = true;
            -        }
            -    }
            -
            -    function removeMarkerElement(doc, markerId) {
            -        var markerEl = gEBI(markerId, doc);
            -        if (markerEl) {
            -            markerEl.parentNode.removeChild(markerEl);
            -        }
            -    }
            -
            -    function removeMarkers(savedSelection) {
            -        var rangeInfos = savedSelection.rangeInfos;
            -        for (var i = 0, len = rangeInfos.length, rangeInfo; i < len; ++i) {
            -            rangeInfo = rangeInfos[i];
            -            if (rangeInfo.collapsed) {
            -                removeMarkerElement(savedSelection.doc, rangeInfo.markerId);
            -            } else {
            -                removeMarkerElement(savedSelection.doc, rangeInfo.startMarkerId);
            -                removeMarkerElement(savedSelection.doc, rangeInfo.endMarkerId);
            -            }
            -        }
            -    }
            -
            -    api.saveSelection = saveSelection;
            -    api.restoreSelection = restoreSelection;
            -    api.removeMarkerElement = removeMarkerElement;
            -    api.removeMarkers = removeMarkers;
            -});
            -
            -/* globals -$ */
            -"use strict";
            -
            -WYMeditor.SKINS.compact = {
            -    init: function(wym) {
            -        // Move the containers panel to the top area
            -        jQuery(wym._options.containersSelector + ', ' +
            -            wym._options.classesSelector, wym._box)
            -          .appendTo( jQuery("div.wym_area_top", wym._box) )
            -          .addClass("wym_dropdown")
            -          .css({"margin-right": "10px", "width": "120px", "float": "left"});
            -
            -        // Render following sections as buttons
            -        jQuery(wym._options.toolsSelector, wym._box)
            -          .addClass("wym_buttons")
            -          .css({"margin-right": "10px", "float": "left"});
            -
            -        // Make hover work under IE < 7
            -        jQuery(".wym_section", wym._box).hover(function(){
            -          jQuery(this).addClass("hover");
            -        },function(){
            -          jQuery(this).removeClass("hover");
            -        });
            -
            -        var postInit = wym._options.postInit;
            -        wym._options.postInit = function(wym) {
            -            if (postInit) {
            -                postInit.call(wym, wym);
            -            }
            -
            -            wym.$body().css('background-color', '#f0f0f0');
            -        };
            -    }
            -};
            -
            -"use strict";
            -
            -WYMeditor.SKINS['default'] = {
            -    init: function (wym) {
            -        //render following sections as panels
            -        jQuery(wym._box).find(wym._options.classesSelector)
            -          .addClass("wym_panel");
            -
            -        //render following sections as buttons
            -        jQuery(wym._box).find(wym._options.toolsSelector)
            -          .addClass("wym_buttons");
            -
            -        //render following sections as dropdown menus
            -        jQuery(wym._box).find(wym._options.containersSelector)
            -          .addClass("wym_dropdown")
            -          .find(WYMeditor.H2)
            -          .append(" >");
            -
            -        // auto add some margin to the main area sides if left area
            -        // or right area are not empty (if they contain sections)
            -        jQuery(wym._box).find("div.wym_area_right ul")
            -          .parents("div.wym_area_right").show()
            -          .parents(wym._options.boxSelector)
            -          .find("div.wym_area_main")
            -          .css({"margin-right": "155px"});
            -
            -        jQuery(wym._box).find("div.wym_area_left ul")
            -          .parents("div.wym_area_left").show()
            -          .parents(wym._options.boxSelector)
            -          .find("div.wym_area_main")
            -          .css({"margin-left": "155px"});
            -
            -        //make hover work under IE < 7
            -        jQuery(wym._box).find(".wym_section").hover(
            -            function () {
            -                jQuery(this).addClass("hover");
            -            },
            -            function () {
            -                jQuery(this).removeClass("hover");
            -            }
            -        );
            -    }
            -};
            -
            -"use strict";
            -
            -WYMeditor.SKINS.legacy = {
            -    init: function (wym) {
            -        //render following sections as panels
            -        jQuery(wym._box).find(wym._options.classesSelector)
            -          .addClass("wym_panel");
            -
            -        //render following sections as buttons
            -        jQuery(wym._box).find(wym._options.toolsSelector)
            -          .addClass("wym_buttons");
            -
            -        //render following sections as dropdown menus
            -        jQuery(wym._box).find(wym._options.containersSelector)
            -          .addClass("wym_dropdown")
            -          .find(WYMeditor.H2)
            -          .append(" >");
            -
            -        // auto add some margin to the main area sides if left area
            -        // or right area are not empty (if they contain sections)
            -        jQuery(wym._box).find("div.wym_area_right ul")
            -          .parents("div.wym_area_right").show()
            -          .parents(wym._options.boxSelector)
            -          .find("div.wym_area_main")
            -          .css({"margin-right": "155px"});
            -
            -        jQuery(wym._box).find("div.wym_area_left ul")
            -          .parents("div.wym_area_left").show()
            -          .parents(wym._options.boxSelector)
            -          .find("div.wym_area_main")
            -          .css({"margin-left": "155px"});
            -
            -        //make hover work under IE < 7
            -        jQuery(wym._box).find(".wym_section").hover(
            -            function () {
            -                jQuery(this).addClass("hover");
            -            },
            -            function () {
            -                jQuery(this).removeClass("hover");
            -            }
            -        );
            -    }
            -};
            -
            -jQuery.fn.selectify = function() {
            -    var $elements = this;
            -    return $elements.each(function() {
            -        var element = this;
            -        jQuery(element).hover(
            -            function() {
            -                var element = this;
            -                jQuery("h2", element).css("background-position", "0px -18px");
            -                jQuery("ul", element).fadeIn("fast");
            -            },
            -            function() {
            -                var element = this;
            -                jQuery("h2", element).css("background-position", "");
            -                jQuery("ul", element).fadeOut("fast");
            -            }
            -        );
            -    });
            -};
            -
            -WYMeditor.SKINS.minimal = {
            -    //placeholder for the skin JS, if needed
            -
            -    //init the skin
            -    //wym is the WYMeditor.editor instance
            -    init: function(wym) {
            -
            -        //render following sections as dropdown menus
            -        jQuery(wym._box).find(wym._options.toolsSelector + ', ' + wym._options.containersSelector + ', ' + wym._options.classesSelector)
            -          .addClass("wym_dropdown")
            -          .selectify();
            -
            -
            -    }
            -};
            -
            -/* globals -$ */
            -"use strict";
            -
            -// Add classes to an element based on its current location relative to top and
            -// or bottom offsets.
            -// Useful for affixing an element on the page within a certain vertical range.
            -// Based largely off of the bootstrap affix plugin
            -// https://github.com/twbs/bootstrap/blob/master/js/affix.js
            -(function ($) {
            -    var Affix = function (element, options) {
            -        this.options = $.extend({}, $.fn.wymAffix.defaults, options);
            -        this.$window = $(window);
            -
            -        this.$window.bind(
            -            'scroll.affix.data-api',
            -            $.proxy(this.checkPosition, this)
            -        );
            -        this.$window.bind(
            -            'click.affix.data-api',
            -            $.proxy(
            -                function () {
            -                    setTimeout(
            -                        $.proxy(this.checkPosition, this),
            -                        1
            -                    );
            -                },
            -                this
            -            )
            -        );
            -        this.$element = $(element);
            -        this.checkPosition();
            -    };
            -
            -    Affix.prototype.checkPosition = function () {
            -        var scrollTop = this.$window.scrollTop()
            -          , offset = this.options.offset
            -          , offsetBottom = offset.bottom
            -          , offsetTop = offset.top
            -          , reset = 'affix affix-top affix-bottom'
            -          , desiredAffixType
            -          , isBelowTop = true
            -          , isAboveBottom = true;
            -
            -        if (typeof offset !== 'object') {
            -            offsetBottom = offsetTop = offset;
            -        }
            -        if (typeof offsetTop === 'function') {
            -            offsetTop = offset.top();
            -        }
            -        if (typeof offsetBottom === 'function') {
            -            offsetBottom = offset.bottom();
            -        }
            -
            -        if (offsetTop !== null) {
            -            isBelowTop = scrollTop > offsetTop;
            -        }
            -        if (offsetBottom !== null) {
            -            isAboveBottom = scrollTop + this.$element.height() < offsetBottom;
            -        }
            -
            -        if (isBelowTop && isAboveBottom) {
            -            desiredAffixType = 'affix';
            -        } else if (isAboveBottom === false) {
            -            // We're below the bottom offset
            -            desiredAffixType = 'affix-bottom';
            -        } else {
            -            desiredAffixType = 'affix-top';
            -        }
            -
            -        if (this.currentAffixType === desiredAffixType) {
            -            // We're already properly-affixed. No changes required.
            -            return;
            -        }
            -
            -        this.$element.removeClass(reset).addClass(desiredAffixType);
            -
            -        this.currentAffixType = desiredAffixType;
            -    };
            -
            -
            - /* AFFIX PLUGIN DEFINITION
            -  * ======================= */
            -
            -    $.fn.wymAffix = function (option) {
            -        var $elements = this;
            -        return $elements.each(function () {
            -            var element = this,
            -                $element = $(element)
            -                , data = $element.data('affix')
            -                , options = typeof option === 'object' && option;
            -
            -            if (!data) {
            -                $element.data(
            -                    'affix',
            -                    (data = new Affix(element, options))
            -                );
            -            }
            -            if (typeof option === 'string') {
            -                data[option]();
            -            }
            -        });
            -    };
            -
            -    $.fn.wymAffix.Constructor = Affix;
            -
            -    $.fn.wymAffix.defaults = {
            -        offset: 0
            -    };
            -}(jQuery));
            -
            -WYMeditor.SKINS.seamless = {
            -    OPTS: {
            -        iframeHtml: [""
            -        , '
            ' - , '' - , '
            ' - ].join(""), - // After Iframe initialization, check if we're ready to perform the - // first resize every this many ms - initIframeCheckFrequency: 50, - // After load or after images are inserted, check every this many ms to - // see if they've properly set their height. - imagesLoadedCheckFrequency: 300, - // After this many ms, give up on images finishing loading. Some images - // might never load due to network connectivity or bad links. - imagesLoadedCheckTimeout: 5000 - }, - init: function (wym) { - var This = WYMeditor.SKINS.seamless; - - // TODO: Find a unified strategy for dealing with loading polyfills - // This is a polyfill for old IE - if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; - } - - wym.seamlessSkinOpts = jQuery.extend( - This.OPTS, - { - initialIframeResizeTimer: null, - resizeAfterImagesLoadTimer: null, - _imagesLoadedCheckStartedTime: 0, - minimumHeight: jQuery(wym.element).height() - } - ); - This.initUIChrome(wym); - - // The Iframe isn't initialized at this point, so we'll need to wait - // until it is before attempting to use it. - jQuery(wym.element).bind( - WYMeditor.EVENTS.postIframeInitialization, - This.postIframeInit - ); - }, - postIframeInit: function (e, wym) { - var This = WYMeditor.SKINS.seamless; - - // Perform an initial resize, if necessary - This.resizeIframeOnceBodyExists(wym); - - // Detect possible Block creation so that we can always keep the iframe - // properly resized and the current container in view - jQuery(wym.element).bind( - WYMeditor.EVENTS.postBlockMaybeCreated, - function () { - This.resizeAndScrollIfNeeded(wym); - } - ); - }, - initUIChrome: function (wym) { - // Initialize the toolbar and classes/containers selectors - - // The classes and containers sections are dropdowns to the right of - // the toolbar at the top - var This = WYMeditor.SKINS.seamless, - $dropdowns = jQuery( - [ - wym._options.containersSelector - , wym._options.classesSelector - ].join(', '), - wym._box - ), - $toolbar, - $areaTop; - - $areaTop = jQuery("div.wym_area_top", wym._box); - - $dropdowns.appendTo($areaTop); - $dropdowns.addClass("wym_dropdown"); - // Make dropdowns also work on click, for mobile devices - jQuery(".wym_dropdown", wym._box).click( - function () { - var dropDown = this; - jQuery(dropDown).toggleClass("hover"); - } - ); - - // The toolbar uses buttons - $toolbar = jQuery(wym._options.toolsSelector, wym._box); - $toolbar.addClass("wym_buttons"); - - This.affixTopControls(wym); - - }, - affixTopControls: function (wym) { - // Affix the top area, which contains the toolbar and containers, to - // the top of the screen so that we can see it, even if we're scrolled - // down. - var $areaTop, - $offsetWrapper, - earlyScrollPixels = 5, - usePlaceholderWidth, - $placeholder; - - $areaTop = jQuery("div.wym_area_top", wym._box); - - // Use a wrapper so we can keep the toolbar styling consistent - $offsetWrapper = jQuery( - '
            ' - ); - $areaTop.wrap($offsetWrapper); - $offsetWrapper = $areaTop.parent(); - - // Add another, non-affixed wrapper to stick around and hold vertical - // space. This avoids the "jump" when the toolbar switches to being - // affixed - $offsetWrapper.wrap('
            '); - $placeholder = $offsetWrapper.parent(); - $placeholder.height($areaTop.height()); - - usePlaceholderWidth = function () { - // Hard-code the offsetWrapper width so that when this floats to - // the top, it doesn't expand to take up all of the room to the - // right - $offsetWrapper.width($placeholder.width()); - }; - usePlaceholderWidth(); - jQuery(window).resize(usePlaceholderWidth); - - $offsetWrapper.wymAffix({ - offset: { - top: function () { - return $placeholder.offset().top - earlyScrollPixels; - }, - bottom: function () { - return $placeholder.offset().top + - wym.seamlessSkinIframeHeight; - } - } - }); - }, - resizeIframeOnceBodyExists: function (wym) { - // In IE, the wym._doc DOMLoaded event doesn't mean the iframe will - // actually have a body. We need to wait until the body actually exists - // before trying to set the initial hight of the iframe, so we hack - // this together with setTimeout. - var This = WYMeditor.SKINS.seamless, - scrollHeightCalcFix; - - if (wym.seamlessSkinOpts.initialIframeResizeTimer) { - // We're handling a timer, clear it - window.clearTimeout( - wym.seamlessSkinOpts.initialIframeResizeTimer - ); - wym.seamlessSkinOpts.initialIframeResizeTimer = null; - } - - if (typeof wym._doc.body === "undefined" || wym._doc.body === null) { - // Body isn't ready - wym.seamlessSkinOpts.initialIframeResizeTimer = window.setTimeout( - function () { - This.resizeIframeOnceBodyExists(wym); - }, - wym.seamlessSkinOpts.initIframeCheckFrequency - ); - return; - } - // The body is ready, so let's get to resizing - // For some reason, at least IE7 requires at least one access to the - // scrollHeight before it gives a real value. I was unable to find any - // kind of feature detection that would work here and the fix of adding - // an extra access here doesn't have any real negative impact on the - // other browsers, but does fix IE7's behavior. - scrollHeightCalcFix = wym._doc.body.scrollHeight; - This.resizeIframe(wym); - This.resizeIframeOnceImagesLoaded(wym); - }, - resizeIframeOnceImagesLoaded: function (wym) { - // Even though the body may be "loaded" from a DOM even standpoint, - // that doesn't mean that images have yet been retrieved or that their - // heights have been determined. If an image's height pops in after - // we've calculated the iframe height, the iframe will be too short. - var This = WYMeditor.SKINS.seamless, - images, - imagesLength, - i = 0, - allImagesLoaded = true, - skinOpts = wym.seamlessSkinOpts, - timeWaited; - - if (typeof skinOpts._imagesLoadedCheckStartedTime === "undefined" || - skinOpts._imagesLoadedCheckStartedTime === 0) { - skinOpts._imagesLoadedCheckStartedTime = Date.now(); - } - - if (skinOpts.resizeAfterImagesLoadTimer !== null) { - // We're handling a timer, clear it - window.clearTimeout( - skinOpts.resizeAfterImagesLoadTimer - ); - skinOpts.resizeAfterImagesLoadTimer = null; - } - - images = wym.$body().find('img'); - imagesLength = images.length; - - if (imagesLength === 0) { - // No images. No need to worry about resizing based on them. - return; - } - - for (i = 0; i < imagesLength; i += 1) { - if (!This._imageIsLoaded(images[i])) { - // If any image isn't loaded, we're not done - allImagesLoaded = false; - break; - } - } - // Even if all of the images haven't loaded, we can still be more - // correct by accounting for any that have. - This.resizeAndScrollIfNeeded(wym); - - if (allImagesLoaded === true) { - // Clean up the timeout timer for subsequent calls - skinOpts._imagesLoadedCheckStartedTime = 0; - return; - } - - timeWaited = Date.now() - skinOpts._imagesLoadedCheckStartedTime; - if (timeWaited > skinOpts.imagesLoadedCheckTimeout) { - // Clean up the timeout timer for subsequent calls - skinOpts._imagesLoadedCheckStartedTime = 0; - // We've waited long enough. The images might never load. - // Don't set another timer. - return; - } - - // Let's check again in after a delay - skinOpts.resizeAfterImagesLoadTimer = window.setTimeout( - function () { - This.resizeIframeOnceImagesLoaded(wym); - }, - skinOpts.imagesLoadedCheckFrequency - ); - }, - _imageIsLoaded: function (img) { - if (img.complete !== true) { - return false; - } - - if (typeof img.naturalWidth !== "undefined" && - img.naturalWidth === 0) { - return false; - } - - return true; - }, - _getIframeHeightStrategy: function (wym) { - // For some browsers (IE8+ and FF), the scrollHeight of the body - // doesn't seem to include the top and bottom margins of the body - // relative to the HTML. This leaves the editing "window" smaller - // than required, which results in weird overlaps at the start/end. - // For those browsers, the HTML element's scrollHeight is more - // reliable. - // Let's detect which kind of browser we're dealing with one time - // so we can just do the right thing in the future. - var bodyScrollHeight, - $htmlElement, - htmlElementHeight, - htmlElementScrollHeight, - heightStrategy; - - $htmlElement = jQuery(wym._doc).children().eq(0); - - bodyScrollHeight = wym._doc.body.scrollHeight; - htmlElementHeight = $htmlElement.height(); - htmlElementScrollHeight = $htmlElement[0].scrollHeight; - - if (WYMeditor.isInternetExplorerPre11()) { - // The htmlElementScrollHeight is fairly reliable, - // but doesn't shrink when content is removed. - heightStrategy = function (wym) { - var $htmlElement = jQuery(wym._doc).children().eq(0), - htmlElementScrollHeight = $htmlElement[0].scrollHeight; - - // Without the 10px reduction in height, every possible action - // adds 10 pixels of height. - // TODO: Figure out why this happens and if we can make the - // 10px number not magic (actually derived from a - // margin/padding etc). - return htmlElementScrollHeight - 10; - }; - - return heightStrategy; - } else if (htmlElementHeight >= bodyScrollHeight) { - // Well-behaving browsers like FF and Chrome let us rely on the - // HTML element's jQuery height() in every case. Hooray! - heightStrategy = function (wym) { - var $htmlElement = jQuery(wym._doc).children().eq(0), - htmlElementHeight = $htmlElement.height(); - - return htmlElementHeight; - }; - - return heightStrategy; - } else if (bodyScrollHeight > htmlElementScrollHeight) { - // This is probably IE7, where the only thing reliable is the - // bodyScrollHeight - heightStrategy = function (wym) { - return wym._doc.body.scrollHeight; - }; - - return heightStrategy; - } else { - throw new Error('unsupported browser'); - } - }, - resizeIframe: function (wym) { - var This = WYMeditor.SKINS.seamless, - desiredHeight, - $iframe = jQuery(wym._iframe), - currentHeight = $iframe.height(); - - if (typeof WYMeditor.IFRAME_HEIGHT_GETTER === "undefined") { - WYMeditor.IFRAME_HEIGHT_GETTER = This._getIframeHeightStrategy( - wym - ); - } - - desiredHeight = WYMeditor.IFRAME_HEIGHT_GETTER(wym); - - // Don't let the height drop below the WYMeditor textarea. This allows - // folks to use their favorite height-setting method on the textarea, - // without needing to pass options on to WYMeditor. - if (desiredHeight < wym.seamlessSkinOpts.minimumHeight) { - desiredHeight = wym.seamlessSkinOpts.minimumHeight; - } - - if (currentHeight !== desiredHeight) { - $iframe.height(desiredHeight); - wym.seamlessSkinIframeHeight = desiredHeight; - - return true; - } - return false; - }, - scrollIfNeeded: function (wym) { - var iframeOffset = jQuery(wym._iframe).offset(), - iframeOffsetTop = iframeOffset.top, - $container = jQuery(wym.selectedContainer()), - containerOffset = $container.offset(), - viewportLowestY, - containerLowestY, - newScrollTop, - extraScroll = 20, - scrollDiff, - $window = jQuery(window), - $body = jQuery(document.body); - - if ($container.length === 0) { - // With nothing selected, there's no need to scroll - return; - } - containerLowestY = iframeOffsetTop + containerOffset.top; - containerLowestY += $container.outerHeight(); - viewportLowestY = $window.scrollTop() + $window.height(); - scrollDiff = containerLowestY - viewportLowestY; - if (scrollDiff > 0) { - // Part of our selected container isn't - // visible, so we need to scroll down. - newScrollTop = $body.scrollTop() + scrollDiff + extraScroll; - $body.scrollTop(newScrollTop); - } - }, - resizeAndScrollIfNeeded: function (wym) { - // Scroll the page so that our current selection - // within the iframe is actually in view. - var This = WYMeditor.SKINS.seamless, - resizeOccurred = This.resizeIframe(wym); - if (resizeOccurred !== true) { - return; - } - This.scrollIfNeeded(wym); - } -}; - -/* This file is part of the Silver skin for WYMeditor by Scott Edwin Lewis */ - -jQuery.fn.selectify = function() { - var $elements = this; - return $elements.each(function() { - var element = this; - jQuery(element).hover( - function() { - var element = this; - jQuery("h2", element).css("background-position", "0px -18px"); - jQuery("ul", element).fadeIn("fast"); - }, - function() { - var element = this; - jQuery("h2", element).css("background-position", ""); - jQuery("ul", element).fadeOut("fast"); - } - ); - }); -}; - -WYMeditor.SKINS.silver = { - - init: function(wym) { - - //add some elements to improve the rendering - jQuery(wym._box) - .append('
            ') - .wrapInner('
            '); - - //render following sections as panels - jQuery(wym._box).find(wym._options.classesSelector) - .addClass("wym_panel"); - - //render following sections as buttons - jQuery(wym._box).find(wym._options.toolsSelector) - .addClass("wym_buttons"); - - //render following sections as dropdown menus - jQuery(wym._box).find(wym._options.containersSelector) - .addClass("wym_dropdown") - .selectify(); - - // auto add some margin to the main area sides if left area - // or right area are not empty (if they contain sections) - jQuery(wym._box).find("div.wym_area_right ul") - .parents("div.wym_area_right").show() - .parents(wym._options.boxSelector) - .find("div.wym_area_main") - .css({"margin-right": "155px"}); - - jQuery(wym._box).find("div.wym_area_left ul") - .parents("div.wym_area_left").show() - .parents(wym._options.boxSelector) - .find("div.wym_area_main") - .css({"margin-left": "155px"}); - - //make hover work under IE < 7 - jQuery(wym._box).find(".wym_section").hover(function(){ - var section = this; - jQuery(section).addClass("hover"); - },function(){ - var section = this; - jQuery(section).removeClass("hover"); - }); - } -}; - -WYMeditor.SKINS.twopanels = { - - init: function(wym) { - - //move the containers panel to the left area - jQuery(wym._box).find(wym._options.containersSelector) - .appendTo("div.wym_area_left"); - - //render following sections as panels - jQuery(wym._box).find(wym._options.classesSelector + ', ' + - wym._options.containersSelector) - .addClass("wym_panel"); - - //render following sections as buttons - jQuery(wym._box).find(wym._options.toolsSelector) - .addClass("wym_buttons"); - - // auto add some margin to the main area sides if left area - // or right area are not empty (if they contain sections) - jQuery(wym._box).find("div.wym_area_right ul") - .parents("div.wym_area_right").show() - .parents(wym._options.boxSelector) - .find("div.wym_area_main") - .css({"margin-right": "155px"}); - - jQuery(wym._box).find("div.wym_area_left ul") - .parents("div.wym_area_left").show() - .parents(wym._options.boxSelector) - .find("div.wym_area_main") - .css({"margin-left": "115px"}); - - //make hover work under IE < 7 - jQuery(wym._box).find(".wym_section").hover(function(){ - jQuery(this).addClass("hover"); - },function(){ - jQuery(this).removeClass("hover"); - }); - } -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/jquery.wymeditor.min.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/jquery.wymeditor.min.js deleted file mode 100644 index c5cf86b1b3..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/jquery.wymeditor.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/*! -WYMeditor - v1.1.1 - -Home page: http://wymeditor.github.io/wymeditor/ - -Copyright (c) 2015 Jean-Francois Hovinne; -Licensed (MIT OR GPL-2.0) -*/ - -if(function(a){"function"==typeof define&&define.amd?define(["jquery"],function(b){return a(b)}):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(window.jQuery)}(function(a){"use strict";function b(a){void 0===a&&(a=window.navigator.userAgent),a=a.toLowerCase();var b=/(edge)\/([\w.]+)/.exec(a)||/(opr)[\/]([\w.]+)/.exec(a)||/(chrome)[ \/]([\w.]+)/.exec(a)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[],c=/(ipad)/.exec(a)||/(ipod)/.exec(a)||/(iphone)/.exec(a)||/(kindle)/.exec(a)||/(silk)/.exec(a)||/(android)/.exec(a)||/(windows phone)/.exec(a)||/(win)/.exec(a)||/(mac)/.exec(a)||/(linux)/.exec(a)||/(cros)/.exec(a)||/(playbook)/.exec(a)||/(bb)/.exec(a)||/(blackberry)/.exec(a)||[],d={},e={browser:b[5]||b[3]||b[1]||"",version:b[2]||b[4]||"0",versionNumber:b[4]||b[2]||"0",platform:c[0]||""};if(e.browser&&(d[e.browser]=!0,d.version=e.version,d.versionNumber=parseInt(e.versionNumber,10)),e.platform&&(d[e.platform]=!0),(d.android||d.bb||d.blackberry||d.ipad||d.iphone||d.ipod||d.kindle||d.playbook||d.silk||d["windows phone"])&&(d.mobile=!0),(d.cros||d.mac||d.linux||d.win)&&(d.desktop=!0),(d.chrome||d.opr||d.safari)&&(d.webkit=!0),d.rv||d.edge){var f="msie";e.browser=f,d[f]=!0}if(d.safari&&d.blackberry){var g="blackberry";e.browser=g,d[g]=!0}if(d.safari&&d.playbook){var h="playbook";e.browser=h,d[h]=!0}if(d.bb){var i="blackberry";e.browser=i,d[i]=!0}if(d.opr){var j="opera";e.browser=j,d[j]=!0}if(d.safari&&d.android){var k="android";e.browser=k,d[k]=!0}if(d.safari&&d.kindle){var l="kindle";e.browser=l,d[l]=!0}if(d.safari&&d.silk){var m="silk";e.browser=m,d[m]=!0}return d.name=e.browser,d.platform=e.platform,d}return window.jQBrowser=b(window.navigator.userAgent),window.jQBrowser.uaMatch=b,a&&(a.browser=window.jQBrowser),window.jQBrowser}),"undefined"==typeof WYMeditor)var WYMeditor={};!function(){if("undefined"==typeof window.console&&"undefined"==typeof console){var a,b=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"],c=function(){};for(WYMeditor.console={},a=0;a
            "+WYMeditor.TOOLS+"
            "+WYMeditor.CONTAINERS+WYMeditor.CLASSES+"
            "+WYMeditor.HTML+WYMeditor.IFRAME+WYMeditor.STATUS+"
            "+WYMeditor.LOGO+"
            ",logoHtml:String()+'WYMeditor',iframeHtml:String()+'
            ',toolsHtml:String()+'

            {Tools}

              '+WYMeditor.TOOLS_ITEMS+"
            ",toolsItemHtml:String()+'
          2. '+WYMeditor.TOOL_TITLE+"
          3. ",toolsItems:[{name:"Bold",title:"Strong",css:"wym_tools_strong"},{name:"Italic",title:"Emphasis",css:"wym_tools_emphasis"},{name:"Superscript",title:"Superscript",css:"wym_tools_superscript"},{name:"Subscript",title:"Subscript",css:"wym_tools_subscript"},{name:"InsertOrderedList",title:"Ordered_List",css:"wym_tools_ordered_list"},{name:"InsertUnorderedList",title:"Unordered_List",css:"wym_tools_unordered_list"},{name:"Indent",title:"Indent",css:"wym_tools_indent"},{name:"Outdent",title:"Outdent",css:"wym_tools_outdent"},{name:"Undo",title:"Undo",css:"wym_tools_undo"},{name:"Redo",title:"Redo",css:"wym_tools_redo"},{name:"CreateLink",title:"Link",css:"wym_tools_link wym_opens_dialog"},{name:"Unlink",title:"Unlink",css:"wym_tools_unlink"},{name:"InsertImage",title:"Image",css:"wym_tools_image wym_opens_dialog"},{name:"InsertTable",title:"Table",css:"wym_tools_table wym_opens_dialog"},{name:"Paste",title:"Paste_From_Word",css:"wym_tools_paste wym_opens_dialog"},{name:"ToggleHtml",title:"HTML",css:"wym_tools_html"},{name:"Preview",title:"Preview",css:"wym_tools_preview wym_opens_dialog"}],containersHtml:String()+'

            {Containers}

              '+WYMeditor.CONTAINERS_ITEMS+"
            ",containersItemHtml:String()+'
          4. '+WYMeditor.CONTAINER_TITLE+"
          5. ",containersItems:[{name:"P",title:"Paragraph",css:"wym_containers_p"},{name:"H1",title:"Heading_1",css:"wym_containers_h1"},{name:"H2",title:"Heading_2",css:"wym_containers_h2"},{name:"H3",title:"Heading_3",css:"wym_containers_h3"},{name:"H4",title:"Heading_4",css:"wym_containers_h4"},{name:"H5",title:"Heading_5",css:"wym_containers_h5"},{name:"H6",title:"Heading_6",css:"wym_containers_h6"},{name:"PRE",title:"Preformatted",css:"wym_containers_pre"},{name:"BLOCKQUOTE",title:"Blockquote",css:"wym_containers_blockquote"},{name:"TH",title:"Table_Header",css:"wym_containers_th"}],classesHtml:String()+'

            {Classes}

              '+WYMeditor.CLASSES_ITEMS+"
            ",classesItemHtml:String()+'
          6. '+WYMeditor.CLASS_TITLE+"
          7. ",classesItems:[],statusHtml:String()+'

            {Status}

            ',htmlHtml:String()+'

            {Source_Code}

            ',boxSelector:".wym_box",toolsSelector:".wym_tools",toolsListSelector:" ul",containersSelector:".wym_containers",classesSelector:".wym_classes",htmlSelector:".wym_html",iframeSelector:".wym_iframe iframe",iframeBodySelector:".wym_iframe",statusSelector:".wym_status",toolSelector:".wym_tools a",containerSelector:".wym_containers a",classSelector:".wym_classes a",htmlValSelector:".wym_html_val",updateSelector:".wymupdate",updateEvent:"click",stringDelimiterLeft:"{",stringDelimiterRight:"}",preInit:null,preBind:null,postInit:null},a),a=jQuery.extend(WYMeditor.DEFAULT_DIALOG_OPTIONS,a),b.each(function(){var b=this;b._wym=new WYMeditor.editor(jQuery(b),a)})},jQuery.extend({wymeditors:function(a){return WYMeditor.INSTANCES[a]}}),jQuery.extend({getWymeditorByTextarea:function(a){var b;if(!a||!a.tagName||"textarea"!==a.tagName.toLowerCase())throw"jQuery.getWymeditorByTextarea requires a textarea element.";for(b=0;b=11?!0:!1},WYMeditor._computeWymPath=function(){var a=jQuery(jQuery.grep(jQuery("script"),function(a){return a.src?a.src.match(/jquery\.wymeditor(\.pack|\.min|\.packed)?\.js(\?.*)?$/)||a.src.match(/\/core\.js(\?.*)?$/):null}));return a.length>0?a.attr("src"):(WYMeditor.console.warn("Error determining wymPath. No base WYMeditor file located."),WYMeditor.console.warn("Assuming wymPath to be the current URL"),WYMeditor.console.warn("Please pass a correct wymPath option"),"")},WYMeditor._computeBasePath=function(a){var b=a.lastIndexOf("/");return a.substr(0,b+1)},jQuery.fn.isPhantomNode=function(){var a=this;return a[0].nodeType===WYMeditor.NODE_TYPE.TEXT?!/[^\t\n\r ]/.test(a[0].data):!1},jQuery.fn.nextContentsUntil=function(a,b){var c,d=this,e=[],f=d.get(0);if(a=a?a:"",b=b?b:"",!f)return jQuery();for(f=f.nextSibling;f&&!jQuery(f).is(a);)e.push(f),f=f.nextSibling;return c=jQuery(e),b?c.filter(b):c},jQuery.fn.nextAllContents=function(){var a=this;return jQuery(a).nextContentsUntil("","")},jQuery.fn.prevContentsUntil=function(a,b){var c,d=this,e=[],f=d.get(0);if(a=a?a:"",b=b?b:"",!f)return jQuery();for(f=f.previousSibling;f&&!jQuery(f).is(a);)e.push(f),f=f.previousSibling;return c=jQuery(e),b?c.filter(b):c},jQuery.fn.prevAllContents=function(){var a=this;return jQuery(a).prevContentsUntil("","")},WYMeditor.isPhantomNode=function(a){return a.nodeType===WYMeditor.NODE_TYPE.TEXT?!/[^\t\n\r ]/.test(a.data):!1},WYMeditor.isPhantomString=function(a){return!/[^\t\n\r ]/.test(a)},jQuery.fn.addBack=jQuery.fn.addBack?jQuery.fn.addBack:jQuery.fn.andSelf,jQuery.fn.parentsOrSelf=function(a){var b=this;return a?b.parents().addBack().filter(a):b.parents().addBack()},WYMeditor.Helper={replaceAllInStr:function(a,b,c){var d=new RegExp(b,"g");return a.replace(d,c)},insertAt:function(a,b,c){return a.substr(0,c)+b+a.substring(c)},trim:function(a){return a.replace(/^(\s*)|(\s*)$/gm,"")},arrayContains:function(a,b){var c;for(c=0;c'+WYMeditor.DIALOG_TITLE+""+WYMeditor.DIALOG_BODY+"",h=[{placeholder:WYMeditor.DIRECTION,replacement:n.direction},{placeholder:WYMeditor.DIALOG_TITLE,replacement:e?l._encloseString(e.title):"Dialog"},{placeholder:WYMeditor.DIALOG_BODY,replacement:c||e.getBodyHtml.call(l)}],d=0;d
            {Link}
            '},getBodyClass:function(){var a=this;return a._options.dialogSelectorLink||"wym_dialog_link"},initialize:function(a){var b,c,d,e,f,g,h=this,i=a.document,j=h._options,k=h.selectedContainer();k&&(b=jQuery(j.hrefSelector,i),c=jQuery(j.titleSelector,i),d=jQuery(j.relSelector,i),e=jQuery(k).attr(WYMeditor.HREF),f=jQuery(k).attr(WYMeditor.TITLE),g=jQuery(k).attr(WYMeditor.REL),b.val(e),c.val(f),d.val(g))},submitHandler:function(a){var b=this,c=b._options,d=jQuery(c.hrefSelector,a.document).val(),e=jQuery(c.titleSelector,a.document).val(),f=jQuery(c.relSelector,a.document).val();b.link({href:d,title:e,rel:f}),a.close()}},InsertImage:{title:"Image",shouldOpen:function(){var a=this,b=a.getSelectedImage();return b&&b.tagName&&"img"===b.tagName.toLowerCase()?!0:a.hasSelection()},getBodyHtml:function(){var a=this;return a._options.dialogImageHtml||String()+'
            {Image}
            '},getBodyClass:function(){var a=this;return a._options.dialogImageSelector||"wym_dialog_image"},initialize:function(a){var b,c,d,e,f,g,h=this,i=a.document,j=h._options,k=h.getSelectedImage();k&&(b=jQuery(j.srcSelector,i),c=jQuery(j.titleSelector,i),d=jQuery(j.altSelector,i),e=jQuery(k).attr(WYMeditor.SRC),f=jQuery(k).attr(WYMeditor.TITLE),g=jQuery(k).attr(WYMeditor.ALT),b.val(e),c.val(f),d.val(g))},submitHandler:function(a){var b,c=this,d=c._options,e=c.getSelectedImage();b={src:jQuery(d.srcSelector,a.document).val(),title:jQuery(d.titleSelector,a.document).val(),alt:jQuery(d.altSelector,a.document).val()},c.focusOnDocument(),e?(c._updateImageAttrs(e,b),c.registerModification()):c.insertImage(b),a.close()}},InsertTable:{title:"Table",shouldOpen:function(){var a=this;return a.hasSelection()!==!0||a.selection().isCollapsed!==!0?!1:!0},getBodyHtml:function(){var a=this;return a._options.dialogTableHtml||String()+'
            {Table}
            '},getBodyClass:function(){var a=this;return a._options.dialogTableSelector||"wym_dialog_table"},submitHandler:function(a){var b=this,c=b._options,d=a.document,e=jQuery(c.rowsSelector,d).val(),f=jQuery(c.colsSelector,d).val(),g=jQuery(c.captionSelector,d).val(),h=jQuery(c.summarySelector,d).val();b.insertTable(e,f,g,h),a.close()}},Paste:{title:"Paste_From_Word",shouldOpen:function(){var a=this;return a.hasSelection()},getBodyHtml:function(){var a=this;return a._options.dialogPasteHtml||String()+'
            {Paste_From_Word}
            '},getBodyClass:function(){var a=this;return a._options.dialogPasteSelector||"wym_dialog_paste"},submitHandler:function(a){var b,c=this;b=jQuery(c._options.textSelector,a.document).val(),c.paste(b),a.close()}},Preview:{title:"Preview",shouldOpen:function(){return!0},getBodyHtml:function(){var a=this;return a._options.dialogPreviewHtml||a.html()},getWindowFeatures:function(){return["menubar=no","titlebar=no","toolbar=no","resizable=no","width=560","height=300","top=0","left=0","scrollbars=yes"].join(",")},getBodyClass:function(){var a=this;return a._options.dialogPreviewSelector||"wym_dialog_preview"}}},WYMeditor.DIALOG_TITLE="{Wym_Dialog_Title}",WYMeditor.DIALOG_BODY="{Wym_Dialog_Body}",WYMeditor.DIALOG_BUTTON_SELECTOR=".wym_opens_dialog a",WYMeditor.DEFAULT_DIALOG_OPTIONS={hrefSelector:".wym_href",srcSelector:".wym_src",titleSelector:".wym_title",relSelector:".wym_rel",altSelector:".wym_alt",textSelector:".wym_text",rowsSelector:".wym_rows",colsSelector:".wym_cols",captionSelector:".wym_caption",summarySelector:".wym_summary",submitSelector:"form",cancelSelector:".wym_cancel",previewSelector:"",dialogLinkSelector:".wym_dialog_link",dialogImageSelector:".wym_dialog_image",dialogTableSelector:".wym_dialog_table",dialogPasteSelector:".wym_dialog_paste",dialogPreviewSelector:".wym_dialog_preview"},WYMeditor.editor.prototype._init=function(){var wym=this,WymClass,browserInstance,SaxListener,prop,h,iframeHtml,boxHtml,aTools,sTools,oTool,sTool,i,aClasses,sClasses,oClass,sClass,aContainers,sContainers,sContainer,oContainer;if(WymClass=WYMeditor._getWymClassForBrowser()){browserInstance=new WymClass(wym),jQuery.isFunction(wym._options.preInit)&&wym._options.preInit(wym),wym.parser=null,wym.helper=null,SaxListener=new WYMeditor.XhtmlSaxListener,wym.parser=new WYMeditor.XhtmlParser(SaxListener),wym.helper=new WYMeditor.XmlHelper;for(prop in browserInstance)wym[prop]=browserInstance[prop];for(wym._box=jQuery(wym.element).hide().after(wym._options.boxHtml).next().addClass("wym_box_"+wym._index),jQuery.isFunction(jQuery.fn.data)&&(jQuery.data(wym._box.get(0),WYMeditor.WYM_INDEX,wym._index),jQuery.data(wym.element.get(0),WYMeditor.WYM_INDEX,wym._index)),h=WYMeditor.Helper,iframeHtml=wym._options.iframeHtml,iframeHtml=h.replaceAllInStr(iframeHtml,WYMeditor.IFRAME_BASE_PATH,wym._options.iframeBasePath),boxHtml=jQuery(wym._box).html(),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.LOGO,wym._options.logoHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.TOOLS,wym._options.toolsHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.CONTAINERS,wym._options.containersHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.CLASSES,wym._options.classesHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.HTML,wym._options.htmlHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.IFRAME,iframeHtml),boxHtml=h.replaceAllInStr(boxHtml,WYMeditor.STATUS,wym._options.statusHtml),aTools=eval(wym._options.toolsItems),sTools="",i=0;i-1?!0:!1},WYMeditor.editor.prototype.isInlineNode=function(a){return a.nodeType===WYMeditor.NODE_TYPE.TEXT||jQuery.inArray(a.tagName.toLowerCase(),WYMeditor.INLINE_ELEMENTS)>-1?!0:!1},WYMeditor.editor.prototype.isListNode=function(a){return a.tagName&&jQuery.inArray(a.tagName.toLowerCase(),WYMeditor.LIST_TYPE_ELEMENTS)>-1?!0:!1},WYMeditor.editor.prototype.unwrapIfMeaninglessSpan=function(a){var b,c=jQuery(a),d=0,e=["_wym_visited","length","ie8_length"];if(!a||"undefined"==typeof a.tagName||"span"!==a.tagName.toLowerCase())return!1;for(;d0&&(g=e.item(0)),h=0;f>h;h+=1)d.parentNode.insertBefore(e.item(0),d);d.parentNode.removeChild(d),g&&i.setCaretIn(g)}else i.restoreSelectionAfterManipulation(function(){return i.switchTo(j,a,!1),!0});i.update(),i.registerModification()}return!1},WYMeditor.editor.prototype.isForbiddenRootContainer=function(a){return jQuery.inArray(a.toLowerCase(),WYMeditor.FORBIDDEN_ROOT_CONTAINERS)>-1},WYMeditor.editor.prototype.keyCanCreateBlockElement=function(a){return jQuery.inArray(a,WYMeditor.POTENTIAL_BLOCK_ELEMENT_CREATION_KEYS)>-1},WYMeditor.editor.prototype.toggleClass=function(a,b){var c,d=this;c=jQuery(d.getSelectedImage()),1!==c.length&&(c=jQuery(d.selectedContainer()).parentsOrSelf(b).last()),c.toggleClass(a),c.attr(WYMeditor.CLASS)||c.removeAttr(d._class),d.registerModification()},WYMeditor.editor.prototype.getSelectedImage=function(){var a,b,c=this;return c.hasSelection()!==!0?!1:c.selection().isCollapsed!==!1?!1:(a=c._getSelectedNodes(),1!==a.length?!1:(b=a[0],b.tagName&&"img"===b.tagName.toLowerCase()?b:!1))},WYMeditor.editor.prototype.findUp=function(a,b){if("undefined"==typeof a||null===a)return null;"#text"===a.nodeName&&(a=a.parentNode);var c,d,e=a.tagName.toLowerCase();if(typeof b===WYMeditor.STRING)for(;e!==b&&e!==WYMeditor.BODY;)a=a.parentNode,e=a.tagName.toLowerCase();else for(c=!1;!c&&e!==WYMeditor.BODY;){for(d=0;d"),jQuery(b.element).trigger(WYMeditor.EVENTS.postBlockMaybeCreated,b)},WYMeditor.editor.prototype._spaceBlockingElements=function(){var a,b,c,d,e,f,g=this,h=WYMeditor.DocumentStructureManager.CONTAINERS_BLOCKING_NAVIGATION.join(", "),i=g.$body(),j=i.children();a=jQuery.browser.mozilla?'
            ':'
            ',j.length>0&&(b=jQuery(j[0]),c=jQuery(j[j.length-1]),b.is(h)&&b.before(a),c.is(h)&&c.after(a)),d=g._getBlockSepSelector(),i.find(d).before(a),e=g._getBlockInListSepSelector(),f=i.find(e),f.each(function(){var b=this,c=jQuery(b);c.next(h).length||c.next("br").length||c.after(a)})},WYMeditor.editor.prototype._getBlockSepSelector=function(){var a,b=this,c=[],d=WYMeditor.DocumentStructureManager.CONTAINERS_BLOCKING_NAVIGATION;return"undefined"!=typeof b._blockSpacersSel?b._blockSpacersSel:(a=jQuery.grep(b.documentStructureManager.structureRules.validRootContainers,function(a){return-1===jQuery.inArray(a,d)}),jQuery.each(d,function(a,b){jQuery.each(d,function(a,d){c.push(b+" + "+d)})}),jQuery.each(d,function(b,d){jQuery.each(a,function(a,b){c.push(d+" + "+b),c.push(b+" + "+d)})}),b._blockSpacersSel=c.join(", "),b._blockSpacersSel)},WYMeditor.editor.prototype._getBlockInListSepSelector=function(){var a=this,b=[];return"undefined"!=typeof a._blockInListSpacersSel?a._blockInListSpacersSel:(jQuery.each(WYMeditor.LIST_TYPE_ELEMENTS,function(a,c){jQuery.each(WYMeditor.BLOCKING_ELEMENTS,function(a,d){b.push(c+" "+d)})}),a._blockInListSpacersSel=b.join(", "),a._blockInListSpacersSel)},WYMeditor.editor.prototype._fixDoubleBr=function(){var a,b=this,c=b.$body();c.children("br + br").filter(":not(pre br)").remove(),c.find("p + br").next("p").prev("br").remove(),a=c.find("p + br").slice(-1),a.length>0&&0===a.next().length&&a.remove()},WYMeditor.editor.prototype.link=function(a){var b,c,d,e=this;if(jQuery.isPlainObject(a)!==!0)throw"Expected a plain object.";a.hasOwnProperty("href")===!0&&"string"==typeof a.href&&0!==a.href.length&&(b=jQuery(e.selectedContainer()),b.is("a")?d=b:(c=e.uniqueStamp(),e._exec(WYMeditor.EXEC_COMMANDS.CREATE_LINK,c),d=jQuery("a[href="+c+"]",e.body())),0!==d.length&&(d.attr(a),e.registerModification()))},WYMeditor.editor.prototype.insertImage=function(a){var b,c,d=this;if(jQuery.isPlainObject(a)!==!0)throw"Expected a plain object.";a.hasOwnProperty("src")===!0&&"string"==typeof a.src&&0!==a.src.length&&(b=d.uniqueStamp(),d._exec(WYMeditor.EXEC_COMMANDS.INSERT_IMAGE,b),c=jQuery("img[src="+b+"]",d.body()),0!==c.length&&(c.attr(a),d.$body().find(".Apple-style-span").children().unwrap(),d.registerModification()))},WYMeditor.editor.prototype._updateImageAttrs=function(a,b){var c=jQuery(a);b.src!==c.attr("src")&&(c.data("DimensionsRatio",null),c.removeAttr("height").removeAttr("width")),c.attr(b)},WYMeditor.editor.prototype.toggleHtml=function(){var a=this;jQuery(a._box).find(a._options.htmlSelector).toggle()},WYMeditor.editor.prototype.uniqueStamp=function(){var a=new Date;return"wym"+a.getTime()},WYMeditor.editor.prototype._handleMultilineBlockContainerPaste=function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;for(f=jQuery(o),h="p",b.is("li")&&(h="li"),c.splitBoundaries(),o=a.findUp(c.startContainer,["p","h1","h2","h3","h4","h5","h6","li"]),p=o.tagName,i=[],j=[],jQuery(o).contents().each(function(a,b){k=c.compareNode(b),k===c.NODE_BEFORE||k===c.NODE_BEFORE_AND_AFTER&&c.startOffset===c.startContainer.length?i.push(b):j.push(b)}),e=0;e0&&jQuery(o).prepend(i),j.length>0&&(l=jQuery("<"+p+">",a._doc),l.insertAfter(jQuery(o)),l.append(j)),m=d.splice(0,1)[0],n=m.split(WYMeditor.NEWLINE).join("
            "),jQuery(o).html(jQuery(o).html()+n),f=jQuery(o),e=0;e"+d[e].split(WYMeditor.NEWLINE).join("
            ")+"",f=jQuery(g,a._doc).insertAfter(f)},WYMeditor.editor.prototype.paste=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.selectedContainer(),l=jQuery(k),m="",n=!1,o=j.selection(),p=o.getRangeAt(0);if(p.collapse(!0),b=a.split(new RegExp(WYMeditor.NEWLINE+"{2,}","g")),1===b.length&&(n=!0),"undefined"==typeof k||k&&k.tagName.toLowerCase()===WYMeditor.BODY)if(n)f=jQuery("

            "+b[0]+"

            ",j._doc).appendTo(j._doc.body);else for(e="p",g=b.length-1;g>=0;g-=1)for(m="<"+e+">"+b[g].split(WYMeditor.NEWLINE).join("
            ")+"",i=jQuery(m,j._doc),c=i.length-1;c>=0;c--)p.insertNode(i[c]);else if(n||l.is("pre"))h=j._doc.createTextNode(a),p.insertNode(h);else if(l.is("p,h1,h2,h3,h4,h5,h6,li"))j._handleMultilineBlockContainerPaste(j,l,p,b);else for(d=a.split(WYMeditor.NEWLINE),g=d.length-1;g>=0;g-=1)h=j._doc.createTextNode(d[g]),p.insertNode(h),g>0&&p.insertNode(jQuery("
            ",j._doc).get(0));j.registerModification()},WYMeditor.editor.prototype.insert=function(a){var b,c,d=this,e=d.hasSelection()?d.selection():!1;e&&(b=e.getRangeAt(0),c=b.createContextualFragment(a),b.deleteContents(),b.insertNode(c))},WYMeditor.editor.prototype.canSetCaretBefore=function(a){var b=this;if(a.nodeType===WYMeditor.NODE_TYPE.TEXT)return!0;if(a.tagName&&"br"===a.tagName.toLowerCase()){if(!a.previousSibling)return!0;if(a.previousSibling.tagName&&"br"===a.previousSibling.tagName.toLowerCase())return!0;if(b.isBlockNode(a.previousSibling))return!0;if(a.previousSibling.nodeType===WYMeditor.NODE_TYPE.TEXT)return!0}return!1},WYMeditor.editor.prototype.setCaretBefore=function(a){var b=this,c=rangy.createRange(b._doc),d=b.selection();if(!b.canSetCaretBefore(a))throw"Can't set caret before this node.";c.selectNode(a),c.collapse(!0),d.setSingleRange(c)},WYMeditor.editor.prototype.canSetCaretIn=function(a){var b=this;if(a.nodeType===WYMeditor.NODE_TYPE.TEXT||a.tagName&&jQuery.inArray(a.tagName.toLowerCase(),WYMeditor.NO_CARET_ELEMENTS)>-1)return!1;if(b.isInlineNode(a)){if(0===a.childNodes.length)return!1;WYMeditor.console.warn("Can set a non-collapsed selection. Rangy issue #209.")}return!0},WYMeditor.editor.prototype.setCaretIn=function(a){var b=this,c=rangy.createRange(b._doc),d=b.selection();if(!b.canSetCaretIn(a))throw"The element must be able to contain other elements. Perhaps you would like to use `setCaretBefore`, instead.";c.selectNodeContents(a),b.isInlineNode(a)?WYMeditor.console.warn("Can't set a collapsed selection. Setting a non-collapsed selection, instead. Rangy issue #209."):c.collapse(!0),d.setSingleRange(c)},WYMeditor.editor.prototype._splitListItemContents=function(a){var b,c,d,e=!1,f={itemContents:[],sublistContents:[]};for(b=a.contents(),c=0;c',b.before(d),i=b.prev()),j=i.contents().last().filter("ol,ul"),j.length>0?(j.append(b),h.detach(),i.append(h),k=h.first(),n._joinAdjacentLists(j.get(0),k.get(0))):(h.length>0?(h.detach(),i.append(h),j=h.first()):(e="<"+c+">",i.append(e),j=i.contents().last()),j.prepend(b)),b.next().is(".spacer_li")&&(l=b.next(".spacer_li"),m=l.contents(),m.detach(),b.append(m),l.remove())},WYMeditor.editor.prototype._outdentSingleItem=function(a){var b,c,d,e,f,g,h,i,j,k,l,m=this;if(b=jQuery(a),c=b.parent()[0].tagName.toLowerCase(),b.parent().parent().is("ol,ul,li")){if(b.parent().parent().is("li")||(WYMeditor.console.log("Attempting to fix invalid list nesting before outdenting."),m._fixInvalidListNesting(a)),e=m._splitListItemContents(b),g=jQuery(e.sublistContents),f=jQuery(e.itemContents),h=b.parent().parent("li"),0===h.length)return void WYMeditor.console.error("Invalid list. No parentLi found, so aborting outdent");i=b.parent(),j=b.nextAllContents(),k=i.nextAllContents(),b.detach(),h.after(b),g.length>0&&(d="<"+c+'>
          8. ",b.append(d),l=b.children().last(),g.detach(),l.children("li").append(g)),j.length>0&&("undefined"==typeof l&&(d="<"+c+">",b.append(d),l=b.children().last()),j.detach(),l.append(j)),k.length>0&&(k.detach(),b.contents().length>0&&b.contents().last()[0].nodeType===WYMeditor.NODE_TYPE.TEXT&&k[0].nodeType===WYMeditor.NODE_TYPE.TEXT&&b.append("
            "),b.append(k)),0===i.contents().length&&i.remove(),0===h.contents().length&&h.remove()}},WYMeditor.editor.prototype._fixInvalidListNesting=function(a,b){var c,d,e=this,f=a;if("undefined"==typeof b&&(b=!1),!f)return b;for(;f.parentNode&&(c=f.parentNode,c.nodeType===WYMeditor.NODE_TYPE.ELEMENT)&&(d=c.tagName.toLowerCase(),"ol"===d||"ul"===d||"li"===d);)f=c;return jQuery(f).is("li")?(WYMeditor.console.log("Correcting orphaned root li before correcting invalid list nesting."),e._correctOrphanedListItem(f),e._fixInvalidListNesting(f,!0)):jQuery(f).is("ol,ul")?e._fixInvalidlyNestedList(f,b):(WYMeditor.console.error("Can't correct invalid list nesting. No root list found"),b)},WYMeditor.editor.prototype._isPOrDivAfterEnterInEmptyNestedLi=function(a){if(jQuery.inArray(a.tagName.toLowerCase(),WYMeditor.DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS)>-1&&"li"===a.parentNode.tagName.toLowerCase())switch(a.childNodes.length){case 0:return!0;case 1:if(a.childNodes[0].tagName&&"br"===a.childNodes[0].tagName.toLowerCase())return!0;if(a.childNodes[0].nodeType===WYMeditor.NODE_TYPE.TEXT&&a.childNodes[0].data===WYMeditor.NBSP)return!0}return!1},WYMeditor.editor.prototype._isSpilledListAfterEnterInEmptyLi=function(a){var b=this;return"li"===a.tagName.toLowerCase()&&a.previousSibling&&b.isListNode(a.previousSibling)&&a.previousSibling.previousSibling&&"li"===a.previousSibling.previousSibling.tagName.toLowerCase()&&b.isListNode(a.parentNode)?!0:!1},WYMeditor.editor.prototype._handlePotentialEnterInEmptyNestedLi=function(a,b){if(a!==WYMeditor.KEY_CODE.ENTER)return null;var c=this;c._isPOrDivAfterEnterInEmptyNestedLi(b)?c._replaceNodeWithBrAndSetCaret(b):c._isSpilledListAfterEnterInEmptyLi(b)&&(c._appendSiblingsUntilNextLiToPreviousLi(b),c._replaceNodeWithBrAndSetCaret(b))},WYMeditor.editor.prototype._replaceNodeWithBrAndSetCaret=function(a){var b=this,c=jQuery(a);(a.previousSibling&&!a.previousSibling.tagName||"br"!==a.previousSibling.tagName.toLowerCase()&&b.isInlineNode(a.previousSibling))&&c.before("
            "),c.before("
            "),b.setCaretBefore(a.previousSibling),c.remove()},WYMeditor.editor.prototype._appendSiblingsUntilNextLiToPreviousLi=function(a){var b,c=jQuery(a),d=c.parent().contents(),e=c.prevAll("li").first(),f=c.nextAll("li").first(),g=e.index()+1;b=1===f.length?d.slice(g,f.index()):d.slice(g),e.append(b)},WYMeditor.editor.prototype._correctOrphanedListItem=function(a){var b,c,d,e,f=jQuery();b=jQuery(a).prevContentsUntil(":not(li)"),c=jQuery(a).nextContentsUntil(":not(li)"),f=f.add(b),f=f.add(a),f=f.add(c),e=f[0].previousSibling,e&&jQuery(e).is("ol,ul")?d=e:(f.before("
              "),d=f.prev()[0]),jQuery(d).append(f)},WYMeditor.editor.prototype._fixInvalidlyNestedList=function(a,b){var c,d,e,f,g,h,i=a,j=a,k=!1,l='
            1. ';for("undefined"!=typeof b&&(k=b);j;)if(j._wym_visited){if(j._wym_visited=!1,j===i)break;j=j.previousSibling?j.previousSibling:j.parentNode}else{if(j!==i&&!jQuery(j).is("li"))for(e=j;e.parentNode&&(e=e.parentNode,!jQuery(e).is("li"))&&e.nodeType===WYMeditor.NODE_TYPE.ELEMENT;)if(d=e.tagName.toLowerCase(),"ol"===d||"ul"===d){for(WYMeditor.console.log("Fixing orphaned list content"),k=!0,f=[j],c=j,g=null;c.previousSibling;){if(c=c.previousSibling,jQuery(c).is("li")){g=c;break}f.push(c)}f.reverse(),g||1!==f.length||jQuery(j.nextSibling).is("li")&&(g=j.nextSibling),g||(jQuery(f[0]).before(l),g=jQuery(f[0]).prev()[0]),h=jQuery(g).contents().last(),1===h.length&&h[0].nodeType===WYMeditor.NODE_TYPE.TEXT&&f[0].nodeType===WYMeditor.NODE_TYPE.TEXT&&jQuery(g).append("
              "),jQuery(g).append(jQuery(f));break}j.lastChild?(j._wym_visited=!0,j=j.lastChild):j=j.previousSibling?j.previousSibling:j.parentNode}return k},WYMeditor.editor.prototype._getCommonParentList=function(a,b){var c,d,e,f=!0;return a=jQuery(a).filter("li"),0===a.length?null:(c=a[0],d=jQuery(c).parents("ol,ul"),d=b?d.first():d.last(),0===d.length?null:(e=d[0],jQuery(a).each(function(a,c){d=jQuery(c).parents("ol,ul"),d=b?d.first():d.last(),(0===d.length||d[0]!==e)&&(f=!1)}),f?e:null))},WYMeditor.editor.prototype.deselect=function(){var a=this;a.selection().removeAllRanges(),a.body().blur()},WYMeditor.editor.prototype._getSelectedNodes=function(){var a,b=this,c=b.selection();return b.hasSelection()!==!0?!1:a=c.getAllRanges().reduce(function(a,b){return a.concat(b.getNodes())},[])},WYMeditor.editor.prototype._getSelectedListItems=function(a){var b,c,d,e=this;return a.isCollapsed?(b=jQuery(e.selectedContainer()),b.closest("li, table").is("table")?[]:b.closest("li")):(c=jQuery(e._getSelectedNodes()),0===c.closest("li, table").filter("li").length?[]:(d=c.not("li, ol, ul").add(c.find(".rangySelectionBoundary")).add(c.filter(function(){return e.nodeType===WYMeditor.NODE_TYPE.TEXT})).closest("li").add(c.filter("li:empty")).not(c.filter("table").find("li")),jQuery.unique(d.get())))},WYMeditor.editor.prototype._selectionOnlyInList=function(a){var b,c,d,e=this;for(d=0;d0){if(c=jQuery(b),d=c.parent(":not("+a+")"),!(d.length>0))return g._removeItemsFromList(c),!0;if(e=g._getCommonParentList(b,!0))return g.changeListType(e,a),!0}return f=g.findUp(g.selectedContainer(),WYMeditor.POTENTIAL_LIST_ELEMENTS),f?(g.convertToList(f,a),!0):!1},WYMeditor.editor.prototype.changeListType=function(a,b){var c=this;return c.switchTo(a,b)},WYMeditor.editor.prototype.convertToList=function(a,b){var c,d,e=this,f=jQuery(a);return c="<"+b+">
            2. ",e.findUp(a,WYMeditor.ROOT_CONTAINERS)===a?(f.wrapInner(c),d=f.children(),d.unwrap(),d.get(0)):(f.wrapInner(c),d=f.children(),d.get(0))},WYMeditor.editor.prototype._removeItemsFromList=function(a){var b,c,d,e,f,g,h,i,j=this,k=j.documentStructureManager.structureRules.defaultRootContainer;for(c=0;c"),jQuery(b.prevAll().toArray().reverse()).appendTo(b.parent().prev()),b.parent().before(b)):b[0]===b.parent().children().last()[0]&&b.parent().after(b),d=0;d"):h[0].tagName&&!j.isBlockNode(h[0])&&"br"!==h[0].tagName.toLowerCase()&&j.switchTo(f[g],k,!1);b.after(b.contents().slice(d));break}j.$body().children("br").remove(),"span"===b[0].tagName.toLowerCase()&&(0===b.contents(":not(.rangySelectionBoundary)").length||b.contents(":not(.rangySelectionBoundary)").length===b.contents("br").length?(b.before(b.contents(".rangySelectionBoundary")),b.remove()):((b[0].previousSibling&&b[0].previousSibling.nodeType===WYMeditor.NODE_TYPE.TEXT||b.prevAll(":not(.rangySelectionBoundary)").length>0&&j.isBlockNode(b.prevAll(":not(.rangySelectionBoundary)")[0])===!1)&&b.before("
              "),(b[0].nextSibling&&b[0].nextSibling.nodeType===WYMeditor.NODE_TYPE.TEXT||b.nextAll(":not(.rangySelectionBoundary)").length>0&&j.isBlockNode(b.nextAll(":not(.rangySelectionBoundary)")[0])===!1)&&b.after("
              "),i=b[0].attributes,j.unwrapIfMeaninglessSpan(b[0])))}j.prepareDocForEditing()},WYMeditor.editor.prototype.insertTable=function(a,b,c,d){if(!(0>=a||0>=b)){var e,f,g,h,i,j=this,k=j._doc.createElement(WYMeditor.TABLE),l=null;for(e=k.createCaption(),e.innerHTML=c,f=0;a>f;f+=1)for(l=k.insertRow(f),g=0;b>g;g+=1)l.insertCell(g);if(""!==d&&jQuery(k).attr("summary",d),h=jQuery(j.findUp(j.selectedContainer(),WYMeditor.POTENTIAL_TABLE_INSERT_ELEMENTS)).get(0),h&&h.parentNode)if(jQuery.inArray(h.nodeName.toLowerCase(),WYMeditor.INLINE_TABLE_INSERTION_ELEMENTS)>-1){if(i=j.selection().focusNode,jQuery.inArray(i.nodeName.toLowerCase(),WYMeditor.SELECTABLE_TABLE_ELEMENTS)>-1||jQuery.inArray(i.parentNode.nodeName.toLowerCase(),WYMeditor.SELECTABLE_TABLE_ELEMENTS)>-1)for(;i.nodeName.toLowerCase()!==WYMeditor.TABLE;)i=i.parentNode;i.nodeName.toLowerCase()===WYMeditor.LI?jQuery(i).append(k):jQuery(i).after(k)}else jQuery(h).after(k);else j.$body().append(k);return j._afterInsertTable(k),j.prepareDocForEditing(),j.registerModification(),k}},WYMeditor.editor.prototype._afterInsertTable=function(){},WYMeditor.editor.prototype._listen=function(){var a=this;jQuery(a._doc).bind("paste",function(){a._handlePasteEvent()})},WYMeditor.editor.prototype._handlePasteEvent=function(){var a=this;window.setTimeout(function(){jQuery(a.element).trigger(WYMeditor.EVENTS.postBlockMaybeCreated,a)},20)},WYMeditor.editor.prototype._selectSingleNode=function(a){var b,c,d=this;if(!a)throw"Expected a node";b=d.selection(),c=rangy.createRangyRange(),c.selectNode(a),b.setSingleRange(c)},WYMeditor.editor.prototype._initSkin=function(){var a=this;jQuery(a._box).addClass("wym_skin_"+a._options.skin),"undefined"!=typeof WYMeditor.SKINS[a._options.skin]?"function"==typeof WYMeditor.SKINS[a._options.skin].init&&WYMeditor.SKINS[a._options.skin].init(a):WYMeditor.console.warn("Chosen skin _"+a.options.skin+"_ not found.")},WYMeditor.editor.prototype.body=function(){var a,b=this;if(!b._doc.body)throw"The document seems to have no body element.";if(a=b._doc.body,!a.tagName||"body"!==a.tagName.toLowerCase())throw"The document's body doesn't seem to be a `body` element.";return a},WYMeditor.editor.prototype.$body=function(){var a,b=this;return a=b.body(),jQuery(a)},WYMeditor.editor.prototype.doesElementContainSelection=function(a){var b,c,d,e,f,g,h=this;if(h.hasSelection()!==!0)return!1;if(b=jQuery(a),h.selection().isCollapsed===!0)return c=h.selectedContainer(),a===c?!0:b.has(c).length>0?!0:!1;for(d=jQuery(h._getSelectedNodes()),e=0;e-1&&a.eq(g).remove(),d===k&&(e=!1);e&&(f=j._options.containersItemHtml,f=WYMeditor.Helper.replaceAllInStr(f,WYMeditor.CONTAINER_NAME,k.toUpperCase()),h=WYMeditor.DocumentStructureManager,f=WYMeditor.Helper.replaceAllInStr(f,WYMeditor.CONTAINER_TITLE,h.DEFAULT_ROOT_CONTAINER_TITLES[k]),f=WYMeditor.Helper.replaceAllInStr(f,WYMeditor.CONTAINER_CLASS,"wym_containers_"+k),c=jQuery(f),a=jQuery(j._box).find(j._options.containersSelector).find("li"),a.eq(0).before(c),c.find("a").click(function(){var a=this;return j.setRootContainer(jQuery(a).attr(WYMeditor.NAME)),!1}))},WYMeditor.ImageHandler=function(a){var b=this;return b._wym=a,b._$resizeHandle=b._createResizeHandle(),b._$currentImageMarker=null,b._$currentImg=null,b._resizingNow=!1,b._imgDragDropAllowed=WYMeditor.ImageHandler._isImgDragDropAllowed(),b._addEventListeners(),b},WYMeditor.ImageHandler._isImgDragDropAllowed=function(){var a=jQuery.browser;return a.msie&&a.versionNumber<=9?!1:!0},WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML=jQuery("
              ").addClass(WYMeditor.EDITOR_ONLY_CLASS).css({margin:0,padding:0}).attr("outerHTML"),WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML=["drag this to resize","click on image to select"].join(WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML),WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR="yellow",WYMeditor.ImageHandler.prototype._createResizeHandle=function(){var a=jQuery("
              ");return a.attr("contentEditable","false"),a.html(WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML),a.addClass(WYMeditor.RESIZE_HANDLE_CLASS).addClass(WYMeditor.EDITOR_ONLY_CLASS),a.css({margin:"0",padding:"0",cursor:"row-resize","text-align":"center",position:"absolute","background-color":WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR,"background-image":"none","min-width":"13em",width:"100%"}),a},WYMeditor.ImageHandler.prototype._getCurrentImageMarker=function(){ -var a=this;return a._$currentImageMarker&&a._$currentImageMarker.length||(a._$currentImageMarker=a._createCurrentImageMarker()),a._$currentImageMarker},WYMeditor.ImageHandler._IMAGE_MARKER_CLASS="wym-image-marker",WYMeditor.ImageHandler.prototype._createCurrentImageMarker=function(){return jQuery("
              ").addClass(WYMeditor.EDITOR_ONLY_CLASS).addClass(WYMeditor.ImageHandler._IMAGE_MARKER_CLASS).hide()},WYMeditor.ImageHandler.prototype._addEventListeners=function(){var a=this,b=jQuery(a._wym._doc);b.delegate("img","mouseover",a._onImgMouseover.bind(a)),b.delegate("img","click",a._onImgClick.bind(a)),b.delegate("."+WYMeditor.RESIZE_HANDLE_CLASS,"mousedown",a._onResizeHandleMousedown.bind(a)),b.delegate("img","mousedown",a._onImgMousedown.bind(a)),b.delegate("img","dragstart",a._onImgDragstart.bind(a)),b.bind("mousemove",a._onMousemove.bind(a)),b.bind("mouseup",a._onMouseup.bind(a)),a._edited=new WYMeditor.EXTERNAL_MODULES.Edited(b[0],function(){},a._onAnyNativeEdit.bind(a)),b.delegate("."+WYMeditor.RESIZE_HANDLE_CLASS,"click dblclick",a._onResizeHandleClickDblclick.bind(a))},WYMeditor.ImageHandler.prototype._onImgMouseover=function(a){var b=this,c=jQuery(a.target);!c.data("cE disabled")&&jQuery.browser.msie&&(c.attr("contentEditable","false"),c.data("cE disabled",!0)),b._setImgCursor(c)},WYMeditor.ImageHandler.prototype._setImgCursor=function(a){var b=this;return b._wym.getSelectedImage()!==a[0]?void a.css("cursor","pointer"):void(b._imgDragDropAllowed?a.css("cursor","move"):a.css("cursor","default"))},WYMeditor.ImageHandler.prototype._onImgClick=function(a){var b=this;return b._selectImage(a.target),b._indicateOnResizeHandleThatImageIsSelected(),!1},WYMeditor.ImageHandler.prototype._selectImage=function(a){var b=this,c=jQuery(a);jQuery.browser.msie&&8===jQuery.browser.versionNumber?setTimeout(function(){b._wym._selectSingleNode(a)},0):b._wym._selectSingleNode(a),b._setImgCursor(c)},WYMeditor.ImageHandler.prototype._indicateOnResizeHandleThatImageIsSelected=function(){var a=this,b="image is selected";a._imgDragDropAllowed&&(b=[b,"drag image to move it"].join(WYMeditor.ImageHandler._RESIZE_HANDLE_HR_HTML)),a._$resizeHandle.css("font-weight","bold").html(b),setTimeout(function(){a._$resizeHandle.css("font-weight","normal").html(WYMeditor.ImageHandler._RESIZE_HANDLE_INNER_HTML)},1e3)},WYMeditor.ImageHandler.prototype._placeResizeHandleOnImg=function(a){var b=this,c="0.8em",d=jQuery(a);b._$currentImg=d,b._getCurrentImageMarker().insertAfter(d),d.css({"background-color":WYMeditor.ImageHandler._IMAGE_HIGHLIGHT_COLOR,"padding-top":c,"padding-right":c,"padding-bottom":"0","padding-left":c,"margin-top":"-"+c,"margin-right":"-"+c,"margin-bottom":"0","margin-left":"-"+c}),b._$resizeHandle.prependTo(b._wym.$body()),b._correctResizeHandleOffsetAndWidth(),b._$resizeHandle.show()},WYMeditor.ImageHandler.prototype._correctResizeHandleOffsetAndWidth=function(){var a=this;a._$resizeHandle.css("max-width",a._$currentImg.outerWidth());var b=a._$currentImg.offset();a._$resizeHandle.css("left",b.left);var c=b.top+a._$currentImg.outerHeight();jQuery.browser.msie&&c--,a._$resizeHandle.css("top",c)},WYMeditor.ImageHandler.prototype._onResizeHandleMousedown=function(a){var b=this;return b._resizingNow||b._startResize(a.clientY),!1},WYMeditor.ImageHandler.prototype._startResize=function(a){var b=this;b._startMouseY=a,b._$currentImg.data("StartHeight",b._$currentImg.height()),b._resizingNow=!0},WYMeditor.ImageHandler.prototype._onMousemove=function(a){var b=this;if(a.target.tagName){if(b._resizingNow)return b._resizeImage(a.clientY),!1;if("img"===a.target.tagName.toLowerCase()&&!b._isResizeHandleAttached())return b._placeResizeHandleOnImg(a.target),!1;if(b._isResizeHandleAttached())return(jQuery(a.target).hasClass(WYMeditor.EDITOR_ONLY_CLASS)||b._isCurrentImg(a.target))&&b._isCurrentImgAtMarker()?void 0:void b._detachResizeHandle()}},WYMeditor.ImageHandler.prototype._isCurrentImgAtMarker=function(){var a=this,b=a._$currentImageMarker;if(!b.length)return!1;var c=a._$currentImg,d=b.prev("img");return c.length&&d.length&&d[0]===c[0]?!0:!1},WYMeditor.ImageHandler.prototype._isResizeHandle=function(a){return jQuery(a).hasClass(WYMeditor.RESIZE_HANDLE_CLASS)},WYMeditor.ImageHandler.prototype._isCurrentImg=function(a){var b=this;return a===b._$currentImg[0]},WYMeditor.ImageHandler.prototype._resizeImage=function(a){var b=this,c=b._$currentImg,d=c.data("DimensionsRatio");if(!d){var e=c.height(),f=c.width();d=f/e,c.data("DimensionsRatio",d)}var g=c.data("StartHeight"),h=g-b._startMouseY+a;h=h>0?h:0;var i=h*d;c.attr("height",h),c.attr("width",i),b._correctResizeHandleOffsetAndWidth()},WYMeditor.ImageHandler.prototype._onMouseup=function(){var a=this;a._resizingNow&&a._stopResize()},WYMeditor.ImageHandler.prototype._stopResize=function(){var a=this;a._resizingNow=!1,a._startMouseY=null,a._wym.registerModification()},WYMeditor.ImageHandler.prototype._onImgMousedown=function(a){var b=this;return jQuery.browser.msie&&11===jQuery.browser.versionNumber&&b._selectImage(a.target),b._imgDragDropAllowed},WYMeditor.ImageHandler.prototype._onAnyNativeEdit=function(){var a=this;setTimeout(a._handlePossibleModification.bind(a),0)},WYMeditor.ImageHandler.prototype._handlePossibleModification=function(){var a=this;if(a._isResizeHandleAttached())return a._isCurrentImgAtMarker()?void a._correctResizeHandleOffsetAndWidth():void a._detachResizeHandle()},WYMeditor.ImageHandler.prototype._isResizeHandleAttached=function(){var a=this,b=a._getResizeHandle();return b&&"none"!==b.css("display")},WYMeditor.ImageHandler.prototype._getResizeHandle=function(){var a=this,b=a._wym.$body().find("."+WYMeditor.RESIZE_HANDLE_CLASS);return b.length?b:!1},WYMeditor.ImageHandler.prototype._detachResizeHandle=function(){var a=this;a._$currentImageMarker.detach(),a._$currentImg.height()>=16&&a._$currentImg.width()>=16&&a._$currentImg.css({padding:0,margin:0}),a._$currentImg=null,a._$resizeHandle.hide()},WYMeditor.ImageHandler.prototype._onImgDragstart=function(){var a=this;a._detachResizeHandle()},WYMeditor.ImageHandler.prototype._onResizeHandleClickDblclick=function(){var a=this;return jQuery.browser.msie&&11===jQuery.browser.versionNumber&&a._wym.deselect(),!1},WYMeditor.ImageHandler.prototype._isAnImgSelected=function(a){function b(b){var d=c._wym.getSelectedImage()?"***YES***":"";b=b?b+" ":"",WYMeditor.console.log(b+a+" "+d)}var c=this;a=a.toUpperCase(),b("sync"),setTimeout(function(){b("async")},0)},WYMeditor.ImageHandler._onAllEvents=function(a){var b=this;b._isAnImgSelected([a.type,a.target.tagName,jQuery(a.target).attr("className")].join(" "))},WYMeditor.WymClassGecko=function(a){var b=this;b._wym=a,b._class="class"},WYMeditor.WymClassGecko.CELL_PLACEHOLDER='
              ',WYMeditor.WymClassGecko.NEEDS_CELL_FIX=1===parseInt(jQuery.browser.version,10)&&jQuery.browser.version>="1.9.1"&&jQuery.browser.version<"2.0",WYMeditor.WymClassGecko.prototype._docEventQuirks=function(){var a=this,b=jQuery(a._doc);b.keyup(a._keyup.bind(a)),b.focus(function(){a.undoRedo._onBodyFocus()}),b.click(a._click.bind(a))},WYMeditor.WymClassGecko.prototype._keyup=function(a){var b,c,d,e,f,g=this;d=g.documentStructureManager.structureRules.notValidRootContainers,c=g.documentStructureManager.structureRules.defaultRootContainer,b=null,g.keyCanCreateBlockElement(a.which)||a.which===WYMeditor.KEY_CODE.CTRL||a.which===WYMeditor.KEY_CODE.COMMAND||a.metaKey||a.ctrlKey||(b=g.selectedContainer(),e=b.tagName.toLowerCase(),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),g.isForbiddenRootContainer(e)&&(e=f),(e===WYMeditor.BODY||jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY)&&(g._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK,c),g.prepareDocForEditing())),g.keyCanCreateBlockElement(a.which)&&(b=g.selectedContainer(),e=b.tagName.toLowerCase(),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY&&g._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK,c),g._handlePotentialEnterInEmptyNestedLi(a.which,b),g.prepareDocForEditing())},WYMeditor.WymClassGecko.prototype._click=function(){var a,b=this,c=b.selectedContainer();WYMeditor.WymClassGecko.NEEDS_CELL_FIX===!0&&c&&c.tagName.toLowerCase()===WYMeditor.TR&&jQuery(WYMeditor.TD,b._doc.body).append(WYMeditor.WymClassGecko.CELL_PLACEHOLDER),c&&c.tagName.toLowerCase()===WYMeditor.BODY&&(a=b.selection(),a.isCollapsed===!0&&b._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK,WYMeditor.P))},WYMeditor.WymClassGecko.prototype._designModeQuirks=function(){var a=this;try{a._doc.execCommand("styleWithCSS","",!1),a._doc.execCommand("enableObjectResizing",!1,!1),a._doc.execCommand("enableInlineTableEditing",!1,!1)}catch(b){}},WYMeditor.WymClassGecko.prototype._afterInsertTable=function(a){WYMeditor.WymClassGecko.NEEDS_CELL_FIX===!0&&jQuery(a).find("td").each(function(a,b){jQuery(b).append(WYMeditor.WymClassGecko.CELL_PLACEHOLDER)})},WYMeditor.WymClassWebKit=function(a){var b=this;b._wym=a,b._class="class"},WYMeditor.WymClassWebKit.prototype._docEventQuirks=function(){var a=this;jQuery(a._doc).bind("keyup",function(b){a._keyup(b)}),a.keyboard.combokeys.bind("shift+enter",function(){return a._exec(WYMeditor.EXEC_COMMANDS.INSERT_LINEBREAK),!1}),a.$body().bind("focus",function(){a.undoRedo._onBodyFocus()})},WYMeditor.WymClassWebKit.prototype._inListBreakoutDiv=function(a){var b=this,c=jQuery(b.getRootContainer());return a===WYMeditor.KEY_CODE.ENTER&&c.is("div")&&"div"!==b.documentStructureManager.defaultRootContainer&&1===c.prev("ol, ul").length?!0:!1},WYMeditor.WymClassWebKit.prototype._isLiInLiAfterEnter=function(a){var b,c,d,e,f=this,g=f.nodeAfterSel();return a!==WYMeditor.KEY_CODE.ENTER?!1:g&&(b=g.parentNode)?"string"!=typeof b.tagName?!1:"li"!==b.tagName.toLowerCase()?!1:(c=g.previousSibling)?"string"!=typeof c.tagName?!1:"li"!==c.tagName.toLowerCase()?!1:1!==c.childNodes.length?!1:(d=c.childNodes[0])?"string"!=typeof d.tagName?!1:"br"!==d.tagName.toLowerCase()?!1:(e=c.previousSibling,e?"string"!=typeof e.tagName?!1:-1===jQuery.inArray(e.tagName.toLowerCase(),["ol","ul"])?!1:!0:!1):!1:!1:!1},WYMeditor.WymClassWebKit.prototype._fixLiInLiAfterEnter=function(){var a=this,b=a.nodeAfterSel(),c=jQuery(b.previousSibling),d=c.parent("li"),e=d.contents().index(c),f=d.contents().slice(e+1);c.remove(),d.after("

            3. "),d.next().append(f),a.setCaretBefore(d.next("li").children().first("br")[0])},WYMeditor.WymClassWebKit.prototype._keyup=function(a){var b,c,d,e,f,g,h=this;if(d=h.documentStructureManager.structureRules.notValidRootContainers,c=h.documentStructureManager.structureRules.defaultRootContainer,jQuery.browser.version<534.1&&a.which===WYMeditor.KEY_CODE.ENTER&&a.shiftKey&&h._exec("InsertLineBreak"),h.keyCanCreateBlockElement(a.which)||a.which===WYMeditor.KEY_CODE.CTRL||a.which===WYMeditor.KEY_CODE.COMMAND||a.metaKey||a.ctrlKey||(b=h.selectedContainer(),e=b.tagName.toLowerCase(),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),h.isForbiddenRootContainer(e)&&(e=f),(e===WYMeditor.BODY||jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY)&&(h._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK,c),h.prepareDocForEditing())),h.keyCanCreateBlockElement(a.which)){if(b=h.selectedContainer(),e=b.tagName.toLowerCase(),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY&&(h._exec(WYMeditor.EXEC_COMMANDS.FORMAT_BLOCK,c),b=h.selectedContainer()),h._isLiInLiAfterEnter(a.which,b))return h._fixLiInLiAfterEnter(),void(b=h.selectedContainer());h._handlePotentialEnterInEmptyNestedLi(a.which,b),h._inListBreakoutDiv(a.which)&&(g=h.switchTo(h.getRootContainer(),c),h.setCaretIn(g)),h.prepareDocForEditing()}},WYMeditor.WymClassBlink=function(a){var b=this;b._wym=a},jQuery.extend(WYMeditor.WymClassBlink.prototype,WYMeditor.WymClassWebKit.prototype),WYMeditor.WymClassSafari=function(a){var b=this;b._wym=a},jQuery.extend(WYMeditor.WymClassSafari.prototype,WYMeditor.WymClassWebKit.prototype),WYMeditor.WymClassTridentPre7=function(a){var b=this;b._wym=a,b._class="className"},WYMeditor.WymClassTridentPre7.prototype._onEditorIframeLoad=function(a){a._assignWymDoc(),a._isDesignModeOn()===!1?a._doc.designMode="On":a._afterDesignModeOn()},WYMeditor.WymClassTridentPre7.prototype._assignWymDoc=function(){var a=this;a._doc=a._iframe.contentWindow.document},WYMeditor.WymClassTridentPre7.prototype._docEventQuirks=function(){var a=this;a._doc.onbeforedeactivate=function(){a._saveCaret()},jQuery(a._doc).bind("keyup",function(b){a._keyup(b)}),a._doc.onkeyup=function(){a._saveCaret()},a._doc.onclick=function(){a._saveCaret()},a.$body().bind("focus",function(){a.undoRedo._onBodyFocus()}),a._doc.body.onbeforepaste=function(){a._iframe.contentWindow.event.returnValue=!1},a._doc.body.onpaste=function(){a._iframe.contentWindow.event.returnValue=!1,a.paste(window.clipboardData.getData("Text"))},a.$body().bind("dragend",function(b){b.target.tagName.toLowerCase()===WYMeditor.IMG&&a.deselect()}),a._doc.oncontrolselect=function(){return!1}},WYMeditor.WymClassTridentPre7.prototype._setButtonsUnselectable=function(){var a=this,b=a.get$Buttons();b.attr("unselectable","on")},WYMeditor.WymClassTridentPre7.prototype._uiQuirks=function(){var a=this;8===jQuery.browser.versionNumber&&a._setButtonsUnselectable()},WYMeditor.WymClassTridentPre7.prototype._saveCaret=function(){var a=this,b=a._doc.selection;"None"!==b.type&&(a._doc.caretPos=b.createRange())},WYMeditor.WymClassTridentPre7.prototype._wrapWithContainer=function(a,b){var c,d,e,f=this;c=jQuery(a).wrap("<"+b+" />"),d=f.selection(),e=rangy.createRange(f._doc),e.selectNodeContents(c[0]),e.collapse(),d.setSingleRange(e)},WYMeditor.WymClassTridentPre7.prototype._keyup=function(a){var b,c,d,e,f,g,h=this,i=!1;d=h.documentStructureManager.structureRules.notValidRootContainers,c=h.documentStructureManager.structureRules.defaultRootContainer,h.keyCanCreateBlockElement(a.which)||a.which===WYMeditor.KEY_CODE.CTRL||a.which===WYMeditor.KEY_CODE.COMMAND||a.metaKey||a.ctrlKey||(b=h.selectedContainer(),g=h.selection().focusNode,null!==b&&(e=b.tagName.toLowerCase()),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),h.isForbiddenRootContainer(e)&&(e=f,i=!0),e===WYMeditor.BODY&&"#text"===g.nodeName&&(i&&(g=g.parentNode),h._wrapWithContainer(g,c),h.prepareDocForEditing()),jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY&&(h.switchTo(b,c),h.prepareDocForEditing())),h.keyCanCreateBlockElement(a.which)&&(b=h.selectedContainer(),e=b.tagName.toLowerCase(),b.parentNode&&(f=b.parentNode.tagName.toLowerCase()),jQuery.inArray(e,d)>-1&&f===WYMeditor.BODY&&h.switchTo(b,c),h._handlePotentialEnterInEmptyNestedLi(a.which,b),a.which!==WYMeditor.KEY_CODE.BACKSPACE||8!==jQuery.browser.versionNumber||!b.parentNode||"ul"!==f&&"ol"!==f||h._fixInvalidListNesting(b),h.prepareDocForEditing())},WYMeditor.WymClassTrident7=function(a){var b=this;b._wym=a,b._class="class"},jQuery.extend(WYMeditor.WymClassTrident7.prototype,WYMeditor.WymClassGecko.prototype),jQuery.copyPropsFromObjectToObject(WYMeditor.WymClassTridentPre7.prototype,WYMeditor.WymClassTrident7.prototype,["_exec","_keyup","_wrapWithContainer"]),WYMeditor.WymClassTrident7.prototype.rawHtml=function(a){var b=this;return"string"!=typeof a?b.$body().html():(b._doc.designMode="off",b.$body().html(a),b._isDesignModeOn()!==!0&&b._enableDesignModeOnDocument(),!1)},WYMeditor.WymClassTrident7.prototype._docEventQuirks=function(){var a=this;jQuery(a._doc).bind("keyup",function(b){a._keyup(b)}),a.$body().bind("dragend",function(b){b.target.tagName.toLowerCase()===WYMeditor.IMG&&a.deselect()}),a.$body().bind("focus",function(){a.undoRedo._onBodyFocus()})},function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.foo=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;ge?b=b[c]:b[c]=a.value}):e=a.value;break;case"del":b=e,c=a.key,d=c.length,d?c.forEach(function(a,c){a in b||(b[a]={}),d-1>c?b=b[a]:delete b[a]}):e=null}}),e}var h=a("underscore");b.exports=d;var i=[];b.exports.apply=g},{udc:15,underscore:13}],13:[function(a,b,c){(function(){var a=this,d=a._,e={},f=Array.prototype,g=Object.prototype,h=Function.prototype,i=f.push,j=f.slice,k=f.concat,l=g.toString,m=g.hasOwnProperty,n=f.forEach,o=f.map,p=f.reduce,q=f.reduceRight,r=f.filter,s=f.every,t=f.some,u=f.indexOf,v=f.lastIndexOf,w=Array.isArray,x=Object.keys,y=h.bind,z=function(a){return a instanceof z?a:this instanceof z?void(this._wrapped=a):new z(a)};"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=z),c._=z):a._=z,z.VERSION="1.4.4";var A=z.each=z.forEach=function(a,b,c){if(null!=a)if(n&&a.forEach===n)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,f=a.length;f>d;d++)if(b.call(c,a[d],d,a)===e)return}else for(var g in a)if(z.has(a,g)&&b.call(c,a[g],g,a)===e)return};z.map=z.collect=function(a,b,c){var d=[];return null==a?d:o&&a.map===o?a.map(b,c):(A(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),d)};var B="Reduce of empty array with no initial value";z.reduce=z.foldl=z.inject=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),p&&a.reduce===p)return d&&(b=z.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(A(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(B);return c},z.reduceRight=z.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),q&&a.reduceRight===q)return d&&(b=z.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=z.keys(a);f=g.length}if(A(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(B);return c},z.find=z.detect=function(a,b,c){var d;return C(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,!0):void 0}),d},z.filter=z.select=function(a,b,c){var d=[];return null==a?d:r&&a.filter===r?a.filter(b,c):(A(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},z.reject=function(a,b,c){return z.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},z.every=z.all=function(a,b,c){b||(b=z.identity);var d=!0;return null==a?d:s&&a.every===s?a.every(b,c):(A(a,function(a,f,g){return(d=d&&b.call(c,a,f,g))?void 0:e}),!!d)};var C=z.some=z.any=function(a,b,c){b||(b=z.identity);var d=!1;return null==a?d:t&&a.some===t?a.some(b,c):(A(a,function(a,f,g){return d||(d=b.call(c,a,f,g))?e:void 0}),!!d)};z.contains=z.include=function(a,b){return null==a?!1:u&&a.indexOf===u?-1!=a.indexOf(b):C(a,function(a){return a===b})},z.invoke=function(a,b){var c=j.call(arguments,2),d=z.isFunction(b);return z.map(a,function(a){return(d?b:a[b]).apply(a,c)})},z.pluck=function(a,b){return z.map(a,function(a){return a[b]})},z.where=function(a,b,c){return z.isEmpty(b)?c?null:[]:z[c?"find":"filter"](a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},z.findWhere=function(a,b){return z.where(a,b,!0)},z.max=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);if(!b&&z.isEmpty(a))return-(1/0);var d={computed:-(1/0),value:-(1/0)};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},z.min=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);if(!b&&z.isEmpty(a))return 1/0;var d={computed:1/0,value:1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;gd||void 0===c)return 1;if(d>c||void 0===d)return-1}return a.indexf;){var h=f+g>>>1;c.call(d,a[h])=0})})},z.difference=function(a){var b=k.apply(f,j.call(arguments,1));return z.filter(a,function(a){return!z.contains(b,a)})},z.zip=function(){for(var a=j.call(arguments),b=z.max(z.pluck(a,"length")),c=new Array(b),d=0;b>d;d++)c[d]=z.pluck(a,""+d);return c},z.object=function(a,b){if(null==a)return{};for(var c={},d=0,e=a.length;e>d;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},z.indexOf=function(a,b,c){if(null==a)return-1;var d=0,e=a.length;if(c){if("number"!=typeof c)return d=z.sortedIndex(a,b),a[d]===b?d:-1;d=0>c?Math.max(0,e+c):c}if(u&&a.indexOf===u)return a.indexOf(b,c);for(;e>d;d++)if(a[d]===b)return d;return-1},z.lastIndexOf=function(a,b,c){if(null==a)return-1;var d=null!=c;if(v&&a.lastIndexOf===v)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);for(var e=d?c:a.length;e--;)if(a[e]===b)return e;return-1},z.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);d>e;)f[e++]=a,a+=c;return f},z.bind=function(a,b){if(a.bind===y&&y)return y.apply(a,j.call(arguments,1));var c=j.call(arguments,2);return function(){return a.apply(b,c.concat(j.call(arguments)))}},z.partial=function(a){var b=j.call(arguments,1);return function(){return a.apply(this,b.concat(j.call(arguments)))}},z.bindAll=function(a){var b=j.call(arguments,1);return 0===b.length&&(b=z.functions(a)),A(b,function(b){a[b]=z.bind(a[b],a)}),a},z.memoize=function(a,b){var c={};return b||(b=z.identity),function(){var d=b.apply(this,arguments);return z.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},z.delay=function(a,b){var c=j.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},z.defer=function(a){return z.delay.apply(z,[a,1].concat(j.call(arguments,1)))},z.throttle=function(a,b){var c,d,e,f,g=0,h=function(){g=new Date,e=null,f=a.apply(c,d)};return function(){var i=new Date,j=b-(i-g);return c=this,d=arguments,0>=j?(clearTimeout(e),e=null,g=i,f=a.apply(c,d)):e||(e=setTimeout(h,j)),f}},z.debounce=function(a,b,c){var d,e;return function(){var f=this,g=arguments,h=function(){d=null,c||(e=a.apply(f,g))},i=c&&!d;return clearTimeout(d),d=setTimeout(h,b),i&&(e=a.apply(f,g)),e}},z.once=function(a){var b,c=!1;return function(){return c?b:(c=!0,b=a.apply(this,arguments),a=null,b)}},z.wrap=function(a,b){return function(){var c=[a];return i.apply(c,arguments),b.apply(this,c)}},z.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},z.after=function(a,b){return 0>=a?b():function(){return--a<1?b.apply(this,arguments):void 0}},z.keys=x||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)z.has(a,c)&&(b[b.length]=c);return b},z.values=function(a){var b=[];for(var c in a)z.has(a,c)&&b.push(a[c]);return b},z.pairs=function(a){var b=[];for(var c in a)z.has(a,c)&&b.push([c,a[c]]);return b},z.invert=function(a){var b={};for(var c in a)z.has(a,c)&&(b[a[c]]=c);return b},z.functions=z.methods=function(a){var b=[];for(var c in a)z.isFunction(a[c])&&b.push(c);return b.sort()},z.extend=function(a){return A(j.call(arguments,1),function(b){if(b)for(var c in b)a[c]=b[c]}),a},z.pick=function(a){var b={},c=k.apply(f,j.call(arguments,1));return A(c,function(c){c in a&&(b[c]=a[c])}),b},z.omit=function(a){var b={},c=k.apply(f,j.call(arguments,1));for(var d in a)z.contains(c,d)||(b[d]=a[d]);return b},z.defaults=function(a){return A(j.call(arguments,1),function(b){if(b)for(var c in b)null==a[c]&&(a[c]=b[c])}),a},z.clone=function(a){return z.isObject(a)?z.isArray(a)?a.slice():z.extend({},a):a},z.tap=function(a,b){return b(a),a};var G=function(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;if(null==a||null==b)return a===b;a instanceof z&&(a=a._wrapped),b instanceof z&&(b=b._wrapped);var e=l.call(a);if(e!=l.call(b))return!1;switch(e){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return!1;for(var f=c.length;f--;)if(c[f]==a)return d[f]==b;c.push(a),d.push(b);var g=0,h=!0;if("[object Array]"==e){if(g=a.length,h=g==b.length)for(;g--&&(h=G(a[g],b[g],c,d)););}else{var i=a.constructor,j=b.constructor;if(i!==j&&!(z.isFunction(i)&&i instanceof i&&z.isFunction(j)&&j instanceof j))return!1;for(var k in a)if(z.has(a,k)&&(g++,!(h=z.has(b,k)&&G(a[k],b[k],c,d))))break;if(h){for(k in b)if(z.has(b,k)&&!g--)break;h=!g}}return c.pop(),d.pop(),h};z.isEqual=function(a,b){return G(a,b,[],[])},z.isEmpty=function(a){if(null==a)return!0;if(z.isArray(a)||z.isString(a))return 0===a.length;for(var b in a)if(z.has(a,b))return!1;return!0},z.isElement=function(a){return!(!a||1!==a.nodeType)},z.isArray=w||function(a){return"[object Array]"==l.call(a)},z.isObject=function(a){return a===Object(a)},A(["Arguments","Function","String","Number","Date","RegExp"],function(a){z["is"+a]=function(b){return l.call(b)=="[object "+a+"]"}}),z.isArguments(arguments)||(z.isArguments=function(a){return!(!a||!z.has(a,"callee"))}),"function"!=typeof/./&&(z.isFunction=function(a){return"function"==typeof a}),z.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},z.isNaN=function(a){return z.isNumber(a)&&a!=+a},z.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"==l.call(a)},z.isNull=function(a){return null===a},z.isUndefined=function(a){return void 0===a},z.has=function(a,b){return m.call(a,b)},z.noConflict=function(){return a._=d,this},z.identity=function(a){return a},z.times=function(a,b,c){for(var d=Array(a),e=0;a>e;e++)d[e]=b.call(c,e);return d},z.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))};var H={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};H.unescape=z.invert(H.escape);var I={escape:new RegExp("["+z.keys(H.escape).join("")+"]","g"),unescape:new RegExp("("+z.keys(H.unescape).join("|")+")","g")};z.each(["escape","unescape"],function(a){z[a]=function(b){return null==b?"":(""+b).replace(I[a],function(b){return H[a][b]})}}),z.result=function(a,b){if(null==a)return null;var c=a[b];return z.isFunction(c)?c.call(a):c},z.mixin=function(a){A(z.functions(a),function(b){var c=z[b]=a[b];z.prototype[b]=function(){var a=[this._wrapped];return i.apply(a,arguments),N.call(this,c.apply(z,a))}})};var J=0;z.uniqueId=function(a){var b=++J+"";return a?a+b:b},z.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,L={ -"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},M=/\\|'|\r|\n|\t|\u2028|\u2029/g;z.template=function(a,b,c){var d;c=z.defaults({},c,z.templateSettings);var e=new RegExp([(c.escape||K).source,(c.interpolate||K).source,(c.evaluate||K).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(M,function(a){return"\\"+L[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=new Function(c.variable||"obj","_",g)}catch(h){throw h.source=g,h}if(b)return d(b,z);var i=function(a){return d.call(this,a,z)};return i.source="function("+(c.variable||"obj")+"){\n"+g+"}",i},z.chain=function(a){return z(a).chain()};var N=function(a){return this._chain?z(a).chain():a};z.mixin(z),A(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=f[a];z.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],N.call(this,c)}}),A(["concat","join","slice"],function(a){var b=f[a];z.prototype[a]=function(){return N.call(this,b.apply(this._wrapped,arguments))}}),z.extend(z.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],14:[function(b,c,d){(function(b){(function(){function e(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d-1?0:-1:a?0:-1}function g(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:v+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function h(a){return a.charCodeAt(0)}function i(a,b){for(var c=a.criteria,d=b.criteria,e=-1,f=c.length;++eh||"undefined"==typeof g)return 1;if(h>g||"undefined"==typeof h)return-1}}return a.index-b.index}function j(a){var b=-1,c=a.length,d=a[0],e=a[c/2|0],f=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&f&&"object"==typeof f)return!1;var h=m();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=m();for(i.array=a,i.cache=h,i.push=g;++be?0:e);++d=w&&d===e,i=[];if(h){var k=j(b);k?(d=f,b=k):h=!1}for(;++c-1:void 0});return e.pop(),f.pop(),s&&(n(e),n(f)),g}function ba(a,b,c,d,e){(Zc(b)?Ya:hd)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Zc(b))||id(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Zc(j)?j:[]:id(j)?j:{}),d.push(b),e.push(j),l||ba(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function ca(a,b){return a+Ec(Vc()*(b-a+1))}function ea(a,b,c){var d=-1,g=ia(),h=a?a.length:0,i=[],k=!b&&h>=w&&g===e,m=c||k?l():i;if(k){var p=j(m);g=f,m=p}for(;++d3&&"function"==typeof b[c-2])var d=t(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=p(arguments,1,c),f=-1,g=l(),h=l();++fc?Sc(0,f+c):c)||0,Zc(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Ja(a)?a.indexOf(b,c):e(a,b,c))>-1:hd(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Ua(a,c,d){var e=!0;c=b.createCallback(c,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++ff&&(f=j)}else c=null==c&&Ja(a)?h:b.createCallback(c,d,3),Ya(a,function(a,b,d){var g=c(a,b,d);g>e&&(e=g,f=a)});return f}function bb(a,c,d){var e=1/0,f=e;if("function"!=typeof c&&d&&d[c]===a&&(c=null),null==c&&Zc(a))for(var g=-1,i=a.length;++gj&&(f=j)}else c=null==c&&Ja(a)?h:b.createCallback(c,d,3),Ya(a,function(a,b,d){var g=c(a,b,d);e>g&&(e=g,f=a)});return f}function cb(a,c,d,e){if(!a)return d;var f=arguments.length<3;c=b.createCallback(c,e,4);var g=-1,h=a.length;if("number"==typeof h)for(f&&(d=a[++g]);++gc?Sc(0,d+c):c||0}else if(c){var f=Ab(a,b);return a[f]===b?f:-1}return e(a,b,c)}function sb(a,c,d){var e=0,f=a?a.length:0;if("number"!=typeof c&&null!=c){var g=f;for(c=b.createCallback(c,d,3);g--&&c(a[g],g,a);)e++}else e=null==c||d?1:c||e;return p(a,0,Tc(Sc(0,f-e),f))}function tb(){for(var a=[],b=-1,c=arguments.length,d=l(),g=ia(),h=g===e,i=l();++b=w&&j(b?a[b]:i)))}var m=a[0],p=-1,q=m?m.length:0,r=[];a:for(;++pc?Sc(0,d+c):Tc(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function wb(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++cf;){var h=f+g>>>1;d(a[h])1?arguments:arguments[0],b=-1,c=a?ab(md(a,"length")):0,d=nc(0>c?0:c);++b2?ga(a,17,p(arguments,2),null,b):ga(a,1,null,null,b)}function Jb(a){for(var b=arguments.length>1?_(arguments,!0,!1,1):ua(a),c=-1,d=b.length;++c2?ga(b,19,p(arguments,2),null,a):ga(b,3,null,null,a)}function Lb(){for(var a=arguments,b=a.length;b--;)if(!Da(a[b]))throw new wc;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Mb(a,b){return b="number"==typeof b?b:+b||a.length,ga(a,4,null,null,null,b)}function Nb(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!Da(a))throw new wc;if(b=Sc(0,b)||0,c===!0){var n=!0;m=!1}else Ea(c)&&(n=c.leading,l="maxWait"in c&&(Sc(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(od()-g);if(0>=c){e&&Dc(e);var l=j;e=i=j=r,l&&(k=od(),f=a.apply(h,d),i||e||(d=h=null))}else i=Jc(o,c)},p=function(){i&&Dc(i),e=i=j=r,(m||l!==b)&&(k=od(),f=a.apply(h,d),i||e||(d=h=null))};return function(){if(d=arguments,g=od(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k),r=0>=q;r?(e&&(e=Dc(e)),k=g,f=a.apply(h,d)):e||(e=Jc(p,q))}return r&&i?i=Dc(i):i||b===l||(i=Jc(o,b)),c&&(r=!0,f=a.apply(h,d)),!r||i||e||(d=h=null),f}}function Ob(a){if(!Da(a))throw new wc;var b=p(arguments,1);return Jc(function(){a.apply(r,b)},1)}function Pb(a,b){if(!Da(a))throw new wc;var c=p(arguments,2);return Jc(function(){a.apply(r,c)},b)}function Qb(a,b){if(!Da(a))throw new wc;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):v+arguments[0];return Hc.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Rb(a){var b,c;if(!Da(a))throw new wc;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Sb(a){return ga(a,16,p(arguments,1))}function Tb(a){return ga(a,32,null,p(arguments,1))}function Ub(a,b,c){var d=!0,e=!0;if(!Da(a))throw new wc;return c===!1?d=!1:Ea(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),W.leading=d,W.maxWait=b,W.trailing=e,Nb(a,b,W)}function Vb(a,b){return ga(b,16,[a])}function Wb(a){return function(){return a}}function Xb(a,b,c){var d=typeof a;if(null==a||"function"==d)return t(a,b,c);if("object"!=d)return bc(a);var e=_c(a),f=e[0],g=a[f];return 1!=e.length||g!==g||Ea(g)?function(b){for(var c=e.length,d=!1;c--&&(d=aa(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return g===b&&(0!==g||1/g==1/b)}}function Yb(a){return null==a?"":vc(a).replace(dd,ha)}function Zb(a){return a}function $b(a,d,e){var f=!0,g=d&&ua(d);d&&(e||g.length)||(null==e&&(e=d),h=c,d=a,a=b,g=ua(d)),e===!1?f=!1:Ea(e)&&"chain"in e&&(f=e.chain);var h=a,i=Da(h);Ya(g,function(b){var c=a[b]=d[b];i&&(h.prototype[b]=function(){var b=this.__chain__,d=this.__wrapped__,e=[d];Ic.apply(e,arguments);var g=c.apply(a,e);if(f||b){if(d===g&&Ea(g))return this;g=new h(g),g.__chain__=b}return g})})}function _b(){return a._=zc,this}function ac(){}function bc(a){return function(b){return b[a]}}function cc(a,b,c){var d=null==a,e=null==b;if(null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0,c||a%1||b%1){var f=Vc();return Tc(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b)}return ca(a,b)}function dc(a,b){if(a){var c=a[b];return Da(c)?a[b]():c}}function ec(a,c,d){var e=b.templateSettings;a=vc(a||""),d=fd({},d,e);var f,g=fd({},d.imports,e.imports),h=_c(g),i=Ra(g),j=0,l=d.interpolate||H,m="__p += '",n=uc((d.escape||H).source+"|"+l.source+"|"+(l===F?C:H).source+"|"+(d.evaluate||H).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(J,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(z,""):m).replace(A,"$1").replace(B,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+L++ +"]")+"\n*/";try{var s=qc(h,"return "+m+q).apply(r,i)}catch(t){throw t.source=m,t}return c?s(c):(s.source=m,s)}function fc(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=nc(a);for(b=t(b,c,1);++d/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:F,variable:"",imports:{_:b}},Nc||(s=function(){function b(){}return function(c){if(Ea(c)){b.prototype=c;var d=new b;b.prototype=null}return d||a.Object()}}());var Yc=Mc?function(a,b){X.value=b,Mc(a,"__bindData__",X),X.value=null}:ac,Zc=Oc||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ac.call(a)==N||!1},$c=function(a){var b,c=a,d=[];if(!c)return d;if(!Y[typeof a])return d;for(b in c)Hc.call(c,b)&&d.push(b);return d},_c=Rc?function(a){return Ea(a)?Rc(a):[]}:$c,ad={"&":"&","<":"<",">":">",'"':""","'":"'"},bd=wa(ad),cd=uc("("+_c(bd).join("|")+")","g"),dd=uc("["+_c(ad).join("")+"]","g"),ed=function(a,b,c){var d,e=a,f=e;if(!e)return f;var g=arguments,h=0,i="number"==typeof c?2:g.length;if(i>3&&"function"==typeof g[i-2])var j=t(g[--i-1],g[i--],2);else i>2&&"function"==typeof g[i-1]&&(j=g[--i]);for(;++h/g,G=RegExp("^["+y+"]*0+(?=.$)"),H=/($^)/,I=/\bthis\b/,J=/['\n\r\t\u2028\u2029\\]/g,K=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],L=0,M="[object Arguments]",N="[object Array]",O="[object Boolean]",P="[object Date]",Q="[object Function]",R="[object Number]",S="[object Object]",T="[object RegExp]",U="[object String]",V={};V[Q]=!1,V[M]=V[N]=V[O]=V[P]=V[R]=V[S]=V[T]=V[U]=!0;var W={leading:!1,maxWait:0,trailing:!1},X={configurable:!1,enumerable:!1,value:null,writable:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=Y[typeof window]&&window||this,_=Y[typeof d]&&d&&!d.nodeType&&d,aa=Y[typeof c]&&c&&!c.nodeType&&c,ba=aa&&aa.exports===_&&_,ca=Y[typeof b]&&b;!ca||ca.global!==ca&&ca.window!==ca||($=ca);var da=q();"function"==typeof a&&"object"==typeof a.amd&&a.amd?($._=da,a(function(){return da})):_&&aa?ba?(aa.exports=da)._=da:_._=da:$._=da}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],15:[function(b,c,d){!function(b,e){"use strict";"object"==typeof d?c.exports=e():"function"==typeof a&&a.amd?a(e):b.UltraDeepClone=e()}(this,function(){function a(a){return"[object "+a+"]"}function b(a){for(var b=[],c=1;a>=c;c++)b.push("arg"+c);return b}function c(a){var c=b(a.length),d="return false || function ";return d+=a.name+"(",d+=c.join(", ")+") {\n",d+="return fn.apply(this, arguments);\n",d+="};",Function("fn",d)(a)}function d(a){return function(b,c,d){c.push(b);var e=a(b);return d.push(e),e}}function e(a){return a}function f(a){return new RegExp(a)}function g(a){return new Date(a.getTime())}function h(a){return c(a)}function i(a){return Object.create(Object.getPrototypeOf(a))}function j(a){return[]}function k(a){var b=a.length;return new a.constructor(b)}function l(a,b){return function(c,d,e){var f=this;return Object.getOwnPropertyNames(c).filter(function(a){return!b||-1===b.indexOf(a)}).reduce(function(a,b){var g=d.indexOf(c[b]);return-1===g?a[b]=f(c[b]):a[b]=e[g],a},a(c,d,e))}}var m=["caller","arguments"],n=["BYTES_PER_ELEMENT","get","set","slice","subarray","buffer","length","byteOffset","byteLength"],o=d(e),p=l(d(k),n),q={};return q[a("RegExp")]=d(f),q[a("Date")]=d(g),q[a("Function")]=l(d(h),m),q[a("Object")]=l(d(i)),q[a("Array")]=l(d(j)),["Null","Undefined","Number","String","Boolean"].map(a).forEach(function(a){q[a]=o}),["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"].map(a).forEach(function(a){q[a]=p}),function(a){function b(a){var e=Object.prototype.toString.call(a);return q[e].call(b,a,c,d)}var c=[],d=[];return b(a)}})},{}],16:[function(a,b,c){function d(){for(var a={},b=0;b1?void f.bindSequence(a,h,b,c):(g=f.getKeyInfo(a,c),f.callbacks[g.key]=f.callbacks[g.key]||[],f.getMatches(g.key,g.modifiers,{type:g.action},d,a,e),void f.callbacks[g.key][d?"unshift":"push"]({callback:b,modifiers:g.modifiers,action:g.action,seq:d,level:e,combo:a}))}},{}],7:[function(a,b,c){var d=a("dom-event").off;b.exports=function(){var a=this,b=a.element;d(b,"keypress",a.eventHandler),d(b,"keydown",a.eventHandler),d(b,"keyup",a.eventHandler)}},{"dom-event":33}],8:[function(a,b,c){"use strict";b.exports=function(b,c,d,e){var f,g,h=this;h.stopCallback(c,c.target||c.srcElement,d,e)||b(c,d)===!1&&(f=a("../../helpers/preventDefault"),f(c),(g=a("../../helpers/stopPropagation"))(c))}},{"../../helpers/preventDefault":27,"../../helpers/stopPropagation":32}],9:[function(a,b,c){"use strict";b.exports=function(b,c){var d,e,f,g,h,i,j,k=this,l=[];for(d=a("../../helpers/keysFromString"),e=d(b),h=a("../../helpers/special-aliases"),i=a("../../helpers/shift-map"),j=a("../../helpers/isModifier"),g=0;g95&&112>e||b.hasOwnProperty(e)&&(d.REVERSE_MAP[b[e]]=e)}return d.REVERSE_MAP}},{"../../helpers/special-keys-map":31}],12:[function(a,b,c){"use strict";b.exports=function(b,c,d){var e,f,g,h,i=this,j={},k=0,l=!1;for(e=i.getMatches(b,c,d),f=0;f-1)return!1;var c=b.tagName.toLowerCase();return"input"===c||"select"===c||"textarea"===c||b.isContentEditable}},{}],20:[function(a,b,c){"use strict";b.exports=function(a,b){var c=this;return c.directMap[a+":"+b]&&c.directMap[a+":"+b]({},a),this}},{}],21:[function(a,b,c){"use strict";b.exports=function(a,b){var c=this;return c.bind(a,function(){},b)}},{}],22:[function(a,b,c){"use strict";b.exports=function(){var a=this;a.instances.forEach(function(a){a.reset()})}},{}],23:[function(a,b,c){"use strict";b.exports=function(b){var c,d;if(c=a("./special-keys-map"),d=a("./special-characters-map"),"keypress"===b.type){var e=String.fromCharCode(b.which);return b.shiftKey||(e=e.toLowerCase()),e}return c[b.which]?c[b.which]:d[b.which]?d[b.which]:String.fromCharCode(b.which).toLowerCase()}},{"./special-characters-map":30,"./special-keys-map":31}],24:[function(a,b,c){"use strict";b.exports=function(a){var b=[];return a.shiftKey&&b.push("shift"),a.altKey&&b.push("alt"),a.ctrlKey&&b.push("ctrl"),a.metaKey&&b.push("meta"),b}},{}],25:[function(a,b,c){"use strict";b.exports=function(a){return"shift"===a||"ctrl"===a||"alt"===a||"meta"===a}},{}],26:[function(a,b,c){"use strict";b.exports=function(a){return"+"===a?["+"]:a.split("+")}},{}],27:[function(a,b,c){"use strict";b.exports=function(a){return a.preventDefault?void a.preventDefault():void(a.returnValue=!1)}},{}],28:[function(a,b,c){"use strict";b.exports={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"}},{}],29:[function(a,b,c){"use strict";b.exports={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"}},{}],30:[function(a,b,c){"use strict";b.exports={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}},{}],31:[function(a,b,c){"use strict";b.exports={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",187:"plus",189:"minus",224:"meta"};for(var d=1;20>d;++d)b.exports[111+d]="f"+d;for(d=0;9>=d;++d)b.exports[d+96]=d},{}],32:[function(a,b,c){"use strict";b.exports=function(a){return a.stopPropagation?void a.stopPropagation():void(a.cancelBubble=!0)}},{}],33:[function(a,b,c){function d(a,b,c,d){return!a.addEventListener&&(b="on"+b),(a.addEventListener||a.attachEvent).call(a,b,c,d),c}function e(a,b,c,d){return!a.removeEventListener&&(b="on"+b),(a.removeEventListener||a.detachEvent).call(a,b,c,d),c}b.exports=d,b.exports.on=d,b.exports.off=e},{}],34:[function(a,b,c){WYMeditor.EXTERNAL_MODULES.Combokeys=a("combokeys")},{combokeys:1}]},{},[34])(34)}),function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.foo=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g-1?"backwardsRemoval":e.indexOf(c)>-1?"forwardRemoval":"space"===c?c:"enter"===c?c:"characterAddition"}if("paste"===a.type)return a.type;if("drop"===a.type)return a.type;throw new Error("Shouldn't get this far")}},{keycode:15}],10:[function(a,b,c){"use strict";b.exports=function(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1);if(a.attachEvent)return a.attachEvent("on"+b,c);throw"No event handler adding interface found"}},{}],11:[function(a,b,c){var d=a("synthetic-dom-events"),e=function(a,b,c,d){return a.addEventListener(b,c,d||!1)},f=function(a,b,c,d){return a.removeEventListener(b,c,d||!1)},g=function(a,b,c,d){function g(e){f(a,b,g,d),c(e)}e(a,b,g,d)},h=function(a,b,c){var e=d(b,c);a.dispatchEvent(e)};document.addEventListener||(e=function(a,b,c){return a.attachEvent("on"+b,c)}),document.removeEventListener||(f=function(a,b,c){return a.detachEvent("on"+b,c)}),document.dispatchEvent||(h=function(a,b,c){var e=d(b,c);return a.fireEvent("on"+e.type,e)}),b.exports={on:e,off:f,once:g,emit:h}},{"synthetic-dom-events":12}],12:[function(a,b,c){function d(a,b){return(a.ctrlKey!=(b.ctrlKey||!1)||a.altKey!=(b.altKey||!1)||a.shiftKey!=(b.shiftKey||!1)||a.metaKey!=(b.metaKey||!1)||a.keyCode!=(b.keyCode||0)||a.charCode!=(b.charCode||0))&&(a=document.createEvent("Event"),a.initEvent(b.type,b.bubbles,b.cancelable),a.ctrlKey=b.ctrlKey||!1,a.altKey=b.altKey||!1,a.shiftKey=b.shiftKey||!1,a.metaKey=b.metaKey||!1,a.keyCode=b.keyCode||0,a.charCode=b.charCode||0),a}var e=(window,document||{}),f=(e.documentElement||{},!0);try{e.createEvent("KeyEvents")}catch(g){f=!1}var h=function(a,b){b=b||{};var c=l(a),g=c;"KeyboardEvent"===c&&f&&(c="KeyEvents",g="KeyEvent");var h=e.createEvent(c),i="init"+g,k="function"==typeof h[i]?i:"initEvent",m=j[k],n=[],o={};b.type=a;for(var p=0;pf;f++)d[String.fromCharCode(f)]=f-32;for(var f=48;58>f;f++)d[f-48]=f;for(f=1;13>f;f++)d["f"+f]=f+111;for(f=0;10>f;f++)d["numpad "+f]=f+96;var g=c.names=c.title={};for(f in d)g[d[f]]=f;for(var h in e)d[h]=e[h]},{}],16:[function(a,b,c){WYMeditor.EXTERNAL_MODULES.Edited=a("edited")},{edited:1}]},{},[16])(16)}),WYMeditor.UndoRedo=function(a){var b=this;b.wym=a,a.keyboard.combokeys.bind("mod+z",function(){return a.undoRedo.undo(),!1}),a.keyboard.combokeys.bind(["shift+meta+z","mod+y"],function(){return a.undoRedo.redo(),!1})},WYMeditor.UndoRedo.prototype._onBodyFocus=function(){var a=this,b=a.wym;a.history||setTimeout(function(){a._instantiateHistory(b.getCurrentState())},0)},WYMeditor.UndoRedo.prototype._add=function(){var a=this,b=a.wym;a.history&&(a.history.add(b.getCurrentState()),a.hasUnregisteredModification=!1)},WYMeditor.UndoRedo.prototype._do=function(a){var b,c,d=this,e=d.wym,f=d.history;if(d.history){if(a===WYMeditor.UndoRedo.UN){if(0===f.lengthBackward())return;d.hasUnregisteredModification&&d._add(),f.backward(),c="postUndo"}else{if(a!==WYMeditor.UndoRedo.RE)throw"Single parameter must be either `'un'` or `'re'` (there are constants for those).";if(0===f.lengthForward())return;f.forward(),c="postRedo"}b=f.get(),e.rawHtml(b.html),b.savedSelection&&(b.savedSelection.win=e._iframe.contentWindow,b.savedSelection.doc=e._doc,rangy.restoreSelection(b.savedSelection)),jQuery(e.element).trigger(WYMeditor.EVENTS[c])}},WYMeditor.UndoRedo.UN="un",WYMeditor.UndoRedo.RE="re",WYMeditor.UndoRedo.prototype.redo=function(){var a=this;a._do(WYMeditor.UndoRedo.RE)},WYMeditor.UndoRedo.prototype.undo=function(){var a=this;a._do(WYMeditor.UndoRedo.UN)},WYMeditor.UndoRedo.prototype.reset=function(){var a=this,b=a.wym;a._instantiateHistory(b.getCurrentState()),a.hasUnregisteredModification=null},WYMeditor.UndoRedo.prototype._instantiateHistory=function(a){var b=this;b.history=new WYMeditor.EXTERNAL_MODULES.ObjectHistory(a,{limit:100})},WYMeditor.Keyboard=function(a){var b=this;return b._wym=a,b.combokeys=new WYMeditor.EXTERNAL_MODULES.Combokeys(a._doc),b},WYMeditor.Keyboard.DEFAULT_KEYBOARD_SHORTCUTS=[{combo:"mod+b",cb:function(){var a=this;return a.exec(WYMeditor.EXEC_COMMANDS.BOLD),!1}},{combo:"mod+i",cb:function(){var a=this;return a.exec(WYMeditor.EXEC_COMMANDS.ITALIC),!1}},{combo:"mod+k",cb:function(){var a=this;return a.dialog(WYMeditor.DIALOGS.CreateLink),!1}},{combo:"tab",cb:function(){return!1}}],WYMeditor.Keyboard.prototype._attachDefaultKeyboardShortcuts=function(){var a,b,c=this,d=c._wym,e=c.constructor.DEFAULT_KEYBOARD_SHORTCUTS;for(b=0;ba;a++)this._patterns[a]="("+this._untokenizeRegex(this._tokenizeRegex(this._patterns[a]).replace(/([\/\(\)])/g,"\\$1"))+")";this._regex=new RegExp(this._patterns.join("|"),this._getPerlMatchingFlags())}return this._regex},WYMeditor.ParallelRegex.prototype._tokenizeRegex=function(a){return a.replace(/\(\?(i|m|s|x|U)\)/,"~~~~~~Tk1$1~~~~~~").replace(/\(\?(\-[i|m|s|x|U])\)/,"~~~~~~Tk2$1~~~~~~").replace(/\(\?\=(.*)\)/,"~~~~~~Tk3$1~~~~~~").replace(/\(\?\!(.*)\)/,"~~~~~~Tk4$1~~~~~~").replace(/\(\?\<\=(.*)\)/,"~~~~~~Tk5$1~~~~~~").replace(/\(\?\<\!(.*)\)/,"~~~~~~Tk6$1~~~~~~").replace(/\(\?\:(.*)\)/,"~~~~~~Tk7$1~~~~~~")},WYMeditor.ParallelRegex.prototype._untokenizeRegex=function(a){return a.replace(/~~~~~~Tk1(.{1})~~~~~~/,"(?$1)").replace(/~~~~~~Tk2(.{2})~~~~~~/,"(?$1)").replace(/~~~~~~Tk3(.*)~~~~~~/,"(?=$1)").replace(/~~~~~~Tk4(.*)~~~~~~/,"(?!$1)").replace(/~~~~~~Tk5(.*)~~~~~~/,"(?<=$1)").replace(/~~~~~~Tk6(.*)~~~~~~/,"(?","Comment")},WYMeditor.XhtmlLexer.prototype.addScriptTokens=function(a){this.addEntryPattern("","Script")},WYMeditor.XhtmlLexer.prototype.addCssTokens=function(a){this.addEntryPattern("","Css")},WYMeditor.XhtmlLexer.prototype.addTagTokens=function(a){this.addSpecialPattern("<\\s*[a-z0-9:-]+\\s*/>",a,"SelfClosingTag"),this.addSpecialPattern("<\\s*[a-z0-9:-]+\\s*>",a,"OpeningTag"),this.addEntryPattern("<[a-z0-9:-]+[\\/ \\>]+",a,"OpeningTag"),this.addInTagDeclarationTokens("OpeningTag"),this.addSpecialPattern("",a,"ClosingTag")},WYMeditor.XhtmlLexer.prototype.addInTagDeclarationTokens=function(a){this.addSpecialPattern("\\s+",a,"Ignore"),this.addAttributeTokens(a),this.addExitPattern("/>",a),this.addExitPattern(">",a)},WYMeditor.XhtmlLexer.prototype.addAttributeTokens=function(a){this.addSpecialPattern("\\s*[a-z-_0-9]*:?[a-z-_0-9]+\\s*(?==)\\s*",a,"TagAttributes"),this.addEntryPattern('=\\s*"',a,"DoubleQuotedAttribute"),this.addPattern('\\\\"',"DoubleQuotedAttribute"),this.addExitPattern('"',"DoubleQuotedAttribute"),this.addEntryPattern("=\\s*'",a,"SingleQuotedAttribute"),this.addPattern("\\\\'","SingleQuotedAttribute"),this.addExitPattern("'","SingleQuotedAttribute"),this.addSpecialPattern("=\\s*[^>\\s]*",a,"UnquotedAttribute")},WYMeditor.XhtmlParser=function(a,b){return b=b||"Text",this._Lexer=new WYMeditor.XhtmlLexer(this),this._Listener=a,this._mode=b,this._matches=[],this._last_match="",this._current_match="",this},WYMeditor.XhtmlParser.prototype.parse=function(a){return this._Lexer.parse(this.beforeParsing(a)),this.afterParsing(this._Listener.getResult())},WYMeditor.XhtmlParser.prototype.beforeParsing=function(a){return(a.match(/class="MsoNormal"/)||a.match(/ns = "urn:schemas-microsoft-com/))&&this._Listener.avoidStylingTagsAndAttributes(),this._Listener.beforeParsing(a)},WYMeditor.XhtmlParser.prototype.afterParsing=function(a){return this._Listener._avoiding_tags_implicitly&&this._Listener.allowStylingTagsAndAttributes(),this._Listener.afterParsing(a)},WYMeditor.XhtmlParser.prototype.Ignore=function(a,b){return!0},WYMeditor.XhtmlParser.prototype.Text=function(a){return this._Listener.addContent(a),!0},WYMeditor.XhtmlParser.prototype.Comment=function(a,b){return this._addNonTagBlock(a,b,"addComment")},WYMeditor.XhtmlParser.prototype.Script=function(a,b){return this._addNonTagBlock(a,b,"addScript")},WYMeditor.XhtmlParser.prototype.Css=function(a,b){return this._addNonTagBlock(a,b,"addCss")},WYMeditor.XhtmlParser.prototype._addNonTagBlock=function(a,b,c){switch(b){case WYMeditor.LEXER_ENTER:this._non_tag=a;break;case WYMeditor.LEXER_UNMATCHED:this._non_tag+=a;break;case WYMeditor.LEXER_EXIT:switch(c){case"addComment":this._Listener.addComment(this._non_tag+a);break;case"addScript":this._Listener.addScript(this._non_tag+a);break;case"addCss":this._Listener.addCss(this._non_tag+a)}}return!0},WYMeditor.XhtmlParser.prototype.SelfClosingTag=function(a,b){this.OpeningTag(a,b),this.normalizeTag(a);return this.ClosingTag(a,b)},WYMeditor.XhtmlParser.prototype.OpeningTag=function(a,b){switch(b){case WYMeditor.LEXER_ENTER:this._tag=this.normalizeTag(a),this._tag_attributes={};break;case WYMeditor.LEXER_SPECIAL:this._callOpenTagListener(this.normalizeTag(a));break;case WYMeditor.LEXER_EXIT:this._callOpenTagListener(this._tag,this._tag_attributes)}return!0},WYMeditor.XhtmlParser.prototype.ClosingTag=function(a,b){return this._callCloseTagListener(this.normalizeTag(a)),!0},WYMeditor.XhtmlParser.prototype._callOpenTagListener=function(a,b){b=b||{},this.autoCloseUnclosedBeforeNewOpening(a),this._Listener.isBlockTag(a)?(this._Listener._tag_stack.push(a),this._Listener.fixNestingBeforeOpeningBlockTag(a,b),this._Listener.openBlockTag(a,b),this._increaseOpenTagCounter(a)):this._Listener.isInlineTag(a)?this._Listener.inlineTag(a,b):(this._Listener.openUnknownTag(a,b),this._increaseOpenTagCounter(a)),this._Listener.last_tag=a,this._Listener.last_tag_opened=!0,this._Listener.last_tag_attributes=b},WYMeditor.XhtmlParser.prototype._callCloseTagListener=function(a){if(this._decreaseOpenTagCounter(a)){if(this.autoCloseUnclosedBeforeTagClosing(a),this._Listener.isBlockTag(a)){var b=this._Listener._tag_stack.pop();if(b===!1)return;if(b!==a){if(this._Listener._extraBlockClosingTags)return this._Listener._tag_stack.push(b),void this._Listener.removedExtraBlockClosingTag();a=b}this._Listener.closeBlockTag(a)}}else this._Listener.isInlineTag(a)||this._Listener.closeUnopenedTag(a);this._Listener.last_tag=a,this._Listener.last_tag_opened=!1},WYMeditor.XhtmlParser.prototype._increaseOpenTagCounter=function(a){this._Listener._open_tags[a]=this._Listener._open_tags[a]||0,this._Listener._open_tags[a]++},WYMeditor.XhtmlParser.prototype._decreaseOpenTagCounter=function(a){return this._Listener._open_tags[a]?(this._Listener._open_tags[a]--,0===this._Listener._open_tags[a]&&(this._Listener._open_tags[a]=void 0),!0):!1},WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeNewOpening=function(a){this._autoCloseUnclosed(a,!1)},WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeTagClosing=function(a){this._autoCloseUnclosed(a,!0)},WYMeditor.XhtmlParser.prototype._autoCloseUnclosed=function(a,b){if(b=b||!1,this._Listener._open_tags)for(var c in this._Listener._open_tags)this._Listener.shouldCloseTagAutomatically(c,a,b)&&this._callCloseTagListener(c,!0); -},WYMeditor.XhtmlParser.prototype.getTagReplacements=function(){return this._Listener.getTagReplacements()},WYMeditor.XhtmlParser.prototype.normalizeTag=function(a){a=a.replace(/^([\s<\/>]*)|([\s<\/>]*)$/gm,"").toLowerCase();var b=this._Listener.getTagReplacements();return b[a]?b[a]:a},WYMeditor.XhtmlParser.prototype.TagAttributes=function(a,b){return WYMeditor.LEXER_SPECIAL==b&&(this._current_attribute=a),!0},WYMeditor.XhtmlParser.prototype.DoubleQuotedAttribute=function(a,b){return WYMeditor.LEXER_UNMATCHED==b&&(this._tag_attributes[this._current_attribute]=a),!0},WYMeditor.XhtmlParser.prototype.SingleQuotedAttribute=function(a,b){return WYMeditor.LEXER_UNMATCHED==b&&(this._tag_attributes[this._current_attribute]=a),!0},WYMeditor.XhtmlParser.prototype.UnquotedAttribute=function(a,b){return this._tag_attributes[this._current_attribute]=a.replace(/^=/,""),!0},WYMeditor.XhtmlSaxListener=function(){return this.output="",this.helper=new WYMeditor.XmlHelper,this._open_tags={},this.validator=WYMeditor.XhtmlValidator,this._tag_stack=[],this.avoided_tags=[],this._insert_before_closing=[],this._insert_after_closing=[],this._last_node_was_text=!1,this._consecutive_brs=0,this._lastAddedOpenTag="",this._insideLI=!1,this.tagsToUnwrapInLists=WYMeditor.DocumentStructureManager.VALID_DEFAULT_ROOT_CONTAINERS,this._rootInlineTagsToRemove=["br"],this._extraBlockClosingTags=0,this._insideTagToRemove=!1,this._addSpacerBeforeElementInLI=!1,this._insideTagToRemove=!1,this._lastTagRemoved=!1,this._extraLIClosingTags=0,this._removedTagStackIndex=0,this.entities={" ":" ","¡":"¡","¢":"¢","£":"£","¤":"¤","¥":"¥","¦":"¦","§":"§","¨":"¨","©":"©","ª":"ª","«":"«","¬":"¬","­":"­","®":"®","¯":"¯","°":"°","±":"±","²":"²","³":"³","´":"´","µ":"µ","¶":"¶","·":"·","¸":"¸","¹":"¹","º":"º","»":"»","¼":"¼","½":"½","¾":"¾","¿":"¿","À":"À","Á":"Á","Â":"Â","Ã":"Ã","Ä":"Ä","Å":"Å","Æ":"Æ","Ç":"Ç","È":"È","É":"É","Ê":"Ê","Ë":"Ë","Ì":"Ì","Í":"Í","Î":"Î","Ï":"Ï","Ð":"Ð","Ñ":"Ñ","Ò":"Ò","Ó":"Ó","Ô":"Ô","Õ":"Õ","Ö":"Ö","×":"×","Ø":"Ø","Ù":"Ù","Ú":"Ú","Û":"Û","Ü":"Ü","Ý":"Ý","Þ":"Þ","ß":"ß","à":"à","á":"á","â":"â","ã":"ã","ä":"ä","å":"å","æ":"æ","ç":"ç","è":"è","é":"é","ê":"ê","ë":"ë","ì":"ì","í":"í","î":"î","ï":"ï","ð":"ð","ñ":"ñ","ò":"ò","ó":"ó","ô":"ô","õ":"õ","ö":"ö","÷":"÷","ø":"ø","ù":"ù","ú":"ú","û":"û","ü":"ü","ý":"ý","þ":"þ","ÿ":"ÿ","Œ":"Œ","œ":"œ","Š":"Š","š":"š","Ÿ":"Ÿ","ƒ":"ƒ","ˆ":"ˆ","˜":"˜","Α":"Α","Β":"Β","Γ":"Γ","Δ":"Δ","Ε":"Ε","Ζ":"Ζ","Η":"Η","Θ":"Θ","Ι":"Ι","Κ":"Κ","Λ":"Λ","Μ":"Μ","Ν":"Ν","Ξ":"Ξ","Ο":"Ο","Π":"Π","Ρ":"Ρ","Σ":"Σ","Τ":"Τ","Υ":"Υ","Φ":"Φ","Χ":"Χ","Ψ":"Ψ","Ω":"Ω","α":"α","β":"β","γ":"γ","δ":"δ","ε":"ε","ζ":"ζ","η":"η","θ":"θ","ι":"ι","κ":"κ","λ":"λ","μ":"μ","ν":"ν","ξ":"ξ","ο":"ο","π":"π","ρ":"ρ","ς":"ς","σ":"σ","τ":"τ","υ":"υ","φ":"φ","χ":"χ","ψ":"ψ","ω":"ω","ϑ":"ϑ","ϒ":"ϒ","ϖ":"ϖ"," ":" "," ":" "," ":" ","‌":"‌","‍":"‍","‎":"‎","‏":"‏","–":"–","—":"—","‘":"‘","’":"’","‚":"‚","“":"“","”":"”","„":"„","†":"†","‡":"‡","•":"•","…":"…","‰":"‰","′":"′","″":"″","‹":"‹","›":"›","‾":"‾","⁄":"⁄","€":"€","ℑ":"ℑ","℘":"℘","ℜ":"ℜ","™":"™","ℵ":"ℵ","←":"←","↑":"↑","→":"→","↓":"↓","↔":"↔","↵":"↵","⇐":"⇐","⇑":"⇑","⇒":"⇒","⇓":"⇓","⇔":"⇔","∀":"∀","∂":"∂","∃":"∃","∅":"∅","∇":"∇","∈":"∈","∉":"∉","∋":"∋","∏":"∏","∑":"∑","−":"−","∗":"∗","√":"√","∝":"∝","∞":"∞","∠":"∠","∧":"∧","∨":"∨","∩":"∩","∪":"∪","∫":"∫","∴":"∴","∼":"∼","≅":"≅","≈":"≈","≠":"≠","≡":"≡","≤":"≤","≥":"≥","⊂":"⊂","⊃":"⊃","⊄":"⊄","⊆":"⊆","⊇":"⊇","⊕":"⊕","⊗":"⊗","⊥":"⊥","⋅":"⋅","⌈":"⌈","⌉":"⌉","⌊":"⌊","⌋":"⌋","⟨":"〈","⟩":"〉","◊":"◊","♠":"♠","♣":"♣","♥":"♥","♦":"♦"},this.block_tags=["a","abbr","acronym","address","area","b","base","bdo","big","blockquote","body","button","caption","cite","code","colgroup","dd","del","div","dfn","dl","dt","em","fieldset","form","head","h1","h2","h3","h4","h5","h6","html","i","iframe","ins","kbd","label","legend","li","map","noscript","object","ol","optgroup","option","p","param","pre","q","samp","script","select","small","span","strong","style","sub","sup","table","tbody","td","textarea","tfoot","th","thead","title","tr","tt","ul","var","extends"],this.inline_tags=["br","col","hr","img","input"],this},WYMeditor.XhtmlSaxListener.prototype.shouldCloseTagAutomatically=function(a,b,c){if("td"!=a&&"option"!=a)return!1;var d=this._open_tags[a];if(!d)return!1;if("td"==a){var e=this._open_tags.tr||0;if(!c&&"td"===b&&d>=e)return!0;if(c&&"tr"==b&&d>e)return!0}else if("option"==a&&(c&&"select"==b||!c&&"option"==b))return!0;return!1},WYMeditor.XhtmlSaxListener.prototype.beforeParsing=function(a){return this.output="",this._insert_before_closing=[],this._insert_after_closing=[],this._open_tags={},this._tag_stack=[],this._last_node_was_text=!1,this._lastTagRemoved=!1,this._insideTagToRemove=!1,this.last_tag=null,a},WYMeditor.XhtmlSaxListener.prototype.afterParsing=function(a){return a=this.replaceNamedEntities(a),a=this.joinRepeatedEntities(a),a=this.removeEmptyTags(a),a=this.removeBrInPre(a)},WYMeditor.XhtmlSaxListener.prototype.replaceNamedEntities=function(a){for(var b in this.entities)a=a.replace(new RegExp(b,"g"),this.entities[b]);return a},WYMeditor.XhtmlSaxListener.prototype.joinRepeatedEntities=function(a){var b="em|strong|sub|sup|acronym|pre|del|address";return a.replace(new RegExp("<\\1>",""),"").replace(new RegExp("(s*<("+b+")>s*){2}(.*)(s*s*){2}",""),"<$2>$3<$2>")},WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags=function(a){return a.replace(new RegExp("<("+this.block_tags.join("|").replace(/\|td/,"").replace(/\|th/,"")+")>(
              | | |\\s)*","g"),"")},WYMeditor.XhtmlSaxListener.prototype.removeBrInPre=function(a){var b=a.match(new RegExp("]*>(.*?)
              ","gmi"));if(b)for(var c=0;c","g"),String.fromCharCode(13,10)));return a},WYMeditor.XhtmlSaxListener.prototype.getResult=function(){return this.output},WYMeditor.XhtmlSaxListener.prototype.getTagReplacements=function(){return{b:"strong",i:"em"}},WYMeditor.XhtmlSaxListener.prototype.getTagForStyle=function(a){return/sub/.test(a)?"sub":/super/.test(a)?"sup":/bold/.test(a)?"strong":/italic/.test(a)?"em":!1},WYMeditor.XhtmlSaxListener.prototype.addContent=function(a){this.last_tag&&"li"==this.last_tag&&(a=a.replace(/(\r|\n|\r\n)+$/g,""),a=a.replace(/(\r|\n|\r\n)+/g," ")),a.replace(/^\s+|\s+$/g,"").length>0&&(this._last_node_was_text=!0,this._addSpacerBeforeElementInLI&&(this.output+="
              ",this._addSpacerBeforeElementInLI=!1)),this._insideTagToRemove||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.addComment=function(a){this.remove_comments||this._insideTagToRemove||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.addScript=function(a){this.remove_scripts||this._insideTagToRemove||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.addCss=function(a){this.remove_embeded_styles||this._insideTagToRemove||(this.output+=a)},WYMeditor.XhtmlSaxListener.prototype.openBlockTag=function(a,b){var c=this._last_node_was_text;if(this._last_node_was_text=!1,!this._insideTagToRemove){if(this._shouldRemoveTag(a,b))return this._insideTagToRemove=!0,void(this._removedTagStackIndex=this._tag_stack.length-1);if(this._insideLI&&jQuery.inArray(a,this.tagsToUnwrapInLists)>-1)return("li"!==this._lastAddedOpenTag||c)&&(this.output+="
              ",this._addSpacerBeforeElementInLI=!1),this._tag_stack.pop(),void this._extraBlockClosingTags++;if(this._addSpacerBeforeElementInLI&&"li"!==a&&-1===jQuery.inArray(a,WYMeditor.LIST_TYPE_ELEMENTS)&&(this.output+="
              ",this._addSpacerBeforeElementInLI=!1),b=this.validator.getValidTagAttributes(a,b),b=this.removeUnwantedClasses(b),"span"===a&&b.style){var d=this.getTagForStyle(b.style);d&&(a=d,this._tag_stack.pop(),this._tag_stack.push(a),b.style="")}"li"===a&&(this._insideLI=!0,this._addSpacerBeforeElementInLI=!1),this.output+=this.helper.tag(a,b,!0),this._lastAddedOpenTag=a,this._lastTagRemoved=!1}},WYMeditor.XhtmlSaxListener.prototype.inlineTag=function(a,b){this._insideTagToRemove||this._shouldRemoveTag(a,b)||(this._last_node_was_text=!1,b=this.validator.getValidTagAttributes(a,b),b=this.removeUnwantedClasses(b),this.output+=this.helper.tag(a,b),this._lastTagRemoved=!1)},WYMeditor.XhtmlSaxListener.prototype.openUnknownTag=function(a,b){},WYMeditor.XhtmlSaxListener.prototype.closeBlockTag=function(a){return this._last_node_was_text=!1,this._insideTagToRemove?(this._tag_stack.length===this._removedTagStackIndex&&(this._insideTagToRemove=!1),void(this._lastTagRemoved=!0)):("li"===a&&(this._insideLI=!1,this._addSpacerBeforeElementInLI=!1),jQuery.inArray(a,WYMeditor.LIST_TYPE_ELEMENTS)>-1&&(this._insideLI=!1),void(this.output=this.output+this._getClosingTagContent("before",a)+""+this._getClosingTagContent("after",a)))},WYMeditor.XhtmlSaxListener.prototype.removedExtraBlockClosingTag=function(){this._extraBlockClosingTags--,this._addSpacerBeforeElementInLI=!0,this._last_node_was_text=!1},WYMeditor.XhtmlSaxListener.prototype.closeUnknownTag=function(a){},WYMeditor.XhtmlSaxListener.prototype.closeUnopenedTag=function(a){this._last_node_was_text=!1,this._insideTagToRemove||("li"===a&&this._extraLIClosingTags?this._extraLIClosingTags--:this.output+="")},WYMeditor.XhtmlSaxListener.prototype.avoidStylingTagsAndAttributes=function(){this.avoided_tags=["div","span"],this.validator.skiped_attributes=["style"],this.validator.skiped_attribute_values=["MsoNormal","main1"],this._avoiding_tags_implicitly=!0},WYMeditor.XhtmlSaxListener.prototype.allowStylingTagsAndAttributes=function(){this.avoided_tags=[],this.validator.skiped_attributes=[],this.validator.skiped_attribute_values=[],this._avoiding_tags_implicitly=!1},WYMeditor.XhtmlSaxListener.prototype.isBlockTag=function(a){return!WYMeditor.Helper.arrayContains(this.avoided_tags,a)&&WYMeditor.Helper.arrayContains(this.block_tags,a)},WYMeditor.XhtmlSaxListener.prototype.isInlineTag=function(a){return!WYMeditor.Helper.arrayContains(this.avoided_tags,a)&&WYMeditor.Helper.arrayContains(this.inline_tags,a)},WYMeditor.XhtmlSaxListener.prototype.insertContentAfterClosingTag=function(a,b){this._insertContentWhenClosingTag("after",a,b)},WYMeditor.XhtmlSaxListener.prototype.insertContentBeforeClosingTag=function(a,b){this._insertContentWhenClosingTag("before",a,b)},WYMeditor.XhtmlSaxListener.prototype.removeUnwantedClasses=function(a){var b,c;if(!a["class"])return a;for(c=0;c=2){var c=this._tag_stack[this._tag_stack.length-2];"li"!=c||this._shouldRemoveTag(a,b)||(this._open_tags.li-=1,0===this._open_tags.li&&(this._open_tags.li=void 0),this._tag_stack.splice(this._tag_stack.length-2,1),this._last_node_was_text=!1,this._insideTagToRemove?this._tag_stack.length-1===this._removedTagStackIndex&&(this._insideTagToRemove=!1,this._lastTagRemoved=!0,this._extraLIClosingTags++):this.output+="")}}else this._shouldRemoveTag(a,b)||(this.output+=this.helper.tag("li",{},!0),this.insertContentAfterClosingTag(a,"")),this._last_node_was_text=!1;else this._lastTagRemoved?(this._insideTagToRemove=!0,this._removedTagStackIndex=this._tag_stack.length-1):this._shouldRemoveTag(a,b)||(this.output=this.output.replace(/<\/li>\s*$/,""),this.insertContentAfterClosingTag(a,""))},WYMeditor.XhtmlSaxListener.prototype._insertContentWhenClosingTag=function(a,b,c){this["_insert_"+a+"_closing"]||(this["_insert_"+a+"_closing"]=[]),this["_insert_"+a+"_closing"][b]||(this["_insert_"+a+"_closing"][b]=[]),this["_insert_"+a+"_closing"][b].push(c)},WYMeditor.XhtmlSaxListener.prototype._getClosingTagContent=function(a,b){return this["_insert_"+a+"_closing"]&&this["_insert_"+a+"_closing"][b]&&this["_insert_"+a+"_closing"][b].length>0?this["_insert_"+a+"_closing"][b].pop():""},WYMeditor.XhtmlSaxListener.prototype._shouldRemoveTag=function(a,b){return this._isEditorOnlyTag(a,b)?!0:this._isRootInlineTagToRemove(a,b,this._tag_stack)?!0:this._isThirdConsecutiveBrWithNoAttributes(a,b)?!0:!1},WYMeditor.XhtmlSaxListener.prototype._isEditorOnlyTag=function(a,b){var c;return b["class"]?(c=b["class"].split(" "),WYMeditor.Helper.arrayContains(c,WYMeditor.EDITOR_ONLY_CLASS)?!0:!1):!1},WYMeditor.XhtmlSaxListener.prototype._isRootInlineTagToRemove=function(a,b,c){return this.isInlineTag(a)?c.length>0?!1:WYMeditor.Helper.arrayContains(this._rootInlineTagsToRemove,a)?!0:!1:!1},WYMeditor.XhtmlSaxListener.prototype._isThirdConsecutiveBrWithNoAttributes=function(a,b){var c;if("br"!==a)return this._consecutive_brs=0,!1;if(0!==this._consecutive_brs&&this._last_node_was_text)return this._consecutive_brs=0,!1;for(c in b)if(b.hasOwnProperty(c))return this._consecutive_brs=0,!1;return this._consecutive_brs++,this._consecutive_brs>2?!0:!1},WYMeditor.XhtmlValidator={_attributes:{core:{except:["base","head","html","meta","param","script","style","title"],attributes:["class","id","title","accesskey","tabindex","/^data-.*/"]},styleAttr:{except:["img"],attributes:["style"]},language:{except:["base","br","hr","iframe","param","script"],attributes:{dir:["ltr","rtl"],0:"lang",1:"xml:lang"}},keyboard:{attributes:{accesskey:/^(\w){1}$/,tabindex:/^(\d)+$/}}},_events:{window:{only:["body"],attributes:["onload","onunload"]},form:{only:["form","input","textarea","select","a","label","button"],attributes:["onchange","onsubmit","onreset","onselect","onblur","onfocus"]},keyboard:{except:["base","bdo","br","frame","frameset","head","html","iframe","meta","param","script","style","title"],attributes:["onkeydown","onkeypress","onkeyup"]},mouse:{except:["base","bdo","br","head","html","meta","param","script","style","title"],attributes:["onclick","ondblclick","onmousedown","onmousemove","onmouseover","onmouseout","onmouseup"]}},_tags:{a:{attributes:{0:"charset",1:"coords",2:"href",3:"hreflang",4:"name",5:"rel",6:"rev",shape:/^(rect|rectangle|circ|circle|poly|polygon)$/,7:"type"}},0:"abbr",1:"acronym",2:"address",area:{attributes:{0:"alt",1:"coords",2:"href",nohref:/^(true|false)$/,shape:/^(rect|rectangle|circ|circle|poly|polygon)$/},required:["alt"]},3:"b",base:{attributes:["href"],required:["href"]},bdo:{attributes:{dir:/^(ltr|rtl)$/},required:["dir"]},4:"big",blockquote:{attributes:["cite"]},5:"body",6:"br",button:{attributes:{disabled:/^(disabled)$/,type:/^(button|reset|submit)$/,0:"value"},inside:"form"},7:"caption",8:"cite",9:"code",col:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",span:/^(\d)+$/,valign:/^(top|middle|bottom|baseline)$/,2:"width"},inside:"colgroup"},colgroup:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",span:/^(\d)+$/,valign:/^(top|middle|bottom|baseline)$/,2:"width"}},10:"dd",del:{attributes:{0:"cite",datetime:/^([0-9]){8}/}},11:"div",12:"dfn",13:"dl",14:"dt",15:"em",fieldset:{inside:"form"},form:{attributes:{0:"action",1:"accept",2:"accept-charset",3:"enctype",method:/^(get|post)$/},required:["action"]},head:{attributes:["profile"]},16:"h1",17:"h2",18:"h3",19:"h4",20:"h5",21:"h6",22:"hr",html:{attributes:["xmlns"]},23:"i",img:{attributes:["alt","src","height","ismap","longdesc","usemap","width"],required:["alt","src"]},input:{attributes:{0:"accept",1:"alt",checked:/^(checked)$/,disabled:/^(disabled)$/,maxlength:/^(\d)+$/,2:"name",readonly:/^(readonly)$/,size:/^(\d)+$/,3:"src",type:/^(button|checkbox|file|hidden|image|password|radio|reset|submit|text)$/,4:"value"},inside:"form"},ins:{attributes:{0:"cite",datetime:/^([0-9]){8}/}},24:"kbd",label:{attributes:["for"],inside:"form"},25:"legend",26:"li",link:{attributes:{0:"charset",1:"href",2:"hreflang",media:/^(all|braille|print|projection|screen|speech|,|;| )+$/i,rel:/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,rev:/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,3:"type"},inside:"head"},map:{attributes:["id","name"],required:["id"]},meta:{attributes:{0:"content","http-equiv":/^(content\-type|expires|refresh|set\-cookie)$/i,1:"name",2:"scheme"},required:["content"]},27:"noscript",object:{attributes:["archive","classid","codebase","codetype","data","declare","height","name","standby","type","usemap","width"]},28:"ol",optgroup:{attributes:{0:"label",disabled:/^(disabled)$/},required:["label"]},option:{attributes:{0:"label",disabled:/^(disabled)$/,selected:/^(selected)$/,1:"value"},inside:"select"},29:"p",param:{attributes:{0:"type",valuetype:/^(data|ref|object)$/,1:"valuetype",2:"value"},required:["name"]},30:"pre",q:{attributes:["cite"]},31:"samp",script:{attributes:{type:/^(text\/ecmascript|text\/javascript|text\/jscript|text\/vbscript|text\/vbs|text\/xml)$/,0:"charset",defer:/^(defer)$/,1:"src"},required:["type"]},select:{attributes:{disabled:/^(disabled)$/,multiple:/^(multiple)$/,0:"name",1:"size"},inside:"form"},32:"small",33:"span",34:"strong",style:{attributes:{0:"type",media:/^(screen|tty|tv|projection|handheld|print|braille|aural|all)$/},required:["type"]},35:"sub",36:"sup",table:{attributes:{0:"border",1:"cellpadding",2:"cellspacing",frame:/^(void|above|below|hsides|lhs|rhs|vsides|box|border)$/,rules:/^(none|groups|rows|cols|all)$/,3:"summary",4:"width"}},tbody:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},td:{attributes:{0:"abbr",align:/^(left|right|center|justify|char)$/,1:"axis",2:"char",3:"charoff",colspan:/^(\d)+$/,4:"headers",rowspan:/^(\d)+$/,scope:/^(col|colgroup|row|rowgroup)$/,valign:/^(top|middle|bottom|baseline)$/}},textarea:{attributes:["cols","rows","disabled","name","readonly"],required:["cols","rows"],inside:"form"},tfoot:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom)$/,2:"baseline"}},th:{attributes:{0:"abbr",align:/^(left|right|center|justify|char)$/,1:"axis",2:"char",3:"charoff",colspan:/^(\d)+$/,4:"headers",rowspan:/^(\d)+$/,scope:/^(col|colgroup|row|rowgroup)$/,valign:/^(top|middle|bottom|baseline)$/}},thead:{attributes:{align:/^(right|left|center|justify)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},37:"title",tr:{attributes:{align:/^(right|left|center|justify|char)$/,0:"char",1:"charoff",valign:/^(top|middle|bottom|baseline)$/}},38:"tt",39:"ul",40:"var"},skiped_attributes:[],skiped_attribute_values:[],getValidTagAttributes:function(a,b){var c={},d=this.getPossibleTagAttributes(a);for(var e in b){var f=b[e];e=e.toLowerCase();var g=WYMeditor.Helper;g.arrayContains(this.skiped_attributes,e)||g.arrayContains(this.skiped_attribute_values,f)||("function"!=typeof f&&g.arrayContains(d,e)?this.doesAttributeNeedsValidation(a,e)?this.validateAttribute(a,e,f)&&(c[e]=f):c[e]=f:jQuery.each(d,function(){this.match(/\/(.*)\//)&&(regex=new RegExp(this.match(/\/(.*)\//)[1]),regex.test(e)&&(c[e]=f))}))}return c},getUniqueAttributesAndEventsForTag:function(a){var b=[];if(this._tags[a]&&this._tags[a].attributes)for(var c in this._tags[a].attributes)b.push(parseInt(c,10)==c?this._tags[a].attributes[c]:c);return b},getDefaultAttributesAndEventsForTags:function(){var a=[];for(var b in this._events)a.push(this._events[b]);for(b in this._attributes)a.push(this._attributes[b]);return a},isValidTag:function(a){if(this._tags[a])return!0;for(var b in this._tags)if(this._tags[b]==a)return!0;return!1},getDefaultAttributesAndEventsForTag:function(a){var b=[];if(this.isValidTag(a)){var c=this.getDefaultAttributesAndEventsForTags();for(var d in c){var e=c[d];if("object"==typeof e){var f=WYMeditor.Helper;if(e.except&&f.arrayContains(e.except,a)||e.only&&!f.arrayContains(e.only,a))continue;var g=e.attributes?e.attributes:e.events;for(var h in g)b.push("string"!=typeof g[h]?h:g[h])}}}return b},doesAttributeNeedsValidation:function(a,b){return this._tags[a]&&(this._tags[a].attributes&&this._tags[a].attributes[b]||this._tags[a].required&&WYMeditor.Helper.arrayContains(this._tags[a].required,b))},validateAttribute:function(a,b,c){return this._tags[a]&&this._tags[a].attributes&&this._tags[a].attributes[b]&&c.length>0&&!c.match(this._tags[a].attributes[b])||this._tags[a]&&this._tags[a].required&&WYMeditor.Helper.arrayContains(this._tags[a].required,b)&&0===c.length?!1:"undefined"!=typeof this._tags[a]},getPossibleTagAttributes:function(a){return this._possible_tag_attributes||(this._possible_tag_attributes={}),this._possible_tag_attributes[a]||(this._possible_tag_attributes[a]=this.getUniqueAttributesAndEventsForTag(a).concat(this.getDefaultAttributesAndEventsForTag(a))),this._possible_tag_attributes[a]}},WYMeditor.XmlHelper=function(){return this._entitiesDiv=document.createElement("div"),this},WYMeditor.XmlHelper.prototype.tag=function(a,b,c){return b=b||!1,c=c||!1,"<"+a+(b?this.tagOptions(b):"")+(c?">":" />")},WYMeditor.XmlHelper.prototype.contentTag=function(a,b,c){return c=c||!1,"<"+a+(c?this.tagOptions(c):"")+">"+b+""},WYMeditor.XmlHelper.prototype.cdataSection=function(a){return""},WYMeditor.XmlHelper.prototype.escapeOnce=function(a){return this._fixDoubleEscape(this.escapeEntities(a))},WYMeditor.XmlHelper.prototype._fixDoubleEscape=function(a){return a.replace(/&([a-z]+|(#\d+));/gi,"&$1;")},WYMeditor.XmlHelper.prototype.tagOptions=function(a){var b=this;b._formated_options="";for(var c in a){var d=a[c];"function"!=typeof d&&d.length>0&&(parseInt(c,10)==c&&"object"==typeof d&&(c=d.shift(),d=d.pop()),""!==c&&""!==d&&(b._formated_options+=" "+c+'="'+b.escapeOnce(d)+'"'))}return b._formated_options},WYMeditor.XmlHelper.prototype.escapeEntities=function(a,b){this._entitiesDiv.innerHTML=a,this._entitiesDiv.textContent=a;var c=this._entitiesDiv.innerHTML;return"undefined"==typeof b&&(b!==!1&&(c=c.replace('"',""")),b===!0&&(c=c.replace('"',"'"))),c},WYMeditor.XmlHelper.prototype.parseAttributes=function(a){var b=[],c=a.split(/((=\s*")(")("))|((=\s*\')(\')(\'))|((=\s*[^>\s]*))/g);if(c.toString()!=a)for(var d in c){var e=c[d];if("function"!=typeof e&&0!==e.length){var f=new RegExp("(\\w+)\\s*"+e),g=a.match(f);if(g){var h=e.replace(/^[\s=]+/,""),i=h.charAt(0);i='"'==i?'"':"'"==i?"'":"",""!==i&&(h='"'==i?h.replace(/^"|"+$/g,""):h.replace(/^'|'+$/g,"")),a=a.replace(g[0],""),b.push([g[1],h])}}}return b},WYMeditor.STRINGS.bg={Strong:"Получер",Emphasis:"Курсив",Superscript:"Горен индекс",Subscript:"Долен индекс",Ordered_List:"Подреден списък",Unordered_List:"Неподреден списък",Indent:"Блок навътре",Outdent:"Блок навън",Undo:"Стъпка назад",Redo:"Стъпка напред",Link:"Създай хипервръзка",Unlink:"Премахни хипервръзката",Image:"Изображение",Table:"Таблица",HTML:"HTML",Paragraph:"Абзац",Heading_1:"Заглавие 1",Heading_2:"Заглавие 2",Heading_3:"Заглавие 3",Heading_4:"Заглавие 4",Heading_5:"Заглавие 5",Heading_6:"Заглавие 6",Preformatted:"Преформатиран",Blockquote:"Цитат",Table_Header:"Заглавие на таблицата",URL:"URL",Title:"Заглавие",Alternative_Text:"Алтернативен текст",Caption:"Етикет",Summary:"Общо",Number_Of_Rows:"Брой редове",Number_Of_Cols:"Брой колони",Submit:"Изпрати",Cancel:"Отмени",Choose:"Затвори",Preview:"Предварителен преглед",Paste_From_Word:"Вмъкни от MS WORD",Tools:"Инструменти",Containers:"Контейнери",Classes:"Класове",Status:"Статус",Source_Code:"Източник, код"},WYMeditor.STRINGS.ca={Strong:"Ressaltar",Emphasis:"Emfatitzar",Superscript:"Superindex",Subscript:"Subindex",Ordered_List:"Llistat ordenat",Unordered_List:"Llistat sense ordenar",Indent:"Indentat",Outdent:"Sense indentar",Undo:"Desfer",Redo:"Refer",Link:"Enllaçar",Unlink:"Eliminar enllaç",Image:"Imatge",Table:"Taula",HTML:"HTML",Paragraph:"Paràgraf",Heading_1:"Capçalera 1",Heading_2:"Capçalera 2",Heading_3:"Capçalera 3",Heading_4:"Capçalera 4",Heading_5:"Capçalera 5",Heading_6:"Capçalera 6",Preformatted:"Pre-formatejat",Blockquote:"Cita",Table_Header:"Capçalera de la taula",URL:"URL",Title:"Títol",Alternative_Text:"Text alternatiu",Caption:"Llegenda",Summary:"Summary",Number_Of_Rows:"Nombre de files",Number_Of_Cols:"Nombre de columnes",Submit:"Enviar",Cancel:"Cancel·lar",Choose:"Triar",Preview:"Vista prèvia",Paste_From_Word:"Pegar des de Word",Tools:"Eines",Containers:"Contenidors",Classes:"Classes",Status:"Estat",Source_Code:"Codi font"},WYMeditor.STRINGS.cs={Strong:"Tučné",Emphasis:"Kurzíva",Superscript:"Horní index",Subscript:"Dolní index",Ordered_List:"Číslovaný seznam",Unordered_List:"Nečíslovaný seznam",Indent:"Zvětšit odsazení",Outdent:"Zmenšit odsazení",Undo:"Zpět",Redo:"Znovu",Link:"Vytvořit odkaz",Unlink:"Zrušit odkaz",Image:"Obrázek",Table:"Tabulka",HTML:"HTML",Paragraph:"Odstavec",Heading_1:"Nadpis 1. úrovně",Heading_2:"Nadpis 2. úrovně",Heading_3:"Nadpis 3. úrovně",Heading_4:"Nadpis 4. úrovně",Heading_5:"Nadpis 5. úrovně",Heading_6:"Nadpis 6. úrovně",Preformatted:"Předformátovaný text",Blockquote:"Citace",Table_Header:"Hlavičková buňka tabulky",URL:"Adresa",Title:"Text po najetí myší",Alternative_Text:"Text pro případ nezobrazení obrázku",Caption:"Titulek tabulky",Summary:"Shrnutí obsahu",Number_Of_Rows:"Počet řádek",Number_Of_Cols:"Počet sloupců",Submit:"Vytvořit",Cancel:"Zrušit",Choose:"Vybrat",Preview:"Náhled",Paste_From_Word:"Vložit z Wordu",Tools:"Nástroje",Containers:"Typy obsahu",Classes:"Třídy",Status:"Stav",Source_Code:"Zdrojový kód"},WYMeditor.STRINGS.cy={Strong:"Bras",Emphasis:"Italig",Superscript:"Uwchsgript",Subscript:"Is-sgript",Ordered_List:"Rhestr mewn Trefn",Unordered_List:"Pwyntiau Bwled",Indent:"Mewnoli",Outdent:"Alloli",Undo:"Dadwneud",Redo:"Ailwneud",Link:"Cysylltu",Unlink:"Datgysylltu",Image:"Delwedd",Table:"Tabl",HTML:"HTML",Paragraph:"Paragraff",Heading_1:"Pennawd 1",Heading_2:"Pennawd 2",Heading_3:"Pennawd 3",Heading_4:"Pennawd 4",Heading_5:"Pennawd 5",Heading_6:"Pennawd 6",Preformatted:"Rhagfformat",Blockquote:"Bloc Dyfyniad",Table_Header:"Pennyn Tabl",URL:"URL",Title:"Teitl",Alternative_Text:"Testun Amgen",Caption:"Pennawd",Summary:"Crynodeb",Number_Of_Rows:"Nifer y rhesi",Number_Of_Cols:"Nifer y colofnau",Submit:"Anfon",Cancel:"Diddymu",Choose:"Dewis",Preview:"Rhagolwg",Paste_From_Word:"Gludo o Word",Tools:"Offer",Containers:"Cynhwysyddion",Classes:"Dosbarthiadau",Status:"Statws",Source_Code:"Cod ffynhonnell"},WYMeditor.STRINGS.da={Strong:"Fed",Emphasis:"Skrå",Superscript:"Superscript",Subscript:"Subscript",Ordered_List:"Ordnet liste",Unordered_List:"Uordnet liste",Indent:"Indrykke",Outdent:"Udrykke",Undo:"Fortryd",Redo:"Fortryd",Link:"Link",Unlink:"Fjern link",Image:"Billede",Table:"Tabel",HTML:"HTML",Paragraph:"Paragraf",Heading_1:"Overskrift 1",Heading_2:"Overskrift 2",Heading_3:"Overskrift 3",Heading_4:"Overskrift 4",Heading_5:"Overskrift 5",Heading_6:"Overskrift 6",Preformatted:"Forudformateret",Blockquote:"Citat",Table_Header:"Tabel Overskrift",URL:"URL",Title:"Titel",Alternative_Text:"Alternativ tekst",Caption:"Billedtekst",Summary:"Resumé",Number_Of_Rows:"Antal rækker",Number_Of_Cols:"Antal kolonner",Submit:"Indsend",Cancel:"Afbryd",Choose:"Vælg",Preview:"Forhåndsvisning",Paste_From_Word:"Indsæt fra Word",Tools:"Værktøjer",Containers:"Containere",Classes:"Klasser",Status:"Status",Source_Code:"Kildekode"},WYMeditor.STRINGS.de={Strong:"Fett",Emphasis:"Kursiv",Superscript:"Text hochstellen",Subscript:"Text tiefstellen",Ordered_List:"Geordnete Liste einfügen",Unordered_List:"Ungeordnete Liste einfügen",Indent:"Einzug erhöhen",Outdent:"Einzug vermindern",Undo:"Befehle rückgängig machen",Redo:"Befehle wiederherstellen",Link:"Hyperlink einfügen",Unlink:"Hyperlink entfernen",Image:"Bild einfügen",Table:"Tabelle einfügen",HTML:"HTML anzeigen/verstecken",Paragraph:"Absatz",Heading_1:"Überschrift 1",Heading_2:"Überschrift 2",Heading_3:"Überschrift 3",Heading_4:"Überschrift 4",Heading_5:"Überschrift 5",Heading_6:"Überschrift 6",Preformatted:"Vorformatiert",Blockquote:"Zitat",Table_Header:"Tabellenüberschrift",URL:"URL",Title:"Titel",Alternative_Text:"Alternativer Text",Caption:"Tabellenüberschrift",Summary:"Summary",Number_Of_Rows:"Anzahl Zeilen",Number_Of_Cols:"Anzahl Spalten",Submit:"Absenden",Cancel:"Abbrechen",Choose:"Auswählen",Preview:"Vorschau",Paste_From_Word:"Aus Word einfügen",Tools:"Werkzeuge",Containers:"Inhaltstyp",Classes:"Klassen",Status:"Status",Source_Code:"Quellcode"},WYMeditor.STRINGS.en={Strong:"Strong",Emphasis:"Emphasis",Superscript:"Superscript",Subscript:"Subscript",Ordered_List:"Ordered List",Unordered_List:"Unordered List",Indent:"Indent",Outdent:"Outdent",Undo:"Undo",Redo:"Redo",Link:"Link",Unlink:"Unlink",Image:"Image",Table:"Table",HTML:"HTML",Paragraph:"Paragraph",Heading_1:"Heading 1",Heading_2:"Heading 2",Heading_3:"Heading 3",Heading_4:"Heading 4",Heading_5:"Heading 5",Heading_6:"Heading 6",Preformatted:"Preformatted",Blockquote:"Blockquote",Table_Header:"Table Header",URL:"URL",Title:"Title",Relationship:"Relationship",Alternative_Text:"Alternative text",Caption:"Caption",Summary:"Summary",Number_Of_Rows:"Number of rows",Number_Of_Cols:"Number of cols",Submit:"Submit", -Cancel:"Cancel",Choose:"Choose",Preview:"Preview",Paste_From_Word:"Paste from Word",Tools:"Tools",Containers:"Formatting",Classes:"Style",Status:"Status",Source_Code:"Source code"},WYMeditor.STRINGS.es={Strong:"Resaltar",Emphasis:"Enfatizar",Superscript:"Superindice",Subscript:"Subindice",Ordered_List:"Lista ordenada",Unordered_List:"Lista sin ordenar",Indent:"Indentado",Outdent:"Sin indentar",Undo:"Deshacer",Redo:"Rehacer",Link:"Enlazar",Unlink:"Eliminar enlace",Image:"Imagen",Table:"Tabla",HTML:"HTML",Paragraph:"Párrafo",Heading_1:"Cabecera 1",Heading_2:"Cabecera 2",Heading_3:"Cabecera 3",Heading_4:"Cabecera 4",Heading_5:"Cabecera 5",Heading_6:"Cabecera 6",Preformatted:"Preformateado",Blockquote:"Cita",Table_Header:"Cabecera de la tabla",URL:"URL",Title:"Título",Alternative_Text:"Texto alternativo",Caption:"Leyenda",Summary:"Summary",Number_Of_Rows:"Número de filas",Number_Of_Cols:"Número de columnas",Submit:"Enviar",Cancel:"Cancelar",Choose:"Seleccionar",Preview:"Vista previa",Paste_From_Word:"Pegar desde Word",Tools:"Herramientas",Containers:"Contenedores",Classes:"Clases",Status:"Estado",Source_Code:"Código fuente"},WYMeditor.STRINGS.fa={Strong:"پررنگ",Emphasis:"ایتالیک",Superscript:"بالانويس‌ ",Subscript:"زيرنويس‌",Ordered_List:"لیست مرتب",Unordered_List:"لیست نامرتب",Indent:"افزودن دندانه",Outdent:"کاهش دندانه",Undo:"واگردانی",Redo:"تکرار",Link:"ساختن پیوند",Unlink:"برداشتن پیوند",Image:"تصویر",Table:"جدول",HTML:"HTML",Paragraph:"پاراگراف",Heading_1:"سرتیتر ۱",Heading_2:"سرتیتر ۲",Heading_3:"سرتیتر ۳",Heading_4:"سرتیتر ۴",Heading_5:"سرتیتر ۵",Heading_6:"سرتیتر ۶",Preformatted:"قالب آماده",Blockquote:"نقل قول",Table_Header:"سرجدول",URL:"آدرس اینترنتی",Title:"عنوان",Alternative_Text:"متن جایگزین",Caption:"عنوان",Summary:"Summary",Number_Of_Rows:"تعداد سطرها",Number_Of_Cols:"تعداد ستون‌ها",Submit:"فرستادن",Cancel:"لغو",Choose:"انتخاب",Preview:"پیش‌نمایش",Paste_From_Word:"انتقال از ورد",Tools:"ابزار",Containers:"‌قالب‌ها",Classes:"کلاس‌ها",Status:"وضعیت",Source_Code:"کد مبدأ"},WYMeditor.STRINGS.fi={Strong:"Lihavoitu",Emphasis:"Korostus",Superscript:"Yläindeksi",Subscript:"Alaindeksi",Ordered_List:"Numeroitu lista",Unordered_List:"Luettelomerkit",Indent:"Suurenna sisennystä",Outdent:"Pienennä sisennystä",Undo:"Kumoa",Redo:"Toista",Link:"Linkitä",Unlink:"Poista linkitys",Image:"Kuva",Table:"Taulukko",HTML:"HTML",Paragraph:"Kappale",Heading_1:"Otsikko 1",Heading_2:"Otsikko 2",Heading_3:"Otsikko 3",Heading_4:"Otsikko 4",Heading_5:"Otsikko 5",Heading_6:"Otsikko 6",Preformatted:"Esimuotoilu",Blockquote:"Sitaatti",Table_Header:"Taulukon otsikko",URL:"URL",Title:"Otsikko",Alternative_Text:"Vaihtoehtoinen teksti",Caption:"Kuvateksti",Summary:"Yhteenveto",Number_Of_Rows:"Rivien määrä",Number_Of_Cols:"Palstojen määrä",Submit:"Lähetä",Cancel:"Peruuta",Choose:"Valitse",Preview:"Esikatsele",Paste_From_Word:"Tuo Wordista",Tools:"Työkalut",Containers:"Muotoilut",Classes:"Luokat",Status:"Tila",Source_Code:"Lähdekoodi"},WYMeditor.STRINGS.fr={Strong:"Mise en évidence",Emphasis:"Emphase",Superscript:"Exposant",Subscript:"Indice",Ordered_List:"Liste Ordonnée",Unordered_List:"Liste Non-Ordonnée",Indent:"Imbriqué",Outdent:"Non-imbriqué",Undo:"Annuler",Redo:"Rétablir",Link:"Lien",Unlink:"Supprimer le Lien",Image:"Image",Table:"Tableau",HTML:"HTML",Paragraph:"Paragraphe",Heading_1:"Titre 1",Heading_2:"Titre 2",Heading_3:"Titre 3",Heading_4:"Titre 4",Heading_5:"Titre 5",Heading_6:"Titre 6",Preformatted:"Pré-formatté",Blockquote:"Citation",Table_Header:"Cellule de titre",URL:"URL",Title:"Titre",Alternative_Text:"Texte alternatif",Caption:"Légende",Summary:"Résumé",Number_Of_Rows:"Nombre de lignes",Number_Of_Cols:"Nombre de colonnes",Submit:"Envoyer",Cancel:"Annuler",Choose:"Choisir",Preview:"Prévisualisation",Paste_From_Word:"Copier depuis Word",Tools:"Outils",Containers:"Type de texte",Classes:"Type de contenu",Status:"Infos",Source_Code:"Code source"},WYMeditor.STRINGS.gl={Strong:"Moita énfase",Emphasis:"Énfase",Superscript:"Superíndice",Subscript:"Subíndice",Ordered_List:"Lista ordenada",Unordered_List:"Lista sen ordenar",Indent:"Aniñar",Outdent:"Desaniñar",Undo:"Desfacer",Redo:"Refacer",Link:"Ligazón",Unlink:"Desligar",Image:"Imaxe",Table:"Táboa",HTML:"HTML",Paragraph:"Parágrafo",Heading_1:"Título 1",Heading_2:"Título 2",Heading_3:"Título 3",Heading_4:"Título 4",Heading_5:"Título 5",Heading_6:"Título 6",Preformatted:"Preformatado",Blockquote:"Cita en parágrafo",Table_Header:"Cabeceira da táboa",URL:"URL",Title:"Título",Alternative_Text:"Texto alternativo",Caption:"Título",Summary:"Resumo",Number_Of_Rows:"Número de filas",Number_Of_Cols:"Número de columnas",Submit:"Enviar",Cancel:"Cancelar",Choose:"Escoller",Preview:"Previsualizar",Paste_From_Word:"Colar dende Word",Tools:"Ferramentas",Containers:"Contenedores",Classes:"Clases",Status:"Estado",Source_Code:"Código fonte"},WYMeditor.STRINGS.he={Strong:"חזק",Emphasis:"מובלט",Superscript:"כתב עילי",Subscript:"כתב תחתי",Ordered_List:"רשימה ממוספרת",Unordered_List:"רשימה לא ממוספרת",Indent:"הזחה פנימה",Outdent:"הזחה החוצה",Undo:"בטל פעולה",Redo:"בצע מחדש פעולה",Link:"קישור",Unlink:"בטל קישור",Image:"תמונה",Table:"טבלה",HTML:"קוד HTML",Paragraph:"פסקה",Heading_1:"כותרת 1 ; תג <h1>",Heading_2:"כותרת 2 ; תג <h2>",Heading_3:"כותרת 3 ; תג <h3>",Heading_4:"כותרת 4 ; תג <h4>",Heading_5:"כותרת 5 ; תג <h5>",Heading_6:"כותרת 6 ; תג <h6>",Preformatted:"משמר רווחים",Blockquote:"ציטוט",Table_Header:"כותרת טבלה",URL:"קישור (URL)",Title:"כותרת",Alternative_Text:"טקסט חלופי",Caption:"כותרת",Summary:"סיכום",Number_Of_Rows:"מספר שורות",Number_Of_Cols:"מספר טורים",Submit:"שלח",Cancel:"בטל",Choose:"בחר",Preview:"תצוגה מקדימה",Paste_From_Word:"העתק מ-Word",Tools:"כלים",Containers:"מיכלים",Classes:"מחלקות",Status:"מצב",Source_Code:"קוד מקור"},WYMeditor.STRINGS.hr={Strong:"Podebljano",Emphasis:"Naglašeno",Superscript:"Iznad",Subscript:"Ispod",Ordered_List:"Pobrojana lista",Unordered_List:"Nepobrojana lista",Indent:"Uvuci",Outdent:"Izvuci",Undo:"Poništi promjenu",Redo:"Ponovno promjeni",Link:"Hiperveza",Unlink:"Ukloni hipervezu",Image:"Slika",Table:"Tablica",HTML:"HTML",Paragraph:"Paragraf",Heading_1:"Naslov 1",Heading_2:"Naslov 2",Heading_3:"Naslov 3",Heading_4:"Naslov 4",Heading_5:"Naslov 5",Heading_6:"Naslov 6",Preformatted:"Unaprijed formatirano",Blockquote:"Citat",Table_Header:"Zaglavlje tablice",URL:"URL",Title:"Naslov",Alternative_Text:"Alternativni tekst",Caption:"Zaglavlje",Summary:"Sažetak",Number_Of_Rows:"Broj redova",Number_Of_Cols:"Broj kolona",Submit:"Snimi",Cancel:"Odustani",Choose:"Izaberi",Preview:"Pregled",Paste_From_Word:"Zalijepi iz Word-a",Tools:"Alati",Containers:"Kontejneri",Classes:"Klase",Status:"Status",Source_Code:"Izvorni kod"},WYMeditor.STRINGS.hu={Strong:"Félkövér",Emphasis:"Kiemelt",Superscript:"Felső index",Subscript:"Alsó index",Ordered_List:"Rendezett lista",Unordered_List:"Rendezetlen lista",Indent:"Bekezdés",Outdent:"Bekezdés törlése",Undo:"Visszavon",Redo:"Visszaállít",Link:"Link",Unlink:"Link törlése",Image:"Kép",Table:"Tábla",HTML:"HTML",Paragraph:"Bekezdés",Heading_1:"Címsor 1",Heading_2:"Címsor 2",Heading_3:"Címsor 3",Heading_4:"Címsor 4",Heading_5:"Címsor 5",Heading_6:"Címsor 6",Preformatted:"Előformázott",Blockquote:"Idézet",Table_Header:"Tábla Fejléc",URL:"Webcím",Title:"Megnevezés",Alternative_Text:"Alternatív szöveg",Caption:"Fejléc",Summary:"Summary",Number_Of_Rows:"Sorok száma",Number_Of_Cols:"Oszlopok száma",Submit:"Elküld",Cancel:"Mégsem",Choose:"Választ",Preview:"Előnézet",Paste_From_Word:"Másolás Word-ból",Tools:"Eszközök",Containers:"Tartalmak",Classes:"Osztályok",Status:"Állapot",Source_Code:"Forráskód"},WYMeditor.STRINGS.it={Strong:"Grassetto",Emphasis:"Corsetto",Superscript:"Apice",Subscript:"Pedice",Ordered_List:"Lista Ordinata",Unordered_List:"Lista Puntata",Indent:"Indenta",Outdent:"Caccia",Undo:"Indietro",Redo:"Avanti",Link:"Inserisci Link",Unlink:"Togli Link",Image:"Inserisci Immagine",Table:"Inserisci Tabella",HTML:"HTML",Paragraph:"Paragrafo",Heading_1:"Heading 1",Heading_2:"Heading 2",Heading_3:"Heading 3",Heading_4:"Heading 4",Heading_5:"Heading 5",Heading_6:"Heading 6",Preformatted:"Preformattato",Blockquote:"Blockquote",Table_Header:"Header Tabella",URL:"Indirizzo",Title:"Titolo",Alternative_Text:"Testo Alternativo",Caption:"Caption",Summary:"Summary",Number_Of_Rows:"Numero di Righe",Number_Of_Cols:"Numero di Colonne",Submit:"Invia",Cancel:"Cancella",Choose:"Scegli",Preview:"Anteprima",Paste_From_Word:"Incolla",Tools:"Tools",Containers:"Contenitori",Classes:"Classi",Status:"Stato",Source_Code:"Codice Sorgente"},WYMeditor.STRINGS.ja={Strong:"強調",Emphasis:"強調",Superscript:"上付き",Subscript:"下付き",Ordered_List:"番号付きリスト",Unordered_List:"番号無リスト",Indent:"インデントを増やす",Outdent:"インデントを減らす",Undo:"元に戻す",Redo:"やり直す",Link:"リンク",Unlink:"リンク取消",Image:"画像",Table:"テーブル",HTML:"HTML",Paragraph:"段落",Heading_1:"見出し 1",Heading_2:"見出し 2",Heading_3:"見出し 3",Heading_4:"見出し 4",Heading_5:"見出し 5",Heading_6:"見出し 6",Preformatted:"整形済みテキスト",Blockquote:"引用文",Table_Header:"表見出し",URL:"URL",Title:"タイトル",Alternative_Text:"代替テキスト",Caption:"キャプション",Summary:"サマリー",Number_Of_Rows:"行数",Number_Of_Cols:"列数",Submit:"送信",Cancel:"キャンセル",Choose:"選択",Preview:"プレビュー",Paste_From_Word:"貼り付け",Tools:"ツール",Containers:"コンテナ",Classes:"クラス",Status:"ステータス",Source_Code:"ソースコード"},WYMeditor.STRINGS.lt={Strong:"Pusjuodis",Emphasis:"Kursyvas",Superscript:"Viršutinis indeksas",Subscript:"Apatinis indeksas",Ordered_List:"Numeruotas sąrašas",Unordered_List:"Suženklintas sąrašas",Indent:"Padidinti įtrauką",Outdent:"Sumažinti įtrauką",Undo:"Atšaukti",Redo:"Atstatyti",Link:"Nuoroda",Unlink:"Panaikinti nuorodą",Image:"Vaizdas",Table:"Lentelė",HTML:"HTML",Paragraph:"Paragrafas",Heading_1:"Antraštinis 1",Heading_2:"Antraštinis 2",Heading_3:"Antraštinis 3",Heading_4:"Antraštinis 4",Heading_5:"Antraštinis 5",Heading_6:"Antraštinis 6",Preformatted:"Formuotas",Blockquote:"Citata",Table_Header:"Lentelės antraštė",URL:"URL",Title:"Antraštinis tekstas",Relationship:"Sąryšis",Alternative_Text:"Alternatyvus tekstas",Caption:"Antraštė",Summary:"Santrauka",Number_Of_Rows:"Eilučių skaičius",Number_Of_Cols:"Stulpelių skaičius",Submit:"Išsaugoti",Cancel:"Nutraukti",Choose:"Rinktis",Preview:"Peržiūra",Paste_From_Word:"Įkelti iš MS Word",Tools:"Įrankiai",Containers:"Stiliai",Classes:"Klasės",Status:"Statusas",Source_Code:"Išeities tekstas"},WYMeditor.STRINGS.nb={Strong:"Fet",Emphasis:"Uthevet",Superscript:"Opphøyet",Subscript:"Nedsenket",Ordered_List:"Nummerert liste",Unordered_List:"Punktliste",Indent:"Rykk inn",Outdent:"Rykk ut",Undo:"Angre",Redo:"Gjenta",Link:"Lenke",Unlink:"Ta bort lenken",Image:"Bilde",Table:"Tabell",HTML:"HTML",Paragraph:"Avsnitt",Heading_1:"Overskrift 1",Heading_2:"Overskrift 2",Heading_3:"Overskrift 3",Heading_4:"Overskrift 4",Heading_5:"Overskrift 5",Heading_6:"Overskrift 6",Preformatted:"Preformatert",Blockquote:"Sitat",Table_Header:"Tabelloverskrift",URL:"URL",Title:"Tittel",Alternative_Text:"Alternativ tekst",Caption:"Overskrift",Summary:"Sammendrag",Number_Of_Rows:"Antall rader",Number_Of_Cols:"Antall kolonner",Submit:"Ok",Cancel:"Avbryt",Choose:"Velg",Preview:"Forhåndsvis",Paste_From_Word:"Lim inn fra Word",Tools:"Verktøy",Containers:"Formatering",Classes:"Klasser",Status:"Status",Source_Code:"Kildekode"},WYMeditor.STRINGS.nl={Strong:"Sterk benadrukken",Emphasis:"Benadrukken",Superscript:"Bovenschrift",Subscript:"Onderschrift",Ordered_List:"Geordende lijst",Unordered_List:"Ongeordende lijst",Indent:"Inspringen",Outdent:"Terugspringen",Undo:"Ongedaan maken",Redo:"Opnieuw uitvoeren",Link:"Linken",Unlink:"Ontlinken",Image:"Afbeelding",Table:"Tabel",HTML:"HTML",Paragraph:"Paragraaf",Heading_1:"Kop 1",Heading_2:"Kop 2",Heading_3:"Kop 3",Heading_4:"Kop 4",Heading_5:"Kop 5",Heading_6:"Kop 6",Preformatted:"Voorgeformatteerd",Blockquote:"Citaat",Table_Header:"Tabel-kop",URL:"URL",Title:"Titel",Relationship:"Relatie",Alternative_Text:"Alternatieve tekst",Caption:"Bijschrift",Summary:"Summary",Number_Of_Rows:"Aantal rijen",Number_Of_Cols:"Aantal kolommen",Submit:"Versturen",Cancel:"Annuleren",Choose:"Kiezen",Preview:"Voorbeeld bekijken",Paste_From_Word:"Plakken uit Word",Tools:"Hulpmiddelen",Containers:"Teksttypes",Classes:"Klassen",Status:"Status",Source_Code:"Broncode"},WYMeditor.STRINGS.nn={Strong:"Feit",Emphasis:"Utheva",Superscript:"Opphøgd",Subscript:"Nedsenka",Ordered_List:"Nummerert liste",Unordered_List:"Punktliste",Indent:"Rykk inn",Outdent:"Rykk ut",Undo:"Angre",Redo:"Gjentaka",Link:"Lenkje",Unlink:"Ta bort lenkja",Image:"Bilete",Table:"Tabell",HTML:"HTML",Paragraph:"Avsnitt",Heading_1:"Overskrift 1",Heading_2:"Overskrift 2",Heading_3:"Overskrift 3",Heading_4:"Overskrift 4",Heading_5:"Overskrift 5",Heading_6:"Overskrift 6",Preformatted:"Preformatert",Blockquote:"Sitat",Table_Header:"Tabelloverskrift",URL:"URL",Title:"Tittel",Alternative_Text:"Alternativ tekst",Caption:"Overskrift",Summary:"Samandrag",Number_Of_Rows:"Tal på rader",Number_Of_Cols:"Tal på kolonnar",Submit:"Ok",Cancel:"Avbryt",Choose:"Vel",Preview:"Førehandsvis",Paste_From_Word:"Lim inn frå Word",Tools:"Verkty",Containers:"Formatering",Classes:"Klassar",Status:"Status",Source_Code:"Kjeldekode"},WYMeditor.STRINGS.pl={Strong:"Nacisk",Emphasis:"Emfaza",Superscript:"Indeks górny",Subscript:"Indeks dolny",Ordered_List:"Lista numerowana",Unordered_List:"Lista wypunktowana",Indent:"Zwiększ wcięcie",Outdent:"Zmniejsz wcięcie",Undo:"Cofnij",Redo:"Ponów",Link:"Wstaw link",Unlink:"Usuń link",Image:"Obraz",Table:"Tabela",HTML:"Źródło HTML",Paragraph:"Akapit",Heading_1:"Nagłówek 1",Heading_2:"Nagłówek 2",Heading_3:"Nagłówek 3",Heading_4:"Nagłówek 4",Heading_5:"Nagłówek 5",Heading_6:"Nagłówek 6",Preformatted:"Preformatowany",Blockquote:"Cytat blokowy",Table_Header:"Nagłówek tabeli",URL:"URL",Title:"Tytuł",Alternative_Text:"Tekst alternatywny",Caption:"Tytuł tabeli",Summary:"Summary",Number_Of_Rows:"Liczba wierszy",Number_Of_Cols:"Liczba kolumn",Submit:"Wyślij",Cancel:"Anuluj",Choose:"Wybierz",Preview:"Podgląd",Paste_From_Word:"Wklej z Worda",Tools:"Narzędzia",Containers:"Format",Classes:"Styl",Status:"Status",Source_Code:"Kod źródłowy"},WYMeditor.STRINGS["pt-br"]={Strong:"Resaltar",Emphasis:"Enfatizar",Superscript:"Sobre escrito",Subscript:"Sub escrito ",Ordered_List:"Lista ordenada",Unordered_List:"Lista desordenada",Indent:"Indentado",Outdent:"Desidentar",Undo:"Desfazer",Redo:"Refazer",Link:"Link",Unlink:"Remover Link",Image:"Imagem",Table:"Tabela",HTML:"HTML",Paragraph:"Parágrafo",Heading_1:"Título 1",Heading_2:"Título 2",Heading_3:"Título 3",Heading_4:"Título 4",Heading_5:"Título 5",Heading_6:"Título 6",Preformatted:"Preformatado",Blockquote:"Citação",Table_Header:"Título de tabela",URL:"URL",Title:"Título",Alternative_Text:"Texto alternativo",Caption:"Legenda",Summary:"Summary",Number_Of_Rows:"Número de linhas",Number_Of_Cols:"Número de colunas",Submit:"Enviar",Cancel:"Cancelar",Choose:"Selecionar",Preview:"Previsualizar",Paste_From_Word:"Copiar do Word",Tools:"Ferramentas",Containers:"Conteneiners",Classes:"Classes",Status:"Estado",Source_Code:"Código fonte"},WYMeditor.STRINGS.pt={Strong:"Negrito",Emphasis:"Itálico",Superscript:"Sobrescrito",Subscript:"Subsescrito",Ordered_List:"Lista Numerada",Unordered_List:"Lista Marcada",Indent:"Aumentar Indentaçã",Outdent:"Diminuir Indentaçã",Undo:"Desfazer",Redo:"Restaurar",Link:"Link",Unlink:"Tirar link",Image:"Imagem",Table:"Tabela",HTML:"HTML",Paragraph:"Parágrafo",Heading_1:"Título 1",Heading_2:"Título 2",Heading_3:"Título 3",Heading_4:"Título 4",Heading_5:"Título 5",Heading_6:"Título 6",Preformatted:"Pré-formatado",Blockquote:"Citação",Table_Header:"Cabeçalho Tabela",URL:"URL",Title:"Título",Alternative_Text:"Texto Alterativo",Caption:"Título Tabela",Summary:"Summary",Number_Of_Rows:"Número de Linhas",Number_Of_Cols:"Número de Colunas",Submit:"Enviar",Cancel:"Cancelar",Choose:"Escolha",Preview:"Prever",Paste_From_Word:"Colar do Word",Tools:"Ferramentas",Containers:"Containers",Classes:"Classes",Status:"Status",Source_Code:"Código Fonte"},WYMeditor.STRINGS.ru={Strong:"Жирный",Emphasis:"Наклонный",Superscript:"Надстрочный",Subscript:"Подстрочный",Ordered_List:"Нумерованый список",Unordered_List:"Ненумерованый список",Indent:"Увеличить отступ",Outdent:"Уменьшить отступ",Undo:"Отменить",Redo:"Повторить",Link:"Ссылка",Unlink:"Удалить ссылку",Image:"Изображение",Table:"Таблица",HTML:"Править HTML",Paragraph:"Параграф",Heading_1:"Заголовок 1",Heading_2:"Заголовок 2",Heading_3:"Заголовок 3",Heading_4:"Заголовок 4",Heading_5:"Заголовок 5",Heading_6:"Заголовок 6",Preformatted:"Preformatted",Blockquote:"Цитата",Table_Header:"Заголовок таблицы",URL:"URL",Title:"Заголовок",Alternative_Text:"Альтернативный текст",Caption:"Надпись",Summary:"Summary",Number_Of_Rows:"Кол-во строк",Number_Of_Cols:"Кол-во столбцов",Submit:"Отправить",Cancel:"Отмена",Choose:"Выбор",Preview:"Просмотр",Paste_From_Word:"Вставить из Word",Tools:"Инструменты",Containers:"Контейнеры",Classes:"Классы",Status:"Статус",Source_Code:"Исходный код"},WYMeditor.STRINGS.sk={Strong:"Tučné",Emphasis:"Kurzíva",Superscript:"Horný index",Subscript:"Dolný index",Ordered_List:"Číslovaný zoznam",Unordered_List:"Nečíslovaný zoznam",Indent:"Zväčšiť odsadenie",Outdent:"Zmenšiť odsadenie",Undo:"Vrátiť",Redo:"Opakovať",Link:"Vytvoriť odkaz",Unlink:"Zrušiť odkaz",Image:"Obrázok",Table:"Tabuľka",HTML:"HTML",Paragraph:"Odstavec",Heading_1:"Nadpis 1. úrovne",Heading_2:"Nadpis 2. úrovne",Heading_3:"Nadpis 3. úrovne",Heading_4:"Nadpis 4. úrovne",Heading_5:"Nadpis 5. úrovne",Heading_6:"Nadpis 6. úrovne",Preformatted:"Predformátovaný text",Blockquote:"Citácia",Table_Header:"Hlavička tabuľky",URL:"URL adresa",Title:"Titulok",Alternative_Text:"Alternatívny text",Caption:"Titulok tabuľky",Summary:"Zhrnutie obsahu",Number_Of_Rows:"Počet riadkov",Number_Of_Cols:"Počet stĺpcov",Submit:"Odoslať",Cancel:"Zrušiť",Choose:"Vybrať",Preview:"Náhľad",Paste_From_Word:"Vložiť z Wordu",Tools:"Nástroje",Containers:"Typy obsahu",Classes:"Triedy",Status:"Stav",Source_Code:"Zdrojový kód"},WYMeditor.STRINGS.sv={Strong:"Viktigt",Emphasis:"Betoning",Superscript:"Upphöjt",Subscript:"Nedsänkt",Ordered_List:"Nummerlista",Unordered_List:"Punktlista",Indent:"Indrag",Outdent:"Utdrag",Undo:"Ångra",Redo:"Gör om",Link:"Länk",Unlink:"Ta bort länk",Image:"Bild",Table:"Tabell",HTML:"HTML",Paragraph:"Paragraf",Heading_1:"Rubrik 1",Heading_2:"Rubrik 2",Heading_3:"Rubrik 3",Heading_4:"Rubrik 4",Heading_5:"Rubrik 5",Heading_6:"Rubrik 6",Preformatted:"Förformaterad",Blockquote:"Blockcitat",Table_Header:"Tabellrubrik",URL:"URL",Title:"Titel",Relationship:"Relation",Alternative_Text:"Alternativ text",Caption:"Överskrift",Summary:"Summary",Number_Of_Rows:"Antal rader",Number_Of_Cols:"Antal kolumner",Submit:"Skicka",Cancel:"Avbryt",Choose:"Välj",Preview:"Förhandsgranska",Paste_From_Word:"Klistra in från Word",Tools:"Verktyg",Containers:"Formatering",Classes:"Klasser",Status:"Status",Source_Code:"Källkod"},WYMeditor.STRINGS.tr={Strong:"Kalın",Emphasis:"Vurgu",Superscript:"Üstsimge",Subscript:"Altsimge",Ordered_List:"Sıralı List",Unordered_List:"Sırasız List",Indent:"Girintile",Outdent:"Çıkıntıla",Undo:"Geri Al",Redo:"Yinele",Link:"Bağlantı",Unlink:"Bağlantıyı Kaldır",Image:"Resim",Table:"Tablo",HTML:"HTML",Paragraph:"Parağraf",Heading_1:"Başlık 1",Heading_2:"Başlık 2",Heading_3:"Başlık 3",Heading_4:"Başlık 4",Heading_5:"Başlık 5",Heading_6:"Başlık 6",Preformatted:"Önceden Formatlı",Blockquote:"Alıntı",Table_Header:"Tablo Başlığı",URL:"URL",Title:"Başlık",Alternative_Text:"Alternatif Metin",Caption:"Etiket",Summary:"Özet",Number_Of_Rows:"Satır sayısı",Number_Of_Cols:"Sütun sayısı",Submit:"Gönder",Cancel:"İptal",Choose:"Seç",Preview:"Önizleme",Paste_From_Word:"Word'den yapıştır",Tools:"Araçlar",Containers:"Kapsayıcılar",Classes:"Sınıflar",Status:"Durum",Source_Code:"Kaynak Kodu"},WYMeditor.STRINGS.zh_cn={Strong:"加粗",Emphasis:"斜体",Superscript:"上标",Subscript:"下标",Ordered_List:"有序列表",Unordered_List:"无序列表",Indent:"增加缩进",Outdent:"减少缩进",Undo:"撤消",Redo:"重做",Link:"链接",Unlink:"取消链接",Image:"图片",Table:"表格",HTML:"HTML源代码",Paragraph:"段落",Heading_1:"标题 1",Heading_2:"标题 2",Heading_3:"标题 3",Heading_4:"标题 4",Heading_5:"标题 5",Heading_6:"标题 6",Preformatted:"原始文本",Blockquote:"引语",Table_Header:"表头",URL:"地址",Title:"提示文字",Alternative_Text:"失效文字",Caption:"标题",Summary:"Summary",Number_Of_Rows:"行数",Number_Of_Cols:"列数",Submit:"提交",Cancel:"放弃",Choose:"选择",Preview:"预览",Paste_From_Word:"从Word粘贴纯文本",Tools:"工具",Containers:"容器",Classes:"预定义样式",Status:"状态",Source_Code:"源代码",Attachment:"附件",NewParagraph:"新段落"},WYMeditor.STRINGS.zh_tw={Strong:"加粗",Emphasis:"斜體",Superscript:"上標",Subscript:"下標",Ordered_List:"有序列表",Unordered_List:"無序列表",Indent:"增加縮排",Outdent:"減少縮排",Undo:"取消",Redo:"重做",Link:"鏈結",Unlink:"取消鏈結",Image:"圖片",Table:"表格",HTML:"HTML 源代碼",Paragraph:"段落",Heading_1:"標題 1",Heading_2:"標題 2",Heading_3:"標題 3",Heading_4:"標題 4",Heading_5:"標題 5",Heading_6:"標題 6",Preformatted:"原始文本",Blockquote:"引語",Table_Header:"表格頂部",URL:"地址",Title:"提示文字",Alternative_Text:"失效文字",Caption:"主題",Summary:"大綱",Number_Of_Rows:"行數",Number_Of_Cols:"列數",Submit:"提交",Cancel:"放棄",Choose:"選擇",Preview:"預覽",Paste_From_Word:"從Word複制純文本",Tools:"工具",Containers:"容器",Classes:"預定義樣式",Status:"狀態",Source_Code:"源代碼",Attachment:"附件",NewParagraph:"新段落"},window.rangy=function(){function a(a,b){var c=typeof a[b];return c==l||!(c!=k||!a[b])||"unknown"==c}function b(a,b){return!(typeof a[b]!=k||!a[b])}function c(a,b){return typeof a[b]!=m}function d(a){return function(b,c){for(var d=c.length;d--;)if(!a(b,c[d]))return!1;return!0}}function e(a){return a&&r(a,q)&&t(a,p)}function f(a){window.alert("Rangy not supported in your browser. Reason: "+a),u.initialized=!0,u.supported=!1}function g(a){var b="Rangy warning: "+a;u.config.alertOnWarn?window.alert(b):typeof window.console!=m&&typeof window.console.log!=m&&window.console.log(b)}function h(){if(!u.initialized){var c,d=!1,g=!1;a(document,"createRange")&&(c=document.createRange(),r(c,o)&&t(c,n)&&(d=!0),c.detach());var h=b(document,"body")?document.body:document.getElementsByTagName("body")[0];h&&a(h,"createTextRange")&&(c=h.createTextRange(),e(c)&&(g=!0)),d||g||f("Neither Range nor TextRange are implemented"),u.initialized=!0,u.features={implementsDomRange:d,implementsTextRange:g};for(var i=w.concat(v),j=0,k=i.length;k>j;++j)try{i[j](u)}catch(l){b(window,"console")&&a(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",l)}}}function i(a){a=a||window,h();for(var b=0,c=x.length;c>b;++b)x[b](a)}function j(a){this.name=a,this.initialized=!1,this.supported=!1}var k="object",l="function",m="undefined",n=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],o=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],p=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],q=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"],r=d(a),s=d(b),t=d(c),u={version:"1.2.2",initialized:!1,supported:!0,util:{isHostMethod:a,isHostObject:b,isHostProperty:c,areHostMethods:r,areHostObjects:s,areHostProperties:t,isTextRange:e},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};u.fail=f,u.warn=g,{}.hasOwnProperty?u.util.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}:f("hasOwnProperty not supported");var v=[],w=[];u.init=h,u.addInitListener=function(a){u.initialized?a(u):v.push(a)};var x=[];u.addCreateMissingNativeApiListener=function(a){x.push(a)},u.createMissingNativeApi=i,j.prototype.fail=function(a){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+a)},j.prototype.warn=function(a){u.warn("Module "+this.name+": "+a)},j.prototype.createError=function(a){return new Error("Error in Rangy "+this.name+" module: "+a)},u.createModule=function(a,b){var c=new j(a);u.modules[a]=c,w.push(function(a){b(a,c),c.initialized=!0,c.supported=!0})},u.requireModules=function(a){for(var b,c,d=0,e=a.length;e>d;++d){if(c=a[d],b=u.modules[c],!(b&&b instanceof j))throw new Error("Module '"+c+"' not found");if(!b.supported)throw new Error("Module '"+c+"' not supported")}};var y=!1,z=function(a){y||(y=!0,u.initialized||h())};return typeof window==m?void f("No window found"):typeof document==m?void f("No document found"):(a(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",z,!1),a(window,"addEventListener")?window.addEventListener("load",z,!1):a(window,"attachEvent")?window.attachEvent("onload",z):f("Window does not have required addEventListener or attachEvent method"),u)}(),rangy.createModule("DomUtil",function(a,b){function c(a){var b;return typeof a.namespaceURI==z||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"==b}function d(a){var b=a.parentNode;return 1==b.nodeType?b:null}function e(a){for(var b=0;a=a.previousSibling;)b++;return b}function f(a){var b;return j(a)?a.length:(b=a.childNodes)?b.length:0}function g(a,b){var c,d=[];for(c=a;c;c=c.parentNode)d.push(c);for(c=b;c;c=c.parentNode)if(D(d,c))return c;return null}function h(a,b,c){for(var d=c?b:b.parentNode;d;){if(d===a)return!0;d=d.parentNode}return!1}function i(a,b,c){for(var d,e=c?a:a.parentNode;e;){if(d=e.parentNode,d===b)return e;e=d}return null}function j(a){var b=a.nodeType;return 3==b||4==b||8==b}function k(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a}function l(a,b){var c=a.cloneNode(!1);return c.deleteData(0,b),a.deleteData(b,a.length-b),k(c,a),c}function m(a){if(9==a.nodeType)return a;if(typeof a.ownerDocument!=z)return a.ownerDocument;if(typeof a.document!=z)return a.document;if(a.parentNode)return m(a.parentNode);throw new Error("getDocument: no document found for node")}function n(a){var b=m(a);if(typeof b.defaultView!=z)return b.defaultView;if(typeof b.parentWindow!=z)return b.parentWindow;throw new Error("Cannot get a window object for node")}function o(a){if(typeof a.contentDocument!=z)return a.contentDocument;if(typeof a.contentWindow!=z)return a.contentWindow.document;throw new Error("getIframeWindow: No Document object found for iframe element")}function p(a){if(typeof a.contentWindow!=z)return a.contentWindow;if(typeof a.contentDocument!=z)return a.contentDocument.defaultView;throw new Error("getIframeWindow: No Window object found for iframe element")}function q(a){return A.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]}function r(a){for(var b;b=a.parentNode;)a=b;return a}function s(a,b,c,d){var f,h,j,k,l;if(a==c)return b===d?0:d>b?-1:1;if(f=i(c,a,!0))return b<=e(f)?-1:1;if(f=i(a,c,!0))return e(f)["+a.childNodes.length+"]"}return a.nodeName}function v(a){this.root=a,this._next=a}function w(a){return new v(a)}function x(a,b){this.node=a,this.offset=b}function y(a){this.code=this[a],this.codeName=a,this.message="DOMException: "+this.codeName}var z="undefined",A=a.util;A.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method"),A.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method");var B=document.createElement("div");A.areHostMethods(B,["insertBefore","appendChild","cloneNode"]||!A.areHostObjects(B,["previousSibling","nextSibling","childNodes","parentNode"]))||b.fail("Incomplete Element implementation"),A.isHostProperty(B,"innerHTML")||b.fail("Element is missing innerHTML property");var C=document.createTextNode("test");A.areHostMethods(C,["splitText","deleteData","insertData","appendData","cloneNode"]||!A.areHostObjects(B,["previousSibling","nextSibling","childNodes","parentNode"])||!A.areHostProperties(C,["data"]))||b.fail("Incomplete Text Node implementation");var D=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1};v.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a,b,c=this._current=this._next;if(this._current)if(a=c.firstChild)this._next=a;else{for(b=null;c!==this.root&&!(b=c.nextSibling);)c=c.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}},x.prototype={equals:function(a){return this.node===a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+u(this.node)+":"+this.offset+")]"}},y.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11},y.prototype.toString=function(){return this.message},a.dom={arrayContains:D,isHtmlNamespace:c,parentElement:d,getNodeIndex:e,getNodeLength:f,getCommonAncestor:g,isAncestorOf:h,getClosestAncestorIn:i,isCharacterDataNode:j,insertAfter:k,splitDataNode:l,getDocument:m,getWindow:n,getIframeWindow:p,getIframeDocument:o,getBody:q,getRootContainer:r,comparePoints:s,inspectNode:u,fragmentFromNodeChildren:t,createIterator:w,DomPosition:x},a.DOMException=y}),rangy.createModule("DomRange",function(a,b){function c(a,b){return 3!=a.nodeType&&(L.isAncestorOf(a,b.startContainer,!0)||L.isAncestorOf(a,b.endContainer,!0))}function d(a){return L.getDocument(a.startContainer)}function e(a,b,c){var d=a._listeners[b];if(d)for(var e=0,f=d.length;f>e;++e)d[e].call(a,{target:a,args:c})}function f(a){return new M(a.parentNode,L.getNodeIndex(a))}function g(a){return new M(a.parentNode,L.getNodeIndex(a)+1)}function h(a,b,c){var d=11==a.nodeType?a.firstChild:a;return L.isCharacterDataNode(b)?c==b.length?L.insertAfter(a,b):b.parentNode.insertBefore(a,0==c?b:L.splitDataNode(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]),d}function i(a){for(var b,c,e,f=d(a.range).createDocumentFragment();c=a.next();){if(b=a.isPartiallySelectedSubtree(),c=c.cloneNode(!b),b&&(e=a.getSubtreeIterator(),c.appendChild(i(e)),e.detach(!0)),10==c.nodeType)throw new N("HIERARCHY_REQUEST_ERR");f.appendChild(c)}return f}function j(a,b,c){var d,e;c=c||{stop:!1};for(var f,g;f=a.next();)if(a.isPartiallySelectedSubtree()){if(b(f)===!1)return void(c.stop=!0);if(g=a.getSubtreeIterator(),j(g,b,c),g.detach(!0),c.stop)return}else for(d=L.createIterator(f);e=d.next();)if(b(e)===!1)return void(c.stop=!0)}function k(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),k(b),b.detach(!0)):a.remove()}function l(a){for(var b,c,e=d(a.range).createDocumentFragment();b=a.next();){if(a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),c=a.getSubtreeIterator(),b.appendChild(l(c)),c.detach(!0)):a.remove(),10==b.nodeType)throw new N("HIERARCHY_REQUEST_ERR");e.appendChild(b)}return e}function m(a,b,c){var d,e=!(!b||!b.length),f=!!c;e&&(d=new RegExp("^("+b.join("|")+")$"));var g=[];return j(new o(a,!1),function(a){e&&!d.test(a.nodeType)||f&&!c(a)||g.push(a)}),g}function n(a){var b="undefined"==typeof a.getName?"Range":a.getName();return"["+b+"("+L.inspectNode(a.startContainer)+":"+a.startOffset+", "+L.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function o(a,b){if(this.range=a,this.clonePartiallySelectedTextNodes=b,!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&L.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==c||L.isCharacterDataNode(this.sc)?L.getClosestAncestorIn(this.sc,c,!0):this.sc.childNodes[this.so], -this._last=this.ec!==c||L.isCharacterDataNode(this.ec)?L.getClosestAncestorIn(this.ec,c,!0):this.ec.childNodes[this.eo-1])}}function p(a){this.code=this[a],this.codeName=a,this.message="RangeException: "+this.codeName}function q(a,b,c){this.nodes=m(a,b,c),this._next=this.nodes[0],this._position=0}function r(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){if(d=e.nodeType,L.arrayContains(a,d))return e;e=e.parentNode}return null}}function s(a,b){if(W(a,b))throw new p("INVALID_NODE_TYPE_ERR")}function t(a){if(!a.startContainer)throw new N("INVALID_STATE_ERR")}function u(a,b){if(!L.arrayContains(b,a.nodeType))throw new p("INVALID_NODE_TYPE_ERR")}function v(a,b){if(0>b||b>(L.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new N("INDEX_SIZE_ERR")}function w(a,b){if(U(a,!0)!==U(b,!0))throw new N("WRONG_DOCUMENT_ERR")}function x(a){if(V(a,!0))throw new N("NO_MODIFICATION_ALLOWED_ERR")}function y(a,b){if(!a)throw new N(b)}function z(a){return!L.arrayContains(P,a.nodeType)&&!U(a,!0)}function A(a,b){return b<=(L.isCharacterDataNode(a)?a.length:a.childNodes.length)}function B(a){if(t(a),z(a.startContainer)||z(a.endContainer)||!A(a.startContainer,a.startOffset)||!A(a.endContainer,a.endOffset))throw new Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")")}function C(){}function D(a){a.START_TO_START=aa,a.START_TO_END=ba,a.END_TO_END=ca,a.END_TO_START=da,a.NODE_BEFORE=ea,a.NODE_AFTER=fa,a.NODE_BEFORE_AND_AFTER=ga,a.NODE_INSIDE=ha}function E(a){D(a),D(a.prototype)}function F(a,b){return function(){B(this);var c,d,e=this.startContainer,f=this.startOffset,h=this.commonAncestorContainer,i=new o(this,!0);e!==h&&(c=L.getClosestAncestorIn(e,h,!0),d=g(c),e=d.node,f=d.offset),j(i,x),i.reset();var k=a(i);return i.detach(),b(this,e,f,e,f),k}}function G(b,d,e){function h(a,b){return function(c){t(this),u(c,O),u(T(c),P);var d=(a?f:g)(c);(b?i:j)(this,d.node,d.offset)}}function i(a,b,c){var e=a.endContainer,f=a.endOffset;(b!==a.startContainer||c!==a.startOffset)&&((T(b)!=T(e)||1==L.comparePoints(b,c,e,f))&&(e=b,f=c),d(a,b,c,e,f))}function j(a,b,c){var e=a.startContainer,f=a.startOffset;(b!==a.endContainer||c!==a.endOffset)&&((T(b)!=T(e)||-1==L.comparePoints(b,c,e,f))&&(e=b,f=c),d(a,e,f,b,c))}function m(a,b,c){(b!==a.startContainer||c!==a.startOffset||b!==a.endContainer||c!==a.endOffset)&&d(a,b,c,b,c)}b.prototype=new C,a.util.extend(b.prototype,{setStart:function(a,b){t(this),s(a,!0),v(a,b),i(this,a,b)},setEnd:function(a,b){t(this),s(a,!0),v(a,b),j(this,a,b)},setStartBefore:h(!0,!0),setStartAfter:h(!1,!0),setEndBefore:h(!0,!1),setEndAfter:h(!1,!1),collapse:function(a){B(this),a?d(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){t(this),s(a,!0),d(this,a,0,a,L.getNodeLength(a))},selectNode:function(a){t(this),s(a,!1),u(a,O);var b=f(a),c=g(a);d(this,b.node,b.offset,c.node,c.offset)},extractContents:F(l,d),deleteContents:F(k,d),canSurroundContents:function(){B(this),x(this.startContainer),x(this.endContainer);var a=new o(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);return a.detach(),!b},detach:function(){e(this)},splitBoundaries:function(){B(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,f=a===c;L.isCharacterDataNode(c)&&e>0&&e0&&b=L.getNodeIndex(a)&&e++,b=0),d(this,a,b,c,e)},normalizeBoundaries:function(){B(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,f=function(a){var b=a.nextSibling;b&&b.nodeType==a.nodeType&&(c=a,e=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},g=function(d){var f=d.previousSibling;if(f&&f.nodeType==d.nodeType){a=d;var g=d.length;if(b=f.length,d.insertData(0,f.data),f.parentNode.removeChild(f),a==c)e+=b,c=a;else if(c==d.parentNode){var h=L.getNodeIndex(d);e==h?(c=d,e=g):e>h&&e--}}},h=!0;if(L.isCharacterDataNode(c))c.length==e&&f(c);else{if(e>0){var i=c.childNodes[e-1];i&&L.isCharacterDataNode(i)&&f(i)}h=!this.collapsed}if(h){if(L.isCharacterDataNode(a))0==b&&g(a);else if(bx",Y=3==X.firstChild.nodeType}catch(Z){}a.features.htmlParsingConforms=Y;var $=Y?function(a){var b=this.startContainer,c=L.getDocument(b);if(!b)throw new N("INVALID_STATE_ERR");var d=null;return 1==b.nodeType?d=b:L.isCharacterDataNode(b)&&(d=L.parentElement(b)),d=null===d||"HTML"==d.nodeName&&L.isHtmlNamespace(L.getDocument(d).documentElement)&&L.isHtmlNamespace(d)?c.createElement("body"):d.cloneNode(!1),d.innerHTML=a,L.fragmentFromNodeChildren(d)}:function(a){t(this);var b=d(this),c=b.createElement("body");return c.innerHTML=a,L.fragmentFromNodeChildren(c)},_=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],aa=0,ba=1,ca=2,da=3,ea=0,fa=1,ga=2,ha=3;C.prototype={attachListener:function(a,b){this._listeners[a].push(b)},compareBoundaryPoints:function(a,b){B(this),w(this.startContainer,b.startContainer);var c,d,e,f,g=a==da||a==aa?"start":"end",h=a==ba||a==aa?"start":"end";return c=this[g+"Container"],d=this[g+"Offset"],e=b[h+"Container"],f=b[h+"Offset"],L.comparePoints(c,d,e,f)},insertNode:function(a){if(B(this),u(a,R),x(this.startContainer),L.isAncestorOf(a,this.startContainer,!0))throw new N("HIERARCHY_REQUEST_ERR");var b=h(a,this.startContainer,this.startOffset);this.setStartBefore(b)},cloneContents:function(){B(this);var a,b;if(this.collapsed)return d(this).createDocumentFragment();if(this.startContainer===this.endContainer&&L.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=d(this).createDocumentFragment(),b.appendChild(a),b;var c=new o(this,!0);return a=i(c),c.detach(),a},canSurroundContents:function(){B(this),x(this.startContainer),x(this.endContainer);var a=new o(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);return a.detach(),!b},surroundContents:function(a){if(u(a,S),!this.canSurroundContents())throw new p("BAD_BOUNDARYPOINTS_ERR");var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);h(a,this.startContainer,this.startOffset),a.appendChild(b),this.selectNode(a)},cloneRange:function(){B(this);for(var a,b=new K(d(this)),c=_.length;c--;)a=_[c],b[a]=this[a];return b},toString:function(){B(this);var a=this.startContainer;if(a===this.endContainer&&L.isCharacterDataNode(a))return 3==a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"";var b=[],c=new o(this,!0);return j(c,function(a){(3==a.nodeType||4==a.nodeType)&&b.push(a.data)}),c.detach(),b.join("")},compareNode:function(a){B(this);var b=a.parentNode,c=L.getNodeIndex(a);if(!b)throw new N("NOT_FOUND_ERR");var d=this.comparePoint(b,c),e=this.comparePoint(b,c+1);return 0>d?e>0?ga:ea:e>0?fa:ha},comparePoint:function(a,b){return B(this),y(a,"HIERARCHY_REQUEST_ERR"),w(a,this.startContainer),L.comparePoints(a,b,this.startContainer,this.startOffset)<0?-1:L.comparePoints(a,b,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:$,toHtml:function(){B(this);var a=d(this).createElement("div");return a.appendChild(this.cloneContents()),a.innerHTML},intersectsNode:function(a,b){if(B(this),y(a,"NOT_FOUND_ERR"),L.getDocument(a)!==d(this))return!1;var c=a.parentNode,e=L.getNodeIndex(a);y(c,"NOT_FOUND_ERR");var f=L.comparePoints(c,e,this.endContainer,this.endOffset),g=L.comparePoints(c,e+1,this.startContainer,this.startOffset);return b?0>=f&&g>=0:0>f&&g>0},isPointInRange:function(a,b){return B(this),y(a,"HIERARCHY_REQUEST_ERR"),w(a,this.startContainer),L.comparePoints(a,b,this.startContainer,this.startOffset)>=0&&L.comparePoints(a,b,this.endContainer,this.endOffset)<=0},intersectsRange:function(a,b){if(B(this),d(a)!=d(this))throw new N("WRONG_DOCUMENT_ERR");var c=L.comparePoints(this.startContainer,this.startOffset,a.endContainer,a.endOffset),e=L.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset);return b?0>=c&&e>=0:0>c&&e>0},intersection:function(a){if(this.intersectsRange(a)){var b=L.comparePoints(this.startContainer,this.startOffset,a.startContainer,a.startOffset),c=L.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),d=this.cloneRange();return-1==b&&d.setStart(a.startContainer,a.startOffset),1==c&&d.setEnd(a.endContainer,a.endOffset),d}return null},union:function(a){if(this.intersectsRange(a,!0)){var b=this.cloneRange();return-1==L.comparePoints(a.startContainer,a.startOffset,this.startContainer,this.startOffset)&&b.setStart(a.startContainer,a.startOffset),1==L.comparePoints(a.endContainer,a.endOffset,this.endContainer,this.endOffset)&&b.setEnd(a.endContainer,a.endOffset),b}throw new p("Ranges do not intersect")},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==ha},containsNodeContents:function(a){return this.comparePoint(a,0)>=0&&this.comparePoint(a,L.getNodeLength(a))<=0},containsRange:function(a){return this.intersection(a).equals(a)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);if(c.length>0){b.setStart(c[0],0);var d=c.pop();b.setEnd(d,d.length);var e=this.containsRange(b);return b.detach(),e}return this.containsNodeContents(a)},createNodeIterator:function(a,b){return B(this),new q(this,a,b)},getNodes:function(a,b){return B(this),m(this,a,b)},getDocument:function(){return d(this)},collapseBefore:function(a){t(this),this.setEndBefore(a),this.collapse(!1)},collapseAfter:function(a){t(this),this.setStartAfter(a),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(a){return K.rangesEqual(this,a)},inspect:function(){return n(this)}},G(K,I,J),a.rangePrototype=C.prototype,K.rangeProperties=_,K.RangeIterator=o,K.copyComparisonConstants=E,K.createPrototypeRange=G,K.inspect=n,K.getRangeDocument=d,K.rangesEqual=function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset},a.DomRange=K,a.RangeException=p}),rangy.createModule("WrappedRange",function(a,b){function c(a){var b=a.parentElement(),c=a.duplicate();c.collapse(!0);var d=c.parentElement();c=a.duplicate(),c.collapse(!1);var e=c.parentElement(),f=d==e?d:h.getCommonAncestor(d,e);return f==b?f:h.getCommonAncestor(b,f)}function d(a){return 0==a.compareEndPoints("StartToEnd",a)}function e(a,b,c,d){var e=a.duplicate();e.collapse(c);var f=e.parentElement();if(h.isAncestorOf(b,f,!0)||(f=b),!f.canHaveHTML)return new i(f.parentNode,h.getNodeIndex(f));var g,j,k,l,m,n=h.getDocument(f).createElement("span"),o=c?"StartToStart":"StartToEnd";do f.insertBefore(n,n.previousSibling),e.moveToElementText(n);while((g=e.compareEndPoints(o,a))>0&&n.previousSibling);if(m=n.nextSibling,-1==g&&m&&h.isCharacterDataNode(m)){e.setEndPoint(c?"EndToStart":"EndToEnd",a);var p;if(/[\r\n]/.test(m.data)){var q=e.duplicate(),r=q.text.replace(/\r\n/g,"\r").length;for(p=q.moveStart("character",r);-1==(g=q.compareEndPoints("StartToEnd",q));)p++,q.moveStart("character",1)}else p=e.text.length;l=new i(m,p)}else j=(d||!c)&&n.previousSibling,k=(d||c)&&n.nextSibling,l=k&&h.isCharacterDataNode(k)?new i(k,0):j&&h.isCharacterDataNode(j)?new i(j,j.length):new i(f,h.getNodeIndex(n));return n.parentNode.removeChild(n),l}function f(a,b){var c,d,e,f,g=a.offset,i=h.getDocument(a.node),j=i.body.createTextRange(),k=h.isCharacterDataNode(a.node);return k?(c=a.node,d=c.parentNode):(f=a.node.childNodes,c=gb;++b)if(!w.isAncestorOf(a[0],a[b]))return!1;return!0}function j(a){var b=a.getNodes();if(!i(b))throw new Error("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element");return b[0]}function k(a){return!!a&&"undefined"!=typeof a.text}function l(a,b){var c=new z(b);a._ranges=[c],e(a,c,!1),a.rangeCount=1,a.isCollapsed=c.collapsed}function m(b){if(b._ranges.length=0,"None"==b.docSelection.type)g(b);else{var c=b.docSelection.createRange();if(k(c))l(b,c);else{b.rangeCount=c.length;for(var d,f=w.getDocument(c.item(0)),h=0;hg;++g)f.add(c.item(g));try{f.add(d)}catch(i){throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}f.select(),m(a)}function o(a,b,c){this.nativeSelection=a,this.docSelection=b,this._ranges=[],this.win=c,this.refresh()}function p(a,b){for(var c,d=w.getDocument(b[0].startContainer),e=w.getBody(d).createControlRange(),f=0;ff;++f)b[f]=y.inspect(a.getRangeAt(f));return"["+e+"(Ranges: "+b.join(", ")+")(anchor: "+c.inspect()+", focus: "+d.inspect()+"]"}a.requireModules(["DomUtil","DomRange","WrappedRange"]),a.config.checkSelectionRanges=!0;var s,t,u="boolean",v="_rangySelection",w=a.dom,x=a.util,y=a.DomRange,z=a.WrappedRange,A=a.DOMException,B=w.DomPosition,C="Control",D=a.util.isHostMethod(window,"getSelection"),E=a.util.isHostObject(document,"selection"),F=E&&(!D||a.config.preferTextRange);F?(s=d,a.isSelectionValid=function(a){var b=(a||window).document,c=b.selection;return"None"!=c.type||w.getDocument(c.createRange().parentElement())==b}):D?(s=c,a.isSelectionValid=function(){return!0}):b.fail("Neither document.selection or window.getSelection() detected."),a.getNativeSelection=s;var G=s(),H=a.createNativeRange(document),I=w.getBody(document),J=x.areHostObjects(G,["anchorNode","focusNode"]&&x.areHostProperties(G,["anchorOffset","focusOffset"]));a.features.selectionHasAnchorAndFocus=J;var K=x.isHostMethod(G,"extend");a.features.selectionHasExtend=K;var L="number"==typeof G.rangeCount;a.features.selectionHasRangeCount=L;var M=!1,N=!0;x.areHostMethods(G,["addRange","getRangeAt","removeAllRanges"])&&"number"==typeof G.rangeCount&&a.features.implementsDomRange&&!function(){var a=document.createElement("iframe");I.appendChild(a);var b=w.getIframeDocument(a);b.open(),b.write("12"),b.close();var c=w.getIframeWindow(a).getSelection(),d=b.documentElement,e=d.lastChild,f=e.firstChild,g=b.createRange();g.setStart(f,1),g.collapse(!0),c.addRange(g),N=1==c.rangeCount,c.removeAllRanges();var h=g.cloneRange();g.setStart(f,0),h.setEnd(f,2),c.addRange(g),c.addRange(h),M=2==c.rangeCount,g.detach(),h.detach(),I.removeChild(a)}(),a.features.selectionSupportsMultipleRanges=M,a.features.collapsedNonEditableSelectionsSupported=N;var O,P=!1;I&&x.isHostMethod(I,"createControlRange")&&(O=I.createControlRange(),x.areHostProperties(O,["item","add"])&&(P=!0)),a.features.implementsControlRange=P,t=J?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var Q;x.isHostMethod(G,"getRangeAt")?Q=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:J&&(Q=function(b){var c=w.getDocument(b.anchorNode),d=a.createRange(c);return d.setStart(b.anchorNode,b.anchorOffset),d.setEnd(b.focusNode,b.focusOffset),d.collapsed!==this.isCollapsed&&(d.setStart(b.focusNode,b.focusOffset),d.setEnd(b.anchorNode,b.anchorOffset)),d}),a.getSelection=function(a){a=a||window;var b=a[v],c=s(a),e=E?d(a):null;return b?(b.nativeSelection=c,b.docSelection=e,b.refresh(a)):(b=new o(c,e,a),a[v]=b),b},a.getIframeSelection=function(b){return a.getSelection(w.getIframeWindow(b))};var R=o.prototype;if(!F&&J&&x.areHostMethods(G,["removeAllRanges","addRange"])){R.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),g(this)};var S=function(b,c){var d=y.getRangeDocument(c),e=a.createRange(d);e.collapseToPoint(c.endContainer,c.endOffset),b.nativeSelection.addRange(h(e)),b.nativeSelection.extend(c.startContainer,c.startOffset),b.refresh()};L?R.addRange=function(b,c){if(P&&E&&this.docSelection.type==C)n(this,b);else if(c&&K)S(this,b);else{var d;if(M?d=this.rangeCount:(this.removeAllRanges(),d=0),this.nativeSelection.addRange(h(b)),this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==d+1){if(a.config.checkSelectionRanges){var f=Q(this.nativeSelection,this.rangeCount-1);f&&!y.rangesEqual(f,b)&&(b=new z(f))}this._ranges[this.rangeCount-1]=b,e(this,b,V(this.nativeSelection)),this.isCollapsed=t(this)}else this.refresh()}}:R.addRange=function(a,b){b&&K?S(this,a):(this.nativeSelection.addRange(h(a)),this.refresh())},R.setRanges=function(a){if(P&&a.length>1)p(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;c>b;++b)this.addRange(a[b])}}}else{if(!(x.isHostMethod(G,"empty")&&x.isHostMethod(H,"select")&&P&&F))return b.fail("No means of selecting a Range or TextRange was found"),!1;R.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var a;if(this.anchorNode)a=w.getDocument(this.anchorNode);else if(this.docSelection.type==C){var b=this.docSelection.createRange();b.length&&(a=w.getDocument(b.item(0)).body.createTextRange())}if(a){var c=a.body.createTextRange();c.select(),this.docSelection.empty()}}}catch(d){}g(this)},R.addRange=function(a){this.docSelection.type==C?n(this,a):(z.rangeToTextRange(a).select(),this._ranges[0]=a,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,e(this,a,!1))},R.setRanges=function(a){this.removeAllRanges();var b=a.length;b>1?p(this,a):b&&this.addRange(a[0])}}R.getRangeAt=function(a){if(0>a||a>=this.rangeCount)throw new A("INDEX_SIZE_ERR");return this._ranges[a]};var T;if(F)T=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=w.getBody(b.win.document).createTextRange(),c.collapse(!0)),b.docSelection.type==C?m(b):k(c)?l(b,c):g(b)};else if(x.isHostMethod(G,"getRangeAt")&&"number"==typeof G.rangeCount)T=function(b){if(P&&E&&b.docSelection.type==C)m(b);else if(b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount,b.rangeCount){for(var c=0,d=b.rangeCount;d>c;++c)b._ranges[c]=new a.WrappedRange(b.nativeSelection.getRangeAt(c));e(b,b._ranges[b.rangeCount-1],V(b.nativeSelection)),b.isCollapsed=t(b)}else g(b)};else{if(!J||typeof G.isCollapsed!=u||typeof H.collapsed!=u||!a.features.implementsDomRange)return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;T=function(a){var b,c=a.nativeSelection;c.anchorNode?(b=Q(c,0),a._ranges=[b],a.rangeCount=1,f(a),a.isCollapsed=t(a)):g(a)}}R.refresh=function(a){var b=a?this._ranges.slice(0):null;if(T(this),a){var c=b.length;if(c!=this._ranges.length)return!1;for(;c--;)if(!y.rangesEqual(b[c],this._ranges[c]))return!1;return!0}};var U=function(a,b){var c=a.getAllRanges(),d=!1;a.removeAllRanges();for(var e=0,f=c.length;f>e;++e)d||b!==c[e]?a.addRange(c[e]):d=!0;a.rangeCount||g(a)};P?R.removeRange=function(a){if(this.docSelection.type==C){for(var b,c=this.docSelection.createRange(),d=j(a),e=w.getDocument(c.item(0)),f=w.getBody(e).createControlRange(),g=!1,h=0,i=c.length;i>h;++h)b=c.item(h),b!==d||g?f.add(c.item(h)):g=!0;f.select(),m(this)}else U(this,a)}:R.removeRange=function(a){U(this,a)};var V;!F&&J&&a.features.implementsDomRange?(V=function(a){var b=!1;return a.anchorNode&&(b=1==w.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset)),b},R.isBackwards=function(){return V(this)}):V=R.isBackwards=function(){return!1},R.toString=function(){for(var a=[],b=0,c=this.rangeCount;c>b;++b)a[b]=""+this._ranges[b];return a.join("")},R.collapse=function(b,c){q(this,b);var d=a.createRange(w.getDocument(b));d.collapseToPoint(b,c),this.removeAllRanges(),this.addRange(d),this.isCollapsed=!0},R.collapseToStart=function(){if(!this.rangeCount)throw new A("INVALID_STATE_ERR");var a=this._ranges[0];this.collapse(a.startContainer,a.startOffset)},R.collapseToEnd=function(){if(!this.rangeCount)throw new A("INVALID_STATE_ERR");var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)},R.selectAllChildren=function(b){q(this,b);var c=a.createRange(w.getDocument(b));c.selectNodeContents(b),this.removeAllRanges(),this.addRange(c)},R.deleteFromDocument=function(){if(P&&E&&this.docSelection.type==C){for(var a,b=this.docSelection.createRange();b.length;)a=b.item(0),b.remove(a),a.parentNode.removeChild(a);this.refresh()}else if(this.rangeCount){var c=this.getAllRanges();this.removeAllRanges();for(var d=0,e=c.length;e>d;++d)c[d].deleteContents();this.addRange(c[e-1])}},R.getAllRanges=function(){return this._ranges.slice(0)},R.setSingleRange=function(a){this.setRanges([a])},R.containsNode=function(a,b){for(var c=0,d=this._ranges.length;d>c;++c)if(this._ranges[c].containsNode(a,b))return!0;return!1},R.toHtml=function(){var a="";if(this.rangeCount){for(var b=y.getRangeDocument(this._ranges[0]).createElement("div"),c=0,d=this._ranges.length;d>c;++c)b.appendChild(this._ranges[c].cloneContents());a=b.innerHTML}return a},R.getName=function(){return"WrappedSelection"},R.inspect=function(){return r(this)},R.detach=function(){this.win[v]=null,this.win=this.anchorNode=this.focusNode=null},o.inspect=r,a.Selection=o,a.selectionPrototype=R,a.addCreateMissingNativeApiListener(function(b){"undefined"==typeof b.getSelection&&(b.getSelection=function(){return a.getSelection(this)}),b=null})}),rangy.createModule("SaveRestore",function(a,b){function c(a,b){return(b||document).getElementById(a)}function d(a,b){var c,d="selectionBoundary_"+ +new Date+"_"+(""+Math.random()).slice(2),e=k.getDocument(a.startContainer),f=a.cloneRange();return f.collapse(b),c=e.createElement("span"),c.id=d,c.style.lineHeight="0",c.style.display="none",c.className="rangySelectionBoundary",c.appendChild(e.createTextNode(l)),f.insertNode(c),f.detach(),c}function e(a,d,e,f){var g=c(e,a);g?(d[f?"setStartBefore":"setEndBefore"](g),g.parentNode.removeChild(g)):b.warn("Marker element has been removed. Cannot restore selection.")}function f(a,b){return b.compareBoundaryPoints(a.START_TO_START,a)}function g(e){e=e||window;var g=e.document;if(!a.isSelectionValid(e))return void b.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus.");var h,i,j,k=a.getSelection(e),l=k.getAllRanges(),m=[];l.sort(f);for(var n=0,o=l.length;o>n;++n)j=l[n],j.collapsed?(i=d(j,!1),m.push({markerId:i.id,collapsed:!0})):(i=d(j,!1),h=d(j,!0),m[n]={startMarkerId:h.id,endMarkerId:i.id,collapsed:!1,backwards:1==l.length&&k.isBackwards()});for(n=o-1;n>=0;--n)j=l[n],j.collapsed?j.collapseBefore(c(m[n].markerId,g)):(j.setEndBefore(c(m[n].endMarkerId,g)),j.setStartAfter(c(m[n].startMarkerId,g))); -return k.setRanges(l),{win:e,doc:g,rangeInfos:m,restored:!1}}function h(d,f){if(!d.restored){for(var g,h,i=d.rangeInfos,j=a.getSelection(d.win),k=[],l=i.length,m=l-1;m>=0;--m){if(g=i[m],h=a.createRange(d.doc),g.collapsed){var n=c(g.markerId,d.doc);if(n){n.style.display="inline";var o=n.previousSibling;o&&3==o.nodeType?(n.parentNode.removeChild(n),h.collapseToPoint(o,o.length)):(h.collapseBefore(n),n.parentNode.removeChild(n))}else b.warn("Marker element has been removed. Cannot restore selection.")}else e(d.doc,h,g.startMarkerId,!0),e(d.doc,h,g.endMarkerId,!1);1==l&&h.normalizeBoundaries(),k[m]=h}1==l&&f&&a.features.selectionHasExtend&&i[0].backwards?(j.removeAllRanges(),j.addRange(k[0],!0)):j.setRanges(k),d.restored=!0}}function i(a,b){var d=c(b,a);d&&d.parentNode.removeChild(d)}function j(a){for(var b,c=a.rangeInfos,d=0,e=c.length;e>d;++d)b=c[d],b.collapsed?i(a.doc,b.markerId):(i(a.doc,b.startMarkerId),i(a.doc,b.endMarkerId))}a.requireModules(["DomUtil","DomRange","WrappedRange"]);var k=a.dom,l="\ufeff";a.saveSelection=g,a.restoreSelection=h,a.removeMarkerElement=i,a.removeMarkers=j}),WYMeditor.SKINS.compact={init:function(a){jQuery(a._options.containersSelector+", "+a._options.classesSelector,a._box).appendTo(jQuery("div.wym_area_top",a._box)).addClass("wym_dropdown").css({"margin-right":"10px",width:"120px","float":"left"}),jQuery(a._options.toolsSelector,a._box).addClass("wym_buttons").css({"margin-right":"10px","float":"left"}),jQuery(".wym_section",a._box).hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")});var b=a._options.postInit;a._options.postInit=function(a){b&&b.call(a,a),a.$body().css("background-color","#f0f0f0")}}},WYMeditor.SKINS["default"]={init:function(a){jQuery(a._box).find(a._options.classesSelector).addClass("wym_panel"),jQuery(a._box).find(a._options.toolsSelector).addClass("wym_buttons"),jQuery(a._box).find(a._options.containersSelector).addClass("wym_dropdown").find(WYMeditor.H2).append(" >"),jQuery(a._box).find("div.wym_area_right ul").parents("div.wym_area_right").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-right":"155px"}),jQuery(a._box).find("div.wym_area_left ul").parents("div.wym_area_left").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-left":"155px"}),jQuery(a._box).find(".wym_section").hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")})}},WYMeditor.SKINS.legacy={init:function(a){jQuery(a._box).find(a._options.classesSelector).addClass("wym_panel"),jQuery(a._box).find(a._options.toolsSelector).addClass("wym_buttons"),jQuery(a._box).find(a._options.containersSelector).addClass("wym_dropdown").find(WYMeditor.H2).append(" >"),jQuery(a._box).find("div.wym_area_right ul").parents("div.wym_area_right").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-right":"155px"}),jQuery(a._box).find("div.wym_area_left ul").parents("div.wym_area_left").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-left":"155px"}),jQuery(a._box).find(".wym_section").hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")})}},jQuery.fn.selectify=function(){var a=this;return a.each(function(){var a=this;jQuery(a).hover(function(){var a=this;jQuery("h2",a).css("background-position","0px -18px"),jQuery("ul",a).fadeIn("fast")},function(){var a=this;jQuery("h2",a).css("background-position",""),jQuery("ul",a).fadeOut("fast")})})},WYMeditor.SKINS.minimal={init:function(a){jQuery(a._box).find(a._options.toolsSelector+", "+a._options.containersSelector+", "+a._options.classesSelector).addClass("wym_dropdown").selectify()}},function(a){var b=function(b,c){this.options=a.extend({},a.fn.wymAffix.defaults,c),this.$window=a(window),this.$window.bind("scroll.affix.data-api",a.proxy(this.checkPosition,this)),this.$window.bind("click.affix.data-api",a.proxy(function(){setTimeout(a.proxy(this.checkPosition,this),1)},this)),this.$element=a(b),this.checkPosition()};b.prototype.checkPosition=function(){var a,b=this.$window.scrollTop(),c=this.options.offset,d=c.bottom,e=c.top,f="affix affix-top affix-bottom",g=!0,h=!0;"object"!=typeof c&&(d=e=c),"function"==typeof e&&(e=c.top()),"function"==typeof d&&(d=c.bottom()),null!==e&&(g=b>e),null!==d&&(h=b+this.$element.height()','","
            "].join(""),initIframeCheckFrequency:50,imagesLoadedCheckFrequency:300,imagesLoadedCheckTimeout:5e3},init:function(a){var b=WYMeditor.SKINS.seamless;Date.now||(Date.now=function(){return(new Date).getTime()}),a.seamlessSkinOpts=jQuery.extend(b.OPTS,{initialIframeResizeTimer:null,resizeAfterImagesLoadTimer:null,_imagesLoadedCheckStartedTime:0,minimumHeight:jQuery(a.element).height()}),b.initUIChrome(a),jQuery(a.element).bind(WYMeditor.EVENTS.postIframeInitialization,b.postIframeInit)},postIframeInit:function(a,b){var c=WYMeditor.SKINS.seamless;c.resizeIframeOnceBodyExists(b),jQuery(b.element).bind(WYMeditor.EVENTS.postBlockMaybeCreated,function(){c.resizeAndScrollIfNeeded(b)})},initUIChrome:function(a){var b,c,d=WYMeditor.SKINS.seamless,e=jQuery([a._options.containersSelector,a._options.classesSelector].join(", "),a._box);c=jQuery("div.wym_area_top",a._box),e.appendTo(c),e.addClass("wym_dropdown"),jQuery(".wym_dropdown",a._box).click(function(){var a=this;jQuery(a).toggleClass("hover")}),b=jQuery(a._options.toolsSelector,a._box),b.addClass("wym_buttons"),d.affixTopControls(a)},affixTopControls:function(a){var b,c,d,e,f=5;b=jQuery("div.wym_area_top",a._box),c=jQuery('
            '),b.wrap(c),c=b.parent(),c.wrap('
            '),e=c.parent(),e.height(b.height()),d=function(){c.width(e.width())},d(),jQuery(window).resize(d),c.wymAffix({offset:{top:function(){return e.offset().top-f},bottom:function(){return e.offset().top+a.seamlessSkinIframeHeight}}})},resizeIframeOnceBodyExists:function(a){var b,c=WYMeditor.SKINS.seamless;return a.seamlessSkinOpts.initialIframeResizeTimer&&(window.clearTimeout(a.seamlessSkinOpts.initialIframeResizeTimer),a.seamlessSkinOpts.initialIframeResizeTimer=null),"undefined"==typeof a._doc.body||null===a._doc.body?void(a.seamlessSkinOpts.initialIframeResizeTimer=window.setTimeout(function(){c.resizeIframeOnceBodyExists(a)},a.seamlessSkinOpts.initIframeCheckFrequency)):(b=a._doc.body.scrollHeight,c.resizeIframe(a),void c.resizeIframeOnceImagesLoaded(a))},resizeIframeOnceImagesLoaded:function(a){var b,c,d,e=WYMeditor.SKINS.seamless,f=0,g=!0,h=a.seamlessSkinOpts;if(("undefined"==typeof h._imagesLoadedCheckStartedTime||0===h._imagesLoadedCheckStartedTime)&&(h._imagesLoadedCheckStartedTime=Date.now()),null!==h.resizeAfterImagesLoadTimer&&(window.clearTimeout(h.resizeAfterImagesLoadTimer),h.resizeAfterImagesLoadTimer=null),b=a.$body().find("img"),c=b.length,0!==c){for(f=0;c>f;f+=1)if(!e._imageIsLoaded(b[f])){g=!1;break}return e.resizeAndScrollIfNeeded(a),g===!0?void(h._imagesLoadedCheckStartedTime=0):(d=Date.now()-h._imagesLoadedCheckStartedTime,d>h.imagesLoadedCheckTimeout?void(h._imagesLoadedCheckStartedTime=0):void(h.resizeAfterImagesLoadTimer=window.setTimeout(function(){e.resizeIframeOnceImagesLoaded(a)},h.imagesLoadedCheckFrequency)))}},_imageIsLoaded:function(a){return a.complete!==!0?!1:"undefined"!=typeof a.naturalWidth&&0===a.naturalWidth?!1:!0},_getIframeHeightStrategy:function(a){var b,c,d,e,f;if(c=jQuery(a._doc).children().eq(0),b=a._doc.body.scrollHeight,d=c.height(),e=c[0].scrollHeight,WYMeditor.isInternetExplorerPre11())return f=function(a){var b=jQuery(a._doc).children().eq(0),c=b[0].scrollHeight;return c-10};if(d>=b)return f=function(a){var b=jQuery(a._doc).children().eq(0),c=b.height();return c};if(b>e)return f=function(a){return a._doc.body.scrollHeight};throw new Error("unsupported browser")},resizeIframe:function(a){var b,c=WYMeditor.SKINS.seamless,d=jQuery(a._iframe),e=d.height();return"undefined"==typeof WYMeditor.IFRAME_HEIGHT_GETTER&&(WYMeditor.IFRAME_HEIGHT_GETTER=c._getIframeHeightStrategy(a)),b=WYMeditor.IFRAME_HEIGHT_GETTER(a),b0&&(d=l.scrollTop()+e+j,l.scrollTop(d)))},resizeAndScrollIfNeeded:function(a){var b=WYMeditor.SKINS.seamless,c=b.resizeIframe(a);c===!0&&b.scrollIfNeeded(a)}},jQuery.fn.selectify=function(){var a=this;return a.each(function(){var a=this;jQuery(a).hover(function(){var a=this;jQuery("h2",a).css("background-position","0px -18px"),jQuery("ul",a).fadeIn("fast")},function(){var a=this;jQuery("h2",a).css("background-position",""),jQuery("ul",a).fadeOut("fast")})})},WYMeditor.SKINS.silver={init:function(a){jQuery(a._box).append('
            ').wrapInner('
            '),jQuery(a._box).find(a._options.classesSelector).addClass("wym_panel"),jQuery(a._box).find(a._options.toolsSelector).addClass("wym_buttons"),jQuery(a._box).find(a._options.containersSelector).addClass("wym_dropdown").selectify(),jQuery(a._box).find("div.wym_area_right ul").parents("div.wym_area_right").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-right":"155px"}),jQuery(a._box).find("div.wym_area_left ul").parents("div.wym_area_left").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-left":"155px"}),jQuery(a._box).find(".wym_section").hover(function(){var a=this;jQuery(a).addClass("hover")},function(){var a=this;jQuery(a).removeClass("hover")})}},WYMeditor.SKINS.twopanels={init:function(a){jQuery(a._box).find(a._options.containersSelector).appendTo("div.wym_area_left"),jQuery(a._box).find(a._options.classesSelector+", "+a._options.containersSelector).addClass("wym_panel"),jQuery(a._box).find(a._options.toolsSelector).addClass("wym_buttons"),jQuery(a._box).find("div.wym_area_right ul").parents("div.wym_area_right").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-right":"155px"}),jQuery(a._box).find("div.wym_area_left ul").parents("div.wym_area_left").show().parents(a._options.boxSelector).find("div.wym_area_main").css({"margin-left":"115px"}),jQuery(a._box).find(".wym_section").hover(function(){jQuery(this).addClass("hover")},function(){jQuery(this).removeClass("hover")})}}; \ No newline at end of file diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/embed/jquery.wymeditor.embed.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/embed/jquery.wymeditor.embed.js deleted file mode 100644 index 79daa16de5..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/embed/jquery.wymeditor.embed.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * jquery.wymeditor.embed.js - * Experimental embed plugin - * - * File Authors: - * Jonatan Lundin (jonatan.lundin a-t gmail dotcom) - * Roger Hu (roger.hu a-t gmail dotcom) - * Scott Nixon (citadelgrad a-t gmail dotcom) - */ - -(function () { - function removeItem(item, arr) { - for (var i = arr.length; i--;) { - if (arr[i] === item) { - arr.splice(i, 1); - } - } - return arr; - } - if (WYMeditor && WYMeditor.XhtmlValidator._tags.param.attributes) { - - WYMeditor.XhtmlValidator._tags.embed = { - "attributes":[ - "allowscriptaccess", - "allowfullscreen", - "height", - "src", - "type", - "width" - ] - }; - - WYMeditor.XhtmlValidator._tags.param.attributes = { - '0':'name', - '1':'type', - 'valuetype':/^(data|ref|object)$/, - '2':'valuetype', - '3':'value' - }; - - WYMeditor.XhtmlValidator._tags.iframe = { - "attributes":[ - "allowfullscreen", - "width", - "height", - "src", - "title", - "frameborder" - ] - }; - - // Override the XhtmlSaxListener to allow param, embed and iframe. - // - // We have to do an explicit override - // of the function instead of just changing the startup parameters - // because those are only used on creation, and changing them after - // the fact won't affect the existing XhtmlSaxListener - var XhtmlSaxListener = WYMeditor.XhtmlSaxListener; - WYMeditor.XhtmlSaxListener = function () { - var listener = XhtmlSaxListener.call(this); - // param, embed and iframe should be inline tags so that they can - // be nested inside other elements - removeItem('param', listener.block_tags); - listener.inline_tags.push('param'); - listener.inline_tags.push('embed'); - listener.inline_tags.push('iframe'); - - return listener; - }; - - WYMeditor.XhtmlSaxListener.prototype = XhtmlSaxListener.prototype; - } -})(); diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/icon_fullscreen.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/icon_fullscreen.gif deleted file mode 100644 index d2a8b0ab98..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/icon_fullscreen.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/jquery.wymeditor.fullscreen.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/jquery.wymeditor.fullscreen.js deleted file mode 100644 index faaa69376a..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/fullscreen/jquery.wymeditor.fullscreen.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * jquery.wymeditor.fullscreen.js - * Fullscreen plugin for WYMeditor - * - * File Authors: - * Luis Santos (luis.santos a-t openquest dotpt) - * Jonatan Lundin (jonatan.lundin a-t gmail dotcom) - * Gerd Riesselmann (gerd a-t gyro-php dot org) : Fixed issue with new skin layout - * Philipp Cordes (pc a-t irgendware dotnet) - */ - -//Extend WYMeditor -WYMeditor.editor.prototype.fullscreen = function() { - var wym = this, - $box = jQuery(wym._box), - $iframe = jQuery(wym._iframe), - $overlay = null, - $window = jQuery(window), - - editorMargin = 15; // Margin from window (without padding) - - - //construct the button's html - var html = '' + - "
          9. " + - "" + - "Fullscreen" + - "" + - "
          10. "; - //add the button to the tools box - $box.find(wym._options.toolsSelector + wym._options.toolsListSelector) - .append(html); - - function resize () { - // Calculate margins - var uiHeight = $box.outerHeight(true) - $iframe.outerHeight(true); - var editorPadding = $box.outerWidth() - $box.width(); - - // Calculate heights - var screenHeight = $window.height(); - var iframeHeight = (screenHeight - uiHeight - (editorMargin * 2)) + 'px'; - - // Calculate witdths - var screenWidth = $window.width(); - var boxWidth = (screenWidth - editorPadding - (editorMargin * 2)) + 'px'; - - $box.css('width', boxWidth); - $iframe.css('height', iframeHeight); - $overlay.css({ - 'height': screenHeight + 'px', - 'width': screenWidth + 'px' - }); - } - - //handle click event - $box.find('li.wym_tools_fullscreen a').click(function() { - if ($box.css('position') != 'fixed') { - // Store previous inline styles - $box.data('wym-inline-css', $box.attr('style')); - $iframe.data('wym-inline-css', $iframe.attr('style')); - - // Create overlay - $overlay = jQuery('
            ') - .appendTo('body').css({ - 'position': 'fixed', - 'background-color': 'rgb(0, 0, 0)', - 'opacity': '0.75', - 'z-index': '98', - 'top': '0px', - 'left': '0px' - }); - - // Possition the editor - $box.css({ - 'position': 'fixed', - 'z-index': '99', - 'top': editorMargin + 'px', - 'left': editorMargin + 'px' - }); - - // Bind event listeners - $window.bind('resize', resize); - $box.find('li.wym_tools_html a').bind('click', resize); - - // Force resize - resize(); - } else { - // Unbind event listeners - $window.unbind('resize', resize); - $box.find('li.wym_tools_html a').unbind('click', resize); - - // Remove inline styles - $box.css({ - 'position': 'static', - 'z-index': '', - 'width': '', - 'top': '', - 'left': '' - }); - $iframe.css('height', ''); - - // Remove overlay - $overlay.remove(); - $overlay = null; - - // Retore previous inline styles - $box.attr('style', $box.data('wym-inline-css')); - $iframe.attr('style', $iframe.data('wym-inline-css')); - } - - return false; - }); -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js deleted file mode 100644 index 41d70ada1a..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/hovertools/jquery.wymeditor.hovertools.js +++ /dev/null @@ -1,51 +0,0 @@ -/*jslint evil: true */ -/** - WYMeditor.hovertools - ==================== - - A hovertools plugin. -*/ - -WYMeditor.editor.prototype.hovertools = function() { - var wym = this; - - wym.status(' '); - - // Bind events on buttons - jQuery(wym._box).find(wym._options.toolSelector).hover( - function() { - var button = this; - wym.status(jQuery(button).html()); - }, - function() { - wym.status(' '); - } - ); - - // Classes: add/remove a style attr to matching elems - // while mouseover/mouseout - jQuery(wym._box).find(wym._options.classSelector).hover( - function() { - var button = this, - aClasses = eval(wym._options.classesItems), - sName = jQuery(button).attr(WYMeditor.NAME), - oClass = WYMeditor.Helper._getFromArrayByName(aClasses, sName); - - if (oClass){ - jqexpr = oClass.expr; - // Don't use jQuery.find() on the iframe body - // because of MSIE + jQuery + expando issue (#JQ1143) - if (!WYMeditor.isInternetExplorerPre11()) { - wym.$body().find(jqexpr).css('background-color','#cfc'); - } - } - }, - function() { - // Don't use jQuery.find() on the iframe body - // because of MSIE + jQuery + expando issue (#JQ1143) - if (!WYMeditor.isInternetExplorerPre11()) { - wym.$body().find('*').removeAttr('style'); - } - } - ); -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/list/jquery.wymeditor.list.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/list/jquery.wymeditor.list.js deleted file mode 100644 index b009e2587b..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/list/jquery.wymeditor.list.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2011 PolicyStat LLC. - * MIT licensed (MIT-license.txt) - * - * This plugin adds the ability to use tab and shift+tab to indent/outdent - * lists, mimicking a user's expected behavior when inside an editor. - * - * @author Wes Winham (winhamwr@gmail.com) - */ - -function ListPlugin(options, wym) { - var listPlugin = this; - ListPlugin._options = jQuery.extend({}, options); - listPlugin._wym = wym; - - listPlugin.init(); -} - -ListPlugin.prototype.init = function() { - var listPlugin = this; - listPlugin._wym.listPlugin = listPlugin; - - listPlugin.bindEvents(); -}; - -ListPlugin.prototype.bindEvents = function() { - var listPlugin = this, - wym = listPlugin._wym; - - wym.keyboard.combokeys.bind( - "tab", - function () { - wym.indent(); - return false; - } - ); - wym.keyboard.combokeys.bind( - "shift+tab", - function () { - wym.outdent(); - return false; - } - ); -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/rdfa/jquery.wymeditor.rdfa.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/rdfa/jquery.wymeditor.rdfa.js deleted file mode 100644 index 23234400c9..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/rdfa/jquery.wymeditor.rdfa.js +++ /dev/null @@ -1,192 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2011 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * jquery.wymeditor.rdfa.js - * RDFa plugin for WYMeditor - * - * File Authors: - * Jean-Francois Hovinne (@jfhovinne) - */ - -//Extend WYMeditor -WYMeditor.editor.prototype.rdfa = function (options) { - var wym = this, - rdfa = new WYMeditor.RDFa(options, wym); - return rdfa; -}; - -//RDFa constructor -WYMeditor.RDFa = function (options, wym) { - var rdfa = this; - options = jQuery.extend({ - setStdNameSpaces: true, - extendXHTMLParser: true, - buttons: {} - }, options); - - rdfa._options = options; - rdfa._wym = wym; - rdfa.init(); -}; - -//RDFa plugin init -WYMeditor.RDFa.prototype.init = function () { - var rdfa = this; - if (rdfa._options.setStdNameSpaces) { - rdfa.setStdNameSpaces(); - } - if (rdfa._options.extendXHTMLParser) { - rdfa.extendXHTMLParser(); - } - rdfa.setButtons(); -}; - -//Adding the namespaces to the document -WYMeditor.RDFa.prototype.setStdNameSpaces = function () { - var rdfa = this; - rdfa.addNameSpace('xmlns', 'http://www.w3.org/1999/xhtml'); - rdfa.addNameSpace('version', 'XHTML+RDFa 1.0'); -}; - -WYMeditor.RDFa.prototype.addNameSpace = function (attr, value) { - var rdfa = this; - jQuery('html', rdfa._wym._doc) - .attr(attr, value); -}; - -WYMeditor.RDFa.prototype.extendXHTMLParser = function () { - var rdfa = this; - rdfa.extendAttributes(); - rdfa.setStdVocabularies(); - rdfa.extendLinkAttributes(); -}; - -WYMeditor.RDFa.prototype.extendAttributes = function () { - //Add the RDFa attributes - WYMeditor.XhtmlValidator._attributes.core.attributes.push( - 'rel', - 'rev', - 'content', - 'href', - 'src', - 'about', - 'property', - 'resource', - 'datatype', - 'typeof' - ); -}; - -WYMeditor.RDFa.prototype.setStdVocabularies = function () { - var rdfa = this; - //Add the 'standard' vocabularies - vocabularies = [ - 'xmlns:biblio', - 'xmlns:cc', - 'xmlns:dbp', - 'xmlns:dbr', - 'xmlns:dc', - 'xmlns:ex', - 'xmlns:foaf', - 'xmlns:rdf', - 'xmlns:rdfs', - 'xmlns:taxo', - 'xmlns:xhv', - 'xmlns:xsd' - ]; - jQuery.each(vocabularies, function (index, vocabulary) { - rdfa.addVocabulary(vocabulary); - }); -}; - -WYMeditor.RDFa.prototype.addVocabulary = function (vocabulary) { - WYMeditor.XhtmlValidator._attributes.core.attributes.push(vocabulary); -}; - -WYMeditor.RDFa.prototype.extendLinkAttributes = function () { - //Overwrite the attributes 'rel' and 'rev' - WYMeditor.XhtmlValidator._tags.a = { - "attributes": { - "0": "charset", - "1": "coords", - "2": "href", - "3": "hreflang", - "4": "name", - "5": "rel", - "6": "rev", - "shape": /^(rect|rectangle|circ|circle|poly|polygon)$/, - "7": "type" - } - }; -}; - -WYMeditor.RDFa.prototype.setButtons = function () { - var rdfa = this, - list = jQuery(rdfa._wym._box).find('div.wym_classes ul'); - jQuery.each(rdfa._options.buttons, function (index, button) { - list - .append('
          11. ') - .children(':last') - .append('
            ') - .children(':last') - .attr('href', '#') - .text(button.title) - .bind('click', - { - instance: rdfa._wym, - button: button, - ns: button.ns, - attr: button.attr, - value: button.value - }, - rdfa.clickButtonHandler); - }); -}; - -WYMeditor.RDFa.prototype.clickButtonHandler = function (evt) { - var wym = evt.data.instance, - selected = wym.selectedContainer(); - - //the attribute already exists, remove it - if (typeof jQuery(selected).attr(evt.data.attr) !== 'undefined' && - jQuery(selected).attr(evt.data.attr) !== '') { - WYMeditor.console.log( - 'attribute already exists, remove it:', - evt.data.attr, - jQuery(selected).attr(evt.data.attr) - ); - jQuery(selected) - .removeAttr(evt.data.attr) - .removeClass(evt.data.ns) - .removeClass(evt.data.attr) - .removeClass(evt.data.value); - - //else, add it - } else { - WYMeditor.console.log('attribute does not exist, add it:', evt.data.attr, evt.data.value); - if (evt.data.value) { //value available - jQuery(selected) - .attr(evt.data.attr, evt.data.ns + ':' + evt.data.value) - .addClass(evt.data.ns) - .addClass(evt.data.attr) - .addClass(evt.data.value); - } else { //value not available - evt.data.value = prompt('Value', ''); - if (evt.data.value !== null) { - jQuery(selected) - .attr(evt.data.attr, evt.data.value) - .addClass(evt.data.ns) - .addClass(evt.data.attr) - .addClass(evt.data.value); - } - } - } - return false; -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js deleted file mode 100644 index 51b012188d..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/resizable/jquery.wymeditor.resizable.js +++ /dev/null @@ -1,41 +0,0 @@ -/* global -$ */ -"use strict"; - -/** - * The resizable plugin makes the wymeditor box vertically resizable. - * It it based on the ui.resizable.js plugin of the jQuery UI library. - * - * The WYMeditor resizable plugin supports all parameters of the jQueryUI - * resizable plugin. The parameters are passed like this: - * - * wym.resizable({ handles: "s,e", - * maxHeight: 600 }); - * - * DEPENDENCIES: jQuery UI, jQuery UI resizable - * - * @param options options for the plugin - */ -WYMeditor.editor.prototype.resizable = function (options) { - var wym = this, - $iframe = jQuery(wym._box).find('iframe'), - $iframeDiv = jQuery(wym._box).find('.wym_iframe'), - // Define some default options - defaultOptions = { - resize: function () { - $iframeDiv.height($iframe.height()); - }, - alsoResize: $iframe, - handles: "s,e,se", - minHeight: 250 - }, - // Merge given options with default options. Given options override - // default ones. - finalOptions = jQuery.extend(defaultOptions, options); - - if (jQuery.isFunction(jQuery.fn.resizable)) { - jQuery(wym._box).resizable(finalOptions); - } else { - WYMeditor.console.error('Oops, jQuery UI.resizable unavailable.'); - } - -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/jquery.wymeditor.structured_headings.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/jquery.wymeditor.structured_headings.js deleted file mode 100644 index bf71387eab..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/jquery.wymeditor.structured_headings.js +++ /dev/null @@ -1,512 +0,0 @@ -/* jshint maxlen: 90 */ -"use strict"; - -// In case the script is included on a page without WYMeditor, define the -// WYMeditor and WYMeditor.editor objects to hold the constants used. -if (typeof (WYMeditor) === 'undefined') { - /* jshint -W020 */ - WYMeditor = {}; - /* jshint +W020 */ - WYMeditor.HEADING_ELEMENTS = ["h1", "h2", "h3", "h4", "h5", "h6"]; - WYMeditor.KEY_CODE = { - BACKSPACE: 8, - ENTER: 13, - DELETE: 46 - }; -} -if (typeof (WYMeditor.editor) === 'undefined') { - WYMeditor.editor = {}; - WYMeditor.editor.prototype = {}; -} - -WYMeditor.STRUCTURED_HEADINGS_POLYFILL_REQUIRED = - jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8.0; - -// Constants for class names used in structuring the headings -WYMeditor.STRUCTURED_HEADINGS_START_NODE_CLASS = 'wym-structured-headings-start'; -WYMeditor.STRUCTURED_HEADINGS_LEVEL_CLASSES = ['wym-structured-heading-level1', - 'wym-structured-heading-level2', - 'wym-structured-heading-level3', - 'wym-structured-heading-level4', - 'wym-structured-heading-level5', - 'wym-structured-heading-level6']; -WYMeditor.STRUCTURED_HEADINGS_NUMBERING_SPAN_CLASS = 'wym-structured-heading-numbering'; - -// Key codes for the keyup events that the heading numberings should be -// recalculated on -WYMeditor.STRUCTURED_HEADINGS_POTENTIAL_HEADING_MODIFICATION_KEYS = - [WYMeditor.KEY_CODE.BACKSPACE, WYMeditor.KEY_CODE.DELETE, WYMeditor.KEY_CODE.ENTER]; - -/* - getHeadingLevel - =============== - - Returns the integer heading level of the passed heading DOM element. For - example, if the passed heading was an `h2` element, the function would - return the integer `2`. -*/ -function getHeadingLevel(heading) { - return parseInt(heading.nodeName.slice(-1), 10); -} - - - -/** - StructuredHeadingsManager - ========================= - - A heading structure management object that makes it easier for a user to - structure the headings in a document by simplifying the user interface and - adding features such as heading numbering. - - @param options A configuration object. - @param wym The WYMeditor instance to which the StructuredHeadingsManager - object should attach. - @class -*/ -function StructuredHeadingsManager(options, wym) { - var shm = this; - options = jQuery.extend({ - headingIndentToolSelector: "li.wym_tools_indent a", - headingOutdentToolSelector: "li.wym_tools_outdent a", - - enableFixHeadingStructureButton: false, - fixHeadingStructureButtonHtml: String() + - '
          12. ' + - '' + - 'Fix Heading Structure' + - '' + - '
          13. ', - fixHeadingStructureSelector: "li.wym_tools_fix_heading_structure a", - - headingContainerPanelHtml: String() + - '
          14. ' + - 'Heading' + - '
          15. ', - headingContainerPanelSelector: "li.wym_containers_heading a", - - highestAllowableHeadingLevel: 1, - lowestAllowableHeadingLevel: 6 - - }, options); - - shm._headingElements = WYMeditor.HEADING_ELEMENTS - .slice(options.highestAllowableHeadingLevel - 1, - options.lowestAllowableHeadingLevel); - shm._limitedHeadingSel = shm._headingElements.join(", "); - shm._fullHeadingSel = WYMeditor.HEADING_ELEMENTS.join(", "); - shm._options = options; - shm._wym = wym; - - shm.init(); -} - -/** - init - ==== - - Initializes the heading structure object used in the plugin for the - wymeditor instance. Creates the user interface adjustments, binds any - required listeners, and applies the necessary CSS stylesheets. -*/ -StructuredHeadingsManager.prototype.init = function () { - var shm = this; - shm.createUI(); - shm.bindEvents(); - shm.addCssStylesheet(); -}; - -/** - createUI - ======== - - Creates the structured headings user interface by adding the tools to the - tool bar and modifying the container selection panel. -*/ -StructuredHeadingsManager.prototype.createUI = function () { - var shm = this, - wym = shm._wym, - $tools = jQuery(wym._box).find( - wym._options.toolsSelector + wym._options.toolsListSelector - ), - $containerItems, - $containerLink, - i; - - // Add tool panel buttons if necessary - if (shm._options.enableFixHeadingStructureButton) { - $tools.append(shm._options.fixHeadingStructureButtonHtml); - } - - // Remove normal heading links from the containers panel list - $containerItems = jQuery(wym._box).find(wym._options.containersSelector) - .find('li'); - for (i = 0; i < $containerItems.length; ++i) { - $containerLink = $containerItems.eq(i).find('a'); - if (jQuery.inArray($containerLink[0].name.toLowerCase(), - WYMeditor.HEADING_ELEMENTS) > -1) { - $containerItems.eq(i).remove(); - } - } - - // Add new single heading container to the containers panel list - $containerItems.eq(0).after(shm._options.headingContainerPanelHtml); -}; - -/** - bindEvents - ========== - - Binds the click events for the buttons in the tool bar and the container - link in the containers panel. -*/ -StructuredHeadingsManager.prototype.bindEvents = function () { - var shm = this, - wym = shm._wym, - $box = jQuery(wym._box), - sel; - - // Bind click events to tool buttons - $box.find(shm._options.headingOutdentToolSelector).click(function () { - sel = wym.selection(); - shm.changeSelectedHeadingsLevel(sel, "up"); - }); - $box.find(shm._options.headingIndentToolSelector).click(function () { - sel = wym.selection(); - shm.changeSelectedHeadingsLevel(sel, "down"); - }); - if (shm._options.enableFixHeadingStructureButton) { - $box.find(shm._options.fixHeadingStructureSelector).click(function () { - shm.fixHeadingStructure(); - }); - } - - // Bind click event to the new single heading link - $box.find(shm._options.headingContainerPanelSelector).click(function () { - shm.switchToHeading(wym.getRootContainer()); - }); -}; - -/** - addCssStylesheet - ================ - - Adds the CSS stylesheet for the heading numbering to the wymeditor iframe - and stores the CSS for access through the printCss function. -*/ -StructuredHeadingsManager.prototype.addCssStylesheet = function () { - var shm = this, - wym = shm._wym, - iframeHead = jQuery(wym._doc).find('head')[0], - stylesheetHref, - cssLink, - cssRequest; - - cssLink = wym._doc.createElement('link'); - cssLink.rel = 'stylesheet'; - cssLink.type = 'text/css'; - - stylesheetHref = '/plugins/structured_headings/structured_headings.css'; - cssLink.href = '../..' + stylesheetHref; // Adjust path for iframe - iframeHead.appendChild(cssLink); - - // Get stylesheet CSS and store it in WYMeditor so that it can be accessed - // to put on other pages. - cssRequest = new XMLHttpRequest(); - cssRequest.open('GET', wym._options.basePath + stylesheetHref, false); - cssRequest.send(''); - WYMeditor.structuredHeadingsCSS = cssRequest.responseText; -}; - -/** - canRaiseHeadingLevel - ==================== - - Checks the context of the passed heading DOM node to see if it can validly - have its heading level raised. Returns true if the heading's level can - validly be raised, false if otherwise. - - @param heading A heading DOM node for checking if it can validly have its - heading level raised -*/ -StructuredHeadingsManager.prototype.canRaiseHeadingLevel = function (heading) { - var shm = this, - headingLevel = getHeadingLevel(heading), - headingLevelDifference, - nextHeading, - nextHeadingLevel; - - // The level of a heading cannot be raised if it is already at the highest - // allowable level. - if (headingLevel === shm._options.highestAllowableHeadingLevel) { - return false; - } - - // The level of a heading cannot be raised if the heading level is any - // higher than the level of its following heading. - nextHeading = jQuery(heading).nextAll(shm._fullHeadingSel)[0]; - if (nextHeading) { - nextHeadingLevel = getHeadingLevel(nextHeading); - headingLevelDifference = headingLevel - nextHeadingLevel; - if (headingLevelDifference < 0) { - return false; - } - } - - return true; -}; - -/** - canLowerHeadingLevel - ==================== - - Checks the context of the passed heading DOM node to see if it can validly - have its heading level lowered. Returns true if the heading's level can - validly be lowered, false if otherwise. - - @param heading A heading DOM node for checking if it can validly have its - heading level lowered -*/ -StructuredHeadingsManager.prototype.canLowerHeadingLevel = function (heading) { - var shm = this, - headingLevel = getHeadingLevel(heading), - headingLevelDifference, - prevHeading, - prevHeadingLevel; - - // The level of a heading cannot be lowered if it is already at the lowest - // allowable level. - if (headingLevel === shm._options.lowestAllowableHeadingLevel) { - return false; - } - - // The user cannot lower the level of a heading if the heading level is any - // lower than the level of its previous heading. - prevHeading = jQuery(heading).prevAll(shm._fullHeadingSel)[0]; - if (prevHeading) { - prevHeadingLevel = getHeadingLevel(prevHeading); - headingLevelDifference = prevHeadingLevel - headingLevel; - if (headingLevelDifference < 0) { - return false; - } - } - - return true; -}; - -/** - changeSelectedHeadingsLevel - =========================== - - Iterates through the headings in the passed selection and raises or lowers - the level of each heading if it is allowable. - - The level of a heading can only be raised if it is not the highest - allowable level and if the level of the heading is not higher than the - level of its following heading after all headings in the selection have had - their heading level attempted to be raised. - - The level of a heading can only be lowered if it is not the lowest - allowable level and if the level of the heading is not lower than the level - of its preceding heading after all headings in the selection have had their - heading level attempted to be lowered. - - @param selection A rangy selection object to have the level of its - containing headings raised if allowable. - @param upOrDown A string being either "up" or "down" that specifies if the - selected headings should have their level raised up or - lowered down. -*/ -StructuredHeadingsManager.prototype.changeSelectedHeadingsLevel = function ( - selection, upOrDown -) { - var shm = this, - wym = shm._wym, - shouldRaise = (upOrDown === 'up'), - i, - iStart = (shouldRaise ? selection.rangeCount - 1 : 0), - iLimit = (shouldRaise ? -1 : selection.rangeCount), - iterChange = (shouldRaise ? -1 : 1), - range, - heading, - $headingList, - j, - jStart, - jLimit, - $selectedNodes; - - // Iterate through the headings in the selection from bottom to top if the - // level of the headings should be raised or top to bottom if the level of - // the headings should be lowered. This ordering is necessary to ensure - // each heading has had its relevant context of surrounding heading levels - // modified so that it can be assessed if the heading can validly be raised - // or lowered. - for (i = iStart; i !== iLimit; i += iterChange) { - range = selection.getRangeAt(i); - if (range.collapsed) { - heading = wym.findUp(range.startContainer, - WYMeditor.HEADING_ELEMENTS); - shm.changeHeadingLevel(heading, upOrDown); - } else { - $selectedNodes = jQuery(wym._getSelectedNodes()); - $headingList = $selectedNodes.filter(shm._fullHeadingSel); - if (!$headingList.length && $selectedNodes.length) { - // If there are some nodes in the range, but none of the are - // headings, it's possible that all of the nodes are contained - // within a heading. - $headingList = [wym.findUp( - $selectedNodes[0], - WYMeditor.HEADING_ELEMENTS - )]; - } - - jStart = (shouldRaise ? $headingList.length - 1 : 0); - jLimit = (shouldRaise ? -1 : $headingList.length); - for (j = jStart; j !== jLimit; j += iterChange) { - shm.changeHeadingLevel($headingList[j], upOrDown); - } - } - } -}; - -/** - changeHeadingLevel - ================== - - If the passed heading DOM node exists in the documet, changes the level of - that heading up or down by one level if it is allowable. The heading will not - have its level moved up if the heading following it is at a lower level - than the passed heading's current level. A heading will not have its - level moved down if the heading preceding it is at a higher level than the - passed heading's current level. - - @param heading The DOM node of a heading element in the document. - @param upOrDown A string either being "up" or "down" that indicates if the - heading level should be raised or lowered. -*/ -StructuredHeadingsManager.prototype.changeHeadingLevel = function ( - heading, upOrDown -) { - var shm = this, - wym = shm._wym, - changeLevelUp = (upOrDown === "up"), - levelAdjustment = (changeLevelUp ? -1 : 1), - headingLevel; - - // If the heading doesn't exist, don't do anything. - if (!heading) { - return; - } - - // Check if the requested change in the heading level is valid. If it is - // not valid, don't modify the heading. - headingLevel = getHeadingLevel(heading); - if (changeLevelUp && !shm.canRaiseHeadingLevel(heading)) { - return; - } - if (!changeLevelUp && !shm.canLowerHeadingLevel(heading)) { - return; - } - - wym.switchTo(heading, 'h' + (headingLevel + levelAdjustment)); -}; - -/** - switchToHeading - =============== - - Switches the passed DOM node (if it exists) to a heading with the same - heading level as the preceding heading to the node. If there is no - preceding heading to the node, the node is switched to a heading with the - specified highest allowable heading level in the options. - - @param node The DOM node to be switched to a heading. -*/ -StructuredHeadingsManager.prototype.switchToHeading = function (node) { - var shm = this, - wym = shm._wym, - $prevHeading; - - // If the node doesn't exist, don't do anything. - if (!node) { - return; - } - - $prevHeading = jQuery(node).prev(shm._fullHeadingSel); - if ($prevHeading.length) { - wym.switchTo(node, $prevHeading[0].nodeName); - } else { - wym.switchTo(node, 'h' + shm._options.highestAllowableHeadingLevel); - } -}; - -/** - fixHeadingStructure - =================== - - Fixes the structure of the headings in the editor if needed so that they - follow proper standards of heading usage. The main fix this applies is - preventing headings from being more than one level apart while descending - (e.g. an H1 followed by an H3 or an H2 followed by an H4). - - This function is pretty simple now and will need more work in the future to - make it smarter. -*/ -StructuredHeadingsManager.prototype.fixHeadingStructure = function () { - var shm = this, - wym = shm._wym, - $headings = wym.$body().find(shm._limitedHeadingSel), - heading, - headingLevel, - prevHeadingLevel, - i; - - // If there are no headings in the document, don't do anything. - if (!$headings.length) { - return; - } - - prevHeadingLevel = getHeadingLevel($headings[0]); - for (i = 1; i < $headings.length; ++i) { - heading = $headings[i]; - headingLevel = getHeadingLevel(heading); - if (headingLevel - prevHeadingLevel > 1) { - wym.switchTo(heading, 'h' + (prevHeadingLevel + 1)); - ++prevHeadingLevel; - } else { - prevHeadingLevel = headingLevel; - } - } -}; - -/** - WYMeditor.printStructuredHeadingsCss - ==================================== - - Function to output the plugin CSS to the console log so that it can be - copied over to other pages. -*/ -WYMeditor.printStructuredHeadingsCSS = function () { - WYMeditor.console.log(WYMeditor.structuredHeadingsCSS); -}; - -/** - structuredHeadings - ================== - - Construct and return a heading structure object using the given options - object. This should be called in the `postInit` function when initializing - a wymeditor instance. - - @param options A configuration object. -*/ -WYMeditor.editor.prototype.structuredHeadings = function (options) { - var wym = this, - structuredHeadingsManager = new StructuredHeadingsManager(options, wym); - wym.structuredHeadingsManager = structuredHeadingsManager; - - return structuredHeadingsManager; -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/ruler_arrow.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/ruler_arrow.png deleted file mode 100644 index a11b94fa9d..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/ruler_arrow.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/structured_headings.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/structured_headings.css deleted file mode 100644 index 3def5cb68a..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/structured_headings/structured_headings.css +++ /dev/null @@ -1,55 +0,0 @@ -/* Structured Headings Plugin CSS */ -body { - counter-reset: cntr-h1; -} - -h1 { - counter-reset: cntr-h2; -} - -h1:before { - content: counter(cntr-h1) " "; - counter-increment: cntr-h1; -} - -h2 { - counter-reset: cntr-h3; -} - -h2:before { - content: counter(cntr-h1) "." counter(cntr-h2) " "; - counter-increment: cntr-h2; -} - -h3 { - counter-reset: cntr-h4; -} - -h3:before { - content: counter(cntr-h1) "." counter(cntr-h2) "." counter(cntr-h3) " "; - counter-increment: cntr-h3; -} - -h4 { - counter-reset: cntr-h5; -} - -h4:before { - content: counter(cntr-h1) "." counter(cntr-h2) "." counter(cntr-h3) "." counter(cntr-h4) " "; - counter-increment: cntr-h4; -} - -h5 { - counter-reset: cntr-h6; -} - -h5:before { - content: counter(cntr-h1) "." counter(cntr-h2) "." counter(cntr-h3) "." counter(cntr-h4) "." counter(cntr-h5) " "; - counter-increment: cntr-h5; -} - -h6:before { - content: counter(cntr-h1) "." counter(cntr-h2) "." counter(cntr-h3) "." counter(cntr-h4) "." counter(cntr-h5) "." counter(cntr-h6) " "; - counter-increment: cntr-h6; -} - diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/jquery.wymeditor.table.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/jquery.wymeditor.table.js deleted file mode 100644 index d258cb5cf1..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/jquery.wymeditor.table.js +++ /dev/null @@ -1,761 +0,0 @@ -/* global rangy */ -"use strict"; - -// Fugue icons by Yusuke Kamiyamane http://p.yusukekamiyamane.com/ -// and licensed under Creative Commons Attribution - -/** - * A Table editing plugin that gives the user ability to add and remove - * rows and columns as well as merge rows and columns. - * - * @param options A configuration object. - * @param wym The WYMeditor instance to which the TableEditor should attach. - * @class - */ -function TableEditor(options, wym) { - var tableEditor = this; - options = jQuery.extend({ - sMergeRowButtonHtml: String() + - '
          16. ' + - '' + - 'Merge Table Row' + - '' + - '
          17. ', - - sMergeRowButtonSelector: "li.wym_tools_merge_row a", - - sAddRowButtonHtml: String() + - "
          18. " + - "" + - "Add Table Row" + - "" + - "
          19. ", - sAddRowButtonSelector: "li.wym_tools_add_row a", - - sRemoveRowButtonHtml: String() + - "
          20. " + - "" + - "Remove Table Row" + - "" + - "
          21. ", - sRemoveRowButtonSelector: "li.wym_tools_remove_row a", - - sAddColumnButtonHtml: String() + - "
          22. " + - "" + - "Add Table Column" + - "" + - "
          23. ", - sAddColumnButtonSelector: "li.wym_tools_add_column a", - - sRemoveColumnButtonHtml: String() + - "
          24. " + - "" + - "Remove Table Column" + - "" + - "
          25. ", - sRemoveColumnButtonSelector: "li.wym_tools_remove_column a", - - enableCellTabbing: true - - }, options); - - tableEditor._options = options; - tableEditor._wym = wym; - - tableEditor.init(); -} - -/** - * Construct and return a table objects using the given options object. - * - * @param options The configuration object. - */ -WYMeditor.editor.prototype.table = function (options) { - var wym = this, - tableEditor = new TableEditor(options, wym); - wym.tableEditor = tableEditor; - - return tableEditor; -}; - -/** - * Initialize the TableEditor object by adding appropriate toolbar buttons and - * binding any required event listeners. - */ -TableEditor.prototype.init = function () { - var tableEditor = this, - wym = tableEditor._wym, - // Add the tool panel buttons - tools = jQuery(wym._box).find( - wym._options.toolsSelector + wym._options.toolsListSelector - ); - - tools.append(tableEditor._options.sMergeRowButtonHtml); - tools.append(tableEditor._options.sAddRowButtonHtml); - tools.append(tableEditor._options.sRemoveRowButtonHtml); - tools.append(tableEditor._options.sAddColumnButtonHtml); - tools.append(tableEditor._options.sRemoveColumnButtonHtml); - - tableEditor.bindEvents(); - rangy.init(); -}; - -/** - * Bind all required event listeners, including button listeners and support - * for tabbing through table cells if enableCellTabbing is true. - */ -TableEditor.prototype.bindEvents = function () { - var tableEditor = this, - wym = tableEditor._wym; - - // Handle tool button click - jQuery(wym._box).find( - tableEditor._options.sMergeRowButtonSelector - ).click(function () { - tableEditor.mergeRow(); - return false; - }); - jQuery(wym._box).find( - tableEditor._options.sAddRowButtonSelector - ).click(function () { - return tableEditor.addRow(wym.selectedContainer()); - }); - jQuery(wym._box).find( - tableEditor._options.sRemoveRowButtonSelector - ).click(function () { - return tableEditor.removeRow(wym.selectedContainer()); - }); - jQuery(wym._box).find( - tableEditor._options.sAddColumnButtonSelector - ).click(function () { - return tableEditor.addColumn(wym.selectedContainer()); - }); - jQuery(wym._box).find( - tableEditor._options.sRemoveColumnButtonSelector - ).click(function () { - return tableEditor.removeColumn(wym.selectedContainer()); - }); - - // Handle tab clicks - if (tableEditor._options.enableCellTabbing) { - jQuery(wym._doc).bind('keydown', tableEditor.keyDown); - } -}; - -/** - * Get the number of columns in a given tr element, accounting for colspan and - * rowspan. This function assumes that the table structure is valid, and will - * return incorrect results for uneven tables. - * - * @param tr The node whose number of columns we need to count. - * - * @returns {Number} The number of columns in the given tr, accounting for - * colspan and rowspan. - */ -TableEditor.prototype.getNumColumns = function (tr) { - var tableEditor = this, - wym = tableEditor._wym, - numColumns = 0, - table, - firstTr; - - table = wym.findUp(tr, 'table'); - firstTr = jQuery(table).find('tr:eq(0)'); - - // Count the tds and ths in the FIRST ROW of this table, accounting for - // colspan. We count the first td because it won't have any rowspan's - // before it to complicate things - jQuery(firstTr).children('td,th').each(function (index, elmnt) { - numColumns += TableEditor.GET_COLSPAN_PROP(elmnt); - }); - - return numColumns; -}; - -/** - TableEditor.GET_COLSPAN_PROP - ============================ - - Get the integer value of the inferred colspan property on the given cell in - a cross-browser compatible way that's also compatible across jquery - versions. - - jquery 1.6 changed the way .attr works, which affected certain browsers - differently with regard to colspan and rowspan for cells that didn't - explicitly have that attribute set. -*/ -TableEditor.GET_COLSPAN_PROP = function (cell) { - var colspan = jQuery(cell).attr('colspan'); - if (typeof colspan === 'undefined') { - colspan = 1; - } - return parseInt(colspan, 10); -}; - -/** - TableEditor.GET_ROWSPAN_PROP - ============================ - - Get the integer value of the inferred rowspan property on the given cell in - a cross-browser compatible way that's also compatible across jquery - versions. - - See GET_COLSPAN_PROP for details -*/ -TableEditor.GET_ROWSPAN_PROP = function (cell) { - var rowspan = jQuery(cell).attr('rowspan'); - if (typeof rowspan === 'undefined') { - rowspan = 1; - } - return parseInt(rowspan, 10); -}; -/** - * Get the X grid index of the given td or th table cell (0-indexed). This - * takes in to account all colspans and rowspans. - * - * @param cell The td or th node whose X index we're returning. - */ -TableEditor.prototype.getCellXIndex = function (cell) { - var tableEditor = this, - i, - parentTr, - baseRowColumns, - rowColCount, - missingCells, - rowspanIndexes, - checkTr, - rowOffset, - trChildren, - elmnt, - colspan, - indexCounter, - cellIndex; - parentTr = jQuery(cell).parent('tr')[0]; - - baseRowColumns = tableEditor.getNumColumns(parentTr); - - // Figure out how many explicit cells are missing which is how many - // rowspans we're affected by - rowColCount = 0; - jQuery(parentTr).children('td,th').each(function (index, elmnt) { - rowColCount += TableEditor.GET_COLSPAN_PROP(elmnt); - }); - - missingCells = baseRowColumns - rowColCount; - rowspanIndexes = []; - checkTr = parentTr; - rowOffset = 1; - - // If this cell is affected by a rowspan from farther up the table, - // we need to take in to account any possible colspan attributes on that - // cell. Store the real X index of the cells to the left of our cell to use - // in the colspan calculation. - while (missingCells > 0) { - checkTr = jQuery(checkTr).prev('tr'); - rowOffset += 1; - trChildren = jQuery(checkTr).children('td,th'); - for (i = 0; i < trChildren.length; i++) { - elmnt = trChildren[i]; - if (TableEditor.GET_ROWSPAN_PROP(elmnt) >= rowOffset) { - // Actually affects our source row - missingCells -= 1; - colspan = TableEditor.GET_COLSPAN_PROP(elmnt); - rowspanIndexes[tableEditor.getCellXIndex(elmnt)] = colspan; - } - } - } - - indexCounter = 0; - cellIndex = null; - // Taking in to account the real X indexes of all of the columns to the - // left of this cell, determine the real X index. - jQuery(parentTr).children('td,th').each(function (index, elmnt) { - if (cellIndex !== null) { - // We've already iterated to the cell we're checking - return; - } - // Account for an inferred colspan created by a rowspan from above - while (typeof rowspanIndexes[indexCounter] !== 'undefined') { - indexCounter += parseInt(rowspanIndexes[indexCounter], 10); - } - if (elmnt === cell) { - // We're at our cell, no need to keep moving to the right. - // Signal this by setting the cellIndex - cellIndex = indexCounter; - return; - } - // Account for an explicit colspan on this cell - indexCounter += TableEditor.GET_COLSPAN_PROP(elmnt); - }); - - if (cellIndex === null) { - // Somehow, we never found the cell when iterating over its row. - throw "Cell index not found"; - } - return cellIndex; -}; - -/** - * Get the number of columns represented by the given array of contiguous cell - * (td/th) nodes. - * Accounts for colspan and rowspan attributes. - * - * @param cells An array of td/th nodes whose total column span we're checking. - * - * @return {Number} The number of columns represented by the "cells" - */ -TableEditor.prototype.getTotalColumns = function (cells) { - var tableEditor = this, - rootTr = tableEditor.getCommonParentTr(cells), - baseRowColumns, - colspanCount, - rowColCount, - lastCell, - firstCell; - - if (rootTr === null) { - // Non-contiguous columns - throw "getTotalColumns only allowed for contiguous cells"; - } - - baseRowColumns = tableEditor.getNumColumns(rootTr); - - // Count the number of simple columns, not accounting for rowspans - colspanCount = 0; - jQuery(cells).each(function (index, elmnt) { - colspanCount += TableEditor.GET_COLSPAN_PROP(elmnt); - }); - - // Determine if we're affected by rowspans. If the number of simple columns - // in the row equals the number of columns in the first row, we don't have - // any rowspans - rowColCount = 0; - jQuery(rootTr).children('td,th').each(function (index, elmnt) { - rowColCount += TableEditor.GET_COLSPAN_PROP(elmnt); - }); - - if (rowColCount === baseRowColumns) { - // Easy case. No rowspans to deal with - return colspanCount; - } else { - if (cells.length === 1) { - // Easy. Just the colspan - return TableEditor.GET_COLSPAN_PROP(cells[0]); - } else { - lastCell = jQuery(cells).eq(cells.length - 1)[0]; - firstCell = jQuery(cells).eq(0)[0]; - // On jQuery 1.4 upgrade, jQuery(cells).eq(-1) - return 1 + tableEditor.getCellXIndex(lastCell) - - tableEditor.getCellXIndex(firstCell); - } - } -}; - -/** - * Merge the table cells in the given selection using a colspan. - * - * @return {Boolean} true if changes are made, false otherwise - */ -TableEditor.prototype.mergeRow = function () { - var tableEditor = this, - wym = tableEditor._wym, - // Get all of the affected nodes in the range - nodes = wym._getSelectedNodes(), - cells, - rootTr, - mergeCell, - $elmnt, - rowspanProp, - newContent, - combinedColspan; - - wym.deselect(); - - // Just use the td and th nodes - cells = jQuery(nodes).filter('td,th'); - if (cells.length === 0) { - return false; - } - - // If the selection is across multiple tables, don't merge - rootTr = tableEditor.getCommonParentTr(cells); - if (rootTr === null) { - return false; - } - - mergeCell = cells[0]; - // If any of the cells have a rowspan, create the inferred cells - jQuery(cells).each(function (i, elmnt) { - $elmnt = jQuery(elmnt); - rowspanProp = TableEditor.GET_ROWSPAN_PROP(elmnt); - if (rowspanProp <= 1) { - // We don't care about cells without a rowspan - return; - } - - // This cell has an actual rowspan, we need to account for it - // Figure out the x index for this cell in the table grid - var index = tableEditor.getCellXIndex(elmnt), - // Create the previously-inferred cell in the appropriate index - // with one less rowspan - newRowspan = rowspanProp - 1, - newTd, - insertionIndex, - insertionCells, - cellInserted, - xIndex; - if (newRowspan === 1) { - newTd = '' + $elmnt.html() + ''; - } else { - newTd = String() + - '' + - $elmnt.html() + - ''; - } - if (index === 0) { - $elmnt.parent('tr') - .next('tr') - .prepend(newTd); - } else { - // TODO: account for colspan/rowspan with insertion - // Account for colspan/rowspan by walking from right to left - // looking for the cell closest to the desired index to APPEND to - insertionIndex = index - 1; - insertionCells = $elmnt.parent('tr').next('tr').find('td,th'); - cellInserted = false; - for (i = insertionCells.length - 1; i >= 0; i--) { - xIndex = tableEditor.getCellXIndex(insertionCells[i]); - if (xIndex <= insertionIndex) { - jQuery(insertionCells[i]).after(newTd); - cellInserted = true; - break; - } - } - if (!cellInserted) { - // Bail out now before we clear HTML and break things - throw "Cell rowspan invalid"; - } - } - - // Clear the cell's html, since we just moved it down - $elmnt.html(''); - }); - - // Remove any rowspan from the mergecell now that we've shifted rowspans - // down - // ie fails when we try to remove a rowspan for some reason - try { - jQuery(mergeCell).removeAttr('rowspan'); - } catch (err) { - jQuery(mergeCell).attr('rowspan', 1); - } - - // Build the content of the new combined cell from all of the included - // cells - newContent = ''; - jQuery(cells).each(function (index, elmnt) { - newContent += jQuery(elmnt).html(); - }); - - // Add a colspan to the farthest-left cell - combinedColspan = tableEditor.getTotalColumns(cells); - if (jQuery.browser.msie) { - // jQuery.attr doesn't work for colspan in ie - mergeCell.colSpan = combinedColspan; - } else { - jQuery(mergeCell).attr('colspan', combinedColspan); - } - - // Delete the rest of the cells - jQuery(cells).each(function (index, elmnt) { - if (index !== 0) { - jQuery(elmnt).remove(); - } - }); - - // Change the content in our newly-merged cell - jQuery(mergeCell).html(newContent); - - tableEditor.selectElement(mergeCell); - - wym.registerModification(); - return true; -}; - -/** - * Add a row to the given elmnt (representing a or a child of a ). - * - * @param The node which will have a row appended after its parent row. - */ -TableEditor.prototype.addRow = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - tr = tableEditor._wym.findUp(elmnt, 'tr'), - numColumns, - tdHtml, - i; - - if (tr === null) { - return false; - } - - numColumns = tableEditor.getNumColumns(tr); - - tdHtml = ''; - for (i = 0; i < numColumns; i++) { - tdHtml += ' '; - } - jQuery(tr).after('' + tdHtml + ''); - - wym.registerModification(); - return false; -}; - -/** - * Remove the given table if it doesn't have any rows/columns. - * - * @param table The table to delete if it is empty. - */ -TableEditor.prototype.removeEmptyTable = function (table) { - var tableEditor = this, - wym = tableEditor._wym, - cells = jQuery(table).find('td,th'), - $table; - if (cells.length === 0) { - $table = jQuery(table); - $table.prev('br.' + WYMeditor.BLOCKING_ELEMENT_SPACER_CLASS).remove(); - $table.next('br.' + WYMeditor.BLOCKING_ELEMENT_SPACER_CLASS).remove(); - $table.remove(); - wym.prepareDocForEditing(); - } -}; - -/** - * Remove the row for the given element (representing a or a child - * of a ). - * - * @param elmnt The node whose parent tr will be removed. - */ -TableEditor.prototype.removeRow = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - tr = wym.findUp(elmnt, 'tr'), - table; - - if (tr === null) { - return false; - } - table = wym.findUp(elmnt, 'table'); - if ( - wym.hasSelection() === true && - wym.doesElementContainSelection(elmnt) === true - ) { - wym.deselect(); - } - jQuery(tr).remove(); - tableEditor.removeEmptyTable(table); - - wym.registerModification(); - return false; -}; - -/** - * Add a column to the given elmnt (representing a or a child of a ). - * - * @param elmnt The node which will have a column appended afterward. - */ -TableEditor.prototype.addColumn = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - td = wym.findUp(elmnt, ['td', 'th']), - prevTds, - tdIndex, - tr, - newTd = ' ', - newTh = ' ', - insertionElement; - - if (td === null) { - return false; - } - prevTds = jQuery(td).prevAll(); - tdIndex = prevTds.length; - - tr = wym.findUp(td, 'tr'); - jQuery(tr).siblings('tr').andSelf().each(function (index, element) { - insertionElement = newTd; - if (jQuery(element).find('th').length > 0) { - // The row has a TH, so insert a th - insertionElement = newTh; - } - - jQuery(element).find('td,th').eq(tdIndex).after(insertionElement); - }); - - wym.registerModification(); - return false; -}; - -/** - * Remove the column to the right of the given elmnt (representing a or a - * child of a ). - */ -TableEditor.prototype.removeColumn = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - td = wym.findUp(elmnt, ['td', 'th']), - table, - prevTds, - tdIndex, - tr; - if (td === null) { - return false; - } - table = wym.findUp(elmnt, 'table'); - prevTds = jQuery(td).prevAll(); - tdIndex = prevTds.length; - - tr = wym.findUp(td, 'tr'); - jQuery(tr).siblings('tr').addBack().each(function (index, element) { - var $cell = jQuery(element).find("td, th").eq(tdIndex); - if ( - wym.hasSelection() === true && - wym.doesElementContainSelection($cell[0]) === true - ) { - wym.deselect(); - } - $cell.remove(); - }); - tableEditor.removeEmptyTable(table); - - wym.registerModification(); - return false; -}; - -/** - * keyDown event handler used for consistent tab key cell movement. - */ -TableEditor.prototype.keyDown = function (evt) { - var doc = this, - wym = WYMeditor.INSTANCES[doc.title], - tableEditor = wym.tableEditor; - - if (evt.which === WYMeditor.KEY_CODE.TAB) { - return tableEditor.selectNextCell(wym.selectedContainer()); - } - - return null; -}; - -/** - * Move the focus to the next cell. - */ -TableEditor.prototype.selectNextCell = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - cell = wym.findUp(elmnt, ['td', 'th']), - nextCells, - tr, - nextRows; - - if (cell === null) { - return null; - } - - // Try moving to the next cell to the right - nextCells = jQuery(cell).next('td,th'); - if (nextCells.length > 0) { - tableEditor.selectElement(nextCells[0]); - return false; - } - - // There was no cell to the right, use the first cell in the next row - tr = wym.findUp(cell, 'tr'); - nextRows = jQuery(tr).next('tr'); - if (nextRows.length !== 0) { - nextCells = jQuery(nextRows).children('td,th'); - if (nextCells.length > 0) { - tableEditor.selectElement(nextCells[0]); - return false; - } - } - - // There is no next row. Do a normal tab - return null; -}; - -/** - * Select the given element using rangy selectors. - */ -TableEditor.prototype.selectElement = function (elmnt) { - var tableEditor = this, - wym = tableEditor._wym, - sel = wym.selection(), - range = rangy.createRange(wym._doc); - - range.setStart(elmnt, 0); - range.setEnd(elmnt, 0); - range.collapse(false); - - try { - sel.setSingleRange(range); - } catch (err) { - // ie8 can raise an "unkown runtime error" trying to empty the range - } - // Old IE selection hack - if (WYMeditor.isInternetExplorerPre11()) { - wym._saveCaret(); - } -}; - -/** - * Get the common parent tr for the given table cell nodes. If the closest - * parent tr for each cell isn't the same, returns null. - */ -TableEditor.prototype.getCommonParentTr = function (cells) { - var firstCell, - parentTrList, - rootTr; - - cells = jQuery(cells).filter('td,th'); - if (cells.length === 0) { - return null; - } - firstCell = cells[0]; - parentTrList = jQuery(firstCell).parent('tr'); - - if (parentTrList.length === 0) { - return null; - } - rootTr = parentTrList[0]; - - // Ensure that all of the cells have the same parent tr - jQuery(cells).each(function (index, elmnt) { - parentTrList = jQuery(elmnt).parent('tr'); - if (parentTrList.length === 0 || parentTrList[0] !== rootTr) { - return null; - } - }); - - return rootTr; -}; diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_column.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_column.png deleted file mode 100644 index 9022d686f6..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_column.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_row.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_row.png deleted file mode 100644 index f9d956f05a..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_delete_row.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_column.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_column.png deleted file mode 100644 index 49226ec5ec..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_column.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_row.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_row.png deleted file mode 100644 index da435c33ac..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_insert_row.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_join_row.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_join_row.png deleted file mode 100644 index 70e5983c7d..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/table/table_join_row.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js deleted file mode 100644 index 5798aa5d0c..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/plugins/tidy/jquery.wymeditor.tidy.js +++ /dev/null @@ -1,74 +0,0 @@ -"use strict"; - -function WymTidy(options, wym) { - var wymTidy = this, - wandUrl = wym._options.basePath + "plugins/tidy/wand.png"; - options = jQuery.extend({ - sUrl: wym._options.basePath + "plugins/tidy/tidy.php", - sButtonHtml: "" + - "
          26. " + - "" + - "Clean up HTML" + - "" + - "
          27. ", - - sButtonSelector: "li.wym_tools_tidy a" - - }, options); - - wymTidy._options = options; - wymTidy._wym = wym; -} - -//Extend WYMeditor -WYMeditor.editor.prototype.tidy = function (options) { - var wym = this, - tidy = new WymTidy(options, wym); - return tidy; -}; - - -//WymTidy initialization -WymTidy.prototype.init = function () { - var tidy = this, - wym = tidy._wym; - - jQuery(wym._box).find( - wym._options.toolsSelector + wym._options.toolsListSelector - ).append(tidy._options.sButtonHtml); - - //handle click event - jQuery(wym._box).find( - tidy._options.sButtonSelector - ).click( - function () { - tidy.cleanup(); - return false; - } - ); -}; - -//WymTidy cleanup -WymTidy.prototype.cleanup = function () { - var tidy = this, - wym = tidy._wym, - html = "" + wym.html() + ""; - - jQuery.post( - tidy._options.sUrl, - {html: html}, - function (data) { - if (data.length > 0 && data !== '0') { - if (data.indexOf(" diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/icons.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/icons.png deleted file mode 100644 index c6eb463f11..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/icons.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/skin.css deleted file mode 100644 index 2becf0b146..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/compact/skin.css +++ /dev/null @@ -1,134 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * screen.css - * main stylesheet for the WYMeditor skin - * See the documentation for more info. - * - * File Authors: - * Daniel Reszka (d.reszka a-t wymeditor dotorg) - * Jean-Francois Hovinne (jf.hovinne a-t wymeditor dotorg) -*/ - -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ - .wym_skin_compact p, .wym_skin_compact h2, .wym_skin_compact h3, - .wym_skin_compact ul, .wym_skin_compact li { background: transparent url(); margin: 0; padding: 0; border-width:0; list-style: none; } - - -/*HIDDEN BY DEFAULT*/ - .wym_skin_compact .wym_area_left { display: none; } - .wym_skin_compact .wym_area_right { display: none; } - - -/*TYPO*/ - .wym_skin_compact { font-size: 10px; font-family: Verdana, Arial, sans-serif; } - .wym_skin_compact h2 { font-size: 110%; /* = 11px */} - .wym_skin_compact h3 { font-size: 100%; /* = 10px */} - .wym_skin_compact li { font-size: 100%; /* = 10px */} - - -/*WYM_BOX*/ - .wym_skin_compact { border: 1px solid gray; padding: 5px} - - /*auto-clear the wym_box*/ - .wym_skin_compact:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_compact { height: 1%;} - - -/*WYM_HTML*/ - .wym_skin_compact .wym_html { width: 98%;} - .wym_skin_compact .wym_html textarea { font-size: 120%; width: 100%; height: 200px; border: 1px solid gray; background: white; } - - -/*WYM_IFRAME*/ - .wym_skin_compact .wym_iframe { width: 98%;} - .wym_skin_compact .wym_iframe iframe { width: 100%; height: 200px; border: 1px solid gray; background: white; display: block; } - - -/*AREAS*/ - .wym_skin_compact .wym_area_left { width: 100px; float: left;} - .wym_skin_compact .wym_area_right { width: 150px; float: right;} - .wym_skin_compact .wym_area_bottom { height: 1%; clear: both;} - * html .wym_skin_compact .wym_area_main { height: 1%;} - * html .wym_skin_compact .wym_area_top { height: 1%;} - *+html .wym_skin_compact .wym_area_top { height: 1%;} - -/*SECTIONS SYSTEM*/ - - /*common defaults for all sections*/ - .wym_skin_compact .wym_section { margin-bottom: 5px; } - .wym_skin_compact .wym_section h2, - .wym_skin_compact .wym_section h3 { padding: 1px 3px; margin: 0; } - .wym_skin_compact .wym_section a { padding: 0 3px; display: block; text-decoration: none; color: black; } - .wym_skin_compact .wym_section a:hover { background-color: yellow; } - /*hide section titles by default*/ - .wym_skin_compact .wym_section h2 { display: none; } - /*disable any margin-collapse*/ - .wym_skin_compact .wym_section { padding-top: 1px; padding-bottom: 1px; } - /*auto-clear sections*/ - .wym_skin_compact .wym_section ul:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_compact .wym_section ul { height: 1%;} - - /*option: add this class to a section to make it render as a panel*/ - .wym_skin_compact .wym_panel { } - .wym_skin_compact .wym_panel h2 { display: block; } - - /*option: add this class to a section to make it render as a dropdown menu*/ - .wym_skin_compact .wym_dropdown h2 { display: block; } - .wym_skin_compact .wym_dropdown ul { display: none; position: absolute; background: white; } - .wym_skin_compact .wym_dropdown:hover ul, - .wym_skin_compact .wym_dropdown.hover ul { display: block; } - - /*option: add this class to a section to make its elements render buttons (icons are only available for the wym_tools section for now)*/ - .wym_skin_compact .wym_buttons li { float:left;} - .wym_skin_compact .wym_buttons a { width: 20px; height: 20px; overflow: hidden; padding: 2px } - /*image replacements*/ - .wym_skin_compact .wym_buttons li a { background: url(icons.png) no-repeat; text-indent: -9999px;} - .wym_skin_compact .wym_buttons li.wym_tools_strong a { background-position: 0 -382px;} - .wym_skin_compact .wym_buttons li.wym_tools_emphasis a { background-position: 0 -22px;} - .wym_skin_compact .wym_buttons li.wym_tools_superscript a { background-position: 0 -430px;} - .wym_skin_compact .wym_buttons li.wym_tools_subscript a { background-position: 0 -454px;} - .wym_skin_compact .wym_buttons li.wym_tools_ordered_list a { background-position: 0 -48px;} - .wym_skin_compact .wym_buttons li.wym_tools_unordered_list a{ background-position: 0 -72px;} - .wym_skin_compact .wym_buttons li.wym_tools_indent a { background-position: 0 -574px;} - .wym_skin_compact .wym_buttons li.wym_tools_outdent a { background-position: 0 -598px;} - .wym_skin_compact .wym_buttons li.wym_tools_undo a { background-position: 0 -502px;} - .wym_skin_compact .wym_buttons li.wym_tools_redo a { background-position: 0 -526px;} - .wym_skin_compact .wym_buttons li.wym_tools_link a { background-position: 0 -96px;} - .wym_skin_compact .wym_buttons li.wym_tools_unlink a { background-position: 0 -168px;} - .wym_skin_compact .wym_buttons li.wym_tools_image a { background-position: 0 -121px;} - .wym_skin_compact .wym_buttons li.wym_tools_table a { background-position: 0 -144px;} - .wym_skin_compact .wym_buttons li.wym_tools_paste a { background-position: 0 -552px;} - .wym_skin_compact .wym_buttons li.wym_tools_html a { background-position: 0 -193px;} - .wym_skin_compact .wym_buttons li.wym_tools_preview a { background-position: 0 -408px;} - -/*DECORATION*/ - .wym_skin_compact .wym_section h2 { background: #f0f0f0; border: solid gray; border-width: 0 0 1px;} - .wym_skin_compact .wym_section h2 span { color: gray;} - .wym_skin_compact .wym_panel { padding: 0; border: solid gray; border-width: 1px; background: white;} - .wym_skin_compact .wym_panel ul { margin: 2px 0 5px; } - .wym_skin_compact .wym_dropdown { padding: 0; border: solid gray; border-width: 1px 1px 0 1px; } - .wym_skin_compact .wym_dropdown ul { border: solid gray; border-width: 0 1px 1px 1px; margin-left: -1px; padding: 5px 10px 5px 3px;} - -/*DIALOGS*/ - .wym_dialog div.row { margin-bottom: 5px;} - .wym_dialog div.row input { margin-right: 5px;} - .wym_dialog div.row label { float: left; width: 150px; display: block; text-align: right; margin-right: 10px; } - .wym_dialog div.row-indent { padding-left: 160px; } - /*autoclearing*/ - .wym_dialog div.row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - .wym_dialog div.row { display: inline-block; } - /* Hides from IE-mac \*/ - * html .wym_dialog div.row { height: 1%; } - .wym_dialog div.row { display: block; } - /* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ - a.wym_wymeditor_link { text-indent: -9999px; float: right; display: block; width: 50px; height: 15px; background: url(../wymeditor_icon.png); overflow: hidden; text-decoration: none; } diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/icons.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/icons.png deleted file mode 100644 index c6eb463f11..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/icons.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/skin.css deleted file mode 100644 index bbffd6e81a..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/default/skin.css +++ /dev/null @@ -1,133 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * skin.css - * main stylesheet for the default WYMeditor skin - * See the documentation for more info. - * - * File Authors: - * Daniel Reszka (d.reszka a-t wymeditor dotorg) -*/ - -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ - .wym_skin_default p, .wym_skin_default h2, .wym_skin_default h3, - .wym_skin_default ul, .wym_skin_default li { background: transparent url(); margin: 0; padding: 0; border-width:0; list-style: none; } - - -/*HIDDEN BY DEFAULT*/ - .wym_skin_default .wym_area_left { display: none; } - .wym_skin_default .wym_area_right { display: block; } - - -/*TYPO*/ - .wym_skin_default { font-size: 62.5%; font-family: Verdana, Arial, sans-serif; } - .wym_skin_default h2 { font-size: 110%; /* = 11px */} - .wym_skin_default h3 { font-size: 100%; /* = 10px */} - .wym_skin_default li { font-size: 100%; /* = 10px */} - - -/*WYM_BOX*/ - .wym_skin_default { border: 1px solid gray; background: #f2f2f2; padding: 5px} - - /*auto-clear the wym_box*/ - .wym_skin_default:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_default { height: 1%;} - - -/*WYM_HTML*/ - .wym_skin_default .wym_html { width: 98%;} - .wym_skin_default .wym_html textarea { width: 100%; height: 200px; border: 1px solid gray; background: white; } - - -/*WYM_IFRAME*/ - .wym_skin_default .wym_iframe { width: 98%;} - .wym_skin_default .wym_iframe iframe { width: 100%; height: 200px; border: 1px solid gray; background: white } - - -/*AREAS*/ - .wym_skin_default .wym_area_left { width: 150px; float: left;} - .wym_skin_default .wym_area_right { width: 150px; float: right;} - .wym_skin_default .wym_area_bottom { height: 1%; clear: both;} - * html .wym_skin_default .wym_area_main { height: 1%;} - * html .wym_skin_default .wym_area_top { height: 1%;} - *+html .wym_skin_default .wym_area_top { height: 1%;} - -/*SECTIONS SYSTEM*/ - - /*common defaults for all sections*/ - .wym_skin_default .wym_section { margin-bottom: 5px; } - .wym_skin_default .wym_section h2, - .wym_skin_default .wym_section h3 { padding: 1px 3px; margin: 0; } - .wym_skin_default .wym_section a { padding: 0 3px; display: block; text-decoration: none; color: black; } - .wym_skin_default .wym_section a:hover { background-color: yellow; } - /*hide section titles by default*/ - .wym_skin_default .wym_section h2 { display: none; } - /*disable any margin-collapse*/ - .wym_skin_default .wym_section { padding-top: 1px; padding-bottom: 1px; } - /*auto-clear sections*/ - .wym_skin_default .wym_section ul:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_default .wym_section ul { height: 1%;} - - /*option: add this class to a section to make it render as a panel*/ - .wym_skin_default .wym_panel { } - .wym_skin_default .wym_panel h2 { display: block; } - - /*option: add this class to a section to make it render as a dropdown menu*/ - .wym_skin_default .wym_dropdown h2 { display: block; } - .wym_skin_default .wym_dropdown ul { display: none; position: absolute; background: white; } - .wym_skin_default .wym_dropdown:hover ul, - .wym_skin_default .wym_dropdown.hover ul { display: block; } - - /*option: add this class to a section to make its elements render buttons (icons are only available for the wym_tools section for now)*/ - .wym_skin_default .wym_buttons li { float:left;} - .wym_skin_default .wym_buttons a { width: 20px; height: 20px; overflow: hidden; padding: 2px } - /*image replacements*/ - .wym_skin_default .wym_buttons li a { background: url(icons.png) no-repeat; text-indent: -9999px;} - .wym_skin_default .wym_buttons li.wym_tools_strong a { background-position: 0 -382px;} - .wym_skin_default .wym_buttons li.wym_tools_emphasis a { background-position: 0 -22px;} - .wym_skin_default .wym_buttons li.wym_tools_superscript a { background-position: 0 -430px;} - .wym_skin_default .wym_buttons li.wym_tools_subscript a { background-position: 0 -454px;} - .wym_skin_default .wym_buttons li.wym_tools_ordered_list a { background-position: 0 -48px;} - .wym_skin_default .wym_buttons li.wym_tools_unordered_list a{ background-position: 0 -72px;} - .wym_skin_default .wym_buttons li.wym_tools_indent a { background-position: 0 -574px;} - .wym_skin_default .wym_buttons li.wym_tools_outdent a { background-position: 0 -598px;} - .wym_skin_default .wym_buttons li.wym_tools_undo a { background-position: 0 -502px;} - .wym_skin_default .wym_buttons li.wym_tools_redo a { background-position: 0 -526px;} - .wym_skin_default .wym_buttons li.wym_tools_link a { background-position: 0 -96px;} - .wym_skin_default .wym_buttons li.wym_tools_unlink a { background-position: 0 -168px;} - .wym_skin_default .wym_buttons li.wym_tools_image a { background-position: 0 -121px;} - .wym_skin_default .wym_buttons li.wym_tools_table a { background-position: 0 -144px;} - .wym_skin_default .wym_buttons li.wym_tools_paste a { background-position: 0 -552px;} - .wym_skin_default .wym_buttons li.wym_tools_html a { background-position: 0 -193px;} - .wym_skin_default .wym_buttons li.wym_tools_preview a { background-position: 0 -408px;} - -/*DECORATION*/ - .wym_skin_default .wym_section h2 { background: #ddd; border: solid gray; border-width: 0 0 1px;} - .wym_skin_default .wym_section h2 span { color: gray;} - .wym_skin_default .wym_panel { padding: 0; border: solid gray; border-width: 1px; background: white;} - .wym_skin_default .wym_panel ul { margin: 2px 0 5px; } - .wym_skin_default .wym_dropdown { padding: 0; border: solid gray; border-width: 1px 1px 0 1px; } - .wym_skin_default .wym_dropdown ul { border: solid gray; border-width: 0 1px 1px 1px; margin-left: -1px; padding: 5px 10px 5px 3px;} - -/*DIALOGS*/ - .wym_dialog div.row { margin-bottom: 5px;} - .wym_dialog div.row input { margin-right: 5px;} - .wym_dialog div.row label { float: left; width: 120px; display: block; text-align: right; margin-right: 10px; } - .wym_dialog div.row-indent { padding-left: 160px; } - /*autoclearing*/ - .wym_dialog div.row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - .wym_dialog div.row { display: inline-block; } - /* Hides from IE-mac \*/ - * html .wym_dialog div.row { height: 1%; } - .wym_dialog div.row { display: block; } - /* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ - a.wym_wymeditor_link { text-indent: -9999px; float: right; display: block; width: 50px; height: 15px; background: url(../wymeditor_icon.png); overflow: hidden; text-decoration: none; } diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/icons.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/icons.png deleted file mode 100644 index c6eb463f11..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/icons.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/skin.css deleted file mode 100644 index cc936dff3f..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/legacy/skin.css +++ /dev/null @@ -1,115 +0,0 @@ -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ - .wym_skin_legacy p, .wym_skin_legacy h2, .wym_skin_legacy h3, - .wym_skin_legacy ul, .wym_skin_legacy li { background: transparent url(); margin: 0; padding: 0; border-width:0; list-style: none; } - - -/*HIDDEN BY DEFAULT*/ - .wym_skin_legacy .wym_area_left { display: none; } - .wym_skin_legacy .wym_area_right { display: block; } - - -/*TYPO*/ - .wym_skin_legacy { font-size: 62.5%; font-family: Verdana, Arial, sans-serif; } - .wym_skin_legacy h2 { font-size: 110%; /* = 11px */} - .wym_skin_legacy h3 { font-size: 100%; /* = 10px */} - .wym_skin_legacy li { font-size: 100%; /* = 10px */} - - -/*WYM_BOX*/ - .wym_skin_legacy { border: 1px solid gray; background: #f2f2f2; padding: 5px} - - /*auto-clear the wym_box*/ - .wym_skin_legacy:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_legacy { height: 1%;} - - -/*WYM_HTML*/ - .wym_skin_legacy .wym_html { width: 98%;} - .wym_skin_legacy .wym_html textarea { width: 100%; height: 200px; border: 1px solid gray; background: white; } - - -/*WYM_IFRAME*/ - .wym_skin_legacy .wym_iframe { width: 98%;} - .wym_skin_legacy .wym_iframe iframe { width: 100%; height: 200px; border: 1px solid gray; background: white } - - -/*AREAS*/ - .wym_skin_legacy .wym_area_left { width: 150px; float: left;} - .wym_skin_legacy .wym_area_right { width: 150px; float: right;} - .wym_skin_legacy .wym_area_bottom { height: 1%; clear: both;} - * html .wym_skin_legacy .wym_area_main { height: 1%;} - * html .wym_skin_legacy .wym_area_top { height: 1%;} - *+html .wym_skin_legacy .wym_area_top { height: 1%;} - -/*SECTIONS SYSTEM*/ - - /*common defaults for all sections*/ - .wym_skin_legacy .wym_section { margin-bottom: 5px; } - .wym_skin_legacy .wym_section h2, - .wym_skin_legacy .wym_section h3 { padding: 1px 3px; margin: 0; } - .wym_skin_legacy .wym_section a { padding: 0 3px; display: block; text-decoration: none; color: black; } - .wym_skin_legacy .wym_section a:hover { background-color: yellow; } - /*hide section titles by default*/ - .wym_skin_legacy .wym_section h2 { display: none; } - /*disable any margin-collapse*/ - .wym_skin_legacy .wym_section { padding-top: 1px; padding-bottom: 1px; } - /*auto-clear sections*/ - .wym_skin_legacy .wym_section ul:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_legacy .wym_section ul { height: 1%;} - - /*option: add this class to a section to make it render as a panel*/ - .wym_skin_legacy .wym_panel { } - .wym_skin_legacy .wym_panel h2 { display: block; } - - /*option: add this class to a section to make it render as a dropdown menu*/ - .wym_skin_legacy .wym_dropdown h2 { display: block; } - .wym_skin_legacy .wym_dropdown ul { display: none; position: absolute; background: white; } - .wym_skin_legacy .wym_dropdown:hover ul, - .wym_skin_legacy .wym_dropdown.hover ul { display: block; } - - /*option: add this class to a section to make its elements render buttons (icons are only available for the wym_tools section for now)*/ - .wym_skin_legacy .wym_buttons li { float:left;} - .wym_skin_legacy .wym_buttons a { width: 20px; height: 20px; overflow: hidden; padding: 2px } - /*image replacements*/ - .wym_skin_legacy .wym_buttons li a { background: url(icons.png) no-repeat; text-indent: -9999px;} - .wym_skin_legacy .wym_buttons li.wym_tools_strong a { background-position: 0 -382px;} - .wym_skin_legacy .wym_buttons li.wym_tools_emphasis a { background-position: 0 -22px;} - .wym_skin_legacy .wym_buttons li.wym_tools_superscript a { background-position: 0 -430px;} - .wym_skin_legacy .wym_buttons li.wym_tools_subscript a { background-position: 0 -454px;} - .wym_skin_legacy .wym_buttons li.wym_tools_ordered_list a { background-position: 0 -48px;} - .wym_skin_legacy .wym_buttons li.wym_tools_unordered_list a{ background-position: 0 -72px;} - .wym_skin_legacy .wym_buttons li.wym_tools_indent a { background-position: 0 -574px;} - .wym_skin_legacy .wym_buttons li.wym_tools_outdent a { background-position: 0 -598px;} - .wym_skin_legacy .wym_buttons li.wym_tools_undo a { background-position: 0 -502px;} - .wym_skin_legacy .wym_buttons li.wym_tools_redo a { background-position: 0 -526px;} - .wym_skin_legacy .wym_buttons li.wym_tools_link a { background-position: 0 -96px;} - .wym_skin_legacy .wym_buttons li.wym_tools_unlink a { background-position: 0 -168px;} - .wym_skin_legacy .wym_buttons li.wym_tools_image a { background-position: 0 -121px;} - .wym_skin_legacy .wym_buttons li.wym_tools_table a { background-position: 0 -144px;} - .wym_skin_legacy .wym_buttons li.wym_tools_paste a { background-position: 0 -552px;} - .wym_skin_legacy .wym_buttons li.wym_tools_html a { background-position: 0 -193px;} - .wym_skin_legacy .wym_buttons li.wym_tools_preview a { background-position: 0 -408px;} - -/*DECORATION*/ - .wym_skin_legacy .wym_section h2 { background: #ddd; border: solid gray; border-width: 0 0 1px;} - .wym_skin_legacy .wym_section h2 span { color: gray;} - .wym_skin_legacy .wym_panel { padding: 0; border: solid gray; border-width: 1px; background: white;} - .wym_skin_legacy .wym_panel ul { margin: 2px 0 5px; } - .wym_skin_legacy .wym_dropdown { padding: 0; border: solid gray; border-width: 1px 1px 0 1px; } - .wym_skin_legacy .wym_dropdown ul { border: solid gray; border-width: 0 1px 1px 1px; margin-left: -1px; padding: 5px 10px 5px 3px;} - -/*DIALOGS*/ - .wym_dialog div.row { margin-bottom: 5px;} - .wym_dialog div.row input { margin-right: 5px;} - .wym_dialog div.row label { float: left; width: 120px; display: block; text-align: right; margin-right: 10px; } - .wym_dialog div.row-indent { padding-left: 160px; } - /*autoclearing*/ - .wym_dialog div.row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - .wym_dialog div.row { display: inline-block; } - /* Hides from IE-mac \*/ - * html .wym_dialog div.row { height: 1%; } - .wym_dialog div.row { display: block; } - /* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ - a.wym_wymeditor_link { text-indent: -9999px; float: right; display: block; width: 50px; height: 15px; background: url(../wymeditor_icon.png); overflow: hidden; text-decoration: none; } diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.header.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.header.gif deleted file mode 100644 index b2d2907bde..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.header.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.selector.silver.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.selector.silver.gif deleted file mode 100644 index e65976bdda..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.selector.silver.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.wymeditor.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.wymeditor.png deleted file mode 100644 index 1e84813f7e..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/bg.wymeditor.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/icons.silver.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/icons.silver.gif deleted file mode 100644 index 8c6a4fbfbe..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/images/icons.silver.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/skin.css deleted file mode 100644 index cea8d842cb..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/minimal/skin.css +++ /dev/null @@ -1,131 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * skin.css - * main stylesheet for the minimal WYMeditor skin - * See the documentation for more info. - * - * File Authors: - * Jean-Francois Hovinne - * Scott Lewis (see Silver skin) -*/ - -/* Set iframe */ -.wym_skin_minimal div.wym_iframe iframe { - width: 90%; - height: 200px; -} - -/* Hide h2 by default */ -.wym_skin_minimal h2 { - display: none; -} - -/* Show specific h2 */ -.wym_skin_minimal div.wym_tools h2, -.wym_skin_minimal div.wym_containers h2, -.wym_skin_minimal div.wym_classes h2 { - display: block; -} - -.wym_skin_minimal div.wym_section ul { - margin: 0; -} - -.wym_skin_minimal div.wym_section ul li { - float: left; - list-style-type: none; - margin-right: 5px; -} - -.wym_skin_minimal div.wym_area_top, -.wym_skin_minimal div.wym_area_right, -.wym_skin_minimal div.wym_containers, -.wym_skin_minimal div.wym_classes { - float: left; -} - -.wym_skin_minimal div.wym_area_main { - clear: both; -} - -.wym_skin_minimal div.wym_html { - width: 90%; -} - -.wym_skin_minimal textarea.wym_html_val { - width: 100%; - height: 100px; -} - -/* DROPDOWNS (see Silver skin) */ -.wym_skin_minimal div.wym_dropdown { - cursor: pointer; - margin: 0px 4px 10px 0px; - padding: 0px; - z-index: 1001; - display: block; -} - -.wym_skin_minimal div.wym_dropdown ul { - display: none; - width: 124px; - padding: 0px; - margin: 0px; - list-style-type: none; - list-style-image: none; - z-index: 1002; - position: absolute; - border-top: 1px solid #AAA; -} - -.wym_skin_minimal div.wym_dropdown ul li { - width: 146px; - height: 20px; - padding: 0px; - margin: 0px; - border: 1px solid #777; - border-top: none; - background: #EEE; - list-style-image: none; -} - -.wym_skin_minimal div.wym_dropdown h2 { - width: 138px; - height: 16px; - color: #000; - background-image: url(images/bg.selector.silver.gif); - background-position: 0px -18px; - background-repeat: no-repeat; - border: none; - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, Sanserif; - font-size: 12px; - font-weight: bold; - padding: 2px 0px 0px 10px; - margin: 0px; -} - -.wym_skin_minimal div.wym_dropdown a { - text-decoration: none; - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, Sanserif; - font-size: 12px; - padding: 5px 0px 0px 10px; - display: block; - width: 136px; - height: 15px; - color: #000; - text-align: left; - margin-left: 0px; -} - -.wym_skin_minimal div.wym_dropdown a:hover { - background: #BBB; - border-bottom: none; -} diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/icons.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/icons.png deleted file mode 100644 index c6eb463f11..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/icons.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/skin.css deleted file mode 100644 index c48d618565..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/seamless/skin.css +++ /dev/null @@ -1,306 +0,0 @@ -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ -.wym_skin_seamless p, -.wym_skin_seamless h2, -.wym_skin_seamless h3, -.wym_skin_seamless ul, -.wym_skin_seamless li { - background: transparent url(); - margin: 0; - padding: 0; - border-width: 0; - list-style: none; -} - -/*HIDDEN BY DEFAULT*/ -.wym_skin_seamless .wym_area_left { - display: none; -} -.wym_skin_seamless .wym_area_right { - display: block; -} - -/*TYPOGRAPHY*/ -.wym_skin_seamless { - font-size: 62.5%; - font-family: Verdana, Arial, sans-serif; -} -.wym_skin_seamless h2 { - font-size: 110%; /* = 11px */ -} -.wym_skin_seamless h3 { - font-size: 100%; /* = 10px */ -} -.wym_skin_seamless li { - font-size: 100%; /* = 10px */ -} - -/*WYM_BOX*/ -.wym_box { - margin: 0; - overflow: visible; - width: 98%; -} -.wym_skin_seamless { - border-style: none; - padding: 1px; -} - -/*WYM_HTML*/ -.wym_skin_seamless .wym_html { - width: 98%; -} -.wym_skin_seamless .wym_html textarea { - width: 100%; - height: 200px; - border: 1px solid gray; - background: white; -} - -/* Top controls */ -.wym_skin_seamless .wym_area_top { - width: 802px; - margin-left: auto; - margin-right: auto; - height: 24px; -} -.wym_skin_seamless .wym_area_top_affix_placeholder { - margin: 0px; - padding: 0px; -} -.wym_skin_seamless .affix { - position: fixed; - top: 0px; - width: 100%; - background: white; -} - -/*WYM_IFRAME*/ -.wym_skin_seamless .wym_iframe { - width: 802px; - margin-left: auto; - margin-right: auto; -} -.wym_skin_seamless .wym_iframe iframe { - width: 100%; - /* Don't set a height. That will be dynamic based on the content. */ - border-style: none; - background: white; - display: block; - vertical-align: bottom; -} - -/*AREAS*/ -.wym_skin_seamless .wym_area_left { - width: 150px; - float: left; -} -.wym_skin_seamless .wym_area_right { - width: 150px; - float: right; -} -.wym_skin_seamless .wym_area_bottom { - height: 1%; - clear: both; -} - -/*SECTIONS SYSTEM*/ -/*common defaults for all sections*/ -.wym_skin_seamless .wym_section { - margin-bottom: 5px; -} -.wym_skin_seamless .wym_section h2, -.wym_skin_seamless .wym_section h3 { - padding: 1px 3px; - margin: 0; -} -.wym_skin_seamless .wym_section a { - display: block; - text-decoration: none; - color: black; -} -.wym_skin_seamless .wym_section a:hover { - background-color: yellow; -} -/*hide section titles by default*/ -.wym_skin_seamless .wym_section h2 { - display: none; -} -/*disable any margin-collapse*/ -.wym_skin_seamless .wym_section { - padding-top: 1px; - padding-bottom: 1px; -} - -/*option: add this class to a section to make it render as a panel*/ -.wym_skin_seamless .wym_panel { -} -.wym_skin_seamless .wym_panel h2 { - display: block; -} - -/*option: add this class to a section to make it render as a dropdown menu*/ -.wym_skin_seamless .wym_dropdown { - padding: 0; - background: #ddd; - border: solid gray; - margin-right: 10px; - width: 110px; - float: left; - border-width: 1px 1px 1px 1px; -} -.wym_skin_seamless .wym_dropdown h2 { - display: block; - font-size: 2.0em; - line-height: 20px; -} -.wym_skin_seamless .wym_dropdown ul { - display: none; - position: absolute; - background: white; - font-size: 1.7em; - /* If there's a top margin, we hit a gap and break the hover - * when scrolling down */ - margin-top: 0px; - margin-left: -1px; - padding: 5px 10px 5px 3px; -} -.wym_skin_seamless .wym_dropdown:hover ul, -.wym_skin_seamless .wym_dropdown.hover ul { - display: block; -} -.wym_skin_seamless .wym_dropdown li { - width: 120px; -} - -/* option: add this class to a section to make its elements render buttons - (icons are only available for the wym_tools section for now) - */ -.wym_skin_seamless .wym_buttons { - margin-right: 5px; - float: left; -} -.wym_skin_seamless .wym_buttons li { - float:left; -} -.wym_skin_seamless .wym_buttons a { - width: 20px; - height: 20px; - overflow: hidden; - padding: 2px; -} -/*image replacements*/ -.wym_skin_seamless .wym_buttons li a { - background: url(icons.png) no-repeat; - text-indent: -9999px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_strong a { - background-position: 0 -382px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_emphasis a { - background-position: 0 -22px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_superscript a { - background-position: 0 -430px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_subscript a { - background-position: 0 -454px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_ordered_list a { - background-position: 0 -48px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_unordered_list a { - background-position: 0 -72px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_indent a { - background-position: 0 -574px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_outdent a { - background-position: 0 -598px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_undo a { - background-position: 0 -502px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_redo a { - background-position: 0 -526px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_link a { - background-position: 0 -96px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_unlink a { - background-position: 0 -168px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_image a { - background-position: 0 -121px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_table a { - background-position: 0 -144px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_paste a { - background-position: 0 -552px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_html a { - background-position: 0 -193px; -} -.wym_skin_seamless .wym_buttons li.wym_tools_preview a { - background-position: 0 -408px; -} - -/*DECORATION*/ -.wym_skin_seamless .wym_panel { - padding: 0; - border: solid gray; - border-width: 1px; - background: white; -} -.wym_skin_seamless .wym_panel ul { - margin: 2px 0 5px; -} - -/*DIALOGS*/ -.wym_dialog div.row { - margin-bottom: 5px; -} -.wym_dialog div.row input { - margin-right: 5px; -} -.wym_dialog div.row label { - float: left; - width: 120px; - display: block; - text-align: right; - margin-right: 10px; -} -.wym_dialog div.row-indent { - padding-left: 160px; -} -/*autoclearing*/ -.wym_dialog div.row:after { - content: "."; - display: block; - height: 0; - clear: both; - visibility: hidden; -} -.wym_dialog div.row { - display: inline-block; -} -/* Hides from IE-mac \*/ -* html .wym_dialog div.row { - height: 1%; -} -.wym_dialog div.row { - display: block; -} -/* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ -a.wym_wymeditor_link { - text-indent: -9999px; - float: right; - display: block; - width: 50px; - height: 15px; - background: url(../wymeditor_icon.png); - overflow: hidden; - text-decoration: none; -} diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.header.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.header.gif deleted file mode 100644 index b2d2907bde..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.header.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.selector.silver.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.selector.silver.gif deleted file mode 100644 index e65976bdda..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.selector.silver.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.wymeditor.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.wymeditor.png deleted file mode 100644 index 1e84813f7e..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/bg.wymeditor.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/icons.silver.gif b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/icons.silver.gif deleted file mode 100644 index 8c6a4fbfbe..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/images/icons.silver.gif and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/skin.css deleted file mode 100644 index 8284d81ba2..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/silver/skin.css +++ /dev/null @@ -1,297 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * screen.css - * main stylesheet for the default WYMeditor skin - * See the documentation for more info. - * - * File Authors: - * Daniel Reszka (d.reszka a-t wymeditor dotorg) - * Scott Edwin Lewis -*/ - -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ - .wym_skin_silver p, .wym_skin_silver h2, .wym_skin_silver h3, - .wym_skin_silver ul, .wym_skin_silver li { background: transparent url(); margin: 0; padding: 0; border-width:0; list-style: none; } - - -/*HIDDEN BY DEFAULT*/ - .wym_skin_silver .wym_area_left { display: none; } - .wym_skin_silver .wym_area_right { display: block; } - - -/*TYPO*/ - .wym_skin_silver { font-size: 62.5%; font-family: Verdana, Arial, sans-serif; } - .wym_skin_silver h2 { font-size: 110%; /* = 11px */} - .wym_skin_silver h3 { font-size: 100%; /* = 10px */} - .wym_skin_silver li { font-size: 100%; /* = 10px */} - - -/*WYM_BOX*/ - .wym_skin_silver { border: 1px solid gray; background: #f2f2f2; padding: 0px; margin: 0px;} - - /*auto-clear the wym_box*/ - .wym_skin_silver:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_silver { height: 1%;} - - -/*WYM_HTML*/ - .wym_skin_silver .wym_html { width: 98%;} - .wym_skin_silver .wym_html textarea { width: 100%; height: 200px; border: 1px solid gray; background: white; } - - -/*WYM_IFRAME*/ - .wym_skin_silver .wym_iframe { width: 98%;} - .wym_skin_silver .wym_iframe iframe { width: 100%; height: 200px; border: 1px solid gray; background: white } - - -/*AREAS*/ - .wym_skin_silver .wym_area_left { width: 150px; float: left;} - .wym_skin_silver .wym_area_right { width: 150px; float: right;} - .wym_skin_silver .wym_area_bottom { height: 1%; clear: both;} - * html .wym_skin_silver .wym_area_main { height: 1%;} - * html .wym_skin_silver .wym_area_top { height: 1%;} - *+html .wym_skin_silver .wym_area_top { height: 1%;} - -/*SECTIONS SYSTEM*/ - - /*common defaults for all sections*/ - .wym_skin_silver .wym_section { margin-bottom: 5px; } - .wym_skin_silver .wym_section h2, - .wym_skin_silver .wym_section h3 { padding: 1px 3px; margin: 0; cursor: pointer; } - .wym_skin_silver .wym_section a { padding: 5px 0px 0px 10px; display: block; text-decoration: none; color: black; } - .wym_skin_silver .wym_section a:hover { /*background-color: #DDD;*/} - /*hide section titles by default*/ - .wym_skin_silver .wym_section h2 { display: none; } - /*disable any margin-collapse*/ - .wym_skin_silver .wym_section { padding-top: 1px; padding-bottom: 1px; } - /*auto-clear sections*/ - .wym_skin_silver .wym_section ul:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; padding: 0px; } - * html .wym_skin_silver .wym_section ul { height: 1%;} - .wym_skin_silver .wym_section li {} - - /*option: add this class to a section to make it render as a panel*/ - .wym_skin_silver .wym_panel { } - .wym_skin_silver .wym_panel h2 { display: block; font-size: 11px; } - - /*option: add this class to a section to make it render as a dropdown menu*/ - .wym_skin_silver .wym_dropdown h2 { display: block; font-size: 11px;} - .wym_skin_silver .wym_dropdown ul { position: absolute; background: white; padding: 0px;} - .wym_skin_silver .wym_dropdown:hover ul, - .wym_skin_silver .wym_dropdown.hover ul { cursor: pointer;} - .wym_skin_silver .wym_dropdown ul li a {/*border-bottom: 1px solid #AAA;*/} - - /*option: add this class to a section to make its elements render buttons (icons are only available for the wym_tools section for now)*/ - .wym_skin_silver .wym_buttons li { float:left;} - .wym_skin_silver .wym_buttons a { width: 20px; height: 20px; overflow: hidden; padding: 2px; text-decoration: none !important; border: 1px solid #666; } - .wym_skin_silver .wym_buttons a:hover { text-decoration: none !important; border: 1px solid #000;} - /*image replacements*/ - .wym_skin_silver .wym_buttons li a { background: url(images/icons.silver.gif) no-repeat; text-indent: -9999px;} - .wym_skin_silver .wym_buttons li.wym_tools_strong a { background-position: 0 -384px;} - .wym_skin_silver .wym_buttons li.wym_tools_emphasis a { background-position: 0 -24px;} - .wym_skin_silver .wym_buttons li.wym_tools_superscript a { background-position: 0 -432px;} - .wym_skin_silver .wym_buttons li.wym_tools_subscript a { background-position: 0 -456px;} - .wym_skin_silver .wym_buttons li.wym_tools_ordered_list a { background-position: 0 -48px;} - .wym_skin_silver .wym_buttons li.wym_tools_unordered_list a{ background-position: 0 -72px;} - .wym_skin_silver .wym_buttons li.wym_tools_indent a { background-position: 0 -600px;} - .wym_skin_silver .wym_buttons li.wym_tools_outdent a { background-position: 0 -624px;} - .wym_skin_silver .wym_buttons li.wym_tools_undo a { background-position: 0 -504px;} - .wym_skin_silver .wym_buttons li.wym_tools_redo a { background-position: 0 -528px;} - .wym_skin_silver .wym_buttons li.wym_tools_link a { background-position: 0 -96px;} - .wym_skin_silver .wym_buttons li.wym_tools_unlink a { background-position: 0 -168px;} - .wym_skin_silver .wym_buttons li.wym_tools_image a { background-position: 0 -120px;} - .wym_skin_silver .wym_buttons li.wym_tools_table a { background-position: 0 -144px;} - .wym_skin_silver .wym_buttons li.wym_tools_paste a { background-position: 0 -552px;} - .wym_skin_silver .wym_buttons li.wym_tools_html a { background-position: 0 -192px;} - .wym_skin_silver .wym_buttons li.wym_tools_preview a { background-position: 0 -408px;} - .wym_skin_silver .wym_buttons li.wym_tools_gadget a { background-position: 0 -576px;} - - .wym_skin_silver .wym_buttons li.wym_tools_strong a:hover { background-position: -24px -384px;} - .wym_skin_silver .wym_buttons li.wym_tools_emphasis a:hover { background-position: -24px -24px;} - .wym_skin_silver .wym_buttons li.wym_tools_superscript a:hover { background-position: -24px -432px;} - .wym_skin_silver .wym_buttons li.wym_tools_subscript a:hover { background-position: -24px -456px;} - .wym_skin_silver .wym_buttons li.wym_tools_ordered_list a:hover { background-position: -24px -48px;} - .wym_skin_silver .wym_buttons li.wym_tools_unordered_list a:hover{ background-position: -24px -72px;} - .wym_skin_silver .wym_buttons li.wym_tools_indent a:hover { background-position: -24px -600px;} - .wym_skin_silver .wym_buttons li.wym_tools_outdent a:hover { background-position: -24px -624px;} - .wym_skin_silver .wym_buttons li.wym_tools_undo a:hover { background-position: -24px -504px;} - .wym_skin_silver .wym_buttons li.wym_tools_redo a:hover { background-position: -24px -528px;} - .wym_skin_silver .wym_buttons li.wym_tools_link a:hover { background-position: -24px -96px;} - .wym_skin_silver .wym_buttons li.wym_tools_unlink a:hover { background-position: -24px -168px;} - .wym_skin_silver .wym_buttons li.wym_tools_image a:hover { background-position: -24px -120px;} - .wym_skin_silver .wym_buttons li.wym_tools_table a:hover { background-position: -24px -144px;} - .wym_skin_silver .wym_buttons li.wym_tools_paste a:hover { background-position: -24px -552px;} - .wym_skin_silver .wym_buttons li.wym_tools_html a:hover { background-position: -24px -192px;} - .wym_skin_silver .wym_buttons li.wym_tools_preview a:hover { background-position: -24px -408px;} - .wym_skin_silver .wym_buttons li.wym_tools_gadget a:hover { background-position: -24px -576px;} - -/*DECORATION*/ - .wym_skin_silver .wym_section h2 { background: #ddd; border: none;} - .wym_skin_silver .wym_section h2 span { color: gray;} - .wym_skin_silver .wym_panel { padding: 0; border: solid gray; border-width: 0px;} - .wym_skin_silver .wym_panel ul { margin: 2px 0 5px; } - .wym_skin_silver .wym_dropdown { padding: 0; border: none; } - .wym_skin_silver .wym_dropdown ul { border: none; margin-left: -1px; padding: 0px;} - -/*DIALOGS*/ - .wym_dialog div.row { margin-bottom: 5px;} - .wym_dialog div.row input { margin-right: 5px;} - .wym_dialog div.row label { float: left; width: 150px; display: block; text-align: right; margin-right: 10px; } - .wym_dialog div.row-indent { padding-left: 160px; } - /*autoclearing*/ - .wym_dialog div.row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - .wym_dialog div.row { display: inline-block; } - /* Hides from IE-mac \*/ - * html .wym_dialog div.row { height: 1%; } - .wym_dialog div.row { display: block; } - /* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ - a.wym_wymeditor_link - { - text-indent: -9999px; - float: right; - display: block; - width: 50px; - height: 15px; - background: url(../wymeditor_icon.png); - background-position: 1px 1px; - background-repeat: no-repeat; - overflow: hidden; - text-decoration: none; - padding: 1px !important; - border: 1px solid #333 !important; - background-color: #FFF !important; - } - -.wym_box -{ - padding: 0px !important; - margin: 0px; -} -.wym_inner -{ - border-left: 1px solid #FFF; - border-top: 1px solid #FFF; - border-right: 1px solid #FFF; - border-bottom: 1px solid #FFF; - padding: 5px; - background-color: #B8C1C4; - height: auto; -} - -.clear {clear: both;} - -div.wym_dropdown -{ - cursor: pointer; - width: 138px !important; - margin: 0px 4px 10px 0px !important; - padding: 0px; - z-index: 1001; - display: block; - border: 1px solid red; -} - -div.wym_dropdown ul -{ - display: none; - width: 124px; - padding: 0px !important; - margin: 0px !important; - list-style-type: none; - list-style-image: none; - z-index: 1002; - position: absolute; - border-top: 1px solid #AAA; -} - -div.wym_dropdown ul li -{ - width: 146px; - height: 20px; - padding: 0px !important; - margin: 0px; - border: 1px solid #777; - border-top: none; - background: #DDD; - list-style-image: none; -} - -div.wym_dropdown h2 -{ - width: 138px; - height: 16px; - color: #000 !important; - background-image: url(images/bg.selector.silver.gif) !important; - background-position: 0px -18px; - background-repeat: no-repeat; - border: none; - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, Sanserif; - font-size: 12px !important; - font-weight: bold !important; - padding: 2px 0px 0px 10px !important; - margin: 0px !important; -} - -.wym_skin_silver .wym_panel h2 -{ - width: 138px; - height: 16px; - color: #000 !important; - background-image: url(images/bg.header.gif) !important; - background-position: 0px 0px; - background-repeat: no-repeat; - border: none; - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, Sanserif; - font-size: 12px !important; - font-weight: bold !important; - padding: 2px 0px 0px 10px !important; - margin: 0px !important; -} - -.wym_skin_silver .wym_panel ul -{ - margin-top: 0px !important; -} - -.wym_skin_silver .wym_panel ul li -{ - width: 146px; - height: 20px; - padding: 0px !important; - margin: 0px; - border: 1px solid #777; - border-top: none; - background: #DDD; - list-style-image: none; -} - -.wym_skin_silver .wym_panel a, -div.wym_dropdown a -{ - text-decoration: none; - font-family: "Trebuchet MS", Verdana, Arial, Helvetica, Sanserif; - font-size: 12px; - padding: 5px 0px 0px 10px !important; - display: block; - width: 136px; - height: 15px; - color: #000; - text-align: left !important; - margin-left: 0px !important; -} - -div.wym_dropdown a:hover, -.wym_skin_silver .wym_panel a:hover -{ - background: #BBB; - border-bottom: none !important; -} diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/icons.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/icons.png deleted file mode 100644 index c6eb463f11..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/icons.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/skin.css b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/skin.css deleted file mode 100644 index 7e6b8fda2f..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/twopanels/skin.css +++ /dev/null @@ -1,134 +0,0 @@ -/* - * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ - * Dual licensed under the MIT (MIT-license.txt) - * and GPL (GPL-license.txt) licenses. - * - * For further information visit: - * http://www.wymeditor.org/ - * - * File Name: - * screen.css - * main stylesheet for the WYMeditor skin - * See the documentation for more info. - * - * File Authors: - * Daniel Reszka (d.reszka a-t wymeditor dotorg) - * Jean-Francois Hovinne -*/ - -/*TRYING TO RESET STYLES THAT MAY INTERFERE WITH WYMEDITOR*/ - .wym_skin_twopanels p, .wym_skin_twopanels h2, .wym_skin_twopanels h3, - .wym_skin_twopanels ul, .wym_skin_twopanels li { background: transparent url(); margin: 0; padding: 0; border-width:0; list-style: none; } - - -/*HIDDEN BY DEFAULT*/ - .wym_skin_twopanels .wym_area_left { display: block; } - .wym_skin_twopanels .wym_area_right { display: block; } - - -/*TYPO*/ - .wym_skin_twopanels { font-size: 62.5%; font-family: Verdana, Arial, sans-serif; } - .wym_skin_twopanels h2 { font-size: 110%; /* = 11px */} - .wym_skin_twopanels h3 { font-size: 100%; /* = 10px */} - .wym_skin_twopanels li { font-size: 100%; /* = 10px */} - - -/*WYM_BOX*/ - .wym_skin_twopanels { border: 1px solid gray; background: #f2f2f2; padding: 5px} - - /*auto-clear the wym_box*/ - .wym_skin_twopanels:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_twopanels { height: 1%;} - - -/*WYM_HTML*/ - .wym_skin_twopanels .wym_html { width: 98%;} - .wym_skin_twopanels .wym_html textarea { width: 100%; height: 200px; border: 1px solid gray; background: white; } - - -/*WYM_IFRAME*/ - .wym_skin_twopanels .wym_iframe { width: 98%;} - .wym_skin_twopanels .wym_iframe iframe { width: 100%; height: 200px; border: 1px solid gray; background: white } - - -/*AREAS*/ - .wym_skin_twopanels .wym_area_left { width: 100px; float: left;} - .wym_skin_twopanels .wym_area_right { width: 150px; float: right;} - .wym_skin_twopanels .wym_area_bottom { height: 1%; clear: both;} - * html .wym_skin_twopanels .wym_area_main { height: 1%;} - * html .wym_skin_twopanels .wym_area_top { height: 1%;} - *+html .wym_skin_twopanels .wym_area_top { height: 1%;} - -/*SECTIONS SYSTEM*/ - - /*common defaults for all sections*/ - .wym_skin_twopanels .wym_section { margin-bottom: 5px; } - .wym_skin_twopanels .wym_section h2, - .wym_skin_twopanels .wym_section h3 { padding: 1px 3px; margin: 0; } - .wym_skin_twopanels .wym_section a { padding: 0 3px; display: block; text-decoration: none; color: black; } - .wym_skin_twopanels .wym_section a:hover { background-color: yellow; } - /*hide section titles by default*/ - .wym_skin_twopanels .wym_section h2 { display: none; } - /*disable any margin-collapse*/ - .wym_skin_twopanels .wym_section { padding-top: 1px; padding-bottom: 1px; } - /*auto-clear sections*/ - .wym_skin_twopanels .wym_section ul:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - * html .wym_skin_twopanels .wym_section ul { height: 1%;} - - /*option: add this class to a section to make it render as a panel*/ - .wym_skin_twopanels .wym_panel { } - .wym_skin_twopanels .wym_panel h2 { display: block; } - - /*option: add this class to a section to make it render as a dropdown menu*/ - .wym_skin_twopanels .wym_dropdown h2 { display: block; } - .wym_skin_twopanels .wym_dropdown ul { display: none; position: absolute; background: white; } - .wym_skin_twopanels .wym_dropdown:hover ul, - .wym_skin_twopanels .wym_dropdown.hover ul { display: block; } - - /*option: add this class to a section to make its elements render buttons (icons are only available for the wym_tools section for now)*/ - .wym_skin_twopanels .wym_buttons li { float:left;} - .wym_skin_twopanels .wym_buttons a { width: 20px; height: 20px; overflow: hidden; padding: 2px } - /*image replacements*/ - .wym_skin_twopanels .wym_buttons li a { background: url(icons.png) no-repeat; text-indent: -9999px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_strong a { background-position: 0 -382px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_emphasis a { background-position: 0 -22px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_superscript a { background-position: 0 -430px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_subscript a { background-position: 0 -454px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_ordered_list a { background-position: 0 -48px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_unordered_list a{ background-position: 0 -72px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_indent a { background-position: 0 -574px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_outdent a { background-position: 0 -598px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_undo a { background-position: 0 -502px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_redo a { background-position: 0 -526px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_link a { background-position: 0 -96px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_unlink a { background-position: 0 -168px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_image a { background-position: 0 -121px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_table a { background-position: 0 -144px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_paste a { background-position: 0 -552px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_html a { background-position: 0 -193px;} - .wym_skin_twopanels .wym_buttons li.wym_tools_preview a { background-position: 0 -408px;} - -/*DECORATION*/ - .wym_skin_twopanels .wym_section h2 { background: #ddd; border: solid gray; border-width: 0 0 1px;} - .wym_skin_twopanels .wym_section h2 span { color: gray;} - .wym_skin_twopanels .wym_panel { padding: 0; border: solid gray; border-width: 1px; background: white;} - .wym_skin_twopanels .wym_panel ul { margin: 2px 0 5px; } - .wym_skin_twopanels .wym_dropdown { padding: 0; border: solid gray; border-width: 1px 1px 0 1px; } - .wym_skin_twopanels .wym_dropdown ul { border: solid gray; border-width: 0 1px 1px 1px; margin-left: -1px; padding: 5px 10px 5px 3px;} - -/*DIALOGS*/ - .wym_dialog div.row { margin-bottom: 5px;} - .wym_dialog div.row input { margin-right: 5px;} - .wym_dialog div.row label { float: left; width: 150px; display: block; text-align: right; margin-right: 10px; } - .wym_dialog div.row-indent { padding-left: 160px; } - /*autoclearing*/ - .wym_dialog div.row:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } - .wym_dialog div.row { display: inline-block; } - /* Hides from IE-mac \*/ - * html .wym_dialog div.row { height: 1%; } - .wym_dialog div.row { display: block; } - /* End hide from IE-mac */ - -/*WYMEDITOR_LINK*/ - a.wym_wymeditor_link { text-indent: -9999px; float: right; display: block; width: 50px; height: 15px; background: url(../wymeditor_icon.png); overflow: hidden; text-decoration: none; } diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/wymeditor_icon.png b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/wymeditor_icon.png deleted file mode 100644 index d4fc155fd9..0000000000 Binary files a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/wymeditor/skins/wymeditor_icon.png and /dev/null differ diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/xml-c14n-sync.js b/src/main/webapp/static/com/atomgraph/linkeddatahub/js/xml-c14n-sync.js deleted file mode 100644 index d74806aa00..0000000000 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/js/xml-c14n-sync.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{var e={237:(e,t,n)=>{var r=n(291),i={algorithms:{"http://www.w3.org/2001/10/xml-exc-c14n#":function(e){return new r(e)},"http://www.w3.org/2001/10/xml-exc-c14n#WithComments":function(e){return(e=Object.create(e||null)).includeComments=!0,new r(e)}}},o=e.exports=function e(){if(!(this instanceof e))return new e;this.algorithms=Object.create(i.algorithms)};o.prototype.registerAlgorithm=function(e,t){return this.algorithms[e]=t,this},o.prototype.getAlgorithm=function(e){return this.algorithms[e]},o.prototype.createCanonicaliser=function(e,t){return this.algorithms[e](t)}},936:e=>{var t=e.exports=function(e){};t.prototype.name=function(){return null},t.prototype.canonicalise=function(e,t){setImmediate((function(){return t(Error("not implemented"))}))},t.prototype.canonicaliseSync=function(e){throw Error("not implemented")}},291:(e,t,n)=>{var r=n(418),i=n(936),o=e.exports=function(e){i.call(this,e),e=e||{},this.includeComments=!!e.includeComments,this.inclusiveNamespaces=e.inclusiveNamespaces||[]};o.prototype=Object.create(i.prototype,{constructor:{value:o}}),o.prototype.name=function(){return"http://www.w3.org/2001/10/xml-exc-c14n#"+(this.includeComments?"WithComments":"")},o.prototype.canonicalise=function(e,t){var n=this;setImmediate((function(){try{var r=n._processInner(e)}catch(e){return t(e)}return t(null,r)}))},o.prototype.canonicaliseSync=function(e){return this._processInner(e)},o.prototype.getIncludeComments=function(){return!!this.includeComments},o.prototype.setIncludeComments=function(e){this.includeComments=!!e},o.prototype.getInclusiveNamespaces=function(){return this.inclusiveNamespaces.slice()},o.prototype.setInclusiveNamespaces=function(e){return this.inclusiveNamespaces=e.slice(),this},o.prototype.addInclusiveNamespace=function(e){return this.inclusiveNamespaces.push(e),this};var s=function(e,t){return!e.prefix&&t.prefix?-1:!t.prefix&&e.prefix?1:e.name.localeCompare(t.name)},a=function(e,t){var n=e.prefix+e.namespaceURI,r=t.prefix+t.namespaceURI;return n===r?0:n.localeCompare(r)};o.prototype._renderAttributes=function(e){return(e.attributes?[].slice.call(e.attributes):[]).filter((function(e){return 0!==e.name.indexOf("xmlns")})).sort(s).map((function(e){return" "+e.name+'="'+r.attributeEntities(e.value)+'"'})).join("")},o.prototype._renderNamespace=function(e,t,n){var i="",o=n,s=t.slice(),c=[],u=e.namespaceURI||"";if(e.prefix){if((m=s.filter((function(t){return t.prefix===e.prefix})).shift())&&m.namespaceURI!==e.namespaceURI){for(var p=0;p"+(t?"\n":"")},o.prototype._processInner=function(e,t,n){if(n=n||"",t=t||[],3===e.nodeType)return e.ownerDocument===e.parentNode?r.textEntities(e.data.trim()):r.textEntities(e.data);if(7===e.nodeType)return this._renderProcessingInstruction(e);if(8===e.nodeType)return this.includeComments?this._renderComment(e):"";if(10===e.nodeType)return"";var i=this._renderNamespace(e,t,n),o=this;return[e.tagName?"<"+e.tagName+i.rendered+this._renderAttributes(e)+">":"",[].slice.call(e.childNodes).map((function(e){return o._processInner(e,i.newPrefixesInScope,i.newDefaultNamespace)})).join(""),e.tagName?"":""].join("")}},418:(e,t)=>{var n=t.entities={"&":"&",'"':""","<":"<",">":">","\t":" ","\n":" ","\r":" "};t.attributeEntities=function(e){return e.replace(/([\&<"\t\n\r])/g,(function(e){return n[e]}))},t.textEntities=function(e){return e.replace(/([\&<>\r])/g,(function(e){return n[e]}))}}},t={},n=function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}(237);window["xml-c14n-sync.js"]=n})(); \ No newline at end of file diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/3d-force-graph.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/3d-force-graph.xsl index a0a1e19ebe..965cad1522 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/3d-force-graph.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/3d-force-graph.xsl @@ -341,7 +341,7 @@ - + @@ -393,7 +393,7 @@ - + @@ -405,7 +405,7 @@ - + @@ -428,7 +428,7 @@ - + @@ -471,7 +471,7 @@ select="if (string-length($literal-value) gt $ldh:literal-label-max-length) then substring($literal-value, 1, $ldh:literal-label-max-length) || '…' else $literal-value"/> - + @@ -492,7 +492,7 @@ select="if (string-length($literal-value) gt $ldh:literal-label-max-length) then substring($literal-value, 1, $ldh:literal-label-max-length) || '…' else $literal-value"/> - + @@ -506,7 +506,7 @@ - + @@ -555,7 +555,7 @@ - + @@ -573,7 +573,7 @@ - + @@ -591,7 +591,7 @@ - + @@ -608,7 +608,7 @@ - + @@ -627,7 +627,7 @@ else if (@rdf:nodeID) then string(@rdf:nodeID) else generate-id(.)"/> - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/admin/signup.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/admin/signup.xsl index e0d56de28c..eee3472da6 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/admin/signup.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/admin/signup.xsl @@ -76,7 +76,7 @@ exclude-result-prefixes="#all"> -
            +
            @@ -91,8 +91,8 @@ exclude-result-prefixes="#all"> - - + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl index 9cb2569592..0e3e66679e 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl @@ -70,42 +70,46 @@ exclude-result-prefixes="#all" } ]]> - + + PREFIX rdf: DELETE { - $this ?sourceSeq $sourceBlock . - $this ?targetSeq $targetBlock . - $this ?seq ?block . + ?doc ?sourceSeq ?source . + ?doc ?targetSeq ?target . + ?doc ?seq ?block . } INSERT { - $this ?newSourceSeq $sourceBlock . - $this ?newTargetSeq $targetBlock . - $this ?newSeq ?block . + ?doc ?newSourceSeq ?source . + ?doc ?newTargetSeq ?target . + ?doc ?newSeq ?block . } WHERE - { $this ?sourceSeq $sourceBlock - FILTER(strstarts(str(?sourceSeq), concat(str(rdf:), "_"))) - BIND(xsd:integer(substr(str(?sourceSeq), 45)) AS ?sourceIndex) - $this ?targetSeq $targetBlock - FILTER(strstarts(str(?targetSeq), concat(str(rdf:), "_"))) - BIND(xsd:integer(substr(str(?targetSeq), 45)) AS ?targetIndex) + { VALUES (?doc ?source ?target) { ($doc $source $target) } + ?doc ?sourceSeq ?source + FILTER(strstarts(str(?sourceSeq), str(rdf:_))) + BIND(xsd:integer(strafter(str(?sourceSeq), str(rdf:_))) AS ?sourceIndex) + ?doc ?targetSeq ?target + FILTER(strstarts(str(?targetSeq), str(rdf:_))) + BIND(xsd:integer(strafter(str(?targetSeq), str(rdf:_))) AS ?targetIndex) BIND(if(( ?sourceIndex < ?targetIndex ), ( ?targetIndex - 1 ), ?targetIndex) AS ?newTargetIndex) BIND(if(( ?sourceIndex < ?targetIndex ), ?targetIndex, ( ?targetIndex + 1 )) AS ?newSourceIndex) BIND(IRI(concat(str(rdf:), "_", str(?newSourceIndex))) AS ?newSourceSeq) BIND(IRI(concat(str(rdf:), "_", str(?newTargetIndex))) AS ?newTargetSeq) OPTIONAL - { $this ?sourceSeq $sourceBlock - FILTER(strstarts(str(?sourceSeq), concat(str(rdf:), "_"))) - BIND(xsd:integer(substr(str(?sourceSeq), 45)) AS ?sourceIndex) - $this ?targetSeq $targetBlock - FILTER(strstarts(str(?targetSeq), concat(str(rdf:), "_"))) - BIND(xsd:integer(substr(str(?targetSeq), 45)) AS ?targetIndex) - $this ?seq ?block - FILTER strstarts(str(?seq), str(rdf:_)) - BIND(xsd:integer(substr(str(?seq), 45)) AS ?index) + { ?doc ?sourceSeq ?source + FILTER(strstarts(str(?sourceSeq), str(rdf:_))) + BIND(xsd:integer(strafter(str(?sourceSeq), str(rdf:_))) AS ?sourceIndex) + ?doc ?targetSeq ?target + FILTER(strstarts(str(?targetSeq), str(rdf:_))) + BIND(xsd:integer(strafter(str(?targetSeq), str(rdf:_))) AS ?targetIndex) + ?doc ?seq ?block + FILTER(strstarts(str(?seq), str(rdf:_))) + BIND(xsd:integer(strafter(str(?seq), str(rdf:_))) AS ?index) BIND(( ( ?index > ?sourceIndex ) && ( ?index < ?targetIndex ) ) AS ?isBetweenSourceAndTarget) BIND(( ( ?index < ?sourceIndex ) && ( ?index > ?targetIndex ) ) AS ?isBetweenTargetAndSource) FILTER ( ?isBetweenSourceAndTarget || ?isBetweenTargetAndSource ) @@ -178,16 +182,14 @@ exclude-result-prefixes="#all" - + @@ -267,80 +269,65 @@ exclude-result-prefixes="#all" - - - - - - - - - - + - - - - - + + - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + @@ -431,16 +417,12 @@ exclude-result-prefixes="#all" - + - - - - @@ -510,130 +492,141 @@ exclude-result-prefixes="#all" + + - - + + + + + - - + + - - - - - - - + + + + + + - - - - + + + - - - - - - - - - - - + + + + + - - + - + - - - - - - - - - - + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -773,8 +766,7 @@ exclude-result-prefixes="#all" - - + @@ -784,7 +776,7 @@ exclude-result-prefixes="#all" - + @@ -989,7 +981,7 @@ exclude-result-prefixes="#all" - + @@ -1082,20 +1074,30 @@ exclude-result-prefixes="#all" - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/chart.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/chart.xsl index 0f2976dd47..03eaf7e61a 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/chart.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/chart.xsl @@ -118,6 +118,11 @@ exclude-result-prefixes="#all" + + + + + @@ -126,17 +131,30 @@ exclude-result-prefixes="#all" - - - + + + + + + + + + + + + + + + + - - + + - - + + @@ -162,96 +180,6 @@ exclude-result-prefixes="#all" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -262,24 +190,9 @@ exclude-result-prefixes="#all" - - - - - -
            - -
            -
            @@ -306,9 +219,6 @@ exclude-result-prefixes="#all" 'container': $container, 'container-id': $container-id, 'method': $method, - 'action': $action, - 'accept-charset': $accept-charset, - 'enctype': $enctype, 'chart-type-id': $chart-type-id, 'category-id': $category-id, 'series-id': $series-id, @@ -318,7 +228,6 @@ exclude-result-prefixes="#all" 'series': $series, 'canvas-id': $canvas-id, 'canvas-class': $canvas-class, - 'form-actions': $form-actions, 'cache': $cache }"/> @@ -370,107 +279,41 @@ exclude-result-prefixes="#all" - - - - + + + + + + ldh:render-chart - + -
            - - - - - - - -
            -
            -
            - - - -
            -
            - - -
            -
            - - -
            -
            -
            - -
            - - - - - - -
            - - - - -
            + + + + + + + + + + +
            - + @@ -879,11 +722,19 @@ exclude-result-prefixes="#all" - - - - - + + + + + + + + + + + + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/object.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/object.xsl index 173b274e9f..c7e1308d30 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/object.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/object.xsl @@ -222,7 +222,7 @@ exclude-result-prefixes="#all" -
            +
            @@ -300,7 +300,7 @@ exclude-result-prefixes="#all" -
            +
            diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl index a1944e0e3a..9e8ddf0566 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl @@ -114,7 +114,7 @@ exclude-result-prefixes="#all" - + @@ -171,12 +171,12 @@ exclude-result-prefixes="#all" ldh:render-query - + -
            +
            @@ -223,22 +223,22 @@ exclude-result-prefixes="#all" -
            +
            - -
            @@ -321,6 +324,7 @@ exclude-result-prefixes="#all" + @@ -359,6 +363,7 @@ exclude-result-prefixes="#all" map { 'request': $request, 'container': ., + 'container-id': $container-id, 'count-var-name': $count-var-name, 'cache': $cache }"/> @@ -372,43 +377,134 @@ exclude-result-prefixes="#all" - + + + - + -
              - - -
            + +
            +
            + + + + + + + + + + + +
            + +
            + + +
            +
            + +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            + + +
            + + + + + + / + +
            @@ -429,19 +525,19 @@ exclude-result-prefixes="#all"
            -
            +
            - +
            - + @@ -504,8 +600,10 @@ exclude-result-prefixes="#all" + + - + @@ -514,6 +612,23 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + @@ -536,6 +651,42 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -545,10 +696,16 @@ exclude-result-prefixes="#all" + + + + + + @@ -558,6 +715,10 @@ exclude-result-prefixes="#all" + + + + @@ -723,42 +884,60 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + + @@ -810,94 +989,123 @@ exclude-result-prefixes="#all" - - - +
            +
            + + + + + + + + + + +
            +
            + + + + + + + -
            - - - -
            + + + + + + + - - - - - -
            - + + +
            -
            +
            -
            -

            + +

            + + + + + + + +
            +
            +
            @@ -923,6 +1131,9 @@ exclude-result-prefixes="#all" + + + @@ -937,6 +1148,7 @@ exclude-result-prefixes="#all" + @@ -954,6 +1166,9 @@ exclude-result-prefixes="#all" + + + @@ -979,6 +1194,7 @@ exclude-result-prefixes="#all" + @@ -1020,7 +1236,7 @@ exclude-result-prefixes="#all" - +
            @@ -1035,125 +1251,243 @@ exclude-result-prefixes="#all" + + - - - - - - +
            + +
            - + + +
            - - - + + -
            - - - - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + - + +
            + + + + + - - - + + + + + + - - - + +
            - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - - - - - - - -
            -
              - -
            + + + + + + + + + + + +
            + {ac:label($subject)} +
            +
            + +
            + +
            +
            +
            +
            + + + + + + + + +
            - +
            - + + + + +
            + + +
            + {ac:label(.)} +
            +
            + +
            + +
            +
            +
            +
            + + + + + + + + + +
            +
            +
            + + + - - - - - - +
            + +
            - + + +
            - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1163,162 +1497,61 @@ exclude-result-prefixes="#all" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            - - - - - - - - - - -
            -
            - - - - - - - BLOCK DELEGATION: view-mode handler triggered - - - BLOCK DELEGATION: block URI = - - BLOCK DELEGATION: cache found: - - - - - - - - - - BLOCK DELEGATION: pager previous triggered - - - BLOCK DELEGATION: block URI = - - BLOCK DELEGATION: cache found: - - - - - - - - - - BLOCK DELEGATION: pager next triggered - - - BLOCK DELEGATION: block URI = - - BLOCK DELEGATION: cache found: - - - - - - - + + + + + + + - - BLOCK DELEGATION: container-order triggered - - - BLOCK DELEGATION: block URI = - - BLOCK DELEGATION: cache found: + + + + - - - + + + + + + + + + + + - - - - - BLOCK DELEGATION: btn-order-by triggered - - - BLOCK DELEGATION: block URI = - - BLOCK DELEGATION: cache found: + + + - - - - + + + + + - + - + - + @@ -1353,14 +1586,14 @@ exclude-result-prefixes="#all" - + - + - + @@ -1394,16 +1627,59 @@ exclude-result-prefixes="#all" on-failure="ldh:promise-failure#1"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -1440,13 +1716,13 @@ exclude-result-prefixes="#all" - + - + @@ -1483,11 +1759,75 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + @@ -1496,13 +1836,13 @@ exclude-result-prefixes="#all" - - - + + + - - - + + + @@ -1528,23 +1868,46 @@ exclude-result-prefixes="#all" - - - + + - - + + + + + + + + + + + + + + + + + + + + @@ -1630,19 +1993,37 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + + + + - - - - + + + - @@ -1651,12 +2032,11 @@ exclude-result-prefixes="#all" - - - - - - + + + + + @@ -1672,7 +2052,7 @@ exclude-result-prefixes="#all" - + - - - - - - + + + + + - + @@ -1699,16 +2078,102 @@ exclude-result-prefixes="#all" - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1720,7 +2185,7 @@ exclude-result-prefixes="#all" - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1959,24 +2450,22 @@ exclude-result-prefixes="#all" - - + + - + - - - - - - - - - + + + + + + + @@ -2060,11 +2549,11 @@ exclude-result-prefixes="#all" - + -
          28. - - + + + @@ -2086,14 +2575,14 @@ exclude-result-prefixes="#all" - -
          29. + +
            - + - - + + @@ -2124,47 +2613,37 @@ exclude-result-prefixes="#all" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + +
          30. + +
          31. +
            +
            +
            +
            - - -
            - Error during query execution: -
            -                                    
            -                                
            -
            + + +
          32. +
            + Error during query execution: +
            +                                        
            +                                    
            +
            +
          33. @@ -2219,7 +2710,7 @@ exclude-result-prefixes="#all" - + @@ -2279,6 +2770,27 @@ exclude-result-prefixes="#all" + + + + + + + + + + + + + + + + + + + + +
            @@ -2372,7 +2884,8 @@ exclude-result-prefixes="#all" - + + @@ -2417,24 +2930,20 @@ exclude-result-prefixes="#all" - + - + - - - - @@ -2539,18 +3048,17 @@ exclude-result-prefixes="#all" - ldh:refresh-view block-id: '' matched views: + ldh:refresh-view block-id: '' matched views: - + - - - ldh:refresh-view block URI: cache found: + + ldh:refresh-view cache found: - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/constructor.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/constructor.xsl index 3eb915b80f..73000e6977 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/constructor.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/constructor.xsl @@ -119,7 +119,7 @@ exclude-result-prefixes="#all" @@ -418,10 +400,10 @@ WHERE
            - - - - + + + +
            @@ -465,8 +447,8 @@ WHERE
            - - + +
            @@ -493,10 +475,12 @@ WHERE - + - + @@ -504,6 +488,21 @@ WHERE + + + + + + + + + + + + + @@ -529,11 +528,11 @@ WHERE -
            -
            -
            +
            +
            +
            - Signup complete + check_circle

            Congratulations! Your WebID profile has been created. You can see its data below.

            @@ -649,7 +648,10 @@ WHERE - + + + + @@ -841,29 +843,36 @@ WHERE - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - + - + @@ -875,17 +884,9 @@ WHERE + - - - - - - - - - - + @@ -893,18 +894,30 @@ WHERE - + + + - - - - - - - - + +
            + + + + +
            + + + + + + + + + +
            +
            @@ -917,7 +930,7 @@ WHERE - + @@ -928,6 +941,7 @@ WHERE + @@ -951,7 +965,8 @@ WHERE - + + @@ -999,7 +1014,7 @@ WHERE - + @@ -1022,7 +1037,7 @@ WHERE - + @@ -1045,10 +1060,6 @@ WHERE - - - - @@ -1097,7 +1108,7 @@ WHERE - + @@ -1115,10 +1126,6 @@ WHERE - - - - @@ -1149,8 +1156,7 @@ WHERE - + @@ -1158,12 +1164,14 @@ WHERE + + - - + + @@ -1212,7 +1220,7 @@ WHERE - + @@ -1220,14 +1228,16 @@ WHERE 'property-control-group': $property-control-group, 'fieldset': $fieldset, 'property-uri': $property-uri, - 'forClass': $forClass + 'forClass': $forClass, + 'types': $forClass }"/> + @@ -1237,23 +1247,25 @@ WHERE - + - - + + + - - + + - + @@ -1648,7 +1662,7 @@ WHERE - + @@ -1785,9 +1799,9 @@ WHERE - + - + @@ -1848,7 +1862,7 @@ WHERE - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl index 54ec483960..f271baa67b 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/functions.xsl @@ -110,10 +110,15 @@ exclude-result-prefixes="#all" - - - - + + + + + + + + @@ -422,22 +427,6 @@ exclude-result-prefixes="#all"
            - - - - - - - - - - - + + + + + + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/graph3d.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/graph3d.xsl index 3ccab50832..c6fb238f85 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/graph3d.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/graph3d.xsl @@ -476,8 +476,8 @@ WHERE
            - - + + @@ -496,7 +496,7 @@ WHERE - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/map.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/map.xsl index 8c2a464333..b9a9f67b79 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/map.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/map.xsl @@ -414,6 +414,8 @@ exclude-result-prefixes="#all" + + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/memento.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/memento.xsl index d47426ee93..c9c54a821f 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/memento.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/memento.xsl @@ -68,7 +68,7 @@ version="3.0" - + @@ -101,7 +101,7 @@ version="3.0"
            - +
            @@ -146,22 +146,23 @@ version="3.0"
            -
            -
            +
            Could not load the version history
            @@ -271,7 +272,7 @@ version="3.0" -
            +
            diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/modal.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/modal.xsl index 8ef59c67e4..7147df7efb 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/modal.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/modal.xsl @@ -75,8 +75,8 @@ LIMIT 10

            Unlock the value of your Knowledge Graph with data-driven content and low code apps.

            Create structured content backed by live data, intuitively explore graph datasets, model and manage RDF data, control data quality and more. Without writing code.

            - Get started - Learn more + +

            @@ -84,7 +84,7 @@ LIMIT 10 - + @@ -121,7 +121,7 @@ LIMIT 10
            - + @@ -176,20 +176,20 @@ LIMIT 10
            - @@ -204,7 +204,7 @@ LIMIT 10 - + @@ -296,8 +296,8 @@ LIMIT 10
            - - @@ -422,7 +422,7 @@ LIMIT 10 - +
            @@ -479,7 +479,7 @@ LIMIT 10 -
            +
            @@ -632,7 +632,7 @@ LIMIT 10 - + @@ -672,7 +672,7 @@ LIMIT 10
            - + @@ -718,7 +718,7 @@ LIMIT 10 - + @@ -764,7 +764,8 @@ LIMIT 10 - + + @@ -783,6 +784,9 @@ LIMIT 10 + + +
            @@ -837,8 +841,8 @@ LIMIT 10 - - + + @@ -857,8 +861,11 @@ LIMIT 10 - @@ -877,12 +884,15 @@ LIMIT 10 'endpoint': sd:endpoint(), 'required': function($r as element()) as xs:boolean { $r/rdf:type/@rdf:resource = ('&dh;Container', '&dh;Item') } }"/> - + + @@ -915,11 +925,7 @@ LIMIT 10 - - - - - + @@ -1128,11 +1134,12 @@ LIMIT 10 - + + @@ -1528,7 +1535,16 @@ LIMIT 10 - + + @@ -2260,6 +2276,7 @@ LIMIT 10 map{ 'body': $body, 'types': $types, + 'forClass': $types, 'endpoint': sd:endpoint(), 'property-uris': distinct-values($body/rdf:RDF/*[@rdf:about = $about]/*/concat(namespace-uri(), local-name())), 'object-uris': distinct-values($body/rdf:RDF/*[not(rdf:type/@rdf:resource = $system-types)]/*/@rdf:resource[not(key('resources', .))]) @@ -2284,7 +2301,7 @@ LIMIT 10 on-failure="ldh:promise-failure#1"/> - + @@ -2294,9 +2311,7 @@ LIMIT 10 diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/navigation.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/navigation.xsl index b50df7fbbf..421f724237 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/navigation.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/navigation.xsl @@ -96,7 +96,7 @@ ORDER BY DESC(?created) - +
            @@ -107,59 +107,62 @@ ORDER BY DESC(?created) - -
            - - -
            + + + -
            -
            +
            diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl index 61e772a5b3..38152fdb37 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl @@ -221,9 +221,6 @@ extension-element-prefixes="ixsl" - - - diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/typeahead.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/typeahead.xsl index 0d4d1ea827..11159fde4a 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/typeahead.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/typeahead.xsl @@ -75,7 +75,7 @@ version="3.0" - + diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/document.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/document.xsl index b0c2719194..dffb61cef1 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/document.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/document.xsl @@ -120,7 +120,7 @@ extension-element-prefixes="ixsl" - +
            @@ -138,7 +138,7 @@ extension-element-prefixes="ixsl" - +
            @@ -153,7 +153,7 @@ extension-element-prefixes="ixsl" - + @@ -168,58 +168,52 @@ extension-element-prefixes="ixsl" -
            - + + +
            + - +
            + +
            -
            - - - -
            + + + + +
            -
            + - -
            - - -
            - -
            - -
            - -
            +
            + + -
            - - + + + + + +
            -
            +
            + + + + + + + +
            + + +
            + + + + + + + + + + +
            +
            +
            + @@ -390,28 +415,37 @@ extension-element-prefixes="ixsl" -
            - - +
            - - - - - -
            - - -
            -
            - @@ -562,7 +564,7 @@ extension-element-prefixes="ixsl" / - + @@ -573,7 +575,7 @@ extension-element-prefixes="ixsl" @@ -586,7 +588,7 @@ extension-element-prefixes="ixsl" - +
            @@ -605,7 +607,7 @@ extension-element-prefixes="ixsl" - +
            @@ -621,7 +623,7 @@ extension-element-prefixes="ixsl" - +
            @@ -656,6 +658,8 @@ extension-element-prefixes="ixsl" + + @@ -666,7 +670,7 @@ extension-element-prefixes="ixsl" - +
            @@ -676,17 +680,13 @@ extension-element-prefixes="ixsl" -
            -
            - + - - - - - -
            -
            + + + + +
            @@ -695,19 +695,22 @@ extension-element-prefixes="ixsl" - + -
            -
            -

            - - -

            -
            +
            + +
            @@ -737,12 +740,10 @@ extension-element-prefixes="ixsl" -
            -
            - - - -
            +
            + + +
            @@ -751,7 +752,7 @@ extension-element-prefixes="ixsl" Admin apps are identified by the 'admin.' subdomain prefix on lapp:origin() (nginx wildcard routing convention). --> - + @@ -777,7 +778,7 @@ extension-element-prefixes="ixsl" - + @@ -826,15 +827,15 @@ extension-element-prefixes="ixsl" - + - + - - + + @@ -851,12 +852,9 @@ extension-element-prefixes="ixsl" -
            -
            @@ -877,100 +875,16 @@ extension-element-prefixes="ixsl" - +
            -
            -
            - - - -
            -
            - - -
            -
            - - -
            -
            + + + + + + + +
            @@ -981,163 +895,161 @@ extension-element-prefixes="ixsl"
            - +
            - + - - - - - - - - - + - - - - - - - - -
            - -
            -
            -
            - - -
            - - - - - - - - - - - - - -
            -
            -
            - - -
            -
            - - - - - - - - -
            -
            - - -
            -
            -
            - -
            - - - - - - -
            - - - -
            + + + + + + + + + + +
            +
            + + +
            +
            + + + + + + + + +
            +
            + + +
            +
            @@ -1212,11 +1124,12 @@ extension-element-prefixes="ixsl" - - + + + - + @@ -1284,20 +1197,21 @@ extension-element-prefixes="ixsl"
            - + - + -
            @@ -1306,7 +1220,7 @@ extension-element-prefixes="ixsl" - + @@ -1316,19 +1230,19 @@ extension-element-prefixes="ixsl" - - - +
            @@ -1356,25 +1270,22 @@ extension-element-prefixes="ixsl" -
            - - +
            @@ -1388,7 +1299,7 @@ extension-element-prefixes="ixsl" - +
            @@ -1403,7 +1314,7 @@ extension-element-prefixes="ixsl" - +
            +
            diff --git a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/imports/default.xsl b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/imports/default.xsl index 0bcd56612a..afdb982f86 100644 --- a/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/imports/default.xsl +++ b/src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/imports/default.xsl @@ -509,7 +509,8 @@ exclude-result-prefixes="#all" - + + @@ -709,11 +710,11 @@ exclude-result-prefixes="#all"
            - + + + - - @@ -738,8 +739,11 @@ exclude-result-prefixes="#all" - - + + + + + @@ -884,7 +888,7 @@ exclude-result-prefixes="#all" - + @@ -896,12 +900,12 @@ exclude-result-prefixes="#all" -
            - + @@ -928,7 +932,7 @@ exclude-result-prefixes="#all" - + @@ -940,7 +944,7 @@ exclude-result-prefixes="#all" -